@abi-software/gallery 0.2.2 → 0.3.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.
@@ -0,0 +1,102 @@
1
+ import axios from 'axios'
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
+ export default {
13
+ data() {
14
+ return {
15
+ defaultImg: require('../assets/logo-sparc-wave-primary.svg'),
16
+ }
17
+ },
18
+ methods: {
19
+ /**
20
+ * Returns a file path for S3.
21
+ * @param {String} dataset_id dataset id.
22
+ * @param {String} dataset_version dataset version.
23
+ * @param {String} file_path file path.
24
+ * @returns {String} full path to S3 file.
25
+ */
26
+ getS3FilePath(dataset_id, dataset_version, file_path) {
27
+ const encoded_file_path = encodeURIComponent(file_path)
28
+ return `${dataset_id}/${dataset_version}/files/${encoded_file_path}`
29
+ },
30
+ findEntryWithPathInArray(array, path) {
31
+ if (path && array) {
32
+ for (let i = 0; i < array.length; i++) {
33
+ if (path === array[i].dataset.path)
34
+ return array[i];
35
+ }
36
+ }
37
+ return undefined;
38
+ },
39
+ getThumbnailForPlot(plot, thumbnails) {
40
+ if (thumbnails && plot) {
41
+ return this.findEntryWithPathInArray(thumbnails, plot.datacite.isSourceOf.path[0]);
42
+ }
43
+ return undefined;
44
+ },
45
+ getThumbnailForScaffold(scaffold, scaffoldViews, thumbnails, index) {
46
+ if (thumbnails && (thumbnails.length > 0)) {
47
+ let thumbnail = undefined;
48
+ if (scaffold && scaffoldViews) {
49
+ const view = this.findEntryWithPathInArray(scaffoldViews, scaffold.datacite.isSourceOf.path[0])
50
+ if (view) {
51
+ thumbnail = this.findEntryWithPathInArray(thumbnails, view.datacite.isSourceOf.path[0]);
52
+ }
53
+ }
54
+ if (thumbnail) {
55
+ return thumbnail
56
+ } else if (index < thumbnails.length) {
57
+ return thumbnails[index]
58
+ }
59
+ }
60
+ return undefined;
61
+ },
62
+ getImageURLFromS3(apiEndpoint, info) {
63
+ return `${apiEndpoint}/s3-resource/${info.datasetId}/${info.datasetVersion}/files/${info.file_path}?encodeBase64=true`
64
+ },
65
+ getSegmentationThumbnailURL(apiEndpoint, info) {
66
+ let endpoint = `${apiEndpoint}/thumbnail/neurolucida`
67
+ endpoint = endpoint + `?datasetId=${info.datasetId}`
68
+ endpoint = endpoint + `&version=${info.datasetVersion}`
69
+ endpoint = endpoint + `&path=files/${info.segmentationFilePath}`
70
+ return endpoint
71
+ },
72
+ getThumbnailURLFromBiolucida(apiEndpoint, info) {
73
+ return`${apiEndpoint}/thumbnail/${info.id}`
74
+ },
75
+ getImageInfoFromBiolucida(apiEndpoint, items, info) {
76
+ const endpoint = `${apiEndpoint}/image/${info.id}`
77
+ const params = { }
78
+ getRequest(endpoint, params, 20000)
79
+ .then(
80
+ response => {
81
+ let item = items.find(x => x.id === info.id)
82
+ const name = response.name
83
+ if (name) {
84
+ item.title = name
85
+ }
86
+ },
87
+ reason => {
88
+ if (
89
+ reason.message.includes('timeout') &&
90
+ reason.message.includes('exceeded') &&
91
+ info.fetchAttempts < 3
92
+ ) {
93
+ info.fetchAttempts += 1
94
+ this.getImageInfoFromBiolucida(apiEndpoint, items, info)
95
+ }
96
+
97
+ return Promise.reject('Maximum iterations reached.')
98
+ }
99
+ )
100
+ }
101
+ }
102
+ };
@@ -1,12 +1,12 @@
1
- import { shallowMount } from '@vue/test-utils'
2
- import HelloWorld from '@/components/HelloWorld.vue'
3
-
4
- describe('HelloWorld.vue', () => {
5
- it('renders props.msg when passed', () => {
6
- const msg = 'new message'
7
- const wrapper = shallowMount(HelloWorld, {
8
- propsData: { msg },
9
- })
10
- expect(wrapper.text()).toMatch(msg)
11
- })
12
- })
1
+ import { shallowMount } from '@vue/test-utils'
2
+ import HelloWorld from '@/components/HelloWorld.vue'
3
+
4
+ describe('HelloWorld.vue', () => {
5
+ it('renders props.msg when passed', () => {
6
+ const msg = 'new message'
7
+ const wrapper = shallowMount(HelloWorld, {
8
+ propsData: { msg },
9
+ })
10
+ expect(wrapper.text()).toMatch(msg)
11
+ })
12
+ })
package/vue.config.js CHANGED
@@ -1,4 +1,12 @@
1
- // vue.config.js
2
- module.exports = {
3
- css: { extract: false },
4
- }
1
+ // vue.config.js
2
+ module.exports = {
3
+ chainWebpack: config => {
4
+ // GraphQL Loader
5
+ config.module
6
+ .rule('vue')
7
+ .use('vue-svg-inline-loader')
8
+ .loader('vue-svg-inline-loader')
9
+ .end()
10
+ },
11
+ css: { extract: false },
12
+ }
package/Meeting-plan.txt DELETED
@@ -1,4 +0,0 @@
1
- Meeting notes
2
-
3
- - Examples of metadata are most critical for arranging layouts
4
-
package/src/delete.json DELETED
@@ -1,39 +0,0 @@
1
- {
2
- "size": 20,
3
- "from": 0,
4
- "query": {
5
- "bool": {
6
- "must": [ {
7
- "match_phrase": {
8
- "existing_ids.curie": {
9
- "query": "UBERON:0000948"
10
- }
11
- }
12
- } ]
13
- }
14
- }
15
- }
16
-
17
- {
18
- "size": 20,
19
- "from": 0,
20
- "query": {
21
- "bool": {
22
- "must": [ {
23
- "match_phrase": {
24
- "label.aggregate": {
25
- "query": "heart"
26
- }
27
- }
28
- },
29
- {
30
- "term": {
31
- "type": {
32
- "value": "term"
33
- }
34
- }
35
- } ]
36
- }
37
- },
38
- "_source": ["label","existing_ids.curie"]
39
- }
@@ -1,2 +0,0 @@
1
- import Gallery from './components/Gallery.vue'
2
- export default Gallery