@abi-software/gallery 0.3.0-beta.5 → 0.3.1

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.
@@ -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
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@abi-software/gallery",
3
- "version": "0.3.0-beta.5",
3
+ "version": "0.3.1",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "https://github.com/hsorby/mapcore-gallery.git"
@@ -19,6 +19,7 @@
19
19
  "@babel/code-frame": "^7.12.11",
20
20
  "axios": "^0.26.1",
21
21
  "babel-plugin-component": "^1.1.1",
22
+ "base64-inline-loader": "^2.0.1",
22
23
  "core-js": "^3.8.3",
23
24
  "element-ui": "^2.15.0",
24
25
  "vue": "^2.6.11"
@@ -24,10 +24,19 @@
24
24
  <p v-if="!data.hideType">
25
25
  <b>{{ data.type }}</b>
26
26
  </p>
27
- <el-popover ref="galleryPopover" :content="data.title" placement="top" trigger="hover" popper-class="gallery-popper" />
28
- <p v-if="!data.hideTitle" class="title" v-popover:galleryPopover>
27
+ <el-popover
28
+ ref="galleryPopover"
29
+ :disabled="disableTooltip"
30
+ :content="data.title"
31
+ placement="top"
32
+ trigger="hover"
33
+ popper-class="gallery-popper"
34
+ />
35
+ <!--use v-show here to make sure el popover always have a starting location -->
36
+ <p v-show="!data.hideTitle" ref="titleText" class="title" v-popover:galleryPopover>
29
37
  {{ data.title }}
30
38
  </p>
39
+ <p v-show="data.hideTitle" class="title text-placeholder" />
31
40
  <el-button class="button" @click.prevent="cardClicked"> View {{ data.type }}</el-button>
32
41
  </div>
33
42
  </div>
@@ -36,9 +45,9 @@
36
45
 
37
46
  <script>
38
47
  // import { SvgIcon } from '@abi-software/svg-sprite'
39
- import axios from 'axios'
40
48
  import Vue from 'vue'
41
49
  import { Button, Card, Popover } from 'element-ui'
50
+ import GalleryHelper from '../mixins/GalleryHelpers'
42
51
  Vue.use(Button)
43
52
  Vue.use(Card)
44
53
  Vue.use(Popover)
@@ -54,17 +63,9 @@ function isValidHttpUrl(string) {
54
63
  return url.protocol === 'http:' || url.protocol === 'https:'
55
64
  }
56
65
 
