watchyourlan/internal/web/public/assets/HostPage.js
2025-09-05 02:40:00 +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 C,s as K,v as j,w as B,x as st,y as dt,h as N,c as m,e as p,F as ct,z as ot,o as z,k as $t,A as ut,B as bt,C as ht}from"./index.js";import{M as ft}from"./MacHistory.js";var gt=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'),_t=o('<i class="bi bi-check-circle-fill"style=color:var(--bs-success);>'),mt=o('<i class="bi bi-circle-fill"style=color:var(--bs-gray-500);>'),vt=o('<button type=button class="btn btn-outline-success">Wake-on-LAN');function St(t){let l="";const i=at(r=>{j(t.host.ID,r,""),B()},300),n=async r=>{l=r,i(r)},d=async()=>{l==""&&(l=t.host.Name),await j(t.host.ID,l,"toggle"),B()},_=async()=>{await dt(t.host.ID),window.location.href="/"},h=async()=>{await st(t.host.Mac)};return(()=>{var r=gt(),f=r.firstChild,v=f.nextSibling,$=v.firstChild,P=$.firstChild,a=P.firstChild,u=a.firstChild,g=u.nextSibling,s=a.nextSibling,y=s.firstChild,w=y.nextSibling,k=w.firstChild,S=s.nextSibling,c=S.firstChild,b=c.nextSibling,x=S.nextSibling,H=x.firstChild,G=H.nextSibling,M=x.nextSibling,R=M.firstChild,q=R.nextSibling,A=q.firstChild,L=M.nextSibling,J=L.firstChild,Q=J.nextSibling,E=L.nextSibling,U=E.firstChild,V=U.nextSibling,O=E.nextSibling,X=O.firstChild,Y=X.nextSibling,F=O.nextSibling,Z=F.firstChild,tt=Z.nextSibling,et=tt.firstChild,T=et.firstChild,lt=F.nextSibling,it=lt.firstChild,nt=it.nextSibling,rt=$.nextSibling;return e(g,()=>t.host.ID),k.$$input=D=>n(D.target.value),e(b,()=>t.host.DNS),e(G,()=>t.host.Iface),e(A,()=>t.host.IP),e(Q,()=>t.host.Mac),e(V,()=>t.host.Hw),e(Y,()=>t.host.Date),T.$$click=d,e(nt,(()=>{var D=I(()=>t.host.Now==1);return()=>D()?_t():[mt(),"   ",(()=>{var W=vt();return W.$$click=h,W})()]})()),rt.$$click=_,C(()=>K(A,"href","http://"+t.host.IP)),C(()=>k.value=t.host.Name),C(()=>T.checked=t.host.Known==1),r})()}N(["input","click"]);var xt=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>'),Ct=o('<div class="d-flex justify-content-between mt-2"><button type=button class="btn btn-warning">Stop/Continue</button><div>Scanning port: '),pt=o("<a class=me-4 target=_blank>");function yt(t){let l=!1;const[i,n]=m(""),[d,_]=m(""),[h,r]=m(""),[f,v]=m([]),$=async()=>{l=!1;let a=Number(i());(Number.isNaN(a)||a<1||a>65535)&&(a=1);let u=Number(d());(Number.isNaN(u)||u<1||u>65535)&&(u=65535);let g;for(let s=a;s<=u&&!l;s++)r(s.toString()),g=await ot(t.IP,s),g&&v([...f(),s])},P=()=>{l?(n(h()),$()):l=!0};return(()=>{var a=xt(),u=a.firstChild,g=u.nextSibling,s=g.firstChild,y=s.firstChild,w=y.nextSibling,k=w.nextSibling,S=s.nextSibling;return y.$$input=c=>n(c.target.value),w.$$input=c=>_(c.target.value),k.$$click=$,e(g,(()=>{var c=I(()=>h()!="");return()=>c()?(()=>{var b=Ct(),x=b.firstChild,H=x.nextSibling;return H.firstChild,x.$$click=P,e(H,h,null),b})():[]})(),S),e(S,p(ct,{get each(){return f()},children:c=>(()=>{var b=pt();return e(b,c),C(()=>K(b,"href","http://"+t.IP+":"+c)),b})()})),a})()}N(["input","click"]);var wt=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 kt(t){const[l,i]=m("");z(()=>{$t(15e3),i(new Date().toLocaleDateString("en-CA"))});const n=d=>{i(""),i(d)};return(()=>{var d=wt(),_=d.firstChild,h=_.firstChild,r=h.firstChild,f=r.nextSibling,v=_.nextSibling;return f.$$input=$=>n($.currentTarget.value),e(v,(()=>{var $=I(()=>t.mac!==""&&l()!=="");return()=>$()?p(ft,{get mac(){return t.mac},get date(){return l()}}):"Loading..."})()),C(()=>f.value=l()),d})()}N(["input"]);var Ht=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 Nt(){const[t,l]=m(ut);return z(async()=>{const i=bt(),n=await ht(i.id);l(n)}),[(()=>{var i=Ht(),n=i.firstChild,d=n.nextSibling;return e(n,p(St,{get host(){return t()}})),e(d,p(yt,{get IP(){return t().IP}})),i})(),(()=>{var i=Pt(),n=i.firstChild;return e(n,p(kt,{get mac(){return t().Mac}})),i})()]}export{Nt as default};