@abi-software/map-side-bar 1.2.2 → 1.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.
@@ -1,240 +1,240 @@
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 card" >
7
- <div class="card-left">
8
- <img :src="entry.banner" class="context-image">
9
- </div>
10
- <div class="card-right">
11
- <div class="title">{{contextData.heading}}</div>
12
- <div>{{contextData.description}}</div>
13
- <br/>
14
- <div v-if="contextData.views" class="subtitle">Scaffold Views</div>
15
- <template v-for="(view, i) in contextData.views">
16
- <span v-bind:key="i+'_1'" @click="openViewFile(view)" class="context-card-item">
17
- <img class="key-image" :src="getFileFromPath(view.thumbnail)">
18
- {{view.description}}
19
- </span>
20
- <br v-bind:key="i"/>
21
- </template>
22
- <div style="margin-bottom: 16px;"/>
23
- <div v-if="contextData.samples && contextData.samples.length > 0" class="subtitle">Samples on Scaffold</div>
24
- <template v-for="(sample, i) in contextData.samples">
25
- <span v-bind:key="i+'_3'" class="context-card-item" @click="toggleSampleDetails(i)">
26
- <div v-bind:key="i+'_6'" style="display: flex">
27
- <div v-if="sample.color" class="color-box" :style="'background-color:'+ sample.color"></div>
28
- <img class="key-image" v-else-if="sample.thumbnail" :src="getFileFromPath(sample.thumbnail)">
29
- {{sample.heading}}
30
- <i class="el-icon-warning-outline info"></i>
31
- </div>
32
- </span>
33
- <div v-bind:key="i+'_4'" v-if="sampleDetails[i]">
34
- {{sample.description}}
35
- <a v-bind:key="i+'_5'" v-if="sampleDetails[i]" :href="generateFileLink(sample.path)" target="_blank">View Source</a>
36
- </div>
37
- <br v-bind:key="i+'_2'"/>
38
- </template>
39
- </div>
40
- </el-card>
41
- </div>
42
- </div>
43
- </template>
44
-
45
-
46
- <script>
47
- /* eslint-disable no-alert, no-console */
48
- import Vue from "vue";
49
- import { Link, Icon, Card, Button, Select, Input } from "element-ui";
50
- import lang from "element-ui/lib/locale/lang/en";
51
- import locale from "element-ui/lib/locale";
52
- import EventBus from "./EventBus"
53
- import hardcoded_info from './hardcoded-context-info'
54
-
55
- locale.use(lang);
56
- Vue.use(Link);
57
- Vue.use(Icon);
58
- Vue.use(Card);
59
- Vue.use(Button);
60
- Vue.use(Select);
61
- Vue.use(Input);
62
-
63
-
64
- export default {
65
- name: "contextCard",
66
- props: {
67
- /**
68
- * Object containing information for
69
- * the required viewing.
70
- */
71
- entry: Object,
72
- },
73
- data: function () {
74
- return {
75
- contextData: {},
76
- showDetails: true,
77
- showContextCard: true,
78
- sampleDetails: {},
79
- loading: false
80
- };
81
- },
82
- watch: {
83
- 'entry.contextCardUrl': {
84
- handler(val){
85
- if (val) {
86
- // used for hardcoding data
87
- if (val === true){
88
- this.contextData = hardcoded_info[this.entry.discoverId]
89
- } else {
90
- this.getContextFile(val)
91
- this.showContextCard = true
92
- }
93
- } else {
94
- this.showContextCard = false
95
- }
96
- },
97
- immediate: true
98
- }
99
- },
100
- methods: {
101
- getContextFile: function (contextFileUrl) {
102
- this.loading = true
103
- fetch(contextFileUrl)
104
- .then((response) =>{
105
- if (!response.ok){
106
- throw Error(response.statusText)
107
- } else {
108
- return response.json()
109
- }
110
- })
111
- .then((data) => {
112
- this.contextData = data
113
- console.log(data)
114
- this.loading = false
115
- })
116
- .catch(() => {
117
- //set defaults if we hit an error
118
- this.thumbnail = require('@/../assets/missing-image.svg')
119
- this.discoverId = undefined
120
- this.loading = false
121
- });
122
- },
123
- removeDoubleFilesPath: function(path){
124
- if (path.includes('files/')){
125
- return path.replace('files/', '')
126
- } else {
127
- return path
128
- }
129
- },
130
- toggleSampleDetails: function(i){
131
- if (this.sampleDetails[i] === undefined){
132
- Vue.set(this.sampleDetails, i, true)
133
- } else {
134
- Vue.set(this.sampleDetails, i, !this.sampleDetails[i])
135
- }
136
- },
137
- getFileFromPath: function(path){
138
- // for hardcoded data
139
- if(this.entry.contextCardUrl === true){
140
- return path
141
- }
142
- path = this.removeDoubleFilesPath(path)
143
- return `${this.entry.apiLocation}s3-resource/${this.entry.discoverId}/${this.entry.version}/files/${path}`
144
- },
145
- generateFileLink(path){
146
- return `https://sparc.science/file/${this.entry.discoverId}/${this.entry.version}?path=${encodeURI(path)}`
147
-
148
- },
149
- openViewFile: function(view){
150
-
151
- // note that we assume that the view file is in the same directory as the scaffold (viewUrls take relative paths)
152
- this.entry.viewUrl = view.path.split('/')[view.path.split('/').length-1]
153
- this.entry.type = 'Scaffold View'
154
- EventBus.$emit("PopoverActionClick", this.entry)
155
- }
156
- }
157
- };
158
- </script>
159
-
160
- <!-- Add "scoped" attribute to limit CSS to this component only -->
161
- <style scoped>
162
-
163
- .hide{
164
- color: #e4e7ed;
165
- cursor: pointer;
166
- }
167
-
168
- .context-card{
169
- background-color: white;
170
- max-height: 10 50px;
171
- padding: 8px;
172
- font-size: 14px;
173
- }
174
-
175
- .context-card-item{
176
- cursor: pointer;
177
- padding-bottom: 8px;
178
- }
179
-
180
- .key-image {
181
- width: 25px;
182
- height: auto;
183
- }
184
-
185
- .context-card >>> .el-card__body {
186
- padding: 0px;
187
- display: flex;
188
- width: 516px;
189
- }
190
-
191
- .context-image{
192
- width: 250px;
193
- height: auto;
194
- }
195
-
196
- .color-box {
197
- width: 16px;
198
- height: 16px;
199
- border: solid 1px #8300bf;
200
- border-radius: 2px;
201
- margin-right: 8px;
202
- }
203
-
204
- .card {
205
- margin-bottom: 18px;
206
- position: relative;
207
- border: solid 1px #e4e7ed;
208
- display: flex;
209
- width: 500px;
210
- max-height: 480px;
211
- }
212
-
213
- .card-left{
214
- flex: 1
215
- }
216
-
217
- .card-right {
218
- flex: 1.3;
219
- padding-left: 6px;
220
- }
221
-
222
- .cursor-pointer {
223
- cursor: pointer;
224
- height: 25px;
225
- }
226
-
227
- .info{
228
- transform: rotate(180deg);
229
- color: #8300bf;
230
- margin-left: 8px;
231
- }
232
-
233
- .title{
234
- font-weight: bold;
235
- }
236
-
237
- .subtitle{
238
- font-weight: bold;
239
- }
240
- </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 card" >
7
+ <div class="card-left">
8
+ <img :src="entry.banner" class="context-image">
9
+ </div>
10
+ <div class="card-right">
11
+ <div class="title">{{contextData.heading}}</div>
12
+ <div>{{contextData.description}}</div>
13
+ <br/>
14
+ <div v-if="contextData.views && contextData.views.length > 0" class="subtitle">Scaffold Views</div>
15
+ <template v-for="(view, i) in contextData.views">
16
+ <span v-bind:key="i+'_1'" @click="openViewFile(view)" class="context-card-item">
17
+ <img class="key-image" :src="getFileFromPath(view.thumbnail)">
18
+ {{view.description}}
19
+ </span>
20
+ <br v-bind:key="i"/>
21
+ </template>
22
+ <div style="margin-bottom: 16px;"/>
23
+ <div v-if="contextData.samples && contextData.samples.length > 0" class="subtitle">Samples on Scaffold</div>
24
+ <template v-for="(sample, i) in contextData.samples">
25
+ <span v-bind:key="i+'_3'" class="context-card-item" @click="toggleSampleDetails(i)">
26
+ <div v-bind:key="i+'_6'" style="display: flex">
27
+ <div v-if="sample.color" class="color-box" :style="'background-color:'+ sample.color"></div>
28
+ <img class="key-image" v-else-if="sample.thumbnail" :src="getFileFromPath(sample.thumbnail)">
29
+ {{sample.heading}}
30
+ <i class="el-icon-warning-outline info"></i>
31
+ </div>
32
+ </span>
33
+ <div v-bind:key="i+'_4'" v-if="sampleDetails[i]">
34
+ {{sample.description}}
35
+ <a v-bind:key="i+'_5'" v-if="sampleDetails[i]" :href="generateFileLink(sample.path)" target="_blank">View Source</a>
36
+ </div>
37
+ <br v-bind:key="i+'_2'"/>
38
+ </template>
39
+ </div>
40
+ </el-card>
41
+ </div>
42
+ </div>
43
+ </template>
44
+
45
+
46
+ <script>
47
+ /* eslint-disable no-alert, no-console */
48
+ import Vue from "vue";
49
+ import { Link, Icon, Card, Button, Select, Input } from "element-ui";
50
+ import lang from "element-ui/lib/locale/lang/en";
51
+ import locale from "element-ui/lib/locale";
52
+ import EventBus from "./EventBus"
53
+ import hardcoded_info from './hardcoded-context-info'
54
+
55
+ locale.use(lang);
56
+ Vue.use(Link);
57
+ Vue.use(Icon);
58
+ Vue.use(Card);
59
+ Vue.use(Button);
60
+ Vue.use(Select);
61
+ Vue.use(Input);
62
+
63
+
64
+ export default {
65
+ name: "contextCard",
66
+ props: {
67
+ /**
68
+ * Object containing information for
69
+ * the required viewing.
70
+ */
71
+ entry: Object,
72
+ },
73
+ data: function () {
74
+ return {
75
+ contextData: {},
76
+ showDetails: true,
77
+ showContextCard: true,
78
+ sampleDetails: {},
79
+ loading: false
80
+ };
81
+ },
82
+ watch: {
83
+ 'entry.contextCardUrl': {
84
+ handler(val){
85
+ if (val) {
86
+ // used for hardcoding data
87
+ if (val === true){
88
+ this.contextData = hardcoded_info[this.entry.discoverId]
89
+ } else {
90
+ this.getContextFile(val)
91
+ this.showContextCard = true
92
+ }
93
+ } else {
94
+ this.showContextCard = false
95
+ }
96
+ },
97
+ immediate: true
98
+ }
99
+ },
100
+ methods: {
101
+ getContextFile: function (contextFileUrl) {
102
+ this.loading = true
103
+ fetch(contextFileUrl)
104
+ .then((response) =>{
105
+ if (!response.ok){
106
+ throw Error(response.statusText)
107
+ } else {
108
+ return response.json()
109
+ }
110
+ })
111
+ .then((data) => {
112
+ this.contextData = data
113
+ console.log(data)
114
+ this.loading = false
115
+ })
116
+ .catch(() => {
117
+ //set defaults if we hit an error
118
+ this.thumbnail = require('@/../assets/missing-image.svg')
119
+ this.discoverId = undefined
120
+ this.loading = false
121
+ });
122
+ },
123
+ removeDoubleFilesPath: function(path){
124
+ if (path.includes('files/')){
125
+ return path.replace('files/', '')
126
+ } else {
127
+ return path
128
+ }
129
+ },
130
+ toggleSampleDetails: function(i){
131
+ if (this.sampleDetails[i] === undefined){
132
+ Vue.set(this.sampleDetails, i, true)
133
+ } else {
134
+ Vue.set(this.sampleDetails, i, !this.sampleDetails[i])
135
+ }
136
+ },
137
+ getFileFromPath: function(path){
138
+ // for hardcoded data
139
+ if(this.entry.contextCardUrl === true){
140
+ return path
141
+ }
142
+ path = this.removeDoubleFilesPath(path)
143
+ return `${this.entry.apiLocation}s3-resource/${this.entry.discoverId}/${this.entry.version}/files/${path}`
144
+ },
145
+ generateFileLink(path){
146
+ return `https://sparc.science/file/${this.entry.discoverId}/${this.entry.version}?path=${encodeURI(path)}`
147
+
148
+ },
149
+ openViewFile: function(view){
150
+
151
+ // note that we assume that the view file is in the same directory as the scaffold (viewUrls take relative paths)
152
+ this.entry.viewUrl = view.path.split('/')[view.path.split('/').length-1]
153
+ this.entry.type = 'Scaffold View'
154
+ EventBus.$emit("PopoverActionClick", this.entry)
155
+ }
156
+ }
157
+ };
158
+ </script>
159
+
160
+ <!-- Add "scoped" attribute to limit CSS to this component only -->
161
+ <style scoped>
162
+
163
+ .hide{
164
+ color: #e4e7ed;
165
+ cursor: pointer;
166
+ }
167
+
168
+ .context-card{
169
+ background-color: white;
170
+ max-height: 10 50px;
171
+ padding: 8px;
172
+ font-size: 14px;
173
+ }
174
+
175
+ .context-card-item{
176
+ cursor: pointer;
177
+ padding-bottom: 8px;
178
+ }
179
+
180
+ .key-image {
181
+ width: 25px;
182
+ height: auto;
183
+ }
184
+
185
+ .context-card >>> .el-card__body {
186
+ padding: 0px;
187
+ display: flex;
188
+ width: 516px;
189
+ }
190
+
191
+ .context-image{
192
+ width: 250px;
193
+ height: auto;
194
+ }
195
+
196
+ .color-box {
197
+ width: 16px;
198
+ height: 16px;
199
+ border: solid 1px #8300bf;
200
+ border-radius: 2px;
201
+ margin-right: 8px;
202
+ }
203
+
204
+ .card {
205
+ margin-bottom: 18px;
206
+ position: relative;
207
+ border: solid 1px #e4e7ed;
208
+ display: flex;
209
+ width: 500px;
210
+ max-height: 480px;
211
+ }
212
+
213
+ .card-left{
214
+ flex: 1
215
+ }
216
+
217
+ .card-right {
218
+ flex: 1.3;
219
+ padding-left: 6px;
220
+ }
221
+
222
+ .cursor-pointer {
223
+ cursor: pointer;
224
+ height: 25px;
225
+ }
226
+
227
+ .info{
228
+ transform: rotate(180deg);
229
+ color: #8300bf;
230
+ margin-left: 8px;
231
+ }
232
+
233
+ .title{
234
+ font-weight: bold;
235
+ }
236
+
237
+ .subtitle{
238
+ font-weight: bold;
239
+ }
240
+ </style>