From 223438861a1c6b4bb358ed599fff1eb90fc4071f Mon Sep 17 00:00:00 2001 From: Tim Wilkinson Date: Wed, 20 Nov 2024 23:50:17 -0800 Subject: [PATCH] Provide access to neighbor info without dragging in extra resource (#1711) unless necessary. --- files/app/main/inject.ut | 75 +++++++++++++++++ .../main/{status/e => }/neighbor-device.ut | 2 + files/app/partial/activator.ut | 47 +++++++++++ files/app/partial/dialog-footer.ut | 2 +- .../app/partial/local-and-neighbor-devices.ut | 80 +++++++++---------- files/app/partial/status.ut | 1 + files/app/resource/css/user.css | 3 +- 7 files changed, 168 insertions(+), 42 deletions(-) create mode 100755 files/app/main/inject.ut rename files/app/main/{status/e => }/neighbor-device.ut (99%) create mode 100755 files/app/partial/activator.ut diff --git a/files/app/main/inject.ut b/files/app/main/inject.ut new file mode 100755 index 00000000..8cc9decf --- /dev/null +++ b/files/app/main/inject.ut @@ -0,0 +1,75 @@ +{% +/* + * Part of AREDN® -- Used for creating Amateur Radio Emergency Data Networks + * Copyright (C) 2024 Tim Wilkinson + * See Contributors file for additional contributors + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation version 3 of the License. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + * + * Additional Terms: + * + * Additional use restrictions exist on the AREDN® trademark and logo. + * See AREDNLicense.txt for more info. + * + * Attributions to the AREDN® Project must be retained in the source code. + * If importing this code into a new or existing project attribution + * to the AREDN® project must be added to the source code. + * + * You must not misrepresent the origin of the material contained within. + * + * Modified versions must be modified to attribute to the original source + * and be marked in reasonable ways as differentiate it from the original + * version + */ +%} +(function(){ + let lk = document.createElement("link"); + lk.rel = "stylesheet"; + {% if (config.resourcehash) { %} + lk.onerror = () => { + lk = document.createElement("link"); + lk.rel = "stylesheet"; + {% if (config.resourcehash) { %} + lk.href = "/a/css/admin.{{versions.admincss}}.css"; + {% } else { %} + lk.href = "/a/css/admin.css"; + {% } %} + document.head.appendChild(lk); + }; + lk.href = "http://localnode.local.mesh/a/css/admin.{{versions.admincss}}.css"; + {% } else { %} + lk.href = "/a/css/admin.css"; + {% } %} + document.head.appendChild(lk); + + let hx = document.createElement("script"); + hx.type = 'text/javascript'; + hx.onload = window.injectCallback; + {% if (config.resourcehash) { %} + hx.onerror = () => { + hx = document.createElement('script'); + hx.type = "text/javascript"; + hx.onload = window.injectCallback; + {% if (config.resourcehash) { %} + hx.src = "/a/js/htmx.min.{{versions.htmx}}.js"; + {% } else { %} + hx.src = "/a/js/htmx.min.js"; + {% } %} + document.head.appendChild(hx); + } + hx.src = "http://localnode.local.mesh/a/js/htmx.min.{{versions.htmx}}.js"; + {% } else { %} + hx.src = "/a/js/htmx.min.js"; + {% } %} + document.head.appendChild(hx); +})(); diff --git a/files/app/main/status/e/neighbor-device.ut b/files/app/main/neighbor-device.ut similarity index 99% rename from files/app/main/status/e/neighbor-device.ut rename to files/app/main/neighbor-device.ut index 2d5d1d0a..af8910b5 100755 --- a/files/app/main/status/e/neighbor-device.ut +++ b/files/app/main/neighbor-device.ut @@ -169,11 +169,13 @@ if (tracker) {
{{n.hostname || n.ip}}
+ {% if (auth.isAdmin) { %} + {% } %}
diff --git a/files/app/partial/activator.ut b/files/app/partial/activator.ut new file mode 100755 index 00000000..af83175c --- /dev/null +++ b/files/app/partial/activator.ut @@ -0,0 +1,47 @@ +{% +/* + * Part of AREDN® -- Used for creating Amateur Radio Emergency Data Networks + * Copyright (C) 2024 Tim Wilkinson + * See Contributors file for additional contributors + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation version 3 of the License. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + * + * Additional Terms: + * + * Additional use restrictions exist on the AREDN® trademark and logo. + * See AREDNLicense.txt for more info. + * + * Attributions to the AREDN® Project must be retained in the source code. + * If importing this code into a new or existing project attribution + * to the AREDN® project must be added to the source code. + * + * You must not misrepresent the origin of the material contained within. + * + * Modified versions must be modified to attribute to the original source + * and be marked in reasonable ways as differentiate it from the original + * version + */ +%} +{% if (!auth.isAdmin) { %} + +{% } %} diff --git a/files/app/partial/dialog-footer.ut b/files/app/partial/dialog-footer.ut index d9b0363d..0be084e0 100755 --- a/files/app/partial/dialog-footer.ut +++ b/files/app/partial/dialog-footer.ut @@ -34,7 +34,7 @@ %} {% - const llist = []; - const nlist = []; - const hlist = lqm.getHidden(); - const t = lqm.getTrackers(); - const trackers = {}; - for (mac in t) { - const tmac = t[mac]; - if (tmac.ip) { - trackers[tmac.ip] = tmac; - } - } - const links = olsr.getLinks(); - for (let i = 0; i < length(links); i++) { - const link = links[i]; - const tracker = trackers[link.remoteIP]; - if (link.ifName === "br-dtdlink") { - if (tracker && tracker.distance >= 100) { - push(nlist, { name: tracker.hostname || `|${link.remoteIP}`, tracker: tracker, link: link }); - } - else { - push(llist, { name: (tracker && tracker.hostname) || `|${link.remoteIP}`, tracker: tracker, link: link }); - } - } - else { - push(nlist, { name: (tracker && tracker.hostname) || `|${link.remoteIP}`, tracker: tracker, link: link }); - } - delete trackers[link.remoteIP]; - } - for (let remoteIP in trackers) - { - const tracker = trackers[remoteIP]; - if (tracker.type == "DtD" && tracker.distance < 100) { - push(llist, { name: tracker.hostname || `|${remoteIP}`, tracker: tracker, link: null }); - } - else { - push(nlist, { name: tracker.hostname || `|${remoteIP}`, tracker: tracker, link: null }); - } - } if (length(llist) > 0) { sort(llist, (a, b) => a.name == b.name ? 0 : a.name < b.name ? -1 : 1); for (let i = 0; i < length(llist); i++) { @@ -159,7 +159,7 @@ const link = entry.link; const status = calcColor(tracker); if (tracker) { - print(`
`); + print(`
`); } else { print(`
`); @@ -201,7 +201,7 @@ const link = entry.link; const status = calcColor(tracker); if (tracker) { - print(`
`); + print(`
`); } else { print(`
`); diff --git a/files/app/partial/status.ut b/files/app/partial/status.ut index d211cc69..40f56d16 100755 --- a/files/app/partial/status.ut +++ b/files/app/partial/status.ut @@ -62,6 +62,7 @@ {{_R("local-and-neighbor-devices")}}
+ {{_R("activator", "local-and-neighbor-devices")}}
diff --git a/files/app/resource/css/user.css b/files/app/resource/css/user.css index ad0d144f..0591dfc8 100755 --- a/files/app/resource/css/user.css +++ b/files/app/resource/css/user.css @@ -406,10 +406,11 @@ body.authenticated .ctrl:hover { flex: 0.75; } -body.authenticated #local-and-neighbor-devices .status.ctrl:hover +#local-and-neighbor-devices .status.ctrl:hover { padding: 7.5px 10px; margin: -10px -10px; + background-color: var(--ctrl-bg-color-hover); } #local-and-neighbor-devices .excellent {