Skip to content

Commit

Permalink
Add configurations for donors label and button urls
Browse files Browse the repository at this point in the history
  • Loading branch information
edlu77 committed Jan 26, 2024
1 parent 7fe920f commit 9868690
Show file tree
Hide file tree
Showing 5 changed files with 77 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,14 @@ export class AppWebComponent extends BaseWebComponent {
@Input() useRemoteApi: string | boolean;
@Input() remoteApiEndpoint: string;

@Input() donorLabel: string;
@Input() ruiUrl: string;
@Input() euiUrl: string;
@Input() asctbUrl: string;
@Input() hraPortalUrl: string;
@Input() onlineCourseUrl: string;
@Input() paperUrl: string;

@Output() readonly sexChange = new EventEmitter<'Male' | 'Female'>();
@Output() readonly sideChange = new EventEmitter<'Left' | 'Right'>();
@Output() nodeClicked = new EventEmitter();
Expand Down
10 changes: 9 additions & 1 deletion projects/ccf-organ-info/src/app/app.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,14 @@
<div class="right" #right>
<ccf-stats-list [statsLabel]="statsLabel$ | async" [stats]="stats$ | async">
</ccf-stats-list>
<ccf-link-cards></ccf-link-cards>
<ccf-link-cards
[ruiUrl]="ruiUrl$ | async"
[euiUrl]="euiUrl$ | async"
[asctbUrl]="asctbUrl$ | async"
[hraPortalUrl]="hraPortalUrl$ | async"
[onlineCourseUrl]="onlineCourseUrl$ | async"
[paperUrl]="paperUrl$ | async"
>
</ccf-link-cards>
</div>
</div>
36 changes: 30 additions & 6 deletions projects/ccf-organ-info/src/app/app.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { SpatialSceneNode } from 'ccf-body-ui';
import { AggregateResult, SpatialEntity, TissueBlockResult } from 'ccf-database';
import { GlobalConfigState, OrganInfo } from 'ccf-shared';
import { GoogleAnalyticsService } from 'ngx-google-analytics';
import { Observable, of } from 'rxjs';
import { Observable, combineLatest, of } from 'rxjs';
import { map, shareReplay, startWith, switchMap, tap } from 'rxjs/operators';

import { OrganLookupService } from './core/services/organ-lookup/organ-lookup.service';
Expand All @@ -15,6 +15,13 @@ interface GlobalConfig {
side?: string;
sex?: 'Both' | 'Male' | 'Female';
highlightProviders?: string[];
donorLabel?: string;
ruiUrl?: string;
euiUrl?: string;
asctbUrl?: string;
hraPortalUrl?: string;
onlineCourseUrl?: string;
paperUrl?: string;
}

const EMPTY_SCENE = [
Expand All @@ -39,13 +46,23 @@ export class AppComponent implements AfterViewInit {
readonly side$ = this.configState.getOption('side');
readonly filter$ = this.configState.getOption('highlightProviders')
.pipe(map((providers: string[]) => ({ tmc: providers })));
readonly donorLabel$ = this.configState.getOption('donorLabel');
readonly ruiUrl$ = this.configState.getOption('ruiUrl');
readonly euiUrl$ = this.configState.getOption('euiUrl');
readonly asctbUrl$ = this.configState.getOption('asctbUrl');
readonly hraPortalUrl$ = this.configState.getOption('hraPortalUrl');
readonly onlineCourseUrl$ = this.configState.getOption('onlineCourseUrl');
readonly paperUrl$ = this.configState.getOption('paperUrl');

readonly organInfo$: Observable<OrganInfo | undefined>;
readonly organ$: Observable<SpatialEntity | undefined>;
readonly scene$: Observable<SpatialSceneNode[]>;
readonly stats$: Observable<AggregateResult[]>;
readonly statsLabel$: Observable<string>;
readonly blocks$: Observable<TissueBlockResult[]>;

stats: AggregateResult[] = [];

private latestConfig: Immutable<GlobalConfig> = {};
private latestOrganInfo?: OrganInfo;

Expand Down Expand Up @@ -92,11 +109,18 @@ export class AppComponent implements AfterViewInit {
) : of(EMPTY_SCENE as SpatialSceneNode[]))
);

this.stats$ = this.organ$.pipe(
switchMap(organ => organ && this.latestOrganInfo ? lookup.getOrganStats(
this.latestOrganInfo,
organ.sex
) : of([]))
this.stats$ = combineLatest([this.organ$, this.donorLabel$]).pipe(
switchMap(([organ, donorLabel]) =>
organ && this.latestOrganInfo ?
lookup.getOrganStats(this.latestOrganInfo, organ.sex).pipe(
map(agg =>
agg.map(result =>
donorLabel && result.label === 'Donors' ?
{ ...result, label: donorLabel } : result
)
)
) : of([])
)
);

this.statsLabel$ = this.organ$.pipe(
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { ChangeDetectionStrategy, Component } from '@angular/core';
import { ChangeDetectionStrategy, Component, Input, OnInit } from '@angular/core';

interface LinkCard {
body: string;
Expand All @@ -12,7 +12,14 @@ interface LinkCard {
styleUrls: ['./link-cards.component.scss'],
changeDetection: ChangeDetectionStrategy.OnPush
})
export class LinkCardsComponent {
export class LinkCardsComponent implements OnInit {
@Input() ruiUrl: string;
@Input() euiUrl: string;
@Input() asctbUrl: string;
@Input() hraPortalUrl: string;
@Input() onlineCourseUrl: string;
@Input() paperUrl: string;

linkCards: LinkCard[] = [
{
body: 'Add tissue blocks using the HRA Registration User Interface (RUI).',
Expand Down Expand Up @@ -49,6 +56,13 @@ export class LinkCardsComponent {
}
];

ngOnInit() {
const linkUrls = [this.ruiUrl, this.euiUrl, this.asctbUrl];
const deepDivesUrls = [this.hraPortalUrl, this.onlineCourseUrl, this.paperUrl];
this.linkCards = this.linkCards.map((card, index) => ({ ...card, buttonUrl: linkUrls[index] ?? card.buttonUrl }));
this.deepDives = this.deepDives.map((card, index) => ({ ...card, buttonUrl: deepDivesUrls[index] ?? card.buttonUrl }));
}

goToURL(url: string): void {
window.open(url, '_blank');
}
Expand Down
14 changes: 14 additions & 0 deletions projects/ccf-organ-info/src/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
use-remote-api="true"
highlight-providers="TMC-Vanderbilt"
></ccf-organ-info>

<!-- <ccf-organ-info
organ-iri="http://purl.obolibrary.org/obo/UBERON_0004538"
hubmap-data-service="search-api"
Expand All @@ -24,6 +25,19 @@
hubmap-asset-url="https://assets.hubmapconsortium.org"
highlight-providers="TMC-Vanderbilt"
></ccf-organ-info> -->

<!-- <ccf-organ-info
organ-iri="http://purl.obolibrary.org/obo/UBERON_0002113"
use-remote-api="true"
highlight-providers="TMC-Vanderbilt"
donor-label="Sources"
rui-url=""
eui-url=""
asctb-url=""
hra-portal-url=""
online-course-url=""
paper-url=""
></ccf-organ-info> -->
</body>

</html>

0 comments on commit 9868690

Please sign in to comment.