@abi-software/map-side-bar 1.3.35 → 1.3.37

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/LICENSE +201 -201
  2. package/README.md +146 -146
  3. package/babel.config.js +14 -14
  4. package/dist/map-side-bar.common.js +306 -231
  5. package/dist/map-side-bar.common.js.map +1 -1
  6. package/dist/map-side-bar.css +1 -1
  7. package/dist/map-side-bar.umd.js +306 -231
  8. package/dist/map-side-bar.umd.js.map +1 -1
  9. package/dist/map-side-bar.umd.min.js +1 -1
  10. package/dist/map-side-bar.umd.min.js.map +1 -1
  11. package/package-lock.json +13716 -13716
  12. package/package.json +67 -67
  13. package/public/index.html +17 -17
  14. package/src/App.vue +155 -152
  15. package/src/algolia/algolia.js +182 -182
  16. package/src/algolia/utils.js +69 -69
  17. package/src/components/BadgesGroup.vue +142 -142
  18. package/src/components/Cascader.vue +49 -49
  19. package/src/components/ContextCard.vue +391 -381
  20. package/src/components/DatasetCard.vue +325 -325
  21. package/src/components/EventBus.js +3 -3
  22. package/src/components/ImageGallery.vue +525 -515
  23. package/src/components/SearchFilters.vue +585 -586
  24. package/src/components/SideBar.vue +224 -224
  25. package/src/components/SidebarContent.vue +508 -508
  26. package/src/components/Tabs.vue +78 -78
  27. package/src/components/hardcoded-context-info.js +79 -79
  28. package/src/components/index.js +8 -8
  29. package/src/components/species-map.js +8 -8
  30. package/src/main.js +8 -8
  31. package/src/mixins/S3Bucket.vue +31 -0
  32. package/static.json +6 -6
  33. package/vue.config.js +11 -11
  34. package/del.json +0 -27
  35. package/delte.json +0 -30
  36. package/scaffold_context_info.json +0 -31
  37. package/src/components/processFilters.js +0 -22
