diff --git a/docs/releases/v2.5.0.md b/docs/releases/v2.5.0.md new file mode 100644 index 0000000000000000000000000000000000000000..5f9bcd52628076fb2cb360b74bf06cf9f11eb838 --- /dev/null +++ b/docs/releases/v2.5.0.md @@ -0,0 +1,5 @@ +# v2.5.0 + +## Under the hood stuff + +- refactor: remove unneeded code diff --git a/mkdocs.yml b/mkdocs.yml index b09aa94d70dfd245a9b73c6a02d529d4bd720f1b..f504c13ca845a5dd5b2bcb51a01caeadb3f47615 100644 --- a/mkdocs.yml +++ b/mkdocs.yml @@ -40,6 +40,7 @@ pages: - Fetching datasets: 'advanced/datasets.md' - Display non-atlas volumes: 'advanced/otherVolumes.md' - Release notes: + - v2.5.0: 'releases/v2.5.0.md' - v2.4.0: 'releases/v2.4.0.md' - v2.3.11: 'releases/v2.3.11.md' - v2.3.10: 'releases/v2.3.10.md' diff --git a/release.sh b/release.sh deleted file mode 100755 index 2eb23818ae9e75d207b874bbaa1b924d9b83dccf..0000000000000000000000000000000000000000 --- a/release.sh +++ /dev/null @@ -1,70 +0,0 @@ -#! /bin/bash - -# This is an automated script for TravisCI -# It is triggered on push to master -# It will create a release and publish to the github repo - -OWNER=HumanBrainProject -REPO=interactive-viewer -USER=xgui3783 -EMAIL=xgui3783@gmail.com -#GITHUB_TOKEN should be populated by CI - -test -z "$GITHUB_TOKEN" && exit 1 - -TAG=$(jq '.version' < package.json) -TAG=${TAG#\"} -TAG=v${TAG%\"} -OBJECT=$(git rev-parse HEAD) -DATE=$(date --iso-8601=seconds) -BODY='{ - "tag": "'$TAG'", - "message": "Annotated release for '$TAG'", - "object": "'$OBJECT'", - "type": "commit", - "tagger": { - "name": "'$USER'", - "email": "'$EMAIL'", - "date": "'$DATE'" - } -}' - -# Create annotated tag - -echo curl -XPOST \ - -H "Accept: application/vnd.github.v3+json" \ - -u "$USER:$GITHUB_TOKEN"\ - -d "$BODY" \ - https://api.github.com/repos/$OWNER/$REPO/git/tags - -# Push tag to remote - -CREATE_REF_BODY='{ - "ref":"refs/tags/'$TAG'", - "sha":"'$OBJECT'" -}' - -echo curl -XPOST\ - -u "$USER:$GITHUB_TOKEN"\ - -H "Accept: application/vnd.github.v3+json" \ - -d "$CREATE_REF_BODY"\ - https://api.github.com/repos/$OWNER/$REPO/git/refs - -# Create release - -RELEASE_NOTES=$(sed -e 's/$/\\n/' docs/releases/$TAG.md) - -RELEASE_BODY='{ - "tag_name":"'$TAG'", - "name":"'$TAG'", - "body":"'$(echo $RELEASE_NOTES)'", - "target_commitish": "master", - "draft":false, - "prerelease":false -}' - -echo curl -XPOST\ - -u "$USER:$GITHUB_TOKEN"\ - -H "Accept: application/vnd.github.v3+json" \ - -d "$RELEASE_BODY" \ - https://api.github.com/repos/$OWNER/$REPO/releases diff --git a/src/atlasComponents/databrowserModule/databrowser.service.ts b/src/atlasComponents/databrowserModule/databrowser.service.ts index 31fd9b517d5818e168e0d47ce73dc64fdfe44159..6a0cf707ac1110554923747f7c32e503b42bfba1 100644 --- a/src/atlasComponents/databrowserModule/databrowser.service.ts +++ b/src/atlasComponents/databrowserModule/databrowser.service.ts @@ -167,21 +167,6 @@ export class DatabrowserService implements OnDestroy { }), ) - this.subscriptions.push( - fromEvent(this.workerService.worker, 'message').pipe( - filter((message: MessageEvent) => message && message.data && message.data.type === 'RETURN_REBUILT_REGION_SELECTION_TREE'), - map(message => message.data), - ).subscribe((payload: any) => { - /** - * rebuiltSelectedRegion contains super region that are - * selected as a result of all of its children that are selectted - */ - const { rebuiltSelectedRegions, rebuiltSomeSelectedRegions } = payload - /** - * apply filter and populate databrowser instances - */ - }), - ) } public ngOnDestroy() { @@ -337,14 +322,6 @@ export class DatabrowserService implements OnDestroy { }) } - public rebuildRegionTree(selectedRegions, regions) { - this.workerService.worker.postMessage({ - type: 'BUILD_REGION_SELECTION_TREE', - selectedRegions, - regions, - }) - } - public getModalityFromDE = getModalityFromDE } diff --git a/src/atlasComponents/parcellation/regionSearch/regionSearch.component.ts b/src/atlasComponents/parcellation/regionSearch/regionSearch.component.ts index b3db031c4416658fed8c1de4d7936607f3f5e74e..6ff6301a2f59a77a959774d31299a679c317bed1 100644 --- a/src/atlasComponents/parcellation/regionSearch/regionSearch.component.ts +++ b/src/atlasComponents/parcellation/regionSearch/regionSearch.component.ts @@ -171,6 +171,9 @@ export class RegionTextSearchAutocomplete { public autocompleteList$: Observable<any[]> public formControl = new FormControl() + public filterNullFn(item: any){ + return !!item + } public regionsSelected$: Observable<any> public parcellationSelected$: Observable<any> diff --git a/src/atlasComponents/parcellation/regionSearch/regionSearch.template.html b/src/atlasComponents/parcellation/regionSearch/regionSearch.template.html index b2f5434124d1a2d5e89c7b5bb1227f1f3c74f914..965cc3c65d508042857b48f489afaf00ee6e2364 100644 --- a/src/atlasComponents/parcellation/regionSearch/regionSearch.template.html +++ b/src/atlasComponents/parcellation/regionSearch/regionSearch.template.html @@ -74,7 +74,7 @@ <ng-template #regionHierarchy> <region-hierarchy [useMobileUI]="useMobileUI$ | async" - [selectedRegions]="regionsSelected$ | async | filterNull" + [selectedRegions]="regionsSelected$ | async | filterArray : filterNullFn" (singleClickRegion)="handleRegionClick({ mode: 'single', region: $event })" (doubleClickRegion)="handleRegionClick({ mode: 'double', region: $event })" (clearAllRegions)="deselectAllRegions($event)" diff --git a/src/atlasComponents/parcellationRegion/regionMenu/regionMenu.template.html b/src/atlasComponents/parcellationRegion/regionMenu/regionMenu.template.html index 52e6a76f5ef109bf25a83c722781dac41ac65722..7f7a0cc5c1aae01b0747185c83b1c4de4c788a09 100644 --- a/src/atlasComponents/parcellationRegion/regionMenu/regionMenu.template.html +++ b/src/atlasComponents/parcellationRegion/regionMenu/regionMenu.template.html @@ -173,7 +173,7 @@ let-iavNgIf="iavNgIf" let-content="content"> <mat-expansion-panel - [expanded]="activePanelTitles$ | async | arrayContains : title" + [expanded]="activePanelTitles$ | async | includes : title" [attr.data-opened]="expansionPanel.expanded" [attr.data-mat-expansion-title]="title" (closed)="handleExpansionPanelClosedEv(title)" diff --git a/src/atlasComponents/regionalFeatures/bsFeatures/ieeg/ieegCmp/ieeg.template.html b/src/atlasComponents/regionalFeatures/bsFeatures/ieeg/ieegCmp/ieeg.template.html index ff8c7d311b9fda82ac9131dab0bac41706274ba2..be044298ea19ec125eab9dc51f8811792aaeba6d 100644 --- a/src/atlasComponents/regionalFeatures/bsFeatures/ieeg/ieegCmp/ieeg.template.html +++ b/src/atlasComponents/regionalFeatures/bsFeatures/ieeg/ieegCmp/ieeg.template.html @@ -27,7 +27,7 @@ <ng-template #electrodeTmpl let-electrode> <mat-expansion-panel - [expanded]="openElectrode$ | async | arrayContains : electrode" + [expanded]="openElectrode$ | async | includes : electrode" (opened)="handleDatumExpansion(electrode, true)" (closed)="handleDatumExpansion(electrode, false)" togglePosition="before"> diff --git a/src/atlasComponents/regionalFeatures/singleFeatures/iEEGRecordings/iEEGRecordings/iEEGRecordings.template.html b/src/atlasComponents/regionalFeatures/singleFeatures/iEEGRecordings/iEEGRecordings/iEEGRecordings.template.html index aefcfeb42af6852e6407042af5a31c384ea9315a..7a4b70d88a55e2e8325446c946c2035ed29d59bf 100644 --- a/src/atlasComponents/regionalFeatures/singleFeatures/iEEGRecordings/iEEGRecordings/iEEGRecordings.template.html +++ b/src/atlasComponents/regionalFeatures/singleFeatures/iEEGRecordings/iEEGRecordings/iEEGRecordings.template.html @@ -3,7 +3,7 @@ <mat-accordion class="ml-24px-n mr-24px-n d-block"> <mat-expansion-panel *ngFor="let datum of (data$ | async)" - [expanded]="openElectrodeId$ | async | arrayContains : datum['@id']" + [expanded]="openElectrodeId$ | async | includes : datum['@id']" (opened)="handleDatumExpansion(datum['@id'], true)" (closed)="handleDatumExpansion(datum['@id'], false)" togglePosition="before"> diff --git a/src/atlasComponents/splashScreen/splashScreen/splashScreen.component.ts b/src/atlasComponents/splashScreen/splashScreen/splashScreen.component.ts index 2435c4e089495a84549374d29f77e1bce8bec238..3d4ed603f7586a8395df2c4daf06949f4b68802c 100644 --- a/src/atlasComponents/splashScreen/splashScreen/splashScreen.component.ts +++ b/src/atlasComponents/splashScreen/splashScreen/splashScreen.component.ts @@ -21,6 +21,10 @@ export class SplashScreen { public loadedAtlases$: Observable<any[]> + public filterNullFn(atlas: any){ + return !!atlas + } + @ViewChild('parentContainer', {read: ElementRef}) public activatedTemplate$: Subject<any> = new Subject() diff --git a/src/atlasComponents/splashScreen/splashScreen/splashScreen.template.html b/src/atlasComponents/splashScreen/splashScreen/splashScreen.template.html index bb855b2ef8cf1226bc3793b664644e14d902250b..6236bd010201f3b334dc28c58df491acdd3017d2 100644 --- a/src/atlasComponents/splashScreen/splashScreen/splashScreen.template.html +++ b/src/atlasComponents/splashScreen/splashScreen/splashScreen.template.html @@ -7,7 +7,7 @@ <mat-card (click)="selectAtlas(atlas)" matRipple - *ngFor="let atlas of loadedAtlases$ | async | filterNull" + *ngFor="let atlas of loadedAtlases$ | async | filterArray : filterNullFn" class="m-3 col-md-12 col-lg-12 pe-all"> <mat-card-header> <mat-card-title class="text-nowrap font-stretch"> diff --git a/src/components/components.module.ts b/src/components/components.module.ts index c03ce4ea93d2f1ab6f1954f0f75e50218462c21c..a17a533ba36d52a2f640028746111b26487844c2 100644 --- a/src/components/components.module.ts +++ b/src/components/components.module.ts @@ -8,9 +8,8 @@ import { MarkdownDom } from './markdown/markdown.component'; import { CommonModule } from '@angular/common'; import { AngularMaterialModule } from 'src/ui/sharedModules/angularMaterial.module'; import { UtilModule } from 'src/util'; -import { SearchResultPaginationPipe } from '../util/pipes/pagination.pipe'; -import { SafeHtmlPipe } from '../util/pipes/safeHtml.pipe' -import { TreeSearchPipe } from '../util/pipes/treeSearch.pipe'; +import { SafeHtmlPipe } from './safeHtml.pipe' +import { TreeSearchPipe } from './treeSearch.pipe'; import { ConfirmDialogComponent } from './confirmDialog/confirmDialog.component'; import { DialogComponent } from './dialog/dialog.component'; import { AppendSiblingFlagPipe } from './flatTree/appendSiblingFlag.pipe'; @@ -69,7 +68,6 @@ import { SpinnerCmp } from './spinner/spinner.component'; /* pipes */ SafeHtmlPipe, - SearchResultPaginationPipe, TreeSearchPipe, FlattenTreePipe, RenderPipe, @@ -98,7 +96,6 @@ import { SpinnerCmp } from './spinner/spinner.component'; DynamicMaterialBtn, SpinnerCmp, - SearchResultPaginationPipe, TreeSearchPipe, HoverableBlockDirective, diff --git a/src/util/pipes/safeHtml.pipe.ts b/src/components/safeHtml.pipe.ts similarity index 66% rename from src/util/pipes/safeHtml.pipe.ts rename to src/components/safeHtml.pipe.ts index 272c1c31623f99ab9168366be311af4b8bbc8d6b..046bbc39c1b9773402d72d144cbabf74ce6b0b13 100644 --- a/src/util/pipes/safeHtml.pipe.ts +++ b/src/components/safeHtml.pipe.ts @@ -1,4 +1,4 @@ -import { Pipe, PipeTransform } from '@angular/core'; +import { Pipe, PipeTransform, SecurityContext } from '@angular/core'; import { DomSanitizer, SafeHtml } from '@angular/platform-browser'; @Pipe({ @@ -10,6 +10,6 @@ export class SafeHtmlPipe implements PipeTransform { } public transform(html: string): SafeHtml { - return this.ds.bypassSecurityTrustHtml(html) + return this.ds.sanitize(SecurityContext.HTML, html) } } diff --git a/src/util/pipes/treeSearch.pipe.spec.ts b/src/components/treeSearch.pipe.spec.ts similarity index 100% rename from src/util/pipes/treeSearch.pipe.spec.ts rename to src/components/treeSearch.pipe.spec.ts diff --git a/src/util/pipes/treeSearch.pipe.ts b/src/components/treeSearch.pipe.ts similarity index 100% rename from src/util/pipes/treeSearch.pipe.ts rename to src/components/treeSearch.pipe.ts diff --git a/src/main.module.ts b/src/main.module.ts index cc25b011578ad18e3a9fb1e0d6f8fd21adc94742..dc5bdfbc1413cc29272709770cfa6f4bacd5bfc8 100644 --- a/src/main.module.ts +++ b/src/main.module.ts @@ -9,8 +9,6 @@ import { ComponentsModule } from "./components/components.module"; import { LayoutModule } from "./layouts/layout.module"; import { ngViewerState, pluginState, uiState, userConfigState, UserConfigStateUseEffect, viewerConfigState, viewerState } from "./services/stateStore.service"; import { UIModule } from "./ui/ui.module"; -import { GetNamePipe } from "./util/pipes/getName.pipe"; -import { GetNamesPipe } from "./util/pipes/getNames.pipe"; import { HttpClientModule } from "@angular/common/http"; import { EffectsModule } from "@ngrx/effects"; @@ -28,10 +26,8 @@ import { ViewerStateUseEffect } from "./services/state/viewerState.store"; import { UIService } from "./services/uiService.service"; import { DatabrowserModule, OVERRIDE_IAV_DATASET_PREVIEW_DATASET_FN, DataBrowserFeatureStore, GET_KGDS_PREVIEW_INFO_FROM_ID_FILENAME, DatabrowserService } from "src/atlasComponents/databrowserModule"; import { ViewerStateControllerUseEffect } from "src/state"; -import { DockedContainerDirective } from "./util/directives/dockedContainer.directive"; import { FloatingContainerDirective } from "./util/directives/floatingContainer.directive"; import { FloatingMouseContextualContainerDirective } from "./util/directives/floatingMouseContextualContainer.directive"; -import { NewViewerDisctinctViewToLayer } from "./util/pipes/newViewerDistinctViewToLayer.pipe"; import { ClickInterceptor, CLICK_INTERCEPTOR_INJECTOR, PureContantService, UtilModule } from "src/util"; import { SpotLightModule } from 'src/spotlight/spot-light.module' import { TryMeComponent } from "./ui/tryme/tryme.component"; @@ -133,14 +129,9 @@ export function debug(reducer: ActionReducer<any>): ActionReducer<any> { TryMeComponent, /* directives */ - DockedContainerDirective, FloatingContainerDirective, FloatingMouseContextualContainerDirective, - /* pipes */ - GetNamesPipe, - GetNamePipe, - NewViewerDisctinctViewToLayer, ], entryComponents : [ DialogComponent, diff --git a/src/plugin/atlasViewer.pluginService.service.ts b/src/plugin/atlasViewer.pluginService.service.ts index 42ac1eb77d55de2adb541adf8c98e60e079ae199..1c83a6d28b92622728c9653cf0562846cd28e2cb 100644 --- a/src/plugin/atlasViewer.pluginService.service.ts +++ b/src/plugin/atlasViewer.pluginService.service.ts @@ -6,7 +6,6 @@ import { select, Store } from "@ngrx/store"; import { BehaviorSubject, from, merge, Observable, of } from "rxjs"; import { catchError, filter, map, mapTo, shareReplay, switchMap, switchMapTo, take, tap } from "rxjs/operators"; import { LoggingService } from 'src/logging'; -import { PluginHandler } from 'src/util/pluginHandler'; import { WidgetUnit, WidgetServices } from "src/widget"; import { APPEND_SCRIPT_TOKEN, REMOVE_SCRIPT_TOKEN, getHttpHeader } from 'src/util/constants'; import { PluginFactoryDirective } from './pluginFactory.directive'; @@ -18,6 +17,19 @@ import { PureContantService } from 'src/util'; const requiresReloadMd = `\n\n***\n\n**warning**: interactive atlas viewer **will** be reloaded in order for the change to take effect.` +class PluginHandler { + public onShutdown: (callback: () => void) => void + public blink: (sec?: number) => void + public shutdown: () => void + + public initState?: any + public initStateUrl?: string + + public setInitManifestUrl: (url: string|null) => void + + public setProgressIndicator: (progress: number) => void +} + export const registerPluginFactoryDirectiveFactory = (pSer: PluginServices) => { return (pFactoryDirective: PluginFactoryDirective) => { pSer.loadExternalLibraries = pFactoryDirective.loadExternalLibraries.bind(pFactoryDirective) diff --git a/src/plugin/pluginCsp/pluginCsp.template.html b/src/plugin/pluginCsp/pluginCsp.template.html index 477d41a9cff6964a477b21df24e11231604c8910..16159fa0bf2b0525eed22819c9d06d4315fec6e4 100644 --- a/src/plugin/pluginCsp/pluginCsp.template.html +++ b/src/plugin/pluginCsp/pluginCsp.template.html @@ -36,7 +36,7 @@ </button> <mat-list> - <ng-container *ngFor="let csp of pluginCsp['pluginCsp'] | objToArray"> + <ng-container *ngFor="let csp of pluginCsp['pluginCsp'] | keyvalue"> <span mat-subheader> {{ csp['key'] }} </span> diff --git a/src/ui/ui.module.ts b/src/ui/ui.module.ts index ff474d2afc77c8adee2ec5174493770321d320c7..0ab786dc662feb6f9d0c778d232f3fb178f55d11 100644 --- a/src/ui/ui.module.ts +++ b/src/ui/ui.module.ts @@ -4,22 +4,13 @@ import { ComponentsModule } from "src/components/components.module"; import { FormsModule, ReactiveFormsModule } from "@angular/forms"; import { LayoutModule } from "src/layouts/layout.module"; -import { FilterRegionDataEntries } from "src/util/pipes/filterRegionDataEntries.pipe"; -import { GroupDatasetByRegion } from "src/util/pipes/groupDataEntriesByRegion.pipe"; - -import { GetLayerNameFromDatasets } from "../util/pipes/getLayerNamePipe.pipe"; -import { SortDataEntriesToRegion } from "../util/pipes/sortDataEntriesIntoRegion.pipe"; import { CitationsContainer } from "./citation/citations.component"; import { ScrollingModule } from "@angular/cdk/scrolling" import { HttpClientModule } from "@angular/common/http"; import { AngularMaterialModule } from 'src/ui/sharedModules/angularMaterial.module' -import { AppendtooltipTextPipe } from "src/util/pipes/appendTooltipText.pipe"; -import { FlatmapArrayPipe } from "src/util/pipes/flatMapArray.pipe"; -import { GetFileExtension } from "src/util/pipes/getFileExt.pipe"; import { UtilModule } from "src/util"; import { DownloadDirective } from "../util/directives/download.directive"; -import { SpatialLandmarksToDataBrowserItemPipe } from "../util/pipes/spatialLandmarksToDatabrowserItem.pipe"; import { DatabrowserModule } from "../atlasComponents/databrowserModule/databrowser.module"; @@ -29,9 +20,6 @@ import { MobileOverlay } from "./nehubaContainer/mobileOverlay/mobileOverlay.com import { MobileControlNubStylePipe } from "./nehubaContainer/pipes/mobileControlNubStyle.pipe"; import { HumanReadableFileSizePipe } from "src/util/pipes/humanReadableFileSize.pipe"; -import { KgSearchBtnColorPipe } from "src/util/pipes/kgSearchBtnColor.pipe"; -import { PluginBtnFabColorPipe } from "src/util/pipes/pluginBtnFabColor.pipe"; -import { TemplateParcellationHasMoreInfo } from "src/util/pipes/templateParcellationHasMoreInfo.pipe"; import { ReorderPanelIndexPipe } from "./nehubaContainer/reorderPanelIndex.pipe"; @@ -77,19 +65,8 @@ import { AtlasCmpParcellationModule } from "src/atlasComponents/parcellation"; ActionDialog, /* pipes */ - GroupDatasetByRegion, - FilterRegionDataEntries, - FlatmapArrayPipe, - GetLayerNameFromDatasets, - SortDataEntriesToRegion, - SpatialLandmarksToDataBrowserItemPipe, - AppendtooltipTextPipe, MobileControlNubStylePipe, - PluginBtnFabColorPipe, - KgSearchBtnColorPipe, - GetFileExtension, - TemplateParcellationHasMoreInfo, HumanReadableFileSizePipe, ReorderPanelIndexPipe, diff --git a/src/util/directives/counter.directive.ts b/src/util/directives/counter.directive.ts deleted file mode 100644 index d66f71877e4f13631a4ad6b4db194aa540106de2..0000000000000000000000000000000000000000 --- a/src/util/directives/counter.directive.ts +++ /dev/null @@ -1,10 +0,0 @@ -import { Directive } from "@angular/core"; - -@Directive({ - selector: '[iav-counter]', - exportAs: 'iavCounter' -}) - -export class CounterDirective{ - public value: number = 0 -} \ No newline at end of file diff --git a/src/util/directives/delayEvent.directive.ts b/src/util/directives/delayEvent.directive.ts deleted file mode 100644 index fa896a09f8ddcd7cd9f6e6909f2059367bc06e9c..0000000000000000000000000000000000000000 --- a/src/util/directives/delayEvent.directive.ts +++ /dev/null @@ -1,54 +0,0 @@ -import { Directive, ElementRef, EventEmitter, Input, OnChanges, OnDestroy, Output } from "@angular/core"; - -const VALID_EVENTNAMES = new Set([ - 'mousedown', - 'mouseup', - 'click', - 'mouseenter', - 'mouseleave', - 'touchstart', - 'touchmove', - 'touchend', -]) - -@Directive({ - selector: '[iav-delay-event]', -}) - -export class DelayEventDirective implements OnChanges, OnDestroy { - - private evListener = (ev: Event) => setTimeout(() => this.delayedEmit.emit(ev)) - - @Input('iav-delay-event') - public delayEvent: string = '' - - @Output('iav-delay-event-emit') - public delayedEmit: EventEmitter<any> = new EventEmitter() - - constructor( - private el: ElementRef, - ) { - - } - - private destroyCb: Array<() => void> = [] - public ngOnChanges() { - this.ngOnDestroy() - - if (!this.delayEvent || this.delayEvent === '') { return } - const el = this.el.nativeElement as HTMLElement - for (const evName of this.delayEvent.split(' ')) { - if (VALID_EVENTNAMES.has(evName)) { - el.addEventListener(evName, this.evListener) - this.destroyCb.push(() => el.removeEventListener(evName, this.evListener)) - } else { - // tslint:disable-next-line - console.warn(`${evName} is not a valid event name in the supported set`, VALID_EVENTNAMES) - } - } - } - - public ngOnDestroy() { - while (this.destroyCb.length > 0) { this.destroyCb.pop()() } - } -} diff --git a/src/util/directives/dockedContainer.directive.ts b/src/util/directives/dockedContainer.directive.ts deleted file mode 100644 index 4f9a9ab9052017df9d644d05bc0ec683695052d0..0000000000000000000000000000000000000000 --- a/src/util/directives/dockedContainer.directive.ts +++ /dev/null @@ -1,15 +0,0 @@ -import { Directive, ViewContainerRef } from "@angular/core"; -import { WidgetServices } from "src/widget"; - -@Directive({ - selector: '[dockedContainerDirective]', -}) - -export class DockedContainerDirective { - constructor( - widgetService: WidgetServices, - viewContainerRef: ViewContainerRef, - ) { - widgetService.dockedContainer = viewContainerRef - } -} diff --git a/src/util/pipes/_tmpParcName.pipe.ts b/src/util/pipes/_tmpParcName.pipe.ts deleted file mode 100644 index 455249098ce35930a1f303b7e4ad7b81f46d9813..0000000000000000000000000000000000000000 --- a/src/util/pipes/_tmpParcName.pipe.ts +++ /dev/null @@ -1,17 +0,0 @@ -import { Pipe, PipeTransform } from "@angular/core"; - -/** - * this is a temporary pipe class that transform - * JuBrain -> Julich-Brain - * in prod version of IAV - */ - -@Pipe({ - name: 'tmpParcNamePipe' -}) - -export class TmpParcNamePipe implements PipeTransform{ - public transform(input: string): string{ - return input.replace(/JuBrain/gi, 'Julich-Brain') - } -} \ No newline at end of file diff --git a/src/util/pipes/appendTooltipText.pipe.ts b/src/util/pipes/appendTooltipText.pipe.ts deleted file mode 100644 index 76f8710696a43987f079bb916ccd6e288798353e..0000000000000000000000000000000000000000 --- a/src/util/pipes/appendTooltipText.pipe.ts +++ /dev/null @@ -1,23 +0,0 @@ -import { Pipe, PipeTransform } from "@angular/core"; - -/** - * TODO - * merge this pipe into cpProp pipe - */ - -@Pipe({ - name: 'appendTooltipTextPipe', -}) - -export class AppendtooltipTextPipe implements PipeTransform { - public transform(array: any[]) { - return array.map(item => { - const { properties = {} } = item - const { description: tooltipText } = properties - return { - ...item, - tooltipText, - } - }) - } -} diff --git a/src/util/pipes/arrayContains.pipe.ts b/src/util/pipes/arrayContains.pipe.ts deleted file mode 100644 index e36b1283d2b69dc11e6c2a1febdc5604ad204ec1..0000000000000000000000000000000000000000 --- a/src/util/pipes/arrayContains.pipe.ts +++ /dev/null @@ -1,12 +0,0 @@ -import { Pipe, PipeTransform } from "@angular/core"; - -@Pipe({ - name: 'arrayContains', - pure: true -}) - -export class ArrayContainsPipe implements PipeTransform{ - public transform<T>(inputArray: T[], qualifier: T): boolean{ - return (inputArray || []).some(it => it === qualifier) - } -} diff --git a/src/util/pipes/filterByProperty.pipe.ts b/src/util/pipes/filterByProperty.pipe.ts deleted file mode 100644 index 6e7819bfe2104dcd4f7f6cc433edbc4c21311c85..0000000000000000000000000000000000000000 --- a/src/util/pipes/filterByProperty.pipe.ts +++ /dev/null @@ -1,12 +0,0 @@ -import { Pipe, PipeTransform } from "@angular/core"; - -@Pipe({ - name: 'filterByProperty', - pure: true -}) - -export class FilterByPropertyPipe implements PipeTransform{ - public transform<T>(input: T[], prop: string): T[]{ - return input.filter(item => !!item[prop]) - } -} diff --git a/src/util/pipes/filterNull.pipe.ts b/src/util/pipes/filterNull.pipe.ts deleted file mode 100644 index 4bbde2567d3f76f550382425264374134571ba0e..0000000000000000000000000000000000000000 --- a/src/util/pipes/filterNull.pipe.ts +++ /dev/null @@ -1,11 +0,0 @@ -import { Pipe, PipeTransform } from "@angular/core"; - -@Pipe({ - name: 'filterNull', -}) - -export class FilterNullPipe implements PipeTransform { - public transform(arr: any[], fn?: (item: any) => boolean) { - return (arr && arr.filter(obj => fn ? fn(obj) : obj !== null)) || [] - } -} diff --git a/src/util/pipes/filterRegionDataEntries.pipe.ts b/src/util/pipes/filterRegionDataEntries.pipe.ts deleted file mode 100644 index 204c3343d31ec5cfd30848ac6bf022894ea2729b..0000000000000000000000000000000000000000 --- a/src/util/pipes/filterRegionDataEntries.pipe.ts +++ /dev/null @@ -1,14 +0,0 @@ -import { Pipe, PipeTransform } from "@angular/core"; -import { IDataEntry } from "../../services/stateStore.service"; - -@Pipe({ - name : 'filterRegionDataEntries', -}) - -export class FilterRegionDataEntries implements PipeTransform { - public transform(arr: Array<{region: any|null, searchResults: IDataEntry[]}>, selectedRegions: any[]): Array<{region: any|null, searchResults: IDataEntry[]}> { - return selectedRegions.length > 0 ? - arr.filter(obj => obj.region !== null && selectedRegions.findIndex(r => obj.region.name === r.name) >= 0) : - arr - } -} diff --git a/src/util/pipes/flatMapArray.pipe.ts b/src/util/pipes/flatMapArray.pipe.ts deleted file mode 100644 index 695a82dbf3d72f1f16d196657d2fb5b8a4b67f25..0000000000000000000000000000000000000000 --- a/src/util/pipes/flatMapArray.pipe.ts +++ /dev/null @@ -1,11 +0,0 @@ -import { Pipe, PipeTransform } from "@angular/core"; - -@Pipe({ - name: 'flatmapArrayPipe', -}) - -export class FlatmapArrayPipe implements PipeTransform { - public transform(aoa: any[][]) { - return aoa.reduce((acc, array) => acc.concat(array), []) - } -} diff --git a/src/util/pipes/getFileExt.pipe.ts b/src/util/pipes/getFileExt.pipe.ts deleted file mode 100644 index 2d677749525a096e40f94845a967ee1fd450ca02..0000000000000000000000000000000000000000 --- a/src/util/pipes/getFileExt.pipe.ts +++ /dev/null @@ -1,35 +0,0 @@ -import { Pipe, PipeTransform } from "@angular/core"; - -const NIFTI = `NIFTI Volume` -const VTK = `VTK Mesh` - -const extMap = new Map([ - ['.nii', NIFTI], - ['.nii.gz', NIFTI], - ['.vtk', VTK], -]) - -@Pipe({ - name: 'getFileExtension', -}) - -export class GetFileExtension implements PipeTransform { - private regex: RegExp = new RegExp('(\\.[\\w\\.]*?)$') - - private getRegexp(ext) { - return new RegExp(`${ext.replace(/\./g, '\\.')}$`, 'i') - } - - private detFileExt(filename: string): string { - for (const [key, val] of extMap) { - if (this.getRegexp(key).test(filename)) { - return val - } - } - return filename - } - - public transform(filename: string): string { - return this.detFileExt(filename) - } -} diff --git a/src/util/pipes/getLayerNamePipe.pipe.ts b/src/util/pipes/getLayerNamePipe.pipe.ts deleted file mode 100644 index 5acf0167a9708bba9dfe70aef3a2e3bb11bacda5..0000000000000000000000000000000000000000 --- a/src/util/pipes/getLayerNamePipe.pipe.ts +++ /dev/null @@ -1,19 +0,0 @@ -import { Pipe, PipeTransform } from "@angular/core"; - -@Pipe({ - name : 'getLayerNameFromDatasets', -}) - -export class GetLayerNameFromDatasets implements PipeTransform { - public transform(ngLayerName: string, datasets?: any[]): string { - if (!datasets) { - return ngLayerName - } - - const foundDataset = datasets.find(ds => ds.files.findIndex(file => file.url === ngLayerName) >= 0) - - return foundDataset - ? foundDataset.name - : ngLayerName - } -} diff --git a/src/util/pipes/getName.pipe.ts b/src/util/pipes/getName.pipe.ts deleted file mode 100644 index 56e4b4cfadb4ca993539fa93e03f62d7e1856e00..0000000000000000000000000000000000000000 --- a/src/util/pipes/getName.pipe.ts +++ /dev/null @@ -1,14 +0,0 @@ -import { Pipe, PipeTransform } from "@angular/core"; - -@Pipe({ - name : 'getName', -}) - -export class GetNamePipe implements PipeTransform { - - public transform(object: any): string { - return object ? - object.name ? object.name : 'Untitled' : - 'Untitled' - } -} diff --git a/src/util/pipes/getNames.pipe.ts b/src/util/pipes/getNames.pipe.ts deleted file mode 100644 index 8e2f0c8331f4cf35b2992b1670eae75b2114ccde..0000000000000000000000000000000000000000 --- a/src/util/pipes/getNames.pipe.ts +++ /dev/null @@ -1,14 +0,0 @@ -import { Pipe, PipeTransform } from "@angular/core"; - -@Pipe({ - name : 'getNames', -}) - -export class GetNamesPipe implements PipeTransform { - - public transform(array: any[]): string[] { - return array ? - array.map(item => item.name ? item.name : 'Untitled') : - [] - } -} diff --git a/src/util/pipes/getNthElement.pipe.ts b/src/util/pipes/getNthElement.pipe.ts index d4b27720b903731fa8c5cb0526380030854b7d4d..2a5d9bc82043dc2395b742528c555cfd84348272 100644 --- a/src/util/pipes/getNthElement.pipe.ts +++ b/src/util/pipes/getNthElement.pipe.ts @@ -1,5 +1,7 @@ import { Pipe, PipeTransform } from "@angular/core"; +// TODO use getProperty pipe instead + @Pipe({ name: 'getNthElement' }) diff --git a/src/util/pipes/getProperty.pipe.spec.ts b/src/util/pipes/getProperty.pipe.spec.ts deleted file mode 100644 index 0ffdd02fcbce683e436c0030ffe0517135c6ceda..0000000000000000000000000000000000000000 --- a/src/util/pipes/getProperty.pipe.spec.ts +++ /dev/null @@ -1 +0,0 @@ -// TODO \ No newline at end of file diff --git a/src/util/pipes/getProperty.pipe.ts b/src/util/pipes/getProperty.pipe.ts index 024135aee89a50d1554f41894ba2cac9f1bd813e..2132c83f2de36cf5b09b257b2fcd22f887be100c 100644 --- a/src/util/pipes/getProperty.pipe.ts +++ b/src/util/pipes/getProperty.pipe.ts @@ -6,7 +6,7 @@ import { Pipe, PipeTransform } from "@angular/core"; }) export class GetPropertyPipe implements PipeTransform{ - public transform(input, property = '@id') { + public transform(input: any, property: any = '@id') { return input && input[property] } } diff --git a/src/util/pipes/groupDataEntriesByRegion.pipe.ts b/src/util/pipes/groupDataEntriesByRegion.pipe.ts deleted file mode 100644 index 50f7a394c7228ea2aa023afa10d8dedddbf48bb7..0000000000000000000000000000000000000000 --- a/src/util/pipes/groupDataEntriesByRegion.pipe.ts +++ /dev/null @@ -1,41 +0,0 @@ -import { Pipe, PipeTransform } from "@angular/core"; -import { IDataEntry } from "../../services/stateStore.service"; - -@Pipe({ - name : 'groupDatasetByRegion', -}) -export class GroupDatasetByRegion implements PipeTransform { - public transform(datasets: IDataEntry[], regions: any[]): Array<{region: any|null, searchResults: IDataEntry[]}> { - - return datasets.reduce((acc, curr) => { - return (curr.parcellationRegion && curr.parcellationRegion.length > 0) - ? curr.parcellationRegion.reduce((acc2, reName) => { - const idx = acc.findIndex(it => it.region === null - ? reName.name === 'none' - : it.region.name === reName.name ) - - return idx >= 0 - ? acc2.map((v, i) => i === idx - ? Object.assign({}, v, {searchResults : v.searchResults.concat(curr)}) - : v ) - : acc2.concat({ - region : this.getRegionFromRegionName(reName.name, regions), - searchResults : [ curr ], - }) - }, acc) - : acc.findIndex(it => it.region == null) >= 0 - ? acc.map(it => it.region === null - ? Object.assign({}, it, {searchResults: it.searchResults.concat(curr)}) - : it) - : acc.concat({ - region : null, - searchResults : [curr], - }) - }, [] as Array<{region: any|null, searchResults: IDataEntry[]}>) - } - - private getRegionFromRegionName(regionName: string, regions: any[]): any|null { - const idx = regions.findIndex(re => re.name == regionName) - return idx >= 0 ? regions[idx] : null - } -} diff --git a/src/util/pipes/includes.pipe.ts b/src/util/pipes/includes.pipe.ts index 9d7dc2d1d10081f5be47d59c07f5b20417b8ec2c..2625cd6d3c2d0794ef5ca5d0e54b53a056617357 100644 --- a/src/util/pipes/includes.pipe.ts +++ b/src/util/pipes/includes.pipe.ts @@ -7,7 +7,7 @@ const defaultCompareFn = (item: any, comparator: any): boolean => item === compa }) export class IncludesPipe implements PipeTransform { - public transform(array: any[], item: any, compareFn= defaultCompareFn): boolean { + public transform(array: any[], item: any, compareFn = defaultCompareFn): boolean { if (!array) { return false } if (!(array instanceof Array)) { return false } return array.some(it => compareFn(it, item)) diff --git a/src/util/pipes/kgSearchBtnColor.pipe.ts b/src/util/pipes/kgSearchBtnColor.pipe.ts deleted file mode 100644 index 7adf205b3ece18cbce8cb07f252dd868162d3377..0000000000000000000000000000000000000000 --- a/src/util/pipes/kgSearchBtnColor.pipe.ts +++ /dev/null @@ -1,14 +0,0 @@ -import { Pipe, PipeTransform } from "@angular/core"; -import { WidgetUnit } from "src/widget"; - -@Pipe({ - name: 'kgSearchBtnColorPipe', -}) - -export class KgSearchBtnColorPipe implements PipeTransform { - public transform([minimisedWidgetUnit]: [Set<WidgetUnit>, string], wu: WidgetUnit ) { - return minimisedWidgetUnit.has(wu) - ? 'primary' - : 'accent' - } -} diff --git a/src/util/pipes/newViewerDistinctViewToLayer.pipe.ts b/src/util/pipes/newViewerDistinctViewToLayer.pipe.ts deleted file mode 100644 index c00db3f04631f1ab07825786d03562b9f1bdc3ce..0000000000000000000000000000000000000000 --- a/src/util/pipes/newViewerDistinctViewToLayer.pipe.ts +++ /dev/null @@ -1,53 +0,0 @@ -import { Pipe, PipeTransform } from "@angular/core"; - -@Pipe({ - name : 'newViewerDisctinctViewToLayer', -}) - -export class NewViewerDisctinctViewToLayer implements PipeTransform { - public transform(input: [any | null, string | null]): AtlasViewerLayerInterface[] { - try { - if (!input) { - return [] - } - const newViewer = input[0] - const dedicatedViewer = input[1] - return [] - .concat(newViewer - ? Object.keys(newViewer.nehubaConfig.dataset.initialNgState.layers).map(key => ({ - name : key, - url : newViewer.nehubaConfig.dataset.initialNgState.layers[key].source, - type : newViewer.nehubaConfig.dataset.initialNgState.layers[key].type === 'image' - ? 'base' - : newViewer.nehubaConfig.dataset.initialNgState.layers[key].type === 'segmentation' - ? 'mixable' - : 'nonmixable', - transform : newViewer.nehubaConfig.dataset.initialNgState.layers[key].transform - ? newViewer.nehubaConfig.dataset.initialNgState.layers[key].transform.map(quat => Array.from(quat)) - : null, - })) - : []) - .concat(dedicatedViewer - ? { name : 'dedicated view', url : dedicatedViewer, type : 'nonmixable' } - : []) - .sort((l1, l2) => l1.type < l2.type - ? -1 - : l1.type > l2.type - ? 1 - : 0 ) - } catch (e) { - - // tslint:disable-next-line - console.error('new viewer distinct view to layer error', e) - return [] - } - } -} - -export interface AtlasViewerLayerInterface { - name: string - url: string - type: string // 'base' | 'mixable' | 'nonmixable' - transform?: [[number, number, number, number], [number, number, number, number], [number, number, number, number], [number, number, number, number]] | null - // colormap : string -} diff --git a/src/util/pipes/objToArray.pipe.spec.ts b/src/util/pipes/objToArray.pipe.spec.ts deleted file mode 100644 index d1a54e0822e710a18cad06ccc9c619423d528a52..0000000000000000000000000000000000000000 --- a/src/util/pipes/objToArray.pipe.spec.ts +++ /dev/null @@ -1,17 +0,0 @@ -import { ObjectToArrayPipe } from "./objToArray.pipe" - -describe('> objToArray.pipe.ts', () => { - describe('> ObjectToArrayPipe', () => { - const pipe = new ObjectToArrayPipe() - it('> transforms obj to array', () => { - const result = pipe.transform({'a': '1', 'b': '2'}) - expect(result).toEqual([{ - key: 'a', - value: '1' - }, { - key: 'b', - value: '2' - }]) - }) - }) -}) \ No newline at end of file diff --git a/src/util/pipes/objToArray.pipe.ts b/src/util/pipes/objToArray.pipe.ts deleted file mode 100644 index 9320b363193d65dab5ae50b19461ae698ea35c00..0000000000000000000000000000000000000000 --- a/src/util/pipes/objToArray.pipe.ts +++ /dev/null @@ -1,22 +0,0 @@ -import { Pipe, PipeTransform } from "@angular/core"; - -interface ITransformedObj{ - key: string - value: string -} - -@Pipe({ - name: 'objToArray', - pure: true -}) - -export class ObjectToArrayPipe implements PipeTransform{ - public transform(input: { [key: string]: any }): ITransformedObj[]{ - return Object.keys(input).map(key => { - return { - key, - value: input[key] - } - }) - } -} \ No newline at end of file diff --git a/src/util/pipes/pagination.pipe.ts b/src/util/pipes/pagination.pipe.ts deleted file mode 100644 index b574b1f16115714113d365c214dd9fc2c600d953..0000000000000000000000000000000000000000 --- a/src/util/pipes/pagination.pipe.ts +++ /dev/null @@ -1,15 +0,0 @@ -import { Pipe, PipeTransform } from "@angular/core"; - -@Pipe({ - name : 'searchResultPagination', -}) - -export class SearchResultPaginationPipe implements PipeTransform { - private _hitsPerPage: number = 15 - private _pageNumber: number = 0 - public transform(arr: any[], pageNumber?: number, hitsPerPage?: number) { - return arr.filter((_, idx) => - (idx >= (pageNumber === undefined ? this._pageNumber : pageNumber) * (hitsPerPage === undefined ? this._hitsPerPage : hitsPerPage)) && - idx < ((pageNumber === undefined ? this._pageNumber : pageNumber) + 1) * (hitsPerPage === undefined ? this._hitsPerPage : hitsPerPage)) - } -} diff --git a/src/util/pipes/pluginBtnFabColor.pipe.ts b/src/util/pipes/pluginBtnFabColor.pipe.ts deleted file mode 100644 index eb4d28a82683529a6e879840e8d5bef49c2ebf04..0000000000000000000000000000000000000000 --- a/src/util/pipes/pluginBtnFabColor.pipe.ts +++ /dev/null @@ -1,15 +0,0 @@ -import { Pipe, PipeTransform } from "@angular/core"; - -@Pipe({ - name: 'pluginBtnFabColorPipe', -}) - -export class PluginBtnFabColorPipe implements PipeTransform { - public transform([launchedSet, minimisedSet], pluginName) { - return minimisedSet.has(pluginName) - ? 'primary' - : launchedSet.has(pluginName) - ? 'accent' - : 'basic' - } -} diff --git a/src/util/pipes/sortDataEntriesIntoRegion.pipe.ts b/src/util/pipes/sortDataEntriesIntoRegion.pipe.ts deleted file mode 100644 index 71433de5592ca49593ca727d6e972176529f64fe..0000000000000000000000000000000000000000 --- a/src/util/pipes/sortDataEntriesIntoRegion.pipe.ts +++ /dev/null @@ -1,15 +0,0 @@ -import { Pipe, PipeTransform } from "@angular/core"; -import { IDataEntry } from "../../services/stateStore.service"; - -@Pipe({ - name : 'sortDataEntriesToRegion', -}) - -export class SortDataEntriesToRegion implements PipeTransform { - public transform(regions: any[], datasets: IDataEntry[]): Array<{region: any, searchResults: IDataEntry[]}> { - return regions.map(region => ({ - region, - searchResults : datasets.filter(dataset => dataset.parcellationRegion.some(r => r.name === region.name)), - })) - } -} diff --git a/src/util/pipes/spatialLandmarksToDatabrowserItem.pipe.ts b/src/util/pipes/spatialLandmarksToDatabrowserItem.pipe.ts deleted file mode 100644 index 6972299d58fde68b710c8992461cc476b33c2386..0000000000000000000000000000000000000000 --- a/src/util/pipes/spatialLandmarksToDatabrowserItem.pipe.ts +++ /dev/null @@ -1,29 +0,0 @@ -import { Pipe, PipeTransform } from "@angular/core"; -import { IDataEntry, ILandmark, IPlaneLandmarkGeometry, IPointLandmarkGeometry } from "../../services/stateStore.service"; - -@Pipe({ - name : 'spatialLandmarksToDataBrowserItemPipe', -}) - -export class SpatialLandmarksToDataBrowserItemPipe implements PipeTransform { - public transform(landmarks: ILandmark[]): Array<{region: any, searchResults: Array<Partial<IDataEntry>>}> { - return landmarks.map(landmark => ({ - region : Object.assign({}, landmark, { - spatialLandmark : true, - }, landmark.geometry.type === 'point' - ? { - position : (landmark.geometry as IPointLandmarkGeometry).position.map(v => v * 1e6), - } - : landmark.geometry.type === 'plane' - ? { - POIs : (landmark.geometry as IPlaneLandmarkGeometry).corners.map(corner => corner.map(coord => coord * 1e6)), - } - : {}), - searchResults : [{ - name : 'Associated dataset', - type : 'Associated dataset', - files : landmark.files, - }], - })) - } -} diff --git a/src/util/pipes/templateParcellationHasMoreInfo.pipe.ts b/src/util/pipes/templateParcellationHasMoreInfo.pipe.ts deleted file mode 100644 index e94e975da6559d70133b60c203b2a3535673f6ba..0000000000000000000000000000000000000000 --- a/src/util/pipes/templateParcellationHasMoreInfo.pipe.ts +++ /dev/null @@ -1,48 +0,0 @@ -import { Pipe, PipeTransform } from "@angular/core"; -import { IPublication } from "src/services/stateStore.service"; - -interface KgSchemaId { - kgSchema: string - kgId: string -} - -interface MoreInfo { - name: string - description: string - publications: IPublication[] - originDatasets: KgSchemaId[] - mindsId: KgSchemaId -} - -const notNullNotEmptyString = (string) => !!string && string !== '' -const notEmptyArray = (arr) => !!arr && arr instanceof Array && arr.length > 0 - -@Pipe({ - name: 'templateParcellationHasMoreInfoPipe', -}) - -export class TemplateParcellationHasMoreInfo implements PipeTransform { - public transform(obj: any): MoreInfo { - - const { description, properties = {}, publications, name, originDatasets, mindsId } = obj - const { description: pDescriptions, publications: pPublications, name: pName, mindsId: pMindsId } = properties - - const hasMoreInfo = notNullNotEmptyString(description) - || notNullNotEmptyString(pDescriptions) - || notEmptyArray(publications) - || notEmptyArray(pPublications) - || notEmptyArray(originDatasets) - - return hasMoreInfo - ? { - name: pName || name, - description: pDescriptions || description, - publications: pPublications || publications, - originDatasets: notEmptyArray(originDatasets) - ? originDatasets - : [{ kgSchema: null, kgId: null }], - mindsId: pMindsId || mindsId, - } - : null - } -} diff --git a/src/util/pluginHandler.ts b/src/util/pluginHandler.ts deleted file mode 100644 index e2767e29412d48300bdf124231ac6f8408069626..0000000000000000000000000000000000000000 --- a/src/util/pluginHandler.ts +++ /dev/null @@ -1,12 +0,0 @@ -export class PluginHandler { - public onShutdown: (callback: () => void) => void - public blink: (sec?: number) => void - public shutdown: () => void - - public initState?: any - public initStateUrl?: string - - public setInitManifestUrl: (url: string|null) => void - - public setProgressIndicator: (progress: number) => void -} diff --git a/src/util/pureConstant.service.ts b/src/util/pureConstant.service.ts index f15f92263977965fadb64d168fcab5c81a9fd597..e3ff4e53e53f5919751e12cb7e80e961310340bf 100644 --- a/src/util/pureConstant.service.ts +++ b/src/util/pureConstant.service.ts @@ -1,11 +1,10 @@ import { Inject, Injectable, OnDestroy } from "@angular/core"; import { Store, select } from "@ngrx/store"; -import { Observable, Subscription, of, forkJoin, fromEvent, combineLatest } from "rxjs"; +import { Observable, Subscription, of, forkJoin, combineLatest } from "rxjs"; import { viewerConfigSelectorUseMobileUi } from "src/services/state/viewerConfig.store.helper"; -import { shareReplay, tap, scan, catchError, filter, switchMap, map, take, distinctUntilChanged, mapTo } from "rxjs/operators"; +import { shareReplay, tap, scan, catchError, filter, switchMap, map, distinctUntilChanged, mapTo } from "rxjs/operators"; import { HttpClient } from "@angular/common/http"; import { viewerStateFetchedTemplatesSelector, viewerStateSetFetchedAtlases } from "src/services/state/viewerState.store.helper"; -import { AtlasWorkerService } from "src/atlasViewer/atlasViewer.workerService.service"; import { LoggingService } from "src/logging"; import { viewerStateFetchedAtlasesSelector, viewerStateSelectedTemplateSelector } from "src/services/state/viewerState/selectors"; import { BS_ENDPOINT } from "src/util/constants"; @@ -185,15 +184,6 @@ Raise/track issues at github repo: <a target = "_blank" href = "${this.repoUrl}" return this._backendUrl } - /** - * TODO remove - * when removing, also remove relevant worker code - */ - private workerUpdateParcellation$ = fromEvent(this.workerService.worker, 'message').pipe( - filter((message: MessageEvent) => message && message.data && message.data.type === 'UPDATE_PARCELLATION_REGIONS'), - map(({ data }) => data) - ) - public getRegionDetail(atlasId: string, parcId: string, spaceId: string, region: any) { return this.http.get<TRegionDetail>( `${this.bsEndpoint}/atlases/${encodeURIComponent(atlasId)}/parcellations/${encodeURIComponent(parcId)}/regions/${encodeURIComponent(region.name)}`, @@ -330,7 +320,6 @@ Raise/track issues at github repo: <a target = "_blank" href = "${this.repoUrl}" private store: Store<any>, private http: HttpClient, private log: LoggingService, - private workerService: AtlasWorkerService, @Inject(BS_ENDPOINT) private bsEndpoint: string, ){ this.darktheme$ = this.store.pipe( diff --git a/src/util/util.module.ts b/src/util/util.module.ts index 51b202ea5664691f4aa242bdfeed59516d6f4b6b..4d817736e98a231bfde294dd19b751fd44f3db63 100644 --- a/src/util/util.module.ts +++ b/src/util/util.module.ts @@ -1,10 +1,8 @@ import { NgModule } from "@angular/core"; import { FilterRowsByVisbilityPipe } from "src/components/flatTree/filterRowsByVisibility.pipe"; -import { DelayEventDirective } from "./directives/delayEvent.directive"; import { KeyListner } from "./directives/keyDownListener.directive"; import { StopPropagationDirective } from "./directives/stopPropagation.directive"; -import { FilterNullPipe } from "./pipes/filterNull.pipe"; import { IncludesPipe } from "./pipes/includes.pipe"; import { SafeResourcePipe } from "./pipes/safeResource.pipe"; import { CaptureClickListenerDirective } from "./directives/captureClickListener.directive"; @@ -15,17 +13,12 @@ import { MediaQueryDirective } from './directives/mediaQuery.directive' import { LayoutModule } from "@angular/cdk/layout"; import { MapToPropertyPipe } from "./pipes/mapToProperty.pipe"; import { ClickOutsideDirective } from "src/util/directives/clickOutside.directive"; -import { CounterDirective } from "./directives/counter.directive"; import { GetNthElementPipe } from "./pipes/getNthElement.pipe"; import { ParseAsNumberPipe } from "./pipes/parseAsNumber.pipe"; import { GetUniquePipe } from "./pipes/getUnique.pipe"; import { GetPropertyPipe } from "./pipes/getProperty.pipe"; import { FilterArrayPipe } from "./pipes/filterArray.pipe"; -import { FilterByPropertyPipe } from "./pipes/filterByProperty.pipe"; -import { ArrayContainsPipe } from "./pipes/arrayContains.pipe"; import { DoiParserPipe } from "./pipes/doiPipe.pipe"; -import { TmpParcNamePipe } from "./pipes/_tmpParcName.pipe"; -import { ObjectToArrayPipe } from "./pipes/objToArray.pipe"; import { GetFilenamePipe } from "./pipes/getFilename.pipe"; @NgModule({ @@ -33,10 +26,8 @@ import { GetFilenamePipe } from "./pipes/getFilename.pipe"; LayoutModule ], declarations: [ - FilterNullPipe, FilterRowsByVisbilityPipe, StopPropagationDirective, - DelayEventDirective, KeyListner, IncludesPipe, SafeResourcePipe, @@ -47,24 +38,17 @@ import { GetFilenamePipe } from "./pipes/getFilename.pipe"; MediaQueryDirective, MapToPropertyPipe, ClickOutsideDirective, - CounterDirective, GetNthElementPipe, ParseAsNumberPipe, GetUniquePipe, GetPropertyPipe, FilterArrayPipe, - FilterByPropertyPipe, - ArrayContainsPipe, DoiParserPipe, - TmpParcNamePipe, - ObjectToArrayPipe, GetFilenamePipe, ], exports: [ - FilterNullPipe, FilterRowsByVisbilityPipe, StopPropagationDirective, - DelayEventDirective, KeyListner, IncludesPipe, SafeResourcePipe, @@ -75,17 +59,12 @@ import { GetFilenamePipe } from "./pipes/getFilename.pipe"; MediaQueryDirective, MapToPropertyPipe, ClickOutsideDirective, - CounterDirective, GetNthElementPipe, ParseAsNumberPipe, GetUniquePipe, GetPropertyPipe, FilterArrayPipe, - FilterByPropertyPipe, - ArrayContainsPipe, DoiParserPipe, - TmpParcNamePipe, - ObjectToArrayPipe, GetFilenamePipe, ] }) diff --git a/src/viewerModule/nehuba/nehubaViewerGlue/nehubaViewerGlue.component.ts b/src/viewerModule/nehuba/nehubaViewerGlue/nehubaViewerGlue.component.ts index c071875bb5faba2dd631d73585b30e4f8a748fd5..4b203fcbf7c3bb734798e2d70cd29feeb4547b66 100644 --- a/src/viewerModule/nehuba/nehubaViewerGlue/nehubaViewerGlue.component.ts +++ b/src/viewerModule/nehuba/nehubaViewerGlue/nehubaViewerGlue.component.ts @@ -128,6 +128,10 @@ export class NehubaGlueCmp implements IViewer<'nehuba'>, OnChanges, OnDestroy, A }))), ) + public filterCustomLandmark(lm: any){ + return !!lm['showInSliceView'] + } + public panelOrder$ = this.store$.pipe( select(ngViewerSelectorPanelOrder), distinctUntilChanged(), diff --git a/src/viewerModule/nehuba/nehubaViewerGlue/nehubaViewerGlue.template.html b/src/viewerModule/nehuba/nehubaViewerGlue/nehubaViewerGlue.template.html index d79c49a59f4708a74e9ee9520fcd4038b6be0980..83852858e81d2b7e6953310670cdd92e7d252b19 100644 --- a/src/viewerModule/nehuba/nehubaViewerGlue/nehubaViewerGlue.template.html +++ b/src/viewerModule/nehuba/nehubaViewerGlue/nehubaViewerGlue.template.html @@ -25,19 +25,19 @@ [quick-tour-order]="quickTourSliceViewSlide.order" [quick-tour-overwrite-arrow]="sliceViewArrow" [quick-tour-overwrite-position]="quickTourOverwritingPos"> - <ng-content *ngTemplateOutlet="ngPanelOverlayTmpl; context: { panelIndex: panelOrder$ | async | getNthElement : 0 | parseAsNumber }"></ng-content> + <ng-content *ngTemplateOutlet="ngPanelOverlayTmpl; context: { panelIndex: panelOrder$ | async | getProperty : 0 | parseAsNumber }"></ng-content> </div> <div class="w-100 h-100 position-relative" cell-ii> - <ng-content *ngTemplateOutlet="ngPanelOverlayTmpl; context: { panelIndex: panelOrder$ | async | getNthElement : 1 | parseAsNumber }"></ng-content> + <ng-content *ngTemplateOutlet="ngPanelOverlayTmpl; context: { panelIndex: panelOrder$ | async | getProperty : 1 | parseAsNumber }"></ng-content> </div> <div class="w-100 h-100 position-relative" cell-iii> - <ng-content *ngTemplateOutlet="ngPanelOverlayTmpl; context: { panelIndex: panelOrder$ | async | getNthElement : 2 | parseAsNumber }"></ng-content> + <ng-content *ngTemplateOutlet="ngPanelOverlayTmpl; context: { panelIndex: panelOrder$ | async | getProperty : 2 | parseAsNumber }"></ng-content> </div> <div class="w-100 h-100 position-relative" cell-iv quick-tour [quick-tour-description]="quickTour3dViewSlide.description" [quick-tour-order]="quickTour3dViewSlide.order"> - <ng-content *ngTemplateOutlet="ngPanelOverlayTmpl; context: { panelIndex: panelOrder$ | async | getNthElement : 3 | parseAsNumber }"></ng-content> + <ng-content *ngTemplateOutlet="ngPanelOverlayTmpl; context: { panelIndex: panelOrder$ | async | getProperty : 3 | parseAsNumber }"></ng-content> </div> </current-layout> @@ -84,7 +84,7 @@ <!-- customLandmarks --> <!-- only show landmarks in slice views --> - <landmark-2d-flat-cmp *ngFor="let lm of (customLandmarks$ | async | filterByProperty : 'showInSliceView')" + <landmark-2d-flat-cmp *ngFor="let lm of (customLandmarks$ | async | filterArray : filterCustomLandmark)" (mouseenter)="handleMouseEnterCustomLandmark(lm)" (mouseleave)="handleMouseLeaveCustomLandmark(lm)" [color]="lm.color || [255, 255, 255]" diff --git a/worker/worker.js b/worker/worker.js index cd05c6ae4d954567cbf8411f2df2247269896065..2c73c75676964ed3df742e9d412aa329badc4258 100644 --- a/worker/worker.js +++ b/worker/worker.js @@ -17,7 +17,6 @@ if (typeof self.importScripts === 'function') self.importScripts('./worker-plot const validTypes = [ 'GET_LANDMARKS_VTK', 'GET_USERLANDMARKS_VTK', - 'BUILD_REGION_SELECTION_TREE', 'PROPAGATE_PARC_REGION_ATTR' ] @@ -32,8 +31,6 @@ const VALID_METHODS = [ const validOutType = [ 'ASSEMBLED_LANDMARKS_VTK', 'ASSEMBLED_USERLANDMARKS_VTK', - 'RETURN_REBUILT_REGION_SELECTION_TREE', - 'UPDATE_PARCELLATION_REGIONS' ] const getVertexHeader = (numVertex) => `POINTS ${numVertex} float` @@ -229,80 +226,6 @@ const getuserLandmarksVtk = (action) => { }) } -const rebuildSelectedRegion = (payload) => { - const { selectedRegions, regions } = payload - - /** - * active tree branch - * branch is active if ALL children are active - */ - const activeTreeBranch = [] - const isRegionActive = (region) => selectedRegions.some(r => r.name === region.name) - || region.children && region.children.length > 0 && region.children.every(isRegionActive) - - /** - * some active tree branch - * branch is active if SOME children are active - */ - const someActiveTreeBranch = [] - const isSomeRegionActive = (region) => selectedRegions.some(r => r.name === region.name) - || region.children && region.children.length > 0 && region.children.some(isSomeRegionActive) - - const handleRegion = (r) => { - isRegionActive(r) ? activeTreeBranch.push(r) : {} - isSomeRegionActive(r) ? someActiveTreeBranch.push(r) : {} - if (r.children && r.children.length > 0) - r.children.forEach(handleRegion) - } - regions.forEach(handleRegion) - postMessage({ - type: 'RETURN_REBUILT_REGION_SELECTION_TREE', - rebuiltSelectedRegions: activeTreeBranch, - rebuiltSomeSelectedRegions: someActiveTreeBranch - }) -} -const recursivePropagateAttri = (region, inheritAttrsOpts) => { - - const inheritAttrs = Object.keys(inheritAttrsOpts) - - const returnRegion = { - ...region - } - const newInhAttrsOpts = {} - for (const attr of inheritAttrs){ - returnRegion[attr] = returnRegion[attr] || inheritAttrsOpts[attr] - newInhAttrsOpts[attr] = returnRegion[attr] || inheritAttrsOpts[attr] - } - returnRegion.children = returnRegion.children && Array.isArray(returnRegion.children) - ? returnRegion.children.map(c => recursivePropagateAttri(c, newInhAttrsOpts)) - : null - return returnRegion -} - -const propagateAttri = (parcellation, inheritAttrsOpts) => { - const inheritAttrs = Object.keys(inheritAttrsOpts) - if (inheritAttrs.indexOf('children') >= 0) throw new Error(`children attr cannot be inherited`) - - const regions = Array.isArray(parcellation.regions) - ? parcellation.regions.map(r => recursivePropagateAttri(r, inheritAttrsOpts)) - : [] - - return { - ...parcellation, - regions - } -} - -const processParcRegionAttr = (payload) => { - const { parcellation, inheritAttrsOpts } = payload - const p = propagateAttri(parcellation, inheritAttrsOpts) - postMessage({ - ...payload, - type: 'UPDATE_PARCELLATION_REGIONS', - parcellation: p - }) -} - let plotyVtkUrl onmessage = (message) => { @@ -355,12 +278,6 @@ onmessage = (message) => { case 'GET_USERLANDMARKS_VTK': getuserLandmarksVtk(message.data) return - case 'BUILD_REGION_SELECTION_TREE': - rebuildSelectedRegion(message.data) - return - case 'PROPAGATE_PARC_REGION_ATTR': - processParcRegionAttr(message.data) - return default: console.warn('unhandled worker action', message) }