Skip to content

Commit

Permalink
Fixes to emulator and dashboard
Browse files Browse the repository at this point in the history
  • Loading branch information
srgtuszy committed Oct 28, 2024
1 parent be2ffec commit 09ea4f9
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 4 deletions.
4 changes: 2 additions & 2 deletions dashboard/hotel-dashboard/components/hotel-dashboard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -210,13 +210,13 @@ export function HotelDashboard() {
<TableCell>
<div className="flex items-center gap-2">
<span>{room?.energy || 0} W</span>
<TinyLineChart data={room?.hourlyEnergy || []} color="chart-1" />
<TinyLineChart data={room?.hourlyEnergy.slice(-10) || []} color="chart-1" />
</div>
</TableCell>
<TableCell>
<div className="flex items-center gap-2">
<span>{room?.water || 0} L</span>
<TinyLineChart data={room?.hourlyWater || []} color="chart-2" />
<TinyLineChart data={room?.hourlyWater.slice(-10) || []} color="chart-2" />
</div>
</TableCell>
</TableRow>
Expand Down
36 changes: 34 additions & 2 deletions emulator/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,12 @@
<button id="emulateButton" class="mdl-button mdl-js-button mdl-button--raised mdl-js-ripple-effect mdl-button--colored">
Start Emulating
</button>
<button id="highUsageButton" class="mdl-button mdl-js-button mdl-button--raised mdl-js-ripple-effect mdl-button--accent">
High Footprint
</button>
<button id="lowUsageButton" class="mdl-button mdl-js-button mdl-button--raised mdl-js-ripple-effect">
Low Footprint
</button>
<button id="clearButton" class="mdl-button mdl-js-button mdl-button--raised mdl-js-ripple-effect">
Clear Measurements
</button>
Expand Down Expand Up @@ -135,6 +141,10 @@
var clearButton = document.getElementById('clearButton');
var spinner = document.querySelector('.spinner');
var entityList = document.getElementById('entityList');
var highUsageButton = document.getElementById('highUsageButton');
var lowUsageButton = document.getElementById('lowUsageButton');
var currentUsageMode = 'normal'; // Can be 'normal', 'high', or 'low'

// Enable or disable functions emulator based on checkbox state
document.getElementById('emulator-checkbox').addEventListener('change', function() {
if (this.checked) {
Expand All @@ -160,8 +170,30 @@
clearMeasurements();
});

highUsageButton.addEventListener('click', function() {
currentUsageMode = currentUsageMode === 'high' ? 'normal' : 'high';
highUsageButton.classList.toggle('mdl-button--accent');
lowUsageButton.classList.remove('mdl-button--accent');
console.log('Usage mode:', currentUsageMode);
});

lowUsageButton.addEventListener('click', function() {
currentUsageMode = currentUsageMode === 'low' ? 'normal' : 'low';
lowUsageButton.classList.toggle('mdl-button--accent');
highUsageButton.classList.remove('mdl-button--accent');
console.log('Usage mode:', currentUsageMode);
});

function getRandomValue(min, max) {
return Math.random() * (max - min) + min;
let value = Math.random() * (max - min) + min;

if (currentUsageMode === 'high') {
value *= 2; // Double the values for high usage
} else if (currentUsageMode === 'low') {
value *= 0.5; // Half the values for low usage
}

return value;
}

function startEmulating() {
Expand Down Expand Up @@ -288,7 +320,7 @@
var room = {
isOccupied: false,
roomNumber: i + 1,
lastName: '' // Empty last name for vacant rooms
lastName: ''
};
db.collection('rooms').add(room)
.then(function(docRef) {
Expand Down

0 comments on commit 09ea4f9

Please sign in to comment.