From f92ded438235f53850d2e79a797be23d4a2d0cd1 Mon Sep 17 00:00:00 2001
From: fsdavid <daviti1@mail.com>
Date: Wed, 18 May 2022 11:21:18 +0200
Subject: [PATCH] Connectivity review changes

---
 .../sapi/core/sapiParcellation.ts             | 14 ++++++++------
 src/atlasComponents/sapi/core/sapiSpace.ts    |  6 +++---
 src/atlasComponents/sapi/sapi.service.ts      | 19 ++++++++++++++-----
 src/atlasComponents/sapi/type.ts              |  5 ++---
 .../connectivityBrowser.component.ts          |  2 +-
 .../connectivityBrowser.stories.ts            |  2 +-
 .../connectivityBrowser.template.html         | 10 ----------
 .../connectivity/hasConnectivity.directive.ts |  2 +-
 8 files changed, 30 insertions(+), 30 deletions(-)

diff --git a/src/atlasComponents/sapi/core/sapiParcellation.ts b/src/atlasComponents/sapi/core/sapiParcellation.ts
index 4870493b3..4767cc289 100644
--- a/src/atlasComponents/sapi/core/sapiParcellation.ts
+++ b/src/atlasComponents/sapi/core/sapiParcellation.ts
@@ -1,7 +1,7 @@
 import { Observable } from "rxjs"
 import { SapiVolumeModel } from ".."
 import { SAPI } from "../sapi.service"
