Skip to content

Commit 8a67878

Browse files
author
renlord
committed
implements toggle for device info body
1 parent a541aa4 commit 8a67878

File tree

1 file changed

+37
-33
lines changed

1 file changed

+37
-33
lines changed

static/monitoring.js

Lines changed: 37 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -169,8 +169,13 @@ function fetchDevices() {
169169
link.href = "#" + fingerprint;
170170
header.appendChild(link);
171171
info.appendChild(header);
172-
173-
const deleteButton = info.appendChild(create("button", "delete device"));
172+
const infoBody = create("div", null, `infobody-${fingerprint}`);
173+
info.appendChild(infoBody);
174+
infoBody.hidden = true;
175+
header.onclick = function toggleInfoBody() {
176+
infoBody.hidden = !infoBody.hidden;
177+
};
178+
const deleteButton = infoBody.appendChild(create("button", "delete device"));
174179
deleteButton.onclick = event => {
175180
if (confirm("Are you sure you want to delete the device " + fingerprint + "?")) {
176181
event.target.disabled = true;
@@ -194,27 +199,26 @@ function fetchDevices() {
194199
});
195200
}
196201
};
197-
198-
info.appendChild(create("h3", "Verified device information:"));
199-
appendLine(info, "Device: " + device.name);
200-
appendLine(info, "OS: " + device.osName);
201-
appendLine(info, "OS version: " + formatOsVersion(device.pinnedOsVersion));
202-
appendLine(info, "OS patch level: " + formatPatchLevel(device.pinnedOsPatchLevel));
202+
infoBody.appendChild(create("h3", "Verified device infoBodyrmation:"));
203+
appendLine(infoBody, "Device: " + device.name);
204+
appendLine(infoBody, "OS: " + device.osName);
205+
appendLine(infoBody, "OS version: " + formatOsVersion(device.pinnedOsVersion));
206+
appendLine(infoBody, "OS patch level: " + formatPatchLevel(device.pinnedOsPatchLevel));
203207
if (device.pinnedVendorPatchLevel !== undefined) {
204-
appendLine(info, "Vendor patch level: " + formatPatchLevel(device.pinnedVendorPatchLevel));
208+
appendLine(infoBody, "Vendor patch level: " + formatPatchLevel(device.pinnedVendorPatchLevel));
205209
}
206210
if (device.pinnedBootPatchLevel !== undefined) {
207-
appendLine(info, "Boot patch level: " + formatPatchLevel(device.pinnedBootPatchLevel));
211+
appendLine(infoBody, "Boot patch level: " + formatPatchLevel(device.pinnedBootPatchLevel));
208212
}
209213
if (device.verifiedBootHash !== undefined) {
210-
info.appendChild(document.createTextNode("Verified boot hash: "));
211-
info.appendChild(create("span", device.verifiedBootHash, "fingerprint"));
212-
info.appendChild(document.createElement("br"));
214+
infoBody.appendChild(document.createTextNode("Verified boot hash: "));
215+
infoBody.appendChild(create("span", device.verifiedBootHash, "fingerprint"));
216+
infoBody.appendChild(document.createElement("br"));
213217
}
214-
appendLine(info, "Security level: " + toSecurityLevelString(device.pinnedSecurityLevel));
218+
appendLine(infoBody, "Security level: " + toSecurityLevelString(device.pinnedSecurityLevel));
215219

