@abi-software/map-side-bar 1.3.0 → 1.3.3

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,265 @@
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>
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" >
7
+ <div class="card-left">
8
+ <img :src="entry.banner" class="context-image">
9
+ </div>
10
+ <div class="card-right scrollbar">
11
+ <div class="title">{{contextData.heading}}</div>
12
+ <div v-html="contextData.description"/>
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
+ <div v-bind:key="i+'_1'" @click="openViewFile(view)" class="context-card-view">
17
+ <img class="view-image" :src="getFileFromPath(view.thumbnail)">
18
+ <div class="view-description">{{view.description}}</div>
19
+ </div>
20
+ <div v-bind:key="i" class="padding"/>
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 cursor-pointer" @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]" v-html="sample.description"/>
34
+ <a v-bind:key="i+'_5'" v-if="sampleDetails[i]" :href="generateFileLink(sample.path)" target="_blank">View Source</a>
35
+ <div v-bind:key="i+'_2'" class="padding"/>
36
+ </template>
37
+ </div>
38
+ </el-card>
39
+ </div>
40
+ </div>
41
+ </template>
42
+
43
+
44
+ <script>
45
+ /* eslint-disable no-alert, no-console */
46
+ import Vue from "vue";
47
+ import { Link, Icon, Card, Button, Select, Input } from "element-ui";
48
+ import lang from "element-ui/lib/locale/lang/en";
49
+ import locale from "element-ui/lib/locale";
50
+ import EventBus from "./EventBus"
51
+ import hardcoded_info from './hardcoded-context-info'
52
+
53
+ locale.use(lang);
54
+ Vue.use(Link);
55
+ Vue.use(Icon);
56
+ Vue.use(Card);
57
+ Vue.use(Button);
58
+ Vue.use(Select);
59
+ Vue.use(Input);
60
+
61
+
62
+ export default {
63
+ name: "contextCard",
64
+ props: {
65
+ /**
66
+ * Object containing information for
67
+ * the required viewing.
68
+ */
69
+ entry: Object,
70
+ },
71
+ data: function () {
72
+ return {
73
+ contextData: {},
74
+ showDetails: true,
75
+ showContextCard: true,
76
+ sampleDetails: {},
77
+ loading: false
78
+ };
79
+ },
80
+ watch: {
81
+ 'entry.contextCardUrl': {
82
+ handler(val){
83
+ if (val) {
84
+ // used for hardcoding data
85
+ if (val === true){
86
+ this.contextData = hardcoded_info[this.entry.discoverId]
87
+ } else {
88
+ this.getContextFile(val)
89
+ this.showContextCard = true
90
+ }
91
+ } else {
92
+ this.showContextCard = false
93
+ }
94
+ },
95
+ immediate: true
96
+ }
97
+ },
98
+ methods: {
99
+ getContextFile: function (contextFileUrl) {
100
+ this.loading = true
101
+ fetch(contextFileUrl)
102
+ .then((response) =>{
103
+ if (!response.ok){
104
+ throw Error(response.statusText)
105
+ } else {
106
+ return response.json()
107
+ }
108
+ })
109
+ .then((data) => {
110
+ this.contextData = data
111
+ console.log(data)
112
+ this.loading = false
113
+ })
114
+ .catch(() => {
115
+ //set defaults if we hit an error
116
+ this.thumbnail = require('@/../assets/missing-image.svg')
117
+ this.discoverId = undefined
118
+ this.loading = false
119
+ });
120
+ },
121
+ removeDoubleFilesPath: function(path){
122
+ if (path.includes('files/')){
123
+ return path.replace('files/', '')
124
+ } else 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
+ // note that we assume that the view file is in the same directory as the scaffold (viewUrls take relative paths)
151
+ this.entry.viewUrl = `${this.entry.apiLocation}s3-resource/${this.entry.discoverId}/${this.entry.version}/${view.path}`
152
+ this.entry.type = 'Scaffold View'
153
+ EventBus.$emit("PopoverActionClick", this.entry)
154
+ }
155
+ }
156
+ };
157
+ </script>
158
+
159
+ <!-- Add "scoped" attribute to limit CSS to this component only -->
160
+ <style scoped>
161
+
162
+ .hide{
163
+ color: #e4e7ed;
164
+ cursor: pointer;
165
+ }
166
+
167
+ .context-card{
168
+ background-color: white;
169
+ max-height: 10 50px;
170
+ padding: 8px;
171
+ font-size: 14px;
172
+ margin-bottom: 18px;
173
+ position: relative;
174
+ border: solid 1px #e4e7ed;
175
+ display: flex;
176
+ width: 500px;
177
+ max-height: 258px;
178
+ }
179
+
180
+ .context-card-view{
181
+ cursor: pointer;
182
+ padding-bottom: 8px;
183
+ display: flex;
184
+ }
185
+
186
+ .view-image {
187
+ width: 25px;
188
+ height: auto;
189
+ flex: 1;
190
+ }
191
+
192
+ .view-descriptions {
193
+ flex: 8;
194
+ }
195
+
196
+ .context-card >>> .el-card__body {
197
+ padding: 0px;
198
+ display: flex;
199
+ width: 516px;
200
+ }
201
+
202
+ .context-image{
203
+ width: 250px;
204
+ height: auto;
205
+ }
206
+
207
+ .color-box {
208
+ width: 16px;
209
+ height: 16px;
210
+ border: solid 1px #8300bf;
211
+ border-radius: 2px;
212
+ margin-right: 8px;
213
+ }
214
+
215
+ .card-left{
216
+ flex: 1
217
+ }
218
+
219
+ .card-right {
220
+ flex: 1.3;
221
+ padding-left: 6px;
222
+ overflow-y: scroll;
223
+ scrollbar-width: thin;
224
+ }
225
+
226
+ .cursor-pointer {
227
+ cursor: pointer;
228
+ }
229
+
230
+ .info{
231
+ transform: rotate(180deg);
232
+ color: #8300bf;
233
+ margin-left: 8px;
234
+ }
235
+
236
+ .padding {
237
+ padding-bottom: 8px;
238
+ }
239
+
240
+ .title{
241
+ font-weight: bold;
242
+ }
243
+
244
+ .subtitle{
245
+ font-weight: bold;
246
+ }
247
+
248
+ .scrollbar::-webkit-scrollbar-track {
249
+ border-radius: 10px;
250
+ background-color: #f5f5f5;
251
+ }
252
+
253
+ .scrollbar::-webkit-scrollbar {
254
+ width: 12px;
255
+ right: -12px;
256
+ background-color: #f5f5f5;
257
+ }
258
+
259
+ .scrollbar::-webkit-scrollbar-thumb {
260
+ border-radius: 4px;
261
+ box-shadow: 0 2px 4px 0 rgba(0, 0, 0, 0.06);
262
+ background-color: #979797;
263
+ }
264
+
265
+ </style>