dsql-admin/dsql-app/.local_dist/static/chunks/pages/su/console-0b061e9801d3c9fc.js
Benjamin Toby 7a06e83a46 Updates
2024-12-08 20:56:57 +01:00

1 line
3.3 KiB
JavaScript

(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[866],{42602:(e,l,t)=>{(window.__NEXT_P=window.__NEXT_P||[]).push(["/su/console",function(){return t(12492)}])},12492:(e,l,t)=>{"use strict";t.r(l),t.d(l,{__N_SSP:()=>d,default:()=>m});var s=t(74848),n=t(96540),o=t(2016),a=t(54787);async function r(e){let{socket:l}=e,{Terminal:s}=t(62975),{FitAddon:n}=t(29195),o=new n,a=document.getElementById("terminalWrapper"),r=document.getElementById("terminal"),i=Math.round(a.clientWidth/12),c=new s({cols:i,rows:6});c.open(r),o.fit(),l.on("console",e=>{c.write(e)});{let e=new n,t=document.getElementById("shell"),o=new s({cols:i,rows:17});o.open(t),e.fit(),l.on("shell",e=>{o.write(e)}),o.onKey((e,t)=>{l.emit("shell",e.key)})}return c}var i=t(911);function c(e){let{socketDomain:l}=e,[t,o]=n.useState(null),[c,d]=n.useState(null),[m,u]=n.useState("");return n.useEffect(()=>{if(console.log("Socket Domain =>",l),!l)return;let e=(0,a.io)(l,{extraHeaders:{"X-Socket-Paradigm":"Console"}});e.on("connect",()=>{o(e),console.log("Socket Connected!")}),setInterval(()=>{e.emit("get-log")},1e3),e.on("console-log",e=>{console.log("Fetched Log",e),u(e.replace((0,i.A)(),"")),setTimeout(()=>{let e=document.getElementById("logHistoryWrapper");e&&(e.scrollTop=e.scrollHeight)},200)})},[]),n.useEffect(()=>{if(t)return r({socket:t}).then(e=>{d(e)}),function(){var e,l;null===(e=document.getElementById("terminal"))||void 0===e||e.childNodes.forEach(e=>{var l;null===(l=e.parentNode)||void 0===l||l.removeChild(e)}),null===(l=document.getElementById("shell"))||void 0===l||l.childNodes.forEach(e=>{var l;null===(l=e.parentNode)||void 0===l||l.removeChild(e)}),null==c||c.dispose()}},[t]),(0,s.jsxs)(n.Fragment,{children:[(0,s.jsxs)("div",{className:"w-full justify-between",children:[(0,s.jsx)("h2",{className:"text-2xl m-0",children:"Console"}),(0,s.jsx)("button",{onClick:e=>{t&&t.emit("log","Logging to the console")},children:"Log console"})]}),(0,s.jsxs)("div",{className:"grid grid-cols-2 gap-6 w-full items-stretch",children:[(0,s.jsx)("section",{className:"paper bg-slate-900",id:"terminalWrapper",children:(0,s.jsx)("div",{className:"flex flex-col w-full gap-10 items-start justify-start terminal",children:(0,s.jsxs)("div",{className:"flex flex-col items-start w-full",children:[(0,s.jsx)("h2",{className:"m-0 text-white text-base",children:"Shell"}),(0,s.jsx)("hr",{className:"opacity-20"}),(0,s.jsx)("div",{id:"shell",className:"relative grow z-50 overflow-hidden w-full h-[340px]"})]})})}),(0,s.jsx)("section",{className:"paper bg-slate-500",id:"terminalWrapper",children:(0,s.jsx)("div",{className:"flex flex-col w-full gap-10 items-start justify-start terminal",children:(0,s.jsxs)("div",{className:"flex flex-col items-start w-full",children:[(0,s.jsx)("h2",{className:"m-0 text-white text-base",children:"Server Log"}),(0,s.jsx)("hr",{className:"opacity-20"}),(0,s.jsx)("div",{id:"terminal",className:"relative grow z-50 overflow-hidden w-full h-[150px]"})]})})})]})]})}t(5044);var d=!0;function m(e){let{user:l,data:t,socketDomain:n}=e,a=(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)("title",{children:"Console | Datasquirel"}),(0,s.jsx)("meta",{name:"description",content:"Databases Console"})]});return(0,s.jsx)(o.A,{head:a,user:l,children:(0,s.jsx)(c,{socketDomain:n})})}}},e=>{var l=l=>e(e.s=l);e.O(0,[160,2793,2016,636,6593,8792],()=>l(42602)),_N_E=e.O()}]);