Skip to content

Commit 03b64f7

Browse files
authored
Merge pull request #20 from PinoutLTD/dev
merge upstream
2 parents f61676a + c2b39b2 commit 03b64f7

File tree

8 files changed

+150
-95
lines changed

8 files changed

+150
-95
lines changed

src/components/Map.vue

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
:canHistory="historyready"
66
@history="historyhandler"
77
:measuretype="measuretype"
8+
:isLoad="isLoad"
89
>
910

1011
<button
@@ -36,7 +37,7 @@ import { getTypeProvider } from "../utils/utils";
3637
3738
export default {
3839
emits: ["city", "clickMarker", "close"],
39-
props: ["measuretype", "historyready", "historyhandler"],
40+
props: ["measuretype", "historyready", "historyhandler", "isLoad"],
4041
components: { Footer },
4142
data() {
4243
return {
@@ -126,7 +127,7 @@ export default {
126127
opengeotip(msg) {
127128
128129
this.closegeotip();
129-
130+
130131
this.geomsg = msg;
131132
this.geomsgopened = true;
132133
@@ -139,7 +140,7 @@ export default {
139140
getlocalmappos() {
140141
// console.log("Geolocation setting up default values");
141142
const lastsettings = localStorage.getItem("map-position") || JSON.stringify({"lat": config.MAP.position.lat, "lng": config.MAP.position.lng, "zoom": config.MAP.zoom });
142-
const savelocally = true;
143+
let savelocally = true;
143144
144145
/* We don't need to save position loacally if there is set from config */
145146
if(!localStorage.getItem("map-position")) {
@@ -206,7 +207,7 @@ export default {
206207
this.geoavailable = false;
207208
reject("Geolocation is not available");
208209
}
209-
210+
210211
});
211212
},
212213
@@ -227,7 +228,7 @@ export default {
227228
228229
async loadMap() {
229230
this.geoisloading = false;
230-
231+
231232
this.map = init([this.lat, this.lng], this.zoom, this.theme);
232233
this.relocatemap(this.lat, this.lng, this.zoom, "reload");
233234
@@ -313,7 +314,7 @@ export default {
313314
this.loadMap();
314315
});
315316
/* - Operate with a map */
316-
317+
317318
},
318319
};
319320
</script>
@@ -454,8 +455,8 @@ export default {
454455
455456
.popoovergeo-tip:after {
456457
content: "";
457-
width: 0;
458-
height: 0;
458+
width: 0;
459+
height: 0;
459460
border-left: 10px solid transparent;
460461
border-right: 10px solid transparent;
461462
border-top: 10px solid color-mix(in srgb, var(--color-dark) 70%, transparent);

src/components/footer/Footer.vue

Lines changed: 75 additions & 65 deletions
Original file line numberDiff line numberDiff line change
@@ -1,46 +1,59 @@
11
<template>
22
<div class="mapcontrols">
3-
<!-- <div style="display:none">{{bufer}}</div> -->
3+
<!-- <div style="display:none">{{bufer}}</div> -->
44
<div class="flexline">
5-
65
<div id="bookmarks" class="popover-bottom-left popover" popover>
7-
<h3>{{$t("bookmarks.listtitle")}}</h3>
6+
<h3>{{ $t("bookmarks.listtitle") }}</h3>
87
<Bookmarks />
98
</div>
10-
<button class="popovercontrol" :class="bookmarks && bookmarks.length > 0 ? 'active' : null" popovertarget="bookmarks"><font-awesome-icon icon="fa-solid fa-bookmark" /></button>
11-
12-
<input
13-
type="date"
14-
v-model="start"
15-
:max="maxDate"
16-
:disabled="currentProvider == 'realtime'"
9+
<button
10+
class="popovercontrol"
11+
:class="bookmarks && bookmarks.length > 0 ? 'active' : null"
12+
popovertarget="bookmarks"
13+
>
14+
<font-awesome-icon icon="fa-solid fa-bookmark" />
15+
</button>
16+
17+
<input type="date" v-model="start" :max="maxDate" :disabled="currentProvider == 'realtime'" />
18+
19+
<Measures
20+
:startTime="startTimestamp"
21+
:endTime="endTimestamp"
22+
:current="measuretype.toLowerCase()"
1723
/>
18-
19-
<Measures :current="measuretype.toLowerCase()" />
24+
<div v-if="isLoad">{{ $t("isLoad") }}</div>
2025
</div>
2126

2227
<div class="flexline">
2328
<div id="mapsettings" class="popover-bottom-right popover" popover>
2429
<section>
2530
<input id="realtime" v-model="realtime" type="checkbox" :checked="realtime" />
26-
<label for="realtime">{{$t('provider.realtime')}}</label>
31+
<label for="realtime">{{ $t("provider.realtime") }}</label>
2732
</section>
2833
<section>
29-
<input id="wind" v-model="wind" type="checkbox" :disabled="!realtime" :checked="wind && realtime" />
30-
<label for="wind">{{$t('layer.wind')}}</label>
34+
<input
35+
id="wind"
36+
v-model="wind"
37+
type="checkbox"
38+
:disabled="!realtime"
39+
:checked="wind && realtime"
40+
/>
41+
<label for="wind">{{ $t("layer.wind") }}</label>
3142
</section>
3243
<section>
3344
<input id="messages" v-model="messages" type="checkbox" :checked="messages" />
34-
<label for="messages">{{$t('layer.messages')}}</label>
45+
<label for="messages">{{ $t("layer.messages") }}</label>
3546
</section>
36-
<hr/>
47+
<hr />
3748
<section>
38-
<h3>{{$t("history.title")}}</h3>
49+
<h3>{{ $t("history.title") }}</h3>
3950
<HistoryImport />
4051
</section>
4152
</div>
42-
<button class="popovercontrol" popovertarget="mapsettings"><font-awesome-icon icon="fa-solid fa-gear" /></button>
43-
<slot/>
53+
<button class="popovercontrol" popovertarget="mapsettings">
54+
<font-awesome-icon icon="fa-solid fa-gear" />
55+
</button>
56+
<slot />
4457
</div>
4558
</div>
4659
</template>
@@ -58,7 +71,7 @@ import Bookmarks from "../../components/Bookmarks.vue";
5871
5972
export default {
6073
emits: ["history"],
61-
props: ["currentProvider", "canHistory", "measuretype"],
74+
props: ["currentProvider", "canHistory", "measuretype", "isLoad"],
6275
components: { HistoryImport, Measures, Bookmarks },
6376
6477
data() {
@@ -77,18 +90,14 @@ export default {
7790
},
7891
computed: {
7992
startTimestamp: function () {
80-
return Number(
81-
moment(this.start + " 00:00:00", "YYYY-MM-DD HH:mm:ss").format("X")
82-
);
93+
return Number(moment(this.start + " 00:00:00", "YYYY-MM-DD HH:mm:ss").format("X"));
8394
},
8495
endTimestamp: function () {
85-
return Number(
86-
moment(this.start + " 23:59:59", "YYYY-MM-DD HH:mm:ss").format("X")
87-
);
96+
return Number(moment(this.start + " 23:59:59", "YYYY-MM-DD HH:mm:ss").format("X"));
8897
},
89-
bookmarks: function() {
98+
bookmarks: function () {
9099
return this.store.idbBookmarks;
91-
}
100+
},
92101
},
93102
watch: {
94103
async realtime(v) {
@@ -139,43 +148,44 @@ export default {
139148
</script>
140149

141150
<style scoped>
142-
.mapcontrols {
143-
bottom: 0;
144-
box-sizing: border-box;
145-
display: flex;
146-
justify-content: space-between;
147-
left: 0;
148-
padding: 0 var(--app-controlsgap) var(--app-controlsgap);
149-
position: absolute;
150-
right: 0;
151-
z-index: 12;
152-
pointer-events: none;
153-
}
154-
155-
.mapcontrols > * {
156-
pointer-events: all;
157-
}
158-
159-
.popover-bottom-right, .popover-bottom-left {
160-
bottom: calc(var(--app-inputheight) + var(--app-controlsgap) * 2);
161-
max-width: calc(100vw - var(--app-controlsgap) * 2);
162-
}
163-
164-
.popover-bottom-right {
165-
right: var(--app-controlsgap);
166-
}
167-
168-
.popover-bottom-left {
169-
left: var(--app-controlsgap);
170-
}
151+
.mapcontrols {
152+
bottom: 0;
153+
box-sizing: border-box;
154+
display: flex;
155+
justify-content: space-between;
156+
left: 0;
157+
padding: 0 var(--app-controlsgap) var(--app-controlsgap);
158+
position: absolute;
159+
right: 0;
160+
z-index: 12;
161+
pointer-events: none;
162+
}
163+
164+
.mapcontrols > * {
165+
pointer-events: all;
166+
}
167+
168+
.popover-bottom-right,
169+
.popover-bottom-left {
170+
bottom: calc(var(--app-inputheight) + var(--app-controlsgap) * 2);
171+
max-width: calc(100vw - var(--app-controlsgap) * 2);
172+
}
173+
174+
.popover-bottom-right {
175+
right: var(--app-controlsgap);
176+
}
177+
178+
.popover-bottom-left {
179+
left: var(--app-controlsgap);
180+
}
171181
</style>
172182

173183
<style>
174-
.popovercontrol.active {
175-
border-color: var(--color-green);
176-
}
184+
.popovercontrol.active {
185+
border-color: var(--color-green);
186+
}
177187
178-
.popovercontrol.active path {
179-
fill: var(--color-green) !important;
180-
}
181-
</style>
188+
.popovercontrol.active path {
189+
fill: var(--color-green) !important;
190+
}
191+
</style>

src/components/measures/Measures.vue

Lines changed: 20 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<template>
22
<select v-model="type" v-if="store.sensors.length > 0">
33
<option v-for="opt in availableoptions" :key="opt.value" :value="opt.value">
4-
{{ opt.name }}
4+
{{ opt.name }}
55
<!-- - {{locale}} -->
66
</option>
77
</select>
@@ -11,36 +11,42 @@
1111
import { useStore } from "@/store";
1212
import measurements from "../../measurements";
1313
import { getTypeProvider } from "../../utils/utils";
14+
import { Remote } from "../../providers";
1415
1516
export default {
16-
props: ["current"],
17+
props: ["current", "startTime", "endTime"],
1718
data() {
1819
return {
1920
type: this.current,
2021
measurements: Object.entries(measurements),
2122
store: useStore(),
23+
availableunits: [{ name: "PM10", value: "pm10" }],
2224
};
2325
},
26+
async mounted() {
27+
try {
28+
const array = await Remote.getMeasurements(this.startTime, this.endTime);
29+
const toMove = ["pm10", "pm25"];
30+
const movedElements = array.filter((item) => toMove.includes(item));
31+
const remainingElements = array.filter((item) => !toMove.includes(item));
32+
this.availableunits = [...movedElements, ...remainingElements];
33+
} catch (error) {
34+
console.log(error);
35+
}
36+
},
2437
computed: {
2538
locale() {
2639
return localStorage.getItem("locale") || this.$i18n.locale || "en";
2740
},
28-
availableunits() {
29-
let bufer = [];
30-
this.store.sensors.forEach((i) => {
31-
Object.keys(i.data).forEach((units) => {
32-
bufer.push(units.toLowerCase());
33-
});
34-
});
35-
return [...new Set(bufer)];
36-
},
3741
availableoptions() {
3842
let buffer = [];
3943
this.availableunits.forEach((i) => {
4044
if (measurements[i]) {
41-
buffer.push({
42-
name: measurements[i]?.nameshort ? measurements[i].nameshort[this.locale] : measurements[i]?.label,
43-
value: i
45+
buffer.push({
46+
name: measurements[i]?.nameshort
47+
? measurements[i].nameshort[this.locale]
48+
: measurements[i]?.label,
49+
value: i,
4450
});
4551
}
4652
});

src/components/sensor/Chart.vue

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
import Highcharts from "highcharts";
77
import { Chart } from "highcharts-vue";
88
import stockInit from "highcharts/modules/stock";
9+
import config from "../../config";
910
import unitsettings from "../../measurements";
1011
1112
Highcharts.seriesTypes.spline.prototype.drawLegendSymbol = function (legend, item) {
@@ -44,11 +45,23 @@ export default {
4445
name: keyname,
4546
data: [[item.timestamp * 1000, parseFloat(item.data[keyname])]],
4647
zones: unitsettingsLowerCase[keyname]?.zones,
48+
visible: true,
49+
dataGrouping: {
50+
enabled: false,
51+
},
4752
});
4853
}
4954
}
5055
}
5156
}
57+
for (const measurement of result) {
58+
if (measurement.data.length > config.SERIES_MAX_VISIBLE) {
59+
measurement.visible = false;
60+
measurement.dataGrouping = {
61+
approximation: "high",
62+
};
63+
}
64+
}
5265
return result;
5366
},
5467
@@ -135,6 +148,14 @@ export default {
135148
tooltip: {
136149
valueDecimals: 2,
137150
},
151+
plotOptions: {
152+
series: {
153+
dataGrouping: {
154+
enabled: true,
155+
units: [["minute", [5]]],
156+
},
157+
},
158+
},
138159
// plotOptions: {
139160
// series: {
140161
// lineWidth: 2,

0 commit comments

Comments
 (0)