@abi-software/map-side-bar 1.5.4 → 1.6.0

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.
Files changed (37) hide show
  1. package/CHANGELOG.md +229 -228
  2. package/LICENSE +201 -201
  3. package/README.md +146 -146
  4. package/babel.config.js +14 -14
  5. package/dist/map-side-bar.common.js +255 -231
  6. package/dist/map-side-bar.common.js.map +1 -1
  7. package/dist/map-side-bar.css +1 -1
  8. package/dist/map-side-bar.umd.js +255 -231
  9. package/dist/map-side-bar.umd.js.map +1 -1
  10. package/dist/map-side-bar.umd.min.js +1 -1
  11. package/dist/map-side-bar.umd.min.js.map +1 -1
  12. package/package-lock.json +14536 -14536
  13. package/package.json +75 -75
  14. package/public/index.html +17 -17
  15. package/src/App.vue +164 -164
  16. package/src/algolia/algolia.js +209 -209
  17. package/src/algolia/utils.js +101 -101
  18. package/src/assets/_variables.scss +43 -43
  19. package/src/assets/styles.scss +7 -7
  20. package/src/components/BadgesGroup.vue +144 -144
  21. package/src/components/Cascader.vue +49 -49
  22. package/src/components/DatasetCard.vue +328 -328
  23. package/src/components/EventBus.js +3 -3
  24. package/src/components/ImageGallery.vue +537 -531
  25. package/src/components/SearchFilters.vue +703 -703
  26. package/src/components/SearchHistory.vue +147 -147
  27. package/src/components/SideBar.vue +235 -235
  28. package/src/components/SidebarContent.vue +564 -564
  29. package/src/components/Tabs.vue +78 -78
  30. package/src/components/index.js +8 -8
  31. package/src/components/species-map.js +8 -8
  32. package/src/main.js +8 -8
  33. package/src/mixins/S3Bucket.vue +37 -31
  34. package/static.json +6 -6
  35. package/vue.config.js +19 -19
  36. package/src/components/ContextCard.vue +0 -397
  37. package/src/components/hardcoded-context-info.js +0 -80
