turboci-admin/dist/web/static/chunks/926-f47925f5116e544b.js
2026-03-14 11:38:37 +01:00

1 line
15 KiB
JavaScript

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