@abi-software/map-side-bar 1.2.3-hardcoded-1 → 1.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.
@@ -1,259 +1,241 @@
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 ( Number.isFinite(val) ){
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
- this.loading = false
114
- })
115
- .catch(() => {
116
- //set defaults if we hit an error
117
- this.thumbnail = require('@/../assets/missing-image.svg')
118
- this.discoverId = undefined
119
- this.loading = false
120
- });
121
- },
122
- removeDoubleFilesPath: function(path){
123
- 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 && 1 > this.entry.contextCardUrl > 0){
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
-
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 = view.path.split('/')[view.path.split('/').length-1]
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
- }
173
-
174
- .context-card-item{
175
- cursor: pointer;
176
- padding-bottom: 8px;
177
- }
178
-
179
- .key-image {
180
- width: 25px;
181
- height: auto;
182
- }
183
-
184
- .context-card >>> .el-card__body {
185
- padding: 0px;
186
- display: flex;
187
- width: 516px;
188
- max-height: 480px;
189
- overflow-y: scroll !important;
190
- scrollbar-width: thin;
191
- }
192
-
193
- .context-image{
194
- width: 230px;
195
- height: auto;
196
- }
197
-
198
- .color-box {
199
- width: 16px;
200
- height: 16px;
201
- border: solid 1px #8300bf;
202
- border-radius: 2px;
203
- margin-right: 8px;
204
- }
205
-
206
- .card {
207
- margin-bottom: 18px;
208
- position: relative;
209
- border: solid 1px #e4e7ed;
210
- display: flex;
211
- width: 500px;
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
-
242
- /* Custom scroll bar */
243
- .context-card >>> .el-card__body::-webkit-scrollbar-track {
244
- border-radius: 10px;
245
- background-color: #f5f5f5;
246
- }
247
-
248
- .context-card >>> .el-card__body::-webkit-scrollbar {
249
- width: 12px;
250
- right: -12px;
251
- background-color: #f5f5f5;
252
- }
253
-
254
- .context-card >>> .el-card__body::-webkit-scrollbar-thumb {
255
- border-radius: 4px;
256
- box-shadow: 0 2px 4px 0 rgba(0, 0, 0, 0.06);
257
- background-color: #979797;
258
- }
259
- </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 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>