This commit is contained in:
@@ -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