Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 10 additions & 1 deletion public/js/smarthome.js
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,15 @@
} catch (_) { /* leer lassen */ }
}

// Modal open/close wired in JS (CSP blocks inline onclick: script-src-attr 'none').
function wireModal() {
const modal = $('#sh-connect-modal');
const open = $('#sh-connect-open');
if (open && modal) open.addEventListener('click', () => { modal.style.display = 'flex'; });
document.querySelectorAll('[data-sh-close]').forEach((el) =>
el.addEventListener('click', () => { if (modal) modal.style.display = 'none'; }));
}

function wireConnect() {
const btn = $('#sh-c-submit'); if (!btn) return;
btn.addEventListener('click', async () => {
Expand Down Expand Up @@ -191,6 +200,6 @@
});
}

document.addEventListener('DOMContentLoaded', () => { fillRoutes(); wireConnect(); wireTest(); loadGateways(); });
document.addEventListener('DOMContentLoaded', () => { wireModal(); fillRoutes(); wireConnect(); wireTest(); loadGateways(); });
window.SmartHome = { loadGateways, loadResources, api };
})();
13 changes: 13 additions & 0 deletions templates/aurora/layout.njk
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,19 @@
midea_integration: {{ ('true' if license.features.midea_integration else 'false') | safe }}
},
t: {
'smarthome.power': {{ t('smarthome.power') | dump | safe }},
'smarthome.brightness': {{ t('smarthome.brightness') | dump | safe }},
'smarthome.color': {{ t('smarthome.color') | dump | safe }},
'smarthome.warmth': {{ t('smarthome.warmth') | dump | safe }},
'smarthome.activate': {{ t('smarthome.activate') | dump | safe }},
'smarthome.load_error': {{ t('smarthome.load_error') | dump | safe }},
'smarthome.empty': {{ t('smarthome.empty') | dump | safe }},
'smarthome.section.lights': {{ t('smarthome.section.lights') | dump | safe }},
'smarthome.section.groups': {{ t('smarthome.section.groups') | dump | safe }},
'smarthome.section.sensors': {{ t('smarthome.section.sensors') | dump | safe }},
'smarthome.kpi.groups': {{ t('smarthome.kpi.groups') | dump | safe }},
'smarthome.test_ok': {{ t('smarthome.test_ok') | dump | safe }},
'smarthome.test_fail': {{ t('smarthome.test_fail') | dump | safe }},
'peers.no_peers': {{ t('peers.no_peers') | dump | safe }},
'peers.online': {{ t('peers.online') | dump | safe }},
'peers.offline': {{ t('peers.offline') | dump | safe }},
Expand Down
2 changes: 1 addition & 1 deletion templates/aurora/pages/smarthome.njk
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
<select id="sh-gateway-select" class="form-select" style="min-width:180px"></select>
<button class="btn btn-ghost" id="sh-test">{{ t('smarthome.test') }}</button>
<button class="btn btn-ghost" id="sh-sync">{{ t('smarthome.sync') }}</button>
<button class="btn btn-primary" onclick="document.getElementById('sh-connect-modal').style.display='flex'">{{ t('smarthome.connect') }}</button>
<button class="btn btn-primary" id="sh-connect-open">{{ t('smarthome.connect') }}</button>
</div>
</div>
<div id="sh-test-result" style="display:none"></div>
Expand Down
4 changes: 2 additions & 2 deletions templates/aurora/partials/modals/smarthome-connect.njk
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<div class="modal">
<div class="modal-head">
<div class="modal-title">{{ t('smarthome.connect.title') }}</div>
<button class="modal-close" onclick="document.getElementById('sh-connect-modal').style.display='none'">
<button class="modal-close" data-sh-close>
<svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.2" stroke-linecap="round"><line x1="18" y1="6" x2="6" y2="18"/><line x1="6" y1="6" x2="18" y2="18"/></svg>
</button>
</div>
Expand All @@ -23,7 +23,7 @@
</div>
</div>
<div class="modal-foot">
<button class="btn btn-ghost" onclick="document.getElementById('sh-connect-modal').style.display='none'">{{ t('common.cancel') }}</button>
<button class="btn btn-ghost" data-sh-close>{{ t('common.cancel') }}</button>
<button class="btn btn-primary" id="sh-c-submit">{{ t('smarthome.connect.acquire') }}</button>
</div>
</div>
Expand Down
13 changes: 13 additions & 0 deletions templates/default/layout.njk
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,19 @@
midea_integration: {{ ('true' if license.features.midea_integration else 'false') | safe }}
},
t: {
'smarthome.power': {{ t('smarthome.power') | dump | safe }},
'smarthome.brightness': {{ t('smarthome.brightness') | dump | safe }},
'smarthome.color': {{ t('smarthome.color') | dump | safe }},
'smarthome.warmth': {{ t('smarthome.warmth') | dump | safe }},
'smarthome.activate': {{ t('smarthome.activate') | dump | safe }},
'smarthome.load_error': {{ t('smarthome.load_error') | dump | safe }},
'smarthome.empty': {{ t('smarthome.empty') | dump | safe }},
'smarthome.section.lights': {{ t('smarthome.section.lights') | dump | safe }},
'smarthome.section.groups': {{ t('smarthome.section.groups') | dump | safe }},
'smarthome.section.sensors': {{ t('smarthome.section.sensors') | dump | safe }},
'smarthome.kpi.groups': {{ t('smarthome.kpi.groups') | dump | safe }},
'smarthome.test_ok': {{ t('smarthome.test_ok') | dump | safe }},
'smarthome.test_fail': {{ t('smarthome.test_fail') | dump | safe }},
'peers.no_peers': {{ t('peers.no_peers') | dump | safe }},
'peers.online': {{ t('peers.online') | dump | safe }},
'peers.offline': {{ t('peers.offline') | dump | safe }},
Expand Down
2 changes: 1 addition & 1 deletion templates/default/pages/smarthome.njk
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
<select id="sh-gateway-select" class="form-select" style="min-width:180px"></select>
<button class="btn btn-ghost" id="sh-test">{{ t('smarthome.test') }}</button>
<button class="btn btn-ghost" id="sh-sync">{{ t('smarthome.sync') }}</button>
<button class="btn btn-primary" onclick="document.getElementById('sh-connect-modal').style.display='flex'">{{ t('smarthome.connect') }}</button>
<button class="btn btn-primary" id="sh-connect-open">{{ t('smarthome.connect') }}</button>
</div>
</div>
<div id="sh-test-result" style="display:none"></div>
Expand Down
4 changes: 2 additions & 2 deletions templates/default/partials/modals/smarthome-connect.njk
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<div class="modal">
<div class="modal-head">
<div class="modal-title">{{ t('smarthome.connect.title') }}</div>
<button class="modal-close" onclick="document.getElementById('sh-connect-modal').style.display='none'">
<button class="modal-close" data-sh-close>
<svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.2" stroke-linecap="round"><line x1="18" y1="6" x2="6" y2="18"/><line x1="6" y1="6" x2="18" y2="18"/></svg>
</button>
</div>
Expand All @@ -23,7 +23,7 @@
</div>
</div>
<div class="modal-foot">
<button class="btn btn-ghost" onclick="document.getElementById('sh-connect-modal').style.display='none'">{{ t('common.cancel') }}</button>
<button class="btn btn-ghost" data-sh-close>{{ t('common.cancel') }}</button>
<button class="btn btn-primary" id="sh-c-submit">{{ t('smarthome.connect.acquire') }}</button>
</div>
</div>
Expand Down
13 changes: 13 additions & 0 deletions templates/pro/layout.njk
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,19 @@
midea_integration: {{ ('true' if license.features.midea_integration else 'false') | safe }}
},
t: {
'smarthome.power': {{ t('smarthome.power') | dump | safe }},
'smarthome.brightness': {{ t('smarthome.brightness') | dump | safe }},
'smarthome.color': {{ t('smarthome.color') | dump | safe }},
'smarthome.warmth': {{ t('smarthome.warmth') | dump | safe }},
'smarthome.activate': {{ t('smarthome.activate') | dump | safe }},
'smarthome.load_error': {{ t('smarthome.load_error') | dump | safe }},
'smarthome.empty': {{ t('smarthome.empty') | dump | safe }},
'smarthome.section.lights': {{ t('smarthome.section.lights') | dump | safe }},
'smarthome.section.groups': {{ t('smarthome.section.groups') | dump | safe }},
'smarthome.section.sensors': {{ t('smarthome.section.sensors') | dump | safe }},
'smarthome.kpi.groups': {{ t('smarthome.kpi.groups') | dump | safe }},
'smarthome.test_ok': {{ t('smarthome.test_ok') | dump | safe }},
'smarthome.test_fail': {{ t('smarthome.test_fail') | dump | safe }},
'peers.no_peers': {{ t('peers.no_peers') | dump | safe }},
'peers.online': {{ t('peers.online') | dump | safe }},
'peers.offline': {{ t('peers.offline') | dump | safe }},
Expand Down
2 changes: 1 addition & 1 deletion templates/pro/pages/smarthome.njk
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
<select id="sh-gateway-select" class="form-select" style="min-width:180px"></select>
<button class="btn btn-ghost" id="sh-test">{{ t('smarthome.test') }}</button>
<button class="btn btn-ghost" id="sh-sync">{{ t('smarthome.sync') }}</button>
<button class="btn btn-primary" onclick="document.getElementById('sh-connect-modal').style.display='flex'">{{ t('smarthome.connect') }}</button>
<button class="btn btn-primary" id="sh-connect-open">{{ t('smarthome.connect') }}</button>
</div>
</div>
<div id="sh-test-result" style="display:none"></div>
Expand Down
4 changes: 2 additions & 2 deletions templates/pro/partials/modals/smarthome-connect.njk
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<div class="modal">
<div class="modal-head">
<div class="modal-title">{{ t('smarthome.connect.title') }}</div>
<button class="modal-close" onclick="document.getElementById('sh-connect-modal').style.display='none'">
<button class="modal-close" data-sh-close>
<svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.2" stroke-linecap="round"><line x1="18" y1="6" x2="6" y2="18"/><line x1="6" y1="6" x2="18" y2="18"/></svg>
</button>
</div>
Expand All @@ -23,7 +23,7 @@
</div>
</div>
<div class="modal-foot">
<button class="btn btn-ghost" onclick="document.getElementById('sh-connect-modal').style.display='none'">{{ t('common.cancel') }}</button>
<button class="btn btn-ghost" data-sh-close>{{ t('common.cancel') }}</button>
<button class="btn btn-primary" id="sh-c-submit">{{ t('smarthome.connect.acquire') }}</button>
</div>
</div>
Expand Down
Loading