-import { SapiParcellationFeatureModel, SapiParcellationModel, SapiQueryParam, SapiRegionModel } from "../type"
+import {SapiParcellationFeatureModel, SapiParcellationModel, SapiQueryPriorityArg, SapiRegionModel} from "../type"
 
 type PaginationQuery = {
   size: number
@@ -10,6 +10,8 @@ type PaginationQuery = {
 
 type ParcellationPaginationQuery = {
   type?: string
+  size?: number
+  page: number
 }
 
 export class SAPIParcellation{
@@ -17,7 +19,7 @@ export class SAPIParcellation{
 
   }
 
-  getDetail(queryParam?: SapiQueryParam): Observable<SapiParcellationModel>{
+  getDetail(queryParam?: SapiQueryPriorityArg): Observable<SapiParcellationModel>{
     return this.sapi.httpGet<SapiParcellationModel>(
       `${this.sapi.bsEndpoint}/atlases/${encodeURIComponent(this.atlasId)}/parcellations/${encodeURIComponent(this.id)}`,
       null,
@@ -25,7 +27,7 @@ export class SAPIParcellation{
     )
   }
 
-  getRegions(spaceId: string, queryParam?: SapiQueryParam): Observable<SapiRegionModel[]> {
+  getRegions(spaceId: string, queryParam?: SapiQueryPriorityArg): Observable<SapiRegionModel[]> {
     return this.sapi.httpGet<SapiRegionModel[]>(
       `${this.sapi.bsEndpoint}/atlases/${encodeURIComponent(this.atlasId)}/parcellations/${encodeURIComponent(this.id)}/regions`,
       {
@@ -40,13 +42,13 @@ export class SAPIParcellation{
     )
   }
 
-  getFeatures(param?: PaginationQuery, parcPagination?: ParcellationPaginationQuery, queryParam?: SapiQueryParam): Observable<SapiParcellationFeatureModel[]> {
+  getFeatures(parcPagination?: ParcellationPaginationQuery, queryParam?: SapiQueryPriorityArg): Observable<SapiParcellationFeatureModel[]> {
     return this.sapi.httpGet<SapiParcellationFeatureModel[]>(
       `${this.sapi.bsEndpoint}/atlases/${encodeURIComponent(this.atlasId)}/parcellations/${encodeURIComponent(this.id)}/features`,
       {
         type: parcPagination?.type,
-        size: param?.size?.toString() || '5',
-        page: param?.page?.toString() || '0',
+        size: parcPagination?.size?.toString() || '5',
+        page: parcPagination?.page.toString() || '0',
       },
       queryParam
     )
diff --git a/src/atlasComponents/sapi/core/sapiSpace.ts b/src/atlasComponents/sapi/core/sapiSpace.ts
index 3ed79e8a7..3effd6f16 100644
--- a/src/atlasComponents/sapi/core/sapiSpace.ts
+++ b/src/atlasComponents/sapi/core/sapiSpace.ts
@@ -1,7 +1,7 @@
 import { Observable } from "rxjs"
 import { SAPI } from '../sapi.service'
 import { camelToSnake } from 'common/util'
-import { SapiQueryParam, SapiSpaceModel, SapiSpatialFeatureModel, SapiVolumeModel } from "../type"
+import {SapiQueryPriorityArg, SapiSpaceModel, SapiSpatialFeatureModel, SapiVolumeModel} from "../type"
 
 type FeatureResponse = {
   features: {
@@ -24,7 +24,7 @@ export class SAPISpace{
 
   constructor(private sapi: SAPI, public atlasId: string, public id: string){}
 
-  getModalities(param?: SapiQueryParam): Observable<FeatureResponse> {
+  getModalities(param?: SapiQueryPriorityArg): Observable<FeatureResponse> {
     return this.sapi.httpGet<FeatureResponse>(
       `${this.sapi.bsEndpoint}/atlases/${encodeURIComponent(this.atlasId)}/spaces/${encodeURIComponent(this.id)}/features`,
       null,
@@ -54,7 +54,7 @@ export class SAPISpace{
     )
   }
 
-  getDetail(param?: SapiQueryParam): Observable<SapiSpaceModel>{
+  getDetail(param?: SapiQueryPriorityArg): Observable<SapiSpaceModel>{
     return this.sapi.httpGet<SapiSpaceModel>(
       `${this.sapi.bsEndpoint}/atlases/${encodeURIComponent(this.atlasId)}/spaces/${encodeURIComponent(this.id)}`,
       null,
diff --git a/src/atlasComponents/sapi/sapi.service.ts b/src/atlasComponents/sapi/sapi.service.ts
index 465c43bbf..3ce34e05f 100644
--- a/src/atlasComponents/sapi/sapi.service.ts
+++ b/src/atlasComponents/sapi/sapi.service.ts
@@ -2,7 +2,16 @@ import { Injectable } from "@angular/core";
 import { HttpClient } from '@angular/common/http';
 import { map, shareReplay, tap } from "rxjs/operators";
 import { SAPIAtlas, SAPISpace } from './core'
-import { SapiAtlasModel, SapiParcellationModel, SapiQueryParam, SapiRegionalFeatureModel, SapiRegionModel, SapiSpaceModel, SpyNpArrayDataModel, SxplrCleanedFeatureModel } from "./type";
+import {
+  SapiAtlasModel,
+  SapiParcellationModel,
+  SapiQueryPriorityArg,
+  SapiRegionalFeatureModel,
+  SapiRegionModel,
+  SapiSpaceModel,
+  SpyNpArrayDataModel,
+  SxplrCleanedFeatureModel
+} from "./type";
 import { getExportNehuba } from "src/util/fn";
 import { SAPIParcellation } from "./core/sapiParcellation";
 import { SAPIRegion } from "./core/sapiRegion"
@@ -58,15 +67,15 @@ export class SAPI{
     return new SAPIRegion(this, atlasId, parcId, regionId)
   }
 
-  getSpaceDetail(atlasId: string, spaceId: string, param?: SapiQueryParam): Observable<SapiSpaceModel> {
+  getSpaceDetail(atlasId: string, spaceId: string, param?: SapiQueryPriorityArg): Observable<SapiSpaceModel> {
     return this.getSpace(atlasId, spaceId).getDetail(param)
   }
 
-  getParcDetail(atlasId: string, parcId: string, param?: SapiQueryParam): Observable<SapiParcellationModel> {
+  getParcDetail(atlasId: string, parcId: string, param?: SapiQueryPriorityArg): Observable<SapiParcellationModel> {
     return this.getParcellation(atlasId, parcId).getDetail(param)
   }
 
-  getParcRegions(atlasId: string, parcId: string, spaceId: string, queryParam?: SapiQueryParam): Observable<SapiRegionModel[]> {
+  getParcRegions(atlasId: string, parcId: string, spaceId: string, queryParam?: SapiQueryPriorityArg): Observable<SapiRegionModel[]> {
     const parc = this.getParcellation(atlasId, parcId)
     return parc.getRegions(spaceId, queryParam)
   }
@@ -85,7 +94,7 @@ export class SAPI{
     return this.http.get(`${SAPI.bsEndpoint}/modalities`)
   }
 
-  httpGet<T>(url: string, params?: Record<string, string>, sapiParam?: SapiQueryParam){
+  httpGet<T>(url: string, params?: Record<string, string>, sapiParam?: SapiQueryPriorityArg){
     const headers: Record<string, string> = {}
     if (sapiParam?.priority) {
       headers[PRIORITY_HEADER] = sapiParam.priority.toString()
diff --git a/src/atlasComponents/sapi/type.ts b/src/atlasComponents/sapi/type.ts
index 574975a95..687a916f5 100644
--- a/src/atlasComponents/sapi/type.ts
+++ b/src/atlasComponents/sapi/type.ts
@@ -110,7 +110,6 @@ export function guardPipe<
   )
 }
 
-export type SapiQueryParam = {
-  priority?: number
-  type?: string
+export type SapiQueryPriorityArg = {
+  priority: number
 }
diff --git a/src/atlasComponents/sapiViews/features/connectivity/connectivityBrowser/connectivityBrowser.component.ts b/src/atlasComponents/sapiViews/features/connectivity/connectivityBrowser/connectivityBrowser.component.ts
index a3cf0cb8c..df1f74668 100644
--- a/src/atlasComponents/sapiViews/features/connectivity/connectivityBrowser/connectivityBrowser.component.ts
+++ b/src/atlasComponents/sapiViews/features/connectivity/connectivityBrowser/connectivityBrowser.component.ts
@@ -197,7 +197,7 @@ export class ConnectivityBrowserComponent implements AfterViewInit, OnDestroy {
       this.fetching = true
       const type = this.types.find(t => t.name === this.selectedType).types[0]
       return this.sapi.getParcellation(this.atlas["@id"], this.parcellation["@id"])
-        .getFeatures({page: this.pageNumber, size: 1}, {type})
+        .getFeatures({type, page: this.pageNumber, size: 1},)
         .pipe(
           take(1),
           catchError(() => {
diff --git a/src/atlasComponents/sapiViews/features/connectivity/connectivityBrowser/connectivityBrowser.stories.ts b/src/atlasComponents/sapiViews/features/connectivity/connectivityBrowser/connectivityBrowser.stories.ts
index 34e44e557..870492b96 100644
--- a/src/atlasComponents/sapiViews/features/connectivity/connectivityBrowser/connectivityBrowser.stories.ts
+++ b/src/atlasComponents/sapiViews/features/connectivity/connectivityBrowser/connectivityBrowser.stories.ts
@@ -77,7 +77,7 @@ class ExampleConnectivityBrowserWrapper {
 
   loadDataset() {
     return this.sapi.getParcellation(this.atlas["@id"], this.parcellation["@id"])
-        .getFeatures({page: this.pageNumber, size: 1}, {type: this.type})
+        .getFeatures({type: this.type, page: this.pageNumber, size: 1})
         .pipe(
             take(1),
             catchError(() => {
diff --git a/src/atlasComponents/sapiViews/features/connectivity/connectivityBrowser/connectivityBrowser.template.html b/src/atlasComponents/sapiViews/features/connectivity/connectivityBrowser/connectivityBrowser.template.html
index 581154905..ee291d06c 100644
--- a/src/atlasComponents/sapiViews/features/connectivity/connectivityBrowser/connectivityBrowser.template.html
+++ b/src/atlasComponents/sapiViews/features/connectivity/connectivityBrowser/connectivityBrowser.template.html
@@ -33,16 +33,6 @@
                             class="w-100">
                 </mat-slider>
             </div>
-
-            <ng-container *ngIf="selectedDataset.description || (selectedDataset.data && selectedDataset.data.description)" >
-                <!--                    TODO please reimplmenent button to explore KG dataset-->
-                <button class="flex-grow-0 flex-shrink-0"
-                        mat-icon-button
-                        (click)="exportFullConnectivity()"
-                        matTooltip="Export full connectivity profile">
-                    <i class="fas fa-download"></i>
-                </button>
-            </ng-container>
         </div>
 
     </div>
diff --git a/src/atlasComponents/sapiViews/features/connectivity/hasConnectivity.directive.ts b/src/atlasComponents/sapiViews/features/connectivity/hasConnectivity.directive.ts
index 9f4577128..75b5edaad 100644
--- a/src/atlasComponents/sapiViews/features/connectivity/hasConnectivity.directive.ts
+++ b/src/atlasComponents/sapiViews/features/connectivity/hasConnectivity.directive.ts
@@ -69,7 +69,7 @@ export class HasConnectivity implements OnDestroy {
           const type = m.types[0]
           
           this.sapi.getParcellation(this.atlas["@id"], this.parcellation["@id"])
-            .getFeatures({page: 1, size: 1}, {type})
+            .getFeatures({type, page: 1, size: 1})
             .pipe(
               take(1),
               switchMap((res: any) => {
-- 
GitLab