dsql-admin/dsql-app/.local_dist/static/chunks/pages/su/console-3a63684b22961749.js

1 line
4.2 KiB
JavaScript
Raw Normal View History

2024-11-05 11:12:42 +00:00
(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[1973],{71889:function(e,n,t){(window.__NEXT_P=window.__NEXT_P||[]).push(["/su/console",function(){return t(73794)}])},73794:function(e,n,t){"use strict";t.r(n),t.d(n,{__N_SSP:function(){return h},default:function(){return x}});var l=t(85893),o=t(67294),s=t(85313),i=t(828),r=t(53920),c=t(47568),a=t(97582);function u(){return(u=(0,c.Z)((function(e){var n,l,o,s,i,r,c,u,d,f,m,h;return(0,a.__generator)(this,(function(a){return n=e.socket,l=t(12320).Terminal,o=t(12617).FitAddon,s=new o,i=document.getElementById("terminalWrapper"),r=document.getElementById("terminal"),c=i.clientWidth,u=Math.round(c/12),(d=new l({cols:u,rows:6})).open(r),s.fit(),n.on("console",(function(e){d.write(e)})),f=new o,m=document.getElementById("shell"),(h=new l({cols:u,rows:17})).open(m),f.fit(),n.on("shell",(function(e){h.write(e)})),h.onKey((function(e,t){n.emit("shell",e.key)})),[2,d]}))}))).apply(this,arguments)}var d=t(48531),f=!1;function m(e){var n=e.socketDomain,t=(0,i.Z)(o.useState(null),2),s=t[0],c=t[1],a=(0,i.Z)(o.useState(null),2),m=a[0],h=a[1],x=(0,i.Z)(o.useState(""),2),v=x[0],g=x[1];return o.useEffect((function(){var e=n;if(console.log("Socket Domain =>",e),e){var t=(0,r.io)(e,{extraHeaders:{"X-Socket-Paradigm":"Console"}});t.on("connect",(function(){c(t),console.log("Socket Connected!")})),setInterval((function(){t.emit("get-log")}),1e3),t.on("console-log",(function(e){console.log("Fetched Log",e),g(e.replace((0,d.Z)(),"")),setTimeout((function(){var e=document.getElementById("logHistoryWrapper");e&&!f&&(e.scrollTop=e.scrollHeight)}),200)}))}}),[]),o.useEffect((function(){if(s)return function(e){return u.apply(this,arguments)}({socket:s}).then((function(e){h(e)})),function(){var e,n;null===(e=document.getElementById("terminal"))||void 0===e||e.childNodes.forEach((function(e){var n;null===(n=e.parentNode)||void 0===n||n.removeChild(e)})),null===(n=document.getElementById("shell"))||void 0===n||n.childNodes.forEach((function(e){var n;null===(n=e.parentNode)||void 0===n||n.removeChild(e)})),null===m||void 0===m||m.dispose()}}),[s]),(0,l.jsxs)(o.Fragment,{children:[(0,l.jsxs)("div",{className:"w-full justify-between",children:[(0,l.jsx)("h2",{className:"text-2xl m-0",children:"Console"}),(0,l.jsx)("button",{onClick:function(e){s&&s.emit("log","Logging to the console")},children:"Log console"})]}),(0,l.jsxs)("div",{className:"grid grid-cols-2 gap-6 w-full items-stretch",children:[(0,l.jsx)("section",{className:"paper bg-slate-900",id:"terminalWrapper",children:(0,l.jsxs)("div",{className:"flex flex-col w-full gap-10 items-start justify-start terminal",children:[(0,l.jsxs)("div",{className:"flex flex-col items-start w-full",children:[(0,l.jsx)("h2",{className:"m-0 text-white text-base",children:"Server Log"}),(0,l.jsx)("hr",{className:"opacity-20"}),(0,l.jsx)("div",{id:"terminal",className:"relative grow z-50 overflow-hidden w-full h-[150px]"})]}),(0,l.jsxs)("div",{className:"flex flex-col items-start w-full",children:[(0,l.jsx)("h2",{className:"m-0 text-white text-base",children:"Shell"}),(0,l.jsx)("hr",{className:"opacity-20"}),(0,l.jsx)("div",{id:"shell",className:"relative grow z-50 overflow-hidden w-full h-[340px]"})]})]})}),(0,l.jsxs)("section",{className:"paper",children:[(0,l.jsxs)("div",{className:"flex w-full justify-between",children:[(0,l.jsx)("h2",{className:"m-0 text-2xl",children:"Log History"}),(0,l.jsx)("button",{className:"outlined smallest gray",onClick:function(e){window.confirm("Clear Log History?")&&s&&s.emit("clear-log")},children:"Clear Log"})]}),(0,l.jsx)("hr",{}),(0,l.jsx)("div",{className:"w-full max-h-[500px] overflow-auto",id:"logHistoryWrapper",style:{scrollBehavior:"smooth"},onMouseEnter:function(){return f=!0},onMouseLeave:function(){return f=!1},children:(0,l.jsx)("pre",{className:"block",children:v})})]})]})]})}t(56500);var h=!0;function x(e){var n=e.user,t=(e.data,e.socketDomain),o=(0,l.jsxs)(l.Fragment,{children:[(0,l.jsx)("title",{children:"Console | Datasquirel"}),(0,l.jsx)("meta",{name:"description",content:"Databases Console"})]});return(0,l.jsx)