From ae9d2dd2a4c5b0b6e5c55b7d5f4994092c18b902 Mon Sep 17 00:00:00 2001
From: Xiao Gui <xgui3783@gmail.com>
Date: Wed, 9 Jun 2021 11:02:41 +0200
Subject: [PATCH] chore: update preview thumbnails

---
 src/atlasComponents/splashScreen/index.ts     |   2 +-
 src/atlasComponents/splashScreen/module.ts    |   3 +-
 .../splashScreen/splashScreen.component.ts    |  14 ----
 .../atlasLayerSelector.component.ts           |  77 +++++++++++++++++-
 .../atlasLayerSelector.template.html          |  38 ++++-----
 src/atlasComponents/uiSelectors/module.ts     |   3 +-
 .../atlas-selection/allen-mouse-2015.png      | Bin
 .../atlas-selection/allen-mouse-2017.png      | Bin
 .../images/atlas-selection/allen-mouse.png    | Bin
 .../res/images/atlas-selection/bigbrain.png   | Bin
 .../res}/images/atlas-selection/colin27.png   | Bin
 .../atlas-selection/cortical-layers.png       | Bin
 .../cytoarchitectonic-maps.png                | Bin
 .../images/atlas-selection/difumo-1024.png    | Bin
 .../images/atlas-selection/difumo-128.png     | Bin
 .../images/atlas-selection/difumo-256.png     | Bin
 .../images/atlas-selection/difumo-512.png     | Bin
 .../res}/images/atlas-selection/difumo-64.png | Bin
 .../images/atlas-selection/firbe-long.png     | Bin
 .../images/atlas-selection/firbe-short.png    | Bin
 .../images/atlas-selection/freesurfer.png     | Bin
 .../atlas-selection/grey-white-matter.png     | Bin
 .../res}/images/atlas-selection/icbm2009c.png | Bin
 .../atlas-selection/short-bundle-hcp.png      | Bin
 .../images/atlas-selection/waxholm-v1.png     | Bin
 .../images/atlas-selection/waxholm-v2.png     | Bin
 .../images/atlas-selection/waxholm-v3.png     | Bin
 .../res}/images/atlas-selection/waxholm.png   | Bin
 28 files changed, 99 insertions(+), 38 deletions(-)
 rename {deploy/assets => src/res}/images/atlas-selection/allen-mouse-2015.png (100%)
 rename {deploy/assets => src/res}/images/atlas-selection/allen-mouse-2017.png (100%)
 rename {deploy/assets => src/res}/images/atlas-selection/allen-mouse.png (100%)
 rename deploy/assets/images/atlas-selection/bugbrain.png => src/res/images/atlas-selection/bigbrain.png (100%)
 rename {deploy/assets => src/res}/images/atlas-selection/colin27.png (100%)
 rename {deploy/assets => src/res}/images/atlas-selection/cortical-layers.png (100%)
 rename {deploy/assets => src/res}/images/atlas-selection/cytoarchitectonic-maps.png (100%)
 rename {deploy/assets => src/res}/images/atlas-selection/difumo-1024.png (100%)
 rename {deploy/assets => src/res}/images/atlas-selection/difumo-128.png (100%)
 rename {deploy/assets => src/res}/images/atlas-selection/difumo-256.png (100%)
 rename {deploy/assets => src/res}/images/atlas-selection/difumo-512.png (100%)
 rename {deploy/assets => src/res}/images/atlas-selection/difumo-64.png (100%)
 rename {deploy/assets => src/res}/images/atlas-selection/firbe-long.png (100%)
 rename {deploy/assets => src/res}/images/atlas-selection/firbe-short.png (100%)
 rename {deploy/assets => src/res}/images/atlas-selection/freesurfer.png (100%)
 rename {deploy/assets => src/res}/images/atlas-selection/grey-white-matter.png (100%)
 rename {deploy/assets => src/res}/images/atlas-selection/icbm2009c.png (100%)
 rename {deploy/assets => src/res}/images/atlas-selection/short-bundle-hcp.png (100%)
 rename {deploy/assets => src/res}/images/atlas-selection/waxholm-v1.png (100%)
 rename {deploy/assets => src/res}/images/atlas-selection/waxholm-v2.png (100%)
 rename {deploy/assets => src/res}/images/atlas-selection/waxholm-v3.png (100%)
 rename {deploy/assets => src/res}/images/atlas-selection/waxholm.png (100%)

