@abi-software/map-side-bar 1.5.0 → 1.5.2

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 +228 -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 +423 -182
  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 +423 -182
  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 +188 -188
  17. package/src/algolia/utils.js +69 -69
  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/ContextCard.vue +397 -397
  23. package/src/components/DatasetCard.vue +328 -328
  24. package/src/components/EventBus.js +3 -3
  25. package/src/components/ImageGallery.vue +531 -531
  26. package/src/components/SearchFilters.vue +586 -587
  27. package/src/components/SearchHistory.vue +146 -0
  28. package/src/components/SideBar.vue +235 -232
  29. package/src/components/SidebarContent.vue +564 -554
  30. package/src/components/Tabs.vue +78 -78
  31. package/src/components/hardcoded-context-info.js +79 -79
  32. package/src/components/index.js +8 -8
  33. package/src/components/species-map.js +8 -8
  34. package/src/main.js +8 -8
  35. package/src/mixins/S3Bucket.vue +31 -31
  36. package/static.json +6 -6
  37. package/vue.config.js +19 -19
@@ -1,397 +1,397 @@
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
+ <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>