@abi-software/map-side-bar 1.3.1 → 1.3.4

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,241 +1,264 @@
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 if (path.includes('files\\')) {
127
- return path.replace('files\\', '')
128
- } else {
129
- return path
130
- }
131
- },
132
- toggleSampleDetails: function(i){
133
- if (this.sampleDetails[i] === undefined){
134
- Vue.set(this.sampleDetails, i, true)
135
- } else {
136
- Vue.set(this.sampleDetails, i, !this.sampleDetails[i])
137
- }
138
- },
139
- getFileFromPath: function(path){
140
- // for hardcoded data
141
- if(this.entry.contextCardUrl === true){
142
- return path
143
- }
144
- path = this.removeDoubleFilesPath(path)
145
- return `${this.entry.apiLocation}s3-resource/${this.entry.discoverId}/${this.entry.version}/files/${path}`
146
- },
147
- generateFileLink(path){
148
- return `https://sparc.science/file/${this.entry.discoverId}/${this.entry.version}?path=${encodeURI(path)}`
149
-
150
- },
151
- openViewFile: function(view){
152
- // note that we assume that the view file is in the same directory as the scaffold (viewUrls take relative paths)
153
- this.entry.viewUrl = `${this.entry.apiLocation}s3-resource/${this.entry.discoverId}/${this.entry.version}/${view.path}`
154
- this.entry.type = 'Scaffold View'
155
- EventBus.$emit("PopoverActionClick", this.entry)
156
- }
157
- }
158
- };
159
- </script>
160
-
161
- <!-- Add "scoped" attribute to limit CSS to this component only -->
162
- <style scoped>
163
-
164
- .hide{
165
- color: #e4e7ed;
166
- cursor: pointer;
167
- }
168
-
169
- .context-card{
170
- background-color: white;
171
- max-height: 10 50px;
172
- padding: 8px;
173
- font-size: 14px;
174
- }
175
-
176
- .context-card-item{
177
- cursor: pointer;
178
- padding-bottom: 8px;
179
- }
180
-
181
- .key-image {
182
- width: 25px;
183
- height: auto;
184
- }
185
-
186
- .context-card >>> .el-card__body {
187
- padding: 0px;
188
- display: flex;
189
- width: 516px;
190
- }
191
-
192
- .context-image{
193
- width: 250px;
194
- height: auto;
195
- }
196
-
197
- .color-box {
198
- width: 16px;
199
- height: 16px;
200
- border: solid 1px #8300bf;
201
- border-radius: 2px;
202
- margin-right: 8px;
203
- }
204
-
205
- .card {
206
- margin-bottom: 18px;
207
- position: relative;
208
- border: solid 1px #e4e7ed;
209
- display: flex;
210
- width: 500px;
211
- max-height: 480px;
212
- }
213
-
214
- .card-left{
215
- flex: 1
216
- }
217
-
218
- .card-right {
219
- flex: 1.3;
220
- padding-left: 6px;
221
- }
222
-
223
- .cursor-pointer {
224
- cursor: pointer;
225
- height: 25px;
226
- }
227
-
228
- .info{
229
- transform: rotate(180deg);
230
- color: #8300bf;
231
- margin-left: 8px;
232
- }
233
-
234
- .title{
235
- font-weight: bold;
236
- }
237
-
238
- .subtitle{
239
- font-weight: bold;
240
- }
241
- </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
+ this.loading = false
112
+ })
113
+ .catch(() => {
114
+ //set defaults if we hit an error
115
+ this.thumbnail = require('@/../assets/missing-image.svg')
116
+ this.discoverId = undefined
117
+ this.loading = false
118
+ });
119
+ },
120
+ removeDoubleFilesPath: function(path){
121
+ if (path.includes('files/')){
122
+ return path.replace('files/', '')
123
+ } else if (path.includes('files\\')) {
124
+ return path.replace('files\\', '')
125
+ } else {
126
+ return path
127
+ }
128
+ },
129
+ toggleSampleDetails: function(i){
130
+ if (this.sampleDetails[i] === undefined){
131
+ Vue.set(this.sampleDetails, i, true)
132
+ } else {
133
+ Vue.set(this.sampleDetails, i, !this.sampleDetails[i])
134
+ }
135
+ },
136
+ getFileFromPath: function(path){
137
+ // for hardcoded data
138
+ if(this.entry.contextCardUrl === true){
139
+ return path
140
+ }
141
+ path = this.removeDoubleFilesPath(path)
142
+ return `${this.entry.apiLocation}s3-resource/${this.entry.discoverId}/${this.entry.version}/files/${path}`
143
+ },
144
+ generateFileLink(path){
145
+ return `https://sparc.science/file/${this.entry.discoverId}/${this.entry.version}?path=${encodeURI(path)}`
146
+
147
+ },
148
+ openViewFile: function(view){
149
+ // note that we assume that the view file is in the same directory as the scaffold (viewUrls take relative paths)
150
+ this.entry.viewUrl = `${this.entry.apiLocation}s3-resource/${this.entry.discoverId}/${this.entry.version}/${view.path}`
151
+ this.entry.type = 'Scaffold View'
152
+ EventBus.$emit("PopoverActionClick", this.entry)
153
+ }
154
+ }
155
+ };
156
+ </script>
157
+
158
+ <!-- Add "scoped" attribute to limit CSS to this component only -->
159
+ <style scoped>
160
+
161
+ .hide{
162
+ color: #e4e7ed;
163
+ cursor: pointer;
164
+ }
165
+
166
+ .context-card{
167
+ background-color: white;
168
+ max-height: 10 50px;
169
+ padding: 8px;
170
+ font-size: 14px;
171
+ margin-bottom: 18px;
172
+ position: relative;
173
+ border: solid 1px #e4e7ed;
174
+ display: flex;
175
+ width: 500px;
176
+ max-height: 258px;
177
+ }
178
+
179
+ .context-card-view{
180
+ cursor: pointer;
181
+ padding-bottom: 8px;
182
+ display: flex;
183
+ }
184
+
185
+ .view-image {
186
+ width: 25px;
187
+ height: auto;
188
+ flex: 1;
189
+ }
190
+
191
+ .view-descriptions {
192
+ flex: 8;
193
+ }
194
+
195
+ .context-card >>> .el-card__body {
196
+ padding: 0px;
197
+ display: flex;
198
+ width: 516px;
199
+ }
200
+
201
+ .context-image{
202
+ width: 250px;
203
+ height: auto;
204
+ }
205
+
206
+ .color-box {
207
+ width: 16px;
208
+ height: 16px;
209
+ border: solid 1px #8300bf;
210
+ border-radius: 2px;
211
+ margin-right: 8px;
212
+ }
213
+
214
+ .card-left{
215
+ flex: 1
216
+ }
217
+
218
+ .card-right {
219
+ flex: 1.3;
220
+ padding-left: 6px;
221
+ overflow-y: scroll;
222
+ scrollbar-width: thin;
223
+ }
224
+
225
+ .cursor-pointer {
226
+ cursor: pointer;
227
+ }
228
+
229
+ .info{
230
+ transform: rotate(180deg);
231
+ color: #8300bf;
232
+ margin-left: 8px;
233
+ }
234
+
235
+ .padding {
236
+ padding-bottom: 8px;
237
+ }
238
+
239
+ .title{
240
+ font-weight: bold;
241
+ }
242
+
243
+ .subtitle{
244
+ font-weight: bold;
245
+ }
246
+
247
+ .scrollbar::-webkit-scrollbar-track {
248
+ border-radius: 10px;
249
+ background-color: #f5f5f5;
250
+ }
251
+
252
+ .scrollbar::-webkit-scrollbar {
253
+ width: 12px;
254
+ right: -12px;
255
+ background-color: #f5f5f5;
256
+ }
257
+
258
+ .scrollbar::-webkit-scrollbar-thumb {
259
+ border-radius: 4px;
260
+ box-shadow: 0 2px 4px 0 rgba(0, 0, 0, 0.06);
261
+ background-color: #979797;
262
+ }
263
+
264
+ </style>