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