@abi-software/flatmapvuer 0.3.3 → 0.3.5

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