@@ -1,381 +1,391 @@
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
- import { marked } from 'marked'
75
- import xss from 'xss'
76
-
77
- locale.use(lang);
78
- Vue.use(Link);
79
- Vue.use(Icon);
80
- Vue.use(Card);
81
- Vue.use(Button);
82
- Vue.use(Select);
83
- Vue.use(Input);
84
-
85
- const addFilesToPathIfMissing = function(path){
86
- if (!path.includes('files')){
87
- return 'files/' + path
88
- } else {
89
- return path
90
- }
91
- }
92
-
93
- const convertBackslashToForwardSlash = function(path){
94
- path = path.replaceAll('\\','/')
95
- path = path.replaceAll('\\\\', '/')
96
- return path
97
- }
98
-
99
- // const switchPathToDirectory = function(path){
100
- // let newPath = path.split('/')
101
- // newPath.pop()
102
- // return newPath.join('/')
103
- // }
104
-
105
-
106
- export default {
107
- name: "contextCard",
108
- props: {
109
- /**
110
- * Object containing information for
111
- * the required viewing.
112
- */
113
- entry: Object,
114
- envVars: Object,
115
- },
116
- data: function () {
117
- return {
118
- contextData: {},
119
- showDetails: true,
120
- showContextCard: true,
121
- sampleDetails: {},
122
- loading: false
123
- };
124
- },
125
- watch: {
126
- 'entry.contextCardUrl': {
127
- handler(val){
128
- if (val) {
129
- // used for hardcoding data
130
- if (val === true){
131
- this.contextData = hardcoded_info[this.entry.discoverId]
132
- } else {
133
- this.getContextFile(val)
134
- this.showContextCard = true
135
- }
136
- } else {
137
- this.showContextCard = false
138
- }
139
- },
140
- immediate: true
141
- }
142
- },
143
- computed: {
144
- samplesUnderViews: function(){
145
- if (this.contextData){
146
- if (this.contextData.samplesUnderViews){
147
- return true
148
- } else {
149
- let viewId = this.contextData.views.map(v=>v.id)
150
- let samplesView = this.contextData.samples.map(s=>s.view)
151
-
152
- // get matching values
153
- let matching = viewId.filter(v=>samplesView.includes(v))
154
-
155
- // check all arrays have the same length (which means all values are in all three)
156
- if ( viewId.length === matching.length && matching.length === samplesView.length){
157
- return true
158
- }
159
- return false
160
- }
161
- }
162
- else return false
163
- },
164
- banner: function(){
165
- if (this.contextData.banner){
166
- return this.getFileFromPath(this.contextData.banner)
167
- } else if (this.contextData && this.contextData.views && this.contextData.views.length > 0) {
168
- if(this.contextData.views[0].thumbnail){
169
- return this.getFileFromPath(this.contextData.views[0].thumbnail)
170
- }
171
- }
172
- return this.entry.banner
173
- }
174
- },
175
- methods: {
176
- samplesMatching: function(viewId){
177
- if (this.contextData && this.contextData.samples){
178
- return this.contextData.samples.filter(s=>s.view == viewId)[0]
179
- }
180
- else return []
181
- },
182
- viewClicked: function(view, i){
183
- this.openViewFile(view)
184
- this.toggleSampleDetails(i)
185
- },
186
- getContextFile: function (contextFileUrl) {
187
- this.loading = true
188
- fetch(contextFileUrl)
189
- .then((response) =>{
190
- if (!response.ok){
191
- throw Error(response.statusText)
192
- } else {
193
- return response.json()
194
- }
195
- })
196
- .then((data) => {
197
- this.contextData = data
198
- this.loading = false
199
- this.addDiscoverIdsToContextData()
200
- })
201
- .catch((err) => {
202
- //set defaults if we hit an error
203
- console.error('caught error!', err)
204
- this.thumbnail = require('@/../assets/missing-image.svg')
205
- this.discoverId = undefined
206
- this.loading = false
207
- });
208
- },
209
- removeDoubleFilesPath: function(path){
210
- if (path.includes('files/')){
211
- return path.replace('files/', '')
212
- } else if (path.includes('files\\')) {
213
- return path.replace('files\\', '')
214
- } else {
215
- return path
216
- }
217
- },
218
- toggleSampleDetails: function(i){
219
- if (this.sampleDetails[i] === undefined){
220
- Vue.set(this.sampleDetails, i, true)
221
- } else {
222
- Vue.set(this.sampleDetails, i, !this.sampleDetails[i])
223
- }
224
- },
225
- getFileFromPath: function(path){
226
- // for hardcoded data
227
- if(this.entry.contextCardUrl === true){
228
- return path
229
- }
230
- path = this.removeDoubleFilesPath(path)
231
- return `${this.envVars.API_LOCATION}s3-resource/${this.entry.discoverId}/${this.entry.version}/files/${path}`
232
- },
233
- // This is used later when generateing links to the resource on sparc.science (see generateFileLink)
234
- addDiscoverIdsToContextData(){
235
- this.contextData.samples.forEach((sample, i)=>{
236
- if (sample && sample.doi && sample.doi !== ""){
237
- fetch(`${this.envVars.PENNSIEVE_API_LOCATION}/discover/datasets/doi/${this.splitDoiFromUrl(sample.doi)}`)
238
- .then((response) => response.json())
239
- .then((data) => {
240
- this.contextData.samples[i].discoverId = data.id
241
- this.contextData.samples[i].version = data.version
242
- })
243
- } else {
244
- this.contextData.samples[i].discoverId = this.entry.discoverId
245
- this.contextData.samples[i].version = this.entry.version
246
- }
247
- })
248
- },
249
- processPathForUrl(path){
250
- path = convertBackslashToForwardSlash(path)
251
- path = addFilesToPathIfMissing(path)
252
- return encodeURI(path)
253
- },
254
- splitDoiFromUrl(url){
255
- return url.split('https://doi.org/').pop()
256
- },
257
- generateFileLink(sample){
258
- return `${this.envVars.ROOT_URL}/file/${sample.discoverId}/${sample.version}?path=${this.processPathForUrl(sample.path)}`
259
-
260
- },
261
- parseMarkdown(markdown){
262
- return xss(marked.parse(markdown))
263
- },
264
- openViewFile: function(view){
265
- // note that we assume that the view file is in the same directory as the scaffold (viewUrls take relative paths)
266
- this.entry.viewUrl = `${this.envVars.API_LOCATION}s3-resource/${this.entry.discoverId}/${this.entry.version}/${view.path}`
267
- this.entry.type = 'Scaffold View'
268
- EventBus.$emit("PopoverActionClick", this.entry)
269
- }
270
- }
271
- };
272
- </script>
273
-
274
- <!-- Add "scoped" attribute to limit CSS to this component only -->
275
- <style scoped>
276
-
277
- .hide{
278
- color: #e4e7ed;
279
- cursor: pointer;
280
- }
281
-
282
- .context-card{
283
- background-color: white;
284
- max-height: 10 50px;
285
- padding: 8px;
286
- font-size: 14px;
287
- margin-bottom: 18px;
288
- position: relative;
289
- border: solid 1px #e4e7ed;
290
- display: flex;
291
- width: 500px;
292
- max-height: 258px;
293
- }
294
-
295
- .context-card-view{
296
- cursor: pointer;
297
- padding-bottom: 8px;
298
- display: flex;
299
- }
300
-
301
- .view-image {
302
- width: 34px;
303
- height: 34px;
304
- flex: 1;
305
- margin-right: 4px;
306
- }
307
-
308
- .view-descriptions {
309
- flex: 8;
310
- }
311
-
312
- .context-card >>> .el-card__body {
313
- padding: 0px;
314
- display: flex;
315
- width: 516px;
316
- }
317
-
318
- .context-image{
319
- width: 250px;
320
- height: auto;
321
- }
322
-
323
- .color-box {
324
- width: 16px;
325
- height: 16px;
326
- border: solid 1px #8300bf;
327
- border-radius: 2px;
328
- margin-right: 8px;
329
- }
330
-
331
- .card-left{
332
- flex: 1
333
- }
334
-
335
- .card-right {
336
- flex: 1.3;
337
- padding-left: 6px;
338
- overflow-y: scroll;
339
- scrollbar-width: thin;
340
- }
341
-
342
- .cursor-pointer {
343
- cursor: pointer;
344
- }
345
-
346
- .info{
347
- transform: rotate(180deg);
348
- color: #8300bf;
349
- margin-left: 8px;
350
- }
351
-
352
- .padding {
353
- padding-bottom: 8px;
354
- }
355
-
356
- .title{
357
- font-weight: bold;
358
- }
359
-
360
- .subtitle{
361
- font-weight: bold;
362
- }
363
-
364
- .scrollbar::-webkit-scrollbar-track {
365
- border-radius: 10px;
366
- background-color: #f5f5f5;
367
- }
368
-
369
- .scrollbar::-webkit-scrollbar {
370
- width: 12px;
371
- right: -12px;
372
- background-color: #f5f5f5;
373
- }
374
-
375
- .scrollbar::-webkit-scrollbar-thumb {
376
- border-radius: 4px;
377
- box-shadow: 0 2px 4px 0 rgba(0, 0, 0, 0.06);
378
- background-color: #979797;
379
- }
380
-
381
- </style>
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>
286
+
287
+ .hide{
288
+ color: #e4e7ed;
289
+ cursor: pointer;
290
+ }
291
+
292
+ .context-card{
293
+ background-color: white;
294
+ max-height: 10 50px;
295
+ padding: 8px;
296
+ font-size: 14px;
297
+ margin-bottom: 18px;
298
+ position: relative;
299
+ border: solid 1px #e4e7ed;
300
+ display: flex;
301
+ width: 500px;
302
+ max-height: 258px;
303
+ }
304
+
305
+ .context-card-view{
306
+ cursor: pointer;
307
+ padding-bottom: 8px;
308
+ display: flex;
309
+ }
310
+
311
+ .view-image {
312
+ width: 34px;
313
+ height: 34px;
314
+ flex: 1;
315
+ margin-right: 4px;
316
+ }
317
+
318
+ .view-descriptions {
319
+ flex: 8;
320
+ }
321
+
322
+ .context-card >>> .el-card__body {
323
+ padding: 0px;
324
+ display: flex;
325
+ width: 516px;
326
+ }
327
+
328
+ .context-image{
329
+ width: 250px;
330
+ height: auto;
331
+ }
332
+
333
+ .color-box {
334
+ width: 16px;
335
+ height: 16px;
336
+ border: solid 1px #8300bf;
337
+ border-radius: 2px;
338
+ margin-right: 8px;
339
+ }
340
+
341
+ .card-left{
342
+ flex: 1
343
+ }
344
+
345
+ .card-right {
346
+ flex: 1.3;
347
+ padding-left: 6px;
348
+ overflow-y: scroll;
349
+ scrollbar-width: thin;
350
+ }
351
+
352
+ .cursor-pointer {
353
+ cursor: pointer;
354
+ }
355
+
356
+ .info{
357
+ transform: rotate(180deg);
358
+ color: #8300bf;
359
+ margin-left: 8px;
360
+ }
361
+
362
+ .padding {
363
+ padding-bottom: 8px;
364
+ }
365
+
366
+ .title{
367
+ font-weight: bold;
368
+ }
369
+
370
+ .subtitle{
371
+ font-weight: bold;
372
+ }
373
+
374
+ .scrollbar::-webkit-scrollbar-track {
375
+ border-radius: 10px;
376
+ background-color: #f5f5f5;
377
+ }
378
+
379
+ .scrollbar::-webkit-scrollbar {
380
+ width: 12px;
381
+ right: -12px;
382
+ background-color: #f5f5f5;
383
+ }
384
+
385
+ .scrollbar::-webkit-scrollbar-thumb {
386
+ border-radius: 4px;
387
+ box-shadow: 0 2px 4px 0 rgba(0, 0, 0, 0.06);
388
+ background-color: #979797;
389
+ }
390
+
391
+ </style>