feat: publish standalone PIGWay Agent Console plugin
This commit is contained in:
@@ -0,0 +1,30 @@
|
||||
import { state as appState } from "/assets/js/state.js";
|
||||
import { tr } from "/assets/js/i18n.js";
|
||||
import { pluginText } from "/assets/js/shared.js";
|
||||
import { field } from "./schema.js";
|
||||
import { markChanged } from "./config.js";
|
||||
export function renderDevice(values) {
|
||||
return `<div class="group"><div class="fields">${Object.entries(values)
|
||||
.map(([key, raw]) => {
|
||||
const automatic = !raw || raw.toLowerCase() === "auto",
|
||||
value = automatic
|
||||
? appState.deviceIdentity[key === "identifier" ? "id" : "name"] ||
|
||||
appState.deviceIdentity.hostname ||
|
||||
""
|
||||
: raw;
|
||||
return field("device", key, value).replace(
|
||||
'data-section="device"',
|
||||
`data-device-auto="${automatic}" data-section="device"`,
|
||||
);
|
||||
})
|
||||
.join(
|
||||
"",
|
||||
)}</div><div class="action-row device-default-actions"><button type="button" onclick="resetDeviceDefaults()">${tr("恢复设备默认值")}</button></div><p class="hint">${pluginText("默认值跟随本机主机名;修改后点击保存到当前机器。", "Defaults follow the device hostname. Save to the current host to apply changes.")}</p></div>`;
|
||||
}
|
||||
export function resetDeviceDefaults() {
|
||||
document.querySelectorAll('[data-section="device"]').forEach((el) => {
|
||||
el.value = appState.deviceIdentity.hostname || "";
|
||||
el.dataset.deviceAuto = "true";
|
||||
});
|
||||
markChanged();
|
||||
}
|
||||
Reference in New Issue
Block a user