watchyourlan/backend/internal/web/public/assets/HostPage.js
2025-09-07 03:33:42 +07:00

1 line
4.8 KiB
JavaScript
Raw Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

import{u as at,t as o,i as e,j as I,b as y,s as B,v as j,w as rt,x as st,h as N,c as m,e as C,F as dt,y as ct,o as K,k as ot,z as $t,A as ut,B as bt}from"./index.js";import{M as ht}from"./MacHistory.js";var ft=o('<div class="card border-primary"><div class=card-header>Host</div><div class="card-body table-responsive"><table class="table table-striped table-hover"><tbody><tr><td>ID</td><td></td></tr><tr><td>Name</td><td><input type=text class=form-control></td></tr><tr><td>DNS name</td><td></td></tr><tr><td>Iface</td><td></td></tr><tr><td>IP</td><td><a target=_blank></a></td></tr><tr><td>MAC</td><td></td></tr><tr><td>Hardware</td><td></td></tr><tr><td>Date</td><td></td></tr><tr><td>Known</td><td><div class="form-check form-switch"><input class=form-check-input type=checkbox></div></td></tr><tr><td>Online</td><td></td></tr></tbody></table><button type=button class="btn btn-outline-danger">Delete host'),gt=o('<i class="bi bi-check-circle-fill"style=color:var(--bs-success);>'),_t=o('<i class="bi bi-circle-fill"style=color:var(--bs-gray-500);>'),mt=o('<button type=button class="btn btn-outline-success">Wake-on-LAN');function vt(t){let l="";const i=at(async a=>{await j(t.host.ID,a,"")},300),n=async a=>{l=a,i(a)},d=async()=>{l==""&&(l=t.host.Name),await j(t.host.ID,l,"toggle")},_=async()=>{await st(t.host.ID),window.location.href="/"},h=async()=>{await rt(t.host.Mac)};return(()=>{var a=ft(),f=a.firstChild,v=f.nextSibling,$=v.firstChild,D=$.firstChild,r=D.firstChild,u=r.firstChild,g=u.nextSibling,s=r.nextSibling,p=s.firstChild,w=p.nextSibling,k=w.firstChild,S=s.nextSibling,c=S.firstChild,b=c.nextSibling,x=S.nextSibling,P=x.firstChild,z=P.nextSibling,M=x.nextSibling,G=M.firstChild,R=G.nextSibling,A=R.firstChild,L=M.nextSibling,q=L.firstChild,J=q.nextSibling,E=L.nextSibling,Q=E.firstChild,U=Q.nextSibling,O=E.nextSibling,V=O.firstChild,X=V.nextSibling,F=O.nextSibling,Y=F.firstChild,Z=Y.nextSibling,tt=Z.firstChild,T=tt.firstChild,et=F.nextSibling,lt=et.firstChild,it=lt.nextSibling,nt=$.nextSibling;return e(g,()=>t.host.ID),k.$$input=H=>n(H.target.value),e(b,()=>t.host.DNS),e(z,()=>t.host.Iface),e(A,()=>t.host.IP),e(J,()=>t.host.Mac),e(U,()=>t.host.Hw),e(X,()=>t.host.Date),T.$$click=d,e(it,(()=>{var H=I(()=>t.host.Now==1);return()=>H()?gt():[_t(),"   ",(()=>{var W=mt();return W.$$click=h,W})()]})()),nt.$$click=_,y(()=>B(A,"href","http://"+t.host.IP)),y(()=>k.value=t.host.Name),y(()=>T.checked=t.host.Known==1),a})()}N(["input","click"]);var St=o('<div class="card border-primary"><div class=card-header>Port Scan</div><div class=card-body><form class=input-group><input type=text class=form-control placeholder=1><input type=text class=form-control placeholder=65535><button type=button class="btn btn-primary">Scan</button></form><div class=mt-2>'),xt=o('<div class="d-flex justify-content-between mt-2"><button type=button class="btn btn-warning">Stop/Continue</button><div>Scanning port: '),yt=o("<a class=me-4 target=_blank>");function Ct(t){let l=!1;const[i,n]=m(""),[d,_]=m(""),[h,a]=m(""),[f,v]=m([]),$=async()=>{l=!1;let r=Number(i());(Number.isNaN(r)||r<1||r>65535)&&(r=1);let u=Number(d());(Number.isNaN(u)||u<1||u>65535)&&(u=65535);let g;for(let s=r;s<=u&&!l;s++)a(s.toString()),g=await ct(t.IP,s),g&&v([...f(),s])},D=()=>{l?(n(h()),$()):l=!0};return(()=>{var r=St(),u=r.firstChild,g=u.nextSibling,s=g.firstChild,p=s.firstChild,w=p.nextSibling,k=w.nextSibling,S=s.nextSibling;return p.$$input=c=>n(c.target.value),w.$$input=c=>_(c.target.value),k.$$click=$,e(g,(()=>{var c=I(()=>h()!="");return()=>c()?(()=>{var b=xt(),x=b.firstChild,P=x.nextSibling;return P.firstChild,x.$$click=D,e(P,h,null),b})():[]})(),S),e(S,C(dt,{get each(){return f()},children:c=>(()=>{var b=yt();return e(b,c),y(()=>B(b,"href","http://"+t.IP+":"+c)),b})()})),r})()}N(["input","click"]);var pt=o('<div class="card border-primary"><div class=card-header><div class=input-group style=width:fit-content;><span class=input-group-text>Host History for</span><input type=date class=form-control></div></div><div class=card-body>');function wt(t){const[l,i]=m("");K(()=>{ot(15e3),i(new Date().toLocaleDateString("en-CA"))});const n=d=>{i(""),i(d)};return(()=>{var d=pt(),_=d.firstChild,h=_.firstChild,a=h.firstChild,f=a.nextSibling,v=_.nextSibling;return f.$$input=$=>n($.currentTarget.value),e(v,(()=>{var $=I(()=>t.mac!==""&&l()!=="");return()=>$()?C(ht,{get mac(){return t.mac},get date(){return l()}}):"Loading..."})()),y(()=>f.value=l()),d})()}N(["input"]);var kt=o("<div class=row><div class=col-md></div><div class=col-md>"),Pt=o('<div class="row mt-4"><div class=col-md>');function It(){const[t,l]=m($t);return K(async()=>{const i=ut(),n=await bt(i.id);l(n)}),[(()=>{var i=kt(),n=i.firstChild,d=n.nextSibling;return e(n,C(vt,{get host(){return t()}})),e(d,C(Ct,{get IP(){return t().IP}})),i})(),(()=>{var i=Pt(),n=i.firstChild;return e(n,C(wt,{get mac(){return t().Mac}})),i})()]}export{It as default};