1 line
15 KiB
JavaScript
1 line
15 KiB
JavaScript
(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[464],{45377:function(e,t,l){"use strict";l.d(t,{Z:function(){return A}});var r=l(85893),n=l(60),s=l(67294),o=l(5606);let a=[{name:"logs"},{name:"shell"}];function i(e){let{elementRef:t,className:l,options:r,removeIntersected:n,delay:o,elId:a}=e,i=(0,s.useRef)(null),[c,u]=s.useState(!1),[d,m]=s.useState(0),v=o||200,f=s.useCallback((e,t)=>{let l=e[0];window.clearTimeout(i.current),l.isIntersecting?i.current=setTimeout(()=>{u(!0),n&&t.unobserve(l.target)},v):u(!1)},[]);return s.useEffect(()=>{let e=a?document.getElementById(a):null==t?void 0:t.current,n=l?document.querySelectorAll(".".concat(l)):null;if(!e&&!l&&d<5){requestAnimationFrame(()=>{setTimeout(()=>{m(d+1)},2e3)});return}let s=new IntersectionObserver(f,{rootMargin:"0px 0px 0px 0px",...r});n?n.forEach(e=>{s.observe(e)}):e&&s.observe(e)},[d]),{isIntersecting:c}}var c=l(71077),u=l(96486),d=l.n(u),m=l(76242),v=l(57493),f=l(98388);function p(e){let{spacing:t,componentRef:l,...n}=e;return(0,r.jsx)("div",{...n,className:(0,f.m6)("relative flex items-center gap-2 border border-solid rounded-default","border-slate-200 dark:border-white/10",t?"normal"==t?"px-3 py-2":"tight"==t?"px-2 py-1":"":"px-3 py-2","twui-border",n.className),ref:l,children:n.children})}var h=l(36969),x=l(25808),g=l(94495),w=l(94655),j=l(3668);function Z(e){let{url:t,wrapperProps:l,title:o,...a}=e,{loading:i,setLoading:c}=(0,x.Z)();return(0,r.jsx)(p,{...l,className:(0,f.m6)("p-0",null==l?void 0:l.className),children:(0,r.jsxs)(n.Z,{className:"gap-0",children:[(0,r.jsxs)(w.Z,{className:"p-4 w-full justify-between",children:[(0,r.jsx)(w.Z,{children:o?(0,r.jsx)(s.Fragment,{children:(0,r.jsx)(j.Z,{size:"small",variant:"faded",children:o})}):null}),(0,r.jsxs)(w.Z,{children:[(0,r.jsx)(g.Z,{title:"Open Full Screen",variant:"ghost",className:"p-1!",onClick:()=>{window.open(t,"__blank")},children:(0,r.jsx)(h.Z,{name:"ArrowUpRight",size:20})}),(0,r.jsx)(g.Z,{title:"Refresh Iframe",variant:"ghost",className:"p-1!",loading:i,onClick:()=>{c(!0),setTimeout(()=>{c(!1)},2e3)},loadingProps:{size:"smaller"},children:(0,r.jsx)(h.Z,{name:"RotateCcw",size:18})})]})]}),(0,r.jsx)("hr",{}),i?(0,r.jsx)(v.Z,{className:"w-full p-10 h-[400px]",children:(0,r.jsx)(m.Z,{})}):(0,r.jsx)("iframe",{...a,src:t,className:(0,f.m6)("w-full h-[400px]",a.className)})]})})}function b(e){let{service:t,server:l,target:a,log_cmd:u,portRef:f}=e,{pageProps:p,ws:h}=(0,s.useContext)(o.AppContext),g=(0,s.useRef)(void 0),{data:w}=(0,c.Z)(),{isIntersecting:j}=i({elementRef:g,options:{rootMargin:"-200px",threshold:0}}),[b,N]=(0,s.useState)(),{refresh:k,setRefresh:y}=(0,x.Z)(),C=(0,s.useRef)(!1);function E(){(null==b?void 0:b.port)&&h.sendData({event:"client:kill-port",server:l,service:d().omit(t,["servers"]),port:b.port})}(0,s.useEffect)(()=>{if((null==h?void 0:h.socket)&&!C.current&&j)return"logs"==a?h.sendData({event:"client:service-server-logs",server:l,service:d().omit(t,["servers"]),cmd:u}):h.sendData({event:"client:service-server-shell",server:l,service:d().omit(t,["servers"])}),C.current=!0,function(){E()}},[h,k,j]),(0,s.useEffect)(()=>{C.current&&(E(),N(void 0),C.current=!1,y(e=>e+1))},[a,u]),(0,s.useEffect)(()=>{var e,t,r;!b&&((null==w?void 0:w.event)=="server:service-server-logs"&&(null==w?void 0:w.ttyd)&&(null===(e=w.server)||void 0===e?void 0:e.private_ip)==l.private_ip&&setTimeout(()=>{N(w.ttyd?{...w.ttyd,href:"".concat(window.location.origin).concat(w.ttyd.url)}:void 0)},2e3),(null==w?void 0:w.event)=="server:service-server-shell"&&(null==w?void 0:w.ttyd)&&(null===(t=w.server)||void 0===t?void 0:t.private_ip)==l.private_ip&&setTimeout(()=>{N(w.ttyd?{...w.ttyd,href:"".concat(window.location.origin).concat(w.ttyd.url)}:void 0)},2e3),f&&(null==w?void 0:null===(r=w.ttyd)||void 0===r?void 0:r.port)&&(f.current=w.ttyd.port))},[w]),(0,s.useEffect)(()=>{(null==b?void 0:b.port)&&(j?(C.current=!1,N(void 0)):E())},[j]);let R=(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)("code",{children:l.private_ip})," ",a]});return(0,r.jsxs)(n.Z,{className:"gap-0 w-full",componentRef:g,children:[j&&(null==b?void 0:b.url)&&b.port?(0,r.jsx)(n.Z,{className:"gap-0",children:(0,r.jsx)(Z,{url:null==b?void 0:b.url,title:R,wrapperProps:{className:"border-none"}})}):(0,r.jsx)(v.Z,{className:"p-10 h-[460px]",children:(0,r.jsx)(m.Z,{})}),(0,r.jsx)("hr",{})]})}var N=l(73935),k=l(62190),y=l(84681);function C(e){let{open:t,setOpen:l,...n}=e;return t?N.createPortal((0,r.jsxs)("div",{className:(0,f.m6)("fixed z-[200] top-0 left-0 w-screen h-screen","flex flex-col items-center justify-center p-4","twui-modal-root"),role:"dialog","aria-modal":"true",children:[(0,r.jsx)("div",{className:(0,f.m6)("absolute top-0 left-0 bg-dark/80 z-0","w-screen h-screen"),onClick:e=>{l(!1)}}),(0,r.jsxs)(y.Z,{...d().omit(n,["targetWrapperProps"]),className:(0,f.m6)("z-10 max-w-modal bg-background-light dark:bg-background-dark","w-full relative max-h-[95vh] overflow-y-auto","twui-modal-content",n.className),children:[n.children,(0,r.jsx)(g.Z,{className:"absolute top-0 right-0 p-2",variant:"ghost",color:"gray",onClick:()=>{l(!1)},title:"Close Modal Button",children:(0,r.jsx)(k.Z,{size:30})})]})]}),document.getElementById("twui-modal-root")):null}var E=l(20528);function R(e){let t,{open:l,setOpen:n,targetElRef:o,position:a="bottom",trigger:i="hover",debounce:c,popoverTargetActiveRef:u,popoverContentActiveRef:m,popoverReferenceRef:v,isPopover:p,...h}=e;if(!l)return null;let[x,g]=s.useState({});s.useEffect(()=>{l&&(null==o?void 0:o.current)&&g(function(e){let{position:t,targetElRef:l}=e;if(!l.current)return{};let r=l.current.getBoundingClientRect(),n=window.getComputedStyle(l.current),s=(0,E.Z)(n.paddingRight),o={position:"absolute",zIndex:100},a={top:r.bottom+window.scrollY+8,left:r.left+window.scrollX+r.width/2,transform:"translateX(-50%)"},i={bottom:window.innerHeight-(r.top+window.scrollY)+8,left:r.left+window.scrollX+r.width/2,transform:"translateX(-50%)"};return"bottom"===t?o=d().merge(o,a):"bottom-left"===t?o=d().merge(o,d().omit(a,["transform"]),{left:r.left}):"bottom-right"===t?o=d().merge(o,d().omit(a,["left","transform"]),{right:window.innerWidth-(r.left+window.scrollX)-r.width-s}):"top"===t?o=d().merge(o,i):"right"===t?(o.top=r.top+window.scrollY+r.height/2,o.left=r.right+window.scrollX+8,o.transform="translateY(-50%)"):"left"===t&&(o.top=r.top+window.scrollY+r.height/2,o.right=window.innerWidth-(r.left+window.scrollX)+8,o.transform="translateY(-50%)"),o}({position:a,targetElRef:o}))},[l,o,a]);let w=s.useCallback(()=>{m.current=!0,u.current=!1,n(!0)},[]),j=s.useCallback(()=>{window.clearTimeout(t),t=setTimeout(()=>{if(u.current){u.current=!1;return}n(!1)},c)},[]);return l?N.createPortal((0,r.jsx)(y.Z,{...h,className:(0,f.m6)("max-w-[300px] z-[250]","twui-popover-content",h.className),style:{...x,...h.style},onMouseEnter:"hover"===i?w:h.onMouseEnter,onMouseLeave:"hover"===i?j:h.onMouseLeave,role:"dialog","aria-modal":"true",children:h.children}),document.getElementById("twui-popover-root")):null}function z(e){let t;let{target:l,targetRef:n,targetWrapperProps:o,open:a,setOpen:i,isPopover:c,popoverReferenceRef:u,trigger:d="hover",debounce:m=500,onClose:v,hoverOpen:p}=e,[h,x]=s.useState(!1),[g,w]=s.useState(a||!1);s.useEffect(()=>{let e=c?"twui-popover-root":"twui-modal-root",t=document.getElementById(e);if(t)c&&(t.style.zIndex="1000"),x(!0);else{let t=document.createElement("div");t.id=e,document.body.appendChild(t),x(!0)}},[]),s.useEffect(()=>{null==i||i(g),!1==g&&(null==v||v())},[g]),s.useEffect(()=>{w(a||!1)},[a]);let j=n||s.useRef(null),Z=u||j,b=s.useRef(!1),N=s.useRef(!1),k=s.useCallback(t=>{var l;b.current=!0,N.current=!1,w(!0),null===(l=e.onMouseEnter)||void 0===l||l.call(e,t)},[]),y=s.useCallback(l=>{var r;window.clearTimeout(t),t=setTimeout(()=>{if(N.current){N.current=!1;return}w(!1)},m),null===(r=e.onMouseLeave)||void 0===r||r.call(e,l)},[]),E=s.useCallback(e=>{let t=e.target,l=t.closest(".twui-popover-content");if(!t.closest(".twui-popover-target")&&!l)return w(!1)},[]);return s.useEffect(()=>{if(c)return document.addEventListener("click",E),()=>{document.removeEventListener("click",E)}},[]),(0,r.jsxs)(s.Fragment,{children:[l?(0,r.jsx)("div",{...o,onClick:e=>{e.preventDefault(),e.stopPropagation(),w(!g)},ref:j,onMouseEnter:c&&("hover"===d||p)?k:null==o?void 0:o.onMouseEnter,onMouseLeave:c&&("hover"===d||p)?y:null==o?void 0:o.onMouseLeave,className:(0,f.m6)("twui-popover-target",null==o?void 0:o.className),children:l}):null,h?c?(0,r.jsx)(R,{...e,open:g,setOpen:w,targetElRef:Z,debounce:m,popoverTargetActiveRef:b,popoverContentActiveRef:N}):(0,r.jsx)(C,{...e,open:g,setOpen:w}):null]})}var S=l(31574),M=l(77827);function _(e){let{componentRef:t,...l}=e;return(0,r.jsx)(M.Z,{istextarea:!0,...l,componentRef:t})}function T(e){let{setLog:t}=e,{open:l,setOpen:o}=(0,x.Z)(),a=(0,s.useRef)("");return(0,r.jsx)(z,{target:(0,r.jsx)(g.Z,{title:"Enter custom command",size:"small",color:"gray",className:"w-[42px] h-[42px]",children:(0,r.jsx)(h.Z,{name:"Edit3",size:14})}),setOpen:o,open:l,children:(0,r.jsxs)(n.Z,{children:[(0,r.jsxs)(n.Z,{className:"gap-1",children:[(0,r.jsx)(S.Z,{className:"admin-h3",children:"Enter a custom Command"}),(0,r.jsx)(j.Z,{variant:"faded",children:"Enter a command to run a custom log"})]}),(0,r.jsx)(_,{placeholder:"Enter custom command",changeHandler:e=>{a.current=e},autoFocus:!0}),(0,r.jsx)(g.Z,{title:"Set Custom Command",onClick:()=>{t(a.current.trim()),o(!1)},children:"Set Custom Command"})]})})}var L=l(39483);function I(e){let{service:t,setLog:l,log:n}=e,o=t.logs,a=null==o?void 0:o.map(e=>"string"==typeof e?e:e.cmd),i=(null==n?void 0:n.match(/./))&&!(null==a?void 0:a.find(e=>e==n));return(0,r.jsx)(s.Fragment,{children:i?(0,r.jsx)(w.Z,{className:"grow",children:(0,r.jsx)(p,{className:"w-full py-1 h-[42px]",children:(0,r.jsxs)(w.Z,{className:"w-full justify-between",children:[(0,r.jsx)(j.Z,{children:n}),(0,r.jsx)(g.Z,{title:"Clear Custom Log",variant:"ghost",className:"p-1",onClick:()=>{l(void 0)},children:(0,r.jsx)(k.Z,{size:17})})]})})}):(0,r.jsx)(L.Z,{options:[...(null==a?void 0:a.map(e=>({value:e,title:e})))||[]],changeHandler:e=>{l(e)}})})}function F(e){let{service:t,setLog:l,log:s}=e;return(0,r.jsx)(n.Z,{className:"w-full gap-2 p-4",children:(0,r.jsxs)(w.Z,{className:"flex-nowrap",children:[(0,r.jsx)(T,{setLog:l}),(0,r.jsx)(I,{service:t,setLog:l,log:s})]})})}function A(e){var t,l;let{service:c,server:u,wrapperProps:d,portRef:m}=e,{pageProps:v}=(0,s.useContext)(o.AppContext),{isIntersecting:p}=i({elementRef:(0,s.useRef)(void 0)}),[h,x]=(0,s.useState)((null===(t=c.logs)||void 0===t?void 0:t[0])?"logs":"shell"),j=null===(l=c.logs)||void 0===l?void 0:l[0],Z="string"==typeof j?j:null==j?void 0:j.cmd,[N,k]=(0,s.useState)(Z);return(0,r.jsxs)(n.Z,{...d,className:(0,f.m6)("gap-0",null==d?void 0:d.className),children:[(0,r.jsxs)(w.Z,{className:"w-full justify-between p-4 -mb-6",children:[(0,r.jsx)(w.Z,{children:(0,r.jsx)("code",{children:u.private_ip})}),(0,r.jsx)(w.Z,{className:"",children:a.map((e,t)=>{let l=e.name==h;return(0,r.jsx)(g.Z,{title:"".concat(e.name),onClick:()=>{x(e.name)},size:"smaller",color:"gray",variant:l?void 0:"outlined",children:e.name},t)})})]}),"logs"==h?(0,r.jsx)(F,{server:u,service:c,setLog:k,log:N}):(0,r.jsx)(w.Z,{className:"h-[74px]"}),(0,r.jsx)("hr",{}),(0,r.jsx)(b,{server:u,service:c,target:h,portRef:m,log_cmd:N})]})}},39483:function(e,t,l){"use strict";l.d(t,{Z:function(){return f}});var r=l(85893),n=l(42171),s=l(74598),o=l(67294),a=l(98388),i=l(59123),c=l(6531),u=l(3668),d=l(60),m=l(30276),v=l(38249);function f(e){var t,l,f;let{label:p,options:h,componentRef:x,labelProps:g,wrapperProps:w,showLabel:j,iconProps:Z,changeHandler:b,info:N,validateValueFn:k,wrapperWrapperProps:y,dispatchState:C,...E}=e,[R,z]=o.useState({isValid:!0}),S=x||o.useRef(null),[M,_]=o.useState({value:null===(t=h[0])||void 0===t?void 0:t.value,data:null===(l=h[0])||void 0===l?void 0:l.data});o.useEffect(()=>{setTimeout(()=>{requestAnimationFrame(()=>{var e;let t=null===(e=S.current)||void 0===e?void 0:e.value;t&&k&&k(t).then(e=>{z(e)})})},200)},[]),o.useEffect(()=>{null==C||C(M.data)},[M]);let T=p?(0,m.Z)(p):E.name?(0,m.Z)(E.name):E.title?(0,m.Z)(E.title):"select-".concat(Math.round(1e6*Math.random()));return(0,r.jsxs)(d.Z,{...y,className:(0,a.m6)("gap-1",null==y?void 0:y.className),children:[(0,r.jsxs)("div",{...w,className:(0,a.m6)("relative w-full flex items-center border rounded-default","border-slate-300 dark:border-white/20 pr-2","focus:border-slate-700 dark:focus:border-white/50","outline-slate-300 dark:outline-white/20","focus:outline-slate-700 dark:focus:outline-white/50","bg-white dark:bg-background-dark",R.isValid?"":"outline-warning border-warning",null==w?void 0:w.className),children:[j&&(0,r.jsx)("label",{htmlFor:T,...g,className:(0,a.m6)("text-xs absolute -top-2.5 left-2 text-foreground-light/80 bg-background-light","dark:text-foreground-dark/70 dark:bg-background-dark px-1.5 rounded-t","twui-input-label",null==g?void 0:g.className),children:p||E.title||E.name}),(0,r.jsx)("select",{id:T,"aria-label":E["aria-label"]||E.title,...E,className:(0,a.m6)("w-full pl-3 py-2 rounded-default appearance-none pr-8","grow !border-none !outline-none","twui-select",E.className),ref:S,value:(null===(f=h.flat().find(e=>e.default))||void 0===f?void 0:f.value)||void 0,onChange:e=>{var t;let l=h.find(t=>t.value==e.target.value);l&&_(l),null==b||b(e.target.value,null==l?void 0:l.data),null===(t=E.onChange)||void 0===t||t.call(E,e),null==k||k(e.target.value).then(e=>{z(e)})},children:h.flat().map((e,t)=>{let l=e.title||(0,v.Z)(e.value);return(0,r.jsx)("option",{value:e.value,children:l},t)})}),(0,r.jsx)(n.Z,{size:20,...Z,className:(0,a.m6)("pointer-events-none -ml-6",null==Z?void 0:Z.className)}),N&&(0,r.jsx)(i.Z,{target:(0,r.jsx)("div",{title:"Select Info Button",children:(0,r.jsx)(s.Z,{size:20})}),hoverOpen:!0,children:(0,r.jsx)(c.Z,{className:"min-w-[250px] p-6",children:"string"==typeof N?(0,r.jsx)(u.Z,{children:N}):N})})]}),!R.isValid&&R.msg?(0,r.jsx)(u.Z,{size:"smaller",className:"text-warning",children:R.msg}):void 0]})}},57493:function(e,t,l){"use strict";l.d(t,{Z:function(){return s}});var r=l(85893),n=l(98388);function s(e){let{...t}=e;return(0,r.jsx)("div",{...t,className:(0,n.m6)("flex flex-col items-center justify-center gap-4 p-2 w-full","h-full twui-center",t.className),children:t.children})}},56211:function(e,t,l){"use strict";l.d(t,{Z:function(){return s}});var r=l(85893),n=l(98388);function s(e){let{...t}=e;return(0,r.jsx)("h2",{...t,className:(0,n.m6)("text-2xl md:text-3xl mb-4","twui-headings twui-heading","twui-h2",t.className),children:t.children})}},31574:function(e,t,l){"use strict";l.d(t,{Z:function(){return s}});var r=l(85893),n=l(98388);function s(e){let{...t}=e;return(0,r.jsx)("h3",{...t,className:(0,n.m6)("text-xl mb-4","twui-headings twui-heading","twui-h3",t.className),children:t.children})}},30276:function(e,t,l){"use strict";function r(e,t,l){let r=t||"-";try{if(!e)return"";let t=String(e).trim().toLowerCase().replace(/ {2,}/g," ").replace(/ /g,r).replace(/[^a-z0-9]/g,r).replace(/-{2,}|_{2,}/g,r).replace(/^-/,"");if(l)return t;return t.replace(/-$/,"")}catch(e){return""}}l.d(t,{Z:function(){return r}})},9008:function(e,t,l){e.exports=l(23867)}}]); |