Skip to content

Commit cb065c9

Browse files
committed
loading measurements for footer
1 parent a7367f9 commit cb065c9

File tree

3 files changed

+91
-77
lines changed

3 files changed

+91
-77
lines changed

src/components/footer/Footer.vue

Lines changed: 71 additions & 57 deletions
Original file line numberDiff line numberDiff line change
@@ -1,42 +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>
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>
1116

1217
<input type="date" v-model="start" :max="maxDate" :disabled="currentProvider == 'realtime'" />
1318

14-
<Measures :current="measuretype.toLowerCase()" />
19+
<Measures
20+
:startTime="startTimestamp"
21+
:endTime="endTimestamp"
22+
:current="measuretype.toLowerCase()"
23+
/>
1524
<div v-if="isLoad">{{ $t("isLoad") }}</div>
1625
</div>
1726

1827
<div class="flexline">
1928
<div id="mapsettings" class="popover-bottom-right popover" popover>
2029
<section>
2130
<input id="realtime" v-model="realtime" type="checkbox" :checked="realtime" />
22-
<label for="realtime">{{$t('provider.realtime')}}</label>
31+
<label for="realtime">{{ $t("provider.realtime") }}</label>
2332
</section>
2433
<section>
25-
<input id="wind" v-model="wind" type="checkbox" :disabled="!realtime" :checked="wind && realtime" />
26-
<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>
2742
</section>
2843
<section>
2944
<input id="messages" v-model="messages" type="checkbox" :checked="messages" />
30-
<label for="messages">{{$t('layer.messages')}}</label>
45+
<label for="messages">{{ $t("layer.messages") }}</label>
3146
</section>
32-
<hr/>
47+
<hr />
3348
<section>
34-
<h3>{{$t("history.title")}}</h3>
49+
<h3>{{ $t("history.title") }}</h3>
3550
<HistoryImport />
3651
</section>
3752
</div>
38-
<button class="popovercontrol" popovertarget="mapsettings"><font-awesome-icon icon="fa-solid fa-gear" /></button>
39-
<slot/>
53+
<button class="popovercontrol" popovertarget="mapsettings">
54+
<font-awesome-icon icon="fa-solid fa-gear" />
55+
</button>
56+
<slot />
4057
</div>
4158
</div>
4259
</template>
@@ -73,18 +90,14 @@ export default {
7390
},
7491
computed: {
7592
startTimestamp: function () {
76-
return Number(
77-
moment(this.start + " 00:00:00", "YYYY-MM-DD HH:mm:ss").format("X")
78-
);
93+
return Number(moment(this.start + " 00:00:00", "YYYY-MM-DD HH:mm:ss").format("X"));
7994
},
8095
endTimestamp: function () {
81-
return Number(
82-
moment(this.start + " 23:59:59", "YYYY-MM-DD HH:mm:ss").format("X")
83-
);
96+
return Number(moment(this.start + " 23:59:59", "YYYY-MM-DD HH:mm:ss").format("X"));
8497
},
85-
bookmarks: function() {
98+
bookmarks: function () {
8699
return this.store.idbBookmarks;
87-
}
100+
},
88101
},
89102
watch: {
90103
async realtime(v) {
@@ -135,43 +148,44 @@ export default {
135148
</script>
136149

137150
<style scoped>
138-
.mapcontrols {
139-
bottom: 0;
140-
box-sizing: border-box;
141-
display: flex;
142-
justify-content: space-between;
143-
left: 0;
144-
padding: 0 var(--app-controlsgap) var(--app-controlsgap);
145-
position: absolute;
146-
right: 0;
147-
z-index: 12;
148-
pointer-events: none;
149-
}
150-
151-
.mapcontrols > * {
152-
pointer-events: all;
153-
}
154-
155-
.popover-bottom-right, .popover-bottom-left {
156-
bottom: calc(var(--app-inputheight) + var(--app-controlsgap) * 2);
157-
max-width: calc(100vw - var(--app-controlsgap) * 2);
158-
}
159-
160-
.popover-bottom-right {
161-
right: var(--app-controlsgap);
162-
}
163-
164-
.popover-bottom-left {
165-
left: var(--app-controlsgap);
166-
}
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+
}
167181
</style>
168182

169183
<style>
170-
.popovercontrol.active {
171-
border-color: var(--color-green);
172-
}
184+
.popovercontrol.active {
185+
border-color: var(--color-green);
186+
}
173187
174-
.popovercontrol.active path {
175-
fill: var(--color-green) !important;
176-
}
177-
</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/views/Main.vue

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -309,12 +309,6 @@ export default {
309309
this.providerObj = new providers.Libp2p(config.LIBP2P);
310310
}
311311
312-
const result = await providers.Remote.getMeasurements(
313-
moment().startOf("day").format("X"),
314-
moment().format("X")
315-
);
316-
console.log(result);
317-
318312
this.providerObj.ready().then(() => {
319313
this.providerReady = true;
320314
this.providerObj.watch(this.handlerNewPoint);

0 commit comments

Comments
 (0)