@abi-software/scaffoldvuer 1.4.0-beta.2 → 1.4.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@abi-software/scaffoldvuer",
3
- "version": "1.4.0-beta.2",
3
+ "version": "1.4.1",
4
4
  "license": "Apache-2.0",
5
5
  "repository": {
6
6
  "type": "git",
@@ -41,7 +41,7 @@
41
41
  "*.js"
42
42
  ],
43
43
  "dependencies": {
44
- "@abi-software/map-utilities": "^1.1.0-beta.2",
44
+ "@abi-software/map-utilities": "^1.1.0",
45
45
  "@abi-software/sparc-annotation": "^0.3.1",
46
46
  "@abi-software/svg-sprite": "^1.0.0",
47
47
  "@element-plus/icons-vue": "^2.3.1",
@@ -55,12 +55,12 @@
55
55
  "vue": "^3.4.15",
56
56
  "vue-router": "^4.2.5",
57
57
  "vue3-component-svg-sprite": "^0.0.1",
58
- "zincjs": "^1.11.3"
58
+ "zincjs": "^1.11.4"
59
59
  },
60
60
  "devDependencies": {
61
61
  "@vitejs/plugin-vue": "^4.6.2",
62
62
  "@vuese/markdown-render": "^2.11.3",
63
- "@vuese/parser": "^2.9.1",
63
+ "@vuese/parser": "^2.10.3",
64
64
  "auto-changelog": "^2.4.0",
65
65
  "babel-eslint": "^10.1.0",
66
66
  "babel-plugin-component": "^1.1.1",
@@ -92,8 +92,5 @@
92
92
  "browserslist": [
93
93
  "> 1%",
94
94
  "last 2 versions"
95
- ],
96
- "optionalDependencies": {
97
- "@rollup/rollup-linux-x64-gnu": "^4.21.1"
98
- }
95
+ ]
99
96
  }
package/src/App.vue CHANGED
@@ -28,7 +28,6 @@
28
28
  :format="format"
29
29
  :marker-labels="markerLabels"
30
30
  :enableLocalAnnotations="false"
31
- :sparcAPI="sparcAPI"
32
31
  @open-map="openMap"
33
32
  @on-ready="onReady"
34
33
  @scaffold-selected="onSelected"