57
- const getRequest = async (url, params, timeout) => {
58
- return await axios({
59
- method: 'get',
60
- url,
61
- params,
62
- timeout,
63
- })
64
- }
65
-
66
66
  export default {
67
67
  name: 'GalleryCard',
68
+ mixins: [GalleryHelper],
68
69
  props: {
69
70
  data: {
70
71
  type: Object,
@@ -110,6 +111,8 @@ export default {
110
111
  triangleSize: 4,
111
112
  thumbnail: undefined,
112
113
  useDefaultImg: false,
114
+ disableTooltip: false,
115
+ tooltipCalculated: false,
113
116
  }
114
117
  },
115
118
  computed: {
@@ -132,6 +135,31 @@ export default {
132
135
  return undefined
133
136
  },
134
137
  },
138
+ watch: {
139
+ data: {
140
+ deep: true,
141
+ immediate: true,
142
+ handler: function () {
143
+ this.thumbnail = undefined
144
+ this.useDefaultImg = false
145
+ this.tooltipCalculated = false
146
+ this.disableTooltip = false
147
+ if (this.data.thumbnail) {
148
+ if (isValidHttpUrl(this.data.thumbnail) && this.data.mimetype) {
149
+ this.downloadThumbnail(this.data.thumbnail, { fetchAttempts: 0 })
150
+ } else {
151
+ this.thumbnail = this.data.thumbnail
152
+ }
153
+ } else {
154
+ this.useDefaultImg = true
155
+ }
156
+ //Dynamically check title length to determine if popover should be shown
157
+ this.$nextTick(() => {
158
+ this.calculateShowTooltip()
159
+ })
160
+ },
161
+ },
162
+ },
135
163
  methods: {
136
164
  /**
137
165
  * Open a new link if link is provide.
@@ -154,7 +182,7 @@ export default {
154
182
  * handle thumbnail downloading,, it will use a default svg image if fails
155
183
  */
156
184
  downloadThumbnail: function (url, info) {
157
- getRequest(url, {}, 11000).then(
185
+ this.getRequest(url, {}, 11000).then(
158
186
  (response) => {
159
187
  let data = response.data
160
188
  if (data.startsWith('data:')) {
@@ -177,26 +205,33 @@ export default {
177
205
  }
178
206
  )
179
207
  },
180
- },
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
- }
208
+ //dynamically calculate if tooltip is required
209
+ calculateShowTooltip: function () {
210
+ if (this.data.hideTitle) {
211
+ this.disableTooltip = true
212
+ this.tooltipCalculated = true
213
+ } else {
214
+ const ele = this.$refs.titleText
215
+ //Check if title text is rendered yet
216
+ if (ele && ele.offsetParent) {
217
+ this.tooltipCalculated = true
218
+ if (ele.offsetWidth >= ele.scrollWidth) this.disableTooltip = true
219
+ else this.disableTooltip = false
194
220
  } else {
195
- this.useDefaultImg = true
221
+ //text not rendered yet
222
+ if (this.data.title.length > 20) this.disableTooltip = false
223
+ else this.disableTooltip = true
196
224
  }
197
- },
225
+ }
198
226
  },
199
227
  },
228
+ updated: function () {
229
+ if (!this.tooltipCalculated) {
230
+ this.$nextTick(() => {
231
+ this.calculateShowTooltip()
232
+ })
233
+ }
234
+ },
200
235
  }
201
236
  </script>
202
237
 
@@ -232,6 +267,10 @@ export default {
232
267
  text-align: left;
233
268
  }
234
269
 
270
+ .text-placeholder {
271
+ height: 1rem;
272
+ }
273
+
235
274
  .title {
236
275
  overflow-x: hidden;
237
276
  text-overflow: ellipsis;
@@ -9,6 +9,7 @@
9
9
  <div class="card-line">
10
10
  <span v-for="(item, index) in windowedItems" :key="'card_' + index" :class="['key-image-span', { active: isActive(index) }]">
11
11
  <card
12
+ v-if="item"
12
13
  :data="item"
13
14
  :body-style="bodyStyle"
14
15
  :image-container-style="imageContainerStyle"
@@ -27,7 +28,7 @@
27
28
  </a>
28
29
  <div v-else style="width: 2rem" />
29
30
  </div>
30
- <div v-if="canShowIndicatorBar" :style="bottomSpacer" />
31
+ <div :style="bottomSpacer" />
31
32
  <index-indicator v-if="canShowIndicatorBar" :count="itemCount" :current="currentIndex" @clicked="indicatorClicked" />
32
33
  </div>
33
34
  </template>
@@ -194,27 +195,6 @@ export default {
194
195
  }
195
196
  },
196
197
  },
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
198
  }
219
199
  </script>
220
200
 
@@ -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 && (thumbnails.length > 0)) {
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
- .then(
89
- response => {
90
- let item = items.find(x => x.id === info.id)
91
- const name = response.name
92
- if (name) {
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
+ }
package/vue.config.js CHANGED
@@ -7,5 +7,17 @@ module.exports = {
7
7
  .use('vue-svg-inline-loader')
8
8
  .loader('vue-svg-inline-loader')
9
9
  .end()
10
- },
10
+ const fontsRule = config.module.rule('fonts')
11
+ fontsRule.uses.clear()
12
+ config.module
13
+ .rule('fonts')
14
+ .test(/\.(ttf|otf|eot|woff|woff2)$/)
15
+ .use('base64-inline-loader')
16
+ .loader('base64-inline-loader')
17
+ .tap(options => {
18
+ // modify the options...
19
+ return options
20
+ })
21
+ .end()
22
+ }
11
23
  }