@abi-software/flatmapvuer 0.3.0 → 0.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,349 +1,349 @@
1
- <template>
2
- <div class="multi-container">
3
- <div style="position:absolute;z-index:10;">
4
- <div class="species-display-text">
5
- Species
6
- </div>
7
- <el-popover content="Select a species" placement="right"
8
- :appendToBody=false trigger="manual" popper-class="flatmap-popper right-popper" v-model="helpMode" ref="selectPopover">
9
- </el-popover>
10
- <el-select
11
- id="flatmap-select"
12
- :popper-append-to-body="appendToBody"
13
- v-model="activeSpecies"
14
- placeholder="Select"
15
- class="select-box"
16
- popper-class="flatmap_dropdown"
17
- @change="flatmapChanged"
18
- v-popover:selectPopover
19
- >
20
- <el-option v-for="(item, key) in speciesList" :key="key" :label="key" :value="key">
21
- <el-row>
22
- <el-col :span="8"><i :class="item.iconClass"></i></el-col>
23
- <el-col :span="12">{{ key }}</el-col>
24
- </el-row>
25
- </el-option>
26
- </el-select>
27
- </div>
28
- <FlatmapVuer
29
- v-for="(item, key) in speciesList"
30
- :key="key"
31
- :showLayer="showLayer"
32
- v-show="activeSpecies==key"
33
- :entry="item.taxo"
34
- :displayWarning="item.displayWarning"
35
- :warningMessage="warningMessage"
36
- :ref="key"
37
- @resource-selected="FlatmapSelected"
38
- @ready="FlatmapReady"
39
- @pan-zoom-callback="panZoomCallback"
40
- :featureInfo="featureInfo"
41
- :minZoom="minZoom"
42
- :pathControls="pathControls"
43
- :searchable="searchable"
44
- :helpMode="helpMode"
45
- :renderAtMounted="renderAtMounted"
46
- :displayMinimap="displayMinimap"
47
- style="height:100%"
48
- :flatmapAPI="flatmapAPI"
49
- :sparcAPI="sparcAPI"
50
- />
51
- </div>
52
- </template>
53
-
54
-
55
- <script>
56
- /* eslint-disable no-alert, no-console */
57
- import EventBus from './EventBus'
58
- import Vue from "vue";
59
- import FlatmapVuer from "./FlatmapVuer.vue";
60
- import { Col, Option, Select, Row, Popover } from "element-ui";
61
- import lang from "element-ui/lib/locale/lang/en";
62
- import locale from "element-ui/lib/locale";
63
- locale.use(lang);
64
- Vue.use(Col);
65
- Vue.use(Row);
66
- Vue.use(Option);
67
- Vue.use(Select);
68
- Vue.use(Popover)
69
-
70
-
71
- export default {
72
- name: "MultiFlatmapVuer",
73
- components: {
74
- FlatmapVuer
75
- },
76
- mounted: function() {
77
- this.initialise();
78
- EventBus.$on('onActionClick', (action) =>{
79
- this.FlatmapSelected(action)
80
- })
81
- },
82
- methods: {
83
- initialise: function() {
84
- return new Promise(resolve => {
85
- fetch(this.flatmapAPI)
86
- .then(response => response.json())
87
- .then(data => {
88
- this.speciesLis= {};
89
- Object.keys(this.availableSpecies).forEach(key => {
90
- for (let i = 0; i < data.length; i++) {
91
- if (data[i].taxon === this.availableSpecies[key].taxo) {
92
- this.speciesList[key] = this.availableSpecies[key];
93
- break;
94
- }
95
- }
96
- });
97
- if (!this.state) {
98
- if (this.initial && this.speciesList[this.initial] !== undefined) {
99
- this.activeSpecies = this.initial;
100
- } else {
101
- this.activeSpecies = Object.keys(this.speciesList)[0];
102
- }
103
- Vue.nextTick(() => {
104
- if (this.$refs[this.activeSpecies])
105
- this.$refs[this.activeSpecies][0].createFlatmap();
106
- });
107
- }
108
- resolve();
109
- });
110
- })
111
- },
112
- FlatmapSelected: function(resource) {
113
- this.$emit("resource-selected", resource);
114
- },
115
- FlatmapReady: function(component) {
116
- this.$emit("ready", component);
117
- },
118
- getCoordinatesOfLastClick: function() {
119
- const flatmap = this.$refs[this.activeSpecies];
120
- if (flatmap && flatmap[0]) {
121
- return flatmap[0].getCoordinatesOfLastClick();
122
- }
123
- return undefined;
124
- },
125
- getCurrentFlatmap: function() {
126
- return this.$refs[this.activeSpecies][0];
127
- },
128
- panZoomCallback: function(payload) {
129
- this.$emit("pan-zoom-callback", payload);
130
- },
131
- showPopup: function(featureId, node, options) {
132
- let map = this.getCurrentFlatmap();
133
- map.showPopup(featureId, node, options);
134
- },
135
- showMarkerPopup: function(featureId, node, options) {
136
- let map = this.getCurrentFlatmap();
137
- map.showMarkerPopup(featureId, node, options);
138
- },
139
- flatmapChanged: function(species){
140
- if (this.activeSpecies != species)
141
- this.activeSpecies = species;
142
- this.$refs[this.activeSpecies][0].createFlatmap();
143
- this.$emit('flatmapChanged', this.activeSpecies);
144
- },
145
- /**
146
- * Function used for getting the current states of the scene. This exported states
147
- * can be imported using the importStates method.
148
- *
149
- * @public
150
- */
151
- getState: function() {
152
- let state = {
153
- species: this.activeSpecies,
154
- state: undefined,
155
- };
156
- let map = this.getCurrentFlatmap();
157
- state.state = map.getState();
158
- return state;
159
- },
160
- /**
161
- * Function used for importing the states of the scene. This exported states
162
- * can be imported using the read states method.
163
- *
164
- * @public
165
- */
166
- setState: function(state) {
167
- if (state) {
168
- this.initialise().then(() => {
169
- if (state.species && state.species !== this.activeSpecies) {
170
- this.activeSpecies = state.species;
171
- if (state.state) {
172
- //Wait for next tick when the refs are ready for rendering
173
- this.$nextTick(() => {
174
- this.$refs[this.activeSpecies][0].createFlatmap(state.state);
175
- this.$emit('flatmapChanged', this.activeSpecies);
176
- })
177
- }
178
- } else if (state.state) {
179
- let map = this.getCurrentFlatmap();
180
- map.setState(state.state);
181
- }
182
- })
183
- }
184
- },
185
- resourceSelected: function(action) {
186
- this.$emit("resource-selected", action);
187
- },
188
- },
189
- props: {
190
- showLayer: {
191
- type: Boolean,
192
- default: false
193
- },
194
- featureInfo: {
195
- type: Boolean,
196
- default: false
197
- },
198
- pathControls: {
199
- type: Boolean,
200
- default: true
201
- },
202
- searchable: {
203
- type: Boolean,
204
- default: false
205
- },
206
- /**
207
- * Initial species for the flatmap.
208
- * This value will be ignored if a valid state object is provided.
209
- */
210
- initial: {
211
- type: String,
212
- default: ""
213
- },
214
- minZoom: {
215
- type: Number,
216
- default: 4
217
- },
218
- renderAtMounted: {
219
- type: Boolean,
220
- default: false
221
- },
222
- helpMode: {
223
- type: Boolean,
224
- default: false
225
- },
226
- displayMinimap: {
227
- type: Boolean,
228
- default: false
229
- },
230
- warningMessage: {
231
- type: String,
232
- default: "Beta feature - This map is based on the connectivity of a rat. New connectivity and species specificity will be added as the SPARC program progress."
233
- },
234
- availableSpecies: {},
235
- /**
236
- * State containing state of the flatmap.
237
- */
238
- state: {
239
- type: Object,
240
- default: undefined,
241
- },
242
- /**
243
- * Specify the endpoint of the flatmap server.
244
- */
245
- flatmapAPI: {
246
- type: String,
247
- default: "https://mapcore-demo.org/flatmaps/"
248
- },
249
- sparcAPI: {
250
- type: String,
251
- default: "https://api.sparc.science/"
252
- }
253
- },
254
- data: function() {
255
- return {
256
- activeSpecies: undefined,
257
- appendToBody: false,
258
- speciesList: {}
259
- };
260
- },
261
- watch: {
262
- state: {
263
- handler: function(state) {
264
- this.setState(state);
265
- },
266
- immediate: true,
267
- deep: true,
268
- }
269
- }
270
- };
271
- </script>
272
-
273
- <style scoped lang="scss">
274
- @import "~element-ui/packages/theme-chalk/src/select";
275
- @import "~element-ui/packages/theme-chalk/src/option";
276
-
277
- .multi-container {
278
- height: 100%;
279
- width: 100%;
280
- }
281
-
282
- .species-display-text {
283
- width: 47px;
284
- height: 20px;
285
- color: rgb(48, 49, 51);
286
- font-size: 14px;
287
- font-weight: normal;
288
- line-height: 20px;
289
- left:24px;
290
- top:16px;
291
- position: absolute;
292
- }
293
-
294
- .select-box {
295
- width: 120px;
296
- border-radius: 4px;
297
- border: 1px solid rgb(144, 147, 153);
298
- background-color: var(--white);
299
- font-weight: 500;
300
- color:rgb(48, 49, 51);;
301
- left: 16px;
302
- top: 44px;
303
- position: absolute;
304
- ::v-deep .el-input__inner {
305
- color: rgb(48, 49, 51);
306
- padding-top: 0.25em;
307
- .is-focus {
308
- border: 1px solid $app-primary-color;
309
- }
310
- }
311
- }
312
-
313
- .flatmap_dropdown {
314
- .el-select-dropdown__item {
315
- white-space: nowrap;
316
- text-align: left;
317
- &.selected {
318
- color: $app-primary-color;
319
- font-weight: normal;
320
- }
321
- }
322
- }
323
-
324
- ::v-deep .flatmap-popper {
325
- padding: 6px 4px;
326
- font-size:12px;
327
- color: rgb(48, 49, 51);
328
- background-color: #f3ecf6;
329
- border: 1px solid $app-primary-color;
330
- white-space: nowrap;
331
- min-width: unset;
332
- &.right-popper {
333
- .popper__arrow {
334
- border-right-color: $app-primary-color !important;
335
- &:after {
336
- border-right-color: #f3ecf6 !important;
337
- }
338
- }
339
- }
340
- }
341
-
342
- ::v-deep .flatmap-marker-popup{
343
- background-color: #f0f0f000 !important;
344
- box-shadow: none !important;
345
- }
346
-
347
- </style>
348
-
349
-
1
+ <template>
2
+ <div class="multi-container">
3
+ <div style="position:absolute;z-index:10;">
4
+ <div class="species-display-text">
5
+ Species
6
+ </div>
7
+ <el-popover content="Select a species" placement="right"
8
+ :appendToBody=false trigger="manual" popper-class="flatmap-popper right-popper" v-model="helpMode" ref="selectPopover">
9
+ </el-popover>
10
+ <el-select
11
+ id="flatmap-select"
12
+ :popper-append-to-body="appendToBody"
13
+ v-model="activeSpecies"
14
+ placeholder="Select"
15
+ class="select-box"
16
+ popper-class="flatmap_dropdown"
17
+ @change="flatmapChanged"
18
+ v-popover:selectPopover
19
+ >
20
+ <el-option v-for="(item, key) in speciesList" :key="key" :label="key" :value="key">
21
+ <el-row>
22
+ <el-col :span="8"><i :class="item.iconClass"></i></el-col>
23
+ <el-col :span="12">{{ key }}</el-col>
24
+ </el-row>
25
+ </el-option>
26
+ </el-select>
27
+ </div>
28
+ <FlatmapVuer
29
+ v-for="(item, key) in speciesList"
30
+ :key="key"
31
+ :showLayer="showLayer"
32
+ v-show="activeSpecies==key"
33
+ :entry="item.taxo"
34
+ :displayWarning="item.displayWarning"
35
+ :warningMessage="warningMessage"
36
+ :ref="key"
37
+ @resource-selected="FlatmapSelected"
38
+ @ready="FlatmapReady"
39
+ @pan-zoom-callback="panZoomCallback"
40
+ :featureInfo="featureInfo"
41
+ :minZoom="minZoom"
42
+ :pathControls="pathControls"
43
+ :searchable="searchable"
44
+ :helpMode="helpMode"
45
+ :renderAtMounted="renderAtMounted"
46
+ :displayMinimap="displayMinimap"
47
+ style="height:100%"
48
+ :flatmapAPI="flatmapAPI"
49
+ :sparcAPI="sparcAPI"
50
+ />
51
+ </div>
52
+ </template>
53
+
54
+
55
+ <script>
56
+ /* eslint-disable no-alert, no-console */
57
+ import EventBus from './EventBus'
58
+ import Vue from "vue";
59
+ import FlatmapVuer from "./FlatmapVuer.vue";
60
+ import { Col, Option, Select, Row, Popover } from "element-ui";
61
+ import lang from "element-ui/lib/locale/lang/en";
62
+ import locale from "element-ui/lib/locale";
63
+ locale.use(lang);
64
+ Vue.use(Col);
65
+ Vue.use(Row);
66
+ Vue.use(Option);
67
+ Vue.use(Select);
68
+ Vue.use(Popover)
69
+
70
+
71
+ export default {
72
+ name: "MultiFlatmapVuer",
73
+ components: {
74
+ FlatmapVuer
75
+ },
76
+ mounted: function() {
77
+ this.initialise();
78
+ EventBus.$on('onActionClick', (action) =>{
79
+ this.FlatmapSelected(action)
80
+ })
81
+ },
82
+ methods: {
83
+ initialise: function() {
84
+ return new Promise(resolve => {
85
+ fetch(this.flatmapAPI)
86
+ .then(response => response.json())
87
+ .then(data => {
88
+ this.speciesLis= {};
89
+ Object.keys(this.availableSpecies).forEach(key => {
90
+ for (let i = 0; i < data.length; i++) {
91
+ if (data[i].taxon === this.availableSpecies[key].taxo) {
92
+ this.speciesList[key] = this.availableSpecies[key];
93
+ break;
94
+ }
95
+ }
96
+ });
97
+ if (!this.state) {
98
+ if (this.initial && this.speciesList[this.initial] !== undefined) {
99
+ this.activeSpecies = this.initial;
100
+ } else {
101
+ this.activeSpecies = Object.keys(this.speciesList)[0];
102
+ }
103
+ Vue.nextTick(() => {
104
+ if (this.$refs[this.activeSpecies])
105
+ this.$refs[this.activeSpecies][0].createFlatmap();
106
+ });
107
+ }
108
+ resolve();
109
+ });
110
+ })
111
+ },
112
+ FlatmapSelected: function(resource) {
113
+ this.$emit("resource-selected", resource);
114
+ },
115
+ FlatmapReady: function(component) {
116
+ this.$emit("ready", component);
117
+ },
118
+ getCoordinatesOfLastClick: function() {
119
+ const flatmap = this.$refs[this.activeSpecies];
120
+ if (flatmap && flatmap[0]) {
121
+ return flatmap[0].getCoordinatesOfLastClick();
122
+ }
123
+ return undefined;
124
+ },
125
+ getCurrentFlatmap: function() {
126
+ return this.$refs[this.activeSpecies][0];
127
+ },
128
+ panZoomCallback: function(payload) {
129
+ this.$emit("pan-zoom-callback", payload);
130
+ },
131
+ showPopup: function(featureId, node, options) {
132
+ let map = this.getCurrentFlatmap();
133
+ map.showPopup(featureId, node, options);
134
+ },
135
+ showMarkerPopup: function(featureId, node, options) {
136
+ let map = this.getCurrentFlatmap();
137
+ map.showMarkerPopup(featureId, node, options);
138
+ },
139
+ flatmapChanged: function(species){
140
+ if (this.activeSpecies != species)
141
+ this.activeSpecies = species;
142
+ this.$refs[this.activeSpecies][0].createFlatmap();
143
+ this.$emit('flatmapChanged', this.activeSpecies);
144
+ },
145
+ /**
146
+ * Function used for getting the current states of the scene. This exported states
147
+ * can be imported using the importStates method.
148
+ *
149
+ * @public
150
+ */
151
+ getState: function() {
152
+ let state = {
153
+ species: this.activeSpecies,
154
+ state: undefined,
155
+ };
156
+ let map = this.getCurrentFlatmap();
157
+ state.state = map.getState();
158
+ return state;
159
+ },
160
+ /**
161
+ * Function used for importing the states of the scene. This exported states
162
+ * can be imported using the read states method.
163
+ *
164
+ * @public
165
+ */
166
+ setState: function(state) {
167
+ if (state) {
168
+ this.initialise().then(() => {
169
+ if (state.species && state.species !== this.activeSpecies) {
170
+ this.activeSpecies = state.species;
171
+ if (state.state) {
172
+ //Wait for next tick when the refs are ready for rendering
173
+ this.$nextTick(() => {
174
+ this.$refs[this.activeSpecies][0].createFlatmap(state.state);
175
+ this.$emit('flatmapChanged', this.activeSpecies);
176
+ })
177
+ }
178
+ } else if (state.state) {
179
+ let map = this.getCurrentFlatmap();
180
+ map.setState(state.state);
181
+ }
182
+ })
183
+ }
184
+ },
185
+ resourceSelected: function(action) {
186
+ this.$emit("resource-selected", action);
187
+ },
188
+ },
189
+ props: {
190
+ showLayer: {
191
+ type: Boolean,
192
+ default: false
193
+ },
194
+ featureInfo: {
195
+ type: Boolean,
196
+ default: false
197
+ },
198
+ pathControls: {
199
+ type: Boolean,
200
+ default: true
201
+ },
202
+ searchable: {
203
+ type: Boolean,
204
+ default: false
205
+ },
206
+ /**
207
+ * Initial species for the flatmap.
208
+ * This value will be ignored if a valid state object is provided.
209
+ */
210
+ initial: {
211
+ type: String,
212
+ default: ""
213
+ },
214
+ minZoom: {
215
+ type: Number,
216
+ default: 4
217
+ },
218
+ renderAtMounted: {
219
+ type: Boolean,
220
+ default: false
221
+ },
222
+ helpMode: {
223
+ type: Boolean,
224
+ default: false
225
+ },
226
+ displayMinimap: {
227
+ type: Boolean,
228
+ default: false
229
+ },
230
+ warningMessage: {
231
+ type: String,
232
+ default: "Beta feature - This map is based on the connectivity of a rat. New connectivity and species specificity will be added as the SPARC program progress."
233
+ },
234
+ availableSpecies: {},
235
+ /**
236
+ * State containing state of the flatmap.
237
+ */
238
+ state: {
239
+ type: Object,
240
+ default: undefined,
241
+ },
242
+ /**
243
+ * Specify the endpoint of the flatmap server.
244
+ */
245
+ flatmapAPI: {
246
+ type: String,
247
+ default: "https://mapcore-demo.org/flatmaps/"
248
+ },
249
+ sparcAPI: {
250
+ type: String,
251
+ default: "https://api.sparc.science/"
252
+ }
253
+ },
254
+ data: function() {
255
+ return {
256
+ activeSpecies: undefined,
257
+ appendToBody: false,
258
+ speciesList: {}
259
+ };
260
+ },
261
+ watch: {
262
+ state: {
263
+ handler: function(state) {
264
+ this.setState(state);
265
+ },
266
+ immediate: true,
267
+ deep: true,
268
+ }
269
+ }
270
+ };
271
+ </script>
272
+
273
+ <style scoped lang="scss">
274
+ @import "~element-ui/packages/theme-chalk/src/select";
275
+ @import "~element-ui/packages/theme-chalk/src/option";
276
+
277
+ .multi-container {
278
+ height: 100%;
279
+ width: 100%;
280
+ }
281
+
282
+ .species-display-text {
283
+ width: 47px;
284
+ height: 20px;
285
+ color: rgb(48, 49, 51);
286
+ font-size: 14px;
287
+ font-weight: normal;
288
+ line-height: 20px;
289
+ left:24px;
290
+ top:16px;
291
+ position: absolute;
292
+ }
293
+
294
+ .select-box {
295
+ width: 120px;
296
+ border-radius: 4px;
297
+ border: 1px solid rgb(144, 147, 153);
298
+ background-color: var(--white);
299
+ font-weight: 500;
300
+ color:rgb(48, 49, 51);;
301
+ left: 16px;
302
+ top: 44px;
303
+ position: absolute;
304
+ ::v-deep .el-input__inner {
305
+ color: rgb(48, 49, 51);
306
+ padding-top: 0.25em;
307
+ .is-focus {
308
+ border: 1px solid $app-primary-color;
309
+ }
310
+ }
311
+ }
312
+
313
+ .flatmap_dropdown {
314
+ .el-select-dropdown__item {
315
+ white-space: nowrap;
316
+ text-align: left;
317
+ &.selected {
318
+ color: $app-primary-color;
319
+ font-weight: normal;
320
+ }
321
+ }
322
+ }
323
+
324
+ ::v-deep .flatmap-popper {
325
+ padding: 6px 4px;
326
+ font-size:12px;
327
+ color: rgb(48, 49, 51);
328
+ background-color: #f3ecf6;
329
+ border: 1px solid $app-primary-color;
330
+ white-space: nowrap;
331
+ min-width: unset;
332
+ &.right-popper {
333
+ .popper__arrow {
334
+ border-right-color: $app-primary-color !important;
335
+ &:after {
336
+ border-right-color: #f3ecf6 !important;
337
+ }
338
+ }
339
+ }
340
+ }
341
+
342
+ ::v-deep .flatmap-marker-popup{
343
+ background-color: #f0f0f000 !important;
344
+ box-shadow: none !important;
345
+ }
346
+
347
+ </style>
348
+
349
+