Commit 948ae06e authored by Gezer's avatar Gezer
Browse files

Refactor DeviceDashboard filter implementation; replace select with button...

Refactor DeviceDashboard filter implementation; replace select with button group for improved usability and styling
parent 2f300868
...@@ -5,15 +5,20 @@ ...@@ -5,15 +5,20 @@
<p>Übersicht aller Geräte und deren Verfügbarkeit</p> <p>Übersicht aller Geräte und deren Verfügbarkeit</p>
</div> </div>
<div class="filter-bar"> <div class="filter-bar">
<label for="status-filter">Filter:</label> <span class="filter-label">Filter:</span>
<select id="status-filter" v-model="selectedFilter" @change="applyFilter"> <div class="filter-buttons">
<option value="all">Alle</option> <button
<option value="true">Verfügbar</option> v-for="option in filterOptions"
<option value="loading">Lädt...</option> :key="option.value"
<option value="false">Nicht verfügbar</option> :class="['filter-button', { active: selectedFilter === option.value }]"
</select> @click="setFilter(option.value)"
</div> >
{{ option.label }}
</button>
</div>
</div>
<div class="table-container" v-if="!loading"> <div class="table-container" v-if="!loading">
<table class="status-table"> <table class="status-table">
...@@ -25,9 +30,9 @@ ...@@ -25,9 +30,9 @@
</tr> </tr>
</thead> </thead>
<tbody> <tbody>
<tr v-for="device in filteredDevices" :key="device['mac-adress']"> <tr v-for="device in filteredDevices" :key="device.mac_address">
<td class="room-cell">{{ device.room }}</td> <td class="room-cell">{{ device.room }}</td>
<td><span class="mac-cell">{{ device['mac-adress'] }}</span></td> <td><span class="mac-cell">{{ device.mac_address }}</span></td>
<td> <td>
<div class="status-indicator"> <div class="status-indicator">
<div class="status-light" :class="getStatusClass(device.availabil)"></div> <div class="status-light" :class="getStatusClass(device.availabil)"></div>
...@@ -70,6 +75,14 @@ ...@@ -70,6 +75,14 @@
<script> <script>
export default { export default {
filterOptions: [
{ value: "all", label: "Alle" },
{ value: "true", label: "Verfügbar" },
{ value: "false", label: "Nicht verfügbar" },
],
setFilter(value) {
this.selectedFilter = value;
},
data() { data() {
return { return {
...@@ -94,23 +107,13 @@ export default { ...@@ -94,23 +107,13 @@ export default {
},}, },},
methods: { methods: {
async loadDevices() { async loadDevices() {
this.loading = true; this.loading = true;
try { try {
// ✨ Beispielgeräte (verschiedene Räume & Stati) const response = await fetch("/api/sensors/all_room_sensors_availability");
const data = [ const result = await response.json();
{ "mac-adress": "00:11:22:33:44:01", room: "Büro A", availabil: "true" }, this.devices = result.sensors;
{ "mac-adress": "00:11:22:33:44:02", room: "Büro B", availabil: "false" },
{ "mac-adress": "00:11:22:33:44:03", room: "Lager", availabil: "loading" },
{ "mac-adress": "00:11:22:33:44:04", room: "Küche", availabil: "true" },
{ "mac-adress": "00:11:22:33:44:05", room: "Serverraum", availabil: "false" },
{ "mac-adress": "00:11:22:33:44:06", room: "Eingang", availabil: "loading" },
{ "mac-adress": "00:11:22:33:44:07", room: "Konferenz 1", availabil: "true" },
{ "mac-adress": "00:11:22:33:44:08", room: "Konferenz 2", availabil: "false" }
];
await new Promise(resolve => setTimeout(resolve, 500)); // künstliche Ladezeit
this.devices = data;
} catch (err) { } catch (err) {
console.error('Mock-Daten-Fehler:', err); console.error("Fehler beim Laden der Gerätedaten:", err);
this.devices = []; this.devices = [];
} finally { } finally {
this.loading = false; this.loading = false;
...@@ -145,10 +148,6 @@ async refreshData() { ...@@ -145,10 +148,6 @@ async refreshData() {
mounted() { mounted() {
this.loadDevices(); this.loadDevices();
}, },
}; };
</script> </script>
...@@ -352,4 +351,43 @@ async refreshData() { ...@@ -352,4 +351,43 @@ async refreshData() {
align-items: stretch; align-items: stretch;
} }
} }
.filter-bar {
display: flex;
align-items: center;
padding: 20px 30px;
gap: 10px;
flex-wrap: wrap;
}
.filter-label {
font-weight: bold;
font-size: 1rem;
color: #2c3e50;
}
.filter-buttons {
display: flex;
gap: 10px;
}
.filter-button {
background: #ecf0f1;
border: none;
padding: 8px 16px;
border-radius: 30px;
cursor: pointer;
font-weight: 500;
transition: all 0.2s ease;
color: #2c3e50;
}
.filter-button:hover {
background: #d0dce3;
}
.filter-button.active {
background: linear-gradient(135deg, #3498db 0%, #2980b9 100%);
color: white;
}
</style> </style>
\ No newline at end of file
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment