@abi-software/map-utilities 0.0.0-beta.7 → 1.0.0-beta.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/map-utilities",
3
- "version": "0.0.0-beta.7",
3
+ "version": "1.0.0-beta.1",
4
4
  "files": [
5
5
  "dist/*",
6
6
  "src/*",
package/src/App.vue CHANGED
@@ -124,19 +124,19 @@ function onActionClick(value) {
124
124
  /**
125
125
  * Tooltip
126
126
  */
127
- const tooltipDisplay = ref(false);
128
- const tooltipEntry = ref({});
127
+ const tooltipType = ref("");
128
+ const provenanceEntry = ref({});
129
129
  const featuresAlert = ref(undefined);
130
- const annotationDisplay = ref(false);
131
130
  const annotationEntry = ref({});
131
+ const imageEntry = ref([]);
132
132
 
133
133
  provide(/* key */ "getFeaturesAlert", /* value */ () => featuresAlert.value);
134
134
  provide(/* key */ "$annotator", /* value */ undefined);
135
135
  provide(/* key */ "userApiKey", /* value */ undefined);
136
136
 
137
- function addTooltipEntry() {
138
- tooltipDisplay.value = true;
139
- tooltipEntry.value = {
137
+ function addProvenanceEntry() {
138
+ tooltipType.value = "provenance";
139
+ provenanceEntry.value = {
140
140
  destinations: [null],
141
141
  origins: [null],
142
142
  components: ["pudendal nerve"],
@@ -160,13 +160,12 @@ function addTooltipEntry() {
160
160
  provenanceTaxonomyLabel: ["Homo sapiens"],
161
161
  };
162
162
  }
163
- function removeTooltipEntry() {
164
- tooltipDisplay.value = false;
165
- tooltipEntry.value = {};
163
+ function removeProvenanceEntry() {
164
+ tooltipType.value = "";
165
+ provenanceEntry.value = {};
166
166
  }
167
167
  function addAnnotationEntry() {
168
- tooltipDisplay.value = true;
169
- annotationDisplay.value = true;
168
+ tooltipType.value = "annotation";
170
169
  annotationEntry.value = {
171
170
  id: "digestive_8-1",
172
171
  featureId: 4958,
@@ -179,13 +178,97 @@ function addAnnotationEntry() {
179
178
  };
180
179
  }
181
180
  function removeAnnotationEntry() {
182
- tooltipDisplay.value = false;
183
- annotationDisplay.value = false;
181
+ tooltipType.value = "";
184
182
  annotationEntry.value = {};
185
183
  }
186
184
  function commitAnnotationEvent(value) {
187
185
  console.log("🚀 ~ commitAnnotationEvent ~ value:", value);
188
186
  }
187
+ function addImageEntry() {
188
+ tooltipType.value = "image";
189
+ imageEntry.value = [
190
+ {
191
+ anatomy: [
192
+ {
193
+ curie: "",
194
+ matchingStatus: "Exact Match",
195
+ name: "stomach",
196
+ },
197
+ ],
198
+ datasetId: "22",
199
+ datasetVersion: "2",
200
+ link: "https://sparc.biolucida.net/image?c=Mzg3Ny1jb2wtMTUw",
201
+ resource: {
202
+ share_link: "https://sparc.biolucida.net/image?c=Mzg3Ny1jb2wtMTUw",
203
+ },
204
+ s3uri: "s3://prd-sparc-discover50-use1/22/",
205
+ species: [
206
+ {
207
+ species: {
208
+ curie: "NCBITaxon:9825",
209
+ matchingStatus: "approved",
210
+ name: "Pig",
211
+ originalName: "Domestic Pig",
212
+ parents: [
213
+ {
214
+ curie: "ilx:0739765",
215
+ name: "Pig",
216
+ },
217
+ ],
218
+ },
219
+ strain: {
220
+ name: "Large White / Landrace crossbred pig",
221
+ },
222
+ },
223
+ ],
224
+ thumbnail: "https://sparc.biolucida.net/api/v1/thumbnail/3877",
225
+ title: "SPARC Image 1",
226
+ type: "image",
227
+ },
228
+ {
229
+ anatomy: [
230
+ {
231
+ curie: "",
232
+ matchingStatus: "Exact Match",
233
+ name: "stomach",
234
+ },
235
+ ],
236
+ datasetId: "22",
237
+ datasetVersion: "2",
238
+ link: "https://sparc.biolucida.net/image?c=Mzg3Ny1jb2wtMTUw",
239
+ resource: {
240
+ share_link: "https://sparc.biolucida.net/image?c=Mzg3Ny1jb2wtMTUw",
241
+ },
242
+ s3uri: "s3://prd-sparc-discover50-use1/22/",
243
+ species: [
244
+ {
245
+ species: {
246
+ curie: "NCBITaxon:9825",
247
+ matchingStatus: "approved",
248
+ name: "Pig",
249
+ originalName: "Domestic Pig",
250
+ parents: [
251
+ {
252
+ curie: "ilx:0739765",
253
+ name: "Pig",
254
+ },
255
+ ],
256
+ },
257
+ strain: {
258
+ name: "Large White / Landrace crossbred pig",
259
+ },
260
+ },
261
+ ],
262
+ thumbnail: "https://sparc.biolucida.net/api/v1/thumbnail/3877",
263
+ title: "SPARC Image 2",
264
+ type: "image",
265
+ },
266
+ ];
267
+ }
268
+ function removeImageEntry() {
269
+ tooltipType.value = "";
270
+ imageEntry.value = [];
271
+ }
189
272
  /**
190
273
  * TreeControls
191
274
  */
@@ -229,7 +312,7 @@ function setColourField(treeData, nodeData, activeColour) {
229
312
  function setColour(nodeData, value) {
230
313
  if (nodeData && nodeData.isPrimitives) {
231
314
  const activeColour = value ? value : nodeData.defaultColour;
232
- setColourField(treeDataEntry.value, nodeData, activeColour)
315
+ setColourField(treeDataEntry.value, nodeData, activeColour);
233
316
  }
234
317
  }
235
318
  function checkAll(value) {
@@ -380,21 +463,29 @@ function changeHover(value) {
380
463
  </el-col>
381
464
  <el-col>
382
465
  <el-button
383
- v-show="!annotationDisplay"
384
- @click="addTooltipEntry"
466
+ v-show="
467
+ tooltipType === '' ||
468
+ (tooltipType === 'provenance' &&
469
+ Object.keys(provenanceEntry).length === 0)
470
+ "
471
+ @click="addProvenanceEntry"
385
472
  size="small"
386
473
  >
387
- Add Tooltip Entry
474
+ Add Provenance Entry
388
475
  </el-button>
389
476
  <el-button
390
- v-show="Object.keys(tooltipEntry).length > 0"
391
- @click="removeTooltipEntry"
477
+ v-show="Object.keys(provenanceEntry).length > 0"
478
+ @click="removeProvenanceEntry"
392
479
  size="small"
393
480
  >
394
- Remove Tooltip Entry
481
+ Remove Provenance Entry
395
482
  </el-button>
396
483
  <el-button
397
- v-show="!Object.keys(tooltipEntry).length > 0"
484
+ v-show="
485
+ tooltipType === '' ||
486
+ (tooltipType === 'annotation' &&
487
+ Object.keys(annotationEntry).length === 0)
488
+ "
398
489
  @click="addAnnotationEntry"
399
490
  size="small"
400
491
  >
@@ -407,6 +498,23 @@ function changeHover(value) {
407
498
  >
408
499
  Remove Annotation Entry
409
500
  </el-button>
501
+ <el-button
502
+ v-show="
503
+ tooltipType === '' ||
504
+ (tooltipType === 'image' && Object.keys(imageEntry).length === 0)
505
+ "
506
+ @click="addImageEntry"
507
+ size="small"
508
+ >
509
+ Add Image Entry
510
+ </el-button>
511
+ <el-button
512
+ v-show="Object.keys(imageEntry).length > 0"
513
+ @click="removeImageEntry"
514
+ size="small"
515
+ >
516
+ Remove Image Entry
517
+ </el-button>
410
518
  </el-col>
411
519
  </el-row>
412
520
  <el-row>
@@ -414,10 +522,18 @@ function changeHover(value) {
414
522
  <h3>TreeControls - {{ mapType }}</h3>
415
523
  </el-col>
416
524
  <el-col>
417
- <el-button v-show="mapType==='scaffold'" @click="switchTreeEntry('flatmap')" size="small">
525
+ <el-button
526
+ v-show="mapType === 'scaffold'"
527
+ @click="switchTreeEntry('flatmap')"
528
+ size="small"
529
+ >
418
530
  Display Flatmap Tree
419
531
  </el-button>
420
- <el-button v-show="mapType==='flatmap'" @click="switchTreeEntry('scaffold')" size="small">
532
+ <el-button
533
+ v-show="mapType === 'flatmap'"
534
+ @click="switchTreeEntry('scaffold')"
535
+ size="small"
536
+ >
421
537
  Display Scaffold Tree
422
538
  </el-button>
423
539
  </el-col>
@@ -459,11 +575,12 @@ function changeHover(value) {
459
575
  @finish-help-mode="onFinishHelpMode"
460
576
  />
461
577
  <Tooltip
462
- v-show="tooltipDisplay"
578
+ v-show="tooltipType"
463
579
  class="tooltip"
464
- :tooltipEntry="tooltipEntry"
465
- :annotationDisplay="annotationDisplay"
580
+ :tooltipType="tooltipType"
581
+ :provenanceEntry="provenanceEntry"
466
582
  :annotationEntry="annotationEntry"
583
+ :imageEntry="imageEntry"
467
584
  @annotation="commitAnnotationEvent"
468
585
  @onActionClick="onActionClick"
469
586
  />
@@ -498,10 +615,12 @@ function changeHover(value) {
498
615
  .options-container {
499
616
  text-align: center;
500
617
  }
618
+
501
619
  .help-mode-dialog {
502
620
  position: absolute;
503
621
  top: 50%;
504
622
  }
623
+
505
624
  .tooltip {
506
625
  width: 400px;
507
626
  position: absolute;
@@ -1,174 +1,112 @@
1
1
  <template>
2
- <div class="main" v-loading="loading">
3
- <!-- <div class="block" v-if="entry.title">
4
- <span class="title">{{ capitalise(entry.title) }}</span>
5
- </div> -->
6
- <div class="block">
7
- <el-button
8
- class="button"
9
- @click="showImages = !showImages"
10
- >
11
- <span v-if="showImages">Hide images</span>
12
- <span v-else>View images at this location (Gallery)</span>
13
- </el-button>
14
- <template :key="index" v-for="(species, index) in speciesFilterTags">
15
- <el-tag
16
- type="info"
17
- class="tag"
18
- :class="{ 'active-tag': species.taxon === activeSpecies.taxon}"
19
- @close="removeSpeciesFilterTag(species)"
20
- @click="filterBySpecies(species)"
21
- :closable="species.taxon === activeSpecies.taxon"
22
- >
23
- {{ species.name }} ({{ species.count }})
24
- </el-tag>
25
- </template>
26
- <div v-if="showImages" class="image-gallery-container">
27
- <Gallery class="gallery" :items="filteredItems" />
28
- </div>
29
- <el-button
30
- class="button"
31
- @click="viewImage(imageIframeURL[this.entry.featureId[0]])"
32
- >
33
- <span>View images at this location (iFrame)</span>
34
- </el-button>
2
+ <div class="main">
3
+ <div v-if="imageEntry">
4
+ <el-tag
5
+ v-for="(species, index) in speciesFilterTags"
6
+ :key="index"
7
+ type="info"
8
+ class="tag"
9
+ :class="{ 'active-tag': species.taxon === activeSpecies.taxon }"
10
+ :closable="species.taxon === activeSpecies.taxon"
11
+ @close="removeSpeciesFilterTag"
12
+ @click="filterBySpecies(species)"
13
+ >
14
+ {{ species.name }} ({{ species.count }})
15
+ </el-tag>
16
+ <div class="gallery-container">
17
+ <Gallery :items="filteredImages" />
18
+ </div>
35
19
  </div>
36
20
  </div>
37
21
  </template>
38
22
 
39
23
  <script>
40
- import Gallery from "@abi-software/gallery";
41
- import "@abi-software/gallery/dist/style.css";
42
- import {
43
- ArrowUp as ElIconArrowUp,
44
- ArrowDown as ElIconArrowDown,
45
- Warning as ElIconWarning,
46
- } from '@element-plus/icons-vue'
47
24
  /* eslint-disable no-alert, no-console */
48
- import {
49
- ElButton as Button,
50
- ElContainer as Container,
51
- ElIcon as Icon,
52
- ElTag as Tag,
53
- } from 'element-plus'
54
-
55
- import flatmapImageMixin from '../../mixins/flatmapImageMixin';
56
-
57
- const titleCase = (str) => {
58
- return str.replace(/\w\S*/g, (t) => {
59
- return t.charAt(0).toUpperCase() + t.substr(1).toLowerCase()
60
- })
61
- }
25
+ import { ElTag as Tag } from "element-plus";
62
26
 
63
- const capitalise = function (str) {
64
- if (str) return str.charAt(0).toUpperCase() + str.slice(1)
65
- return ''
66
- }
67
-
68
- const imageIframeURL = {
69
- 'UBERON:0000948': 'https://sparc.biolucida.net/image?c=MjIzNzItY29sLTI1NA%3D%3D',
70
- 'UBERON:0016508': 'https://sparc.biolucida.net/image?c=MjIzNzQtY29sLTI1NA%3D%3D',
71
- 'ILX:0793082': 'https://sparc.biolucida.net/image?c=MjIzNzUtY29sLTI1NA%3D%3D'
72
- }
27
+ import Gallery from "@abi-software/gallery";
28
+ import "@abi-software/gallery/dist/style.css";
73
29
 
74
30
  export default {
75
- name: 'ImageGalleryPopup',
76
- mixins: [flatmapImageMixin],
31
+ name: "ImagePopup",
77
32
  components: {
78
- Button,
79
- Container,
80
- Icon,
81
33
  Tag,
82
- ElIconArrowUp,
83
- ElIconArrowDown,
84
- ElIconWarning,
85
34
  Gallery,
86
35
  },
87
36
  props: {
88
- galleryItems: {
37
+ imageEntry: {
89
38
  type: Array,
90
- default: () => [],
91
- },
92
- entry: {
93
- type: Object,
94
- default: () => ({
95
- destinations: [],
96
- origins: [],
97
- components: [],
98
- destinationsWithDatasets: [],
99
- originsWithDatasets: [],
100
- componentsWithDatasets: [],
101
- resource: undefined,
102
- }),
39
+ default: [],
103
40
  },
104
41
  },
105
42
  data: function () {
106
43
  return {
107
- controller: undefined,
108
- activeSpecies: undefined,
109
- loading: false,
110
- showImages: false,
111
- activeSpecies: { taxon: '', name: ''},
112
- imageIframeURL: imageIframeURL,
44
+ activeSpecies: { taxon: "", name: "" },
113
45
  speciesFilterTags: [],
114
- filteredItems: [],
115
- }
46
+ filteredImages: [],
47
+ showImageGallery: false,
48
+ };
116
49
  },
117
50
  watch: {
118
- galleryItems: {
119
- handler: function () {
120
- this.populateSpeciesFilterTags()
51
+ imageEntry: {
52
+ handler: function (value) {
53
+ if (value) {
54
+ this.populateFilterTags();
55
+ this.filteredImages = this.imageEntry;
56
+ }
121
57
  },
122
58
  deep: true,
123
59
  },
124
60
  },
125
61
  methods: {
126
- removeSpeciesFilterTag: function (species) {
127
- this.activeSpecies = { taxon: '', name: '' }
128
- this.filteredItems = this.galleryItems
129
- },
130
- populateSpeciesFilterTags: function () {
131
- this.speciesFilterTags = this.findAllSpeciesFromGalleryItems(this.galleryItems)
62
+ removeSpeciesFilterTag: function () {
63
+ this.activeSpecies = { taxon: "", name: "" };
64
+ this.filteredImages = this.imageEntry;
132
65
  },
133
- filterBySpecies: function (species) {
134
- this.activeSpecies = species
135
- this.filteredItems = this.findImagesForSpeciesFromGalleryItems(this.galleryItems, species.taxon)
66
+ filterBySpecies: function (tagInfo) {
67
+ this.activeSpecies = tagInfo;
68
+ let imageList = [];
69
+ this.imageEntry.forEach((image) => {
70
+ if (image.species && image.species.length > 0) {
71
+ image.species.forEach((species) => {
72
+ if (species.species && species.species.curie === tagInfo.taxon) {
73
+ imageList.push(image);
74
+ }
75
+ });
76
+ }
77
+ });
78
+ this.filteredImages = imageList;
136
79
  },
137
- titleCase: function (title) {
138
- return titleCase(title)
80
+ populateFilterTags: function () {
81
+ let imageObjects = {};
82
+ this.imageEntry.forEach((image) => {
83
+ if (image.species && image.species.length > 0) {
84
+ image.species.forEach((species) => {
85
+ if (species.species) {
86
+ const speciesInfo = species.species;
87
+ if (!(speciesInfo.curie in imageObjects)) {
88
+ imageObjects[speciesInfo.curie] = {
89
+ taxon: speciesInfo.curie,
90
+ name: speciesInfo.name,
91
+ count: 0,
92
+ };
93
+ }
94
+ imageObjects[speciesInfo.curie].count++;
95
+ }
96
+ });
97
+ }
98
+ });
99
+ this.speciesFilterTags = Object.values(imageObjects);
139
100
  },
140
- capitalise: function (text) {
141
- return capitalise(text)
142
- },
143
- viewImage: function (url) {
144
- this.$emit('view-image', url)
145
- }
146
101
  },
147
102
  mounted: function () {
148
- this.populateSpeciesFilterTags()
149
- this.filteredItems = this.galleryItems
103
+ this.populateFilterTags();
104
+ this.filteredImages = this.imageEntry;
150
105
  },
151
- }
106
+ };
152
107
  </script>
153
108
 
154
109
  <style lang="scss" scoped>
155
-
156
- .display {
157
- width: 44px;
158
- word-break: normal;
159
- }
160
-
161
- .title {
162
- text-align: left;
163
- width: 16em;
164
- line-height: 1.5em !important;
165
- font-size: 1em;
166
- font-family: Helvetica;
167
- font-weight: 500;
168
- /* font-weight: bold; */
169
- padding-bottom: 8px;
170
- }
171
-
172
110
  .block {
173
111
  margin-bottom: 0.5em;
174
112
  }
@@ -184,17 +122,6 @@ export default {
184
122
  color: #fff;
185
123
  }
186
124
 
187
- .icon {
188
- right: 0px;
189
- position: absolute;
190
- top: 10px;
191
- }
192
-
193
- .icon:hover {
194
- cursor: pointer;
195
- }
196
-
197
-
198
125
  .main {
199
126
  font-size: 14px;
200
127
  text-align: left;
@@ -207,35 +134,17 @@ export default {
207
134
  min-width: 18rem;
208
135
  }
209
136
 
210
- .title {
211
- font-size: 18px;
212
- font-weight: 500;
213
- font-weight: bold;
214
- padding-bottom: 8px;
215
- color: rgb(131, 0, 191);
216
- }
217
-
218
- .attribute-title {
219
- font-size: 16px;
220
- font-weight: 600;
221
- /* font-weight: bold; */
222
- text-transform: uppercase;
223
- }
224
-
225
- .attribute-content {
226
- font-size: 14px;
227
- font-weight: 500;
228
- }
229
-
230
137
  .button {
231
138
  margin-left: 0px !important;
232
139
  margin-top: 0px !important;
233
140
  font-size: 14px !important;
234
141
  background-color: $app-primary-color;
235
142
  color: #fff;
143
+
236
144
  & + .button {
237
145
  margin-top: 10px !important;
238
146
  }
147
+
239
148
  &:hover {
240
149
  color: #fff !important;
241
150
  background: #ac76c5 !important;
@@ -243,87 +152,7 @@ export default {
243
152
  }
244
153
  }
245
154
 
246
- .tooltip-container {
247
- &::after,
248
- &::before {
249
- content: '';
250
- display: block;
251
- position: absolute;
252
- width: 0;
253
- height: 0;
254
- border-style: solid;
255
- flex-shrink: 0;
256
- }
257
- .tooltip {
258
- &::after {
259
- display: none;
260
- }
261
- &::before {
262
- display: none;
263
- }
264
- }
265
- }
266
-
267
- .maplibregl-popup-anchor-bottom {
268
- .tooltip-container {
269
- &::after,
270
- &::before {
271
- top: 100%;
272
- border-width: 12px;
273
- }
274
- &::after {
275
- margin-top: -1px;
276
- border-color: rgb(255, 255, 255) transparent transparent transparent;
277
- }
278
- &::before {
279
- margin: 0 auto;
280
- border-color: $app-primary-color transparent transparent transparent;
281
- }
282
- }
283
- }
284
-
285
- .maplibregl-popup-anchor-top {
286
- .tooltip-container {
287
- &::after,
288
- &::before {
289
- top: -24px;
290
- border-width: 12px;
291
- }
292
- &::after {
293
- margin-top: 1px;
294
- border-color: transparent transparent rgb(255, 255, 255) transparent;
295
- }
296
- &::before {
297
- margin: 0 auto;
298
- border-color: transparent transparent $app-primary-color transparent;
299
- }
300
- }
301
- }
302
-
303
- .content-container {
304
- overflow-y: scroll;
305
- scrollbar-width: thin !important;
306
- max-height: 240px;
307
- }
308
-
309
- .scrollbar::-webkit-scrollbar-track {
310
- border-radius: 10px;
311
- background-color: #f5f5f5;
312
- }
313
-
314
- .scrollbar::-webkit-scrollbar {
315
- width: 12px;
316
- right: -12px;
317
- background-color: #f5f5f5;
318
- }
319
-
320
- .scrollbar::-webkit-scrollbar-thumb {
321
- border-radius: 4px;
322
- box-shadow: 0 2px 4px 0 rgba(0, 0, 0, 0.06);
323
- background-color: #979797;
324
- }
325
-
326
- .image-gallery-container {
155
+ .gallery-container {
327
156
  :deep(.gallery) {
328
157
  .gallery-strip {
329
158
  padding: 1rem 0;
@@ -334,10 +163,4 @@ export default {
334
163
  }
335
164
  }
336
165
  }
337
-
338
- /* Fix for chrome bug where under triangle pops up above one on top of it */
339
- .selector:not(*:root),
340
- .tooltip-container::after {
341
- top: 99.4%;
342
- }
343
166
  </style>