is this a fix or no
This commit is contained in:
+12
-2
@@ -1,6 +1,8 @@
|
||||
import { filter_array } from "./status.js";
|
||||
|
||||
export const qs = new URLSearchParams(location.search);
|
||||
|
||||
// not real cuh
|
||||
// $ is normally queryselector are we fr
|
||||
export const $ = (id) => document.getElementById(id);
|
||||
export const elName = $("name");
|
||||
export const elCheck = $("check");
|
||||
@@ -17,10 +19,18 @@ export function setPill(kind, text) {
|
||||
pill.textContent = text;
|
||||
}
|
||||
|
||||
export function setLink(name) {
|
||||
export function setLink(name, clear) {
|
||||
if (clear) location.search = "";
|
||||
const url = new URL(location.href);
|
||||
/* const hasExtraFilters = filter_array.some(
|
||||
(k) => url.searchParams.getAll(k).length
|
||||
);
|
||||
if (hasExtraFilters) {
|
||||
// jus returns whatever; they are specifying further
|
||||
} else */ {
|
||||
if (name) url.searchParams.set("name", name);
|
||||
else url.searchParams.delete("name");
|
||||
}
|
||||
history.replaceState(null, "", url);
|
||||
link.href = url.toString();
|
||||
}
|
||||
|
||||
@@ -42,7 +42,7 @@ function pickTarget(value) {
|
||||
elName.value = v;
|
||||
updatePreview();
|
||||
saveName(v);
|
||||
setLink(v);
|
||||
setLink(v, true);
|
||||
fetchStatus(v);
|
||||
fetchLeases();
|
||||
}
|
||||
@@ -74,10 +74,16 @@ const initial = loadName(qs);
|
||||
if (initial) {
|
||||
elName.value = initial;
|
||||
updatePreview();
|
||||
if (qs.has("name")) {
|
||||
setLink(initial);
|
||||
fetchStatus(initial);
|
||||
} else {
|
||||
fetchStatus();
|
||||
}
|
||||
fetchLeases();
|
||||
} else {
|
||||
setPill("warn", "unknown");
|
||||
updatePreview();
|
||||
fetchStatus();
|
||||
fetchLeases();
|
||||
}
|
||||
|
||||
@@ -8,8 +8,8 @@ const status_map = {
|
||||
state: "state",
|
||||
dev: "interface",
|
||||
};
|
||||
|
||||
const filter_array = ["ip", "dev", "nud", "mac"];
|
||||
export const status_array = Object.keys(status_map);
|
||||
export const filter_array = ["ip", "dev", "nud", "mac"];
|
||||
|
||||
function buildStatusUrl(name) {
|
||||
const hasExtraFilters = filter_array.some((k) => qs.getAll(k).length);
|
||||
@@ -18,7 +18,7 @@ function buildStatusUrl(name) {
|
||||
}
|
||||
const u = new URL("/api/status", location.origin);
|
||||
if (name) u.searchParams.set("name", name);
|
||||
for (const k of Object.keys(status_map)) {
|
||||
for (const k of filter_array) {
|
||||
const vals = qs.getAll(k);
|
||||
for (const v of vals) u.searchParams.append(k, v);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user