70 lines
2.3 KiB
TypeScript
70 lines
2.3 KiB
TypeScript
import { DecimalPipe } from '@angular/common';
|
|
import { Component, computed, input } from '@angular/core';
|
|
import { STACKED_BAR_CHART_ICON } from '../../../../shared/ui/icons';
|
|
import { LoadingComponent } from '../../../../shared/ui/loading/loading.component';
|
|
import {
|
|
BmbfProjectStatusStatistics,
|
|
DfgProjectStatusStatistics,
|
|
EuProjectStatusStatistics,
|
|
} from '../../dashboard-statistics.service';
|
|
import { EuProjectStatusChartComponent } from '../eu-project-status-chart/eu-project-status-chart.component';
|
|
|
|
@Component({
|
|
selector: 'app-dashboard-project-status',
|
|
imports: [DecimalPipe, EuProjectStatusChartComponent, LoadingComponent],
|
|
templateUrl: './dashboard-project-status.component.html',
|
|
styleUrl: './dashboard-project-status.component.scss',
|
|
})
|
|
export class DashboardProjectStatusComponent {
|
|
readonly active = input(false);
|
|
readonly euStatuses = input<EuProjectStatusStatistics>();
|
|
readonly bundStatuses = input<BmbfProjectStatusStatistics>();
|
|
readonly dfgStatuses = input<DfgProjectStatusStatistics>();
|
|
readonly euLoading = input(false);
|
|
readonly bundLoading = input(false);
|
|
readonly dfgLoading = input(false);
|
|
readonly euError = input(false);
|
|
readonly bundError = input(false);
|
|
readonly dfgError = input(false);
|
|
|
|
readonly loadingIcon = STACKED_BAR_CHART_ICON;
|
|
readonly loading = computed(
|
|
() => this.euLoading() || this.bundLoading() || this.dfgLoading(),
|
|
);
|
|
readonly allFailed = computed(
|
|
() => this.euError() && this.bundError() && this.dfgError(),
|
|
);
|
|
readonly failedSources = computed(() =>
|
|
[
|
|
this.euError() ? 'EU' : undefined,
|
|
this.bundError() ? 'Bund' : undefined,
|
|
this.dfgError() ? 'DFG' : undefined,
|
|
]
|
|
.filter((source): source is string => source !== undefined)
|
|
.join(' und '),
|
|
);
|
|
readonly statusData = computed(() => {
|
|
const eu = this.euStatuses();
|
|
const bund = this.bundStatuses();
|
|
const dfg = this.dfgStatuses();
|
|
return eu && bund && dfg ? { eu, bund, dfg } : undefined;
|
|
});
|
|
readonly shouldDisplay = computed(
|
|
() =>
|
|
this.active() &&
|
|
(this.loading() ||
|
|
this.euError() ||
|
|
this.bundError() ||
|
|
this.dfgError() ||
|
|
Boolean(this.statusData())),
|
|
);
|
|
|
|
total(statuses: {
|
|
ongoing: number;
|
|
upcoming: number;
|
|
completed: number;
|
|
}): number {
|
|
return statuses.ongoing + statuses.upcoming + statuses.completed;
|
|
}
|
|
}
|