Skip to content

Commit

Permalink
Merge pull request #563 from bmesuere/feature/wbgt-frontend
Browse files Browse the repository at this point in the history
Add WBGT data to the frontend
  • Loading branch information
bmesuere authored Jul 8, 2022
2 parents 0158724 + 29aeae4 commit 7c81183
Show file tree
Hide file tree
Showing 5 changed files with 39 additions and 10 deletions.
8 changes: 8 additions & 0 deletions dashboard/src/app/weatherProperties.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,14 @@ const weatherProperties = {
icon: 'mdi-water-percent',
title: 'Luchtvochtigheid op dit moment',
unit: '%'
},
wbgt: {
property: 'wbgt',
name: 'Gevoelstemperatuur (WBGT)',
legend: 'Gevoelstemperatuur (°C)',
icon: 'mdi-thermometer-lines',
title: 'Gevoelstemperatuur (WBGT) op dit moment',
unit: '°C'
}
};

Expand Down
12 changes: 10 additions & 2 deletions dashboard/src/components/GraphCard.vue
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<template>
<v-card :loading="loading">
<v-card :loading="loading" v-show="hasData">
<v-list-item two-line>
<v-list-item-content>
<v-list-item-title class="mb-1">{{ weatherProperty.name }}</v-list-item-title>
Expand Down Expand Up @@ -46,10 +46,18 @@ export default class GraphCard extends Vue {
return this.graphId || 'weather_graph_' + this.weatherProperty.property;
}
get tooltipI () {
get tooltipI (): number {
return this.tooltipPosition.i;
}
get hasData (): boolean {
if (this.weatherProperty.property === 'wbgt') {
// return this.selectedStations.some(s => s.hasWbgt);
return this.selectedStations.some(s => s.name === 'vlinder02');
}
return true;
}
// when measurements are updated, we have to manually update the D3 map
@Watch('measurements')
measurementsChanged () {
Expand Down
13 changes: 9 additions & 4 deletions dashboard/src/components/StationCard.vue
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@
</v-list-item>

<v-list dense subheader>
<v-list-item v-for="p in weatherProperties" :key="p.property">
<v-list-item v-for="p in activeProperties" :key="p.property">
<v-list-item-subtitle :title="p.name"><v-icon class='pr-1'>{{ p.icon }}</v-icon> {{ p.name }}</v-list-item-subtitle>
<v-list-item-title class="text-right">{{ measurements['status'] == "Offline" ? "-" : measurements[p.property] }} {{ p.unit }}</v-list-item-title>
</v-list-item>
Expand All @@ -66,15 +66,13 @@
import { Vue, Component, Prop } from 'vue-property-decorator';
import LandUseGraph from './LandUseGraph.vue';
import { Station, Measurement } from '../app/types';
import { Station, Measurement, WeatherProperty } from '../app/types';
import { weatherProperties as wp } from '../app/weatherProperties';
@Component({ components: { LandUseGraph } })
export default class StationCard extends Vue {
@Prop() station!: Station;
weatherProperties = wp;
removeFromList ():void {
this.$gtag.event('station_deselect', { event_category: 'stations', value: this.station.id });
this.$store.dispatch('deselectStationById', this.station.id);
Expand All @@ -91,6 +89,13 @@ export default class StationCard extends Vue {
get measurements (): Measurement | {} {
return (this.$store.state.liveMeasurements as Measurement[]).find(m => m.id === this.station.id) || {};
}
get activeProperties (): WeatherProperty[] {
// filter the properties where the measurement is null
return Object.values(wp)
// @ts-ignore
.filter((p: WeatherProperty) => this.measurements[p.property as any] !== null);
}
}
</script>

Expand Down
13 changes: 9 additions & 4 deletions dashboard/src/components/TooltipCard.vue
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@

<v-list subheader class="px-2">
<v-row dense>
<v-col cols="6" class="pa-0" v-for="p in weatherProperties" :key="p.property">
<v-col cols="6" class="pa-0" v-for="p in activeProperties" :key="p.property">
<v-list-item dense class="px-2" style="min-height: 36px;">
<v-list-item-subtitle :title="p.name"><v-icon class='pr-1'>{{ p.icon }}</v-icon> {{ measurements['status'] == "Offline" ? "-" : measurements[p.property] }} {{ p.unit }}</v-list-item-subtitle>
</v-list-item>
Expand All @@ -33,17 +33,22 @@

<script lang="ts">
import { Vue, Component, Prop } from 'vue-property-decorator';
import { Station, Measurement } from '../app/types';
import { Station, Measurement, WeatherProperty } from '../app/types';
import { weatherProperties as wp } from '../app/weatherProperties';
@Component
export default class TooltipCard extends Vue {
@Prop() station!: Station;
weatherProperties = wp;
get measurements (): Measurement | {} {
return (this.$store.state.liveMeasurements as Measurement[]).find(m => m.id === this.station.id) || {};
}
get activeProperties (): WeatherProperty[] {
// filter the properties where the measurement is null
return Object.values(wp)
// @ts-ignore
.filter((p: WeatherProperty) => this.measurements[p.property as any] !== null);
}
}
</script>
3 changes: 3 additions & 0 deletions dashboard/src/views/Dashboard.vue
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,9 @@
<v-col cols="12" md="6" lg="4" >
<GraphCard :weatherProperty="weatherProperties.humidity" :tooltipPosition="tooltipPosition"/>
</v-col>
<v-col cols="12" md="6" lg="4" >
<GraphCard :weatherProperty="weatherProperties.wbgt" :tooltipPosition="tooltipPosition"/>
</v-col>
</v-row>
</v-container>
</template>
Expand Down

0 comments on commit 7c81183

Please sign in to comment.