v0.15.6
This commit is contained in:
@@ -469,16 +469,27 @@ function beginInlineTemperatureEdit(target) {
|
||||
input.addEventListener('blur', () => finish(true), { once: true });
|
||||
}
|
||||
|
||||
function showDiscoveryNames(ids) {
|
||||
const wanted = new Set(Array.isArray(ids) ? ids : []);
|
||||
const devices = app.devices.filter(device => wanted.has(device.id));
|
||||
if (!devices.length) return;
|
||||
function showDiscoveryNames(devices) {
|
||||
const items = Array.isArray(devices) ? devices : [];
|
||||
app.localDiscoveryCandidates = items.map(item => ({ ...item }));
|
||||
const list = $('#discoveryNamesList');
|
||||
list.innerHTML = devices.map(device => `
|
||||
<label class="discovery-name-row">
|
||||
<span><strong>${esc(device.model || 'GREE')}</strong><small>${esc(device.ip)} · ${esc(device.mac)} · ${device.protocol_version === 2 ? 'V2 GCM' : 'V1 ECB'}</small></span>
|
||||
<input data-device-id="${esc(device.id)}" maxlength="80" required value="${esc(device.name)}">
|
||||
</label>`).join('');
|
||||
if (!list) return;
|
||||
list.innerHTML = items.length ? items.map((device, index) => {
|
||||
const alreadyAdded = device.already_added === true;
|
||||
const protocol = Number(device.protocol_version) === 2 ? 'V2 AES-GCM' : 'V1 AES-ECB';
|
||||
const selectorId = `local-discovery-${index}`;
|
||||
return `<div class="discovery-name-row local-discovery-row">
|
||||
<div class="local-discovery-head">
|
||||
<input type="checkbox" id="${esc(selectorId)}" data-discovery-select data-discovery-index="${index}" ${alreadyAdded ? 'disabled' : 'checked'}>
|
||||
<label for="${esc(selectorId)}">
|
||||
<strong>${esc(device.model || device.name || 'GREE')}</strong>
|
||||
<small>IP ${esc(device.ip || '—')} · MAC ${esc(device.mac || '—')} · ${esc(protocol)}</small>
|
||||
</label>
|
||||
${alreadyAdded ? `<span class="badge">${esc(tr('discovery.alreadyAdded'))}</span>` : ''}
|
||||
</div>
|
||||
<input data-discovery-name="${index}" maxlength="80" value="${esc(device.name || device.model || 'GREE')}" ${alreadyAdded ? 'disabled' : ''} aria-label="${esc(tr('common.name'))}">
|
||||
</div>`;
|
||||
}).join('') : `<div class="empty"><strong>${esc(tr('discovery.empty'))}</strong><span>${esc(tr('discovery.emptyHint'))}</span></div>`;
|
||||
openDialog('discoveryNamesDialog');
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user