v0.12.0-preety_code
This commit is contained in:
+6
-6
@@ -356,16 +356,16 @@ $('#flowSharedInputKind')?.addEventListener('change', event => {
|
||||
renderFlowSharedInputFields(event.target.value, flowSharedInputDefaultConfig(event.target.value));
|
||||
});
|
||||
function evaluateFlowSharedHaTest(kind, config, result) {
|
||||
if (kind === 'ha_available') return { actual:result.available === true, valid:true };
|
||||
if (kind === 'ha_available') return { actual: result.available === true, valid: true };
|
||||
if (kind === 'ha_attribute') {
|
||||
const actual = result.attributes?.[config.attribute];
|
||||
return { actual, valid:actual !== undefined };
|
||||
return { actual, valid: actual !== undefined };
|
||||
}
|
||||
if (kind === 'ha_numeric') {
|
||||
const actual = Number(result.state);
|
||||
return { actual, valid:Number.isFinite(actual) };
|
||||
return { actual, valid: Number.isFinite(actual) };
|
||||
}
|
||||
return { actual:result.state, valid:true };
|
||||
return { actual: result.state, valid: true };
|
||||
}
|
||||
|
||||
$('#flowSharedInputTest')?.addEventListener('click', async event => {
|
||||
@@ -384,7 +384,7 @@ $('#flowSharedInputTest')?.addEventListener('click', async event => {
|
||||
button.disabled = true; button.textContent = tr('flow.sharedInputTesting');
|
||||
resultHost.hidden = false; resultHost.innerHTML = `<span>${esc(tr('flow.sharedInputTesting'))}</span>`;
|
||||
try {
|
||||
const result = await api('/api/integrations/home-assistant/entity', { method:'POST', body:{ entity_id:entityId } });
|
||||
const result = await api('/api/integrations/home-assistant/entity', { method: 'POST', body: { entity_id: entityId } });
|
||||
const evaluation = evaluateFlowSharedHaTest(kind, config, result);
|
||||
const actual = evaluation.actual == null ? 'null' : (typeof evaluation.actual === 'object' ? JSON.stringify(evaluation.actual) : String(evaluation.actual));
|
||||
const success = evaluation.valid;
|
||||
@@ -424,7 +424,7 @@ document.addEventListener('click', event => {
|
||||
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 });
|
||||
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();
|
||||
|
||||
Reference in New Issue
Block a user