@@ -322,9 +321,6 @@ import {
322
321
  import { useRoute, useRouter } from 'vue-router'
323
322
  import { HelpModeDialog } from '@abi-software/map-utilities'
324
323
  import '@abi-software/map-utilities/dist/style.css'
325
- import { mapStores } from 'pinia';
326
- import { useSettingsStore } from '@/stores/settings';
327
- import { getOrganCuries } from '@/services/scicrunchQueries'
328
324
 
329
325
  let texture_prefix = undefined;
330
326
 
@@ -362,7 +358,7 @@ export default {
362
358
  },
363
359
  data: function () {
364
360
  return {
365
- consoleOn: false,
361
+ consoleOn: true,
366
362
  createLinesWithNormal: false,
367
363
  url: undefined,
368
364
  input: undefined,
@@ -410,14 +406,9 @@ export default {
410
406
  router: useRouter(),
411
407
  ElIconSetting: shallowRef(ElIconSetting),
412
408
  ElIconFolderOpened: shallowRef(ElIconFolderOpened),
413
- auto: NaN,
414
- sparcAPI: import.meta.env.VITE_SPARC_API,
415
- // sparcAPI: "http://localhost:8000/",
409
+ auto: NaN
416
410
  };
417
411
  },
418
- computed: {
419
- ...mapStores(useSettingsStore),
420
- },
421
412
  watch: {
422
413
  input: function () {
423
414
  this.parseInput();
@@ -431,7 +422,7 @@ export default {
431
422
  "body proper": 9,
432
423
  "Spinal cord": 8,
433
424
  "lung": 11,
434
- "stomach": 12,
425
+ "stomach": {number:12, imgURL: 'https://mapcore-bucket1.s3.us-west-2.amazonaws.com/texture/arm1/jpg/0984.jpg'},
435
426
  "urinary bladder": 11,
436
427
  "Brainstem": 11,
437
428
  "heart": 9,
@@ -463,7 +454,6 @@ export default {
463
454
  },
464
455
  mounted: function () {
465
456
  this._objects = [];
466
- getOrganCuries(this.sparcAPI).then((organCuries) => this.settingsStore.updateOrganCuries(organCuries))
467
457
  },
468
458
  created: function () {
469
459
  texture_prefix = import.meta.env.VITE_TEXTURE_FOOT_PREFIX;
@@ -14,7 +14,7 @@
14
14
  <template #default>
15
15
  <div class="tooltip-text">{{ label }}</div>
16
16
  <div class="tooltip-text" v-if="region">Region: {{ region }}</div>
17
- <CreateTooltipContent
17
+ <CreateTooltiipContent
18
18
  v-show="createData.toBeConfirmed"
19
19
  :createData="createData"
20
20
  @confirm-create="$emit('confirm-create', $event)"
@@ -22,14 +22,10 @@
22
22
  />
23
23
  <Tooltip
24
24
  class="p-tooltip"
25
- v-show="
26
- (annotationDisplay && !createData.toBeConfirmed) ||
27
- imageEntry.length
28
- "
29
- ref="tooltip"
30
- :tooltipType="annotationDisplay ? 'annotation' : 'image'"
25
+ v-show="annotationDisplay && !createData.toBeConfirmed"
26
+ ref="annotationTooltip"
27
+ :annotationDisplay="true"
31
28
  :annotationEntry="annotationEntry"
32
- :imageEntry="imageEntry"
33
29
  />
34
30
  <div v-if="createData.toBeDeleted" class="delete-container">
35
31
  <el-row>
@@ -70,9 +66,9 @@ import {
70
66
  import {
71
67
  Delete as ElIconDelete,
72
68
  } from '@element-plus/icons-vue'
69
+ import CreateTooltiipContent from "./CreateTooltipContent.vue";
73
70
  import { mapState } from 'pinia';
74
- import { useMainStore } from "@/stores/index";
75
- import CreateTooltipContent from "./CreateTooltipContent.vue";
71
+ import { useMainStore } from "@/store/index";
76
72
  import { Tooltip } from '@abi-software/map-utilities'
77
73
  import '@abi-software/map-utilities/dist/style.css'
78
74
 
@@ -83,7 +79,7 @@ export default {
83
79
  name: "ScaffoldTooltip",
84
80
  components: {
85
81
  Col,
86
- CreateTooltipContent,
82
+ CreateTooltiipContent,
87
83
  ElIconDelete,
88
84
  Icon,
89
85
  Popover,
@@ -125,14 +121,6 @@ export default {
125
121
  type: Number,
126
122
  default: 200,
127
123
  },
128
- imageThumbnails: {
129
- type: Object,
130
- default: {},
131
- },
132
- imageThumbnailSidebar: {
133
- type: Boolean,
134
- default: false,
135
- },
136
124
  },
137
125
  inject: ['scaffoldUrl'],
138
126
  provide() {
@@ -142,6 +130,7 @@ export default {
142
130
  },
143
131
  data: function () {
144
132
  return {
133
+ display: false,
145
134
  annotationEntry: { },
146
135
  ElIconDelete: shallowRef(ElIconDelete),
147
136
  };
@@ -156,27 +145,11 @@ export default {
156
145
  const x = this.x - 40;
157
146
  return { left: x + "px", top: this.y - yOffset + "px" };
158
147
  },
159
- imageEntry: function () {
160
- let imageEntries = []
161
- const imageThumbnailsEntries = Object.assign({},
162
- Object.fromEntries(
163
- Object.entries(this.imageThumbnails)
164
- .filter(([key, value]) => value.length > 0)
165
- .map(([key, value]) => [key.toLowerCase(), value])))
166
- const lowerCaseLabel = this.label.toLowerCase()
167
- if (lowerCaseLabel in imageThumbnailsEntries) {
168
- imageEntries = imageThumbnailsEntries[lowerCaseLabel];
169
- }
170
- if (this.imageThumbnailSidebar) {
171
- this.$emit('image-thumbnail-open', imageEntries)
172
- return [];
173
- }
174
- return imageEntries;
175
- },
176
148
  },
177
149
  methods: {
178
150
  checkForDisplay: function () {
179
151
  if (this.visible && this.label && this.label !== "") {
152
+ this.display = true;
180
153
  if (this.annotationDisplay) {
181
154
  const region = this.region ? this.region +"/" : "";
182
155
  this.annotationEntry = {
@@ -185,7 +158,9 @@ export default {
185
158
  "resource": encodeURIComponent(this.scaffoldUrl),
186
159
  };
187
160
  }
188
- } else {
161
+ }
162
+ else {
163
+ this.display = false;
189
164
  this.annotationEntry = { };
190
165
  }
191
166
  },
@@ -15,12 +15,9 @@
15
15
  :x="tData.x"
16
16
  :y="tData.y"
17
17
  :annotationDisplay="annotationDisplay"
18
- :imageThumbnailSidebar="imageThumbnailSidebar"
19
- :imageThumbnails="imageThumbnailsEntry"
20
18
  @confirm-create="confirmCreate($event)"
21
19
  @cancel-create="cancelCreate()"
22
20
  @confirm-delete="confirmDelete($event)"
23
- @image-thumbnail-open="onImageThumbnailOpen"
24
21
  />
25
22
  <div
26
23
  id="organsDisplayArea"
@@ -287,7 +284,7 @@
287
284
  ref="backgroundPopover"
288
285
  :virtual-ref="backgroundIconRef"
289
286
  placement="top-start"
290
- width="330"
287
+ width="128"
291
288
  :teleported="false"
292
289
  trigger="click"
293
290
  popper-class="background-popper non-selectable h-auto"
@@ -295,7 +292,7 @@
295
292
  >
296
293
  <div>
297
294
  <el-row class="backgroundText">Viewing Mode</el-row>
298
- <el-row class="backgroundChooser">
295
+ <el-row class="backgroundControl">
299
296
  <div style="margin-bottom: 2px;">
300
297
  <template
301
298
  v-for="(value, key, index) in viewingModes"
@@ -313,41 +310,6 @@
313
310
  {{ viewingModes[viewingMode] }}
314
311
  </el-row>
315
312
  </el-row>
316
- <el-row class="backgroundSpacer" v-if="viewingMode === 'Exploration'"></el-row>
317
- <el-row class="backgroundText" v-if="viewingMode === 'Exploration'">Markers display</el-row>
318
- <el-row class="backgroundChooser" v-if="viewingMode === 'Exploration'">
319
- <el-col :span="14">
320
- <el-radio-group
321
- v-model="imageRadio"
322
- class="flatmap-radio"
323
- @change="setImage"
324
- >
325
- <el-radio :value="false">Standard</el-radio>
326
- <el-radio :value="true">Image</el-radio>
327
- </el-radio-group>
328
- </el-col>
329
- <el-col :span="10" v-if="imageRadio">
330
- <el-select
331
- :teleported="false"
332
- v-model="imageType"
333
- placeholder="Select"
334
- class="scaffold-select-box imageSelector"
335
- popper-class="scaffold_viewer_dropdown"
336
- @change="setImageType"
337
- >
338
- <el-option
339
- v-for="item in imageTypes"
340
- :key="item"
341
- :label="item"
342
- :value="item"
343
- >
344
- <el-row>
345
- <el-col :span="12">{{ item }}</el-col>
346
- </el-row>
347
- </el-option>
348
- </el-select>
349
- </el-col>
350
- </el-row>
351
313
  <el-row class="backgroundSpacer"></el-row>
352
314
  <el-row class="backgroundText"> Change background </el-row>
353
315
  <el-row class="backgroundChooser">
@@ -420,7 +382,7 @@
420
382
 
421
383
  <script>
422
384
  /* eslint-disable no-alert, no-console */
423
- import { markRaw, toRaw, shallowRef } from 'vue';
385
+ import { markRaw, shallowRef } from 'vue';
424
386
  import {
425
387
  WarningFilled as ElIconWarningFilled,
426
388
  ArrowDown as ElIconArrowDown,
@@ -459,16 +421,8 @@ import { AnnotationService } from '@abi-software/sparc-annotation';
459
421
  import { EventNotifier } from "../scripts/EventNotifier.js";
460
422
  import { OrgansViewer } from "../scripts/OrgansRenderer.js";
461
423
  import { SearchIndex } from "../scripts/Search.js";
462
- import { mapState, mapStores } from 'pinia';
463
- import { useMainStore } from "@/stores/index";
464
- import { useSettingsStore } from '@/stores/settings'
465
- import {
466
- getBiolucidaThumbnails,
467
- getSegmentationThumbnails,
468
- getScaffoldThumbnails,
469
- getPlotThumbnails
470
- } from '../services/scicrunchQueries'
471
- import imageMixin from '../mixins/imageMixin.js'
424
+ import { mapState } from 'pinia';
425
+ import { useMainStore } from "@/store/index";
472
426
 
473
427
  /**
474
428
  * A vue component of the scaffold viewer.
@@ -478,7 +432,6 @@ import imageMixin from '../mixins/imageMixin.js'
478
432
  */
479
433
  export default {
480
434
  name: "ScaffoldVuer",
481
- mixins: [imageMixin],
482
435
  components: {
483
436
  Button,
484
437
  Col,
@@ -736,24 +689,10 @@ export default {
736
689
  /**
737
690
  * Enable local annotations
738
691
  */
739
- enableLocalAnnotations: {
692
+ enableLocalAnnotations: {
740
693
  type: Boolean,
741
694
  default: false
742
695
  },
743
- /**
744
- * Specify the endpoint of the SPARC API.
745
- */
746
- sparcAPI: {
747
- type: String,
748
- default: 'https://api.sparc.science/',
749
- },
750
- /**
751
- * The option to show image thumbnail in sidebar
752
- */
753
- imageThumbnailSidebar: {
754
- type: Boolean,
755
- default: false,
756
- },
757
696
  },
758
697
  provide() {
759
698
  return {
@@ -761,7 +700,6 @@ export default {
761
700
  scaffoldUrl: this.url,
762
701
  $annotator: this.annotator,
763
702
  boundingDims: this.boundingDims,
764
- getFeaturesAlert: () => undefined,
765
703
  };
766
704
  },
767
705
  data: function () {
@@ -852,8 +790,7 @@ export default {
852
790
  active: false,
853
791
  },
854
792
  fileFormat: "metadata",
855
- markerLabelEntry: markRaw({}),
856
- previousMarkerLabelEntry: markRaw({}),
793
+ previousMarkerLabels: markRaw({}),
857
794
  viewingMode: "Exploration",
858
795
  viewingModes: {
859
796
  "Exploration": "View and explore detailed visualization of 3D scaffolds",
@@ -875,10 +812,6 @@ export default {
875
812
  centre: [0, 0, 0],
876
813
  size:[1, 1, 1],
877
814
  },
878
- imageRadio: false,
879
- imageType: 'Image',
880
- imageTypes: ['Image', 'Segmentation', 'Scaffold', 'Plot'],
881
- imageClicked: '',
882
815
  };
883
816
  },
884
817
  watch: {
@@ -958,17 +891,14 @@ export default {
958
891
  },
959
892
  immediate: true,
960
893
  },
961
- markerLabels: function (labels) {
962
- this.markerLabelEntry = markRaw({...labels})
963
- },
964
- markerLabelEntry: function (entry) {
965
- for (const [key, value] of Object.entries(this.previousMarkerLabelEntry)) {
894
+ markerLabels: function(labels) {
895
+ for (const [key, value] of Object.entries(this.previousMarkerLabels)) {
966
896
  this.setMarkerModeForObjectsWithName(key, value, "off");
967
897
  }
968
- for (const [key, value] of Object.entries(entry)) {
898
+ for (const [key, value] of Object.entries(labels)) {
969
899
  this.setMarkerModeForObjectsWithName(key, value, "on");
970
900
  }
971
- this.previousMarkerLabelEntry = markRaw({...entry});
901
+ this.previousMarkerLabels = markRaw({...labels});
972
902
  },
973
903
  },
974
904
  beforeCreate: function () {
@@ -1008,13 +938,9 @@ export default {
1008
938
  },
1009
939
  computed: {
1010
940
  ...mapState(useMainStore, ['userToken']),
1011
- ...mapStores(useSettingsStore),
1012
941
  annotationDisplay: function() {
1013
942
  return this.viewingMode === 'Annotation' && this.tData.active === true &&
1014
943
  (this.activeDrawMode === 'Edit' || this.activeDrawMode === 'Delete');
1015
- },
1016
- imageThumbnailsEntry: function() {
1017
- return this.imageClicked ? this.convertUberonToName() : {};
1018
944
  }
1019
945
  },
1020
946
  methods: {
@@ -1554,9 +1480,6 @@ export default {
1554
1480
  ? identifier.data.id
1555
1481
  : identifier.data.group;
1556
1482
  names.push(id);
1557
- if (identifier.data) {
1558
- identifier.data.imageType = this.imageRadio ? this.imageType : "Standard"
1559
- }
1560
1483
  }
1561
1484
  });
1562
1485
  zincObjects = event.zincObjects;
@@ -1580,13 +1503,6 @@ export default {
1580
1503
  this.$refs.scaffoldTreeControls.removeActive(false);
1581
1504
  }
1582
1505
  }
1583
- if (this.imageRadio && event.identifiers.length && event.identifiers[0]) {
1584
- this.imageClicked = event.identifiers[0].data.id
1585
- ? event.identifiers[0].data.id
1586
- : event.identifiers[0].data.group;
1587
- } else {
1588
- this.imageClicked = ''
1589
- }
1590
1506
  //Emit when an object is selected
1591
1507
  //@arg Identifier of selected objects
1592
1508
  this.$emit("scaffold-selected", event.identifiers);
@@ -1637,12 +1553,6 @@ export default {
1637
1553
  this.createEditTemporaryLines(event.identifiers[0].extraData.worldCoords);
1638
1554
  }
1639
1555
  this.createEditTemporaryLines(event.identifiers[0].extraData.worldCoords);
1640
- const id = event.identifiers[0].data.id
1641
- ? event.identifiers[0].data.id
1642
- : event.identifiers[0].data.group;
1643
- if (this.imageClicked !== id) {
1644
- this.imageClicked = ''
1645
- }
1646
1556
  }
1647
1557
  }
1648
1558
  }
@@ -2417,67 +2327,15 @@ export default {
2417
2327
  this.$module.toggleSyncControl(flag, rotateMode);
2418
2328
  this.$module.setSyncControlCallback(this.syncControlCallback);
2419
2329
  },
2330
+
2420
2331
  /**
2421
2332
  * Set the markers for the scene.
2422
2333
  */
2423
2334
  setMarkers: function () {
2424
- for (const [key, value] of Object.entries(this.markerLabelEntry)) {
2335
+ for (const [key, value] of Object.entries(this.markerLabels)) {
2425
2336
  this.setMarkerModeForObjectsWithName(key, value, "on");
2426
2337
  }
2427
2338
  },
2428
- removeImageThumbnails: function () {
2429
- this.imageThumbnails = {}
2430
- this.markerLabelEntry = markRaw(this.markerLabels)
2431
- },
2432
- setImage: function (flag) {
2433
- if (flag) {
2434
- this.setImageType(this.imageType)
2435
- } else {
2436
- this.removeImageThumbnails()
2437
- }
2438
- },
2439
- setImageType: async function (type) {
2440
- this.imageType = type
2441
- if (!this.settingsStore.imageTypeCached(type)) {
2442
- this.loading = true
2443
- await this.fetchImageThumbnails(type)
2444
- this.loading = false
2445
- }
2446
- this.populateImageThumbnails(type)
2447
- },
2448
- fetchImageThumbnails: async function (type) {
2449
- let thumbnails = {}
2450
- const organCuries = this.settingsStore.organCuries
2451
- if (type === 'Image') {
2452
- thumbnails = await getBiolucidaThumbnails(this.sparcAPI, organCuries, type)
2453
- } else if (type === 'Segmentation') {
2454
- thumbnails = await getSegmentationThumbnails(this.sparcAPI, organCuries, type)
2455
- } else if (type === 'Scaffold') {
2456
- thumbnails = await getScaffoldThumbnails(this.sparcAPI, organCuries, type)
2457
- } else if (type === 'Plot') {
2458
- thumbnails = await getPlotThumbnails(this.sparcAPI, organCuries, type)
2459
- }
2460
- this.settingsStore.updateImageThumbnails(type, thumbnails)
2461
- },
2462
- convertUberonToName: function () {
2463
- const organCuries = this.settingsStore.organCuries
2464
- const identifiers = organCuries.filter((curie) => curie.name in this.markerLabels).map((curie) => curie.id)
2465
- const imageThumbnails = this.settingsStore.getImageThumbnails(this.imageType, identifiers)
2466
- return Object.assign({},
2467
- Object.fromEntries(
2468
- Object.entries(imageThumbnails)
2469
- .map(([key, value]) => [organCuries.filter((curie) => curie.id === key)[0].name, value])))
2470
- },
2471
- populateImageThumbnails: async function (type) {
2472
- this.removeImageThumbnails()
2473
- const thumbnails = this.convertUberonToName()
2474
- this.loading = true
2475
- this.markerLabelEntry = markRaw(await this.populateMapWithImages(thumbnails, type))
2476
- this.loading = false
2477
- },
2478
- onImageThumbnailOpen: function (payload) {
2479
- this.$emit('image-thumbnail-open', payload);
2480
- },
2481
2339
  },
2482
2340
  };
2483
2341
  </script>
@@ -2637,7 +2495,7 @@ export default {
2637
2495
  background-color: #ffffff;
2638
2496
  border: 1px solid $app-primary-color;
2639
2497
  box-shadow: 0px 2px 12px 0px rgba(0, 0, 0, 0.06);
2640
- height: fit-content;
2498
+ height: 140px;
2641
2499
  min-width: 200px;
2642
2500
  .el-popper__arrow {
2643
2501
  &:before {
@@ -2894,10 +2752,6 @@ export default {
2894
2752
  min-height: 24px
2895
2753
  }
2896
2754
  }
2897
-
2898
- &.imageSelector {
2899
- width: 125px!important;
2900
- }
2901
2755
  }
2902
2756
 
2903
2757
  :deep(.scaffold_viewer_dropdown) {
@@ -26,8 +26,6 @@ declare module 'vue' {
26
26
  ElMain: typeof import('element-plus/es')['ElMain']
27
27
  ElOption: typeof import('element-plus/es')['ElOption']
28
28
  ElPopover: typeof import('element-plus/es')['ElPopover']
29
- ElRadio: typeof import('element-plus/es')['ElRadio']
30
- ElRadioGroup: typeof import('element-plus/es')['ElRadioGroup']
31
29
  ElRow: typeof import('element-plus/es')['ElRow']
32
30
  ElSelect: typeof import('element-plus/es')['ElSelect']
33
31
  ElSlider: typeof import('element-plus/es')['ElSlider']
package/src/main.js CHANGED
@@ -2,7 +2,7 @@ import { createApp } from 'vue'
2
2
  import { createPinia } from 'pinia'
3
3
  import * as VueRouter from 'vue-router'
4
4
  import App from './App.vue'
5
- import { useMainStore } from '@/stores/index'
5
+ import { useMainStore } from '@/store/index'
6
6
 
7
7
  const routes = [
8
8
  { path: '/'},
@@ -1,89 +0,0 @@
1
- export default {
2
- methods: {
3
- populateMapWithImages: async function (images, type) {
4
- let imageMarkerLabels = {};
5
- for (const [key, list] of Object.entries(images)) {
6
- const response = await this.downloadImageThumbnail(key, list, type);
7
- if (response) {
8
- imageMarkerLabels[key] = response;
9
- } else {
10
- imageMarkerLabels[key] = this.markerLabels[key];
11
- }
12
- }
13
- return imageMarkerLabels;
14
- },
15
- downloadImageThumbnail: async function (key, list, type) {
16
- const count = list.length;
17
- if (count > 0) {
18
- //Pick a random image
19
- const index = Math.floor(Math.random() * count);
20
- const thumbnail = list[index].thumbnail;
21
- try {
22
- const response = await this.getImageThumbnail(thumbnail, type);
23
- const markerObject = await this.addImageThumbnailMarker(key, response);
24
- return markerObject;
25
- } catch (error) {
26
- // Failed to download, pick another one
27
- list.splice(index);
28
- this.downloadImageThumbnail(key, list, type);
29
- }
30
- }
31
- },
32
- getImageThumbnail: async function (url, type) {
33
- return new Promise((resolve, reject) => {
34
- if (type === "Image" || type === "Segmentation") {
35
- this.getBinaryThumbnail(url)
36
- .then((response) => resolve(response))
37
- .catch((response) => reject(response));
38
- } else {
39
- this.getGenericThumbnail(url)
40
- .then((response) => resolve(response))
41
- .catch((response) => reject(response));
42
- }
43
- });
44
- },
45
- getBinaryThumbnail: async function (url) {
46
- return new Promise((resolve, reject) => {
47
- fetch(url)
48
- .then((response) => {
49
- if (response.status >= 200 && response.status < 300) {
50
- return response.text();
51
- } else {
52
- reject();
53
- }
54
- })
55
- .then((data) => {
56
- if (data) {
57
- let img = new Image();
58
- img.onload = function () {
59
- resolve(`data:'image/png';base64,${data}`);
60
- };
61
- img.onerror = function () {
62
- reject(new Error("Failed to load image at " + url));
63
- };
64
- img.src = `data:'image/png';base64,${data}`;
65
- } else {
66
- reject(new Error("Failed to load image at " + url));
67
- }
68
- });
69
- });
70
- },
71
- getGenericThumbnail: async function (url) {
72
- return new Promise((resolve, reject) => {
73
- let img = new Image();
74
- img.onload = function () {
75
- resolve(url);
76
- };
77
- img.onerror = function () {
78
- reject(new Error("Failed to load image at " + url));
79
- };
80
- img.src = url;
81
- });
82
- },
83
- addImageThumbnailMarker: async function (id, source) {
84
- const blob = await (await fetch(source)).blob();
85
- const blobUrl = URL.createObjectURL(blob);
86
- return { number: this.markerLabels[id], imgURL: blobUrl };
87
- },
88
- },
89
- };