UNPKG

@mountainpass/hooked-cli

Version:
1 lines 4.6 kB
(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[405],{8312:function(e,s,l){(window.__NEXT_P=window.__NEXT_P||[]).push(["/",function(){return l(7654)}])},7654:function(e,s,l){"use strict";l.r(s),l.d(s,{default:function(){return b}});var a=l(5893),t=l(2460),i=l(4440),r=l(389),n=l(1486),d=l(202),c=l(7294),o=l(6502),u=l(8506),x=l(4822);let h=e=>{var s,l,t,r;let{name:d,scriptPath:c}=e,o=(0,n.XD)("display","/api/run/default/".concat(c),!!c,6e4);return console.log("%cRe-rendering DisplayRow","color:magenta;"),(0,a.jsx)("div",{className:"flex max-w-full w-full",children:(0,a.jsxs)(i.HC,{className:"rounded max-sm:flex-col",fixedHeight:!1,children:[(0,a.jsxs)("div",{className:"flex gap-2",children:[(0,a.jsx)(u.YDc,{className:"text-xl flex-shrink-0 text-red-500"}),(0,a.jsx)("span",{className:"truncate self-center",children:d})]}),(0,a.jsx)("div",{className:"flex w-full overflow-auto",children:(0,a.jsx)(x.K,{className:"max-sm:m-auto sm:ml-auto",isLoading:o.isLoading,style:(null===(s=o.data)||void 0===s?void 0:s.success)?"success":"error",text:(null===(l=o.data)||void 0===l?void 0:l.success)?(null===(t=o.data)||void 0===t?void 0:t.outputs.join("\n"))||"-":(null===(r=o.error)||void 0===r?void 0:r.message)||"An error occurred."})})]})})},m=e=>{var s,l,t,r;let{name:d,scriptPath:c}=e,o=(0,n.XD)("display","/api/run/default/".concat(c),!!c,6e4);return console.log("%cRe-rendering DisplayRow","color:magenta;"),(0,a.jsxs)(i.HC,{className:"rounded flex-col overflow-hidden",fixedHeight:!1,children:[(0,a.jsx)(x.K,{className:"overflow-hidden",size:"lg",isLoading:o.isLoading,style:(null===(s=o.data)||void 0===s?void 0:s.success)?"success":"error",text:(null===(l=o.data)||void 0===l?void 0:l.success)?(null===(t=o.data)||void 0===t?void 0:t.outputs.join("\n"))||"-":(null===(r=o.error)||void 0===r?void 0:r.message)||"An error occurred."}),(0,a.jsx)("span",{className:"truncate self-center text-neutral-500 overflow-hidden text-ellipsis",children:d})]})};class p{hasNext(){return this.nextIndex<this.array.length}peek(){if(this.hasNext())return this.array[this.nextIndex]}next(){return this.array[this.nextIndex++]}mapWhile(e,s){let l=[];for(;this.hasNext()&&e(this.peek());)l.push(s(this.next(),1,this));return l}map(e){return this.mapWhile(()=>!0,e)}constructor(e){this.nextIndex=0,this.array=e}}let v=e=>{var s;let{visible:l,dashboard:t}=e,x=(0,d.NL)();return console.log("%cRe-rendering DashboardTab","color:magenta;"),c.useEffect(()=>{l||x.invalidateQueries({queryKey:n.tW.executeScript()})},[l,x]),(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)("div",{className:"grid grid-cols-1 xl:grid-cols-2 2xl:grid-cols-3 gap-4 w-full",children:null===(s=t.sections)||void 0===s?void 0:s.map((e,s)=>(0,a.jsx)(a.Fragment,{children:(0,a.jsxs)(i.$0,{visible:l,children:[(0,a.jsxs)("div",{className:"flex items-start max-sm:px-2 justify-between",children:[(0,a.jsx)("h2",{className:"overflow-hidden text-ellipsis",children:e.title}),(0,a.jsx)(i.hO,{size:"md",title:"Refresh",onClick:()=>x.invalidateQueries({queryKey:n.tW.getCategory("display")}),children:(0,a.jsx)(u.T8D,{className:"text-xl"})})]}),(0,a.jsx)("div",{className:"flex flex-col gap-2 overflow-auto [color-scheme:light_dark]",children:new p(e.fields).map((e,s,l)=>"button"===e.type?(0,a.jsx)(r.A,{name:e.label,scriptPath:e.$script,buttonOnly:!0},e.label+s):"display"===e.type?(0,a.jsx)(h,{name:e.label,scriptPath:e.$script},e.label+s):"chip"===e.type?(0,a.jsxs)("div",{className:"grid grid-cols-2 md:grid-cols-3 lg:grid-cols-4 gap-2",children:[(0,a.jsx)(m,{name:e.label,scriptPath:e.$script}),l.mapWhile(e=>"chip"===e.type,(e,s)=>(0,a.jsx)(m,{name:e.label,scriptPath:e.$script},e.label+s))]},e.label+s):void 0)})]},e.title+s)}))}),(0,a.jsx)(o.t,{visible:!0})]})};var f=l(5227),g=l(9473),j=l(3890);function b(){var e,s,l,i,r;let d=(0,n.XD)("meta","/api/dashboard/list",!0,6e4),c=(0,j.Y)("dashboardTab",null!==(l=null===(e=d.data)||void 0===e?void 0:e.map(e=>e.title))&&void 0!==l?l:[],null!==(i=null===(s=d.data)||void 0===s?void 0:s.map(e=>e.title).find(e=>e))&&void 0!==i?i:""),o=(0,n.XD)("meta","/api/dashboard/get/".concat(c.currentTab),(0,f.HD)(c.currentTab)&&c.currentTab.trim().length>0,6e4);return(0,a.jsx)(a.Fragment,{children:(0,a.jsxs)("main",{className:"flex flex-col items-center gap-4",children:[(0,a.jsx)(t.j,{showRefresh:!1,showLogout:!0}),(0,a.jsxs)("div",{className:"flex flex-col items-center gap-4 w-full px-4 pb-4",children:[(0,a.jsx)(g.m,{...c}),(0,a.jsx)(v,{visible:o.isFetched,dashboard:null!==(r=o.data)&&void 0!==r?r:{}})]})]})})}}},function(e){e.O(0,[391,913,888,774,179],function(){return e(e.s=8312)}),_N_E=e.O()}]);