diff --git a/e2e/src/layout/layout.e2e-spec.js b/e2e/src/layout/layout.e2e-spec.js index 148a11d4c32867bdc26c5d4adc42872ce7aef5cc..45949849da49cde44630876060fc88ce35ef945c 100644 --- a/e2e/src/layout/layout.e2e-spec.js +++ b/e2e/src/layout/layout.e2e-spec.js @@ -11,6 +11,13 @@ describe('> sidenav', () => { await layoutPage.goto('/?templateSelected=MNI+152+ICBM+2009c+Nonlinear+Asymmetric&parcellationSelected=JuBrain+Cytoarchitectonic+Atlas') await layoutPage.wait(MAT_SIDENAV_TIMEOUT) await layoutPage.dismissModal() + + do { + + } while( + await this.wait(100), + !(await this.viewerIsPopulated()) + ) }) it('> on init, side panel should be visible', async () => { @@ -49,6 +56,13 @@ describe('> status panel', () => { await layoutPage.goto('/?templateSelected=MNI+152+ICBM+2009c+Nonlinear+Asymmetric&parcellationSelected=JuBrain+Cytoarchitectonic+Atlas') await layoutPage.wait(MAT_SIDENAV_TIMEOUT) await layoutPage.dismissModal() + + do { + + } while( + await this.wait(100), + !(await this.viewerIsPopulated()) + ) }) afterEach(() => { diff --git a/e2e/src/util.js b/e2e/src/util.js index 00f524b8efafe85c114276d31988a51e6dad168c..6d4a1a336f808f1aed9b1eeaff486ded4b9ebe7d 100644 --- a/e2e/src/util.js +++ b/e2e/src/util.js @@ -133,10 +133,14 @@ class WdBase{ await this._browser.get(actualUrl) } + // if doNotAutomate is not set + // should wait for async operations to end if (!doNotAutomate) { await this.wait(200) await this.dismissModal() await this.wait(200) + await this.waitForAsync() + } } @@ -620,13 +624,23 @@ class WdIavPage extends WdLayoutPage{ } async viewerIsPopulated() { - const ngContainer = await this._browser.findElement( - By.id('neuroglancer-container') - ) - const canvas = await ngContainer.findElement( - By.tagName('canvas') - ) - return !!canvas + try { + const ngContainer = await this._browser.findElement( + By.id('neuroglancer-container') + ) + if (! (await ngContainer.isDisplayed())) { + return false + } + const canvas = await ngContainer.findElement( + By.tagName('canvas') + ) + if (!(await canvas.isDisplayed())) { + return false + } + return true + } catch (e) { + return false + } } async getNavigationState() { diff --git a/src/atlasViewer/atlasViewer.constantService.service.ts b/src/atlasViewer/atlasViewer.constantService.service.ts index d198eaa62087796d64fd18e31bb829800022071d..56057d3be8df33a05ce589edb85a9a54b1b5cb27 100644 --- a/src/atlasViewer/atlasViewer.constantService.service.ts +++ b/src/atlasViewer/atlasViewer.constantService.service.ts @@ -101,7 +101,11 @@ export class AtlasViewerConstantsServices implements OnDestroy { }) ) - public initFetchTemplate$ = this.http.get(`${this.backendUrl}templates`, { responseType: 'json' }).pipe( + public getTemplateEndpoint$ = this.http.get(`${this.backendUrl}templates`, { responseType: 'json' }).pipe( + shareReplay(1) + ) + + public initFetchTemplate$ = this.getTemplateEndpoint$.pipe( tap((arr: any[]) => this.totalTemplates = arr.length), switchMap((templates: string[]) => merge( ...templates.map(templateName => this.fetchTemplate(templateName).pipe( diff --git a/src/services/state/viewerState.store.ts b/src/services/state/viewerState.store.ts index 32aa245885a85a13db77008022d6e11834896c98..455ea30b863b88370210002763fcaebf1319248d 100644 --- a/src/services/state/viewerState.store.ts +++ b/src/services/state/viewerState.store.ts @@ -7,7 +7,7 @@ import { IUserLandmark } from 'src/atlasViewer/atlasViewer.apiService.service'; import { INgLayerInterface } from 'src/atlasViewer/atlasViewer.component'; import { getViewer } from 'src/util/fn'; import { LoggingService } from 'src/logging'; -import { generateLabelIndexId, IavRootStoreInterface, viewerState } from '../stateStore.service'; +import { generateLabelIndexId, IavRootStoreInterface } from '../stateStore.service'; import { GENERAL_ACTION_TYPES } from '../stateStore.service' import { MOUSEOVER_USER_LANDMARK, CLOSE_SIDE_PANEL } from './uiState.store'; diff --git a/src/ui/nehubaContainer/splashScreen/splashScreen.component.ts b/src/ui/nehubaContainer/splashScreen/splashScreen.component.ts index f20cb3bc477f31979b168d8624aacf1161dbe299..8681248e788a5476e5d0b28abea58b32570b1d29 100644 --- a/src/ui/nehubaContainer/splashScreen/splashScreen.component.ts +++ b/src/ui/nehubaContainer/splashScreen/splashScreen.component.ts @@ -1,7 +1,7 @@ import { AfterViewInit, Component, ElementRef, Pipe, PipeTransform, ViewChild } from "@angular/core"; import { select, Store } from "@ngrx/store"; -import { fromEvent, Observable, Subject, Subscription } from "rxjs"; -import { bufferTime, filter, map, switchMap, take, withLatestFrom } from 'rxjs/operators' +import { fromEvent, Observable, Subject, Subscription, combineLatest } from "rxjs"; +import { bufferTime, filter, map, switchMap, take, withLatestFrom, shareReplay, startWith } from 'rxjs/operators' import { AtlasViewerConstantsServices } from "src/atlasViewer/atlasViewer.constantService.service"; import { NEWVIEWER, ViewerStateInterface } from "src/services/stateStore.service"; @@ -15,6 +15,7 @@ import { NEWVIEWER, ViewerStateInterface } from "src/services/stateStore.service export class SplashScreen implements AfterViewInit { + public stillLoadingTemplates$: Observable<any> public loadedTemplate$: Observable<any[]> @ViewChild('parentContainer', {read: ElementRef}) private parentContainer: ElementRef @@ -25,11 +26,29 @@ export class SplashScreen implements AfterViewInit { constructor( private store: Store<ViewerStateInterface>, private constanceService: AtlasViewerConstantsServices, - private constantsService: AtlasViewerConstantsServices, ) { this.loadedTemplate$ = this.store.pipe( select('viewerState'), select('fetchedTemplates'), + shareReplay(1), + ) + + this.stillLoadingTemplates$ = combineLatest( + this.constanceService.getTemplateEndpoint$.pipe( + startWith(null) + ), + this.loadedTemplate$.pipe( + startWith([]) + ) + ).pipe( + map(([templateEndpoints, loadedTemplates]) => { + if (templateEndpoints && Array.isArray(templateEndpoints)) { + // TODO this is not exactly correct + return templateEndpoints.slice(loadedTemplates.length) + } else { + return null + } + }) ) } diff --git a/src/ui/nehubaContainer/splashScreen/splashScreen.template.html b/src/ui/nehubaContainer/splashScreen/splashScreen.template.html index 9d4a9b4ce15e5d02305353964bb1595d1fc598d1..af7271b054d41d2d589d5a7b2a6528480deff312 100644 --- a/src/ui/nehubaContainer/splashScreen/splashScreen.template.html +++ b/src/ui/nehubaContainer/splashScreen/splashScreen.template.html @@ -43,5 +43,12 @@ <mat-card-footer> </mat-card-footer> </mat-card> + <ng-container *ngIf="stillLoadingTemplates$ | async as stillLoadingTemplates"> + <div class="d-flex align-items-center p-4" *ngFor="let t of stillLoadingTemplates"> + <h1 class="mat-h1"> + <div class="spinnerAnimationCircle"></div> + </h1> + </div> + </ng-container> </div> </div> \ No newline at end of file