webui: more typings, clean-up sensor units init

This commit is contained in:
Maxim Prokhorov
2024-07-04 07:30:40 +03:00
parent c3e587d6fd
commit 53dc51ff41
31 changed files with 1559 additions and 783 deletions

View File

@@ -2,12 +2,21 @@ import { randomString } from './core.mjs';
import { setChangedElement } from './settings.mjs';
function randomApiKey() {
const elem = document.forms["form-admin"].elements.apiKey;
const form = document.forms.namedItem("form-admin");
if (!form) {
return;
}
const elem = form.elements.namedItem("apiKey");
if (!(elem instanceof HTMLInputElement)) {
return;
}
elem.value = randomString(16, {hex: true});
setChangedElement(elem);
}
export function init() {
document.querySelector(".button-apikey")
.addEventListener("click", randomApiKey);
?.addEventListener("click", randomApiKey);
}