216-
info.appendChild(create("button", "show advanced information", "toggle"));
217-
const advanced = info.appendChild(document.createElement("section"));
220+
infoBody.appendChild(create("button", "show advanced information", "toggle"));
221+
const advanced = infoBody.appendChild(document.createElement("section"));
218222
advanced.hidden = true;
219223
advanced.appendChild(document.createTextNode("Certificate 0 (persistent Auditor key): "));
220224
advanced.appendChild(create("button", "show", "toggle"));
@@ -235,29 +239,29 @@ function fetchDevices() {
235239
advanced.appendChild(document.createTextNode("Verified boot key fingerprint: "));
236240
advanced.appendChild(create("span", device.verifiedBootKey, "fingerprint"));
237241

238-
info.appendChild(create("h3", "Information provided by the verified OS:"));
239-
appendLine(info, "Auditor app version: " + device.pinnedAppVersion);
240-
appendLine(info, "User profile secure: " + toYesNoString(device.userProfileSecure));
242+
infoBody.appendChild(create("h3", "Information provided by the verified OS:"));
243+
appendLine(infoBody, "Auditor app version: " + device.pinnedAppVersion);
244+
appendLine(infoBody, "User profile secure: " + toYesNoString(device.userProfileSecure));
241245
if (device.pinnedAppVersion < 26) {
242-
appendLine(info, "Enrolled fingerprints: " + toYesNoString(device.enrolledBiometrics));
246+
appendLine(infoBody, "Enrolled fingerprints: " + toYesNoString(device.enrolledBiometrics));
243247
} else {
244-
appendLine(info, "Enrolled biometrics: " + toYesNoString(device.enrolledBiometrics));
248+
appendLine(infoBody, "Enrolled biometrics: " + toYesNoString(device.enrolledBiometrics));
245249
}
246-
appendLine(info, "Accessibility service(s) enabled: " + toYesNoString(device.accessibility));
247-
appendLine(info, "Device administrator(s) enabled: " + deviceAdminStrings.get(device.deviceAdmin));
248-
appendLine(info, "Android Debug Bridge enabled: " + toYesNoString(device.adbEnabled));
249-
appendLine(info, "Add users from lock screen: " + toYesNoString(device.addUsersWhenLocked));
250-
appendLine(info, "Disallow new USB peripherals when locked: " + toYesNoString(device.denyNewUsb));
251-
appendLine(info, "OEM unlocking allowed: " + toYesNoString(device.oemUnlockAllowed));
250+
appendLine(infoBody, "Accessibility service(s) enabled: " + toYesNoString(device.accessibility));
251+
appendLine(infoBody, "Device administrator(s) enabled: " + deviceAdminStrings.get(device.deviceAdmin));
252+
appendLine(infoBody, "Android Debug Bridge enabled: " + toYesNoString(device.adbEnabled));
253+
appendLine(infoBody, "Add users from lock screen: " + toYesNoString(device.addUsersWhenLocked));
254+
appendLine(infoBody, "Disallow new USB peripherals when locked: " + toYesNoString(device.denyNewUsb));
255+
appendLine(infoBody, "OEM unlocking allowed: " + toYesNoString(device.oemUnlockAllowed));
252256
if (device.systemUser !== undefined) {
253-
appendLine(info, "Main user account: " + toYesNoString(device.systemUser));
257+
appendLine(infoBody, "Main user account: " + toYesNoString(device.systemUser));
254258
}
255259

256-
info.appendChild(create("h3", "Attestation history"));
257-
appendLine(info, "First verified time: " + new Date(device.verifiedTimeFirst));
258-
appendLine(info, "Last verified time: " + new Date(device.verifiedTimeLast));
259-
const historyButton = info.appendChild(create("button", "show detailed history", "toggle"));
260-
const history = info.appendChild(document.createElement("div"));
260+
infoBody.appendChild(create("h3", "Attestation history"));
261+
appendLine(infoBody, "First verified time: " + new Date(device.verifiedTimeFirst));
262+
appendLine(infoBody, "Last verified time: " + new Date(device.verifiedTimeLast));
263+
const historyButton = infoBody.appendChild(create("button", "show detailed history", "toggle"));
264+
const history = infoBody.appendChild(document.createElement("div"));
261265
history.dataset.deviceFingerprint = device.fingerprint;
262266
history.dataset.minId = Number(device.minId);
263267
history.dataset.maxId = Number(device.maxId);

0 commit comments

Comments
 (0)