src/app/shared/components/spatial-search-ui-behavior/spatial-search-ui-behavior.component.ts
Behavioral component for Spatial Search UI
changeDetection | ChangeDetectionStrategy.OnPush |
selector | ccf-spatial-search-ui-behavior |
templateUrl | ./spatial-search-ui-behavior.component.html |
Properties |
|
Methods |
constructor(dialogRef: MatDialogRef<SpatialSearchUiComponent>, dialog: MatDialog, infoService: InfoButtonService, globalConfig: GlobalConfigState
|
|||||||||||||||
Parameters :
|
addSpatialSearch |
addSpatialSearch()
|
Decorators :
@Dispatch()
|
Adds a new spatial search and closes the spatial search UI
Returns :
GenerateSpatialSearch
spatial search |
close |
close()
|
Closes spatial search UI
Returns :
void
|
launchInfoDialog | ||||||||
launchInfoDialog(data: PanelData)
|
||||||||
Launchs info dialog with the input data
Parameters :
Returns :
void
|
onDialogButtonClick |
onDialogButtonClick()
|
Updates dialog with spatial search information
Returns :
void
|
openSpatialSearchConfig |
openSpatialSearchConfig()
|
Closes the spatial search UI and opens spatial search config
Returns :
void
|
Readonly anatomicalStructures$ |
Type : Observable<TermResult[]>
|
Decorators :
@Select(SpatialSearchUiSelectors.anatomicalStructures)
|
baseHref |
Type : string
|
Default value : ''
|
Readonly cellTypes$ |
Type : Observable<TermResult[]>
|
Decorators :
@Select(SpatialSearchUiSelectors.cellTypes)
|
Readonly defaultPosition$ |
Type : Observable<Position>
|
Decorators :
@Select(SpatialSearchUiSelectors.defaultPosition)
|
Public dialog |
Type : MatDialog
|
Readonly moveToNode |
Default value : actionAsFn(MoveToNode)
|
Decorators :
@Dispatch()
|
Readonly organ$ |
Type : Observable<OrganInfo | undefined>
|
Decorators :
@Select(SpatialSearchUiSelectors.organ)
|
panelData |
Type : PanelData
|
Data to be displayed in the info panel |
Readonly position$ |
Type : Observable<Position>
|
Decorators :
@Select(SpatialSearchUiSelectors.position)
|
Readonly radius$ |
Type : Observable<number>
|
Decorators :
@Select(SpatialSearchUiSelectors.radius)
|
Readonly radiusSettings$ |
Type : Observable<RadiusSettings>
|
Decorators :
@Select(SpatialSearchUiSelectors.radiusSettings)
|
Readonly resetPosition |
Default value : actionAsFn(ResetPosition)
|
Decorators :
@Dispatch()
|
Readonly resetRadius |
Default value : actionAsFn(ResetRadius)
|
Decorators :
@Dispatch()
|
Readonly scene$ |
Type : Observable<SpatialSceneNode[]>
|
Decorators :
@Select(SpatialSearchUiSelectors.scene)
|
Readonly sceneBounds$ |
Type : Observable<Position>
|
Decorators :
@Select(SpatialSearchUiSelectors.sceneBounds)
|
Readonly sceneTarget$ |
Type : Observable<Position>
|
Decorators :
@Select(SpatialSearchUiSelectors.sceneTarget)
|
Readonly sex$ |
Type : Observable<Sex>
|
Decorators :
@Select(SpatialSearchUiSelectors.sex)
|
Readonly tissueBlocks$ |
Type : Observable<TissueBlockResult[]>
|
Decorators :
@Select(SpatialSearchUiSelectors.tissueBlocks)
|
Readonly updatePosition |
Default value : actionAsFn(SetPosition)
|
Decorators :
@Dispatch()
|
Readonly updateRadius |
Default value : actionAsFn(SetRadius)
|
Decorators :
@Dispatch()
|
import { ChangeDetectionStrategy, Component } from '@angular/core';
import { MatDialog, MatDialogRef } from '@angular/material/dialog';
import { Dispatch } from '@ngxs-labs/dispatch-decorator';
import { Select } from '@ngxs/store';
import { SpatialSceneNode, TissueBlockResult } from 'ccf-database';
import { GlobalConfigState, InfoButtonService, InfoDialogComponent, OrganInfo, PanelData } from 'ccf-shared';
import { Observable, Subscription } from 'rxjs';
import { actionAsFn } from '../../../core/store/action-as-fn';
import {
GenerateSpatialSearch,
MoveToNode,
ResetPosition,
ResetRadius,
SetPosition,
SetRadius,
} from '../../../core/store/spatial-search-ui/spatial-search-ui.actions';
import { SpatialSearchUiSelectors } from '../../../core/store/spatial-search-ui/spatial-search-ui.selectors';
import { Position, RadiusSettings, TermResult } from '../../../core/store/spatial-search-ui/spatial-search-ui.state';
import { SpatialSearchConfigBehaviorComponent } from '../spatial-search-config-behavior/spatial-search-config-behavior.component';
import { Sex } from '../spatial-search-config/spatial-search-config.component';
import { SpatialSearchUiComponent } from '../spatial-search-ui/spatial-search-ui.component';
/**
* Behavioral component for Spatial Search UI
*/
@Component({
selector: 'ccf-spatial-search-ui-behavior',
templateUrl: './spatial-search-ui-behavior.component.html',
changeDetection: ChangeDetectionStrategy.OnPush,
})
export class SpatialSearchUiBehaviorComponent {
@Select(SpatialSearchUiSelectors.scene)
readonly scene$!: Observable<SpatialSceneNode[]>;
@Select(SpatialSearchUiSelectors.sceneBounds)
readonly sceneBounds$!: Observable<Position>;
@Select(SpatialSearchUiSelectors.sceneTarget)
readonly sceneTarget$!: Observable<Position>;
@Select(SpatialSearchUiSelectors.sex)
readonly sex$!: Observable<Sex>;
@Select(SpatialSearchUiSelectors.organ)
readonly organ$!: Observable<OrganInfo | undefined>;
@Select(SpatialSearchUiSelectors.position)
readonly position$!: Observable<Position>;
@Select(SpatialSearchUiSelectors.defaultPosition)
readonly defaultPosition$!: Observable<Position>;
@Select(SpatialSearchUiSelectors.radius)
readonly radius$!: Observable<number>;
@Select(SpatialSearchUiSelectors.radiusSettings)
readonly radiusSettings$!: Observable<RadiusSettings>;
@Select(SpatialSearchUiSelectors.tissueBlocks)
readonly tissueBlocks$!: Observable<TissueBlockResult[]>;
@Select(SpatialSearchUiSelectors.anatomicalStructures)
readonly anatomicalStructures$!: Observable<TermResult[]>;
@Select(SpatialSearchUiSelectors.cellTypes)
readonly cellTypes$!: Observable<TermResult[]>;
@Dispatch()
readonly updatePosition = actionAsFn(SetPosition);
@Dispatch()
readonly resetPosition = actionAsFn(ResetPosition);
@Dispatch()
readonly moveToNode = actionAsFn(MoveToNode);
@Dispatch()
readonly updateRadius = actionAsFn(SetRadius);
@Dispatch()
readonly resetRadius = actionAsFn(ResetRadius);
/** Data to be displayed in the info panel */
panelData!: PanelData;
baseHref = '';
/** Subscriptions for the info panel data */
private readonly subscriptions = new Subscription();
constructor(
private readonly dialogRef: MatDialogRef<SpatialSearchUiComponent>,
public dialog: MatDialog,
private readonly infoService: InfoButtonService,
private readonly globalConfig: GlobalConfigState<{ baseHref: string }>,
) {
this.globalConfig.getOption('baseHref').subscribe((ref) => {
this.baseHref = ref;
});
}
/**
* Launchs info dialog with the input data
* @param data Data for the info dialog
*/
launchInfoDialog(data: PanelData): void {
this.subscriptions.unsubscribe();
this.dialog.open(InfoDialogComponent, {
autoFocus: false,
panelClass: 'modal-animated',
width: '72rem',
data: {
title: data.infoTitle,
content: data.content,
videoID: data.videoID,
},
});
}
/**
* Updates dialog with spatial search information
*/
onDialogButtonClick(): void {
this.infoService.updateData(
this.baseHref + 'assets/docs/SPATIAL_SEARCH_README.md',
'UfxMpzatowE',
'Spatial Search',
);
const panelContent$ = this.infoService.panelContent.asObservable();
this.subscriptions.add(
panelContent$.subscribe((data) => {
if (data.content.length) {
this.panelData = data;
this.launchInfoDialog(this.panelData);
}
}),
);
}
/**
* Closes spatial search UI
*/
close(): void {
this.dialogRef.close();
}
/**
* Adds a new spatial search and closes the spatial search UI
* @returns spatial search
*/
@Dispatch()
addSpatialSearch(): GenerateSpatialSearch {
this.close();
return new GenerateSpatialSearch();
}
/**
* Closes the spatial search UI and opens spatial search config
*/
openSpatialSearchConfig(): void {
this.close();
this.dialog.open(SpatialSearchConfigBehaviorComponent);
}
}
<ccf-spatial-search-ui
*ngIf="organ$ | async as organ"
[sex]="(sex$ | async)!"
[referenceOrgan]="organ"
[radius]="(radius$ | async) ?? 0"
[radiusSettings]="(radiusSettings$ | async)!"
[defaultPosition]="(defaultPosition$ | async)!"
[position]="(position$ | async)!"
[scene]="(scene$ | async)!"
[sceneBounds]="(sceneBounds$ | async)!"
[sceneTarget]="$any(sceneTarget$ | async)!"
[tissueBlocks]="(tissueBlocks$ | async)!"
[anatomicalStructures]="(anatomicalStructures$ | async) ?? []"
[cellTypes]="(cellTypes$ | async) ?? []"
(addSpatialSearch)="addSpatialSearch()"
(radiusChange)="updateRadius($event)"
(resetPosition)="resetPosition()"
(resetSphere)="resetRadius()"
(positionChange)="updatePosition($event)"
(closeSpatialSearch)="close()"
(editReferenceOrganClicked)="openSpatialSearchConfig()"
(infoClicked)="onDialogButtonClick()"
(nodeClicked)="moveToNode($event)"
>
</ccf-spatial-search-ui>