summaryrefslogtreecommitdiffstats
path: root/ogcp/static/js/ogcp.js
diff options
context:
space:
mode:
authorJavier Sánchez Parra <jsanchez@soleta.eu>2022-05-04 17:22:38 +0200
committerJavier Sánchez Parra <jsanchez@soleta.eu>2022-05-06 09:55:58 +0200
commitce651453c420527208d2c7a26a9634de59b09a1e (patch)
tree76ea7f6013deb2b6bcda73f797e46d5ecc53b895 /ogcp/static/js/ogcp.js
parent72c10e15298aef311eed2aeb4774bf78029ea075 (diff)
Add MAC to pills
Retrieve and cache MACs one by one as users select clients.
Diffstat (limited to 'ogcp/static/js/ogcp.js')
-rw-r--r--ogcp/static/js/ogcp.js19
1 files changed, 18 insertions, 1 deletions
diff --git a/ogcp/static/js/ogcp.js b/ogcp/static/js/ogcp.js
index 4605e5d..ffddc58 100644
--- a/ogcp/static/js/ogcp.js
+++ b/ogcp/static/js/ogcp.js
@@ -1,16 +1,33 @@
const Endpoint = '/scopes/status';
+const macs = new Map();
const Interval = 1000;
let updateTimeoutId = null;
+async function show_client_mac(pill_id) {
+ const pill = $('#' +pill_id);
+ const ip = pill.html().split('<br>')[1]
+
+ if (!macs.get(ip)) {
+ const resp = await fetch('/client/mac?ip=' + ip);
+ const resp_mac = await resp.json();
+ macs.set(ip, resp_mac)
+ }
+
+ const mac = macs.get(ip)
+ pill.append('<br>' + mac);
+}
+
function showSelectedClient(client_checkbox) {
const container = $('#selected-clients');
const pill_id = 'pill-' + client_checkbox.name.replaceAll(/[.]|[ ]/g, '_');
if (client_checkbox.checked) {
- if (!($('#' + pill_id).length))
+ if (!($('#' + pill_id).length)) {
$(container).append('<div class="badge badge-pill og-pill badge-light" ' +
'id="'+ pill_id + '">' + client_checkbox.name +
'<br>' + client_checkbox.value + '</div>');
+ show_client_mac(pill_id);
+ }
return;
}