feat(web-app): selected user/room/device
This part allow to select from where the data from with some option - user - room - device
This commit is contained in:
@@ -14,6 +14,7 @@
|
|||||||
:show-humidity.sync="showHumidity"
|
:show-humidity.sync="showHumidity"
|
||||||
@add-temperature="addTemperature"
|
@add-temperature="addTemperature"
|
||||||
@refresh="refreshData"
|
@refresh="refreshData"
|
||||||
|
:manager="manager"
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
@@ -41,9 +42,6 @@ import { URL, USERNAME, PASSWORD, USER, ROOM, DEVICE, APP_NAME } from "./const";
|
|||||||
import { Serie } from "./Measures/Serie";
|
import { Serie } from "./Measures/Serie";
|
||||||
|
|
||||||
let httpClient = new HttpClient(URL, USERNAME, PASSWORD);
|
let httpClient = new HttpClient(URL, USERNAME, PASSWORD);
|
||||||
|
|
||||||
// console.log(httpClient.newValue(URL, USERNAME, PASSWORD));
|
|
||||||
|
|
||||||
let manager = new TimeSeriesManager(httpClient);
|
let manager = new TimeSeriesManager(httpClient);
|
||||||
|
|
||||||
export default defineComponent({
|
export default defineComponent({
|
||||||
@@ -66,6 +64,14 @@ export default defineComponent({
|
|||||||
addTemperature() {
|
addTemperature() {
|
||||||
// Implement your functionality here
|
// Implement your functionality here
|
||||||
console.log("Add temperature clicked");
|
console.log("Add temperature clicked");
|
||||||
|
manager
|
||||||
|
.getNewValue(USER, ROOM, DEVICE)
|
||||||
|
.then((result) => {})
|
||||||
|
.catch((error) => {
|
||||||
|
console.error("Error asking data:", error);
|
||||||
|
this.error = "Failed to load data. Please try again later.";
|
||||||
|
this.loading = false;
|
||||||
|
});
|
||||||
},
|
},
|
||||||
|
|
||||||
refreshData() {
|
refreshData() {
|
||||||
|
|||||||
@@ -2,10 +2,61 @@ import { Prop } from "vue";
|
|||||||
import { Serie } from "./Serie";
|
import { Serie } from "./Serie";
|
||||||
import { HttpClient } from "../Services/HttpClient";
|
import { HttpClient } from "../Services/HttpClient";
|
||||||
import { TEMPERATURE, HUMIDITY, TYPE, VALUE } from "../const";
|
import { TEMPERATURE, HUMIDITY, TYPE, VALUE } from "../const";
|
||||||
|
import { ref } from "vue";
|
||||||
|
|
||||||
export class TimeSeriesManager {
|
export class TimeSeriesManager {
|
||||||
private client: HttpClient;
|
private client: HttpClient;
|
||||||
|
|
||||||
|
selected_user = {
|
||||||
|
user: "Rémi",
|
||||||
|
tag: "remi",
|
||||||
|
};
|
||||||
|
selected_room = {
|
||||||
|
room: "Bedroom",
|
||||||
|
tag: "Bedroom",
|
||||||
|
};
|
||||||
|
selected_device = {
|
||||||
|
device: "Door sensor",
|
||||||
|
tag: "DoorSensor",
|
||||||
|
};
|
||||||
|
|
||||||
|
user_options = [
|
||||||
|
{
|
||||||
|
user: "Rémi",
|
||||||
|
tag: "remi",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
user: "Sylvan",
|
||||||
|
tag: "sylvan",
|
||||||
|
},
|
||||||
|
];
|
||||||
|
|
||||||
|
room_options = [
|
||||||
|
{
|
||||||
|
room: "23N309",
|
||||||
|
tag: "23N309",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
room: "Bedroom",
|
||||||
|
tag: "Bedroom",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
room: "Terrasse",
|
||||||
|
tag: "Terrasse",
|
||||||
|
},
|
||||||
|
];
|
||||||
|
|
||||||
|
device_options = [
|
||||||
|
{
|
||||||
|
device: "Door sensor",
|
||||||
|
tag: "DoorSensor",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
device: "Shed",
|
||||||
|
tag: "Shed",
|
||||||
|
},
|
||||||
|
];
|
||||||
|
|
||||||
constructor(client: HttpClient) {
|
constructor(client: HttpClient) {
|
||||||
this.client = client;
|
this.client = client;
|
||||||
}
|
}
|
||||||
@@ -16,7 +67,11 @@ export class TimeSeriesManager {
|
|||||||
device: string
|
device: string
|
||||||
): Promise<Serie[]> {
|
): Promise<Serie[]> {
|
||||||
return this.client
|
return this.client
|
||||||
.getValues(user, room, device)
|
.getValues(
|
||||||
|
this.selected_user.tag,
|
||||||
|
this.selected_room.tag,
|
||||||
|
this.selected_device.tag
|
||||||
|
)
|
||||||
.then((response) => {
|
.then((response) => {
|
||||||
// Filter temperature records
|
// Filter temperature records
|
||||||
let temperatureRecords = response.data.filter(
|
let temperatureRecords = response.data.filter(
|
||||||
|
|||||||
@@ -4,28 +4,61 @@
|
|||||||
Add Temperature
|
Add Temperature
|
||||||
</button>
|
</button>
|
||||||
|
|
||||||
<div class="sensor-selector">
|
|
||||||
<h3>Sensors</h3>
|
|
||||||
<div class="sensor-options">
|
|
||||||
<label class="sensor-option">
|
|
||||||
<input type="checkbox" :checked="showTemperature" />
|
|
||||||
<span>Temperature</span>
|
|
||||||
</label>
|
|
||||||
<label class="sensor-option">
|
|
||||||
<input type="checkbox" :checked="showHumidity" />
|
|
||||||
<span>Humidity</span>
|
|
||||||
</label>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<button @click="$emit('refresh')" class="refresh-button">
|
<button @click="$emit('refresh')" class="refresh-button">
|
||||||
<span class="button-icon">↻</span> Refresh Data
|
<span class="button-icon">↻</span> Refresh Data
|
||||||
</button>
|
</button>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<div>
|
||||||
|
<span>
|
||||||
|
<multiselect
|
||||||
|
id="user-select"
|
||||||
|
v-model="manager.selected_user"
|
||||||
|
:options="manager.user_options"
|
||||||
|
:multiple="false"
|
||||||
|
:group-select="false"
|
||||||
|
placeholder="User"
|
||||||
|
track-by="user"
|
||||||
|
label="user"
|
||||||
|
</multiselect>
|
||||||
|
</span>
|
||||||
|
<span>
|
||||||
|
<multiselect
|
||||||
|
id="room-select"
|
||||||
|
v-model="manager.selected_room"
|
||||||
|
:options="manager.room_options"
|
||||||
|
:multiple="false"
|
||||||
|
:group-select="false"
|
||||||
|
placeholder="Room"
|
||||||
|
track-by="room"
|
||||||
|
label="room"
|
||||||
|
</multiselect>
|
||||||
|
</span>
|
||||||
|
<span>
|
||||||
|
<multiselect
|
||||||
|
id="device-select"
|
||||||
|
v-model="manager.selected_device"
|
||||||
|
:options="manager.device_options"
|
||||||
|
:close-on-select="true"
|
||||||
|
:multiple="false"
|
||||||
|
:group-select="false"
|
||||||
|
placeholder="Device"
|
||||||
|
track-by="device"
|
||||||
|
label="device"
|
||||||
|
</multiselect>
|
||||||
|
</span>
|
||||||
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
import { defineComponent } from "vue";
|
import { defineComponent } from "vue";
|
||||||
|
import Multiselect from "vue-multiselect";
|
||||||
|
import "vue-multiselect/dist/vue-multiselect.css"; // Add
|
||||||
|
import { ref } from "vue";
|
||||||
|
import { TimeSeriesManager } from "@/Measures/TimeSeriesManager";
|
||||||
|
|
||||||
|
let options = [{ code: "CA", country: "Canada" }];
|
||||||
|
|
||||||
|
|
||||||
export default defineComponent({
|
export default defineComponent({
|
||||||
name: "ControlPanel",
|
name: "ControlPanel",
|
||||||
@@ -38,6 +71,11 @@ export default defineComponent({
|
|||||||
type: Boolean,
|
type: Boolean,
|
||||||
required: true,
|
required: true,
|
||||||
},
|
},
|
||||||
|
manager: {
|
||||||
|
type: TimeSeriesManager,
|
||||||
|
required: true,
|
||||||
|
}
|
||||||
|
|
||||||
},
|
},
|
||||||
emits: [
|
emits: [
|
||||||
"add-temperature",
|
"add-temperature",
|
||||||
@@ -46,6 +84,14 @@ export default defineComponent({
|
|||||||
"refresh",
|
"refresh",
|
||||||
"simulate-data",
|
"simulate-data",
|
||||||
],
|
],
|
||||||
|
components: {
|
||||||
|
Multiselect,
|
||||||
|
},
|
||||||
|
methods: {
|
||||||
|
setSelected(value: any) {
|
||||||
|
// trigger a mutation, or dispatch an action
|
||||||
|
},
|
||||||
|
},
|
||||||
});
|
});
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
|||||||
6
web-app/src/shims-vue.d.ts
vendored
6
web-app/src/shims-vue.d.ts
vendored
@@ -1,6 +0,0 @@
|
|||||||
/* eslint-disable */
|
|
||||||
declare module '*.vue' {
|
|
||||||
import type { DefineComponent } from 'vue'
|
|
||||||
const component: DefineComponent<{}, {}, any>
|
|
||||||
export default component
|
|
||||||
}
|
|
||||||
Reference in New Issue
Block a user