@abi-software/map-side-bar 1.1.17 → 1.2.0-beta.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.
@@ -1,388 +1,476 @@
1
- <template>
2
- <div class="dataset-card-container" ref="container">
3
- <div v-bind:class=" expanded ? 'dataset-card-expanded' : 'dataset-card'" ref="card">
4
- <div v-if="entry.id !== 0" class="seperator-path"></div>
5
- <div class="card" >
6
- <span class="card-left">
7
- <img svg-inline class="banner-img" :src="thumbnail" @click="openDataset"/>
8
- </span>
9
- <div class="card-right" >
10
- <div class="title" @click="cardClicked">{{entry.name}}</div>
11
- <div class="details">{{contributors}} {{entry.publishDate ? `(${publishYear})` : ''}}</div>
12
- <div class="details">{{samples}}</div>
13
- <div class="details">id: {{discoverId}}</div>
14
- <div>
15
- <el-button v-if="!entry.simulation" @click="openDataset" size="mini" class="button" icon="el-icon-coin">View dataset</el-button>
16
- </div>
17
- <div>
18
- <el-button v-if="entry.scaffolds" @click="openScaffold" size="mini" class="button" icon="el-icon-view">View scaffold</el-button>
19
- </div>
20
- <div>
21
- <el-button v-if="hasCSVFile" @click="openPlot" size="mini" class="button" icon="el-icon-view">View plot</el-button>
22
- </div>
23
- <div>
24
- <el-button v-if="entry.simulation" @click="openRepository" size="mini" class="button" icon="el-icon-view">View repository</el-button>
25
- </div>
26
- <div>
27
- <el-button v-if="entry.simulation" @click="openSimulation" size="mini" class="button" icon="el-icon-view">View simulation</el-button>
28
- </div>
29
- </div>
30
-
31
- </div>
32
- <p v-if="(cardOverflow && !expanded)" class="read-more"><el-button @click="expand" class="read-more-button">Read more...</el-button></p>
33
- </div>
34
- </div>
35
- </template>
36
-
37
-
38
- <script>
39
- /* eslint-disable no-alert, no-console */
40
- import Vue from "vue";
41
- import { Button, Icon } from "element-ui";
42
- import lang from "element-ui/lib/locale/lang/en";
43
- import locale from "element-ui/lib/locale";
44
- import EventBus from "./EventBus"
45
- import speciesMap from "./species-map";
46
-
47
- locale.use(lang);
48
- Vue.use(Button);
49
- Vue.use(Icon);
50
-
51
- const capitalise = function(string){
52
- return string.replace(/\b\w/g, v => v.toUpperCase());
53
- }
54
-
55
- export default {
56
- name: "DatasetCard",
57
- props: {
58
- /**
59
- * Object containing information for
60
- * the required viewing.
61
- */
62
- entry: Object,
63
- envVars: {
64
- type: Object,
65
- default: () => {}
66
- },
67
- },
68
- data: function () {
69
- return {
70
- thumbnail: require('@/../assets/missing-image.svg'),
71
- dataLocation: this.entry.doi,
72
- discoverId: undefined,
73
- cardOverflow: false,
74
- expanded: false
75
- };
76
- },
77
- computed: {
78
- hasCSVFile: function(){
79
- return ( this.entry.csvFiles && this.entry.csvFiles.length !== 0 )
80
- },
81
- contributors: function() {
82
- let text = "";
83
- if (this.entry.contributors) {
84
- if (this.entry.contributors.length === 1) {
85
- text = this.lastName(this.entry.contributors[0].name);
86
- } else if (this.entry.contributors.length === 2) {
87
- text = this.lastName(this.entry.contributors[0].name) + " & " + this.lastName(this.entry.contributors[1].name);
88
- } else if (this.entry.contributors.length > 2) {
89
- text = this.lastName(this.entry.contributors[0].name) + " et al.";
90
- }
91
- }
92
- return text;
93
- },
94
- samples: function() {
95
- let text = "";
96
- if (this.entry.species) {
97
- if (speciesMap[this.entry.species[0].toLowerCase()]){
98
- text = `${speciesMap[this.entry.species[0].toLowerCase()]}`;
99
- } else {
100
- text = `${this.entry.species}`;
101
- }
102
- }
103
- if (this.entry.numberSamples > 0) {
104
- text += " (";
105
- if (this.entry.numberSamples === 1) {
106
- text += `${this.entry.numberSamples} sample`;
107
- } else if (this.entry.numberSamples > 1) {
108
- text += `${this.entry.numberSamples} samples`;
109
- }
110
- if (this.entry.numberSubjects === 1) {
111
- text += ` from ${this.entry.numberSubjects} subject`;
112
- } else if (this.entry.numberSamples > 1) {
113
- text += ` from ${this.entry.numberSubjects} subjects`;
114
- }
115
- text += ")";
116
- }
117
-
118
- return text;
119
- },
120
- label: function(){
121
- return this.entry.organs ? this.entry.organs[0] : this.entry.name
122
- },
123
- publishYear: function() {
124
- return this.entry.publishDate.split('-')[0]
125
- }
126
- },
127
- methods: {
128
- cardClicked: function(){
129
- if(this.entry.scaffolds){
130
- this.openScaffold()
131
- }else{
132
- this.openDataset()
133
- }
134
- },
135
- openScaffold: function(){
136
- let action = {
137
- label: capitalise(this.label),
138
- resource: this.getScaffoldPath(this.discoverId, this.version, this.entry.scaffolds[0].dataset.path),
139
- title: "View 3D scaffold",
140
- type: "Scaffold",
141
- discoverId: this.discoverId,
142
- apiLocation: this.envVars.API_LOCATION,
143
- version: this.version,
144
- contextCardUrl: this.entry.contextualInformation ? this.getFileFromPath(this.discoverId, this.version,this.entry.contextualInformation) : undefined,
145
- banner: this.thumbnail
146
- }
147
- this.propogateCardAction(action)
148
- },
149
- openPlot: function(){
150
- let action = {
151
- label: capitalise(this.label),
152
- resource: this.getFileFromPath(this.discoverId, this.version, this.entry.csvFiles[0].dataset.path),
153
- title: "View plot",
154
- type: "Plot",
155
- discoverId: this.discoverId,
156
- apiLocation: this.envVars.API_LOCATION,
157
- version: this.version,
158
- contextCardUrl: this.entry.contextualInformation ? this.getFileFromPath(this.discoverId, this.version,this.entry.contextualInformation) : undefined,
159
- banner: this.thumbnail
160
- }
161
- this.propogateCardAction(action)
162
- },
163
- openDataset: function(){
164
- window.open(this.dataLocation,'_blank');
165
- },
166
- openRepository: function() {
167
- let apiLocation = this.envVars.API_LOCATION;
168
- this.entry.additionalLinks.forEach(function(el) {
169
- if (el.description == "Repository") {
170
- let xmlhttp = new XMLHttpRequest();
171
- xmlhttp.open("POST", apiLocation + "/pmr_latest_exposure", true);
172
- xmlhttp.setRequestHeader("Content-type", "application/json");
173
- xmlhttp.onreadystatechange = () => {
174
- if (xmlhttp.readyState === 4) {
175
- let url = "";
176
- if (xmlhttp.status === 200) {
177
- url = JSON.parse(xmlhttp.responseText)["url"];
178
- }
179
- if (url === "") {
180
- url = el.uri;
181
- }
182
- window.open(url,'_blank');
183
- }
184
- };
185
- xmlhttp.send(JSON.stringify({workspace_url: el.uri}));
186
- }
187
- });
188
- },
189
- openSimulation: function() {
190
- let isSedmlResource = false;
191
- let resource = undefined;
192
- this.entry.additionalLinks.forEach(function(el) {
193
- if (el.description == "SED-ML file") {
194
- isSedmlResource = true;
195
- resource = el.uri;
196
- } else if (!isSedmlResource && (el.description == "CellML file")) {
197
- resource = el.uri;
198
- }
199
- });
200
- let action = {
201
- label: undefined,
202
- resource: resource,
203
- dataset: this.dataLocation,
204
- apiLocation: this.envVars.API_LOCATION,
205
- version: this.version,
206
- contextCardUrl: this.entry.contextualInformation ? this.getFileFromPath(this.discoverId, this.version,this.entry.contextualInformation) : undefined,
207
- banner: this.thumbnail,
208
- title: "View simulation",
209
- name: this.entry.name,
210
- description: this.entry.description,
211
- type: "Simulation"
212
- }
213
- EventBus.$emit("PopoverActionClick", action)
214
- },
215
- propogateCardAction: function(action){
216
- EventBus.$emit("PopoverActionClick", action)
217
- if (action.contextCardUrl) {
218
- this.$emit('contextUpdate', action)
219
- }
220
-
221
- },
222
- getScaffoldPath: function(discoverId, version, scaffoldPath){
223
- let id = discoverId
224
- let path = `${this.envVars.API_LOCATION}s3-resource/${id}/${version}/files/${scaffoldPath}`
225
- return path
226
- },
227
- getFileFromPath: function(discoverId, version, path){
228
- return `${this.envVars.API_LOCATION}s3-resource/${discoverId}/${version}/files/${path}`
229
- },
230
- isOverflown: function(el){
231
- return el.clientHeight < el.scrollHeight
232
- },
233
- expand: function() {
234
- this.expanded = true
235
- },
236
- splitDOI: function(doi){
237
- return [doi.split('/')[doi.split('/').length-2], doi.split('/')[doi.split('/').length-1]]
238
- },
239
- getBanner: function () {
240
- let doi = this.splitDOI(this.entry.doi)
241
- fetch(`https://api.pennsieve.io/discover/datasets/doi/${doi[0]}/${doi[1]}`)
242
- .then((response) =>{
243
- if (!response.ok){
244
- throw Error(response.statusText)
245
- } else {
246
- return response.json()
247
- }
248
- })
249
- .then((data) => {
250
- this.thumbnail = data.banner
251
- this.discoverId = data.id
252
- this.version = data.version
253
- this.dataLocation = `https://sparc.science/datasets/${data.id}?type=dataset`
254
- })
255
- .catch(() => {
256
- //set defaults if we hit an error
257
- this.thumbnail = require('@/../assets/missing-image.svg')
258
- this.discoverId = undefined
259
- });
260
- },
261
- lastName: function(fullName){
262
- return fullName.split(',')[0]
263
- },
264
- },
265
- mounted: function(){
266
- this.getBanner()
267
- this.cardOverflow = this.isOverflown(this.$refs.card)
268
- },
269
- updated: function () {
270
- },
271
- watch: {
272
- 'entry.description': function() { // watch it
273
- this.cardOverflow = false
274
- this.expanded = false
275
- this.cardOverflow = this.isOverflown(this.$refs.card)
276
- this.getBanner()
277
- }
278
- },
279
- };
280
- </script>
281
-
282
- <!-- Add "scoped" attribute to limit CSS to this component only -->
283
- <style scoped>
284
- .dataset-card {
285
- padding-left: 16px;
286
- position: relative;
287
- }
288
- .seperator-path {
289
- width: 486px;
290
- height: 0px;
291
- border: solid 1px #e4e7ed;
292
- background-color: #e4e7ed;
293
- }
294
- .title {
295
- padding-bottom: 5px;
296
- font-family: Asap;
297
- font-size: 14px;
298
- font-weight: bold;
299
- font-stretch: normal;
300
- font-style: normal;
301
- line-height: 1.5;
302
- letter-spacing: 1.05px;
303
- color: #484848;
304
- cursor: pointer;
305
- }
306
- .card {
307
- padding-top: 18px;
308
- position: relative;
309
- display: flex;
310
- }
311
-
312
- .card-left{
313
- flex: 1
314
- }
315
-
316
- .card-right {
317
- flex: 1.3;
318
- padding-left: 6px;
319
- }
320
-
321
- .dataset-card .read-more {
322
- position: absolute;
323
- z-index: 9;
324
- bottom: 0;
325
- left: 0;
326
- width: 100%;
327
- height: 20px;
328
- margin: 0; padding: 20px 66px;
329
- /* "transparent" only works here because == rgba(0,0,0,0) */
330
- background-image: linear-gradient(to bottom, transparent, white);
331
- pointer-events: none;
332
- }
333
-
334
- .read-more-button{
335
- width: 85px;
336
- height: 20px;
337
- font-family: Asap;
338
- font-size: 14px;
339
- font-weight: normal;
340
- font-stretch: normal;
341
- font-style: normal;
342
- line-height: normal;
343
- letter-spacing: normal;
344
- color: #8300bf;
345
- padding: 0px;
346
- pointer-events: all;
347
- cursor: pointer;
348
- }
349
-
350
- .button{
351
- z-index: 10;
352
- font-family: Asap;
353
- font-size: 14px;
354
- font-weight: normal;
355
- font-stretch: normal;
356
- font-style: normal;
357
- line-height: normal;
358
- letter-spacing: normal;
359
- background-color: #8300bf;
360
- border: #8300bf;
361
- color: white;
362
- cursor: pointer;
363
- margin-top: 8px;
364
- }
365
-
366
- .button:hover {
367
- background-color: #8300bf;
368
- color: white;
369
- }
370
-
371
- .banner-img {
372
- width: 128px;
373
- height: 128px;
374
- box-shadow: 0 2px 4px 0 rgba(0, 0, 0, 0.25);
375
- background-color: #ffffff;
376
- cursor: pointer;
377
- }
378
- .details{
379
- font-family: Asap;
380
- font-size: 14px;
381
- font-weight: normal;
382
- font-stretch: normal;
383
- font-style: normal;
384
- line-height: 1.5;
385
- letter-spacing: 1.05px;
386
- color: #484848;
387
- }
388
- </style>
1
+ <template>
2
+ <div class="dataset-card-container" ref="container">
3
+ <div v-bind:class=" expanded ? 'dataset-card-expanded' : 'dataset-card'" ref="card">
4
+ <!-- The seperator-path css is set on SidebarContent.vue -->
5
+ <div class="seperator-path"></div>
6
+ <div class="card" >
7
+ <span class="card-left">
8
+ <!--
9
+ <img svg-inline class="banner-img" :src="thumbnail" @click="openDataset"/>
10
+ -->
11
+ <image-gallery v-if="dataIsReady"
12
+ :datasetId="discoverId"
13
+ :datasetVersion="version"
14
+ :envVars="envVars"
15
+ :images="entry.images"
16
+ :scaffolds="entry.scaffolds"
17
+ :scaffoldViews="entry.scaffoldViews"
18
+ :segmentations="entry.segmentation"
19
+ :additionalLinks="simulationLinks"
20
+ :videos="entry.videos"
21
+ :thumbnails="entry.thumbnails"
22
+ :label="label"
23
+ :datasetThumbnail="thumbnail"
24
+ @card-clicked="galleryClicked"/>
25
+ </span>
26
+ <div class="card-right" >
27
+ <div class="title" @click="cardClicked">{{entry.name}}</div>
28
+ <div class="details">{{contributors}} {{entry.publishDate ? `(${publishYear})` : ''}}</div>
29
+ <div class="details">{{samples}}</div>
30
+ <div class="details">id: {{discoverId}}</div>
31
+ <!--
32
+ <div>
33
+ <el-button v-if="!entry.simulation" @click="openDataset" size="mini" class="button" icon="el-icon-coin">View dataset</el-button>
34
+ </div>
35
+ <div>
36
+ <el-button v-if="entry.scaffolds" @click="openScaffold" size="mini" class="button" icon="el-icon-view">View scaffold</el-button>
37
+ </div>
38
+ -->
39
+ <!--
40
+ <div>
41
+ <el-button v-if="hasCSVFile" @click="openPlot" size="mini" class="button" icon="el-icon-view">View plot</el-button>
42
+ </div>
43
+ -->
44
+ <div>
45
+ <el-button v-if="entry.simulation" @click="openRepository" size="mini" class="button" icon="el-icon-view">View repository</el-button>
46
+ </div>
47
+ <!--
48
+ <div>
49
+ <el-button v-if="entry.simulation" @click="openSimulation" size="mini" class="button" icon="el-icon-view">View simulation</el-button>
50
+ </div>
51
+ -->
52
+ <!--
53
+ <div>
54
+ <el-button v-if="entry.segmentation" @click="openSegmentation" size="mini" class="button" icon="el-icon-view">View segmentation</el-button>
55
+ </div>
56
+ <div>
57
+ <el-button v-if="biolucidaData" @click="openImage" size="mini" class="button" icon="el-icon-view">View image</el-button>
58
+ </div>
59
+ -->
60
+ </div>
61
+
62
+ </div>
63
+ <p v-if="(cardOverflow && !expanded)" class="read-more"><el-button @click="expand" class="read-more-button">Read more...</el-button></p>
64
+ </div>
65
+ </div>
66
+ </template>
67
+
68
+
69
+ <script>
70
+ /* eslint-disable no-alert, no-console */
71
+ import Vue from "vue";
72
+ import { Button, Icon } from "element-ui";
73
+ import lang from "element-ui/lib/locale/lang/en";
74
+ import locale from "element-ui/lib/locale";
75
+ import EventBus from "./EventBus"
76
+ import speciesMap from "./species-map";
77
+ import ImageGallery from "./ImageGallery.vue";
78
+
79
+ locale.use(lang);
80
+ Vue.use(Button);
81
+ Vue.use(Icon);
82
+
83
+ const capitalise = function(string){
84
+ return string.replace(/\b\w/g, v => v.toUpperCase());
85
+ }
86
+
87
+ export default {
88
+ name: "DatasetCard",
89
+ components: { ImageGallery },
90
+ props: {
91
+ /**
92
+ * Object containing information for
93
+ * the required viewing.
94
+ */
95
+ entry: Object,
96
+ envVars: {
97
+ type: Object,
98
+ default: () => {}
99
+ },
100
+ },
101
+ data: function () {
102
+ return {
103
+ dataIsReady: false,
104
+ thumbnail: require('@/../assets/missing-image.svg'),
105
+ dataLocation: this.entry.doi,
106
+ discoverId: undefined,
107
+ cardOverflow: false,
108
+ expanded: false,
109
+ biolucidaData: undefined
110
+ };
111
+ },
112
+ computed: {
113
+ contributors: function() {
114
+ let text = "";
115
+ if (this.entry.contributors) {
116
+ if (this.entry.contributors.length === 1) {
117
+ text = this.lastName(this.entry.contributors[0].name);
118
+ } else if (this.entry.contributors.length === 2) {
119
+ text = this.lastName(this.entry.contributors[0].name) + " & " + this.lastName(this.entry.contributors[1].name);
120
+ } else if (this.entry.contributors.length > 2) {
121
+ text = this.lastName(this.entry.contributors[0].name) + " et al.";
122
+ }
123
+ }
124
+ return text;
125
+ },
126
+ samples: function() {
127
+ let text = "";
128
+ if (this.entry.species) {
129
+ if (speciesMap[this.entry.species[0].toLowerCase()]){
130
+ text = `${speciesMap[this.entry.species[0].toLowerCase()]}`;
131
+ } else {
132
+ text = `${this.entry.species}`;
133
+ }
134
+ }
135
+ if (this.entry.numberSamples > 0) {
136
+ text += " (";
137
+ if (this.entry.numberSamples === 1) {
138
+ text += `${this.entry.numberSamples} sample`;
139
+ } else if (this.entry.numberSamples > 1) {
140
+ text += `${this.entry.numberSamples} samples`;
141
+ }
142
+ if (this.entry.numberSubjects === 1) {
143
+ text += ` from ${this.entry.numberSubjects} subject`;
144
+ } else if (this.entry.numberSamples > 1) {
145
+ text += ` from ${this.entry.numberSubjects} subjects`;
146
+ }
147
+ text += ")";
148
+ }
149
+
150
+ return text;
151
+ },
152
+ simulationLinks: function() {
153
+ if (this.entry.additionalLinks) {
154
+ if (typeof this.entry.additionalLinks != "boolean")
155
+ return this.entry.additionalLinks;
156
+ }
157
+ return [];
158
+ },
159
+ label: function(){
160
+ return this.entry.organs ? this.entry.organs[0] : this.entry.name
161
+ },
162
+ publishYear: function() {
163
+ return this.entry.publishDate.split('-')[0]
164
+ }
165
+ },
166
+ methods: {
167
+ cardClicked: function(){
168
+ if(this.entry.scaffolds){
169
+ this.openScaffold()
170
+ }else{
171
+ this.openDataset()
172
+ }
173
+ },
174
+ galleryClicked: function(payload) {
175
+ this.propogateCardAction(payload)
176
+ },
177
+ openScaffold: function(){
178
+ let action = {
179
+ label: capitalise(this.label),
180
+ resource: this.getScaffoldPath(this.discoverId, this.version, this.entry.scaffolds[0].dataset.path),
181
+ title: "View 3D scaffold",
182
+ type: "Scaffold",
183
+ discoverId: this.discoverId,
184
+ apiLocation: this.envVars.API_LOCATION,
185
+ version: this.version,
186
+ contextCardUrl: this.entry.contextualInformation ? this.getFileFromPath(this.discoverId, this.version,this.entry.contextualInformation) : undefined,
187
+ banner: this.thumbnail
188
+ }
189
+ this.propogateCardAction(action)
190
+ },
191
+ openPlot: function(){
192
+ let action = {
193
+ label: capitalise(this.label),
194
+ resource: this.getFileFromPath(this.discoverId, this.version, this.entry.csvFiles[0].dataset.path),
195
+ title: "View plot",
196
+ type: "Plot",
197
+ discoverId: this.discoverId,
198
+ apiLocation: this.envVars.API_LOCATION,
199
+ version: this.version,
200
+ contextCardUrl: this.entry.contextualInformation ? this.getFileFromPath(this.discoverId, this.version,this.entry.contextualInformation) : undefined,
201
+ banner: this.thumbnail
202
+ }
203
+ this.propogateCardAction(action)
204
+ },
205
+ openDataset: function(){
206
+ window.open(this.dataLocation,'_blank');
207
+ },
208
+ openRepository: function() {
209
+ let apiLocation = this.envVars.API_LOCATION;
210
+ this.entry.additionalLinks.forEach(function(el) {
211
+ if (el.description == "Repository") {
212
+ let xmlhttp = new XMLHttpRequest();
213
+ xmlhttp.open("POST", apiLocation + "/pmr_latest_exposure", true);
214
+ xmlhttp.setRequestHeader("Content-type", "application/json");
215
+ xmlhttp.onreadystatechange = () => {
216
+ if (xmlhttp.readyState === 4) {
217
+ let url = "";
218
+ if (xmlhttp.status === 200) {
219
+ url = JSON.parse(xmlhttp.responseText)["url"];
220
+ }
221
+ if (url === "") {
222
+ url = el.uri;
223
+ }
224
+ window.open(url,'_blank');
225
+ }
226
+ };
227
+ xmlhttp.send(JSON.stringify({workspace_url: el.uri}));
228
+ }
229
+ });
230
+ },
231
+ openSimulation: function() {
232
+ let isSedmlResource = false;
233
+ let resource = undefined;
234
+ this.entry.additionalLinks.forEach(function(el) {
235
+ if (el.description == "SED-ML file") {
236
+ isSedmlResource = true;
237
+ resource = el.uri;
238
+ } else if (!isSedmlResource && (el.description == "CellML file")) {
239
+ resource = el.uri;
240
+ }
241
+ });
242
+ let action = {
243
+ label: undefined,
244
+ resource: resource,
245
+ dataset: this.dataLocation,
246
+ apiLocation: this.envVars.API_LOCATION,
247
+ version: this.version,
248
+ contextCardUrl: this.entry.contextualInformation ? this.getFileFromPath(this.discoverId, this.version,this.entry.contextualInformation) : undefined,
249
+ banner: this.thumbnail,
250
+ title: "View simulation",
251
+ name: this.entry.name,
252
+ description: this.entry.description,
253
+ type: "Simulation"
254
+ }
255
+ EventBus.$emit("PopoverActionClick", action)
256
+ },
257
+ openSegmentation: function() {
258
+ if (this.entry.segmentation && this.entry.segmentation[0]) {
259
+ const segmentation = this.entry.segmentation[0];
260
+ const filePath = segmentation.dataset.path;
261
+ const datasetId = this.discoverId;
262
+ const datasetVersion = this.version;
263
+ const prefix = this.envVars.NL_LINK_PREFIX;
264
+ const resource = {
265
+ share_link: `${prefix}/dataviewer?datasetId=${datasetId}&version=${datasetVersion}&path=${filePath}`
266
+ };
267
+ let action = {
268
+ label: capitalise(this.label),
269
+ resource: resource,
270
+ dataset: this.dataLocation,
271
+ datasetId: this.discoverId,
272
+ title: "View segmentation",
273
+ name: this.entry.name,
274
+ description: this.entry.description,
275
+ type: "Segmentation"
276
+ };
277
+ EventBus.$emit("PopoverActionClick", action);
278
+ }
279
+ },
280
+ openImage: function() {
281
+ if (this.biolucidaData) {
282
+ const biolucidaData = this.biolucidaData;
283
+ if ('dataset_images' in biolucidaData) {
284
+ const image = biolucidaData['dataset_images'][0];
285
+ const resource = {
286
+ share_link: image.share_link,
287
+ id: image.image_id,
288
+ itemId: image.sourcepkg_id
289
+ }
290
+ let action = {
291
+ label: capitalise(this.label),
292
+ resource: resource,
293
+ dataset: this.dataLocation,
294
+ datasetId: this.discoverId,
295
+ title: "View image",
296
+ name: this.entry.name,
297
+ description: this.entry.description,
298
+ type: "Biolucida"
299
+ };
300
+ EventBus.$emit("PopoverActionClick", action);
301
+ }
302
+ }
303
+ },
304
+ propogateCardAction: function(action){
305
+ EventBus.$emit("PopoverActionClick", action)
306
+ if (action.contextCardUrl) {
307
+ this.$emit('contextUpdate', action)
308
+ }
309
+ },
310
+ getScaffoldPath: function(discoverId, version, scaffoldPath){
311
+ let id = discoverId
312
+ let path = `${this.envVars.API_LOCATION}s3-resource/${id}/${version}/files/${scaffoldPath}`
313
+ return path
314
+ },
315
+ getFileFromPath: function(discoverId, version, path){
316
+ return `${this.envVars.API_LOCATION}s3-resource/${discoverId}/${version}/files/${path}`
317
+ },
318
+ isOverflown: function(el){
319
+ return el.clientHeight < el.scrollHeight
320
+ },
321
+ expand: function() {
322
+ this.expanded = true
323
+ },
324
+ splitDOI: function(doi){
325
+ return [doi.split('/')[doi.split('/').length-2], doi.split('/')[doi.split('/').length-1]]
326
+ },
327
+ getBanner: function () {
328
+ let doi = this.splitDOI(this.entry.doi)
329
+ fetch(`${this.envVars.PENNSIEVE_API_LOCATION}/discover/datasets/doi/${doi[0]}/${doi[1]}`)
330
+ .then((response) =>{
331
+ if (!response.ok){
332
+ throw Error(response.statusText)
333
+ } else {
334
+ return response.json()
335
+ }
336
+ })
337
+ .then((data) => {
338
+ this.thumbnail = data.banner
339
+ this.discoverId = data.id
340
+ this.version = data.version
341
+ this.dataLocation = `https://sparc.science/datasets/${data.id}?type=dataset`
342
+ this.getBiolucidaInfo(this.discoverId)
343
+ this.dataIsReady = true
344
+ })
345
+ .catch(() => {
346
+ //set defaults if we hit an error
347
+ this.thumbnail = require('@/../assets/missing-image.svg')
348
+ this.discoverId = undefined
349
+ });
350
+ },
351
+ lastName: function(fullName){
352
+ return fullName.split(',')[0]
353
+ },
354
+ getBiolucidaInfo: function(id) {
355
+ let apiLocation = this.envVars.API_LOCATION;
356
+ let endpoint = apiLocation + "image_search/" + id;
357
+ // Add parameters if we are sent them
358
+ fetch(endpoint)
359
+ .then(response => response.json())
360
+ .then(data => {
361
+ if (data.status == "success")
362
+ this.biolucidaData = data;
363
+ });
364
+ }
365
+ },
366
+ created: function() {
367
+ this.getBanner()
368
+ },
369
+ mounted: function(){
370
+ this.cardOverflow = this.isOverflown(this.$refs.card)
371
+ },
372
+ };
373
+ </script>
374
+
375
+ <!-- Add "scoped" attribute to limit CSS to this component only -->
376
+ <style scoped>
377
+ .dataset-card {
378
+ padding-left: 16px;
379
+ position: relative;
380
+ }
381
+
382
+ .title {
383
+ padding-bottom: 5px;
384
+ font-family: Asap;
385
+ font-size: 14px;
386
+ font-weight: bold;
387
+ font-stretch: normal;
388
+ font-style: normal;
389
+ line-height: 1.5;
390
+ letter-spacing: 1.05px;
391
+ color: #484848;
392
+ cursor: pointer;
393
+ }
394
+ .card {
395
+ padding-top: 18px;
396
+ position: relative;
397
+ display: flex;
398
+ }
399
+
400
+ .card-left{
401
+ flex: 1
402
+ }
403
+
404
+ .card-right {
405
+ flex: 1.3;
406
+ padding-left: 6px;
407
+ }
408
+
409
+ .dataset-card .read-more {
410
+ position: absolute;
411
+ z-index: 9;
412
+ bottom: 0;
413
+ left: 0;
414
+ width: 100%;
415
+ height: 20px;
416
+ margin: 0; padding: 20px 66px;
417
+ /* "transparent" only works here because == rgba(0,0,0,0) */
418
+ background-image: linear-gradient(to bottom, transparent, white);
419
+ pointer-events: none;
420
+ }
421
+
422
+ .read-more-button{
423
+ width: 85px;
424
+ height: 20px;
425
+ font-family: Asap;
426
+ font-size: 14px;
427
+ font-weight: normal;
428
+ font-stretch: normal;
429
+ font-style: normal;
430
+ line-height: normal;
431
+ letter-spacing: normal;
432
+ color: #8300bf;
433
+ padding: 0px;
434
+ pointer-events: all;
435
+ cursor: pointer;
436
+ }
437
+
438
+ .button{
439
+ z-index: 10;
440
+ font-family: Asap;
441
+ font-size: 14px;
442
+ font-weight: normal;
443
+ font-stretch: normal;
444
+ font-style: normal;
445
+ line-height: normal;
446
+ letter-spacing: normal;
447
+ background-color: #8300bf;
448
+ border: #8300bf;
449
+ color: white;
450
+ cursor: pointer;
451
+ margin-top: 8px;
452
+ }
453
+
454
+ .button:hover {
455
+ background-color: #8300bf;
456
+ color: white;
457
+ }
458
+
459
+ .banner-img {
460
+ width: 128px;
461
+ height: 128px;
462
+ box-shadow: 0 2px 4px 0 rgba(0, 0, 0, 0.25);
463
+ background-color: #ffffff;
464
+ cursor: pointer;
465
+ }
466
+ .details{
467
+ font-family: Asap;
468
+ font-size: 14px;
469
+ font-weight: normal;
470
+ font-stretch: normal;
471
+ font-style: normal;
472
+ line-height: 1.5;
473
+ letter-spacing: 1.05px;
474
+ color: #484848;
475
+ }
476
+ </style>