Refactor dashboard layout and update sensor table columns

- Make metric cards and charts more compact and consistent - Change
SensorConsumptionTable columns: show Room and Value, remove
Current/Total/Average - Update headings and layout for AnalyticsView and
HomeView - Improve responsiveness and spacing for cards and sections
This commit is contained in:
rafaeldpsilva
2025-10-03 15:06:34 +01:00
parent 3ecd0ab2c4
commit 9a25170b27
5 changed files with 307 additions and 333 deletions

View File

@@ -1,5 +1,5 @@
<template> <template>
<div class="bg-white rounded-2xl shadow-sm flex flex-col justify-between h-full w-full p-4"> <div class="bg-white rounded-2xl shadow-sm flex flex-col justify-between aspect-square p-4">
<h6 class="text-sm font-bold text-gray-500">{{ title }}</h6> <h6 class="text-sm font-bold text-gray-500">{{ title }}</h6>
<div class="flex-grow flex items-center justify-start"> <div class="flex-grow flex items-center justify-start">
<p class="text-gray-900 font-bold text-2xl"> <p class="text-gray-900 font-bold text-2xl">

View File

@@ -1,8 +1,8 @@
<template> <template>
<div class="bg-white rounded-2xl shadow-sm flex flex-col h-full min-h-[300px]"> <div class="bg-white rounded-2xl shadow-sm flex flex-col p-4">
<div class="p-4 h-full">
<h6 class="text-sm font-bold text-gray-500 mb-2">{{ title }}</h6> <h6 class="text-sm font-bold text-gray-500 mb-2">{{ title }}</h6>
<v-chart class="h-64 w-full" :option="option" autoresize /> <div class="w-full h-[400px]">
<v-chart class="w-full h-full" :option="option" autoresize />
</div> </div>
</div> </div>
</template> </template>

View File

@@ -1,7 +1,6 @@
<template> <template>
<div class="bg-white rounded-2xl shadow-sm p-4"> <div class="bg-white rounded-2xl shadow-sm p-4">
<h6 class="text-sm font-bold text-gray-500 mb-4">Sensor Consumption</h6> <h6 class="text-sm font-bold text-gray-500 mb-4">Sensor Readings</h6>
<div class="overflow-x-auto"> <div class="overflow-x-auto">
<table class="min-w-full"> <table class="min-w-full">
<thead> <thead>
@@ -10,13 +9,10 @@
Sensor ID Sensor ID
</th> </th>
<th class="text-right text-xs font-medium text-gray-500 uppercase tracking-wider py-3"> <th class="text-right text-xs font-medium text-gray-500 uppercase tracking-wider py-3">
Current Room
</th> </th>
<th class="text-right text-xs font-medium text-gray-500 uppercase tracking-wider py-3"> <th class="text-right text-xs font-medium text-gray-500 uppercase tracking-wider py-3">
Total Value
</th>
<th class="text-right text-xs font-medium text-gray-500 uppercase tracking-wider py-3">
Average
</th> </th>
<th class="text-right text-xs font-medium text-gray-500 uppercase tracking-wider py-3"> <th class="text-right text-xs font-medium text-gray-500 uppercase tracking-wider py-3">
Last Updated Last Updated
@@ -55,9 +51,6 @@
sensor.humidity?.unit sensor.humidity?.unit
}} }}
</td> </td>
<td class="py-3 text-sm text-gray-600 text-right">
{{ sensor.room }}
</td>
<td class="py-3 text-sm text-gray-500 text-right"> <td class="py-3 text-sm text-gray-500 text-right">
{{ formatTime(sensor.timestamp) }} {{ formatTime(sensor.timestamp) }}
</td> </td>
@@ -66,7 +59,6 @@
</table> </table>
</div> </div>
<!-- Connection Status Indicator -->
<div class="mt-4 flex items-center justify-between text-xs text-gray-500"> <div class="mt-4 flex items-center justify-between text-xs text-gray-500">
<div class="flex items-center gap-2"> <div class="flex items-center gap-2">
<div <div

View File

