73 lines
2.5 KiB
TypeScript
73 lines
2.5 KiB
TypeScript
import {WebWebSocketHandler} from "./WebWebSocketHandler";
|
|
import {RequestType} from "../RequestType";
|
|
import {Modal} from "./Modal";
|
|
import {ButtonType} from "./ButtonType";
|
|
|
|
export class Settings {
|
|
public static addListeners() {
|
|
// Settings Btns
|
|
const downloadDrinks = document.getElementById("settings_refreshDrinks") as HTMLButtonElement;
|
|
downloadDrinks.onclick = () => this.onClickRefreshDrinks();
|
|
const getInfo = document.getElementById("settings_getInfo") as HTMLButtonElement;
|
|
getInfo.onclick = () => this.onClickInfo();
|
|
|
|
const reload = document.getElementById("settings_reload") as HTMLButtonElement;
|
|
reload.onclick = () => window.location.reload();
|
|
}
|
|
|
|
private static onClickRefreshDrinks() {
|
|
WebWebSocketHandler.request(RequestType.DOWNLOAD_DRINKS).then();
|
|
}
|
|
|
|
private static onClickUpdate() {
|
|
|
|
}
|
|
|
|
private static onClickInfo() {
|
|
WebWebSocketHandler.request(RequestType.INFO, null).then((payload) => {
|
|
let modal = new Modal("info", "Systeminformationen");
|
|
|
|
let table = document.createElement("table");
|
|
table.style.marginLeft = "auto";
|
|
table.style.marginRight = "auto";
|
|
|
|
let th = document.createElement("th");
|
|
table.append(th);
|
|
|
|
let tdTh1 = document.createElement("td");
|
|
tdTh1.innerText = "";
|
|
let tdTh2 = document.createElement("td");
|
|
tdTh2.innerText = "";
|
|
|
|
th.append(tdTh1, tdTh2);
|
|
|
|
let x = [["internet","Internet-Konnektivität"], ["ip","IP-Adresse"], ["network","WiFi-Netzwerk"], ["uptime","Gerät aktiv seit"], ["version", "Version"]];
|
|
for( let y of x )
|
|
{
|
|
let tr = document.createElement("tr");
|
|
let td1 = document.createElement("td");
|
|
let td2 = document.createElement("td");
|
|
|
|
td1.innerText = y[1];
|
|
td1.style.fontWeight = "bold";
|
|
if( payload.data[y[0]] === true || payload.data[y[0]] === false )
|
|
{
|
|
td2.innerText = payload.data[y[0]] == true ? "Verbunden" : "Getrennt";
|
|
}
|
|
else
|
|
{
|
|
td2.innerText = payload.data[y[0]];
|
|
}
|
|
|
|
tr.append(td1,td2);
|
|
|
|
table.append(tr);
|
|
}
|
|
modal.addContent(table);
|
|
|
|
modal.addBR();
|
|
modal.addButton(ButtonType.PRIMARY, "Schließen", () => modal.close() );
|
|
modal.open();
|
|
});
|
|
}
|
|
} |