@abi-software/flatmapvuer 0.2.4 → 0.2.5-alpha.0

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