garaga page 9
This commit is contained in:
@@ -30,12 +30,6 @@
|
||||
gap: 20px;
|
||||
}
|
||||
|
||||
@media (min-width: 768px) {
|
||||
.devices-container {
|
||||
grid-template-columns: 1fr 1fr;
|
||||
}
|
||||
}
|
||||
|
||||
.device-section {
|
||||
background: rgba(255, 255, 255, 0.95);
|
||||
border-radius: 12px;
|
||||
@@ -313,11 +307,12 @@
|
||||
loading.style.display = 'none';
|
||||
container.style.display = 'grid';
|
||||
|
||||
// Render devices
|
||||
garageDevices.forEach(device => {
|
||||
const deviceSection = createDeviceSection(device);
|
||||
// Render only the relay device (it will include the powermeter)
|
||||
const relayDevice = garageDevices.find(d => d.device_id === 'power_relay_caroutlet');
|
||||
if (relayDevice) {
|
||||
const deviceSection = createDeviceSection(relayDevice);
|
||||
container.appendChild(deviceSection);
|
||||
});
|
||||
}
|
||||
|
||||
// Start SSE for live updates
|
||||
connectRealtime();
|
||||
@@ -338,34 +333,7 @@
|
||||
section.className = 'device-section';
|
||||
section.dataset.deviceId = device.device_id;
|
||||
|
||||
// Device header
|
||||
const header = document.createElement('div');
|
||||
header.className = 'device-header';
|
||||
|
||||
const icon = document.createElement('div');
|
||||
icon.className = 'device-icon';
|
||||
icon.textContent = getDeviceIcon(device.type);
|
||||
|
||||
const info = document.createElement('div');
|
||||
info.className = 'device-info';
|
||||
|
||||
const name = document.createElement('h2');
|
||||
name.className = 'device-name';
|
||||
name.textContent = device.name;
|
||||
|
||||
const type = document.createElement('p');
|
||||
type.className = 'device-type';
|
||||
type.textContent = getTypeLabel(device.type);
|
||||
|
||||
info.appendChild(name);
|
||||
info.appendChild(type);
|
||||
|
||||
header.appendChild(icon);
|
||||
header.appendChild(info);
|
||||
|
||||
section.appendChild(header);
|
||||
|
||||
// Device content
|
||||
// Device content (no header for Car Outlet)
|
||||
const content = document.createElement('div');
|
||||
content.className = 'device-content';
|
||||
|
||||
@@ -380,23 +348,33 @@
|
||||
// Clear existing content
|
||||
container.innerHTML = '';
|
||||
|
||||
switch (device.type) {
|
||||
case 'relay':
|
||||
case 'outlet':
|
||||
// Render all content in one column for Car Outlet
|
||||
if (device.device_id === 'power_relay_caroutlet') {
|
||||
// Header card
|
||||
const headerCard = document.createElement('div');
|
||||
headerCard.className = 'card';
|
||||
headerCard.innerHTML = `
|
||||
<div style="display: flex; align-items: center; justify-content: center; gap: 12px;">
|
||||
<div style="font-size: 32px;">⚡</div>
|
||||
<div style="font-size: 20px; font-weight: 600; color: #333;">Car Outlet</div>
|
||||
</div>
|
||||
`;
|
||||
container.appendChild(headerCard);
|
||||
|
||||
// Control card
|
||||
renderOutletControls(container, device);
|
||||
break;
|
||||
case 'three_phase_powermeter':
|
||||
renderThreePhasePowerDisplay(container, device);
|
||||
break;
|
||||
default:
|
||||
container.innerHTML = '<div class="card">Keine Steuerung verfügbar</div>';
|
||||
|
||||
// Find and render powermeter
|
||||
const powermeterDevice = Object.values(devicesData).find(d => d.device_id === 'powermeter_caroutlet');
|
||||
if (powermeterDevice) {
|
||||
renderThreePhasePowerDisplay(container, powermeterDevice);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function renderOutletControls(container, device) {
|
||||
const card = document.createElement('div');
|
||||
card.className = 'card';
|
||||
card.innerHTML = '<div class="card-title">Steuerung</div>';
|
||||
|
||||
const controlGroup = document.createElement('div');
|
||||
controlGroup.className = 'control-group';
|
||||
@@ -416,8 +394,17 @@
|
||||
label.className = 'toggle-label';
|
||||
label.textContent = currentPower ? 'Ein' : 'Aus';
|
||||
|
||||
// State display
|
||||
const stateDisplay = document.createElement('div');
|
||||
stateDisplay.style.marginTop = '16px';
|
||||
stateDisplay.style.fontSize = '18px';
|
||||
stateDisplay.style.fontWeight = '600';
|
||||
stateDisplay.style.color = currentPower ? '#34c759' : '#666';
|
||||
stateDisplay.textContent = `Status: ${currentPower ? 'Eingeschaltet' : 'Ausgeschaltet'}`;
|
||||
|
||||
controlGroup.appendChild(toggleSwitch);
|
||||
controlGroup.appendChild(label);
|
||||
controlGroup.appendChild(stateDisplay);
|
||||
|
||||
card.appendChild(controlGroup);
|
||||
container.appendChild(card);
|
||||
@@ -577,6 +564,13 @@
|
||||
const isOn = state.power === 'on';
|
||||
toggleSwitch.className = `toggle-switch ${isOn ? 'on' : ''}`;
|
||||
label.textContent = isOn ? 'Ein' : 'Aus';
|
||||
|
||||
// Update state display
|
||||
const stateDisplay = section.querySelector('.control-group div:last-child');
|
||||
if (stateDisplay) {
|
||||
stateDisplay.style.color = isOn ? '#34c759' : '#666';
|
||||
stateDisplay.textContent = `Status: ${isOn ? 'Eingeschaltet' : 'Ausgeschaltet'}`;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user