@sedoo/unidoo 0.1.71 → 0.1.73
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.
- package/dist/auth/auth.common.js +1 -1
- package/dist/auth/auth.umd.js +1 -1
- package/dist/auth/auth.umd.min.js +1 -1
- package/dist/unidoo/unidoo.common.js +6 -6
- package/dist/unidoo/unidoo.umd.js +6 -6
- package/dist/unidoo/unidoo.umd.min.js +6 -6
- package/package.json +2 -1
- package/src/auth.js +44 -38
- package/src/components/UnidooCaptcha.vue +62 -68
- package/src/components/UnidooCrudTable.vue +21 -15
- package/src/components/UnidooMapGeoFeatures.vue +142 -134
- package/src/components/UnidooTrajectoryMap.vue +76 -70
- package/src/components/unidoo-heatmap/Heatmap.js +120 -103
- package/src/components/unidoo-heatmap/UnidooHeatmap.vue +333 -291
- package/src/components/unidoo-player/unidoo-player-layout/UnidooPlayerLayout.vue +262 -219
- package/src/components/unidoo-viewer/campaign-product-block/campaign-product-block.vue +59 -44
- package/src/components/unidoo-viewer/heatmap-component/heatmap-component.vue +61 -58
- package/src/components/unidoo-viewer/map-viewer/wms-viewer.vue +1 -1
- package/src/components/unidoo-viewer/map-viewer/wmts-viewer.vue +154 -134
- package/src/components/unidoo-viewer/tree-viewer/tree-viewer.vue +1 -1
- package/src/components/unidoo-viewer/unidoo-viewer.vue +8 -6
- package/src/components/unidoo-viewer/years-component/years-component.vue +58 -38
- package/src/utils.js +7 -5
|
@@ -1,12 +1,10 @@
|
|
|
1
1
|
<template>
|
|
2
|
-
<v-col wmts-viewer style="padding: 0 12px
|
|
2
|
+
<v-col wmts-viewer style="padding: 0 12px">
|
|
3
3
|
<v-row justify="center" style="position: relative; height: 100%">
|
|
4
|
-
|
|
5
4
|
<div :id="id" class="map"></div>
|
|
6
|
-
|
|
5
|
+
|
|
7
6
|
<v-col layers-list-container v-if="layers && layers.length > 0">
|
|
8
|
-
|
|
9
|
-
<v-row justify="end" style="margin-right: 5px;">
|
|
7
|
+
<v-row justify="end" style="margin-right: 5px">
|
|
10
8
|
<v-btn
|
|
11
9
|
v-if="showItems"
|
|
12
10
|
show-items
|
|
@@ -29,37 +27,35 @@
|
|
|
29
27
|
</v-btn>
|
|
30
28
|
</v-row>
|
|
31
29
|
<v-col v-if="showItems" layers-list>
|
|
32
|
-
|
|
33
|
-
|
|
30
|
+
<layer-item
|
|
31
|
+
v-for="(item, index) in layers"
|
|
34
32
|
:key="index"
|
|
35
33
|
:item="item"
|
|
36
34
|
:initialOpacity="item.opacity"
|
|
37
35
|
@change-opacity="changeOpacity"
|
|
38
36
|
></layer-item>
|
|
39
|
-
|
|
40
37
|
</v-col>
|
|
41
38
|
</v-col>
|
|
42
|
-
|
|
43
39
|
</v-row>
|
|
44
40
|
<span coordinates>EPSG:4326<span id="mouse-position"></span></span>
|
|
45
41
|
</v-col>
|
|
46
42
|
</template>
|
|
47
43
|
|
|
48
44
|
<script>
|
|
49
|
-
import layerItem from
|
|
50
|
-
import
|
|
51
|
-
import Map from
|
|
52
|
-
import OSM from
|
|
53
|
-
import TileLayer from
|
|
54
|
-
import View from
|
|
55
|
-
import WMTS from
|
|
56
|
-
import { createStringXY } from
|
|
57
|
-
import MousePosition from
|
|
58
|
-
import { defaults as defaultControls } from
|
|
59
|
-
import moment from
|
|
45
|
+
import layerItem from "./layer-item";
|
|
46
|
+
import "ol/ol.css";
|
|
47
|
+
import Map from "ol/Map";
|
|
48
|
+
import OSM from "ol/source/OSM";
|
|
49
|
+
import TileLayer from "ol/layer/Tile";
|
|
50
|
+
import View from "ol/View";
|
|
51
|
+
import WMTS from "ol/source/WMTS";
|
|
52
|
+
import { createStringXY } from "ol/coordinate";
|
|
53
|
+
import MousePosition from "ol/control/MousePosition";
|
|
54
|
+
import { defaults as defaultControls } from "ol/control";
|
|
55
|
+
import moment from "moment";
|
|
60
56
|
|
|
61
57
|
export default {
|
|
62
|
-
name:
|
|
58
|
+
name: "wmts-viewer",
|
|
63
59
|
|
|
64
60
|
components: {
|
|
65
61
|
layerItem
|
|
@@ -76,7 +72,7 @@ export default {
|
|
|
76
72
|
},
|
|
77
73
|
title: {
|
|
78
74
|
type: String,
|
|
79
|
-
default: () =>
|
|
75
|
+
default: () => ""
|
|
80
76
|
},
|
|
81
77
|
date: {
|
|
82
78
|
type: [String, Date],
|
|
@@ -92,67 +88,78 @@ export default {
|
|
|
92
88
|
zoom: null
|
|
93
89
|
}),
|
|
94
90
|
|
|
95
|
-
watch: {
|
|
96
|
-
layers(val) {
|
|
97
|
-
|
|
91
|
+
watch: {
|
|
92
|
+
layers(val) {
|
|
93
|
+
// tester si ca marche sans le deep avec watch layers(val)
|
|
94
|
+
if (!this.map) this.initMap();
|
|
98
95
|
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
96
|
+
if (this.map && val) {
|
|
97
|
+
if (!this.mapEntryIndexSource) {
|
|
98
|
+
// initialier les layers et les inserer en concervant l'index=
|
|
99
|
+
this.mapEntryIndexSource = {};
|
|
100
|
+
this.mapLayers = {};
|
|
104
101
|
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
});
|
|
119
|
-
|
|
120
|
-
this.map.addLayer(layer);
|
|
121
|
-
this.mapLayers[index] = layer;
|
|
122
|
-
this.mapEntryIndexSource[index] = source;
|
|
123
|
-
});
|
|
124
|
-
} else {
|
|
125
|
-
// mettre a jour les sources à partir de l'index
|
|
126
|
-
val.forEach(item => {
|
|
127
|
-
const index = item.index;
|
|
128
|
-
const layer = this.mapLayers[index];
|
|
129
|
-
if (layer) {
|
|
130
|
-
const source = this.mapEntryIndexSource[index];
|
|
131
|
-
layer.setSource(source);
|
|
132
|
-
} else {
|
|
133
|
-
console.error("Error cannot find layer in map layers at index " + index);
|
|
134
|
-
}
|
|
102
|
+
val.forEach((item) => {
|
|
103
|
+
const option = item.option;
|
|
104
|
+
const opacity = item.opacity;
|
|
105
|
+
const index = item.index;
|
|
106
|
+
const source = new WMTS(option);
|
|
107
|
+
const loadFunction = function (imageTile, src) {
|
|
108
|
+
imageTile.getImage().src = src;
|
|
109
|
+
};
|
|
110
|
+
source.setTileLoadFunction(loadFunction);
|
|
111
|
+
const layer = new TileLayer({
|
|
112
|
+
preload: 0, // default value
|
|
113
|
+
opacity: opacity,
|
|
114
|
+
source: source
|
|
135
115
|
});
|
|
136
|
-
|
|
137
|
-
|
|
116
|
+
|
|
117
|
+
this.map.addLayer(layer);
|
|
118
|
+
this.mapLayers[index] = layer;
|
|
119
|
+
this.mapEntryIndexSource[index] = source;
|
|
120
|
+
});
|
|
138
121
|
} else {
|
|
139
|
-
|
|
122
|
+
// mettre a jour les sources à partir de l'index
|
|
123
|
+
val.forEach((item) => {
|
|
124
|
+
const index = item.index;
|
|
125
|
+
const layer = this.mapLayers[index];
|
|
126
|
+
if (layer) {
|
|
127
|
+
const source = this.mapEntryIndexSource[index];
|
|
128
|
+
layer.setSource(source);
|
|
129
|
+
} else {
|
|
130
|
+
console.error(
|
|
131
|
+
"Error cannot find layer in map layers at index " + index
|
|
132
|
+
);
|
|
133
|
+
}
|
|
134
|
+
});
|
|
140
135
|
}
|
|
136
|
+
this.emitViewChange(
|
|
137
|
+
this.map.getView().getZoom(),
|
|
138
|
+
this.map.getView().calculateExtent(this.map.getSize()),
|
|
139
|
+
Object.assign({}, this.mapEntryIndexSource)
|
|
140
|
+
);
|
|
141
|
+
} else {
|
|
142
|
+
console.error("map or layers undefined");
|
|
143
|
+
}
|
|
141
144
|
},
|
|
142
145
|
|
|
143
146
|
date(value) {
|
|
144
147
|
if (value && this.layers) {
|
|
145
|
-
this.layers.forEach(item => {
|
|
148
|
+
this.layers.forEach((item) => {
|
|
146
149
|
const index = item.index;
|
|
147
|
-
|
|
150
|
+
|
|
148
151
|
const layer = this.mapLayers[index];
|
|
149
152
|
if (layer) {
|
|
150
153
|
const source = this.mapEntryIndexSource[index];
|
|
151
|
-
source.updateDimensions(
|
|
154
|
+
source.updateDimensions(
|
|
155
|
+
this.computeTimeDimension(value, item.dateField, item.dateFormat)
|
|
156
|
+
);
|
|
152
157
|
source.refresh();
|
|
153
158
|
} else {
|
|
154
|
-
console.error(
|
|
155
|
-
|
|
159
|
+
console.error(
|
|
160
|
+
"Error cannot find layer in map layers at index " + index
|
|
161
|
+
);
|
|
162
|
+
}
|
|
156
163
|
});
|
|
157
164
|
}
|
|
158
165
|
}
|
|
@@ -163,47 +170,52 @@ export default {
|
|
|
163
170
|
},
|
|
164
171
|
|
|
165
172
|
methods: {
|
|
166
|
-
|
|
167
173
|
initMap() {
|
|
168
|
-
if (this.id) {
|
|
174
|
+
if (this.id && typeof document !== "undefined") {
|
|
169
175
|
// coordonnées souris
|
|
170
176
|
var mousePositionControl = new MousePosition({
|
|
171
177
|
coordinateFormat: createStringXY(4),
|
|
172
|
-
projection:
|
|
173
|
-
className:
|
|
174
|
-
target: document.getElementById(
|
|
175
|
-
undefinedHTML:
|
|
178
|
+
projection: "EPSG:4326",
|
|
179
|
+
className: "custom-mouse-position",
|
|
180
|
+
target: document.getElementById("mouse-position"),
|
|
181
|
+
undefinedHTML: " "
|
|
176
182
|
});
|
|
177
183
|
|
|
178
184
|
// fond de carte
|
|
179
185
|
const rasterSource = new OSM();
|
|
180
186
|
this.rasterCoords = [];
|
|
181
187
|
const self = this;
|
|
182
|
-
rasterSource.on(
|
|
188
|
+
rasterSource.on("tileloadstart", function (event) {
|
|
183
189
|
self.rasterCoords.push(event.tile.tileCoord);
|
|
184
190
|
});
|
|
185
191
|
const raster = new TileLayer({
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
192
|
+
source: rasterSource,
|
|
193
|
+
opacity: 0.7
|
|
194
|
+
});
|
|
189
195
|
this.map = new Map({
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
if (this.box) {
|
|
196
|
+
layers: [raster],
|
|
197
|
+
controls: defaultControls().extend([mousePositionControl]),
|
|
198
|
+
target: this.id,
|
|
199
|
+
view: new View({
|
|
200
|
+
center: [0, 0],
|
|
201
|
+
zoom: 1
|
|
202
|
+
})
|
|
203
|
+
});
|
|
204
|
+
|
|
205
|
+
if (this.box) {
|
|
200
206
|
this.map.getView().fit(this.box, this.map.getSize());
|
|
201
207
|
}
|
|
202
|
-
this.map.on(
|
|
203
|
-
const newExtent = self.map
|
|
208
|
+
this.map.on("moveend", function (e) {
|
|
209
|
+
const newExtent = self.map
|
|
210
|
+
.getView()
|
|
211
|
+
.calculateExtent(self.map.getSize());
|
|
204
212
|
const newZoom = self.map.getView().getZoom();
|
|
205
213
|
if (self.zoom !== newZoom) {
|
|
206
|
-
self.emitViewChange(
|
|
214
|
+
self.emitViewChange(
|
|
215
|
+
newZoom,
|
|
216
|
+
newExtent,
|
|
217
|
+
Object.assign({}, self.mapEntryIndexSource)
|
|
218
|
+
);
|
|
207
219
|
}
|
|
208
220
|
});
|
|
209
221
|
this.zoom = this.map.getView().getZoom();
|
|
@@ -212,7 +224,11 @@ export default {
|
|
|
212
224
|
|
|
213
225
|
emitViewChange(zoom, extent, sources) {
|
|
214
226
|
// TODO ici recupérer les tileCoords courants et envoyer au player ?
|
|
215
|
-
this.$emit("update-zoom", {
|
|
227
|
+
this.$emit("update-zoom", {
|
|
228
|
+
zoom: zoom,
|
|
229
|
+
extent: extent,
|
|
230
|
+
sources: sources
|
|
231
|
+
});
|
|
216
232
|
},
|
|
217
233
|
|
|
218
234
|
changeOpacity(data) {
|
|
@@ -233,57 +249,61 @@ export default {
|
|
|
233
249
|
|
|
234
250
|
create_UUID() {
|
|
235
251
|
var dt = new Date().getTime();
|
|
236
|
-
var uuid =
|
|
252
|
+
var uuid = "xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(
|
|
253
|
+
/[xy]/g,
|
|
254
|
+
function (c) {
|
|
237
255
|
var r = (dt + Math.random() * 16) % 16 | 0;
|
|
238
256
|
dt = Math.floor(dt / 16);
|
|
239
|
-
return (c ===
|
|
240
|
-
|
|
257
|
+
return (c === "x" ? r : (r & 0x3) | 0x8).toString(16);
|
|
258
|
+
}
|
|
259
|
+
);
|
|
241
260
|
return uuid;
|
|
242
|
-
}
|
|
261
|
+
}
|
|
243
262
|
}
|
|
244
|
-
}
|
|
263
|
+
};
|
|
245
264
|
</script>
|
|
246
265
|
<style scoped>
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
266
|
+
[wmts-viewer] {
|
|
267
|
+
position: relative;
|
|
268
|
+
}
|
|
250
269
|
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
270
|
+
[coordinates] {
|
|
271
|
+
position: absolute;
|
|
272
|
+
display: flex;
|
|
273
|
+
bottom: 0;
|
|
274
|
+
left: 0;
|
|
275
|
+
font-size: small;
|
|
276
|
+
opacity: 0.7;
|
|
277
|
+
letter-spacing: normal;
|
|
278
|
+
}
|
|
260
279
|
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
280
|
+
#mouse-position {
|
|
281
|
+
margin-left: 10px;
|
|
282
|
+
}
|
|
264
283
|
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
284
|
+
.map {
|
|
285
|
+
width: 100%;
|
|
286
|
+
height: 100%;
|
|
287
|
+
}
|
|
269
288
|
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
289
|
+
[layers-list-container] {
|
|
290
|
+
position: absolute;
|
|
291
|
+
top: 0;
|
|
292
|
+
right: 0;
|
|
293
|
+
padding: 12px 0;
|
|
294
|
+
width: 200px;
|
|
295
|
+
max-height: 100%;
|
|
296
|
+
overflow-y: auto;
|
|
297
|
+
}
|
|
298
|
+
[layers-list] {
|
|
299
|
+
padding: 0;
|
|
300
|
+
width: 200px;
|
|
301
|
+
}
|
|
283
302
|
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
303
|
+
[show-items] {
|
|
304
|
+
background: white;
|
|
305
|
+
border-radius: 10px;
|
|
306
|
+
box-shadow: 0 3px 1px -2px rgba(0, 0, 0, 0.2), 0 2px 2px 0 rgba(0, 0, 0, 0.14),
|
|
307
|
+
0 1px 5px 0 rgba(0, 0, 0, 0.12);
|
|
308
|
+
}
|
|
289
309
|
</style>
|
|
@@ -118,7 +118,7 @@ export default {
|
|
|
118
118
|
},
|
|
119
119
|
|
|
120
120
|
created() {
|
|
121
|
-
if (this.sync) {
|
|
121
|
+
if (this.sync && typeof document !== "undefined") {
|
|
122
122
|
this.playerListener = this.showPlayButton.bind(this);
|
|
123
123
|
document.addEventListener("show-play", this.playerListener);
|
|
124
124
|
this.removePlayerListener = this.removePlayer.bind(this);
|
|
@@ -131,7 +131,7 @@ export default {
|
|
|
131
131
|
},
|
|
132
132
|
|
|
133
133
|
destroyed() {
|
|
134
|
-
if (this.sync) {
|
|
134
|
+
if (this.sync && typeof document !== "undefined") {
|
|
135
135
|
document.removeEventListener("show-play", this.playerListener);
|
|
136
136
|
this.playerListener = null;
|
|
137
137
|
document.removeEventListener("remove-player", this.removePlayerListener);
|
|
@@ -157,10 +157,12 @@ export default {
|
|
|
157
157
|
},
|
|
158
158
|
|
|
159
159
|
playOrStop() {
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
160
|
+
if (typeof document !== "undefined") {
|
|
161
|
+
this.isPlaying = !this.isPlaying;
|
|
162
|
+
document.dispatchEvent(
|
|
163
|
+
new CustomEvent("play-stop", { detail: { play: this.isPlaying } })
|
|
164
|
+
);
|
|
165
|
+
}
|
|
164
166
|
}
|
|
165
167
|
}
|
|
166
168
|
};
|
|
@@ -2,20 +2,20 @@
|
|
|
2
2
|
<div>
|
|
3
3
|
<v-row year-list>
|
|
4
4
|
<span
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
5
|
+
v-if="endYear && years && !years.includes(endYear)"
|
|
6
|
+
:class="'clickable-year ' + focus(endYear)"
|
|
7
|
+
@click="$emit('input', endYear)"
|
|
8
|
+
style="padding: 0 10px"
|
|
9
9
|
>
|
|
10
10
|
<v-col>
|
|
11
11
|
<v-row>{{ endYear }}</v-row>
|
|
12
12
|
</v-col>
|
|
13
13
|
</span>
|
|
14
14
|
<span
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
15
|
+
v-if="years && !years.includes(currentYear)"
|
|
16
|
+
:class="'clickable-year ' + focus(currentYear)"
|
|
17
|
+
@click="$emit('input', currentYear)"
|
|
18
|
+
style="padding: 0 10px"
|
|
19
19
|
>
|
|
20
20
|
<v-col>
|
|
21
21
|
<v-row>{{ currentYear }}</v-row>
|
|
@@ -43,7 +43,6 @@ export default {
|
|
|
43
43
|
name: "years-component",
|
|
44
44
|
|
|
45
45
|
props: {
|
|
46
|
-
|
|
47
46
|
// Value of the year : initialized in parent component campaign-product-block by v-model in <years-component v-model="year" ...> equivalent to <years-component :value="year" @input="year = $event" ...>
|
|
48
47
|
value: {
|
|
49
48
|
type: String,
|
|
@@ -69,14 +68,13 @@ export default {
|
|
|
69
68
|
type: Boolean,
|
|
70
69
|
required: true
|
|
71
70
|
}
|
|
72
|
-
|
|
73
71
|
},
|
|
74
72
|
|
|
75
73
|
data: () => ({
|
|
76
74
|
searchResult: [],
|
|
77
75
|
hasData: false,
|
|
78
76
|
positionLastAvailableDay: false,
|
|
79
|
-
endYear:
|
|
77
|
+
endYear: ""
|
|
80
78
|
}),
|
|
81
79
|
|
|
82
80
|
computed: {
|
|
@@ -84,7 +82,9 @@ export default {
|
|
|
84
82
|
if (this.searchResult) {
|
|
85
83
|
return this.searchResult.map((item) => {
|
|
86
84
|
if (item.date) {
|
|
87
|
-
return
|
|
85
|
+
return (
|
|
86
|
+
dateToSpecificTimeZone(new Date(item.date)).getFullYear() + ""
|
|
87
|
+
);
|
|
88
88
|
}
|
|
89
89
|
return null;
|
|
90
90
|
});
|
|
@@ -97,24 +97,29 @@ export default {
|
|
|
97
97
|
},
|
|
98
98
|
|
|
99
99
|
created() {
|
|
100
|
-
|
|
100
|
+
if (typeof window !== "undefined") {
|
|
101
|
+
this.initializeData();
|
|
102
|
+
}
|
|
101
103
|
},
|
|
102
104
|
|
|
103
105
|
methods: {
|
|
104
|
-
|
|
105
106
|
async initializeData() {
|
|
106
107
|
// Start by setting hasData to false by default
|
|
107
108
|
this.hasData = false;
|
|
108
109
|
// If the user has chosen to position the last available day for all products (cf. component setting-available-data.vue), then we have to get the boolean value of attribut positionLastAvailableDay of the current product in database
|
|
109
110
|
if (this.positionLastAvailableDayForAllProducts === false) {
|
|
110
111
|
// Initialize positionLastAvailableDay with the awaited result of the async method
|
|
111
|
-
this.positionLastAvailableDay =
|
|
112
|
+
this.positionLastAvailableDay =
|
|
113
|
+
await this.getPositionLastAvailableDay();
|
|
112
114
|
} else {
|
|
113
115
|
this.positionLastAvailableDay = true; // If the user has chosen to position the last available day for all products, then we set positionLastAvailableDay to true
|
|
114
116
|
}
|
|
115
117
|
|
|
116
118
|
// Emit the positionLastAvailableDay value to the parent component
|
|
117
|
-
this.$emit(
|
|
119
|
+
this.$emit(
|
|
120
|
+
"positionLastAvailableDayTriggered",
|
|
121
|
+
this.positionLastAvailableDay
|
|
122
|
+
);
|
|
118
123
|
|
|
119
124
|
// Call loadAvaiability to get the searchResult and compute hasData and emit it to the parent component through the 'hasDataTriggered' event internally
|
|
120
125
|
this.loadAvaiability();
|
|
@@ -152,20 +157,24 @@ export default {
|
|
|
152
157
|
// Now that searchResult is initialized, compute hasData
|
|
153
158
|
self.hasData = self.computeHasData();
|
|
154
159
|
// Emit the hasData value to the parent component
|
|
155
|
-
self.$emit(
|
|
160
|
+
self.$emit("hasDataTriggered", self.hasData);
|
|
156
161
|
|
|
157
162
|
if (!self.value) {
|
|
158
163
|
if (response.data.endYear) {
|
|
159
164
|
this.endYear = response.data.endYear.toString();
|
|
160
|
-
this.positionLastAvailableDay && this.hasData
|
|
165
|
+
this.positionLastAvailableDay && this.hasData
|
|
166
|
+
? self.goToLastYear()
|
|
167
|
+
: self.goToCurrentYear();
|
|
161
168
|
} else {
|
|
162
|
-
this.positionLastAvailableDay && this.hasData
|
|
169
|
+
this.positionLastAvailableDay && this.hasData
|
|
170
|
+
? self.goToLastYear()
|
|
171
|
+
: self.goToCurrentYear();
|
|
163
172
|
}
|
|
164
173
|
}
|
|
165
174
|
} else {
|
|
166
175
|
self.searchResult = [];
|
|
167
176
|
// Emit false since there's no data
|
|
168
|
-
self.$emit(
|
|
177
|
+
self.$emit("hasDataTriggered", false);
|
|
169
178
|
self.goToCurrentYear();
|
|
170
179
|
}
|
|
171
180
|
})
|
|
@@ -190,7 +199,9 @@ export default {
|
|
|
190
199
|
|
|
191
200
|
goToYear(year) {
|
|
192
201
|
if (this.isNumeric(year)) {
|
|
193
|
-
this.$emit(
|
|
202
|
+
this.$emit(
|
|
203
|
+
"input",
|
|
204
|
+
dateToSpecificTimeZone(new Date(year + "")).getFullYear() + ""
|
|
194
205
|
);
|
|
195
206
|
} else {
|
|
196
207
|
this.goToCurrentYear();
|
|
@@ -198,7 +209,10 @@ export default {
|
|
|
198
209
|
},
|
|
199
210
|
|
|
200
211
|
goToCurrentYear() {
|
|
201
|
-
this.$emit(
|
|
212
|
+
this.$emit(
|
|
213
|
+
"input",
|
|
214
|
+
dateToSpecificTimeZone(new Date()).getFullYear() + ""
|
|
215
|
+
);
|
|
202
216
|
},
|
|
203
217
|
|
|
204
218
|
focus(n) {
|
|
@@ -247,10 +261,11 @@ export default {
|
|
|
247
261
|
*/
|
|
248
262
|
async getPositionLastAvailableDay() {
|
|
249
263
|
try {
|
|
250
|
-
|
|
251
|
-
|
|
264
|
+
const currentProduct = await this.loadProduct();
|
|
265
|
+
return currentProduct ? currentProduct.positionLastAvailableDay : false;
|
|
252
266
|
} catch (error) {
|
|
253
267
|
// Handle error, e.g., by returning false or re-throwing the error
|
|
268
|
+
console.error(error);
|
|
254
269
|
return false;
|
|
255
270
|
}
|
|
256
271
|
},
|
|
@@ -261,25 +276,30 @@ export default {
|
|
|
261
276
|
this.loading = true;
|
|
262
277
|
const self = this;
|
|
263
278
|
this.axios
|
|
264
|
-
|
|
265
|
-
.
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
279
|
+
.get(
|
|
280
|
+
process.env.VUE_APP_CAMPAIGNS_SERVICE +
|
|
281
|
+
"/inputproduct/v1_0/get/" +
|
|
282
|
+
this.campaign +
|
|
283
|
+
"/" +
|
|
284
|
+
this.product
|
|
285
|
+
)
|
|
286
|
+
.then(function (response) {
|
|
287
|
+
const product = response.data;
|
|
288
|
+
resolve(product); // Resolve the promise with the product
|
|
289
|
+
})
|
|
290
|
+
.catch(function (error) {
|
|
291
|
+
console.error("Error loading product:", error);
|
|
292
|
+
reject(error); // Reject the promise if there's an error
|
|
293
|
+
})
|
|
294
|
+
.finally(function () {
|
|
295
|
+
self.loading = false;
|
|
296
|
+
});
|
|
276
297
|
} else {
|
|
277
298
|
console.error("Error: campaign or product is not defined");
|
|
278
299
|
reject(new Error("Campaign or product is not defined"));
|
|
279
300
|
}
|
|
280
301
|
});
|
|
281
|
-
}
|
|
282
|
-
|
|
302
|
+
}
|
|
283
303
|
}
|
|
284
304
|
};
|
|
285
305
|
</script>
|
package/src/utils.js
CHANGED
|
@@ -1,9 +1,11 @@
|
|
|
1
1
|
export function setThemeFromWordpress(vueInstance) {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
2
|
+
if (typeof document !== "undefined") {
|
|
3
|
+
const wpThemeColor = getComputedStyle(
|
|
4
|
+
document.documentElement
|
|
5
|
+
).getPropertyValue("--theme-color");
|
|
6
|
+
const primaryColor = wpThemeColor || "#3f51b5";
|
|
7
|
+
vueInstance.$vuetify.theme.themes.light.primary = primaryColor;
|
|
8
|
+
}
|
|
7
9
|
}
|
|
8
10
|
|
|
9
11
|
export function dateToSpecificTimeZone(date) {
|