turboci-admin/dist/web/static/chunks/464-2201b62318a00d17.js
2026-03-12 15:18:27 +01:00

1 line
15 KiB
JavaScript

(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[464],{45377:function(e,t,l){"use strict";let r;l.d(t,{Z:function(){return B}});var n=l(85893),s=l(60),o=l(67294),a=l(5606);let i=[{name:"logs"},{name:"shell"}];function c(e){let{elementRef:t,className:l,options:n,removeIntersected:s,delay:a,elId:i}=e,[c,u]=o.useState(!1),[d,m]=o.useState(0),v=a||200,f=o.useCallback((e,t)=>{let l=e[0];window.clearTimeout(r),l.isIntersecting?r=setTimeout(()=>{u(!0),s&&t.unobserve(l.target)},v):u(!1)},[]);return o.useEffect(()=>{let e=i?document.getElementById(i):null==t?void 0:t.current,r=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",...n});r?r.forEach(e=>{s.observe(e)}):e&&s.observe(e)},[d]),{isIntersecting:c}}var u=l(71077),d=l(96486),m=l.n(d),v=l(76242),f=l(57493),p=l(98388);function h(e){let{spacing:t,componentRef:l,...r}=e;return(0,n.jsx)("div",{...r,className:(0,p.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",r.className),ref:l,children:r.children})}var x=l(36969),g=l(25808),w=l(94495),j=l(94655),Z=l(3668);function b(e){let{url:t,wrapperProps:l,title:r,...a}=e,{loading:i,setLoading:c}=(0,g.Z)();return(0,n.jsx)(h,{...l,className:(0,p.m6)("p-0",null==l?void 0:l.className),children:(0,n.jsxs)(s.Z,{className:"gap-0",children:[(0,n.jsxs)(j.Z,{className:"p-4 w-full justify-between",children:[(0,n.jsx)(j.Z,{children:r?(0,n.jsx)(o.Fragment,{children:(0,n.jsx)(Z.Z,{size:"small",variant:"faded",children:r})}):null}),(0,n.jsxs)(j.Z,{children:[(0,n.jsx)(w.Z,{title:"Open Full Screen",variant:"ghost",className:"p-1!",onClick:()=>{window.open(t,"__blank")},children:(0,n.jsx)(x.Z,{name:"ArrowUpRight",size:20})}),(0,n.jsx)(w.Z,{title:"Refresh Iframe",variant:"ghost",className:"p-1!",loading:i,onClick:()=>{c(!0),setTimeout(()=>{c(!1)},2e3)},loadingProps:{size:"smaller"},children:(0,n.jsx)(x.Z,{name:"RotateCcw",size:18})})]})]}),(0,n.jsx)("hr",{}),i?(0,n.jsx)(f.Z,{className:"w-full p-10 h-[400px]",children:(0,n.jsx)(v.Z,{})}):(0,n.jsx)("iframe",{...a,src:t,className:(0,p.m6)("w-full h-[400px]",a.className)})]})})}function N(e){let{service:t,server:l,target:r,log_cmd:i,portRef:d}=e,{pageProps:p,ws:h}=(0,o.useContext)(a.AppContext),x=(0,o.useRef)(void 0),{data:w}=(0,u.Z)(),{isIntersecting:j}=c({elementRef:x,options:{rootMargin:"-200px",threshold:0}}),[Z,N]=(0,o.useState)(),{refresh:k,setRefresh:y}=(0,g.Z)(),C=(0,o.useRef)(!1);function E(){(null==Z?void 0:Z.port)&&h.sendData({event:"client:kill-port",server:l,service:m().omit(t,["servers"]),port:Z.port})}(0,o.useEffect)(()=>{if((null==h?void 0:h.socket)&&!C.current&&j)return"logs"==r?h.sendData({event:"client:service-server-logs",server:l,service:m().omit(t,["servers"]),cmd:i}):h.sendData({event:"client:service-server-shell",server:l,service:m().omit(t,["servers"])}),C.current=!0,function(){E()}},[h,k,j]),(0,o.useEffect)(()=>{C.current&&(E(),N(void 0),C.current=!1,y(e=>e+1))},[r,i]),(0,o.useEffect)(()=>{var e,t,r;!Z&&((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),d&&(null==w?void 0:null===(r=w.ttyd)||void 0===r?void 0:r.port)&&(d.current=w.ttyd.port))},[w]),(0,o.useEffect)(()=>{(null==Z?void 0:Z.port)&&(j?(C.current=!1,N(void 0)):E())},[j]);let R=(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)("code",{children:l.private_ip})," ",r]});return(0,n.jsxs)(s.Z,{className:"gap-0 w-full",componentRef:x,children:[j&&(null==Z?void 0:Z.url)&&Z.port?(0,n.jsx)(s.Z,{className:"gap-0",children:(0,n.jsx)(b,{url:null==Z?void 0:Z.url,title:R,wrapperProps:{className:"border-none"}})}):(0,n.jsx)(f.Z,{className:"p-10 h-[460px]",children:(0,n.jsx)(v.Z,{})}),(0,n.jsx)("hr",{})]})}var k=l(73935),y=l(62190),C=l(84681);function E(e){let{open:t,setOpen:l,...r}=e;return t?k.createPortal((0,n.jsxs)("div",{className:(0,p.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,n.jsx)("div",{className:(0,p.m6)("absolute top-0 left-0 bg-dark/80 z-0","w-screen h-screen"),onClick:e=>{l(!1)}}),(0,n.jsxs)(C.Z,{...m().omit(r,["targetWrapperProps"]),className:(0,p.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",r.className),children:[r.children,(0,n.jsx)(w.Z,{className:"absolute top-0 right-0 p-2",variant:"ghost",color:"gray",onClick:()=>{l(!1)},title:"Close Modal Button",children:(0,n.jsx)(y.Z,{size:30})})]})]}),document.getElementById("twui-modal-root")):null}var R=l(20528);function z(e){let t,{open:l,setOpen:r,targetElRef:s,position:a="bottom",trigger:i="hover",debounce:c,popoverTargetActiveRef:u,popoverContentActiveRef:d,popoverReferenceRef:v,isPopover:f,...h}=e;if(!l)return null;let[x,g]=o.useState({});o.useEffect(()=>{l&&(null==s?void 0:s.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,R.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=m().merge(o,a):"bottom-left"===t?o=m().merge(o,m().omit(a,["transform"]),{left:r.left}):"bottom-right"===t?o=m().merge(o,m().omit(a,["left","transform"]),{right:window.innerWidth-(r.left+window.scrollX)-r.width-s}):"top"===t?o=m().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:s}))},[l,s,a]);let w=o.useCallback(()=>{d.current=!0,u.current=!1,r(!0)},[]),j=o.useCallback(()=>{window.clearTimeout(t),t=setTimeout(()=>{if(u.current){u.current=!1;return}r(!1)},c)},[]);return l?k.createPortal((0,n.jsx)(C.Z,{...h,className:(0,p.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 S(e){let t;let{target:l,targetRef:r,targetWrapperProps:s,open:a,setOpen:i,isPopover:c,popoverReferenceRef:u,trigger:d="hover",debounce:m=500,onClose:v,hoverOpen:f}=e,[h,x]=o.useState(!1),[g,w]=o.useState(a||!1);o.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)}},[]),o.useEffect(()=>{null==i||i(g),!1==g&&(null==v||v())},[g]),o.useEffect(()=>{w(a||!1)},[a]);let j=r||o.useRef(null),Z=u||j,b=o.useRef(!1),N=o.useRef(!1),k=o.useCallback(t=>{var l;b.current=!0,N.current=!1,w(!0),null===(l=e.onMouseEnter)||void 0===l||l.call(e,t)},[]),y=o.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)},[]),C=o.useCallback(e=>{let t=e.target,l=t.closest(".twui-popover-content");if(!t.closest(".twui-popover-target")&&!l)return w(!1)},[]);return o.useEffect(()=>{if(c)return document.addEventListener("click",C),()=>{document.removeEventListener("click",C)}},[]),(0,n.jsxs)(o.Fragment,{children:[l?(0,n.jsx)("div",{...s,onClick:e=>{e.preventDefault(),e.stopPropagation(),w(!g)},ref:j,onMouseEnter:c&&("hover"===d||f)?k:null==s?void 0:s.onMouseEnter,onMouseLeave:c&&("hover"===d||f)?y:null==s?void 0:s.onMouseLeave,className:(0,p.m6)("twui-popover-target",null==s?void 0:s.className),children:l}):null,h?c?(0,n.jsx)(z,{...e,open:g,setOpen:w,targetElRef:Z,debounce:m,popoverTargetActiveRef:b,popoverContentActiveRef:N}):(0,n.jsx)(E,{...e,open:g,setOpen:w}):null]})}var M=l(31574),_=l(77827);function T(e){let{componentRef:t,...l}=e;return(0,n.jsx)(_.Z,{istextarea:!0,...l,componentRef:t})}function L(e){let{setLog:t}=e,{open:l,setOpen:r}=(0,g.Z)(),a=(0,o.useRef)("");return(0,n.jsx)(S,{target:(0,n.jsx)(w.Z,{title:"Enter custom command",size:"small",color:"gray",className:"w-[42px] h-[42px]",children:(0,n.jsx)(x.Z,{name:"Edit3",size:14})}),setOpen:r,open:l,children:(0,n.jsxs)(s.Z,{children:[(0,n.jsxs)(s.Z,{className:"gap-1",children:[(0,n.jsx)(M.Z,{className:"admin-h3",children:"Enter a custom Command"}),(0,n.jsx)(Z.Z,{variant:"faded",children:"Enter a command to run a custom log"})]}),(0,n.jsx)(T,{placeholder:"Enter custom command",changeHandler:e=>{a.current=e},autoFocus:!0}),(0,n.jsx)(w.Z,{title:"Set Custom Command",onClick:()=>{t(a.current.trim()),r(!1)},children:"Set Custom Command"})]})})}var I=l(39483);function F(e){let{service:t,setLog:l,log:r}=e,s=t.logs,a=null==s?void 0:s.map(e=>"string"==typeof e?e:e.cmd),i=(null==r?void 0:r.match(/./))&&!(null==a?void 0:a.find(e=>e==r));return(0,n.jsx)(o.Fragment,{children:i?(0,n.jsx)(j.Z,{className:"grow",children:(0,n.jsx)(h,{className:"w-full py-1 h-[42px]",children:(0,n.jsxs)(j.Z,{className:"w-full justify-between",children:[(0,n.jsx)(Z.Z,{children:r}),(0,n.jsx)(w.Z,{title:"Clear Custom Log",variant:"ghost",className:"p-1",onClick:()=>{l(void 0)},children:(0,n.jsx)(y.Z,{size:17})})]})})}):(0,n.jsx)(I.Z,{options:[...(null==a?void 0:a.map(e=>({value:e,title:e})))||[]],changeHandler:e=>{l(e)}})})}function A(e){let{service:t,setLog:l,log:r}=e;return(0,n.jsx)(s.Z,{className:"w-full gap-2 p-4",children:(0,n.jsxs)(j.Z,{className:"flex-nowrap",children:[(0,n.jsx)(L,{setLog:l}),(0,n.jsx)(F,{service:t,setLog:l,log:r})]})})}function B(e){var t,l;let{service:r,server:u,wrapperProps:d,portRef:m}=e,{pageProps:v}=(0,o.useContext)(a.AppContext),{isIntersecting:f}=c({elementRef:(0,o.useRef)(void 0)}),[h,x]=(0,o.useState)((null===(t=r.logs)||void 0===t?void 0:t[0])?"logs":"shell"),g=null===(l=r.logs)||void 0===l?void 0:l[0],Z="string"==typeof g?g:null==g?void 0:g.cmd,[b,k]=(0,o.useState)(Z);return(0,n.jsxs)(s.Z,{...d,className:(0,p.m6)("gap-0",null==d?void 0:d.className),children:[(0,n.jsxs)(j.Z,{className:"w-full justify-between p-4 -mb-6",children:[(0,n.jsx)(j.Z,{children:(0,n.jsx)("code",{children:u.private_ip})}),(0,n.jsx)(j.Z,{className:"",children:i.map((e,t)=>{let l=e.name==h;return(0,n.jsx)(w.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,n.jsx)(A,{server:u,service:r,setLog:k,log:b}):(0,n.jsx)(j.Z,{className:"h-[74px]"}),(0,n.jsx)("hr",{}),(0,n.jsx)(N,{server:u,service:r,target:h,portRef:m,log_cmd:b})]})}},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)}}]);