added organization badge to person profile
This commit is contained in:
@@ -29,27 +29,61 @@
|
||||
}}</mat-icon>
|
||||
</button>
|
||||
</div>
|
||||
@if (resolvedInstitution(); as inst) {
|
||||
@if (resolvedInstitution() || verifiedOrganizations().length > 0) {
|
||||
<div class="institution-line">
|
||||
<app-institution-chip
|
||||
[institution]="inst"
|
||||
size="normal"
|
||||
[showIcon]="true"
|
||||
[isClickable]="false" />
|
||||
@if (secondaryInstitutions().length > 0) {
|
||||
<button
|
||||
type="button"
|
||||
class="more-institutions-btn"
|
||||
[appComponentTooltip]="PersonInstitutionTooltipListComponent"
|
||||
[tooltipInputs]="{ institutions: secondaryInstitutions() }"
|
||||
[attr.aria-label]="
|
||||
secondaryInstitutions().length + ' weitere Institutionen'
|
||||
">
|
||||
<mat-icon class="more-info-icon">{{ MORE_INFO_ICON }}</mat-icon>
|
||||
<span class="count-text"
|
||||
>+{{ secondaryInstitutions().length }}</span
|
||||
>
|
||||
</button>
|
||||
@if (resolvedInstitution(); as inst) {
|
||||
<app-institution-chip
|
||||
[institution]="inst"
|
||||
size="normal"
|
||||
[showIcon]="true"
|
||||
[isClickable]="false" />
|
||||
@if (secondaryInstitutions().length > 0) {
|
||||
<button
|
||||
type="button"
|
||||
class="more-institutions-btn"
|
||||
[appComponentTooltip]="PersonInstitutionTooltipListComponent"
|
||||
[tooltipInputs]="{ institutions: secondaryInstitutions() }"
|
||||
[attr.aria-label]="
|
||||
secondaryInstitutions().length + ' weitere Institutionen'
|
||||
">
|
||||
<mat-icon class="more-info-icon">{{ MORE_INFO_ICON }}</mat-icon>
|
||||
<span class="count-text"
|
||||
>+{{ secondaryInstitutions().length }}</span
|
||||
>
|
||||
</button>
|
||||
}
|
||||
}
|
||||
@for (org of verifiedOrganizations(); track $index) {
|
||||
@if (canOpenOrganizationHierarchy(org)) {
|
||||
<button
|
||||
type="button"
|
||||
class="verified-org-chip"
|
||||
[matTooltip]="
|
||||
'Verifizierte Organisation: ' +
|
||||
org.org_name +
|
||||
' – Hierarchie öffnen'
|
||||
"
|
||||
matTooltipPosition="right"
|
||||
[matTooltipShowDelay]="250"
|
||||
[attr.aria-label]="
|
||||
'Verifizierte Organisation: ' +
|
||||
org.org_name +
|
||||
'. Hierarchie öffnen.'
|
||||
"
|
||||
(click)="openOrganizationHierarchy(org)">
|
||||
<mat-icon>{{ VERIFIED_ICON }}</mat-icon>
|
||||
<span>{{ org.org_name }}</span>
|
||||
</button>
|
||||
} @else {
|
||||
<span
|
||||
class="verified-org-chip static"
|
||||
[matTooltip]="'Verifizierte Organisation: ' + org.org_name"
|
||||
matTooltipPosition="right"
|
||||
[matTooltipShowDelay]="250">
|
||||
<mat-icon>{{ VERIFIED_ICON }}</mat-icon>
|
||||
<span>{{ org.org_name }}</span>
|
||||
</span>
|
||||
}
|
||||
}
|
||||
</div>
|
||||
}
|
||||
|
||||
@@ -146,6 +146,55 @@
|
||||
font-size: 13px;
|
||||
}
|
||||
|
||||
.verified-org-chip {
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
gap: 6px;
|
||||
min-height: 24px;
|
||||
max-width: 100%;
|
||||
padding: 2px 10px;
|
||||
border: 1px solid var(--sg-border);
|
||||
border-radius: 999px;
|
||||
background: var(--sg-surface-muted);
|
||||
color: var(--sg-text);
|
||||
font-size: 13px;
|
||||
font-weight: 600;
|
||||
line-height: 1.2;
|
||||
text-decoration: none;
|
||||
transition:
|
||||
border-color 0.15s,
|
||||
background 0.15s;
|
||||
|
||||
span {
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
||||
mat-icon {
|
||||
flex: 0 0 auto;
|
||||
width: 16px;
|
||||
height: 16px;
|
||||
font-size: 16px;
|
||||
color: var(--sg-success);
|
||||
}
|
||||
|
||||
&[type='button'] {
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
&[type='button']:hover,
|
||||
&[type='button']:focus-visible {
|
||||
border-color: var(--sg-success);
|
||||
background: var(--sg-primary-soft);
|
||||
outline: none;
|
||||
}
|
||||
|
||||
&.static {
|
||||
cursor: default;
|
||||
}
|
||||
}
|
||||
|
||||
.stats-line {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
|
||||
@@ -39,12 +39,17 @@ import { CareerStageChipComponent } from '../../shared/ui/career-stage-chip/care
|
||||
import { AppInstitutionChipComponent } from '../../shared/ui/app-institution-chip/app-institution-chip.component';
|
||||
import { ComponentTooltipDirective } from '../../directives/component-tooltip.directive';
|
||||
import { PersonInstitutionTooltipListComponent } from '../../shared/ui/person-institution-tooltip-list/person-institution-tooltip-list.component';
|
||||
import { DehydratedInstitution, WorksService } from '../../api';
|
||||
import {
|
||||
DehydratedInstitution,
|
||||
VerifiedOrganization,
|
||||
WorksService,
|
||||
} from '../../api';
|
||||
import { LoadingComponent } from '../../shared/ui/loading/loading.component';
|
||||
import { PersonBioResolved } from '../../resolvers/person-bio.resolver';
|
||||
import { PersonDataResolved } from '../../resolvers/person.resolver';
|
||||
import { BookmarkService } from '../../shared/services/bookmark.service';
|
||||
import { AuthorAffiliationService } from '../../shared/services/author-affiliation.service';
|
||||
import { CredentialService } from '../../shared/services/credential.service';
|
||||
import { collaborationGraphQueryParamKeys } from '../../resolvers/collaboration-graph.resolver';
|
||||
import { workQueryParamKeys } from '../../resolvers/work-page.resolver';
|
||||
import {
|
||||
@@ -73,6 +78,16 @@ import {
|
||||
} from '../../shared/ui/icons';
|
||||
import { PageContainerComponent } from '../../shared/ui/page-container/page-container.component';
|
||||
|
||||
/** Accepts raw and full-URL OpenAlex IDs, e.g. `I123` or `.../I123`. */
|
||||
const normalizeInstitutionId = (
|
||||
value: string | null | undefined,
|
||||
): string =>
|
||||
(value ?? '')
|
||||
.trim()
|
||||
.replace(/^https:\/\/openalex\.org\//i, '')
|
||||
.replace(/\/+$/, '')
|
||||
.toUpperCase();
|
||||
|
||||
@Component({
|
||||
selector: 'app-person',
|
||||
imports: [
|
||||
@@ -116,6 +131,7 @@ export class PersonComponent {
|
||||
private readonly destroyRef = inject(DestroyRef);
|
||||
readonly bookmarkService = inject(BookmarkService);
|
||||
private readonly authorAffiliationService = inject(AuthorAffiliationService);
|
||||
private readonly credentialService = inject(CredentialService);
|
||||
|
||||
canFetchGdprRelevantData = input.required<boolean>();
|
||||
|
||||
@@ -206,6 +222,33 @@ export class PersonComponent {
|
||||
.subscribe();
|
||||
}
|
||||
|
||||
canOpenOrganizationHierarchy(organization: VerifiedOrganization): boolean {
|
||||
return (
|
||||
this.canOpenVerifiedOrganizationHierarchy() &&
|
||||
!!organization.org_uri &&
|
||||
(organization.org_hierarchy_path?.length ?? 0) > 0
|
||||
);
|
||||
}
|
||||
|
||||
openOrganizationHierarchy(organization: VerifiedOrganization): void {
|
||||
if (!this.canOpenOrganizationHierarchy(organization)) return;
|
||||
void this.router.navigate(['/hierarchy'], {
|
||||
queryParams: {
|
||||
orgFocus: organization.org_uri,
|
||||
orgFocusPath: JSON.stringify(organization.org_hierarchy_path ?? []),
|
||||
hierarchyExpanded: true,
|
||||
organizationExpanded: false,
|
||||
orgUrl: null,
|
||||
orgName: null,
|
||||
orgExpanded: null,
|
||||
orgSelectionCategory: null,
|
||||
orgSelectionIndex: null,
|
||||
classifiedCategory: null,
|
||||
classifiedPage: null,
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
readonly personBio = toSignal(
|
||||
combineLatest([this.activatedRoute.data, toObservable(this.person)]).pipe(
|
||||
switchMap(([data, person]) => {
|
||||
@@ -249,6 +292,35 @@ export class PersonComponent {
|
||||
readonly secondaryInstitutions = computed<DehydratedInstitution[]>(() =>
|
||||
this.authorAffiliationService.resolveSecondaryInstitutions(this.person()),
|
||||
);
|
||||
readonly verifiedOrganizationData = toSignal(
|
||||
this.activatedRoute.data.pipe(
|
||||
switchMap((data) => {
|
||||
const resolved = data['personData'] as PersonDataResolved | undefined;
|
||||
return resolved?.verifiedOrganizations$ ?? of(null);
|
||||
}),
|
||||
),
|
||||
{ initialValue: null },
|
||||
);
|
||||
readonly verifiedOrganizations = computed(
|
||||
() => this.verifiedOrganizationData()?.organizations ?? [],
|
||||
);
|
||||
/**
|
||||
* Verified organizations come from one institution's OrgMiner data. Only
|
||||
* users of that institution have a hierarchy where the nodes can be found.
|
||||
*/
|
||||
readonly canOpenVerifiedOrganizationHierarchy = computed(() => {
|
||||
const userInstitutionId = normalizeInstitutionId(
|
||||
this.credentialService.effectiveInstitutionId(),
|
||||
);
|
||||
const dataInstitutionId = normalizeInstitutionId(
|
||||
this.verifiedOrganizationData()?.institution_id,
|
||||
);
|
||||
return (
|
||||
!!userInstitutionId &&
|
||||
!!dataInstitutionId &&
|
||||
userInstitutionId === dataInstitutionId
|
||||
);
|
||||
});
|
||||
readonly worksCount = computed(() => this.person()?.works_count ?? null);
|
||||
readonly citedByCount = computed(() => this.person()?.cited_by_count ?? null);
|
||||
readonly h_index = computed(
|
||||
|
||||
@@ -4,6 +4,7 @@ import {
|
||||
CompanyConnectionsService,
|
||||
CustomAuthorsListResponse,
|
||||
PersonsService,
|
||||
VerifiedOrganizationsResponse,
|
||||
} from '../api';
|
||||
import {
|
||||
Observable,
|
||||
@@ -20,6 +21,7 @@ import { toObservable } from '@angular/core/rxjs-interop';
|
||||
export interface PersonDataResolved {
|
||||
personData$: Observable<CustomAuthorsListResponse | null>;
|
||||
companyConnectionsAvailable$: Observable<boolean>;
|
||||
verifiedOrganizations$: Observable<VerifiedOrganizationsResponse | null>;
|
||||
}
|
||||
|
||||
export const personResolver: ResolveFn<PersonDataResolved> = (route, state) => {
|
||||
@@ -38,6 +40,7 @@ export const personResolver: ResolveFn<PersonDataResolved> = (route, state) => {
|
||||
return {
|
||||
personData$: of(null),
|
||||
companyConnectionsAvailable$: of(false),
|
||||
verifiedOrganizations$: of(null),
|
||||
};
|
||||
}
|
||||
|
||||
@@ -51,6 +54,16 @@ export const personResolver: ResolveFn<PersonDataResolved> = (route, state) => {
|
||||
shareReplay(1),
|
||||
);
|
||||
|
||||
const verifiedOrganizations$ = personsService
|
||||
.getVerifiedOrganizations(authorId)
|
||||
.pipe(
|
||||
catchError((err) => {
|
||||
console.error('Failed to load verified organizations:', err);
|
||||
return of(null);
|
||||
}),
|
||||
shareReplay(1),
|
||||
);
|
||||
|
||||
const companyConnectionsAvailable$ = toObservable(
|
||||
credentialService.effectiveInstitutionId,
|
||||
).pipe(
|
||||
@@ -76,5 +89,5 @@ export const personResolver: ResolveFn<PersonDataResolved> = (route, state) => {
|
||||
shareReplay({ bufferSize: 1, refCount: true }),
|
||||
);
|
||||
|
||||
return { personData$, companyConnectionsAvailable$ };
|
||||
return { personData$, companyConnectionsAvailable$, verifiedOrganizations$ };
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user