Skip to content

Commit 9fc7186

Browse files
committed
feat: Make no team selection possible on statistics #1675
1 parent 4fb328f commit 9fc7186

File tree

6 files changed

+25
-18
lines changed

6 files changed

+25
-18
lines changed

backend/src/main/java/ch/puzzle/okr/controller/EvaluationViewController.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ public EvaluationViewController(EvaluationViewMapper evaluationViewMapper,
3737
@ApiResponse(responseCode = "404", description = "The quarter or one of the teams were not found", content = @Content),
3838
@ApiResponse(responseCode = "401", description = "Not Authorized", content = @Content) })
3939
@GetMapping("")
40-
public ResponseEntity<EvaluationDto> getEvaluation(@RequestParam(name = "team")
40+
public ResponseEntity<EvaluationDto> getEvaluation(@RequestParam(name = "team", required = false)
4141
@Parameter(description = "List of Team ids the statistics are requested for") List<Long> teamIds,
4242
@RequestParam(name = "quarter")
4343
@Parameter(description = "Quarter id the statistics are requested for ") Long quarterId) {

backend/src/main/java/ch/puzzle/okr/service/validation/EvaluationViewValidationService.java

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -15,22 +15,18 @@ public class EvaluationViewValidationService
1515
ValidationBase<EvaluationView, RowId, EvaluationViewRepository, EvaluationViewPersistenceService> {
1616

1717
private final QuarterValidationService quarterValidationService;
18-
private final TeamValidationService teamValidationService;
1918

2019
EvaluationViewValidationService(EvaluationViewPersistenceService persistenceService,
21-
QuarterValidationService quarterValidationService,
22-
TeamValidationService teamValidationService) {
20+
QuarterValidationService quarterValidationService) {
2321
super(persistenceService);
2422
this.quarterValidationService = quarterValidationService;
25-
this.teamValidationService = teamValidationService;
2623
}
2724

2825
public void validateOnGet(TeamQuarterFilter filter) {
29-
if (filter.quarterId() == null || filter.teamIds().isEmpty()) {
26+
if (filter.quarterId() == null) {
3027
throw new OkrResponseStatusException(HttpStatus.BAD_REQUEST,
31-
"Es muss mindestens 1 Team und 1 Quartal ausgewählt sein");
28+
"Es muss mindestens 1 Quartal ausgewählt sein");
3229
}
33-
filter.teamIds().forEach(teamValidationService::validateOnGet);
3430
quarterValidationService.validateOnGet(filter.quarterId());
3531
}
3632

frontend/src/app/shared/application-page/application-page.component.html

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,8 @@
66
>
77
<!-- <ng-content select="content"></ng-content>-->
88
<ng-content></ng-content>
9-
<div *ngIf="(elements$ | async)?.length === 0" class="d-flex align-items-center flex-column pt-5 gap-5">
9+
@if ((elements$ | async)?.length === 0 || getFilterPageChange().teamIds.length === 0) {
10+
<div class="d-flex align-items-center flex-column pt-5 gap-5">
1011
<p id="no-team-text">Kein Team ausgewählt</p>
1112
<img
1213
src="{{ backgroundLogoSrc$ | async }}"
@@ -15,5 +16,6 @@
1516
class="puzzle-logo"
1617
/>
1718
</div>
19+
}
1820
</div>
1921
<router-outlet></router-outlet>

frontend/src/app/statistics/statistics-information/statistics-information.component.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,7 @@ export class StatisticsInformationComponent {
2020
@Input() maxHeightInPx = 50;
2121

2222
get chartHeight(): string {
23-
const percentage = this.chartValue / this.maxHeightInPx * 100;
24-
const heightInPx = percentage * this.maxHeightInPx;
23+
const heightInPx = this.chartValue * this.maxHeightInPx;
2524
return heightInPx + 'px';
2625
}
2726
}

frontend/src/app/statistics/statistics.component.html

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -20,18 +20,21 @@ <h1> Auswertung </h1>
2020
Quartal
2121
<app-quarter-filter [showBacklog]="false"></app-quarter-filter>
2222
</div>
23-
<app-team-filter [minTeams]="1"></app-team-filter>
23+
<app-team-filter></app-team-filter>
2424
</div>
2525

2626

27-
<div *ngIf="statistics| async as statistics;" class="d-flex flex-column ">
27+
@if (activeFilter?.teamIds?.length != 0) {
28+
@if (statistics | async; as statistics) {
29+
<div class="d-flex flex-column ">
30+
@if (statistics.objectiveAmount == 0 && statistics.keyResultAmount == 0) {
2831
<div
2932
class="alert alert-warning bg-warning-subtle"
30-
*ngIf="statistics.objectiveAmount ==0 && statistics.keyResultAmount ==0"
3133
[attr.data-testId]="'no-data-banner'"
3234
>
3335
Für dieses Team ist im ausgewählten Zeitraum kein Objective vorhanden.
3436
</div>
37+
}
3538
<div class="row row-cols-1 row-cols-md-2 row-cols-xxl-3 g-4">
3639
<app-statistics-card [title]="'Objectives und Key Results'" [attr.data-testId]="'objectives-key-results'">
3740
<app-statistics-information [topContent]="'Objectives'"> {{ statistics.objectiveAmount }}
@@ -74,9 +77,9 @@ <h1> Auswertung </h1>
7477
</app-statistics-information>
7578
</app-statistics-card>
7679

80+
@if (krRelation(statistics.keyResultsMetricAmount, statistics.keyResultsOrdinalAmount); as relation) {
7781
<app-statistics-card
7882
[attr.data-testId]="'kr-type-relation'"
79-
*ngIf="krRelation(statistics.keyResultsMetricAmount, statistics.keyResultsOrdinalAmount) as relation"
8083
[title]="'Verhältnis metrische vs. ordinale Key Results'"
8184
[barProgress]="relation.metric"
8285
[barColorPreset]="'relation'"
@@ -88,12 +91,13 @@ <h1> Auswertung </h1>
8891
{{ statistics.keyResultsOrdinalAmount }}
8992
</app-statistics-information>
9093
</app-statistics-card>
94+
}
9195

96+
@if (krProgressRelation(statistics); as relation) {
9297
<app-statistics-card
9398
[attr.data-testId]="'kr-progress-relation'"
9499
[title]="'Verteilung der Key Results'"
95100
[subtitle]="'Nur eingecheckte Key Results berücksichtigt'"
96-
*ngIf="krProgressRelation(statistics) as relation"
97101
>
98102
<app-statistics-information
99103
[topContent]="statistics.keyResultsInFailAmount"
@@ -132,8 +136,11 @@ <h1> Auswertung </h1>
132136
{{ relation.stretch | percent : '1.0-1' }}
133137
</app-statistics-information>
134138
</app-statistics-card>
139+
}
135140
</div>
136141
</div>
142+
}
143+
}
137144
</div>
138145

139146
</app-application-page>

frontend/src/app/statistics/statistics.component.ts

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,12 @@ export class StatisticsComponent {
1414

1515
statistics = new Observable<Statistics>();
1616

17-
loadOverview(filterpage: FilterPageChange) {
17+
activeFilter: FilterPageChange | undefined;
18+
19+
loadOverview(filterPage: FilterPageChange) {
20+
this.activeFilter = filterPage;
1821
this.statistics = this.evaluationService
19-
.getStatistics(filterpage.quarterId, filterpage.teamIds)
22+
.getStatistics(filterPage.quarterId, filterPage.teamIds)
2023
.pipe(catchError(() => {
2124
return EMPTY;
2225
}));

0 commit comments

Comments
 (0)