From b66277d4136d7c0aab58044c3cd04c0d252ac33c Mon Sep 17 00:00:00 2001 From: fsdavid <daviti1@mail.com> Date: Fri, 17 Jan 2020 14:36:59 +0100 Subject: [PATCH] fix lint --- ...mplateCoordinatesTransformation.service.ts | 70 ++++++++--------- .../nehubaContainer.component.ts | 4 +- .../statusCard/statusCard.component.ts | 14 ++-- .../viewerState.useEffect.ts | 76 +++++++++---------- 4 files changed, 82 insertions(+), 82 deletions(-) diff --git a/src/services/templateCoordinatesTransformation.service.ts b/src/services/templateCoordinatesTransformation.service.ts index 1f72fe36d..5eb89e6ea 100644 --- a/src/services/templateCoordinatesTransformation.service.ts +++ b/src/services/templateCoordinatesTransformation.service.ts @@ -2,45 +2,45 @@ import {Injectable} from "@angular/core"; import {HttpClient, HttpHeaders} from "@angular/common/http"; @Injectable({ - providedIn: 'root', + providedIn: 'root', }) export class TemplateCoordinatesTransformation { - constructor(private httpClient: HttpClient) {} + constructor(private httpClient: HttpClient) {} - getPointCoordinatesForTemplate(sourceTemplateName, targetTemplateName, coordinates) { - const url = 'https://hbp-spatial-backend.apps-dev.hbp.eu/v1/transform-points' - const httpOptions = { - headers: new HttpHeaders({ - 'Content-Type': 'application/json' - }) - } + getPointCoordinatesForTemplate(sourceTemplateName, targetTemplateName, coordinates) { + const url = 'https://hbp-spatial-backend.apps-dev.hbp.eu/v1/transform-points' + const httpOptions = { + headers: new HttpHeaders({ + 'Content-Type': 'application/json' + }) + } - let convertedPoints = new Promise((resolve, reject) => { - let timeOut = true - setTimeout(() => { - if (timeOut) reject('Timed out') - },3000) + const convertedPoints = new Promise((resolve, reject) => { + let timeOut = true + setTimeout(() => { + if (timeOut) reject('Timed out') + },3000) - this.httpClient.post( - url, - JSON.stringify({ - source_points: [[...coordinates.map(c => c/1000000)]], - source_space: sourceTemplateName, - target_space: targetTemplateName - }), - httpOptions - ).toPromise().then( - res => { - timeOut = false - resolve(res['target_points'][0].map(r=> r*1000000)) - }, - msg => { - timeOut = false - reject(msg) - } - ) - }) - return convertedPoints - } + this.httpClient.post( + url, + JSON.stringify({ + 'source_points': [[...coordinates.map(c => c/1000000)]], + 'source_space': sourceTemplateName, + 'target_space': targetTemplateName + }), + httpOptions + ).toPromise().then( + res => { + timeOut = false + resolve(res['target_points'][0].map(r=> r*1000000)) + }, + msg => { + timeOut = false + reject(msg) + } + ) + }) + return convertedPoints + } } \ No newline at end of file diff --git a/src/ui/nehubaContainer/nehubaContainer.component.ts b/src/ui/nehubaContainer/nehubaContainer.component.ts index 619a30714..3eaf0b5e3 100644 --- a/src/ui/nehubaContainer/nehubaContainer.component.ts +++ b/src/ui/nehubaContainer/nehubaContainer.component.ts @@ -588,7 +588,7 @@ export class NehubaContainer implements OnInit, OnChanges, OnDestroy { this.subscriptions.push( this.newViewer$.pipe( withLatestFrom(this.selectedParcellation$.pipe( - startWith(<object> null), + startWith(null as object), )), ).subscribe(([templateSelected, parcellationSelected]) => { this.store.dispatch({ @@ -983,7 +983,7 @@ export class NehubaContainer implements OnInit, OnChanges, OnDestroy { const { voxelSize = [1e6, 1e6, 1e6], voxelCoordinates = [0, 0, 0] } = (pose && pose.position) || {} const { orientation = [0, 0, 0, 1] } = pose || {} - let initNavigation = { + const initNavigation = { orientation: orientation, perspectiveOrientation, perspectiveZoom, diff --git a/src/ui/nehubaContainer/statusCard/statusCard.component.ts b/src/ui/nehubaContainer/statusCard/statusCard.component.ts index 9389c876c..6bd0f103a 100644 --- a/src/ui/nehubaContainer/statusCard/statusCard.component.ts +++ b/src/ui/nehubaContainer/statusCard/statusCard.component.ts @@ -28,20 +28,20 @@ export class StatusCardComponent implements OnInit{ private store$: Store<IavRootStoreInterface>, ) { const viewerState$ = this.store$.pipe( - select('viewerState'), - shareReplay(1), + select('viewerState'), + shareReplay(1), ) this.selectedTemplateRoot$ = viewerState$.pipe( - select('fetchedTemplates'), - distinctUntilChanged(), + select('fetchedTemplates'), + distinctUntilChanged(), ) } ngOnInit(): void { this.subscriptions.push( - this.selectedTemplateRoot$.subscribe(template => { - this.selectedTemplateRoot = template.find(t => t.name === this.selectedTemplateName) - }) + this.selectedTemplateRoot$.subscribe(template => { + this.selectedTemplateRoot = template.find(t => t.name === this.selectedTemplateName) + }) ) } diff --git a/src/ui/viewerStateController/viewerState.useEffect.ts b/src/ui/viewerStateController/viewerState.useEffect.ts index 140355e79..fddfc2893 100644 --- a/src/ui/viewerStateController/viewerState.useEffect.ts +++ b/src/ui/viewerStateController/viewerState.useEffect.ts @@ -124,35 +124,35 @@ export class ViewerStateControllerUseEffect implements OnInit, OnDestroy { if (templateSelected && templateSelected.name === name) { return false } return true }), - withLatestFrom( - viewerState$.pipe( - select('fetchedTemplates'), - ), - viewerState$.pipe( - select('navigation'), - ), + withLatestFrom( + viewerState$.pipe( + select('fetchedTemplates'), ), + viewerState$.pipe( + select('navigation'), + ), + ), mergeMap(([[name, templateSelected], availableTemplates, navigation]) => - this.coordinatesTransformation.getPointCoordinatesForTemplate(templateSelected.name, name, navigation.position) - .then(res => { - navigation.position = res - return { - name: name, - templateSelected: templateSelected, - availableTemplates: availableTemplates, - coordinates: res, - navigation: navigation - } - }) - .catch(() => { - return { - name: name, - templateSelected: templateSelected, - availableTemplates: availableTemplates, - coordinates: null, - navigation: null - } - }) + this.coordinatesTransformation.getPointCoordinatesForTemplate(templateSelected.name, name, navigation.position) + .then(res => { + navigation.position = res + return { + name: name, + templateSelected: templateSelected, + availableTemplates: availableTemplates, + coordinates: res, + navigation: navigation + } + }) + .catch(() => { + return { + name: name, + templateSelected: templateSelected, + availableTemplates: availableTemplates, + coordinates: null, + navigation: null + } + }) ), map(({name, templateSelected, availableTemplates, coordinates, navigation}) => { const newTemplateTobeSelected = availableTemplates.find(t => t.name === name) @@ -166,20 +166,20 @@ export class ViewerStateControllerUseEffect implements OnInit, OnDestroy { } if (!coordinates && !navigation) - return { - type: NEWVIEWER, - selectTemplate: newTemplateTobeSelected, - selectParcellation: newTemplateTobeSelected.parcellations[0], - } + return { + type: NEWVIEWER, + selectTemplate: newTemplateTobeSelected, + selectParcellation: newTemplateTobeSelected.parcellations[0], + } - const deepCopiedState = JSON.parse(JSON.stringify(newTemplateTobeSelected)) - const initNavigation = deepCopiedState.nehubaConfig.dataset.initialNgState.navigation + const deepCopiedState = JSON.parse(JSON.stringify(newTemplateTobeSelected)) + const initNavigation = deepCopiedState.nehubaConfig.dataset.initialNgState.navigation - initNavigation.zoomFactor = navigation.zoom - initNavigation.pose.position.voxelCoordinates = coordinates.map((c, i) => c/initNavigation.pose.position.voxelSize[i]) - initNavigation.pose.orientation = navigation.orientation + initNavigation.zoomFactor = navigation.zoom + initNavigation.pose.position.voxelCoordinates = coordinates.map((c, i) => c/initNavigation.pose.position.voxelSize[i]) + initNavigation.pose.orientation = navigation.orientation - return { + return { type: NEWVIEWER, selectTemplate: deepCopiedState, selectParcellation: newTemplateTobeSelected.parcellations[0], -- GitLab