@@ -1,12 +1,15 @@
<template> <template>
<div class="min-h-screen bg-gray-50"> <div class="space-y-6">
<div class="px-4 py-6 mx-auto max-w-7xl sm:px-6 lg:px-8"> <div class="flex flex-col sm:flex-row sm:items-center sm:justify-between">
<div>
<h1 class="text-2xl font-bold text-gray-900">Analytics</h1>
<p class="text-gray-600">Manage sensors, assign rooms, and control device actions</p>
</div>
</div>
<div class="mb-8"> <div class="mb-8">
<h1 class="text-3xl font-bold text-gray-900">API Dashboard</h1> <h1 class="text-3xl font-bold text-gray-900">API Dashboard</h1>
<p class="text-gray-600 mt-2">Real-time data from backend APIs</p> <p class="text-gray-600 mt-2">Real-time data from backend APIs</p>
</div> </div>
<!-- API Status Section -->
<div class="grid grid-cols-1 md:grid-cols-2 lg:grid-cols-4 gap-4 mb-8"> <div class="grid grid-cols-1 md:grid-cols-2 lg:grid-cols-4 gap-4 mb-8">
<div class="bg-white rounded-lg shadow p-6"> <div class="bg-white rounded-lg shadow p-6">
<div class="flex items-center"> <div class="flex items-center">
@@ -301,7 +304,6 @@
</div> </div>
</div> </div>
</div> </div>
</div>
</template> </template>
<script setup lang="ts"> <script setup lang="ts">

View File

@@ -1,29 +1,13 @@
<template> <template>
<div class="grid grid-cols-1 lg:grid-cols-2 gap-6 pb-20">
<div class="space-y-6"> <div class="space-y-6">
<!-- Filter Controls Row --> <div class="grid grid-cols-2 sm:grid-cols-3 gap-4">
<!--div class="flex flex-col sm:flex-row gap-4 mb-6">
<select class="px-4 py-2 border border-gray-200 rounded-lg bg-white">
<option>Timeframe: All-time</option>
</select>
<select class="px-4 py-2 border border-gray-200 rounded-lg bg-white">
<option>People: All</option>
</select>
<select class="px-4 py-2 border border-gray-200 rounded-lg bg-white">
<option>Topic: All</option>
</select>
</div-->
<!-- Top Metric Cards Row -->
<div class="grid grid-cols-1 lg:grid-cols-2 gap-4 min-h-96">
<div class="grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-3 gap-x-4 gap-y-3">
<MetricCard title="Current Energy" :content="currentEnergyValue" details="kWh" /> <MetricCard title="Current Energy" :content="currentEnergyValue" details="kWh" />
<MetricCard title="Average Usage" :content="averageEnergyUsage" details="kWh" />
<MetricCard <MetricCard
title="Connection Status" title="Connection Status"
:content="websocketStore.isConnected ? 'Connected' : 'Disconnected'" :content="websocketStore.isConnected ? 'Connected' : 'Disconnected'"
/> />
<MetricCard title="Average Usage" :content="averageEnergyUsage" details="kWh" />
<MetricCard title="Average CO2" :content="averageCO2" details="ppm" />
<MetricCard title="Max CO2" :content="maxCO2" details="ppm" />
<GraphMetricCard <GraphMetricCard
title="Real-time Energy" title="Real-time Energy"
:content="currentEnergyValue" :content="currentEnergyValue"
@@ -31,21 +15,18 @@
:trend-data="energyStore.energyHistory.slice(-8)" :trend-data="energyStore.energyHistory.slice(-8)"
trend-direction="neutral" trend-direction="neutral"
/> />
<GraphMetricCard title="Average CO2" :content="averageCO2" details="ppm" />
<GraphMetricCard title="Max CO2" :content="maxCO2" details="ppm" />
</div> </div>
<div> <SensorConsumptionTable />
<RealtimeEnergyChartCard title="Month" />
</div>
</div> </div>
<!-- Charts and Knowledge Cards Row --> <div class="space-y-6">
<div class="grid grid-cols-1 lg:grid-cols-2 gap-4"> <RealtimeEnergyChartCard title="Month" />
<SensorConsumptionTable />
<div class="grid grid-cols-1 gap-4">
<RoomMetricsCard /> <RoomMetricsCard />
<AirQualityCard /> <AirQualityCard />
</div> </div>
</div> </div>
</div>
</template> </template>
<script setup lang="ts"> <script setup lang="ts">
@@ -66,7 +47,6 @@ const sensorStore = useSensorStore()
const websocketStore = useWebSocketStore() const websocketStore = useWebSocketStore()
const settingsStore = useSettingsStore() const settingsStore = useSettingsStore()
// Use energy store for aggregated values across all sensors
const currentEnergyValue = computed(() => { const currentEnergyValue = computed(() => {
return energyStore.currentEnergyValue.toFixed(2) return energyStore.currentEnergyValue.toFixed(2)
}) })