@abi-software/gallery 0.3.0-beta.6 → 0.3.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.
- package/dist/gallery.common.js +409 -172
- package/dist/gallery.common.js.map +1 -1
- package/dist/gallery.css +1 -1
- package/dist/gallery.umd.js +409 -172
- package/dist/gallery.umd.js.map +1 -1
- package/dist/gallery.umd.min.js +1 -1
- package/dist/gallery.umd.min.js.map +1 -1
- package/dist/img/logo-sparc-wave-primary.8ed83a51.svg +1 -0
- package/package.json +1 -1
- package/src/components/Card.vue +22 -30
- package/src/components/Gallery.vue +0 -21
- package/src/mixins/GalleryHelpers.js +37 -44
|
@@ -0,0 +1 @@
|
|
|
1
|
+
<svg id="logo-sparc-wave-primary" data-name="logo-sparc-wave-primary" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" viewBox="0 0 400 190.5854"><defs><linearGradient id="linear-gradient" y1="96.3505" x2="400" y2="96.3505" gradientUnits="userSpaceOnUse"><stop offset="0" stop-color="#0b00bf"/><stop offset="1" stop-color="#bc00fc"/></linearGradient></defs><title>SPARC Logo</title><path d="M396.6976,128.6248l-146.2735-3.38a6.5358,6.5358,0,0,0-6.1378,3.9236l-.0612.1407-13.673,31.4482L202.9416,9.5333l-.01-.0685a8.9823,8.9823,0,0,0-17.6624-.0114L163.673,125.3819,3.298,129.2886a3.38,3.38,0,0,0,.0269,6.7592L169.34,138.7635a6.5939,6.5939,0,0,0,6.5373-5.1457l.0571-.2546,17.8534-79.5649L221.26,185.1237l.0256.1243A6.7593,6.7593,0,0,0,234.092,186.52L254.9005,138.66l141.7971-3.2762a3.3805,3.3805,0,0,0,0-6.7592Z" style="fill:url(#linear-gradient)"/><path d="M25.6793,0C41.3957,0,51.057,10.0926,51.057,26.0972v9.5162H36.2053V26.0972c0-7.3532-3.8945-11.8219-10.526-11.8219-6.7768,0-10.6691,4.4687-10.6691,11.8219,0,3.8945,1.2982,7.3533,5.4786,11.3908l19.754,18.601C46.5861,62.1441,52.21,68.7778,52.21,79.88c0,16.0047-9.95,26.0973-25.9543,26.0973C10.108,105.9776.1585,95.885.1585,79.88V70.362H15.01V79.88c0,7.3533,4.0375,11.822,11.2455,11.822,7.065,0,11.1025-4.4687,11.1025-11.822,0-4.4709-2.1628-8.6514-6.0551-12.2576L11.1158,48.7357C3.043,41.2372.1585,34.8939.1585,25.666.1585,10.0926,9.82,0,25.6793,0Z" style="fill:#0e0e19"/><path d="M99.7971,69.7856v35.1821H84.9454V1.01h25.3755c16.0047,0,26.0973,10.0926,26.0973,26.0973V43.6883c0,16.15-10.0926,26.0973-26.0973,26.0973Zm10.3808-13.9849c7.2081,0,11.3908-4.3257,11.3908-11.6789V26.6759c0-7.21-4.1827-11.6811-11.3908-11.6811H99.7971V55.8007Z" style="fill:#0e0e19"/><path d="M278.5812,108.147H263.73V4.1893h26.0972c16.0047,0,26.0973,10.0926,26.0973,26.0972v14.13c0,9.95-4.3257,17.7363-11.3908,22.205,4.1827,12.6889,10.0926,29.9917,13.8418,41.5254h-15.14L290.6914,70.3708h-12.11Zm11.1-51.7632c7.21,0,11.3907-4.3257,11.3907-11.5338V29.8553c0-7.21-4.18-11.6812-11.3907-11.6812h-11.1v38.21Z" style="fill:#0e0e19"/><path d="M399.844,73.5414V83.06c0,16.0047-9.9474,26.0973-25.9521,26.0973-16.15,0-26.0972-10.0926-26.0972-26.0973V29.2766c0-16.0046,9.9473-26.0972,26.0972-26.0972,16.0047,0,25.9521,10.0926,25.9521,26.0972v9.5161h-14.85V29.2766c0-7.3532-4.0374-11.822-11.1025-11.822-7.21,0-11.2477,4.4688-11.2477,11.822V83.06c0,7.3533,4.0375,11.822,11.2477,11.822,7.0651,0,11.1025-4.4687,11.1025-11.822V73.5414Z" style="fill:#0e0e19"/></svg>
|
package/package.json
CHANGED
package/src/components/Card.vue
CHANGED
|
@@ -36,9 +36,9 @@
|
|
|
36
36
|
|
|
37
37
|
<script>
|
|
38
38
|
// import { SvgIcon } from '@abi-software/svg-sprite'
|
|
39
|
-
import axios from 'axios'
|
|
40
39
|
import Vue from 'vue'
|
|
41
40
|
import { Button, Card, Popover } from 'element-ui'
|
|
41
|
+
import GalleryHelper from '../mixins/GalleryHelpers'
|
|
42
42
|
Vue.use(Button)
|
|
43
43
|
Vue.use(Card)
|
|
44
44
|
Vue.use(Popover)
|
|
@@ -54,17 +54,9 @@ function isValidHttpUrl(string) {
|
|
|
54
54
|
return url.protocol === 'http:' || url.protocol === 'https:'
|
|
55
55
|
}
|
|
56
56
|
|
|
57
|
-
const getRequest = async (url, params, timeout) => {
|
|
58
|
-
return await axios({
|
|
59
|
-
method: 'get',
|
|
60
|
-
url,
|
|
61
|
-
params,
|
|
62
|
-
timeout,
|
|
63
|
-
})
|
|
64
|
-
}
|
|
65
|
-
|
|
66
57
|
export default {
|
|
67
58
|
name: 'GalleryCard',
|
|
59
|
+
mixins: [GalleryHelper],
|
|
68
60
|
props: {
|
|
69
61
|
data: {
|
|
70
62
|
type: Object,
|
|
@@ -132,6 +124,25 @@ export default {
|
|
|
132
124
|
return undefined
|
|
133
125
|
},
|
|
134
126
|
},
|
|
127
|
+
watch: {
|
|
128
|
+
data: {
|
|
129
|
+
deep: true,
|
|
130
|
+
immediate: true,
|
|
131
|
+
handler: function () {
|
|
132
|
+
this.thumbnail = undefined
|
|
133
|
+
this.useDefaultImg = false
|
|
134
|
+
if (this.data.thumbnail) {
|
|
135
|
+
if (isValidHttpUrl(this.data.thumbnail) && this.data.mimetype) {
|
|
136
|
+
this.downloadThumbnail(this.data.thumbnail, { fetchAttempts: 0 })
|
|
137
|
+
} else {
|
|
138
|
+
this.thumbnail = this.data.thumbnail
|
|
139
|
+
}
|
|
140
|
+
} else {
|
|
141
|
+
this.useDefaultImg = true
|
|
142
|
+
}
|
|
143
|
+
},
|
|
144
|
+
},
|
|
145
|
+
},
|
|
135
146
|
methods: {
|
|
136
147
|
/**
|
|
137
148
|
* Open a new link if link is provide.
|
|
@@ -154,7 +165,7 @@ export default {
|
|
|
154
165
|
* handle thumbnail downloading,, it will use a default svg image if fails
|
|
155
166
|
*/
|
|
156
167
|
downloadThumbnail: function (url, info) {
|
|
157
|
-
getRequest(url, {}, 11000).then(
|
|
168
|
+
this.getRequest(url, {}, 11000).then(
|
|
158
169
|
(response) => {
|
|
159
170
|
let data = response.data
|
|
160
171
|
if (data.startsWith('data:')) {
|
|
@@ -178,25 +189,6 @@ export default {
|
|
|
178
189
|
)
|
|
179
190
|
},
|
|
180
191
|
},
|
|
181
|
-
watch: {
|
|
182
|
-
data: {
|
|
183
|
-
deep: true,
|
|
184
|
-
immediate: true,
|
|
185
|
-
handler: function () {
|
|
186
|
-
this.thumbnail = undefined
|
|
187
|
-
this.useDefaultImg = false
|
|
188
|
-
if (this.data.thumbnail) {
|
|
189
|
-
if (isValidHttpUrl(this.data.thumbnail) && this.data.mimetype) {
|
|
190
|
-
this.downloadThumbnail(this.data.thumbnail, { fetchAttempts: 0 })
|
|
191
|
-
} else {
|
|
192
|
-
this.thumbnail = this.data.thumbnail
|
|
193
|
-
}
|
|
194
|
-
} else {
|
|
195
|
-
this.useDefaultImg = true
|
|
196
|
-
}
|
|
197
|
-
},
|
|
198
|
-
},
|
|
199
|
-
},
|
|
200
192
|
}
|
|
201
193
|
</script>
|
|
202
194
|
|
|
@@ -194,27 +194,6 @@ export default {
|
|
|
194
194
|
}
|
|
195
195
|
},
|
|
196
196
|
},
|
|
197
|
-
watch: {
|
|
198
|
-
currentIndex: {
|
|
199
|
-
handler: function () {
|
|
200
|
-
const oddImagesVisible = this.numberOfItemsVisible % 2 === 1
|
|
201
|
-
let halfVisible = this.numberOfItemsVisible / 2
|
|
202
|
-
if (oddImagesVisible) {
|
|
203
|
-
halfVisible = (this.numberOfItemsVisible - 1) / 2
|
|
204
|
-
}
|
|
205
|
-
let rawIndicies = [this.currentIndex]
|
|
206
|
-
for (let i = 1; i <= halfVisible; i++) {
|
|
207
|
-
rawIndicies.push(this.currentIndex + i)
|
|
208
|
-
rawIndicies.push(this.currentIndex - i)
|
|
209
|
-
}
|
|
210
|
-
|
|
211
|
-
if (!oddImagesVisible) {
|
|
212
|
-
rawIndicies.pop()
|
|
213
|
-
}
|
|
214
|
-
},
|
|
215
|
-
immediate: true,
|
|
216
|
-
},
|
|
217
|
-
},
|
|
218
197
|
}
|
|
219
198
|
</script>
|
|
220
199
|
|
|
@@ -1,14 +1,5 @@
|
|
|
1
1
|
import axios from 'axios'
|
|
2
2
|
|
|
3
|
-
const getRequest = async (url, params, timeout) => {
|
|
4
|
-
return await axios({
|
|
5
|
-
method: "get",
|
|
6
|
-
url,
|
|
7
|
-
params,
|
|
8
|
-
timeout
|
|
9
|
-
})
|
|
10
|
-
}
|
|
11
|
-
|
|
12
3
|
export default {
|
|
13
4
|
//this mixin is not used by this code base but it can be used by other
|
|
14
5
|
//projects to get a handle to various resources
|
|
@@ -18,6 +9,14 @@ export default {
|
|
|
18
9
|
}
|
|
19
10
|
},
|
|
20
11
|
methods: {
|
|
12
|
+
async getRequest(url, params, timeout) {
|
|
13
|
+
return await axios({
|
|
14
|
+
method: 'get',
|
|
15
|
+
url,
|
|
16
|
+
params,
|
|
17
|
+
timeout,
|
|
18
|
+
})
|
|
19
|
+
},
|
|
21
20
|
/**
|
|
22
21
|
* Returns a file path for S3.
|
|
23
22
|
* @param {String} dataset_id dataset id.
|
|
@@ -35,29 +34,28 @@ export default {
|
|
|
35
34
|
findEntryWithPathInArray(array, path) {
|
|
36
35
|
if (path && array) {
|
|
37
36
|
for (let i = 0; i < array.length; i++) {
|
|
38
|
-
if (path === array[i].dataset.path)
|
|
39
|
-
return array[i];
|
|
37
|
+
if (path === array[i].dataset.path) return array[i]
|
|
40
38
|
}
|
|
41
39
|
}
|
|
42
|
-
return undefined
|
|
40
|
+
return undefined
|
|
43
41
|
},
|
|
44
42
|
getThumbnailForPlot(plot, thumbnails) {
|
|
45
43
|
if (thumbnails && plot) {
|
|
46
|
-
return this.findEntryWithPathInArray(thumbnails, plot.datacite.isSourceOf.path[0])
|
|
44
|
+
return this.findEntryWithPathInArray(thumbnails, plot.datacite.isSourceOf.path[0])
|
|
47
45
|
}
|
|
48
|
-
return undefined
|
|
46
|
+
return undefined
|
|
49
47
|
},
|
|
50
48
|
/**
|
|
51
49
|
* Use the scaffoldViews to help with finding the correct thumbnails.
|
|
52
50
|
* Use the index if the workflow stated above fails.
|
|
53
51
|
*/
|
|
54
52
|
getThumbnailForScaffold(scaffold, scaffoldViews, thumbnails, index) {
|
|
55
|
-
if (thumbnails &&
|
|
56
|
-
let thumbnail = undefined
|
|
53
|
+
if (thumbnails && thumbnails.length > 0) {
|
|
54
|
+
let thumbnail = undefined
|
|
57
55
|
if (scaffold && scaffoldViews) {
|
|
58
56
|
const view = this.findEntryWithPathInArray(scaffoldViews, scaffold.datacite.isSourceOf.path[0])
|
|
59
57
|
if (view) {
|
|
60
|
-
thumbnail = this.findEntryWithPathInArray(thumbnails, view.datacite.isSourceOf.path[0])
|
|
58
|
+
thumbnail = this.findEntryWithPathInArray(thumbnails, view.datacite.isSourceOf.path[0])
|
|
61
59
|
}
|
|
62
60
|
}
|
|
63
61
|
if (thumbnail) {
|
|
@@ -66,7 +64,7 @@ export default {
|
|
|
66
64
|
return thumbnails[index]
|
|
67
65
|
}
|
|
68
66
|
}
|
|
69
|
-
return undefined
|
|
67
|
+
return undefined
|
|
70
68
|
},
|
|
71
69
|
getImageURLFromS3(apiEndpoint, info) {
|
|
72
70
|
return `${apiEndpoint}/s3-resource/${info.datasetId}/${info.datasetVersion}/files/${info.file_path}?encodeBase64=true`
|
|
@@ -79,33 +77,28 @@ export default {
|
|
|
79
77
|
return endpoint
|
|
80
78
|
},
|
|
81
79
|
getThumbnailURLFromBiolucida(apiEndpoint, info) {
|
|
82
|
-
return`${apiEndpoint}/thumbnail/${info.id}`
|
|
80
|
+
return `${apiEndpoint}/thumbnail/${info.id}`
|
|
83
81
|
},
|
|
84
82
|
getImageInfoFromBiolucida(apiEndpoint, items, info) {
|
|
85
83
|
const endpoint = `${apiEndpoint}/image/${info.id}`
|
|
86
|
-
const params = {
|
|
87
|
-
getRequest(endpoint, params, 20000)
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
item.title = name
|
|
94
|
-
}
|
|
95
|
-
},
|
|
96
|
-
reason => {
|
|
97
|
-
if (
|
|
98
|
-
reason.message.includes('timeout') &&
|
|
99
|
-
reason.message.includes('exceeded') &&
|
|
100
|
-
info.fetchAttempts < 3
|
|
101
|
-
) {
|
|
102
|
-
info.fetchAttempts += 1
|
|
103
|
-
this.getImageInfoFromBiolucida(apiEndpoint, items, info)
|
|
104
|
-
}
|
|
105
|
-
|
|
106
|
-
return Promise.reject('Maximum iterations reached.')
|
|
84
|
+
const params = {}
|
|
85
|
+
this.getRequest(endpoint, params, 20000).then(
|
|
86
|
+
(response) => {
|
|
87
|
+
let item = items.find((x) => x.id === info.id)
|
|
88
|
+
const name = response.name
|
|
89
|
+
if (name) {
|
|
90
|
+
item.title = name
|
|
107
91
|
}
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
92
|
+
},
|
|
93
|
+
(reason) => {
|
|
94
|
+
if (reason.message.includes('timeout') && reason.message.includes('exceeded') && info.fetchAttempts < 3) {
|
|
95
|
+
info.fetchAttempts += 1
|
|
96
|
+
this.getImageInfoFromBiolucida(apiEndpoint, items, info)
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
return Promise.reject('Maximum iterations reached.')
|
|
100
|
+
}
|
|
101
|
+
)
|
|
102
|
+
},
|
|
103
|
+
},
|
|
104
|
+
}
|