v0.9.7
This commit is contained in:
@@ -67,6 +67,7 @@ function currentSettingsBody() {
|
||||
sensor_stale_after_seconds: Number(ha.sensor_stale_after_seconds || 300),
|
||||
allow_invalid_tls: !!ha.allow_invalid_tls,
|
||||
sensor_aliases: { ...(ha.sensor_aliases || {}) },
|
||||
flow_inputs: JSON.parse(JSON.stringify(ha.flow_inputs || [])),
|
||||
},
|
||||
};
|
||||
}
|
||||
@@ -140,6 +141,7 @@ function homeAssistantSettingsBodyFromForm(form) {
|
||||
sensor_stale_after_seconds: Math.max(60, Math.min(86400, Math.round(Number(raw.ha_sensor_stale_after_minutes || 5) * 60))),
|
||||
allow_invalid_tls: form.ha_allow_invalid_tls.checked,
|
||||
sensor_aliases: { ...(app.sensorAliases || {}) },
|
||||
flow_inputs: JSON.parse(JSON.stringify(app.flowSharedInputs || [])),
|
||||
};
|
||||
return body;
|
||||
}
|
||||
@@ -147,6 +149,7 @@ function homeAssistantSettingsBodyFromForm(form) {
|
||||
async function saveRuntimeSettings(body, notify = true) {
|
||||
app.settings = await api('/api/settings', { method: 'PUT', body });
|
||||
app.sensorAliases = { ...(app.settings?.home_assistant?.sensor_aliases || {}) };
|
||||
app.flowSharedInputs = JSON.parse(JSON.stringify(app.settings?.home_assistant?.flow_inputs || []));
|
||||
renderSettings();
|
||||
renderNightSettings();
|
||||
renderHomeAssistantSettings();
|
||||
@@ -154,6 +157,7 @@ async function saveRuntimeSettings(body, notify = true) {
|
||||
renderSimulationModeBanner();
|
||||
renderSystemInfo();
|
||||
renderDebugOverlay();
|
||||
if (app.flowDraft) renderFlowEditor();
|
||||
scheduleControlPlanLoad();
|
||||
if (app.settings?.debug?.overlay_enabled) loadDebugBacklog();
|
||||
if (notify) toast(tr('common.saved'));
|
||||
@@ -291,3 +295,37 @@ document.addEventListener('change', event => {
|
||||
});
|
||||
|
||||
|
||||
|
||||
$('#addFlowSharedInput')?.addEventListener('click', () => openFlowSharedInputEditor());
|
||||
$('#flowSharedInputKind')?.addEventListener('change', event => {
|
||||
renderFlowSharedInputFields(event.target.value, flowDefaultConfig(event.target.value));
|
||||
});
|
||||
$('#flowSharedInputForm')?.addEventListener('submit', event => {
|
||||
event.preventDefault();
|
||||
const form = event.currentTarget;
|
||||
const name = form.name.value.trim(), kind = form.kind.value;
|
||||
if (!name) return toast(tr('flow.sharedInputNameRequired'), true);
|
||||
const editingId = form.dataset.editingId || '';
|
||||
const id = editingId || newFlowId('shared');
|
||||
const item = { id, name, kind, config: collectFlowSharedInputConfig(kind) };
|
||||
const index = app.flowSharedInputs.findIndex(value => value.id === id);
|
||||
if (index >= 0) app.flowSharedInputs[index] = item; else app.flowSharedInputs.push(item);
|
||||
renderFlowSharedInputs();
|
||||
updateDirtyIndicator($('#homeAssistantForm'));
|
||||
$('#flowSharedInputDialog')?.close();
|
||||
});
|
||||
|
||||
document.addEventListener('click', event => {
|
||||
const edit = event.target.closest?.('[data-flow-shared-edit]');
|
||||
if (edit) { openFlowSharedInputEditor(edit.dataset.flowSharedEdit); return; }
|
||||
const remove = event.target.closest?.('[data-flow-shared-delete]');
|
||||
if (!remove) return;
|
||||
const id = remove.dataset.flowSharedDelete;
|
||||
const item = app.flowSharedInputs.find(value => value.id === id); if (!item) return;
|
||||
const uses = app.flows.reduce((count, flow) => count + (flow.nodes || []).filter(node => node.kind === 'shared_input' && node.config?.input_id === id).length, 0);
|
||||
const message = uses ? tr('flow.sharedInputDeleteUsed', { name:item.name, count:uses }) : tr('flow.sharedInputDeleteConfirm', { name:item.name });
|
||||
if (!confirm(message)) return;
|
||||
app.flowSharedInputs = app.flowSharedInputs.filter(value => value.id !== id);
|
||||
renderFlowSharedInputs();
|
||||
updateDirtyIndicator($('#homeAssistantForm'));
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user