Merge branch 'refactor-multi-organisation' into multi-organisations-statics
LocationBasedServices/smartguide/pipeline/head This commit looks good
LocationBasedServices/smartguide/pipeline/head This commit looks good
# Conflicts: # webapp/src/app/modules/dashboard/dashboard.component.ts
This commit is contained in:
@@ -242,6 +242,7 @@
|
||||
}
|
||||
</section>
|
||||
|
||||
@if (selectedAnalyticalInstitutionId) {
|
||||
@if (
|
||||
euProjectStatusesLoading ||
|
||||
bmbfProjectStatusesLoading ||
|
||||
@@ -303,8 +304,8 @@
|
||||
diameter="64"></app-loading>
|
||||
</div>
|
||||
} @else if (
|
||||
euProjectStatusesError ||
|
||||
bmbfProjectStatusesError ||
|
||||
euProjectStatusesError &&
|
||||
bmbfProjectStatusesError &&
|
||||
dfgProjectStatusesError
|
||||
) {
|
||||
<p class="statistics-error">
|
||||
@@ -314,6 +315,17 @@
|
||||
} @else if (
|
||||
euProjectStatuses && bmbfProjectStatuses && dfgProjectStatuses
|
||||
) {
|
||||
@if (
|
||||
euProjectStatusesError ||
|
||||
bmbfProjectStatusesError ||
|
||||
dfgProjectStatusesError
|
||||
) {
|
||||
<p class="statistics-error">
|
||||
Projektstatusdaten für {{ failedProjectStatusSources() }} konnten
|
||||
nicht geladen werden. Die übrigen Daten werden weiterhin
|
||||
angezeigt.
|
||||
</p>
|
||||
}
|
||||
<app-eu-project-status-chart
|
||||
[statuses]="euProjectStatuses"
|
||||
[bmbfStatuses]="bmbfProjectStatuses"
|
||||
@@ -559,4 +571,5 @@
|
||||
}
|
||||
</section>
|
||||
}
|
||||
}
|
||||
</div>
|
||||
|
||||
@@ -145,8 +145,7 @@ export class DashboardComponent implements OnInit, AfterViewInit {
|
||||
dashboardToYear = this.topicTreemapMaxYear;
|
||||
dashboardInstitutions: DashboardInstitution[] = [];
|
||||
selectedDashboardInstitutionId = 'all';
|
||||
readonly defaultAnalyticalInstitutionId = 'I62318514';
|
||||
selectedAnalyticalInstitutionId = this.defaultAnalyticalInstitutionId;
|
||||
selectedAnalyticalInstitutionId = '';
|
||||
dashboardInstitutionsLoading = false;
|
||||
dashboardInstitutionsError = false;
|
||||
canScrollAnalyticalInstitutionTabsLeft = false;
|
||||
@@ -170,14 +169,6 @@ export class DashboardComponent implements OnInit, AfterViewInit {
|
||||
this.restoreDashboardPeriodState();
|
||||
this.loadDashboardInstitutions();
|
||||
this.loadStatistics();
|
||||
this.loadTopAuthors();
|
||||
this.loadTopicTreemap();
|
||||
this.loadDfgProjectTopics();
|
||||
this.loadEuProjectTopics();
|
||||
this.loadBundProjectTopics();
|
||||
this.loadEuProjectStatuses();
|
||||
this.loadBmbfProjectStatuses();
|
||||
this.loadDfgProjectStatuses();
|
||||
}
|
||||
|
||||
ngAfterViewInit(): void {
|
||||
@@ -210,14 +201,8 @@ export class DashboardComponent implements OnInit, AfterViewInit {
|
||||
this.selectedDashboardInstitutionId = restoredInstitution;
|
||||
this.loadStatistics();
|
||||
}
|
||||
const requestedAnalyticalInstitution =
|
||||
this.route.snapshot.queryParamMap.get('analyticalInstitution') ??
|
||||
this.defaultAnalyticalInstitutionId;
|
||||
const restoredAnalyticalInstitution = institutions.some(
|
||||
(institution) => institution.id === requestedAnalyticalInstitution,
|
||||
)
|
||||
? requestedAnalyticalInstitution
|
||||
: this.defaultAnalyticalInstitutionId;
|
||||
const restoredAnalyticalInstitution =
|
||||
restoredInstitution === 'all' ? '' : restoredInstitution;
|
||||
if (
|
||||
restoredAnalyticalInstitution !== this.selectedAnalyticalInstitutionId
|
||||
) {
|
||||
@@ -462,8 +447,21 @@ export class DashboardComponent implements OnInit, AfterViewInit {
|
||||
|
||||
onDashboardInstitutionChange(institutionId: string): void {
|
||||
this.selectedDashboardInstitutionId = institutionId;
|
||||
const analyticalInstitutionId =
|
||||
institutionId === 'all' ? '' : institutionId;
|
||||
const analyticalInstitutionChanged =
|
||||
analyticalInstitutionId !== this.selectedAnalyticalInstitutionId;
|
||||
this.selectedAnalyticalInstitutionId = analyticalInstitutionId;
|
||||
this.updateDashboardPeriodUrl();
|
||||
this.loadStatistics();
|
||||
if (analyticalInstitutionChanged) {
|
||||
if (analyticalInstitutionId) {
|
||||
this.reloadAnalyticalData();
|
||||
} else {
|
||||
// Invalidate pending requests when "Alle Institutionen" is selected.
|
||||
this.analyticalRequestId += 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
onAnalyticalInstitutionChange(institutionId: string): void {
|
||||
@@ -497,6 +495,15 @@ export class DashboardComponent implements OnInit, AfterViewInit {
|
||||
tabList.scrollLeft < maxScrollLeft - 1;
|
||||
}
|
||||
|
||||
failedProjectStatusSources(): string {
|
||||
const sources = [
|
||||
this.euProjectStatusesError ? 'EU' : undefined,
|
||||
this.bmbfProjectStatusesError ? 'Bund' : undefined,
|
||||
this.dfgProjectStatusesError ? 'DFG' : undefined,
|
||||
].filter((source): source is string => source !== undefined);
|
||||
return sources.join(' und ');
|
||||
}
|
||||
|
||||
onTopicTreemapNodeChange(nodeId: string | undefined): void {
|
||||
this.selectedTopicTreemapNode = nodeId;
|
||||
this.updateDashboardPeriodUrl();
|
||||
@@ -667,7 +674,7 @@ export class DashboardComponent implements OnInit, AfterViewInit {
|
||||
euTreemapNode: this.selectedEuTopicTreemapNode ?? null,
|
||||
bundTreemapNode: this.selectedBundTopicTreemapNode ?? null,
|
||||
institution: this.selectedDashboardInstitutionId,
|
||||
analyticalInstitution: this.selectedAnalyticalInstitutionId,
|
||||
analyticalInstitution: this.selectedAnalyticalInstitutionId || null,
|
||||
},
|
||||
queryParamsHandling: 'merge',
|
||||
replaceUrl: true,
|
||||
@@ -698,7 +705,11 @@ export class DashboardComponent implements OnInit, AfterViewInit {
|
||||
}
|
||||
|
||||
private reloadAnalyticalData(): void {
|
||||
if (!this.selectedAnalyticalInstitutionId) return;
|
||||
const requestId = ++this.analyticalRequestId;
|
||||
this.euProjectStatuses = undefined;
|
||||
this.bmbfProjectStatuses = undefined;
|
||||
this.dfgProjectStatuses = undefined;
|
||||
this.loadTopAuthors(requestId);
|
||||
this.loadTopicTreemap(requestId);
|
||||
this.loadDfgProjectTopics(requestId);
|
||||
@@ -897,6 +908,7 @@ export class DashboardComponent implements OnInit, AfterViewInit {
|
||||
error: () => {
|
||||
if (requestId === this.analyticalRequestId) {
|
||||
this.euProjectStatusesError = true;
|
||||
this.euProjectStatuses = this.emptyProjectStatuses();
|
||||
}
|
||||
},
|
||||
});
|
||||
@@ -926,6 +938,7 @@ export class DashboardComponent implements OnInit, AfterViewInit {
|
||||
error: () => {
|
||||
if (requestId === this.analyticalRequestId) {
|
||||
this.bmbfProjectStatusesError = true;
|
||||
this.bmbfProjectStatuses = this.emptyProjectStatuses();
|
||||
}
|
||||
},
|
||||
});
|
||||
@@ -955,11 +968,25 @@ export class DashboardComponent implements OnInit, AfterViewInit {
|
||||
error: () => {
|
||||
if (requestId === this.analyticalRequestId) {
|
||||
this.dfgProjectStatusesError = true;
|
||||
this.dfgProjectStatuses = this.emptyProjectStatuses();
|
||||
}
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
private emptyProjectStatuses(): EuProjectStatusStatistics {
|
||||
const institution = this.dashboardInstitutions.find(
|
||||
({ id }) => id === this.selectedAnalyticalInstitutionId,
|
||||
);
|
||||
return {
|
||||
institution_id: this.selectedAnalyticalInstitutionId,
|
||||
organization_name: institution?.display_name ?? '',
|
||||
ongoing: 0,
|
||||
upcoming: 0,
|
||||
completed: 0,
|
||||
};
|
||||
}
|
||||
|
||||
private loadTopicTreemap(analyticalRequestId = this.analyticalRequestId): void {
|
||||
if (this.dashboardFromYear > this.dashboardToYear) {
|
||||
this.topicTreemapLoading = false;
|
||||
|
||||
@@ -6,7 +6,7 @@ import {
|
||||
input,
|
||||
signal,
|
||||
} from '@angular/core';
|
||||
import { Institution } from '../../../api';
|
||||
import { AuthService, Institution } from '../../../api';
|
||||
import { PatentsService } from '../../../api/api/patents.service';
|
||||
import { MatCardModule } from '@angular/material/card';
|
||||
import { RouterModule } from '@angular/router';
|
||||
@@ -14,7 +14,6 @@ import { MatDividerModule } from '@angular/material/divider';
|
||||
import { MatIconModule } from '@angular/material/icon';
|
||||
import { MatButtonModule } from '@angular/material/button';
|
||||
import { DecimalPipe } from '@angular/common';
|
||||
import { CredentialService } from '../../services/credential.service';
|
||||
|
||||
@Component({
|
||||
selector: 'app-institution-card',
|
||||
@@ -30,7 +29,7 @@ import { CredentialService } from '../../services/credential.service';
|
||||
styleUrl: './app-institution-card.component.scss',
|
||||
})
|
||||
export class AppInstitutionCardComponent {
|
||||
private readonly credentialService = inject(CredentialService);
|
||||
private readonly authService = inject(AuthService);
|
||||
private readonly patentsApi = inject(PatentsService);
|
||||
|
||||
institution = input.required<Institution>();
|
||||
@@ -45,15 +44,8 @@ export class AppInstitutionCardComponent {
|
||||
return 'Unbekannte Institution';
|
||||
});
|
||||
|
||||
isOwnInstitution = computed(() => {
|
||||
const institutionId = this.stripOpenAlexId(this.institution().id);
|
||||
if (!institutionId) return false;
|
||||
|
||||
const effectiveInstitutionId =
|
||||
this.credentialService.effectiveInstitutionId();
|
||||
|
||||
return institutionId === effectiveInstitutionId;
|
||||
});
|
||||
private readonly isOwnInstitutionSignal = signal(false);
|
||||
isOwnInstitution = this.isOwnInstitutionSignal.asReadonly();
|
||||
|
||||
// The "Patente" action only makes sense once org_patents has been indexed
|
||||
// for this institution (currently a manual, per-institution process), so
|
||||
@@ -65,9 +57,14 @@ export class AppInstitutionCardComponent {
|
||||
constructor() {
|
||||
effect(() => {
|
||||
const id = this.stripOpenAlexId(this.institution().id);
|
||||
this.isOwnInstitutionSignal.set(false);
|
||||
this.hasPatentsSignal.set(false);
|
||||
if (!id) return;
|
||||
|
||||
this.authService.canFetchGdprRelevantData(undefined, id).subscribe({
|
||||
next: (isAllowed) => this.isOwnInstitutionSignal.set(isAllowed),
|
||||
});
|
||||
|
||||
this.patentsApi
|
||||
.getOrgPatentsByInstitution(id, undefined, 0, 0)
|
||||
.subscribe({
|
||||
|
||||
Reference in New Issue
Block a user