@@ -1,397 +0,0 @@
1
- <template>
2
- <div class="context-card-container" ref="container">
3
- <div v-show="showContextCard">
4
- <div v-show="showDetails" class="hide" @click="showDetails = !showDetails">Hide information<i class="el-icon-arrow-up"></i></div>
5
- <div v-show="!showDetails" class="hide" @click="showDetails = !showDetails">Show information<i class="el-icon-arrow-down"></i></div>
6
- <el-card v-if="showDetails && Object.keys(contextData).length !== 0" v-loading="loading" class="context-card" >
7
- <div class="card-left">
8
- <img :src="banner" class="context-image">
9
- </div>
10
- <div class="card-right scrollbar">
11
- <div class="title">{{contextData.heading}}</div>
12
- <div v-html="parseMarkdown(contextData.description)"/>
13
- <br/>
14
-
15
- <!-- Show sampeles and views seperately if they do not match -->
16
- <template v-if="!samplesUnderViews">
17
- <div v-if="contextData.views && contextData.views.length > 0" class="subtitle">Scaffold Views</div>
18
- <template v-for="(view, i) in contextData.views">
19
- <div v-bind:key="i+'_1'" @click="openViewFile(view)" class="context-card-view">
20
- <img class="view-image" :src="getFileFromPath(view.thumbnail)">
21
- <div class="view-description">{{view.description}}</div>
22
- </div>
23
- <div v-bind:key="i" class="padding"/>
24
- </template>
25
- <div style="margin-bottom: 16px;"/>
26
- <div v-if="contextData.samples && contextData.samples.length > 0" class="subtitle">Samples on Scaffold</div>
27
- <template v-for="(sample, i) in contextData.samples">
28
- <span v-bind:key="i+'_3'" class="context-card-item cursor-pointer" @click="toggleSampleDetails(i)">
29
- <div v-bind:key="i+'_6'" style="display: flex">
30
- <div v-if="sample.color" class="color-box" :style="'background-color:'+ sample.color"></div>
31
- <img class="key-image" v-else-if="sample.thumbnail" :src="getFileFromPath(sample.thumbnail)">
32
- {{sample.heading}}
33
- <i class="el-icon-warning-outline info"></i>
34
- </div>
35
- </span>
36
- <div v-bind:key="i+'_4'" v-if="sampleDetails[i]" v-html="sample.description"/>
37
- <a v-bind:key="i+'_5'" v-if="sampleDetails[i] && sample.path" :href="generateFileLink(sample)" target="_blank">View Source</a>
38
- <div v-bind:key="i+'_2'" class="padding"/>
39
- </template>
40
- </template>
41
-
42
- <!-- Show samples under views if the ids match -->
43
- <template v-else>
44
- <div v-if="contextData.views && contextData.views.length > 0" class="subtitle">Scaffold Views</div>
45
- <template v-for="(view, i) in contextData.views">
46
- <span :key="i+'_1'" @click="viewClicked(view, i)" class="context-card-view">
47
- <img class="view-image" :src="getFileFromPath(view.thumbnail)"/>
48
- <div class="view-description">{{view.description}}<i class="el-icon-warning-outline info"></i> </div>
49
- </span>
50
- <div v-if="sampleDetails[i]" v-html="samplesMatching(view.id).description" :key="i+'_2'"/>
51
- <a v-bind:key="i+'_5'" v-if="sampleDetails[i] && samplesMatching(view.id).path" :href="generateFileLink(samplesMatching(view.id))" target="_blank">View Source</a>
52
- <div :key="i" class="padding"/>
53
-
54
- <!-- Extra padding if sample details is open -->
55
- <div :key="i+'_6'" v-if="sampleDetails[i]" class="padding"/>
56
- </template>
57
- </template>
58
- </div>
59
- </el-card>
60
- </div>
61
- </div>
62
- </template>
63
-
64
-
65
- <script>
66
- /* eslint-disable no-alert, no-console */
67
- import Vue from "vue";
68
- import { Link, Icon, Card, Button, Select, Input } from "element-ui";
69
- import lang from "element-ui/lib/locale/lang/en";
70
- import locale from "element-ui/lib/locale";
71
- import EventBus from "./EventBus"
72
- import hardcoded_info from './hardcoded-context-info'
73
-
74
- //provide the s3Bucket related methods and data.
75
- import S3Bucket from "../mixins/S3Bucket";
76
-
77
- import { marked } from 'marked'
78
- import xss from 'xss'
79
-
80
- locale.use(lang);
81
- Vue.use(Link);
82
- Vue.use(Icon);
83
- Vue.use(Card);
84
- Vue.use(Button);
85
- Vue.use(Select);
86
- Vue.use(Input);
87
-
88
- const addFilesToPathIfMissing = function(path){
89
- if (!path.includes('files')){
90
- return 'files/' + path
91
- } else {
92
- return path
93
- }
94
- }
95
-
96
- const convertBackslashToForwardSlash = function(path){
97
- path = path.replaceAll('\\','/')
98
- path = path.replaceAll('\\\\', '/')
99
- return path
100
- }
101
-
102
- // const switchPathToDirectory = function(path){
103
- // let newPath = path.split('/')
104
- // newPath.pop()
105
- // return newPath.join('/')
106
- // }
107
-
108
-
109
- export default {
110
- name: "contextCard",
111
- mixins: [S3Bucket],
112
- props: {
113
- /**
114
- * Object containing information for
115
- * the required viewing.
116
- */
117
- entry: Object,
118
- envVars: Object,
119
- },
120
- data: function () {
121
- return {
122
- contextData: {},
123
- showDetails: true,
124
- showContextCard: true,
125
- sampleDetails: {},
126
- loading: false
127
- };
128
- },
129
- watch: {
130
- 'entry.contextCardUrl': {
131
- handler(val){
132
- if (val) {
133
- // used for hardcoding data
134
- if (val === true){
135
- this.contextData = hardcoded_info[this.entry.discoverId]
136
- } else {
137
- this.getContextFile(val)
138
- this.showContextCard = true
139
- }
140
- } else {
141
- this.showContextCard = false
142
- }
143
- },
144
- immediate: true
145
- },
146
- 'entry.s3uri': {
147
- handler(val){
148
- this.updateS3Bucket(val);
149
- },
150
- immediate: true
151
- }
152
- },
153
- computed: {
154
- samplesUnderViews: function(){
155
- if (this.contextData){
156
- if (this.contextData.samplesUnderViews){
157
- return true
158
- } else {
159
- let viewId = this.contextData.views.map(v=>v.id)
160
- let samplesView = this.contextData.samples.map(s=>s.view)
161
-
162
- // get matching values
163
- let matching = viewId.filter(v=>samplesView.includes(v))
164
-
165
- // check all arrays have the same length (which means all values are in all three)
166
- if ( viewId.length === matching.length && matching.length === samplesView.length){
167
- return true
168
- }
169
- return false
170
- }
171
- }
172
- else return false
173
- },
174
- banner: function(){
175
- if (this.contextData.banner){
176
- return this.getFileFromPath(this.contextData.banner)
177
- } else if (this.contextData && this.contextData.views && this.contextData.views.length > 0) {
178
- if(this.contextData.views[0].thumbnail){
179
- return this.getFileFromPath(this.contextData.views[0].thumbnail)
180
- }
181
- }
182
- return this.entry.banner
183
- }
184
- },
185
- methods: {
186
- samplesMatching: function(viewId){
187
- if (this.contextData && this.contextData.samples){
188
- return this.contextData.samples.filter(s=>s.view == viewId)[0]
189
- }
190
- else return []
191
- },
192
- viewClicked: function(view, i){
193
- this.openViewFile(view)
194
- this.toggleSampleDetails(i)
195
- },
196
- getContextFile: function (contextFileUrl) {
197
- this.loading = true
198
- fetch(contextFileUrl)
199
- .then((response) =>{
200
- if (!response.ok){
201
- throw Error(response.statusText)
202
- } else {
203
- return response.json()
204
- }
205
- })
206
- .then((data) => {
207
- this.contextData = data
208
- this.loading = false
209
- this.addDiscoverIdsToContextData()
210
- })
211
- .catch((err) => {
212
- //set defaults if we hit an error
213
- console.error('caught error!', err)
214
- this.thumbnail = require('@/../assets/missing-image.svg')
215
- this.discoverId = undefined
216
- this.loading = false
217
- });
218
- },
219
- removeDoubleFilesPath: function(path){
220
- if (path.includes('files/')){
221
- return path.replace('files/', '')
222
- } else if (path.includes('files\\')) {
223
- return path.replace('files\\', '')
224
- } else {
225
- return path
226
- }
227
- },
228
- toggleSampleDetails: function(i){
229
- if (this.sampleDetails[i] === undefined){
230
- Vue.set(this.sampleDetails, i, true)
231
- } else {
232
- Vue.set(this.sampleDetails, i, !this.sampleDetails[i])
233
- }
234
- },
235
- getFileFromPath: function(path){
236
- // for hardcoded data
237
- if(this.entry.contextCardUrl === true){
238
- return path
239
- }
240
- path = this.removeDoubleFilesPath(path)
241
- return `${this.envVars.API_LOCATION}s3-resource/${this.entry.discoverId}/${this.entry.version}/files/${path}${this.getS3Args()}`
242
- },
243
- // This is used later when generateing links to the resource on sparc.science (see generateFileLink)
244
- addDiscoverIdsToContextData(){
245
- this.contextData.samples.forEach((sample, i)=>{
246
- if (sample && sample.doi && sample.doi !== ""){
247
- fetch(`${this.envVars.PENNSIEVE_API_LOCATION}/discover/datasets/doi/${this.splitDoiFromUrl(sample.doi)}`)
248
- .then((response) => response.json())
249
- .then((data) => {
250
- this.contextData.samples[i].discoverId = data.id
251
- this.contextData.samples[i].version = data.version
252
- })
253
- } else {
254
- this.contextData.samples[i].discoverId = this.entry.discoverId
255
- this.contextData.samples[i].version = this.entry.version
256
- }
257
- })
258
- },
259
- processPathForUrl(path){
260
- path = convertBackslashToForwardSlash(path)
261
- path = addFilesToPathIfMissing(path)
262
- return encodeURI(path)
263
- },
264
- splitDoiFromUrl(url){
265
- return url.split('https://doi.org/').pop()
266
- },
267
- generateFileLink(sample){
268
- return `${this.envVars.ROOT_URL}/file/${sample.discoverId}/${sample.version}?path=${this.processPathForUrl(sample.path)}`
269
-
270
- },
271
- parseMarkdown(markdown){
272
- return xss(marked.parse(markdown))
273
- },
274
- openViewFile: function(view){
275
- // note that we assume that the view file is in the same directory as the scaffold (viewUrls take relative paths)
276
- this.entry.viewUrl = `${this.envVars.API_LOCATION}s3-resource/${this.entry.discoverId}/${this.entry.version}/${view.path}${this.getS3Args()}`
277
- this.entry.type = 'Scaffold View'
278
- EventBus.$emit("PopoverActionClick", this.entry)
279
- }
280
- }
281
- };
282
- </script>
283
-
284
- <!-- Add "scoped" attribute to limit CSS to this component only -->
285
- <style scoped lang="scss">
286
- @import "~element-ui/packages/theme-chalk/src/button";
287
- @import "~element-ui/packages/theme-chalk/src/card";
288
- @import "~element-ui/packages/theme-chalk/src/icon";
289
- @import "~element-ui/packages/theme-chalk/src/input";
290
- @import "~element-ui/packages/theme-chalk/src/link";
291
- @import "~element-ui/packages/theme-chalk/src/select";
292
-
293
- .hide{
294
- color: #e4e7ed;
295
- cursor: pointer;
296
- }
297
-
298
- .context-card{
299
- background-color: white;
300
- max-height: 10 50px;
301
- padding: 8px;
302
- font-size: 14px;
303
- margin-bottom: 18px;
304
- position: relative;
305
- border: solid 1px #e4e7ed;
306
- display: flex;
307
- width: 500px;
308
- max-height: 258px;
309
- }
310
-
311
- .context-card-view{
312
- cursor: pointer;
313
- padding-bottom: 8px;
314
- display: flex;
315
- }
316
-
317
- .view-image {
318
- width: 34px;
319
- height: 34px;
320
- flex: 1;
321
- margin-right: 4px;
322
- }
323
-
324
- .view-descriptions {
325
- flex: 8;
326
- }
327
-
328
- .context-card ::v-deep .el-card__body {
329
- padding: 0px;
330
- display: flex;
331
- width: 516px;
332
- }
333
-
334
- .context-image{
335
- width: 250px;
336
- height: auto;
337
- }
338
-
339
- .color-box {
340
- width: 16px;
341
- height: 16px;
342
- border: solid 1px $app-primary-color;
343
- border-radius: 2px;
344
- margin-right: 8px;
345
- }
346
-
347
- .card-left{
348
- flex: 1
349
- }
350
-
351
- .card-right {
352
- flex: 1.3;
353
- padding-left: 6px;
354
- overflow-y: scroll;
355
- scrollbar-width: thin;
356
- }
357
-
358
- .cursor-pointer {
359
- cursor: pointer;
360
- }
361
-
362
- .info{
363
- transform: rotate(180deg);
364
- color: $app-primary-color;
365
- margin-left: 8px;
366
- }
367
-
368
- .padding {
369
- padding-bottom: 8px;
370
- }
371
-
372
- .title{
373
- font-weight: bold;
374
- }
375
-
376
- .subtitle{
377
- font-weight: bold;
378
- }
379
-
380
- .scrollbar::-webkit-scrollbar-track {
381
- border-radius: 10px;
382
- background-color: #f5f5f5;
383
- }
384
-
385
- .scrollbar::-webkit-scrollbar {
386
- width: 12px;
387
- right: -12px;
388
- background-color: #f5f5f5;
389
- }
390
-
391
- .scrollbar::-webkit-scrollbar-thumb {
392
- border-radius: 4px;
393
- box-shadow: 0 2px 4px 0 rgba(0, 0, 0, 0.06);
394
- background-color: #979797;
395
- }
396
-
397
- </style>
@@ -1,80 +0,0 @@
1
- export default {
2
-
3
- }
4
- // //Uncomment the code below to add in hardcoded data
5
- // export default {
6
- // 77: {
7
- // "description": "This dataset contains single cell scale anatomical map of the rat intrinsic cardiac nervous system (ICNS) across four male and three female hearts. These cell clusters can be seen by the yellow data points on the image as well as spherical markers on the 3D heart scaffold. The dataset provides an integrative framework to visualise the spatial distribution of ICNS across different hearts.",
8
- // "heading": "Mapped ICN samples",
9
- // "id": "sparc.science.context_data",
10
- // "samples": [
11
- // {
12
- // "annotation": "",
13
- // "description": "Spatial location of isolated ICNS mapped onto a generic heart scaffold",
14
- // "doi": "",
15
- // "heading": "ICNS from subject M54-8",
16
- // "id": "Sample 1",
17
- // "path": "",
18
- // "view": "View 1",
19
- // "color": "#FFFF00",
20
- // "thumbnail": "https://raw.githubusercontent.com/ABI-Software/map-sidebar/main/assets/temp-pics/orange.png"
21
- // },
22
- // {
23
- // "annotation": "",
24
- // "description": "Spatial location of isolated ICNS mapped onto a generic heart scaffold",
25
- // "doi": "",
26
- // "heading": "ICNS from subject M54-5",
27
- // "id": "Sample 2",
28
- // "path": "",
29
- // "view": "View 2",
30
- // "color": "#FFA500",
31
- // "thumbnail": "https://raw.githubusercontent.com/ABI-Software/map-sidebar/main/assets/temp-pics/teal.png"
32
- // }
33
- // ],
34
- // "version": "0.1.0",
35
- // },
36
- // 221: {
37
- // "description": "3D digital tracings of the enteric plexus obtained from seven subjects (M11, M16, M162, M163, M164, M168) are mapped randomly on mouse proximal colon. The data depicts individual neural wiring patterns in enteric microcircuits, and revealed both neuron and fiber units wired in a complex organization.",
38
- // "heading": "Digital tracings of enteric plexus",
39
- // "id": "sparc.science.context_data",
40
- // "samples": [
41
- // {
42
- // "annotation": "",
43
- // "description": "Neuronal soma and fibers in a myenteric ganglion in this subject are annotated into the following groups to highlight their interactions:\n\nNeuron1,2,3 Connex: Connections between 3 neurons and cross-ganglionic fibers\n\nNeuron4_Connex: A small neuron contacts fibers passing the ganglion\n\nNeuron5: Multiple projections of a neuron in an myenteric ganglion\n\nNeuron5,3,7 Connex: Connections between 3 neurons, nerve fibers, IGNEx (complex type of intraganglionic nerve endings) and fibers in the circular muscles.\n\nNeuron8,9,10 Connex: Connections of 3 neurons with each other and with long passing fibers. \n\nIntraganglionic Nerve Ending (IGNE): Digital traces of neurites consist of complex intraganglionic nerve endings. The blue fiber has branched terminals, more likely the afferent nerve endings; the violet and cyan terminals also interweave into the fiber nest; the orange, pink and peach fibers and one process of the neuron cross the IGNE to make 1-2 conjunctions. \n",
44
- // "doi": "",
45
- // "heading": "Digital tracing for subject M11",
46
- // "id": "Sample 1",
47
- // "path": "files/derivative/sub-M11/sam-pCm11/digital-traces/pC PHPS XFP M11 20XZ 180425_180713_2_NL_20.xml",
48
- // "view": "View 1"
49
- // },
50
- // {
51
- // "annotation": "",
52
- // "description": "This digital trace demonstrates some types of wiring. A long process of the green neuron terminates in the intraganglionic nerve endings (IGNE) while in contact with a nerve fiber (cyan), soma of a neuron (peach) and processes of 3 neurons (magenta, yellow and red). Two neurons and one fiber are traced to an IGNE. ",
53
- // "doi": "",
54
- // "heading": "Digital tracing for subject M16",
55
- // "id": "Sample 2",
56
- // "path": "files/derivative/sub-M16/sam-pCm16/digital-traces/pC PHPS XFP M16 20XZ 180425_180524.xml",
57
- // "view": "View 2"
58
- // }
59
- // ],
60
- // "version": "0.1.0",
61
- // "views": [
62
- // {
63
- // "annotation": "--",
64
- // "description": "Digital tracing of neurons for subject M11.",
65
- // "id": "View 1",
66
- // "path": "files/derivative/Scaffolds/M11_view.json",
67
- // "sample": "Sample 1",
68
- // "thumbnail": "https://api.sparc.science/s3-resource/221/2/files/derivative/Scaffolds/M11_thumbnail.jpeg"
69
- // },
70
- // {
71
- // "annotation": "--",
72
- // "description": "Digital tracing of neurons for subject M16.",
73
- // "id": "View 2",
74
- // "path": "files/derivative/Scaffolds/M16_view.json",
75
- // "sample": "Sample 2",
76
- // "thumbnail": "https://api.sparc.science/s3-resource/221/2/files/derivative/Scaffolds/M16_thumbnail.jpeg"
77
- // }
78
- // ]
79
- // }
80
- // }