diff --git a/src/atlasComponents/splashScreen/index.ts b/src/atlasComponents/splashScreen/index.ts
index 182552e5a..5927a7b64 100644
--- a/src/atlasComponents/splashScreen/index.ts
+++ b/src/atlasComponents/splashScreen/index.ts
@@ -1,2 +1,2 @@
-export { GetTemplateImageSrcPipe, ImgSrcSetPipe, SplashScreen } from "./splashScreen/splashScreen.component";
+export { GetTemplateImageSrcPipe, SplashScreen } from "./splashScreen/splashScreen.component";
 export { SplashUiModule } from './module'
\ No newline at end of file
diff --git a/src/atlasComponents/splashScreen/module.ts b/src/atlasComponents/splashScreen/module.ts
index e5817edb3..28f361cd4 100644
--- a/src/atlasComponents/splashScreen/module.ts
+++ b/src/atlasComponents/splashScreen/module.ts
@@ -4,7 +4,7 @@ import { ComponentsModule } from "src/components";
 import { KgTosModule } from "src/ui/kgtos/module";
 import { AngularMaterialModule } from "src/ui/sharedModules/angularMaterial.module";
 import { UtilModule } from "src/util";
-import { GetTemplateImageSrcPipe, SplashScreen, ImgSrcSetPipe } from "./splashScreen/splashScreen.component";
+import { GetTemplateImageSrcPipe, SplashScreen } from "./splashScreen/splashScreen.component";
 
 @NgModule({
   imports: [
@@ -17,7 +17,6 @@ import { GetTemplateImageSrcPipe, SplashScreen, ImgSrcSetPipe } from "./splashSc
   declarations: [
     SplashScreen,
     GetTemplateImageSrcPipe,
-    ImgSrcSetPipe,
   ],
   exports: [
     SplashScreen,
diff --git a/src/atlasComponents/splashScreen/splashScreen/splashScreen.component.ts b/src/atlasComponents/splashScreen/splashScreen/splashScreen.component.ts
index af098de5c..2435c4e08 100644
--- a/src/atlasComponents/splashScreen/splashScreen/splashScreen.component.ts
+++ b/src/atlasComponents/splashScreen/splashScreen/splashScreen.component.ts
@@ -64,17 +64,3 @@ export class GetTemplateImageSrcPipe implements PipeTransform {
     return `./res/image/${name.replace(/[|&;$%@()+,\s./]/g, '')}.png`
   }
 }
-
-@Pipe({
-  name: 'imgSrcSetPipe',
-})
-
-export class ImgSrcSetPipe implements PipeTransform {
-  public transform(src: string): string {
-    const regex = /^(.*?)(\.\w*?)$/.exec(src)
-    if (!regex) { throw new Error(`cannot find filename, ext ${src}`) }
-    const filename = regex[1]
-    const ext = regex[2]
-    return [100, 200, 300, 400].map(val => `${filename}-${val}${ext} ${val}w`).join(',')
-  }
-}
diff --git a/src/atlasComponents/uiSelectors/atlasLayerSelector/atlasLayerSelector.component.ts b/src/atlasComponents/uiSelectors/atlasLayerSelector/atlasLayerSelector.component.ts
index c85dff73d..591cb8367 100644
--- a/src/atlasComponents/uiSelectors/atlasLayerSelector/atlasLayerSelector.component.ts
+++ b/src/atlasComponents/uiSelectors/atlasLayerSelector/atlasLayerSelector.component.ts
@@ -1,4 +1,4 @@
-import { Component, OnInit, ViewChildren, QueryList, HostBinding, ViewChild, TemplateRef, ElementRef } from "@angular/core";
+import { Component, OnInit, ViewChildren, QueryList, HostBinding, ViewChild, TemplateRef, ElementRef, Pipe, PipeTransform } from "@angular/core";
 import { select, Store } from "@ngrx/store";
 import { distinctUntilChanged, map, withLatestFrom, shareReplay, groupBy, mergeMap, toArray, switchMap, scan, filter, startWith } from "rxjs/operators";
 import { Observable, Subscription, from, zip, of, combineLatest } from "rxjs";
@@ -250,3 +250,78 @@ export class AtlasLayerSelector implements OnInit {
       return t['name']
     }
 }
+
+import "src/res/images/atlas-selection/bigbrain.png"
+import 'src/res/images/atlas-selection/icbm2009c.png'
+import 'src/res/images/atlas-selection/colin27.png'
+import 'src/res/images/atlas-selection/cytoarchitectonic-maps.png'
+import 'src/res/images/atlas-selection/cortical-layers.png'
+import 'src/res/images/atlas-selection/grey-white-matter.png'
+import 'src/res/images/atlas-selection/firbe-long.png'
+import 'src/res/images/atlas-selection/firbe-short.png'
+import 'src/res/images/atlas-selection/difumo-64.png'
+import 'src/res/images/atlas-selection/difumo-128.png'
+import 'src/res/images/atlas-selection/difumo-256.png'
+import 'src/res/images/atlas-selection/difumo-512.png'
+import 'src/res/images/atlas-selection/difumo-1024.png'
+import 'src/res/images/atlas-selection/allen-mouse.png'
+import 'src/res/images/atlas-selection/allen-mouse-2017.png'
+import 'src/res/images/atlas-selection/allen-mouse-2015.png'
+import 'src/res/images/atlas-selection/waxholm.png'
+import 'src/res/images/atlas-selection/waxholm-v3.png'
+import 'src/res/images/atlas-selection/waxholm-v2.png'
+import 'src/res/images/atlas-selection/waxholm-v1.png'
+import 'src/res/images/atlas-selection/short-bundle-hcp.png'
+import 'src/res/images/atlas-selection/freesurfer.png'
+
+const previewImgMap = new Map([
+  ['minds/core/referencespace/v1.0.0/a1655b99-82f1-420f-a3c2-fe80fd4c8588', 'bigbrain.png'],
+  ['minds/core/referencespace/v1.0.0/dafcffc5-4826-4bf1-8ff6-46b8a31ff8e2', 'icbm2009c.png'],
+  ['minds/core/referencespace/v1.0.0/7f39f7be-445b-47c0-9791-e971c0b6d992', 'colin27.png'],
+  ['minds/core/parcellationatlas/v1.0.0/94c1125b-b87e-45e4-901c-00daee7f2579', 'cytoarchitectonic-maps.png'],
+  ['juelich/iav/atlas/v1.0.0/3', 'cortical-layers.png'],
+  ['juelich/iav/atlas/v1.0.0/4', 'grey-white-matter.png'],
+  ['juelich/iav/atlas/v1.0.0/5', 'firbe-long.png'],
+  ['juelich/iav/atlas/v1.0.0/6', 'firbe-short.png'],
+  ['minds/core/parcellationatlas/v1.0.0/d80fbab2-ce7f-4901-a3a2-3c8ef8a3b721', 'difumo-64.png'],
+  ['minds/core/parcellationatlas/v1.0.0/73f41e04-b7ee-4301-a828-4b298ad05ab8', 'difumo-128.png'],
+  ['minds/core/parcellationatlas/v1.0.0/141d510f-0342-4f94-ace7-c97d5f160235', 'difumo-256.png'],
+  ['minds/core/parcellationatlas/v1.0.0/63b5794f-79a4-4464-8dc1-b32e170f3d16', 'difumo-512.png'],
+  ['minds/core/parcellationatlas/v1.0.0/12fca5c5-b02c-46ce-ab9f-f12babf4c7e1', 'difumo-1024.png'],
+  ['minds/core/referencespace/v1.0.0/265d32a0-3d84-40a5-926f-bf89f68212b9', 'allen-mouse.png'],
+  ['minds/core/parcellationatlas/v1.0.0/05655b58-3b6f-49db-b285-64b5a0276f83', 'allen-mouse-2017.png'],
+  ['minds/core/parcellationatlas/v1.0.0/39a1384b-8413-4d27-af8d-22432225401f', 'allen-mouse-2015.png'],
+  ['minds/core/referencespace/v1.0.0/d5717c4a-0fa1-46e6-918c-b8003069ade8', 'waxholm.png'],
+  ['minds/core/parcellationatlas/v1.0.0/ebb923ba-b4d5-4b82-8088-fa9215c2e1fe', 'waxholm-v3.png'],
+  ['minds/core/parcellationatlas/v1.0.0/2449a7f0-6dd0-4b5a-8f1e-aec0db03679d', 'waxholm-v2.png'],
+  ['minds/core/parcellationatlas/v1.0.0/11017b35-7056-4593-baad-3934d211daba', 'waxholm-v1.png'],
+  ['juelich/iav/atlas/v1.0.0/79cbeaa4ee96d5d3dfe2876e9f74b3dc3d3ffb84304fb9b965b1776563a1069c', 'short-bundle-hcp.png'],
+  ['minds/core/referencespace/v1.0.0/tmp-fsaverage', 'freesurfer.png'],
+  ['minds/core/referencespace/v1.0.0/tmp-fsaverage6', 'freesurfer.png'],
+  ['julich/tmp/parcellation/freesurfer-test-parc', 'freesurfer.png'],
+])
+
+/**
+ * used for directories
+ */
+const previewNameToPngMap = new Map([
+  ['fibre architecture', 'firbe-long.png'],
+  ['functional modes', 'difumo-128.png']
+])
+
+@Pipe({
+  name: 'getPreviewUrlPipe',
+  pure: true
+})
+
+export class GetPreviewUrlPipe implements PipeTransform{
+  public transform(tile: any){
+    const filename = tile['@id']
+      ? previewImgMap.get(tile['@id'])
+      : previewNameToPngMap.get(tile['name'])
+    if (!filename) {
+      console.log(tile)
+    }
+    return filename && `res/image/${filename}`
+  }
+}
\ No newline at end of file
diff --git a/src/atlasComponents/uiSelectors/atlasLayerSelector/atlasLayerSelector.template.html b/src/atlasComponents/uiSelectors/atlasLayerSelector/atlasLayerSelector.template.html
index c6e4db70b..21aaafd37 100644
--- a/src/atlasComponents/uiSelectors/atlasLayerSelector/atlasLayerSelector.template.html
+++ b/src/atlasComponents/uiSelectors/atlasLayerSelector/atlasLayerSelector.template.html
@@ -119,25 +119,25 @@
 
             <div class="position-relative d-flex flex-column align-items-center">
                 <div class="position-relative">
-                <!-- info icon btn -->
-                <div class="position-absolute top-0 right-0 info-container"
-                    [ngClass]="{ 'darktheme': tileSrc.darktheme, 'lighttheme': !tileSrc.darktheme }">
-                    <ng-container *ngTemplateOutlet="infoBtn; context: { tileSrc: tileSrc}">
-
-                    </ng-container>
-                </div>
-
-                <!-- preview image -->
-                <img [src]="tileSrc.previewUrl"
-                    alt="Preview of this tile"
-                    class="layer-image align-self-center"
-                    [ngClass]="{ 'selectedLayerBorder': selected }"
-                    draggable="false">
-
-                <!-- if is directory, show directory icon -->
-                <div *ngIf="isDirectory" class="position-absolute bottom-0 right-0">
-                    <i class="fas fa-folder folder-container fa-2x"></i>
-                </div>
+                    <!-- info icon btn -->
+                    <div class="position-absolute top-0 right-0 info-container"
+                        [ngClass]="{ 'darktheme': tileSrc.darktheme, 'lighttheme': !tileSrc.darktheme }">
+                        <ng-container *ngTemplateOutlet="infoBtn; context: { tileSrc: tileSrc}">
+
+                        </ng-container>
+                    </div>
+
+                    <!-- preview image -->
+                    <img [src]="tileSrc | getPreviewUrlPipe"
+                        alt="Preview of this tile"
+                        class="layer-image align-self-center"
+                        [ngClass]="{ 'selectedLayerBorder': selected }"
+                        draggable="false">
+
+                    <!-- if is directory, show directory icon -->
+                    <div *ngIf="isDirectory" class="position-absolute bottom-0 right-0">
+                        <i class="fas fa-folder folder-container fa-2x"></i>
+                    </div>
                 </div>
             </div>
 
diff --git a/src/atlasComponents/uiSelectors/module.ts b/src/atlasComponents/uiSelectors/module.ts
index 96ee9a085..2291f425c 100644
--- a/src/atlasComponents/uiSelectors/module.ts
+++ b/src/atlasComponents/uiSelectors/module.ts
@@ -4,7 +4,7 @@ import { AngularMaterialModule } from "src/ui/sharedModules/angularMaterial.modu
 import { UtilModule } from "src/util";
 import { DatabrowserModule } from "src/atlasComponents/databrowserModule";
 import { AtlasDropdownSelector } from "./atlasDropdown/atlasDropdown.component";
-import { AtlasLayerSelector } from "./atlasLayerSelector/atlasLayerSelector.component";
+import { AtlasLayerSelector, GetPreviewUrlPipe } from "./atlasLayerSelector/atlasLayerSelector.component";
 import {QuickTourModule} from "src/ui/quickTour/module";
 
 @NgModule({
@@ -18,6 +18,7 @@ import {QuickTourModule} from "src/ui/quickTour/module";
   declarations: [
     AtlasDropdownSelector,
     AtlasLayerSelector,
+    GetPreviewUrlPipe,
   ],
   exports: [
     AtlasDropdownSelector,
diff --git a/deploy/assets/images/atlas-selection/allen-mouse-2015.png b/src/res/images/atlas-selection/allen-mouse-2015.png
similarity index 100%
rename from deploy/assets/images/atlas-selection/allen-mouse-2015.png
rename to src/res/images/atlas-selection/allen-mouse-2015.png
diff --git a/deploy/assets/images/atlas-selection/allen-mouse-2017.png b/src/res/images/atlas-selection/allen-mouse-2017.png
similarity index 100%
rename from deploy/assets/images/atlas-selection/allen-mouse-2017.png
rename to src/res/images/atlas-selection/allen-mouse-2017.png
diff --git a/deploy/assets/images/atlas-selection/allen-mouse.png b/src/res/images/atlas-selection/allen-mouse.png
similarity index 100%
rename from deploy/assets/images/atlas-selection/allen-mouse.png
rename to src/res/images/atlas-selection/allen-mouse.png
diff --git a/deploy/assets/images/atlas-selection/bugbrain.png b/src/res/images/atlas-selection/bigbrain.png
similarity index 100%
rename from deploy/assets/images/atlas-selection/bugbrain.png
rename to src/res/images/atlas-selection/bigbrain.png
diff --git a/deploy/assets/images/atlas-selection/colin27.png b/src/res/images/atlas-selection/colin27.png
similarity index 100%
rename from deploy/assets/images/atlas-selection/colin27.png
rename to src/res/images/atlas-selection/colin27.png
diff --git a/deploy/assets/images/atlas-selection/cortical-layers.png b/src/res/images/atlas-selection/cortical-layers.png
similarity index 100%
rename from deploy/assets/images/atlas-selection/cortical-layers.png
rename to src/res/images/atlas-selection/cortical-layers.png
diff --git a/deploy/assets/images/atlas-selection/cytoarchitectonic-maps.png b/src/res/images/atlas-selection/cytoarchitectonic-maps.png
similarity index 100%
rename from deploy/assets/images/atlas-selection/cytoarchitectonic-maps.png
rename to src/res/images/atlas-selection/cytoarchitectonic-maps.png
diff --git a/deploy/assets/images/atlas-selection/difumo-1024.png b/src/res/images/atlas-selection/difumo-1024.png
similarity index 100%
rename from deploy/assets/images/atlas-selection/difumo-1024.png
rename to src/res/images/atlas-selection/difumo-1024.png
diff --git a/deploy/assets/images/atlas-selection/difumo-128.png b/src/res/images/atlas-selection/difumo-128.png
similarity index 100%
rename from deploy/assets/images/atlas-selection/difumo-128.png
rename to src/res/images/atlas-selection/difumo-128.png
diff --git a/deploy/assets/images/atlas-selection/difumo-256.png b/src/res/images/atlas-selection/difumo-256.png
similarity index 100%
rename from deploy/assets/images/atlas-selection/difumo-256.png
rename to src/res/images/atlas-selection/difumo-256.png
diff --git a/deploy/assets/images/atlas-selection/difumo-512.png b/src/res/images/atlas-selection/difumo-512.png
similarity index 100%
rename from deploy/assets/images/atlas-selection/difumo-512.png
rename to src/res/images/atlas-selection/difumo-512.png
diff --git a/deploy/assets/images/atlas-selection/difumo-64.png b/src/res/images/atlas-selection/difumo-64.png
similarity index 100%
rename from deploy/assets/images/atlas-selection/difumo-64.png
rename to src/res/images/atlas-selection/difumo-64.png
diff --git a/deploy/assets/images/atlas-selection/firbe-long.png b/src/res/images/atlas-selection/firbe-long.png
similarity index 100%
rename from deploy/assets/images/atlas-selection/firbe-long.png
rename to src/res/images/atlas-selection/firbe-long.png
diff --git a/deploy/assets/images/atlas-selection/firbe-short.png b/src/res/images/atlas-selection/firbe-short.png
similarity index 100%
rename from deploy/assets/images/atlas-selection/firbe-short.png
rename to src/res/images/atlas-selection/firbe-short.png
diff --git a/deploy/assets/images/atlas-selection/freesurfer.png b/src/res/images/atlas-selection/freesurfer.png
similarity index 100%
rename from deploy/assets/images/atlas-selection/freesurfer.png
rename to src/res/images/atlas-selection/freesurfer.png
diff --git a/deploy/assets/images/atlas-selection/grey-white-matter.png b/src/res/images/atlas-selection/grey-white-matter.png
similarity index 100%
rename from deploy/assets/images/atlas-selection/grey-white-matter.png
rename to src/res/images/atlas-selection/grey-white-matter.png
diff --git a/deploy/assets/images/atlas-selection/icbm2009c.png b/src/res/images/atlas-selection/icbm2009c.png
similarity index 100%
rename from deploy/assets/images/atlas-selection/icbm2009c.png
rename to src/res/images/atlas-selection/icbm2009c.png
diff --git a/deploy/assets/images/atlas-selection/short-bundle-hcp.png b/src/res/images/atlas-selection/short-bundle-hcp.png
similarity index 100%
rename from deploy/assets/images/atlas-selection/short-bundle-hcp.png
rename to src/res/images/atlas-selection/short-bundle-hcp.png
diff --git a/deploy/assets/images/atlas-selection/waxholm-v1.png b/src/res/images/atlas-selection/waxholm-v1.png
similarity index 100%
rename from deploy/assets/images/atlas-selection/waxholm-v1.png
rename to src/res/images/atlas-selection/waxholm-v1.png
diff --git a/deploy/assets/images/atlas-selection/waxholm-v2.png b/src/res/images/atlas-selection/waxholm-v2.png
similarity index 100%
rename from deploy/assets/images/atlas-selection/waxholm-v2.png
rename to src/res/images/atlas-selection/waxholm-v2.png
diff --git a/deploy/assets/images/atlas-selection/waxholm-v3.png b/src/res/images/atlas-selection/waxholm-v3.png
similarity index 100%
rename from deploy/assets/images/atlas-selection/waxholm-v3.png
rename to src/res/images/atlas-selection/waxholm-v3.png
diff --git a/deploy/assets/images/atlas-selection/waxholm.png b/src/res/images/atlas-selection/waxholm.png
similarity index 100%
rename from deploy/assets/images/atlas-selection/waxholm.png
rename to src/res/images/atlas-selection/waxholm.png
-- 
GitLab