From ce570b46bded534281042f8836f536a3afb820f1 Mon Sep 17 00:00:00 2001 From: aceberg <1502200+aceberg@users.noreply.github.com> Date: Tue, 25 Mar 2025 00:18:19 +0700 Subject: [PATCH] Highlight sorted field --- frontend/src/components/Body/TableHead.tsx | 25 +++++++++++++++++----- frontend/src/functions/atstart.ts | 2 +- frontend/src/functions/exports.ts | 4 ++-- frontend/src/functions/filter.ts | 3 +-- frontend/src/functions/search.ts | 5 +---- frontend/src/functions/sort.ts | 6 ++---- frontend/src/pages/Body.tsx | 2 +- frontend/src/pages/History.tsx | 4 ++-- internal/web/public/assets/History.js | 2 +- internal/web/public/assets/index.js | 2 +- 10 files changed, 32 insertions(+), 23 deletions(-) diff --git a/frontend/src/components/Body/TableHead.tsx b/frontend/src/components/Body/TableHead.tsx index b36700a..dbfdf81 100644 --- a/frontend/src/components/Body/TableHead.tsx +++ b/frontend/src/components/Body/TableHead.tsx @@ -1,10 +1,22 @@ -import { For } from "solid-js"; +import { createSignal, For } from "solid-js"; import { Host } from "../../functions/exports"; import { sortByAnyField } from "../../functions/sort"; function TableHead() { + const [sortField, setSortField] = createSignal(''); + + const showSort = () => { + let field = localStorage.getItem("sortField") as string; + field === "Mac" ? field = "MAC" : ''; + field === "Hw" ? field = "Hardware" : ''; + field === "Now" ? field = "On" : ''; + setSortField(field); + }; + showSort(); + const handleSort = (sortBy: string) => { + setSortField(sortBy); sortBy === "MAC" ? sortBy = "Mac" : ''; sortBy === "Hardware" ? sortBy = "Hw" : ''; sortBy === "On" ? sortBy = "Now" : ''; @@ -16,10 +28,13 @@ function TableHead() { {(key) => - {key} + {key} } diff --git a/frontend/src/functions/atstart.ts b/frontend/src/functions/atstart.ts index 7d5b6ee..70a0fc8 100644 --- a/frontend/src/functions/atstart.ts +++ b/frontend/src/functions/atstart.ts @@ -29,7 +29,7 @@ function listIfaces() { let ifaces:string[] = []; - for (let host of allHosts()) { + for (let host of allHosts) { if (!ifaces.includes(host.Iface)) { ifaces.push(host.Iface); } diff --git a/frontend/src/functions/exports.ts b/frontend/src/functions/exports.ts index 31c1eb2..70b1d3a 100644 --- a/frontend/src/functions/exports.ts +++ b/frontend/src/functions/exports.ts @@ -1,4 +1,5 @@ import { createSignal } from "solid-js"; +import { createStore } from "solid-js/store"; export interface Host { ID: number; @@ -80,8 +81,7 @@ export const emptyConf:Conf = { PrometheusEnable: false, }; - -export const [allHosts, setAllHosts] = createSignal([]); +export const [allHosts, setAllHosts] = createStore([]); export const [bkpHosts, setBkpHosts] = createSignal([]); export const [ifaces, setIfaces] = createSignal([]); diff --git a/frontend/src/functions/filter.ts b/frontend/src/functions/filter.ts index 6034563..15a5c64 100644 --- a/frontend/src/functions/filter.ts +++ b/frontend/src/functions/filter.ts @@ -11,7 +11,7 @@ export function filterAtStart() { export function filterFunc(field: keyof Host, value: any) { - let addrsArray = allHosts(); + let addrsArray = allHosts; if (oldFilter == field) { addrsArray = bkpHosts(); @@ -35,6 +35,5 @@ export function filterFunc(field: keyof Host, value: any) { addrsArray = bkpHosts(); } - setAllHosts([]); setAllHosts(addrsArray); } \ No newline at end of file diff --git a/frontend/src/functions/search.ts b/frontend/src/functions/search.ts index 91e6369..dc04344 100644 --- a/frontend/src/functions/search.ts +++ b/frontend/src/functions/search.ts @@ -7,18 +7,15 @@ export function searchFunc(s: string) { const sl = s.toLowerCase(); let newArray:Host[] = []; - for (let item of allHosts()) { + for (let item of allHosts) { if (searchItem(item, sl)) { newArray.push(item); } } - setAllHosts([]); setAllHosts(newArray); - } else { - setAllHosts([]); setAllHosts(bkpHosts()); } } diff --git a/frontend/src/functions/sort.ts b/frontend/src/functions/sort.ts index 70c4c53..551575d 100644 --- a/frontend/src/functions/sort.ts +++ b/frontend/src/functions/sort.ts @@ -1,4 +1,4 @@ -import { allHosts, Host, setAllHosts } from "./exports"; +import { bkpHosts, Host, setAllHosts } from "./exports"; let down = false; let oldField = ''; @@ -23,16 +23,14 @@ export function sortByAnyField(field: keyof Host) { localStorage.setItem("sortDown", down.toString()); localStorage.setItem("sortField", field); - // checkNotEmpty(addrsArray); - let someArray = allHosts(); + let someArray = bkpHosts(); if (field == 'IP') { someArray.sort((a, b) => sortIP(a, b, down)); } else { someArray.sort((a, b) => byField(a, b, field, down)); } - setAllHosts([]); setAllHosts(someArray); } diff --git a/frontend/src/pages/Body.tsx b/frontend/src/pages/Body.tsx index 1e7e2ee..64e3c94 100644 --- a/frontend/src/pages/Body.tsx +++ b/frontend/src/pages/Body.tsx @@ -17,7 +17,7 @@ function Body() { - {(host, index) => + {(host, index) => } diff --git a/frontend/src/pages/History.tsx b/frontend/src/pages/History.tsx index 97d9096..4729e40 100644 --- a/frontend/src/pages/History.tsx +++ b/frontend/src/pages/History.tsx @@ -19,9 +19,9 @@ function History() {
- {(host, index) => + {(host, index) => - +
{index()}.{index()+1}. {host.Name}

{host.IP} diff --git a/internal/web/public/assets/History.js b/internal/web/public/assets/History.js index dd38d8e..1c625b5 100644 --- a/internal/web/public/assets/History.js +++ b/internal/web/public/assets/History.js @@ -1 +1 @@ -import{k as f,l as m,t as _,i as t,e as a,m as C,b as H,s as v,n as I,F}from"./index.js";import{H as M,M as N}from"./HistShow.js";var P=_('
'),j=_("
.
");function D(){const $=localStorage.getItem("histShow");return f(+$),(m()===0||isNaN(m()))&&f(200),(()=>{var d=P(),l=d.firstChild,u=l.nextSibling,S=u.firstChild,g=S.firstChild;return t(l,a(C,{}),null),t(l,a(M,{name:"histShow"}),null),t(g,a(F,{get each(){return I()},children:(e,y)=>(()=>{var n=j(),i=n.firstChild,w=i.firstChild,o=i.nextSibling,s=o.firstChild,p=s.nextSibling,c=p.nextSibling,x=o.nextSibling;return t(i,y,w),t(s,()=>e.Name),t(c,()=>e.IP),t(x,a(N,{get mac(){return e.Mac}})),H(r=>{var h="/host/"+e.ID,b="http://"+e.IP;return h!==r.e&&v(s,"href",r.e=h),b!==r.t&&v(c,"href",r.t=b),r},{e:void 0,t:void 0}),n})()})),d})()}export{D as default}; +import{k as f,l as m,t as _,i as t,e as a,m as C,n as H,b as I,s as v,F}from"./index.js";import{H as M,M as N}from"./HistShow.js";var P=_('
'),j=_("
.
");function D(){const $=localStorage.getItem("histShow");return f(+$),(m()===0||isNaN(m()))&&f(200),(()=>{var d=P(),l=d.firstChild,u=l.nextSibling,S=u.firstChild,y=S.firstChild;return t(l,a(C,{}),null),t(l,a(M,{name:"histShow"}),null),t(y,a(F,{each:H,children:(e,g)=>(()=>{var n=j(),i=n.firstChild,w=i.firstChild,o=i.nextSibling,s=o.firstChild,p=s.nextSibling,c=p.nextSibling,x=o.nextSibling;return t(i,()=>g()+1,w),t(s,()=>e.Name),t(c,()=>e.IP),t(x,a(N,{get mac(){return e.Mac}})),I(r=>{var h="/host/"+e.ID,b="http://"+e.IP;return h!==r.e&&v(s,"href",r.e=h),b!==r.t&&v(c,"href",r.t=b),r},{e:void 0,t:void 0}),n})()})),d})()}export{D as default}; diff --git a/internal/web/public/assets/index.js b/internal/web/public/assets/index.js index 54042a6..da02364 100644 --- a/internal/web/public/assets/index.js +++ b/internal/web/public/assets/index.js @@ -1,2 +1,2 @@ const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["fs/public/assets/History.js","fs/public/assets/HistShow.js","fs/public/assets/HostPage.js"])))=>i.map(i=>d[i]); -(function(){const t=document.createElement("link").relList;if(t&&t.supports&&t.supports("modulepreload"))return;for(const s of document.querySelectorAll('link[rel="modulepreload"]'))r(s);new MutationObserver(s=>{for(const o of s)if(o.type==="childList")for(const i of o.addedNodes)i.tagName==="LINK"&&i.rel==="modulepreload"&&r(i)}).observe(document,{childList:!0,subtree:!0});function n(s){const o={};return s.integrity&&(o.integrity=s.integrity),s.referrerPolicy&&(o.referrerPolicy=s.referrerPolicy),s.crossOrigin==="use-credentials"?o.credentials="include":s.crossOrigin==="anonymous"?o.credentials="omit":o.credentials="same-origin",o}function r(s){if(s.ep)return;s.ep=!0;const o=n(s);fetch(s.href,o)}})();const w={context:void 0,registry:void 0,effects:void 0,done:!1,getContextId(){return Ge(this.context.count)},getNextContextId(){return Ge(this.context.count++)}};function Ge(e){const t=String(e),n=t.length-1;return w.context.id+(n?String.fromCharCode(96+n):"")+t}function se(e){w.context=e}const st=!1,_t=(e,t)=>e===t,Oe=Symbol("solid-proxy"),Et=typeof Proxy=="function",It=Symbol("solid-track"),he={equals:_t};let ot=ht;const W=1,pe=2,it={owned:null,cleanups:null,context:null,owner:null},Ae={};var b=null;let Pe=null,kt=null,$=null,T=null,V=null,be=0;function oe(e,t){const n=$,r=b,s=e.length===0,o=t===void 0?r:t,i=s?it:{owned:null,cleanups:null,context:o?o.context:null,owner:o},l=s?e:()=>e(()=>j(()=>le(i)));b=i,$=null;try{return B(l,!0)}finally{$=n,b=r}}function L(e,t){t=t?Object.assign({},he,t):he;const n={value:e,observers:null,observerSlots:null,comparator:t.equals||void 0},r=s=>(typeof s=="function"&&(s=s(n.value)),dt(n,s));return[ft.bind(n),r]}function Lt(e,t,n){const r=ve(e,t,!0,W);te(r)}function q(e,t,n){const r=ve(e,t,!1,W);te(r)}function Ot(e,t,n){ot=Kt;const r=ve(e,t,!1,W);r.user=!0,V?V.push(r):te(r)}function R(e,t,n){n=n?Object.assign({},he,n):he;const r=ve(e,t,!0,0);return r.observers=null,r.observerSlots=null,r.comparator=n.equals||void 0,te(r),ft.bind(r)}function Rt(e){return e&&typeof e=="object"&&"then"in e}function Nt(e,t,n){let r,s,o;r=!0,s=e,o={};let i=null,l=Ae,a=null,c=!1,f="initialValue"in o,u=typeof r=="function"&&R(r);const p=new Set,[h,y]=(o.storage||L)(o.initialValue),[d,g]=L(void 0),[v,m]=L(void 0,{equals:!1}),[C,x]=L(f?"ready":"unresolved");w.context&&(a=w.getNextContextId(),o.ssrLoadFrom==="initial"?l=o.initialValue:w.load&&w.has(a)&&(l=w.load(a)));function E(I,_,k,X){return i===I&&(i=null,X!==void 0&&(f=!0),(I===l||_===l)&&o.onHydrated&&queueMicrotask(()=>o.onHydrated(X,{value:_})),l=Ae,H(_,k)),_}function H(I,_){B(()=>{_===void 0&&y(()=>I),x(_!==void 0?"errored":f?"ready":"unresolved"),g(_);for(const k of p.keys())k.decrement();p.clear()},!1)}function N(){const I=Ft,_=h(),k=d();if(k!==void 0&&!i)throw k;return $&&$.user,_}function U(I=!0){if(I!==!1&&c)return;c=!1;const _=u?u():r;if(_==null||_===!1){E(i,j(h));return}const k=l!==Ae?l:j(()=>s(_,{value:h(),refetching:I}));return Rt(k)?(i=k,"value"in k?(k.status==="success"?E(i,k.value,void 0,_):E(i,void 0,Re(k.value),_),k):(c=!0,queueMicrotask(()=>c=!1),B(()=>{x(f?"refreshing":"pending"),m()},!1),k.then(X=>E(k,X,void 0,_),X=>E(k,void 0,Re(X),_)))):(E(i,k,void 0,_),k)}return Object.defineProperties(N,{state:{get:()=>C()},error:{get:()=>d()},loading:{get(){const I=C();return I==="pending"||I==="refreshing"}},latest:{get(){if(!f)return N();const I=d();if(I&&!i)throw I;return h()}}}),u?Lt(()=>U(!1)):U(!1),[N,{refetch:U,mutate:y}]}function Tt(e){return B(e,!1)}function j(e){if($===null)return e();const t=$;$=null;try{return e()}finally{$=t}}function Fe(e,t,n){const r=Array.isArray(e);let s,o=n&&n.defer;return i=>{let l;if(r){l=Array(e.length);for(let c=0;ct(l,s,i));return s=l,a}}function Dt(e){Ot(()=>j(e))}function He(e){return b===null||(b.cleanups===null?b.cleanups=[e]:b.cleanups.push(e)),e}function lt(){return b}function at(e,t){const n=b,r=$;b=e,$=null;try{return B(t,!0)}catch(s){Ke(s)}finally{b=n,$=r}}function jt(e){const t=$,n=b;return Promise.resolve().then(()=>{$=t,b=n;let r;return B(e,!1),$=b=null,r?r.done:void 0})}const[hr,pr]=L(!1);function ct(e,t){const n=Symbol("context");return{id:n,Provider:Bt(n),defaultValue:e}}function ut(e){let t;return b&&b.context&&(t=b.context[e.id])!==void 0?t:e.defaultValue}function Ue(e){const t=R(e),n=R(()=>Ne(t()));return n.toArray=()=>{const r=n();return Array.isArray(r)?r:r!=null?[r]:[]},n}let Ft;function ft(){if(this.sources&&this.state)if(this.state===W)te(this);else{const e=T;T=null,B(()=>me(this),!1),T=e}if($){const e=this.observers?this.observers.length:0;$.sources?($.sources.push(this),$.sourceSlots.push(e)):($.sources=[this],$.sourceSlots=[e]),this.observers?(this.observers.push($),this.observerSlots.push($.sources.length-1)):(this.observers=[$],this.observerSlots=[$.sources.length-1])}return this.value}function dt(e,t,n){let r=e.value;return(!e.comparator||!e.comparator(r,t))&&(e.value=t,e.observers&&e.observers.length&&B(()=>{for(let s=0;s1e6)throw T=[],new Error},!1)),t}function te(e){if(!e.fn)return;le(e);const t=be;Ht(e,e.value,t)}function Ht(e,t,n){let r;const s=b,o=$;$=b=e;try{r=e.fn(t)}catch(i){return e.pure&&(e.state=W,e.owned&&e.owned.forEach(le),e.owned=null),e.updatedAt=n+1,Ke(i)}finally{$=o,b=s}(!e.updatedAt||e.updatedAt<=n)&&(e.updatedAt!=null&&"observers"in e?dt(e,r):e.value=r,e.updatedAt=n)}function ve(e,t,n,r=W,s){const o={fn:e,state:r,updatedAt:null,owned:null,sources:null,sourceSlots:null,cleanups:null,value:t,owner:b,context:b?b.context:null,pure:n};return b===null||b!==it&&(b.owned?b.owned.push(o):b.owned=[o]),o}function ge(e){if(e.state===0)return;if(e.state===pe)return me(e);if(e.suspense&&j(e.suspense.inFallback))return e.suspense.effects.push(e);const t=[e];for(;(e=e.owner)&&(!e.updatedAt||e.updatedAt=0;n--)if(e=t[n],e.state===W)te(e);else if(e.state===pe){const r=T;T=null,B(()=>me(e,t[0]),!1),T=r}}function B(e,t){if(T)return e();let n=!1;t||(T=[]),V?n=!0:V=[],be++;try{const r=e();return Ut(n),r}catch(r){n||(V=null),T=null,Ke(r)}}function Ut(e){if(T&&(ht(T),T=null),e)return;const t=V;V=null,t.length&&B(()=>ot(t),!1)}function ht(e){for(let t=0;t=0;t--)le(e.tOwned[t]);delete e.tOwned}if(e.owned){for(t=e.owned.length-1;t>=0;t--)le(e.owned[t]);e.owned=null}if(e.cleanups){for(t=e.cleanups.length-1;t>=0;t--)e.cleanups[t]();e.cleanups=null}e.state=0}function Re(e){return e instanceof Error?e:new Error(typeof e=="string"?e:"Unknown error",{cause:e})}function Ke(e,t=b){throw Re(e)}function Ne(e){if(typeof e=="function"&&!e.length)return Ne(e());if(Array.isArray(e)){const t=[];for(let n=0;ns=j(()=>(b.context={...b.context,[e]:r.value},Ue(()=>r.children))),void 0),s}}const Mt=Symbol("fallback");function Xe(e){for(let t=0;t1?[]:null;return He(()=>Xe(o)),()=>{let a=e()||[],c=a.length,f,u;return a[It],j(()=>{let h,y,d,g,v,m,C,x,E;if(c===0)i!==0&&(Xe(o),o=[],r=[],s=[],i=0,l&&(l=[])),n.fallback&&(r=[Mt],s[0]=oe(H=>(o[0]=H,n.fallback())),i=1);else if(i===0){for(s=new Array(c),u=0;u=m&&x>=m&&r[C]===a[x];C--,x--)d[x]=s[C],g[x]=o[C],l&&(v[x]=l[C]);for(h=new Map,y=new Array(x+1),u=x;u>=m;u--)E=a[u],f=h.get(E),y[u]=f===void 0?-1:f,h.set(E,u);for(f=m;f<=C;f++)E=r[f],u=h.get(E),u!==void 0&&u!==-1?(d[u]=s[f],g[u]=o[f],l&&(v[u]=l[f]),u=y[u],h.set(E,u)):o[f]();for(u=m;ue(t||{}))}function ue(){return!0}const qt={get(e,t,n){return t===Oe?n:e.get(t)},has(e,t){return t===Oe?!0:e.has(t)},set:ue,deleteProperty:ue,getOwnPropertyDescriptor(e,t){return{configurable:!0,enumerable:!0,get(){return e.get(t)},set:ue,deleteProperty:ue}},ownKeys(e){return e.keys()}};function Ce(e){return(e=typeof e=="function"?e():e)?e:{}}function Wt(){for(let e=0,t=this.length;e=0;l--){const a=Ce(e[l])[i];if(a!==void 0)return a}},has(i){for(let l=e.length-1;l>=0;l--)if(i in Ce(e[l]))return!0;return!1},keys(){const i=[];for(let l=0;l=0;i--){const l=e[i];if(!l)continue;const a=Object.getOwnPropertyNames(l);for(let c=a.length-1;c>=0;c--){const f=a[c];if(f==="__proto__"||f==="constructor")continue;const u=Object.getOwnPropertyDescriptor(l,f);if(!r[f])r[f]=u.get?{enumerable:!0,configurable:!0,get:Wt.bind(n[f]=[u.get.bind(l)])}:u.value!==void 0?u:void 0;else{const p=n[f];p&&(u.get?p.push(u.get.bind(l)):u.value!==void 0&&p.push(()=>u.value))}}}const s={},o=Object.keys(r);for(let i=o.length-1;i>=0;i--){const l=o[i],a=r[l];a&&a.get?Object.defineProperty(s,l,a):s[l]=a?a.value:void 0}return s}function _e(e){let t,n;const r=s=>{const o=w.context;if(o){const[l,a]=L();w.count||(w.count=0),w.count++,(n||(n=e())).then(c=>{!w.done&&se(o),w.count--,a(()=>c.default),se()}),t=l}else if(!t){const[l]=Nt(()=>(n||(n=e())).then(a=>a.default));t=l}let i;return R(()=>(i=t())?j(()=>{if(!o||w.done)return i(s);const l=w.context;se(o);const a=i(s);return se(l),a}):"")};return r.preload=()=>n||((n=e()).then(s=>t=()=>s.default),n),r}const Xt=e=>`Stale read from <${e}>.`;function Be(e){const t="fallback"in e&&{fallback:()=>e.fallback};return R(Vt(()=>e.each,e.children,t||void 0))}function $e(e){const t=e.keyed,n=R(()=>e.when,void 0,void 0),r=t?n:R(n,void 0,{equals:(s,o)=>!s==!o});return R(()=>{const s=r();if(s){const o=e.children;return typeof o=="function"&&o.length>0?j(()=>o(t?s:()=>{if(!j(r))throw Xt("Show");return n()})):o}return e.fallback},void 0,void 0)}function Yt(e,t,n){let r=n.length,s=t.length,o=r,i=0,l=0,a=t[s-1].nextSibling,c=null;for(;if-l){const y=t[i];for(;l{s=o,t===document?e():O(t,e(),t.firstChild?null:void 0,n)},r.owner),()=>{s(),t.textContent=""}}function D(e,t,n,r){let s;const o=()=>{const l=document.createElement("template");return l.innerHTML=e,l.content.firstChild},i=()=>(s||(s=o())).cloneNode(!0);return i.cloneNode=i,i}function ne(e,t=window.document){const n=t[Ye]||(t[Ye]=new Set);for(let r=0,s=e.length;rwe(e,t(),s,n),r)}function Me(e){return!!w.context&&!w.done&&(!e||e.isConnected)}function Qt(e){if(w.registry&&w.events&&w.events.find(([a,c])=>c===e))return;let t=e.target;const n=`$$${e.type}`,r=e.target,s=e.currentTarget,o=a=>Object.defineProperty(e,"target",{configurable:!0,value:a}),i=()=>{const a=t[n];if(a&&!t.disabled){const c=t[`${n}Data`];if(c!==void 0?a.call(t,c,e):a.call(t,e),e.cancelBubble)return}return t.host&&typeof t.host!="string"&&!t.host._$host&&t.contains(e.target)&&o(t.host),!0},l=()=>{for(;i()&&(t=t._$host||t.parentNode||t.host););};if(Object.defineProperty(e,"currentTarget",{configurable:!0,get(){return t||document}}),w.registry&&!w.done&&(w.done=_$HY.done=!0),e.composedPath){const a=e.composedPath();o(a[0]);for(let c=0;c{let a=t();for(;typeof a=="function";)a=a();n=we(e,a,n,r)}),()=>n;if(Array.isArray(t)){const a=[],c=n&&Array.isArray(n);if(Te(a,t,n,s))return q(()=>n=we(e,a,n,r,!0)),()=>n;if(o){if(!a.length)return n;if(r===void 0)return n=[...e.childNodes];let f=a[0];if(f.parentNode!==e)return n;const u=[f];for(;(f=f.nextSibling)!==r;)u.push(f);return n=u}if(a.length===0){if(n=z(e,n,r),l)return n}else c?n.length===0?Je(e,a,r):Yt(e,n,a):(n&&z(e),Je(e,a));n=a}else if(t.nodeType){if(o&&t.parentNode)return n=l?[t]:t;if(Array.isArray(n)){if(l)return n=z(e,n,r,t);z(e,n,null,t)}else n==null||n===""||!e.firstChild?e.appendChild(t):e.replaceChild(t,e.firstChild);n=t}}return n}function Te(e,t,n,r){let s=!1;for(let o=0,i=t.length;o=0;i--){const l=t[i];if(s!==l){const a=l.parentNode===e;!o&&!i?a?e.replaceChild(s,l):e.insertBefore(s,n):a&&l.remove()}else o=!0}}else e.insertBefore(s,n);return[s]}const Zt=!1,zt="modulepreload",en=function(e){return"/"+e},Qe={},Ee=function(t,n,r){let s=Promise.resolve();if(n&&n.length>0){document.getElementsByTagName("link");const i=document.querySelector("meta[property=csp-nonce]"),l=(i==null?void 0:i.nonce)||(i==null?void 0:i.getAttribute("nonce"));s=Promise.allSettled(n.map(a=>{if(a=en(a),a in Qe)return;Qe[a]=!0;const c=a.endsWith(".css"),f=c?'[rel="stylesheet"]':"";if(document.querySelector(`link[href="${a}"]${f}`))return;const u=document.createElement("link");if(u.rel=c?"stylesheet":zt,c||(u.as="script"),u.crossOrigin="",u.href=a,l&&u.setAttribute("nonce",l),document.head.appendChild(u),c)return new Promise((p,h)=>{u.addEventListener("load",p),u.addEventListener("error",()=>h(new Error(`Unable to preload CSS for ${a}`)))})}))}function o(i){const l=new Event("vite:preloadError",{cancelable:!0});if(l.payload=i,window.dispatchEvent(l),!l.defaultPrevented)throw i}return s.then(i=>{for(const l of i||[])l.status==="rejected"&&o(l.reason);return t().catch(o)})};function gt(){let e=new Set;function t(s){return e.add(s),()=>e.delete(s)}let n=!1;function r(s,o){if(n)return!(n=!1);const i={to:s,options:o,defaultPrevented:!1,preventDefault:()=>i.defaultPrevented=!0};for(const l of e)l.listener({...i,from:l.location,retry:a=>{a&&(n=!0),l.navigate(s,{...o,resolve:!1})}});return!i.defaultPrevented}return{subscribe:t,confirm:r}}let De;function Ve(){(!window.history.state||window.history.state._depth==null)&&window.history.replaceState({...window.history.state,_depth:window.history.length-1},""),De=window.history.state._depth}Ve();function tn(e){return{...e,_depth:window.history.state&&window.history.state._depth}}function nn(e,t){let n=!1;return()=>{const r=De;Ve();const s=r==null?null:De-r;if(n){n=!1;return}s&&t(s)?(n=!0,window.history.go(-s)):e()}}const rn=/^(?:[a-z0-9]+:)?\/\//i,sn=/^\/+|(\/)\/+$/g,mt="http://sr";function ie(e,t=!1){const n=e.replace(sn,"$1");return n?t||/^[?#]/.test(n)?n:"/"+n:""}function de(e,t,n){if(rn.test(t))return;const r=ie(e),s=n&&ie(n);let o="";return!s||t.startsWith("/")?o=r:s.toLowerCase().indexOf(r.toLowerCase())!==0?o=r+s:o=s,(o||"/")+ie(t,!o)}function on(e,t){if(e==null)throw new Error(t);return e}function ln(e,t){return ie(e).replace(/\/*(\*.*)?$/g,"")+ie(t)}function wt(e){const t={};return e.searchParams.forEach((n,r)=>{r in t?Array.isArray(t[r])?t[r].push(n):t[r]=[t[r],n]:t[r]=n}),t}function an(e,t,n){const[r,s]=e.split("/*",2),o=r.split("/").filter(Boolean),i=o.length;return l=>{const a=l.split("/").filter(Boolean),c=a.length-i;if(c<0||c>0&&s===void 0&&!t)return null;const f={path:i?"":"/",params:{}},u=p=>n===void 0?void 0:n[p];for(let p=0;pr===e;return t===void 0?!0:typeof t=="string"?n(t):typeof t=="function"?t(e):Array.isArray(t)?t.some(n):t instanceof RegExp?t.test(e):!1}function cn(e){const[t,n]=e.pattern.split("/*",2),r=t.split("/").filter(Boolean);return r.reduce((s,o)=>s+(o.startsWith(":")?2:3),r.length-(n===void 0?0:1))}function yt(e){const t=new Map,n=lt();return new Proxy({},{get(r,s){return t.has(s)||at(n,()=>t.set(s,R(()=>e()[s]))),t.get(s)()},getOwnPropertyDescriptor(){return{enumerable:!0,configurable:!0}},ownKeys(){return Reflect.ownKeys(e())}})}function bt(e){let t=/(\/?\:[^\/]+)\?/.exec(e);if(!t)return[e];let n=e.slice(0,t.index),r=e.slice(t.index+t[0].length);const s=[n,n+=t[1]];for(;t=/^(\/\:[^\/]+)\?/.exec(r);)s.push(n+=t[1]),r=r.slice(t[0].length);return bt(r).reduce((o,i)=>[...o,...s.map(l=>l+i)],[])}const un=100,vt=ct(),$t=ct(),fn=()=>on(ut(vt)," and 'use' router primitives can be only used inside a Route."),mr=()=>fn().params;function dn(e,t=""){const{component:n,preload:r,load:s,children:o,info:i}=e,l=!o||Array.isArray(o)&&!o.length,a={key:e,component:n,preload:r||s,info:i};return St(e.path).reduce((c,f)=>{for(const u of bt(f)){const p=ln(t,u);let h=l?p:p.split("/*",1)[0];h=h.split("/").map(y=>y.startsWith(":")||y.startsWith("*")?y:encodeURIComponent(y)).join("/"),c.push({...a,originalPath:f,pattern:h,matcher:an(h,!l,e.matchFilters)})}return c},[])}function hn(e,t=0){return{routes:e,score:cn(e[e.length-1])*1e4-t,matcher(n){const r=[];for(let s=e.length-1;s>=0;s--){const o=e[s],i=o.matcher(n);if(!i)return null;r.unshift({...i,route:o})}return r}}}function St(e){return Array.isArray(e)?e:[e]}function xt(e,t="",n=[],r=[]){const s=St(e);for(let o=0,i=s.length;oi.score-o.score)}function ke(e,t){for(let n=0,r=e.length;n{const u=e();try{return new URL(u,r)}catch{return console.error(`Invalid path ${u}`),f}},r,{equals:(f,u)=>f.href===u.href}),o=R(()=>s().pathname),i=R(()=>s().search,!0),l=R(()=>s().hash),a=()=>"",c=Fe(i,()=>wt(s()));return{get pathname(){return o()},get search(){return i()},get hash(){return l()},get state(){return t()},get key(){return a()},query:n?n(c):yt(c)}}let J;function gn(){return J}function mn(e,t,n,r={}){const{signal:[s,o],utils:i={}}=e,l=i.parsePath||(S=>S),a=i.renderPath||(S=>S),c=i.beforeLeave||gt(),f=de("",r.base||"");if(f===void 0)throw new Error(`${f} is not a valid base path`);f&&!s().value&&o({value:f,replace:!0,scroll:!1});const[u,p]=L(!1);let h;const y=(S,A)=>{A.value===d()&&A.state===v()||(h===void 0&&p(!0),J=S,h=A,jt(()=>{h===A&&(g(h.value),m(h.state),E[1](F=>F.filter(Q=>Q.pending)))}).finally(()=>{h===A&&Tt(()=>{J=void 0,S==="navigate"&&X(h),p(!1),h=void 0})}))},[d,g]=L(s().value),[v,m]=L(s().state),C=pn(d,v,i.queryWrapper),x=[],E=L([]),H=R(()=>typeof r.transformUrl=="function"?ke(t(),r.transformUrl(C.pathname)):ke(t(),C.pathname)),N=()=>{const S=H(),A={};for(let F=0;Ff,outlet:()=>null,resolvePath(S){return de(f,S)}};return q(Fe(s,S=>y("native",S),{defer:!0})),{base:I,location:C,params:U,isRouting:u,renderPath:a,parsePath:l,navigatorFactory:k,matches:H,beforeLeave:c,preloadRoute:Ct,singleFlight:r.singleFlight===void 0?!0:r.singleFlight,submissions:E};function _(S,A,F){j(()=>{if(typeof A=="number"){A&&(i.go?i.go(A):console.warn("Router integration does not support relative routing"));return}const Q=!A||A[0]==="?",{replace:Se,resolve:Z,scroll:xe,state:re}={replace:!1,resolve:!Q,scroll:!0,...F},ce=Z?S.resolvePath(A):de(Q&&C.pathname||"",A);if(ce===void 0)throw new Error(`Path '${A}' is not a routable path`);if(x.length>=un)throw new Error("Too many redirects");const We=d();(ce!==We||re!==v())&&(Zt||c.confirm(ce,F)&&(x.push({value:We,replace:Se,scroll:xe,state:v()}),y("navigate",{value:ce,state:re})))})}function k(S){return S=S||ut($t)||I,(A,F)=>_(S,A,F)}function X(S){const A=x[0];A&&(o({...S,replace:A.replace,scroll:A.scroll}),x.length=0)}function Ct(S,A){const F=ke(t(),S.pathname),Q=J;J="preload";for(let Se in F){const{route:Z,params:xe}=F[Se];Z.component&&Z.component.preload&&Z.component.preload();const{preload:re}=Z;A&&re&&at(n(),()=>re({params:xe,location:{pathname:S.pathname,search:S.search,hash:S.hash,query:wt(S),state:null,key:""},intent:"preload"}))}J=Q}}function wn(e,t,n,r){const{base:s,location:o,params:i}=e,{pattern:l,component:a,preload:c}=r().route,f=R(()=>r().path);a&&a.preload&&a.preload();const u=c?c({params:i,location:o,intent:J||"initial"}):void 0;return{parent:t,pattern:l,path:f,outlet:()=>a?P(a,{params:i,location:o,data:u,get children(){return n()}}):n(),resolvePath(h){return de(s.path(),h,f())}}}const yn=e=>t=>{const{base:n}=t,r=Ue(()=>t.children),s=R(()=>xt(r(),t.base||""));let o;const i=mn(e,s,()=>o,{base:n,singleFlight:t.singleFlight,transformUrl:t.transformUrl});return e.create&&e.create(i),P(vt.Provider,{value:i,get children(){return P(bn,{routerState:i,get root(){return t.root},get preload(){return t.rootPreload||t.rootLoad},get children(){return[R(()=>(o=lt())&&null),P(vn,{routerState:i,get branches(){return s()}})]}})}})};function bn(e){const t=e.routerState.location,n=e.routerState.params,r=R(()=>e.preload&&j(()=>{e.preload({params:n,location:t,intent:gn()||"initial"})}));return P($e,{get when(){return e.root},keyed:!0,get fallback(){return e.children},children:s=>P(s,{params:n,location:t,get data(){return r()},get children(){return e.children}})})}function vn(e){const t=[];let n;const r=R(Fe(e.routerState.matches,(s,o,i)=>{let l=o&&s.length===o.length;const a=[];for(let c=0,f=s.length;c{t[c]=h,a[c]=wn(e.routerState,a[c-1]||e.routerState.base,Ze(()=>r()[c+1]),()=>e.routerState.matches()[c])}))}return t.splice(s.length).forEach(c=>c()),i&&l?i:(n=a[0],a)}));return Ze(()=>r()&&n)()}const Ze=e=>()=>P($e,{get when(){return e()},keyed:!0,children:t=>P($t.Provider,{value:t,get children(){return t.outlet()}})}),fe=e=>{const t=Ue(()=>e.children);return Gt(e,{get children(){return t()}})};function $n([e,t],n,r){return[e,r?s=>t(r(s)):t]}function Sn(e){let t=!1;const n=s=>typeof s=="string"?{value:s}:s,r=$n(L(n(e.get()),{equals:(s,o)=>s.value===o.value&&s.state===o.state}),void 0,s=>(!t&&e.set(s),w.registry&&!w.done&&(w.done=!0),s));return e.init&&He(e.init((s=e.get())=>{t=!0,r[1](n(s)),t=!1})),yn({signal:r,create:e.create,utils:e.utils})}function xn(e,t,n){return e.addEventListener(t,n),()=>e.removeEventListener(t,n)}function An(e,t){const n=e&&document.getElementById(e);n?n.scrollIntoView():t&&window.scrollTo(0,0)}const Pn=new Map;function Cn(e=!0,t=!1,n="/_server",r){return s=>{const o=s.base.path(),i=s.navigatorFactory(s.base);let l,a;function c(d){return d.namespaceURI==="http://www.w3.org/2000/svg"}function f(d){if(d.defaultPrevented||d.button!==0||d.metaKey||d.altKey||d.ctrlKey||d.shiftKey)return;const g=d.composedPath().find(H=>H instanceof Node&&H.nodeName.toUpperCase()==="A");if(!g||t&&!g.hasAttribute("link"))return;const v=c(g),m=v?g.href.baseVal:g.href;if((v?g.target.baseVal:g.target)||!m&&!g.hasAttribute("state"))return;const x=(g.getAttribute("rel")||"").split(/\s+/);if(g.hasAttribute("download")||x&&x.includes("external"))return;const E=v?new URL(m,document.baseURI):new URL(m);if(!(E.origin!==window.location.origin||o&&E.pathname&&!E.pathname.toLowerCase().startsWith(o.toLowerCase())))return[g,E]}function u(d){const g=f(d);if(!g)return;const[v,m]=g,C=s.parsePath(m.pathname+m.search+m.hash),x=v.getAttribute("state");d.preventDefault(),i(C,{resolve:!1,replace:v.hasAttribute("replace"),scroll:!v.hasAttribute("noscroll"),state:x?JSON.parse(x):void 0})}function p(d){const g=f(d);if(!g)return;const[v,m]=g;r&&(m.pathname=r(m.pathname)),s.preloadRoute(m,v.getAttribute("preload")!=="false")}function h(d){clearTimeout(l);const g=f(d);if(!g)return a=null;const[v,m]=g;a!==v&&(r&&(m.pathname=r(m.pathname)),l=setTimeout(()=>{s.preloadRoute(m,v.getAttribute("preload")!=="false"),a=v},20))}function y(d){if(d.defaultPrevented)return;let g=d.submitter&&d.submitter.hasAttribute("formaction")?d.submitter.getAttribute("formaction"):d.target.getAttribute("action");if(!g)return;if(!g.startsWith("https://action/")){const m=new URL(g,mt);if(g=s.parsePath(m.pathname+m.search),!g.startsWith(n))return}if(d.target.method.toUpperCase()!=="POST")throw new Error("Only POST forms are supported for Actions");const v=Pn.get(g);if(v){d.preventDefault();const m=new FormData(d.target,d.submitter);v.call({r:s,f:d.target},d.target.enctype==="multipart/form-data"?m:new URLSearchParams(m))}}ne(["click","submit"]),document.addEventListener("click",u),e&&(document.addEventListener("mousemove",h,{passive:!0}),document.addEventListener("focusin",p,{passive:!0}),document.addEventListener("touchstart",p,{passive:!0})),document.addEventListener("submit",y),He(()=>{document.removeEventListener("click",u),e&&(document.removeEventListener("mousemove",h),document.removeEventListener("focusin",p),document.removeEventListener("touchstart",p)),document.removeEventListener("submit",y)})}}function _n(e){const t=()=>{const r=window.location.pathname.replace(/^\/+/,"/")+window.location.search,s=window.history.state&&window.history.state._depth&&Object.keys(window.history.state).length===1?void 0:window.history.state;return{value:r+window.location.hash,state:s}},n=gt();return Sn({get:t,set({value:r,replace:s,scroll:o,state:i}){s?window.history.replaceState(tn(i),"",r):window.history.pushState(i,"",r),An(decodeURIComponent(window.location.hash.slice(1)),o),Ve()},init:r=>xn(window,"popstate",nn(r,s=>{if(s&&s<0)return!n.confirm(s);{const o=t();return!n.confirm(o.value,{state:o.state})}})),create:Cn(e.preload,e.explicitLinks,e.actionBase,e.transformUrl),utils:{go:r=>window.history.go(r),beforeLeave:n}})(e)}const G="",En=async()=>{const e=G+"/api/all";return await(await fetch(e)).json()},In=async()=>{const e=G+"/api/config";return await(await fetch(e)).json()},wr=async()=>{const e=G+"/api/version";return await(await fetch(e)).json()},yr=async()=>{const e=G+"/api/notify_test";await fetch(e)},ze=async(e,t,n)=>{const r=G+"/api/edit/"+e+"/"+t+"/"+n;return await(await fetch(r)).json()},br=async e=>{const t=G+"/api/host/"+e;return await(await fetch(t)).json()},vr=async e=>{const t=G+"/api/host/del/"+e;return await(await fetch(t)).json()},$r=async(e,t)=>{const n=G+"/api/port/"+e+"/"+t;return await(await fetch(n)).json()},Sr=async e=>{const t=G+"/api/history/"+e;return await(await fetch(t)).json()},xr={ID:0,Name:"",DNS:"",Iface:"",IP:"",Mac:"",Hw:"",Date:"",Known:0,Now:0},kn={Host:"",Port:"",Theme:"",Color:"",DirPath:"",Timeout:120,NodePath:"",LogLevel:"",Ifaces:"",ArpArgs:"",ArpStrs:[],TrimHist:48,HistInDB:!1,ShoutURL:"",UseDB:"",PGConnect:"",InfluxEnable:!1,InfluxAddr:"",InfluxToken:"",InfluxOrg:"",InfluxBucket:"",InfluxSkipTLS:!1,PrometheusEnable:!1},[ae,M]=L([]),[je,Ln]=L([]),[On,Rn]=L([]),[Y,Nn]=L(kn),[At,et]=L(!1),[Ar,Pr]=L(200);let tt="ID";function Tn(){const e=localStorage.getItem("filterField"),t=localStorage.getItem("filterValue");qe(e,t)}function qe(e,t){let n=ae();switch(tt==e&&(n=je()),tt=e,localStorage.setItem("filterField",e),localStorage.setItem("filterValue",t),e){case"Iface":n=n.filter(r=>r.Iface==t);break;case"Known":n=n.filter(r=>r.Known==t);break;case"Now":n=n.filter(r=>r.Now==t);break;default:n=je()}M([]),M(n)}let K=!1,Le="";function Dn(){const e=localStorage.getItem("sortField");K=JSON.parse(localStorage.getItem("sortDown")),K=!K,Pt(e)}function Pt(e){e!=Le?(Le=e,K=!K):(Le="",K=!K),localStorage.setItem("sortDown",K.toString()),localStorage.setItem("sortField",e);let t=ae();e=="IP"?t.sort((n,r)=>Fn(n,r,K)):t.sort((n,r)=>jn(n,r,e,K)),M([]),M(t)}function jn(e,t,n,r){return e[n]>t[n]?r?1:-1:r?-1:1}function Fn(e,t,n){const r=nt(e),s=nt(t);return n?r-s:s-r}function nt(e){return Number(e.IP.split(".").map(t=>`000${t}`.slice(-3)).join(""))}function Hn(){ye(),qe("ID",0),setInterval(()=>{ye()},6e4)}async function ye(){const e=await En();e!==null&&e.length>0&&(M(e),Ln(e),Un(),Dn(),Tn())}function Un(){let e=[];for(let t of ae())e.includes(t.Iface)||e.push(t.Iface);Rn(e)}var Kn=D(''),Bn=D(''),Mn=D(""),Vn=D('
.
');function qn(e){const[t,n]=L(e.host.Name);let r=Kn();e.host.Now==1&&(r=Bn());let s;e.host.Known===1?s=!0:s=!1;const o=async l=>{n(l),await ze(e.host.ID,t(),""),ye()},i=async()=>{await ze(e.host.ID,t(),"toggle"),ye()};return(()=>{var l=Vn(),a=l.firstChild,c=a.firstChild,f=a.nextSibling,u=f.nextSibling,p=u.nextSibling,h=p.firstChild,y=p.nextSibling,d=y.nextSibling,g=d.nextSibling,v=g.nextSibling,m=v.firstChild,C=m.firstChild,x=v.nextSibling,E=x.nextSibling,H=E.firstChild;return O(a,()=>e.index,c),O(f,P($e,{get when(){return At()},get fallback(){return t()},get children(){var N=Mn();return N.$$input=U=>o(U.target.value),q(()=>N.value=t()),N}})),O(u,()=>e.host.Iface),O(h,()=>e.host.IP),O(y,()=>e.host.Mac),O(d,()=>e.host.Hw.slice(0,12)+".."),O(g,()=>e.host.Date),C.$$click=i,C.checked=s,O(x,r),q(N=>{var U="http://"+e.host.IP,I=e.host.Hw,_="/host/"+e.host.ID;return U!==N.e&&ee(h,"href",N.e=U),I!==N.t&&ee(d,"title",N.t=I),_!==N.a&&ee(H,"href",N.a=_),N},{e:void 0,t:void 0,a:void 0}),l})()}ne(["input","click"]);var Wn=D("
"),Gn=D(' ');function Xn(){const e=t=>{t==="MAC"&&(t="Mac"),t==="Hardware"&&(t="Hw"),t==="On"&&(t="Now"),Pt(t)};return(()=>{var t=Wn(),n=t.firstChild,r=n.firstChild,s=r.nextSibling;return O(n,P(Be,{each:["Name","Iface","IP","MAC","Hardware","Date","Known","On"],children:o=>(()=>{var i=Gn(),l=i.firstChild,a=l.nextSibling;return O(i,o,l),a.$$click=e,a.$$clickData=o,ee(a,"title","Sort by "+o),i})()}),s),t})()}ne(["click"]);var Yn=D('