harperdb 4.6.2 → 4.6.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -1
- package/bin/harperdb.js +75 -75
- package/bin/lite.js +74 -74
- package/launchServiceScripts/launchNatsIngestService.js +73 -73
- package/launchServiceScripts/launchNatsReplyService.js +73 -73
- package/launchServiceScripts/launchUpdateNodes4-0-0.js +74 -74
- package/npm-shrinkwrap.json +77 -77
- package/package.json +2 -2
- package/resources/ResourceInterface.d.ts +1 -0
- package/resources/Table.d.ts +40 -41
- package/resources/analytics/hostnames.d.ts +39 -39
- package/resources/blob.d.ts +4 -4
- package/resources/databases.d.ts +39 -39
- package/server/Server.d.ts +5 -1
- package/server/jobs/jobProcess.js +73 -73
- package/server/threads/threadServer.js +73 -73
- package/studio/build-local/asset-manifest.json +41 -41
- package/studio/build-local/index.html +1 -1
- package/studio/build-local/static/css/main.a46e2bd8.css +13 -0
- package/studio/build-local/static/js/11.17b2806b.chunk.js +2 -0
- package/studio/build-local/static/js/164.794c66a1.chunk.js +1 -0
- package/studio/build-local/static/js/23.55c690ce.chunk.js +1 -0
- package/studio/build-local/static/js/239.5d22fd48.chunk.js +2 -0
- package/studio/build-local/static/js/240.2c705279.chunk.js +2 -0
- package/studio/build-local/static/js/240.2c705279.chunk.js.LICENSE.txt +16 -0
- package/studio/build-local/static/js/279.bbdf2928.chunk.js +1 -0
- package/studio/build-local/static/js/724.daf66453.chunk.js +1 -0
- package/studio/build-local/static/js/833.8c4a4a90.chunk.js +1 -0
- package/studio/build-local/static/js/browse-csvupload.088afad6.chunk.js +1 -0
- package/studio/build-local/static/js/browse-datatable.9e5f57a4.chunk.js +1 -0
- package/studio/build-local/static/js/browse-entitymanager.b1467efe.chunk.js +1 -0
- package/studio/build-local/static/js/browse-jsonviewer.c5715070.chunk.js +1 -0
- package/studio/build-local/static/js/custom-functions.a20f8853.chunk.js +1 -0
- package/studio/build-local/static/js/instance-cluster.d9f5d94b.chunk.js +1 -0
- package/studio/build-local/static/js/instance-config.cc1f0e92.chunk.js +1 -0
- package/studio/build-local/static/js/instance-logs.9d60d6ad.chunk.js +1 -0
- package/studio/build-local/static/js/instance-roles.cf38a24f.chunk.js +1 -0
- package/studio/build-local/static/js/instance-status.3c776235.chunk.js +1 -0
- package/studio/build-local/static/js/instance-users-datatable.2fa06057.chunk.js +1 -0
- package/studio/build-local/static/js/instance-users-edit.d26ea514.chunk.js +1 -0
- package/studio/build-local/static/js/instance-users.f11ec173.chunk.js +1 -0
- package/studio/build-local/static/js/instance.99cd7bf2.chunk.js +1 -0
- package/studio/build-local/static/js/instances.289c385e.chunk.js +1 -0
- package/studio/build-local/static/js/{main.447848b8.js → main.ba5ab027.js} +2 -2
- package/studio/build-local/static/js/offline-app.54fd7408.chunk.js +1 -0
- package/studio/build-local/static/js/online-app.060fd872.chunk.js +1 -0
- package/studio/build-local/static/js/organization-billing.e0e08f86.chunk.js +1 -0
- package/studio/build-local/static/js/organization-users.5755c9f0.chunk.js +1 -0
- package/studio/build-local/static/js/organization.6db4c138.chunk.js +1 -0
- package/studio/build-local/static/js/organizations.cf417207.chunk.js +1 -0
- package/studio/build-local/static/js/profile.3502eb02.chunk.js +1 -0
- package/studio/build-local/static/js/resetPassword.bdccbba4.chunk.js +1 -0
- package/studio/build-local/static/js/roles-jsonviewer.2488b213.chunk.js +1 -0
- package/studio/build-local/static/js/signIn.44a8eea8.chunk.js +1 -0
- package/studio/build-local/static/js/signUp.84b57b20.chunk.js +1 -0
- package/studio/build-local/static/js/structure-reloader.99217942.chunk.js +1 -0
- package/studio/build-local/static/js/topnav.dc554a18.chunk.js +1 -0
- package/studio/build-local/static/js/updatePassword.56bfd9f7.chunk.js +1 -0
- package/utility/hdbTerms.d.ts +1 -1
- package/utility/scripts/restartHdb.js +73 -73
- package/studio/build-local/static/css/main.34b26890.css +0 -13
- package/studio/build-local/static/js/164.a89f3fc2.chunk.js +0 -1
- package/studio/build-local/static/js/23.3b9f7144.chunk.js +0 -1
- package/studio/build-local/static/js/239.183c6cbc.chunk.js +0 -2
- package/studio/build-local/static/js/279.7dfac9c5.chunk.js +0 -1
- package/studio/build-local/static/js/545.046f5738.chunk.js +0 -1
- package/studio/build-local/static/js/759.7c5150cd.chunk.js +0 -2
- package/studio/build-local/static/js/833.fbb1857f.chunk.js +0 -1
- package/studio/build-local/static/js/845.79392583.chunk.js +0 -2
- package/studio/build-local/static/js/845.79392583.chunk.js.LICENSE.txt +0 -5
- package/studio/build-local/static/js/browse-csvupload.2a02693a.chunk.js +0 -1
- package/studio/build-local/static/js/browse-datatable.6944e1d5.chunk.js +0 -1
- package/studio/build-local/static/js/browse-entitymanager.78d9f3cf.chunk.js +0 -1
- package/studio/build-local/static/js/browse-jsonviewer.b9b13d1d.chunk.js +0 -1
- package/studio/build-local/static/js/custom-functions.5e20728d.chunk.js +0 -1
- package/studio/build-local/static/js/instance-cluster.7fa04087.chunk.js +0 -1
- package/studio/build-local/static/js/instance-config.cab20f8e.chunk.js +0 -1
- package/studio/build-local/static/js/instance-logs.c590cea3.chunk.js +0 -1
- package/studio/build-local/static/js/instance-roles.02c01413.chunk.js +0 -1
- package/studio/build-local/static/js/instance-status.872064e6.chunk.js +0 -1
- package/studio/build-local/static/js/instance-users-datatable.eaa7f9f0.chunk.js +0 -1
- package/studio/build-local/static/js/instance-users-edit.b3009a22.chunk.js +0 -1
- package/studio/build-local/static/js/instance-users.d4c9a21b.chunk.js +0 -1
- package/studio/build-local/static/js/instance.ac2d8e63.chunk.js +0 -1
- package/studio/build-local/static/js/instances.e177eb54.chunk.js +0 -1
- package/studio/build-local/static/js/offline-app.e75335f8.chunk.js +0 -1
- package/studio/build-local/static/js/online-app.161383cc.chunk.js +0 -1
- package/studio/build-local/static/js/organization-billing.8a6543c9.chunk.js +0 -1
- package/studio/build-local/static/js/organization-users.28a7fddd.chunk.js +0 -1
- package/studio/build-local/static/js/organization.7e6de94f.chunk.js +0 -1
- package/studio/build-local/static/js/organizations.a35fef39.chunk.js +0 -1
- package/studio/build-local/static/js/profile.ec638faf.chunk.js +0 -1
- package/studio/build-local/static/js/resetPassword.c64684e3.chunk.js +0 -1
- package/studio/build-local/static/js/roles-jsonviewer.28347efe.chunk.js +0 -1
- package/studio/build-local/static/js/signIn.95abea6a.chunk.js +0 -1
- package/studio/build-local/static/js/signUp.a095114b.chunk.js +0 -1
- package/studio/build-local/static/js/structure-reloader.89712250.chunk.js +0 -1
- package/studio/build-local/static/js/topnav.6ac108a6.chunk.js +0 -1
- package/studio/build-local/static/js/updatePassword.839328e6.chunk.js +0 -1
- /package/studio/build-local/static/js/{759.7c5150cd.chunk.js.LICENSE.txt → 11.17b2806b.chunk.js.LICENSE.txt} +0 -0
- /package/studio/build-local/static/js/{239.183c6cbc.chunk.js.LICENSE.txt → 239.5d22fd48.chunk.js.LICENSE.txt} +0 -0
- /package/studio/build-local/static/js/{main.447848b8.js.LICENSE.txt → main.ba5ab027.js.LICENSE.txt} +0 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";(self.webpackChunkharperdb_studio=self.webpackChunkharperdb_studio||[]).push([[302],{4298:(e,t,n)=>{n.r(t),n.d(t,{default:()=>xt});var a=n(9950),s=n(6713),r=n(135),o=n(5269),l=n(7176),c=n(6114),i=n(4084),u=n(8156),d=n(5077),p=n(9435),m=n(9379),h=n(5488),f=n(3452),g=n(9163),x=n.n(g);var j=n(127);const v=async e=>{let{auth:t,url:n}=e;return(0,j.A)({operation:{operation:"custom_functions_status"},auth:t,url:n,timeout:5e3})},b=async e=>{let{auth:t,url:n}=e;return(0,j.A)({operation:{operation:"get_custom_functions"},auth:t,url:n})};function y(e,t,n){let a=arguments.length>3&&void 0!==arguments[3]&&arguments[3];if(e&&e.entries){var s,r,o;if(t===n)e.path=n,e.key=null!==(s=null===(r=(o=crypto).randomUUID)||void 0===r?void 0:r.call(o))&&void 0!==s?s:Math.random().toString().slice(2);for(const s of e.entries){var l,c,i;const e="".concat(t,"/").concat(s.name),[,r]=e.split("/");s.project=r,s.path=e,s.key=null!==(l=null===(c=(i=crypto).randomUUID)||void 0===c?void 0:c.call(i))&&void 0!==l?l:Math.random().toString().slice(2),s.readOnly=a||!!s.package,y(s,e,n,s.readOnly)}}}const A=async e=>{let{auth:t,url:n}=e;const a=await(0,j.A)({operation:{operation:"get_components"},auth:t,url:n});return y(a,a.name,a.name,!1),a},N=async e=>{let{auth:t,url:n}=e;const{is_enabled:a,port:s,directory:r,error:l,message:c}=await v({auth:t,url:n}),i=await A({auth:t,url:n}),u={is_enabled:a,port:s,endpoints:a?await b({auth:t,url:n}):{},directory:r,error:l,message:c,fileTree:i};return o.A.update((e=>{e.custom_functions=u})),{custom_functions:u}};var k=n(4414);const C=function(){const e=(0,s.O$)(o.A,(e=>e.auth)),t=(0,s.O$)(o.A,(e=>e.url)),n=(0,s.O$)(o.A,(e=>e.is_local)),r=(0,s.O$)(o.A,(e=>{var t;return null===(t=e.custom_functions)||void 0===t?void 0:t.port})),[d,p]=(0,a.useState)({}),[g,v]=(0,a.useState)({port:r||9926});return x()((async()=>{const{submitted:n}=d;if(n){const{port:n}=g;if(n)if(a=n,Number.isNaN(parseFloat(a))||!Number.isFinite(parseFloat(a)))p({error:"port must be a valid number"});else{const a=await(async e=>{let{auth:t,url:n,port:a}=e;return(0,j.A)({operation:{operation:"configure_cluster",CUSTOM_FUNCTIONS_PORT:parseInt(a,10)},auth:t,url:n})})({auth:e,url:t,port:n});a.error?p({error:a.message}):N({auth:e,url:t})}else p({error:"All fields are required"})}var a}),[d]),x()((()=>{d.submitted||p({})}),[g]),n&&!r?(0,k.jsxs)(k.Fragment,{children:[(0,k.jsx)("div",{className:"text-nowrap mb-3",children:"Custom Functions Port"}),(0,k.jsx)(h.A,{id:"custom_api_port",onChange:e=>v((0,m.A)((0,m.A)({},g),{},{port:e.target.value})),className:"mb-3 ".concat(d.error&&!g.port?"error":""),type:"number",title:"custom api port",placeholder:"9926",value:g.port}),(0,k.jsx)(f.A,{color:"success",block:!0,onClick:()=>p({submitted:!0}),children:"Set Custom API Port"}),!!d.error&&(0,k.jsx)(i.A,{className:"mt-3 error",children:(0,k.jsx)(u.A,{children:d.error})})]}):(0,k.jsxs)(l.A,{children:[(0,k.jsxs)(c.A,{xs:"10",children:["Custom Functions Port ",n?r:"Set"]}),(0,k.jsx)(c.A,{xs:"2",className:"text-end",children:(0,k.jsx)("i",{className:"fa fa-check-circle fa-lg text-success"})})]})};var w=n(4834),_=n(2010),S=n(6177);const F=function(e){let{setConfiguring:t}=e;const{compute_stack_id:n}=(0,d.g)(),r=(0,s.O$)(o.A,(e=>e.auth),[n]),l=(0,s.O$)(o.A,(e=>e.url),[n]),c=(0,s.O$)(o.A,(e=>{var t;return parseFloat(null===(t=e.registration)||void 0===t?void 0:t.version)>=4?"nats":"socketcluster"}),[n]),[i,u]=(0,a.useState)({});return x()((async()=>{if(i.submitted){if("nats"===c)await(0,w.A)({auth:r,url:l,customFunctions_enabled:!0});else{const e=await(0,S.A)({auth:r,url:l});await(0,w.A)({auth:r,url:l,operation:"configure_cluster",CUSTOM_FUNCTIONS:!0,CLUSTERING:Boolean(null===e||void 0===e?void 0:e.config_cluster_user),CLUSTERING_PORT:null===e||void 0===e?void 0:e.config_cluster_port,CLUSTERING_USER:null===e||void 0===e?void 0:e.config_cluster_user,NODE_NAME:null===e||void 0===e?void 0:e.nodeName})}window._kmq&&window._kmq.push(["record","enabled custom functions"]),(0,_.A)({auth:r,url:l}),setTimeout((()=>t(!0)),0)}}),[i.submitted]),(0,k.jsxs)(k.Fragment,{children:[(0,k.jsx)("hr",{className:"my-3"}),(0,k.jsx)(f.A,{color:"success",disabled:i.submitted,block:!0,onClick:()=>u({submitted:!0}),children:i.submitted?(0,k.jsx)("i",{className:"fa fa-spinner fa-spin text-white"}):"Enable Custom Functions"})]})};var O=n(6165),P=n(3150),E=n(3628);const D=function(e){let{setConfiguring:t}=e;const{compute_stack_id:n}=(0,d.g)(),a=(0,s.O$)(o.A,(e=>{var t;return null===(t=e.custom_functions)||void 0===t?void 0:t.port}),[n]);return(0,k.jsxs)(l.A,{id:"functions",children:[(0,k.jsxs)(c.A,{xl:"3",lg:"4",md:"5",xs:"12",children:[(0,k.jsx)("span",{className:"floating-card-header",children:"enable custom functions"}),(0,k.jsx)(i.A,{className:"my-3",children:(0,k.jsx)(u.A,{children:(0,k.jsxs)(p.tH,{onError:(e,t)=>(0,E.A)({error:{message:e.message,componentStack:t}}),FallbackComponent:P.A,children:[(0,k.jsx)(C,{}),!!a&&(0,k.jsx)(F,{setConfiguring:t})]})})})]}),(0,k.jsx)(c.A,{xl:"9",lg:"8",md:"7",xs:"12",children:a?(0,k.jsx)(O.A,{headline:"Enable Custom Functions",description:"Click the button at left to enable Custom Functions. NOTE: We'll restart the instance when you click this button.",icon:(0,k.jsx)("i",{className:"fa fa-thumbs-up text-success"})}):(0,k.jsx)(O.A,{headline:"Set Your Custom Functions Server Port",description:"If your instance is behind a firewall, you'll need to ensure this port is accessible by other instances if you want to access the API.",icon:(0,k.jsx)("i",{className:"fa fa-thumbs-up text-success"})})})]})};var I=n(7348),T=n(5553);const R=async e=>{let{auth:t,url:n,project:a,file:s}=e;return(0,j.A)({operation:{operation:"get_component_file",project:a,file:s},auth:t,url:n})},z=async e=>{let{auth:t,url:n,project:a,file:s,payload:r}=e;return(0,j.A)({operation:{operation:"set_component_file",project:a,file:s,payload:r},auth:t,url:n})},U=async e=>{let{auth:t,url:n,project:a,file:s}=e;return(0,j.A)({operation:{operation:"drop_component",project:a,file:s},auth:t,url:n})},$=async e=>{let{auth:t,url:n,project:a,packageUrl:s,payload:r}=e;return r?(0,j.A)({auth:t,url:n,operation:{operation:"deploy_component",project:a,payload:r}}):(0,j.A)({auth:t,url:n,operation:{operation:"deploy_component",project:a,package:s}})};var L=n(1534),W=n(4319);const M=(0,n(6997).A)("editorCache");var q=n(8738),H=n.n(q);function G(){return(0,k.jsx)(i.A,{className:"file-browser-scroll-container",children:(0,k.jsx)(u.A,{children:(0,k.jsxs)("div",{className:"p-4",children:["You have no Harper applications yet. ",(0,k.jsx)("br",{}),(0,k.jsx)("br",{}),'Click "',(0,k.jsx)("i",{className:"fas fa-plus"}),' app" above to create one!',(0,k.jsx)("br",{}),(0,k.jsx)("br",{}),"See the"," ",(0,k.jsx)("a",{className:"docs-link",href:"https://docs.harperdb.io",target:"_blank",rel:"noreferrer",children:"documentation"})," ","for more info on Harper Applications."]})})})}function B(e,t){const n=+Boolean(e.entries),a=+Boolean(t.entries);return n===a?e.name.localeCompare(t.name):a-n}function V(){return(0,k.jsx)("i",{className:H()("package-icon fas fa-cube")})}function K(e){let{name:t,url:n,onPackageSelect:s,selectedPackage:r}=e;const[o,l]=(0,a.useState)(Boolean(r)&&t===(null===r||void 0===r?void 0:r.name));return(0,a.useEffect)((()=>{l(r&&r.name===t)}),[r,t]),(0,k.jsxs)("button",{type:"button",onClick:e=>{s(o?null:{name:t,url:n,event:e}),l(!o)},className:H()("package",{"package-selected":o}),onKeyDown:()=>{},children:[(0,k.jsx)(V,{}),(0,k.jsx)("span",{className:"package-text",children:t})]})}function Z(e){let{directoryEntry:t,selectedFile:n,selectedFolder:a,onFileSelect:s,onFolderSelect:r,Icon:o}=e;const l=Boolean(t.entries);const c=t.path===n,i=t.path===(null===a||void 0===a?void 0:a.path);return(0,k.jsxs)("button",{type:"button",onClick:function(e){const n=e.target.classList.contains("rename-file")||e.target.classList.contains("deploy-project");l?i&&n||r(i?null:t):s(c?null:t)},className:H()("file",{"file-selected":c,"folder-selected":i}),onKeyDown:function(){},children:[(0,k.jsx)(o,{className:"filename-icon"}),(0,k.jsx)("span",{className:"filename-text",children:t.name})]})}function Y(e){let{directoryEntry:t,userOnSelect:n,onFolderSelect:s,onDeployProject:r,onFileSelect:o,onPackageSelect:l,onFileRename:c,selectedFile:i,selectedFolder:u,selectedPackage:d}=e;const[p,m]=(0,a.useState)(!0),h=[...t.entries||[]].sort(B),f=(g=t.name)&&[...g].includes(".")?g.split(".").slice(-1)[0]:null;var g;let x;return x=2===t.path.split("/").length?()=>function(e){let{toggleClosed:t,isOpen:n}=e;return(0,k.jsx)("i",{onClick:t,onKeyDown:t,className:H()("project-icon fas fa-file-code"),tabIndex:0,"aria-expanded":n,"aria-controls":"folder","aria-label":n?"close project":"open project",role:"button"})}({isOpen:p,toggleClosed:()=>m(!p)}):t.entries?()=>function(e){let{toggleClosed:t,isOpen:n}=e;return(0,k.jsx)("i",{onClick:t,onKeyDown:t,className:H()("folder-icon fas ".concat(n?"fa-folder-open":"fa-folder")),tabIndex:0,"aria-expanded":n,"aria-controls":"folder","aria-label":n?"close folder":"open folder",role:"button"})}({isOpen:p,toggleClosed:()=>m(!p)}):()=>function(e){let{extension:t}=e;switch(t){case"js":return(0,k.jsx)("i",{className:H()("file-icon filetype-js fab fa-js")});case"yaml":return(0,k.jsx)("i",{className:H()("file-icon filetype-yaml fas fa-cog")});default:return(0,k.jsx)("i",{className:H()("file-icon filetype-unknown far fa-file-alt")})}}({extension:f}),(0,k.jsxs)(k.Fragment,{children:["components"!==t.name?(0,k.jsx)("li",{className:H()("".concat(t.entries?"folder-container":"file-container"," ").concat(p?"folder-open":"folder-closed")),children:t.package?(0,k.jsx)(K,{selectedPackage:d,onPackageSelect:l,name:t.name,url:t.package}):(0,k.jsx)(Z,{Icon:x,selectedFile:i,selectedFolder:u,selectedPackage:d,directoryEntry:t,onDeployProject:r,onFileRename:()=>{c(t)},onFileSelect:o,onFolderSelect:s,userOnSelect:n})},t.key):null,h.map((e=>(0,k.jsx)("li",{children:(0,k.jsx)("ul",{className:H()("folder",{"folder-contents-open":!0,"folder-contents-closed":!1}),children:(0,k.jsx)(Y,{selectedFile:i,selectedFolder:u,selectedPackage:d,directoryEntry:e,onFileSelect:o,onDeployProject:r,onFileRename:c,onFolderSelect:s,onPackageSelect:l,userOnSelect:n})})},e.key)))]})}const J=function(e){var t;let{files:n,userOnSelect:a,onFileSelect:s,onPackageSelect:r,onDeployProject:o,onFileRename:l,onFolderSelect:c,selectedFile:d,selectedFolder:p,selectedPackage:m}=e;return null!==n&&void 0!==n&&null!==(t=n.entries)&&void 0!==t&&t.length?(0,k.jsx)(i.A,{className:"file-browser-scroll-container",children:(0,k.jsx)(u.A,{children:(0,k.jsx)("ul",{className:"file-browser",children:(0,k.jsx)(Y,{selectedFile:d,selectedFolder:p,selectedPackage:m,onFileSelect:s,onFileRename:l,onFolderSelect:c,onDeployProject:o,onPackageSelect:r,userOnSelect:a,directoryEntry:n})})})}):(0,k.jsx)(G,{})};var Q=n(5023);Q.wG.init().then((e=>{e.editor.defineTheme("hdb",{base:"vs-dark",inherit:!0,rules:[],colors:{"editor.background":"#111111"}})}));const X={js:"javascript",yaml:"yaml",ts:"typescript",json:"json",md:"markdown",html:"html",css:"css",graphql:"graphql",mjs:"javascript"};const ee=function(e){let{active:t,file:n,onFileChange:s}=e;const[r,o]=(0,a.useState)("javascript");return(0,a.useEffect)((()=>{const e=function(e){var t;const n=null===(t=e||"")||void 0===t?void 0:t.split(".");return n.length>1?n.slice(-1)[0]:""}(null===n||void 0===n?void 0:n.name);o(X[e]||"plaintext")}),[n]),t?(0,k.jsx)(Q.Ay,{height:"100%",language:r,value:(null===n||void 0===n?void 0:n.content)||"",theme:"hdb",onChange:s,options:{readOnly:null===n||void 0===n?void 0:n.readOnly,automaticLayout:!0,minimap:{enabled:!1}}}):null};function te(e){let{onClick:t,disabled:n=!1,text:a="",extraClasses:s=""}=e;return(0,k.jsxs)("button",{type:"button",disabled:n,onClick:t,className:s,title:"Create a new app",children:[(0,k.jsx)("i",{className:"fas fa-plus"}),a&&(0,k.jsxs)("span",{className:"ms-1",children:[" ",a]})]})}function ne(e){let{onClick:t,disabled:n=!1,text:a="",extraClasses:s=""}=e;return(0,k.jsxs)("button",{type:"button",disabled:n,onClick:t,className:s,title:"Add a folder",children:[(0,k.jsx)("i",{className:"fas fa-plus"}),a&&(0,k.jsx)("span",{className:"ms-1 d-none d-lg-inline-block",children:a})]})}function ae(e){let{onClick:t,disabled:n=!1,text:a="",extraClasses:s=""}=e;return(0,k.jsxs)("button",{type:"button",onClick:t,disabled:n,className:s,title:"Delete selected app or folder",children:[(0,k.jsx)("i",{className:"fas fa-minus"}),a&&(0,k.jsx)("span",{className:"ms-1 d-none d-lg-inline-block",children:a})]})}function se(e){let{onClick:t,disabled:n,text:a="",extraClasses:s=""}=e;return(0,k.jsxs)("button",{type:"button",disabled:n,onClick:t,className:s,title:"Add a new file",children:[(0,k.jsx)("i",{className:"fas fa-plus"}),a&&(0,k.jsxs)("span",{className:"ms-1 d-none d-lg-inline-block",children:[" ",a]})]})}function re(e){let{onClick:t,disabled:n,text:a="",extraClasses:s=""}=e;return(0,k.jsxs)("button",{type:"button",onClick:t,disabled:n,className:s,title:"Delete selected file",children:[(0,k.jsx)("i",{className:"fas fa-minus"}),a&&(0,k.jsxs)("span",{className:"ms-1 d-none d-lg-inline-block",children:[" ",a]})]})}const oe=function(e){let{children:t}=e;return(0,k.jsx)("ul",{className:"file-menu text-nowrap",children:t.map((e=>{var t,n,a;return e&&(0,k.jsx)("li",{className:"file-menu-item",children:e},null!==(t=null===(n=(a=crypto).randomUUID)||void 0===n?void 0:n.call(a))&&void 0!==t?t:Math.random().toString().slice(2))}))})};function le(e){let{onClick:t,disabled:n=!1,text:a="",extraClasses:s=""}=e;return(0,k.jsxs)("button",{type:"button",disabled:n,onClick:t,className:s,title:"Import external component or application",children:[(0,k.jsx)("i",{className:"fas fa-share-alt"}),a&&(0,k.jsx)("span",{className:"ms-2 d-none d-lg-inline-block",children:a})]})}function ce(e){let{onClick:t,savingFile:n,disabled:a=!1,text:s="",extraClasses:r=""}=e;return(0,k.jsxs)("button",{type:"button",onClick:t,disabled:a,className:r,title:"save file to instance",children:[(0,k.jsx)("i",{className:H()("fas",{"fa-save":!n,"fa-spinner":n,"fa-spin":n})}),s&&(0,k.jsx)("span",{className:"ms-2 d-none d-lg-inline-block",children:s})]})}function ie(e){let{onClick:t,restarting:n,disabled:a=!1,text:s="",extraClasses:r=""}=e;return(0,k.jsxs)("button",{type:"button",onClick:t,disabled:a,className:r,title:"Click to restart your instance",children:[(0,k.jsx)("i",{className:H()("fas",{"fa-sync":!n,"fa-spinner":n,"fa-spin":n})}),s&&(0,k.jsx)("span",{className:"ms-2 d-none d-lg-inline-block",children:s})]})}function ue(e){let{onClick:t,restartAfterSave:n,disabled:a=!1,text:s="",extraClasses:r=""}=e;return(0,k.jsxs)("button",{type:"button",onClick:t,disabled:a,className:r,title:"Toggle whether saving a file restarts the application",children:[(0,k.jsx)("i",{className:H()("fa",{"fa-toggle-on":n,"fa-toggle-off":!n})}),s&&(0,k.jsx)("span",{className:"ms-2 d-none d-lg-inline-block",children:s})]})}function de(e){let{onClick:t,disabled:n=!1,text:a="",extraClasses:s="",loading:r}=e;return(0,k.jsxs)("button",{type:"button",disabled:n,onClick:t,className:s,title:"revert file",children:[(0,k.jsx)("i",{className:H()("revert-file fas",{disabled:n,"fa-history":!r,"fa-spinner":r,"fa-spin":r})}),a&&(0,k.jsx)("span",{className:"ms-2 d-none d-lg-inline-block",children:a})]})}function pe(e){let{children:t}=e;return(0,k.jsx)("ul",{className:"editor-menu",children:t.map((e=>{var t,n,a;return e&&(0,k.jsx)("li",{className:"editor-menu-item",children:e},null!==(t=null===(n=(a=crypto).randomUUID)||void 0===n?void 0:n.call(a))&&void 0!==t?t:Math.random().toString().slice(2))}))})}function me(e){let{active:t,AddProjectButtonClick:n,InstallPackageButtonClick:a}=e;return t?(0,k.jsxs)("div",{className:"content-window",children:[(0,k.jsx)("h4",{className:"mb-5",children:"Add A New Application"}),(0,k.jsx)(te,{text:"Create A New Application Using The Default Template",extraClasses:"btn btn-block btn-success",onClick:n}),(0,k.jsx)(le,{text:"Import Or Deploy A Remote Application Package",extraClasses:"btn btn-block btn-outline-success mt-2",onClick:a})]}):null}function he(e){let{active:t,type:n}=e;return t?(0,k.jsxs)("div",{className:"content-window text-nowrap",children:[(0,k.jsx)("i",{className:"fa fa-exclamation-triangle mt-5 pt-5"}),"\xa0",(0,k.jsxs)("span",{children:["You have selected a ",n,". Nothing to see here!"]})]}):null}var fe=n(8547);function ge(e){return/^[a-zA-Z0-9-_]+$/.test(e)}function xe(e){if(!e)return null;const t={type:null,user:null,repo:null,url:null,package:null,tag:null};if(e.url.match("://"))t.url=e.url,t.type="url";else if(e.url.match("semver:")){const[n,a,s]=e.url.split(/[/#]/);t.type="github",t.user=n,t.repo=a,t.tag=s.replace("semver:","")}else{t.type="npm";const n=e.url.split("/");if(1===n.length){const[e,a]=n[0].split("@");t.package=e,t.tag=a}else if(2===n.length){const[,e]=n,[a,s]=e.split("@");t.package=a,t.tag=s}}return t}function je(e,t,n){var s=this,r=(0,a.useRef)(null),o=(0,a.useRef)(0),l=(0,a.useRef)(null),c=(0,a.useRef)([]),i=(0,a.useRef)(),u=(0,a.useRef)(),d=(0,a.useRef)(e),p=(0,a.useRef)(!0);d.current=e;var m="undefined"!=typeof window,h=!t&&0!==t&&m;if("function"!=typeof e)throw new TypeError("Expected a function");t=+t||0;var f=!!(n=n||{}).leading,g=!("trailing"in n)||!!n.trailing,x="maxWait"in n,j="debounceOnServer"in n&&!!n.debounceOnServer,v=x?Math.max(+n.maxWait||0,t):null;(0,a.useEffect)((function(){return p.current=!0,function(){p.current=!1}}),[]);var b=(0,a.useMemo)((function(){var e=function(e){var t=c.current,n=i.current;return c.current=i.current=null,o.current=e,u.current=d.current.apply(n,t)},n=function(e,t){h&&cancelAnimationFrame(l.current),l.current=h?requestAnimationFrame(e):setTimeout(e,t)},a=function(e){if(!p.current)return!1;var n=e-r.current;return!r.current||n>=t||n<0||x&&e-o.current>=v},b=function(t){return l.current=null,g&&c.current?e(t):(c.current=i.current=null,u.current)},y=function e(){var s=Date.now();if(a(s))return b(s);if(p.current){var l=t-(s-r.current),c=x?Math.min(l,v-(s-o.current)):l;n(e,c)}},A=function(){if(m||j){var d=Date.now(),h=a(d);if(c.current=[].slice.call(arguments),i.current=s,r.current=d,h){if(!l.current&&p.current)return o.current=r.current,n(y,t),f?e(r.current):u.current;if(x)return n(y,t),e(r.current)}return l.current||n(y,t),u.current}};return A.cancel=function(){l.current&&(h?cancelAnimationFrame(l.current):clearTimeout(l.current)),o.current=0,c.current=r.current=i.current=l.current=null},A.isPending=function(){return!!l.current},A.flush=function(){return l.current?b(Date.now()):u.current},A}),[f,x,t,v,g,h,m,j]);return b}function ve(e,t){return e===t}function be(e,t,n){var s=n&&n.equalityFn||ve,r=(0,a.useRef)(e),o=(0,a.useState)({})[1],l=je((0,a.useCallback)((function(e){r.current=e,o({})}),[o]),t,n),c=(0,a.useRef)(e);return s(c.current,e)||(l(e),c.current=e),[r.current,l]}function ye(e){let{pkg:t,setPackageSpec:n}=e;const[s,r]=(0,a.useState)((null===t||void 0===t?void 0:t.user)||""),[o]=be(s,300),[l,c]=(0,a.useState)((null===t||void 0===t?void 0:t.repo)||""),[i]=be(l,300),[u,d]=(0,a.useState)([]),[p,m]=(0,a.useState)(!1),[f,g]=(0,a.useState)((null===t||void 0===t?void 0:t.tag)||""),[x,j]=(0,a.useState)(""),[,v]=(0,a.useState)(!1),[b,y]=(0,a.useState)(!1);return(0,a.useEffect)((()=>{r((null===t||void 0===t?void 0:t.user)||""),c((null===t||void 0===t?void 0:t.repo)||""),d(null!==t&&void 0!==t&&t.tag?[null===t||void 0===t?void 0:t.tag]:[]),g((null===t||void 0===t?void 0:t.tag)||"")}),[t]),(0,a.useEffect)((()=>{o&&i?(v(!0),async function(e,t){try{const n=await fetch("https://api.github.com/repos/".concat(e,"/").concat(t)),a=await n.json();return n.status<400?a.name:null}catch(n){return null}}(s,i).then((e=>{e?(j(e),y(!0),async function(e,t){const n=await fetch("https://api.github.com/repos/".concat(e,"/").concat(t,"/git/refs/tags"));if(n.status<400)return(await n.json()).map((e=>e.ref.split("/").slice(-1)[0]));return[]}(s,i).then((e=>{v(!1),m(!0),d(e)}))):(v(!1),y(!1),j(""),d([]))})).catch((()=>{v(!1)}))):(y(!1),v(!1),d([]),g(""))}),[o,i,s]),(0,a.useEffect)((()=>{if(s&&l&&x){const e=f?"".concat(s,"/").concat(l,"#semver:").concat(f):"".concat(s,"/").concat(l);n(e)}else n("")}),[x,f,s,n,l]),(0,k.jsxs)(k.Fragment,{children:[(0,k.jsx)(h.A,{title:"Github Organization",className:"mt-2 form-control",valid:o.length>0&&i.length>0&&b,placeholder:"Github Organization",onChange:e=>r(e.target.value),value:s}),(0,k.jsx)(h.A,{title:"Github Repo",className:"mt-2",placeholder:"Github Repo",onChange:e=>c(e.target.value),value:l}),(null===u||void 0===u?void 0:u.length)>0&&(0,k.jsx)(fe.Ay,{className:"react-select-container github-tag-select mt-2",classNamePrefix:"react-select",isDisabled:!x,isSearchable:!0,placeholder:"Choose a tag",onChange:e=>g(e.value),options:u.map((e=>({label:e,value:e})))})]})}function Ae(e){let{pkg:t,setPackageSpec:n}=e;const[s,r]=(0,a.useState)(""),[o]=be(s,300),[l,c]=(0,a.useState)(""),[i,u]=(0,a.useState)(""),[d,p]=(0,a.useState)(""),[m,h]=(0,a.useState)(!1),[f,g]=(0,a.useState)(!1);return(0,a.useEffect)((()=>{r((null===t||void 0===t?void 0:t.package)||"")}),[t]),(0,a.useEffect)((function(){if(d){const e=i?"".concat(d,"@").concat(i):d;n(e)}else n("")}),[d,i,n]),(0,a.useEffect)((function(){o?(h(!0),async function(e){var t;const n=await fetch("https://registry.npmjs.org/-/v1/search?text=".concat(e)),a=(await n.json()).objects.find((t=>t.package.name===e));return null===a||void 0===a||null===(t=a.package)||void 0===t?void 0:t.name}(o).then((e=>{h(!1),g(!!e),p(e),e&&async function(e){const t=await fetch("https://registry.npmjs.org/".concat(e));return(await t.json())["dist-tags"]}(e).then((e=>{c(e),u(null)})).catch((e=>{throw e}))})).catch((()=>{h(!1)}))):(p(null),c(null),u(null))}),[o]),(0,k.jsxs)(k.Fragment,{children:[(0,k.jsxs)("div",{className:"input-group",children:[(0,k.jsx)("input",{className:"mt-2 form-control",title:"enter an npm package specifier",value:s,placeholder:"Enter the [@scope]/package",onChange:function(e){r(e.target.value)}}),(0,k.jsx)("div",{className:"input-group-append",children:(0,k.jsx)("i",{className:H()("input-group-text fa mt-2",{"fa-spinner fa-spin loading":m,"fa-check found":o.length>0&&f,"fa-times not-found":o.length>0&&!(m||f),"fa-check not-searching":0===o.length})})})]}),(0,k.jsx)(fe.Ay,{className:"react-select-container mt-2",classNamePrefix:"react-select",isDisabled:!s,placeholder:"Choose a tag",disabled:!l,onChange:function(e){let{value:t}=e;u(t)},options:Object.entries(l||[]).map((e=>{let[t,n]=e;return{label:"".concat(t," (").concat(n,")"),value:t}}))})]})}function Ne(e){return function(e){try{return Boolean(new URL(e))}catch(t){return!1}}(e)&&(-1!==e.indexOf(".tar")||-1!==e.indexOf(".tar.gz")||-1!==e.indexOf(".tgz"))}function ke(e){let{pkg:t,setPackageSpec:n}=e;const[s,r]=(0,a.useState)((null===t||void 0===t?void 0:t.url)||""),[o,l]=(0,a.useState)(Ne(null===t||void 0===t?void 0:t.url));return(0,a.useEffect)((()=>{n(o?s:"")}),[s,o,n]),(0,k.jsx)(h.A,{type:"text",id:"tarball-url",title:"URL to gzipped tarball",className:H()("package-url-input mt-2",{invalid:!o}),value:s,onChange:e=>{l(0===e.target.value.length||Ne(e.target.value)),r(e.target.value)},placeholder:"URL to gzipped tarball"})}var Ce=n(5996);function we(e){let{selectedPackage:t,onConfirm:n,onCancel:r,deployTargets:l,active:c}=e;const i=!1,[u,d]=(0,a.useState)(Boolean(t)),[p,m]=(0,a.useState)(xe(t)),[g,x]=(0,a.useState)((null===p||void 0===p?void 0:p.type)||i),[j,v]=(0,a.useState)((null===t||void 0===t?void 0:t.name)||""),[b,y]=(0,a.useState)(!0),[A,N]=(0,a.useState)(""),[C,w]=(0,a.useState)(!1),_=(0,s.O$)(o.A,(e=>e.auth)),S=(0,s.O$)(o.A,(e=>e.url)),[F,O]=(0,a.useState)([{isCurrentInstance:!0,auth:_,instance:{url:S,instance_name:"This Instance"}}]);function P(){v(""),y(!1),x(!1),O([]),r()}return(0,a.useEffect)((function(){const e=xe(t);v((null===t||void 0===t?void 0:t.name)||""),m(xe(t)),x((null===e||void 0===e?void 0:e.type)||i),d(Boolean(t))}),[t,i]),(0,a.useEffect)((function(){y(ge(j))}),[j]),c?(0,k.jsxs)("div",{className:"content-window",children:[(0,k.jsx)("h4",{className:"mb-5",children:"Import Remote App Package"}),(0,k.jsx)(h.A,{valid:b&&j.length>0,title:"enter a name for this package",value:j,placeholder:"Application Name",onChange:e=>{v(e.target.value),y(ge(e.target.value))}}),!Ce.A.is_local_studio&&(0,k.jsx)(fe.Ay,{className:"react-select-container package-install-deploy-targets-dropdown mt-2",classNamePrefix:"react-select",isSearchable:!0,isMulti:!0,placeholder:"Choose your deploy targets",onChange:e=>{const t=e.map((e=>e.value)),n=l.filter((e=>t.includes(e.instance.url)));O(n)},options:l.map((e=>({label:e.instance.instance_name,value:e.instance.url})))}),(0,k.jsx)(fe.Ay,{className:"react-select-container mt-2",classNamePrefix:"react-select",placeholder:"How would you like to fetch this package?",onChange:function(e){let{value:t}=e;x(t)},options:[{label:"A Public GitHub Repo",value:"github"},{label:"Install a gzipped .tar file from a URL",value:"url"}]}),!b&&j.length>0&&(0,k.jsxs)("span",{className:"text-danger text-center mt-3",children:[(0,k.jsx)("i",{className:"fa fa-exclamation-triangle"}),(0,k.jsx)("br",{}),(0,k.jsx)("span",{className:"mt-2",children:"Project name limited to alphanumeric, dashes, & underscores."})]}),b&&F.length>0&&(0,k.jsxs)(k.Fragment,{children:[(0,k.jsx)("div",{className:"mt-2"}),"npm"===g&&(0,k.jsx)(Ae,{projectName:j,installed:u,pkg:p,setPackageSpec:N}),"github"===g&&(0,k.jsx)(ye,{projectName:j,installed:u,pkg:p,setPackageSpec:N}),"url"===g&&(0,k.jsx)(ke,{projectName:j,installed:u,pkg:p,setPackageSpec:N})]}),b&&F.length>0&&g?(0,k.jsxs)(k.Fragment,{children:[(0,k.jsx)(f.A,{onClick:async()=>{w(!0);try{await n(j,A,F)}catch(e){w(!1)}w(!1)},className:H()("btn btn-block btn-success mt-3",{loading:C}),disabled:!ge(j)||!A||!F.length,children:C?(0,k.jsx)("i",{className:"install-package-status-icon fa fa-spinner fa-spin"}):"Install Package"}),(0,k.jsx)(f.A,{onClick:P,className:"btn btn-block btn-outline-success mt-2",children:"Cancel"})]}):(0,k.jsx)(f.A,{onClick:P,className:"btn btn-block btn-outline-success mt-3",children:"Cancel"})]}):null}function _e(e){let{className:t,onClick:n,disabled:s,children:r}=e;const[o,l]=(0,a.useState)(!1);return(0,k.jsx)("button",{disabled:s,type:"button",onClick:async()=>{l(!0);try{await n(),l(!1)}catch(e){l(!1)}},className:H()("".concat(t," button-with-loader"),{loading:o}),children:o?(0,k.jsx)("i",{className:"button-with-loader-icon fas fa-spinner fa-spin"}):r})}function Se(e){let{onCancel:t,onConfirm:n,onEnter:s,value:r,type:o,validate:l=()=>!0}=e;const[c,i]=(0,a.useState)(r||""),[u,d]=(0,a.useState)(!1);return(0,k.jsxs)(k.Fragment,{children:[(0,k.jsx)("input",{className:H()("w-100 text-center",{invalid:c.length>0&&!u}),onChange:e=>{i(e.target.value),d(l(e.target.value))},onKeyDown:function(e){"Enter"===e.key?s(e.target.value):"Esc"===e.key&&t()},value:c,placeholder:"name for your new ".concat(o),title:"name for your new ".concat(o)}),(0,k.jsx)("i",{title:"error: name must contain only alphanumeric characters, dashes and underscores.",className:H()("text-danger fa fa-warning",{hidden:u||0===c.length})}),(0,k.jsx)(_e,{disabled:!u,className:"btn btn-success btn-block mt-3",onClick:()=>n(c),children:"OK"}),(0,k.jsx)("button",{type:"button",className:"btn btn-outline-success btn-block mt-2",onClick:t,children:"Cancel"}),c.length>0&&!u&&(0,k.jsx)("div",{className:"validation-message mt-5",children:"error: name must contain only alphanumeric characters, dashes and underscores."})]})}function Fe(e){let{active:t,onConfirm:n,onCancel:a}=e;return t?(0,k.jsxs)("div",{className:"content-window",children:[(0,k.jsx)("h4",{className:"mb-5",children:"Default Template Application"}),(0,k.jsx)(Se,{type:"project",validate:ge,onEnter:n,onConfirm:n,onCancel:a})]}):null}function Oe(e){let{active:t,onConfirm:n,onCancel:a,selectedFolder:s}=e;return t?(0,k.jsxs)("div",{className:"content-window",children:[(0,k.jsxs)("h4",{className:"mb-5",children:["Add Folder To ",(0,k.jsx)("span",{className:"text-success",children:s.path.replace("components","")})]}),(0,k.jsx)(Se,{type:"folder",selectedFolder:s,onEnter:n,onConfirm:n,onCancel:a})]}):null}function Pe(e){let{active:t,onConfirm:n,onCancel:a}=e;return t?(0,k.jsxs)("div",{className:"content-window",children:[(0,k.jsx)("h4",{className:"mb-5",children:"Add A New File"}),(0,k.jsx)(Se,{type:"file",onEnter:n,onConfirm:n,onCancel:a})]}):null}function Ee(e){let{active:t,selectedFile:n,onConfirm:a,onCancel:s}=e;if(!t)return null;const{path:r}=n,o=r.split("/"),l=o.pop(),c=o.slice(1);return(0,k.jsxs)("div",{className:"content-window",children:[(0,k.jsxs)("h4",{className:"mb-5",children:["Delete ",(0,k.jsx)("span",{className:"text-danger",children:l})," File"]}),(0,k.jsx)(_e,{className:"btn btn-danger btn-block delete-button mt-2",onClick:a,children:"Delete"}),(0,k.jsx)("button",{type:"button",className:"btn btn-outline-danger btn-block mt-2",onClick:s,children:"Cancel"}),(0,k.jsxs)("div",{className:"mt-5",children:["Are you sure you want to delete ",(0,k.jsx)("span",{className:"text-danger",children:l})," from"," ",(0,k.jsx)("span",{className:"text-danger",children:c.join("/")}),"?"]})]})}function De(e){let{active:t,selectedFolder:n,onConfirm:a,onCancel:s}=e;if(!t)return null;if(!n)return null;const r=n.path.split("/"),o=2===r.length,l=o?null:r.slice(-1)[0];return(0,k.jsxs)("div",{className:"content-window",children:[(0,k.jsxs)("h4",{className:"mb-5",children:["Delete ",(0,k.jsx)("span",{className:"text-danger",children:o?null===n||void 0===n?void 0:n.project:l})," ",o?"Project":"Folder"]}),(0,k.jsx)(_e,{className:"btn btn-danger btn-block delete-button mt-2",onClick:a,children:"Delete"}),(0,k.jsx)("button",{type:"button",className:"btn btn-outline-danger btn-block mt-2",onClick:s,children:"Cancel"}),(0,k.jsx)("div",{className:"mt-5",children:o?(0,k.jsxs)("div",{children:["Are you sure you want to delete project ",(0,k.jsx)("span",{className:"text-danger",children:null===n||void 0===n?void 0:n.project})," ?"]}):(0,k.jsxs)("div",{children:["Are you sure you want to delete the folder ",(0,k.jsx)("span",{className:"text-danger",children:l})," from"," ",(0,k.jsx)("span",{className:"text-danger",children:null===n||void 0===n?void 0:n.project}),"?"]})})]})}function Ie(e){let{active:t,selectedPackage:n,onConfirm:a,onCancel:s}=e;if(!t)return null;const r=n.name;return(0,k.jsxs)("div",{className:"content-window",children:[(0,k.jsxs)("h4",{className:"mb-5",children:["Delete ",(0,k.jsx)("span",{className:"text-danger",children:r})," Package"]}),(0,k.jsx)(_e,{className:"btn btn-danger btn-block delete-button mt-2",onClick:a,children:"Delete"}),(0,k.jsx)("button",{type:"button",className:"btn btn-outline-danger btn-block mt-2",onClick:s,children:"Cancel"}),(0,k.jsxs)("div",{className:"mt-5",children:["Are you sure you want to delete ",(0,k.jsx)("span",{className:"text-danger",children:r}),"?"]})]})}const Te="DEFAULT_WINDOW",Re="DEFAULT_FOLDER_WINDOW",ze="CODE_EDITOR_WINDOW",Ue="NAME_FILE_WINDOW",$e="NAME_PROJECT_WINDOW",Le="NAME_PROJECT_FOLDER_WINDOW",We="INSTALL_PACKAGE_WINDOW",Me="DELETE_FILE_WINDOW",qe="DELETE_FOLDER_WINDOW",He="DELETE_PACKAGE_WINDOW";function Ge(e){let{children:t}=e;return(0,k.jsx)(i.A,{className:"editor-window",children:(0,k.jsx)(u.A,{children:t})})}var Be=n(5502);const Ve=function(e){var t,n,s,r;let{deployTargets:o,fileTree:i,onFileSave:u,onAddFile:d,onRevertFile:p,onAddProjectFolder:h,onAddProject:f,onFileChange:g,onDeleteFolder:x,onDeleteFile:j,onDeletePackage:v,onDeployProject:b,onFileSelect:y,onInstallPackage:A,restartInstance:N,restartingInstance:C}=e;const[w,_]=(0,a.useState)(null),[S,F]=(0,a.useState)(null),[O,P]=(0,a.useState)(null),[E,D]=(0,a.useState)(Te),[I,T]=(0,a.useState)(null),[R,z]=(0,a.useState)(!0),[U,$]=(0,a.useState)(!1),[L,W]=(0,a.useState)(!1),M=(null===i||void 0===i||null===(t=i.entries)||void 0===t?void 0:t.length)>0,q=Boolean(M&&w),H=Boolean(M&&(w||O)),G=Boolean(w);function B(e,t){D(e),T(t)}function V(){P(null),_(null),F(null)}function K(){B(Te,E)}return(0,k.jsxs)(l.A,{id:"webide",children:[(0,k.jsxs)(c.A,{md:"4",xl:"3",className:"file-browser-outer-container mb-3",children:[(0,k.jsx)("div",{className:"floating-card-header-row",children:(0,k.jsxs)(oe,{children:[(0,k.jsx)(te,{onClick:()=>B(Te,E),text:"app"}),(G||H)&&(0,k.jsx)("span",{className:"px-1",children:"|"}),G&&(0,k.jsx)(ne,{disabled:!G,onClick:()=>B(Le,E),text:!H&&"folder"}),H&&(0,k.jsx)(ae,{disabled:!H,onClick:()=>{O?B(He,E):w&&B(qe,E)},text:"folder"}),(q||(null===S||void 0===S?void 0:S.path))&&(0,k.jsx)("span",{className:"px-1",children:"|"}),q&&(0,k.jsx)(se,{onClick:()=>B(Ue,E),disabled:!q,text:!(null!==S&&void 0!==S&&S.path)&&"file"}),(null===S||void 0===S?void 0:S.path)&&(0,k.jsx)(re,{disabled:!(null!==S&&void 0!==S&&S.path),onClick:()=>B(Me,E),text:!q&&"file"})]})}),(0,k.jsx)(J,{files:i,root:i.path,selectedFile:null===S||void 0===S?void 0:S.path,selectedFolder:w,selectedPackage:O,onDeployProject:b,onFolderSelect:e=>{V(),_(e),B(e?Re:Te,E)},onPackageSelect:e=>{V(),P(e),B(e?Re:Te,E)},onFileSelect:async e=>{const t=!e;if(V(),t)F(null),B(Te,E);else{const t=await y(e),{content:n,cached:a}=t;F((0,m.A)((0,m.A)({},e),{},{content:n,cached:a})),B(ze,E)}}})]}),(0,k.jsxs)(c.A,{md:"8",xl:"9",className:"editor-window-container",children:[(0,k.jsxs)(l.A,{className:"floating-card-header-row g-0",children:[(0,k.jsx)(c.A,{className:"text-nowrap",children:S&&(0,k.jsxs)(k.Fragment,{children:[null===S||void 0===S||null===(n=S.path)||void 0===n||null===(s=n.split("/"))||void 0===s||null===(r=s.slice(1))||void 0===r?void 0:r.join(" > ")," ",(0,k.jsxs)("span",{className:"text-grey d-none d-xl-inline-block",children:["| ",(null===S||void 0===S?void 0:S.size)||"..."," bytes |"," ",null!==S&&void 0!==S&&S.mtime?new Date(S.mtime).toLocaleTimeString():"..."]})]})}),(0,k.jsx)(c.A,{className:"text-nowrap",children:(0,k.jsxs)(pe,{children:[(0,k.jsx)(ce,{savingFile:L,disabled:!(null!==S&&void 0!==S&&S.cached&&E===ze),onClick:async()=>{W(!0),await u(S,R),W(!1)},text:"save"}),(0,k.jsx)(de,{loading:U,disabled:!(null!==S&&void 0!==S&&S.cached&&E===ze),onClick:async()=>{$(!0);try{const e=await p(S),t=(0,m.A)((0,m.A)({},S),{},{content:e,cached:!1});F(t)}finally{$(!1)}},text:"revert"}),(0,k.jsx)("span",{className:"px-1",children:"|"}),(0,k.jsx)(ie,{restarting:C,onClick:N,text:"restart"}),(0,k.jsx)(ue,{restartAfterSave:R,onClick:()=>z(!R),text:"auto"})]})})]}),(0,k.jsxs)(Ge,{children:[(0,k.jsx)(me,{fileTree:i,active:E===Te,AddProjectButtonClick:()=>B($e,E),InstallPackageButtonClick:()=>{P(null),B(We,E)}}),(0,k.jsx)(he,{active:E===Re,type:O?"package":w?"folder":"nothing"}),(0,k.jsx)(Fe,{active:E===$e,onConfirm:e=>{!async function(e){await f(e),B(I,E)}(e),(0,Be.Ak)()},onCancel:K}),(0,k.jsx)(Oe,{projectName:null===w||void 0===w?void 0:w.project,active:E===Le,selectedFolder:w,onConfirm:async function(e){await h(e,w),B(I,E)},onCancel:K}),(0,k.jsx)(Pe,{active:E===Ue,onConfirm:async function(e){const t=await d(e,w);F(t),B(ze,E)},onCancel:K}),(0,k.jsx)(we,{active:E===We,onConfirm:async function(e,t,n){await A(e,t,n),P(null),B(Te,E)},onCancel:K,deployTargets:o,selectedPackage:O}),(0,k.jsx)(Ie,{active:E===He,selectedPackage:O,onConfirm:async()=>{await v(O),B(Te,E),V()},onCancel:K}),(0,k.jsx)(De,{active:E===qe,selectedFolder:w,onConfirm:async()=>{await x(w),B(Te,E),V()},onCancel:K}),(0,k.jsx)(Ee,{active:E===Me,selectedFile:S,onConfirm:async()=>{await j(S),B(Te,E),V()},onCancel:K}),(0,k.jsx)(ee,{active:E===ze,file:S,onFileChange:async e=>{S&&(!function(e){const t=(0,m.A)((0,m.A)({},S),{},{content:e});F(t)}(e),await g({path:null===S||void 0===S?void 0:S.path,content:e}),F((0,m.A)((0,m.A)({},S),{},{content:e,cached:!0})))}})]})]})]})},Ke=async e=>{let{auth:t,url:n,function_content:a,project:s,type:r,file:o}=e;return(0,j.A)({operation:{operation:"set_custom_function",function_content:a,project:s,type:r,file:o},auth:t,url:n})},Ze={routes:"'use strict';\n\n/* Dependencies\n- import any packages that are listed in your projects package.json\n- for example:\nimport needle from 'needle'\n*/\n\n/* Helpers\n- import any helper methods from your project's \"helpers\" directory\n- for example:\nimport filter from '../helpers/filter.js';\n*/\n\nmodule.exports = async (server, { hdbCore, logger }) => {\n // POST route\n // with hdbCore.preValidation to process basic auth\n // uses hdbCore.requese to execute the validated request\n server.route({\n url: '/path/to/my/route',\n method: 'POST',\n preValidation: hdbCore.preValidation,\n handler: hdbCore.request,\n })\n\n // GET route\n // with custom validation\n // uses hdbCore.requestWithoutAuthentication\n server.route({\n url: '/path/to/my/route/:id',\n method: 'GET',\n preValidation: async (request, reply) => {\n const token = request.headers.authorization\n const results = hdbCore.requestWithoutAuthentication({\n body: {\n operation: 'search_by_hash',\n schema: 'auth',\n table: 'tokens',\n hash_values: [token],\n get_attributes: ['id']\n }\n })\n if (!results.length) {\n const errorString = result.body.error || 'Sorry, there was an error authenticating your request';\n logger.error(errorString);\n throw new Error(errorString);\n }\n },\n handler: async (request) => {\n const id = parseInt(request.params.id)\n request.body= {\n operation: 'sql',\n sql: `SELECT * FROM dev.dogs WHERE id = ${id}`\n };\n\n /*\n * requestWithoutAuthentication bypasses the standard HarperDB authentication.\n * YOU MUST ADD YOUR OWN preValidation method above, or this method will be available to anyone.\n */\n const result = await hdbCore.requestWithoutAuthentication(request);\n\n return result\n }\n });\n};\n",helpers:"\n/* filters the results, only returning the selected keys */\nexport default (result, keys) => {\n return result.map(r => {\n const f = {}\n keys.forEach(k => f[k] = r[k])\n return f;\n })\n}\n"};var Ye=n(9561);const Je=function(e){let{items:t,toggleDropItem:n,toggleCreate:r,baseUrl:i,restarting:u,itemType:p,project:m}=e;const g=(0,d.Zp)(),x=(0,I.MW)(),v=(0,s.O$)(o.A,(e=>e.auth)),b=(0,s.O$)(o.A,(e=>e.url)),[y,A]=(0,a.useState)(!1),[C,w]=(0,a.useState)(!1),[_,S]=(0,a.useState)(!1),F=async e=>{e.preventDefault();let n,a=!1;if(y&&!t.includes(y)||(w(!0),a=!0),y&&!(0,Ye.A)(y)&&(w(!0),a=!0,x.error("".concat("projects"===p?"Project":"File"," names may only contain letters, numbers, hyphens, or underscores."))),a)return!1;if(S(!0),"projects"===p)n=await(async e=>{let{auth:t,url:n,project:a}=e;return(0,j.A)({operation:{operation:"add_custom_function_project",project:a},auth:t,url:n})})({auth:v,url:b,project:y});else{const e=(e=>Ze[e]||null)(p);n=await Ke({auth:v,url:b,project:m,type:p,file:y,function_content:e})}return n.error?(S(!1),r(!1),x.error(n.message)):setTimeout((async()=>(await(0,L.A)({auth:v,url:b,service:"custom_functions"}),await N({auth:v,url:b}),g("".concat(i,"/").concat(y)))),500)};return(0,a.useEffect)((()=>{n()}),[n]),(0,a.useEffect)((()=>{y&&t.find((e=>e===y))&&g("".concat(i,"/").concat(y))}),[t]),(0,k.jsxs)(l.A,{className:"item-row form",children:[(0,k.jsx)(c.A,{className:"input-holder",children:(0,k.jsx)(h.A,{id:"name",invalid:C,onChange:e=>{w(!1),A(e.target.value)},value:y||"",disabled:_,type:"text",name:"name",placeholder:"projects"===p?"ex: api, api-v1, dogs":"routes"===p?"ex: v1, post, public":"ex: filter, auth, queries"})}),(0,k.jsx)(c.A,{className:"item-action",children:_?(0,k.jsx)(f.A,{color:"success",className:"round me-1",children:(0,k.jsx)("i",{className:"fa fa-spinner fa-spin text-white"})}):(0,k.jsxs)(k.Fragment,{children:[(0,k.jsx)(f.A,{id:"createItem",color:"success",className:"round me-1",disabled:u,onClick:F,onKeyDown:e=>13!==e.keyCode||F(e),children:(0,k.jsx)("i",{className:"fa fa-check text-white"})}),(0,k.jsx)(f.A,{id:"toggleCreate",color:"black",className:"round",onClick:()=>r(!1),children:(0,k.jsx)("i",{className:"fa fa-times text-white"})})]})})]})},Qe=async e=>{let{auth:t,url:n,project:a}=e;return(0,j.A)({operation:{operation:"drop_custom_function_project",project:a},auth:t,url:n})};const Xe=function(e){let{item:t,baseUrl:n,isActive:r,toggleDropItem:i,isDropping:u,itemType:p,restarting:m}=e;const{project:h}=(0,d.g)(),g=(0,d.Zp)(),x=(0,I.MW)(),[v,b]=(0,a.useState)(!1),[y,A]=(0,a.useState)(!1),C=(0,s.O$)(o.A,(e=>e.auth)),w=(0,s.O$)(o.A,(e=>e.url)),_=async()=>{if(!v)return!1;let e;return e="projects"===p?await Qe({auth:C,url:w,project:t}):await(async e=>{let{auth:t,url:n,project:a,type:s,file:r}=e;return(0,j.A)({operation:{operation:"drop_custom_function",project:a,type:s,file:r},auth:t,url:n})})({auth:C,url:w,project:h,type:p,file:t}),e.error?(b(!1),A(!1),x.error(e.message)):(x.success(e.message),(0,L.A)({auth:C,url:w,service:"custom_functions"}),await N({auth:C,url:w}),g(n))};return(0,k.jsxs)(l.A,{title:"View".concat(r?"ing":""," ").concat(t),className:"item-row ".concat(r?"active":""),onClick:m?null:()=>!(r||u||v)&&g("".concat(n,"/").concat(t)),tabIndex:"0",children:[(0,k.jsx)(c.A,{className:"item-label ".concat(v?"text-danger text-nowrap":""),children:v?"drop ".concat(t,"?"):"projects"===p?"/".concat(t):t}),(0,k.jsx)(c.A,{className:"item-action",children:y?(0,k.jsx)(f.A,{tabIndex:"-1",disabled:!0,color:"purple",className:"round",children:(0,k.jsx)("i",{className:"fa fa-spinner fa-spin"})}):v?(0,k.jsxs)(k.Fragment,{children:[(0,k.jsx)(f.A,{id:"confirmDropItem",color:"danger",className:"round me-1",title:"confirm drop ".concat(t),onClick:()=>{b(!1),A(!0),_()},children:(0,k.jsx)("i",{className:"fa fa-check text-white"})}),(0,k.jsx)(f.A,{id:"cancelDropItem",color:"black",className:"round",title:"Cancel drop ".concat(t),onClick:()=>{b(!1)},children:(0,k.jsx)("i",{className:"fa fa-times text-white"})})]}):u?(0,k.jsx)(f.A,{id:"dropItem",color:"danger",className:"round",title:"Drop ".concat(t),onClick:()=>{b(t),i(!1)},children:(0,k.jsx)("i",{className:"fa fa-minus text-white"})}):r?(0,k.jsx)(f.A,{tabIndex:"-1",color:"purple",className:"round",children:(0,k.jsx)("i",{className:"fa fa-chevron-right"})}):null})]},t)};const et=function(e){let{items:t,toggleDropItem:n,isDropping:a,toggleCreate:s,project:r,isCreating:o,restarting:i,itemType:u,showForm:d}=e;return(0,k.jsxs)(l.A,{className:"floating-card-header",children:[(0,k.jsx)(c.A,{children:"projects"===u?"projects":"/".concat(r,"/").concat(u)}),d&&null!==t&&void 0!==t&&t.length?(0,k.jsxs)(c.A,{className:"text-end",children:[(0,k.jsx)(f.A,{disabled:i,id:"toggleRemove",color:"link",title:"Remove Functions",className:"add-remove me-3",onClick:()=>{n(!a),s(!1)},children:(0,k.jsx)("i",{className:"fa fa-minus"})}),(0,k.jsx)(f.A,{disabled:i,id:"toggleCreate",color:"link",title:"Add Function",className:"add-remove me-1",onClick:()=>{s(!o),n(!1)},children:(0,k.jsx)("i",{className:"fa fa-plus"})})]}):null]})};const tt=function(e){let{items:t,activeItem:n,baseUrl:s,restarting:r,itemType:o,project:l,showForm:c}=e;const[d,p]=(0,a.useState)(!1),[m,h]=(0,a.useState)(!1);return(0,a.useEffect)((()=>{h(),p()}),[n,t.length]),(0,k.jsxs)("div",{className:"entity-manager",children:[(0,k.jsx)(et,{items:t,itemType:o,isDropping:d,toggleDropItem:p,isCreating:m,toggleCreate:h,restarting:r,project:l,showForm:c}),(0,k.jsxs)(i.A,{className:"my-3",children:[t&&t.length?(0,k.jsx)(u.A,{className:"scrollable ".concat(m?"creating":""),children:t.map((e=>(0,k.jsx)(Xe,{item:e,baseUrl:s,isActive:n===e,isDropping:d,toggleDropItem:p,itemType:o,restarting:r},e)))}):null,c&&t&&!t.length||m?(0,k.jsx)(u.A,{children:(0,k.jsx)(Je,{items:t,itemType:o,baseUrl:s,isDropping:d,toggleDropItem:p,isCreating:m,toggleCreate:h,restarting:r,project:l})}):!t||t.length||m?null:(0,k.jsx)(u.A,{children:(0,k.jsx)("div",{className:"py-3 text-center no-content",children:"no functions found"})})]})]})};const nt=function(){const e=(0,d.Zp)(),t=(0,I.MW)(),{customer_id:n,compute_stack_id:r,project:p,type:m,file:h}=(0,d.g)(),g=(0,s.O$)(o.A,(e=>e.auth)),x=(0,s.O$)(o.A,(e=>e.url)),[v,b]=(0,a.useState)(""),[y,A]=(0,a.useState)(""),N=(0,a.useCallback)((async()=>{if(p&&m&&h&&"undefined"!==h){const e=await(async e=>{let{auth:t,url:n,project:a,type:s,file:r}=e;return(0,j.A)({operation:{operation:"get_custom_function",project:a,type:s,file:r},auth:t,url:n})})({auth:g,url:x,project:p,type:m,file:h});b(null===e||void 0===e?void 0:e.message),A(null===e||void 0===e?void 0:e.message)}else b("")}),[g,x,p,m,h,b]);return(0,a.useEffect)((()=>{N()}),[p,h,N,r]),(0,k.jsxs)(k.Fragment,{children:[(0,k.jsxs)(l.A,{className:"floating-card-header",children:[(0,k.jsxs)(c.A,{children:["edit >\xa0",(0,k.jsxs)("i",{children:["/",p,h&&"undefined"!==h&&"/".concat(m,"/").concat(h,".js")]})]}),(0,k.jsxs)(c.A,{className:"text-end",children:[(0,k.jsxs)(f.A,{onClick:N,color:"link",className:"me-2",children:[(0,k.jsx)("span",{className:"me-2",children:"reload"}),(0,k.jsx)("i",{title:"Reload File",className:"fa fa-sync-alt"})]}),(0,k.jsx)("span",{className:"mx-3 text",children:"|"}),(0,k.jsxs)(f.A,{onClick:()=>e("/o/".concat(n,"/i/").concat(r,"/functions/deploy/").concat(p)),color:"link",className:"me-2",children:[(0,k.jsx)("span",{className:"me-2",children:"deploy"}),(0,k.jsx)("i",{title:"Deploy Project",className:"fa fa-share"})]})]})]}),(0,k.jsx)(i.A,{className:"my-3",children:v?(0,k.jsxs)(u.A,{children:[(0,k.jsx)("div",{className:"code-editor-holder",children:(0,k.jsx)(Q.Ay,{height:"100%",defaultLanguage:"javascript",value:v,theme:"vs-dark",onChange:b})}),(0,k.jsxs)(l.A,{children:[(0,k.jsx)(c.A,{md:"6",className:"mt-2",children:(0,k.jsx)(f.A,{block:!0,color:"grey",title:"Revert Code to Last Saved State",disabled:v===y,onClick:N,id:"reset",children:(0,k.jsx)("i",{className:"fa fa-undo"})})}),(0,k.jsx)(c.A,{md:"6",className:"mt-2",children:(0,k.jsx)(f.A,{block:!0,title:"Save Code to Instance",color:"success",id:"addEditItem",onClick:async()=>{const e=await Ke({auth:g,url:x,function_content:v,project:p,type:m,file:h});e.error?t.error(e.message):(setTimeout((()=>(0,L.A)({auth:g,url:x,service:"custom_functions"})),500),t.success(e.message)),N()},children:(0,k.jsx)("i",{className:"fa fa-save"})})})]})]}):(0,k.jsx)(u.A,{children:(0,k.jsxs)("div",{className:"empty-prompt narrow",children:[(0,k.jsx)("div",{className:"mt-3 text-bold",children:"This project does not yet have any routes or helpers"}),(0,k.jsx)("div",{className:"mt-3",children:"Add some using the form fields at left."})]})})})]})};var at=n(4343);const st=e=>{let{initializing:t,loading:n,handleClick:a}=e;return[{Header:"instance name",accessor:"instance_name"},{Header:"instance url",accessor:"url"},{Header:"cf capable",id:"hdb-narrow-cfcapable",Cell:e=>{let{row:{original:{custom_functions_status:t}}}=e;return t.error?"no":"yes"}},{Header:"cf enabled",id:"hdb-narrow-cfenabled",Cell:e=>{let{row:{original:{custom_functions_status:t}}}=e;return t.is_enabled?"yes":"no"}},{Header:"has project",id:"hdb-narrow-cfhasproject",Cell:e=>{let{row:{original:{has_current_project:t}}}=e;return t?"yes":"no"}},{Header:"deploy",id:"hdb-narrow-deploy",Cell:e=>{let{row:{original:{compute_stack_id:s,custom_functions_status:r,has_auth:o}}}=e;return r.is_enabled&&o?(0,k.jsx)(f.A,{color:"success",block:!0,size:"sm",disabled:t||n[s],onClick:()=>a(s,"deploy"),children:(0,k.jsx)("i",{className:"fa ".concat("deploy"===n[s]?"fa-spinner fa-spin":"fa-share")})}):null}},{Header:"remove",id:"hdb-narrow-remove",Cell:e=>{let{row:{original:{compute_stack_id:t,custom_functions_status:s,has_current_project:r,has_auth:o}}}=e;return s.is_enabled&&r&&o?(0,k.jsx)(f.A,{color:"danger",block:!0,size:"sm",disabled:n[t],onClick:()=>a(t,"drop"),children:(0,k.jsx)("i",{className:"fa ".concat("drop"===n[t]?"fa-spinner fa-spin":"fa-trash")})}):null}}]},rt={filtered:[],sorted:[],page:0,totalPages:1,pageSize:20,autoRefresh:!1,showFilter:!1,lastUpdate:!1};const ot=function(){const{customer_id:e,compute_stack_id:t,project:n}=(0,d.g)(),r=(0,d.Zp)(),[p]=(0,W.A)({}),h=(0,s.O$)(o.A,(e=>e.auth)),g=(0,s.O$)(o.A,(e=>e.url)),y=(0,s.O$)(o.A,(e=>{var t;return null===(t=e.registration)||void 0===t?void 0:t.version})),[{payload:A,file:N},C]=(0,a.useState)([]),w="/o/".concat(e,"/i/").concat(t,"/functions/edit/").concat(n),_=(0,s.O$)(T.A,(e=>e.instances.filter((e=>e.compute_stack_id!==t)))),[S,F]=y.split("."),O=S>=3&&(S>3||F>=3),[P,E]=(0,a.useState)([]),[D,I]=(0,a.useState)(O),[R,z]=(0,a.useReducer)(((e,t)=>(0,m.A)((0,m.A)({},e),t)),{}),[U,$]=(0,a.useState)(rt),M=(0,a.useCallback)((()=>r(w)),[r,w]),q=(0,a.useCallback)((async(e,t)=>{const a=P.find((t=>t.compute_stack_id===e)),s=p[e];if(a&&s){z({[e]:t});let r=!1;const o=await v({auth:s,url:a.url});if(!o.error){const e=await b({auth:s,url:a.url});r=Object.keys(e).includes(n)}const l=P.map((t=>(t.compute_stack_id===e&&(t.custom_functions_status=o,t.has_current_project=r),t)));E(l),z({[e]:null})}}),[p,n,P]),H=(0,a.useCallback)((async(e,t)=>{const a=P.find((t=>t.compute_stack_id===e)),s=p[e];a&&s&&(z({[e]:t}),"deploy"===t?(await(async e=>{let{auth:t,url:n,project:a,payload:s,file:r}=e;return(0,j.A)({operation:{operation:"deploy_custom_function_project",project:a,payload:s,file:r},auth:t,url:n})})({auth:s,url:a.url,payload:A,project:n,file:N}),D&&await(async e=>{let{auth:t,url:n,projects:a,dry_run:s=!1}=e;return(0,j.A)({operation:{operation:"install_node_modules",projects:a,dry_run:s},auth:t,url:n})})({auth:s,url:a.url,projects:[n]}),await(0,L.A)({auth:s,url:a.url,service:"custom_functions"})):await Qe({auth:s,url:a.url,project:n}),setTimeout((()=>{z({[e]:!1}),q(e,t)}),1e3))}),[N,p,A,n,P,q,D]);return x()((async()=>{if(h&&g&&n){C(!1);const e=await(async e=>{let{auth:t,url:n,project:a,skip_node_modules:s}=e;return(0,j.A)({operation:{operation:"package_custom_function_project",project:a,skip_node_modules:s},auth:t,url:n})})({auth:h,url:g,project:n,skip_node_modules:D});C(e)}}),[h,g,n,D]),x()((async()=>{if(_){const e=await Promise.all(_.map((async e=>{const t=p[e.compute_stack_id];let a={};if(t){const s=await v({auth:t,url:e.url});return s.error||(a=await b({auth:t,url:e.url})),(0,m.A)((0,m.A)({},e),{},{custom_functions_status:s,has_auth:!0,has_current_project:Object.keys(a).includes(n)})}return(0,m.A)((0,m.A)({},e),{},{custom_functions_status:!1})})));E(e)}}),[_,n]),(0,a.useEffect)((()=>{$((0,m.A)((0,m.A)({},U),{},{totalPages:Math.ceil((P.length||U.pageSize)/U.pageSize)}))}),[$,U.pageSize]),(0,k.jsxs)(k.Fragment,{children:[(0,k.jsxs)(l.A,{className:"floating-card-header",children:[(0,k.jsxs)(c.A,{children:["deploy ",n&&"> ".concat(n)]}),(0,k.jsxs)(c.A,{className:"text-end",children:[O&&(0,k.jsxs)(k.Fragment,{children:[(0,k.jsxs)(f.A,{color:"link",title:"Turn on autofresh",onClick:()=>I(!D),children:[(0,k.jsx)("span",{className:"me-2",children:"install dependencies at destination"}),(0,k.jsx)("i",{className:"fa fa-lg fa-toggle-".concat(D?"on":"off")})]}),(0,k.jsx)("span",{className:"mx-3 text",children:"|"})]}),(0,k.jsxs)(f.A,{onClick:M,color:"link",className:"me-2",children:[(0,k.jsx)("span",{className:"me-2",children:"back to edit"}),(0,k.jsx)("i",{title:"Edit Project",className:"fa fa-edit"})]})]})]}),(0,k.jsx)(i.A,{className:"my-3",children:(0,k.jsx)(u.A,{className:"react-table-holder",children:P.length?(0,k.jsx)(at.A,{columns:st({initializing:!A,loading:R,handleClick:H}),data:P,page:U.page,pageSize:U.pageSize,totalPages:U.totalPages,showFilter:U.showFilter,sorted:U.sorted,onFilteredChange:e=>$((0,m.A)((0,m.A)({},U),{},{filtered:e})),onSortedChange:e=>$((0,m.A)((0,m.A)({},U),{},{sorted:e})),onPageChange:e=>$((0,m.A)((0,m.A)({},U),{},{pageSize:e})),onPageSizeChange:e=>$((0,m.A)((0,m.A)({},U),{},{page:0,pageSize:e}))}):(0,k.jsx)("div",{className:"empty-prompt",children:"Please register at least one Custom Function-enabled instance to deploy to"})})})]})};const lt=function(e){let{loading:t,refreshCustomFunctions:n,restarting:a}=e;const r=(0,s.O$)(o.A,(e=>e.auth)),l=(0,s.O$)(o.A,(e=>e.url));return(0,k.jsxs)("span",{className:"structure-reloader d-block text-center mb-4",children:[(0,k.jsxs)(f.A,{disabled:t,color:"link",onClick:n,children:[(0,k.jsx)("span",{className:"me-2",children:"refresh projects"}),(0,k.jsx)("i",{title:"Refresh Endpoint Files",className:"fa ".concat(t?"fa-spinner fa-spin":"fa-sync-alt")})]}),(0,k.jsx)("span",{className:"mx-3 text",children:"|"}),(0,k.jsxs)(f.A,{disabled:a,color:"link",onClick:()=>(0,L.A)({auth:r,url:l,service:"custom_functions"}),className:"me-2",children:[(0,k.jsx)("span",{className:"me-2",children:"restart server"}),(0,k.jsx)("i",{title:"Refresh Endpoint Files",className:"fa ".concat(a?"fa-spinner fa-spin":"fa-stop-circle")})]}),(0,k.jsx)("hr",{className:"d-block d-md-none mt-4"})]})};const ct=function(e){let{url:t,project:n,fileCount:a}=e;return(0,k.jsxs)("div",{className:"entity-manager",children:[(0,k.jsxs)("div",{className:"floating-card-header",children:["/",n,"/static"]}),(0,k.jsx)(i.A,{className:"my-3",children:(0,k.jsx)(u.A,{children:(0,k.jsxs)(l.A,{className:"item-row",children:[(0,k.jsx)(c.A,{className:"item-label",children:a?"enabled":'"static" subfolder not found'}),(0,k.jsxs)(c.A,{className:"item-action",children:[(0,k.jsx)(f.A,{tabIndex:"-1",color:a?"success":"danger",disabled:!a,className:"round me-1",children:a}),(0,k.jsx)(f.A,{tabIndex:"-1",color:"purple",className:"round",disabled:!a,href:"".concat(t,"/").concat(n,"/static"),target:"_blank",rel:"noopener noreferrer",children:(0,k.jsx)("i",{title:"View UI",className:"fa fa-share"})})]})]})})})]})};var it=n(7666);const ut=function(e){var t,n,i;let{refreshCustomFunctions:u,loading:m}=e;const{customer_id:h,compute_stack_id:f,action:g="edit",project:x,file:j}=(0,d.g)(),v=(0,d.Zp)(),b=(0,s.O$)(o.A,(e=>e.custom_functions)),y=(0,s.O$)(o.A,(e=>e.registration)),[A,N]=((null===y||void 0===y?void 0:y.version)||"").split("."),C=parseFloat("".concat(A,".").concat(N))<4.1,w=(0,s.O$)(o.A,(e=>"custom_functions"===e.restarting_service)),_=(0,s.O$)(o.A,(e=>{var t;return e.custom_functions_url||"".concat(e.url.split(":").slice(0,-1).join(":"),":").concat(null===(t=e.custom_functions)||void 0===t?void 0:t.port)})),S="/o/".concat(h,"/i/").concat(f,"/functions/").concat(g);return(0,a.useEffect)((()=>{const e=(null===b||void 0===b?void 0:b.endpoints)&&Object.keys(null===b||void 0===b?void 0:b.endpoints).length,t=(null===b||void 0===b?void 0:b.endpoints)&&Object.keys(null===b||void 0===b?void 0:b.endpoints).includes(x);if(e&&x&&!t){const e=x&&Object.keys(null===b||void 0===b?void 0:b.endpoints)[0];v("".concat(S,"/").concat(e))}else if(e&&x&&!j){var n,a;const e=x&&(null===b||void 0===b||null===(n=b.endpoints[x])||void 0===n?void 0:n.routes[0]),t=x&&(null===b||void 0===b||null===(a=b.endpoints[x])||void 0===a?void 0:a.helpers[0]),s=e?"routes":"helpers";v("".concat(S,"/").concat(x,"/").concat(s,"/").concat(e||t))}else if(e&&!x){const e=Object.keys(null===b||void 0===b?void 0:b.endpoints)[0];v("".concat(S,"/").concat(e))}else e||v(S)}),[null===b||void 0===b?void 0:b.endpoints,h,f,v,g,x,j,S]),(0,r.A)((async()=>{if(_&&w)try{await fetch(_),o.A.update((e=>{e.restarting_service=!1}))}catch(e){console.log(e)}}),1e3),(0,k.jsxs)(l.A,{id:"functions",children:[(0,k.jsx)(c.A,{xl:"3",lg:"4",md:"6",xs:"12",children:(0,k.jsxs)(p.tH,{onError:(e,t)=>(0,E.A)({error:{message:e.message,componentStack:t}}),FallbackComponent:P.A,children:[(0,k.jsx)(tt,{itemType:"projects",items:Object.keys(null===b||void 0===b?void 0:b.endpoints)||[],activeItem:x,baseUrl:S,restarting:w,showForm:"edit"===g}),x&&"edit"===g&&(0,k.jsxs)(k.Fragment,{children:[(0,k.jsx)(tt,{itemType:"routes",items:x&&(null===b||void 0===b||null===(t=b.endpoints[x])||void 0===t?void 0:t.routes)||[],project:x,activeItem:j,baseUrl:"".concat(S,"/").concat(x,"/routes"),restarting:w,showForm:"edit"===g}),(0,k.jsx)(tt,{itemType:"helpers",items:x&&(null===b||void 0===b||null===(n=b.endpoints[x])||void 0===n?void 0:n.helpers)||[],project:x,activeItem:j,baseUrl:"".concat(S,"/").concat(x,"/helpers"),restarting:w,showForm:"edit"===g}),C&&(0,k.jsx)(ct,{url:_,project:x,fileCount:x&&(null===b||void 0===b||null===(i=b.endpoints[x])||void 0===i?void 0:i.static)||0})]}),(0,k.jsx)("hr",{className:"mt-0"}),(0,k.jsxs)("div",{className:"entity-manager-footer",children:[(0,k.jsx)("div",{className:"text-bold mb-1",children:"Root File Directory"}),(0,k.jsx)(it.A,{text:b.directory}),(0,k.jsx)("div",{className:"text-bold mb-1 mt-3",children:"Custom Functions Server URL"}),(0,k.jsx)(it.A,{text:_})]}),(0,k.jsx)("hr",{}),(0,k.jsx)(lt,{refreshCustomFunctions:u,loading:m,restarting:w})]})}),(0,k.jsx)(c.A,{xl:"9",lg:"8",md:"6",xs:"12",children:"deploy"===g?(0,k.jsx)(ot,{}):x?(0,k.jsx)(nt,{}):(0,k.jsx)(O.A,{refreshCustomFunctions:u,headline:"Please ".concat(null!==b&&void 0!==b&&b.endpoints.length?"choose":"create"," a project at left.")})})]})};function dt(e){return e.split("/").slice(2).join("/")}function pt(e,t,n,a){return e.reduce(((e,s)=>{const r=s.compute_stack_id,o=t[r];if(null===o||void 0===o||!o.version)return e;const[l,c]=(null===o||void 0===o?void 0:o.version.split("."))||[];return parseInt(l,10)>=4&&parseInt(c,10)>=2&&e.push({isCurrentInstance:r===n,auth:a,instance:s}),e}),[])}const mt=function(e){let{refreshCustomFunctions:t,loading:n}=e;const{compute_stack_id:r}=(0,d.g)(),l=(0,s.O$)(o.A,(e=>e.registration)),{fileTree:c}=(0,s.O$)(o.A,(e=>e.custom_functions)),i=(0,s.O$)(o.A,(e=>e.auth)),u=(0,s.O$)(o.A,(e=>e.url)),[p,h]=((null===l||void 0===l?void 0:l.version)||"").split(".")||[],f=parseFloat("".concat(p,".").concat(h))>=4.2,g=(0,s.O$)(T.A,(e=>e.instances)),[x]=(0,W.A)({}),[v,b]=M({}),[y,A]=(0,a.useState)(!1),N=(0,I.MW)();function C(e){let{path:t}=e;const n=(0,m.A)({},v),a="".concat(r,"_").concat(t);a in n&&delete n[a],b((0,m.A)({},n))}async function w(e){let{auth:t,url:n}=e;A(!0),setTimeout((async()=>{await(0,L.A)({auth:t,url:n,service:"http_workers"}),A(!1)}),100)}return f?(0,k.jsx)(Ve,{fileTree:c,deployTargets:pt(g,x,r,i),onRevertFile:async function(e){C({path:e.path});const{error:n,message:a}=await R({auth:i,url:u,project:e.project,file:dt(e.path)});return n?N.error(a):(await t(),a)},onFileChange:async function(e){const{path:t,content:n}=e,a="".concat(r,"_").concat(t);b((0,m.A)((0,m.A)({},v),{},{[a]:n}))},onFileSave:async function(e,n){const a=e.path.split("/").slice(2).join("/"),s={auth:i,url:u,project:e.project,file:a,payload:e.content},{error:r,message:o}=await z(s);r&&N.error(o),n&&await w({auth:i,url:u}),C({path:e.path}),e.cached=!1,await t()},onUpdate:t,onAddFile:async function(e,n){const{path:a,project:s}=n,r=dt(a),o=r?"".concat(r,"/").concat(e):e;return await z({auth:i,url:u,project:s,file:o,payload:""}),await t(),{content:"",path:[n.path,e].join("/"),project:s}},onAddProject:async function(e){const{error:n,message:a}=await(async e=>{let{auth:t,url:n,project:a}=e;return(0,j.A)({operation:{operation:"add_component",project:a},auth:t,url:n})})({auth:i,url:u,project:e});n&&N.error(a),await(0,L.A)({auth:i,url:u,service:"http_workers"}),await t()},onAddProjectFolder:async function(e,n){const{path:a,project:s}=n,r=dt(a),o=r?"".concat(r,"/").concat(e):e,{error:l,message:c}=await z({auth:i,url:u,project:s,file:o});l&&N.error(c),await t()},onInstallPackage:async function(e,n,a){const s=a.map((async t=>{const{error:a,message:s}=await $({auth:t.auth,url:t.instance.url,project:e,packageUrl:n});a&&N.error(s),await(0,L.A)({auth:t.auth,url:t.instance.url,service:"http_workers"})}));await Promise.all(s),await t()},onDeployProject:async function(e){let{project:n,deployTarget:a}=e;const{auth:s,instance:r}=a,{payload:o}=await(async e=>{let{auth:t,url:n,project:a,skip_node_modules:s=!0}=e;return(0,j.A)({auth:t,url:n,operation:{operation:"package_component",project:a,skip_node_modules:s}})})({auth:i,url:u,project:n.name});await $({auth:s,url:r.url,project:n.name,payload:o}),await(0,L.A)({auth:s,url:r.url,service:"http_workers"}),await(0,L.A)({auth:i,url:u,service:"http_workers"}),await t()},onDeleteFile:async function(e){const{error:n,message:a}=await U({auth:i,url:u,project:e.project,file:dt(e.path)});n&&N.error(a),await t()},onDeleteFolder:async function(e){let{path:n,project:a}=e;const s=dt(n);if(s.length>0){const{error:e,message:t}=await U({auth:i,url:u,project:a,file:s});e&&N.error(t)}else{const{error:e,message:t}=await U({auth:i,url:u,project:a});e&&N.error(t)}await t()},onDeletePackage:async function(e){let{name:n}=e;const{error:a,message:s}=await U({auth:i,url:u,project:n});a?N.error(s):(await(0,L.A)({auth:i,url:u,service:"http_workers"}),await t())},onFileSelect:async function(e){const{path:t,project:n,name:a}=e,s=dt(t),o="".concat(r,"_").concat(t),l=v[o],c=o in v;if(c)return{cached:c,content:l,path:t,project:n,name:a};const{error:d,message:p}=await R({auth:i,url:u,project:n,file:s});return d?(N.error(p),{content:"",path:t,project:n,name:a,cached:!1}):{cached:c,content:p,path:t,project:n,name:a}},onFileRename:async function(e,n){const{path:a,content:s,project:r}=n,o=dt(a).split("/").slice(0,-1).join("/"),l=o?"".concat(o,"/").concat(e):e;await U({auth:i,url:u,project:r,file:dt(a)}),await z({auth:i,url:u,project:r,file:l,payload:s}),t()},refreshingCustomFunctions:n,restartInstance:async()=>w({auth:i,url:u}),restartingInstance:y}):(0,k.jsx)(ut,{refreshCustomFunctions:t,loading:n})};const ht=function(){return(0,k.jsxs)(k.Fragment,{children:[(0,k.jsx)("div",{className:"floating-card-header text-end",children:"\xa0"}),(0,k.jsx)(i.A,{className:"my-3",children:(0,k.jsx)(u.A,{children:(0,k.jsxs)("div",{className:"empty-prompt narrow",children:[(0,k.jsx)("i",{className:"fa fa-bullhorn fa-3x text-success"}),(0,k.jsx)("div",{className:"mt-3 text-bold",children:"Coming Soon: Custom Functions!"}),(0,k.jsx)("div",{className:"mt-3",children:(0,k.jsxs)("ul",{children:[(0,k.jsx)("li",{children:"Add your own API endpoints to a standalone API server inside Harper"}),(0,k.jsx)("li",{children:"Use Harper Core methods to interact with your data at lightning speed"}),(0,k.jsx)("li",{children:"Custom Functions are powered by Fastify, so they're extremely flexible"}),(0,k.jsx)("li",{children:"Manage in Harper Studio, or use your own IDE and Version Management System"}),(0,k.jsx)("li",{children:"Distribute your Custom Functions to all your Harper instances with a single click"})]})})]})})})]})};var ft=n(4979),gt=n(2914);const xt=function(){const e=(0,s.O$)(o.A,(e=>e.auth)),t=(0,s.O$)(o.A,(e=>e.url)),n=(0,s.O$)(o.A,(e=>e.custom_functions)),l=(0,s.O$)(o.A,(e=>e.registration)),c=(0,gt.A)({version:null===l||void 0===l?void 0:l.version}),i=(0,s.O$)(o.A,(e=>e.restarting)),[u,d]=(0,a.useState)(!1),[p,m]=(0,a.useState)(!0),[h,f]=(0,a.useState)(!1),g=(0,a.useCallback)((async()=>{e&&t&&!i&&(m(!0),await N({auth:e,url:t}),m(!1))}),[e,t,i]);return(0,a.useEffect)((()=>{g()}),[g]),(0,a.useEffect)((()=>{const e=(null===n||void 0===n?void 0:n.is_enabled)&&(null===n||void 0===n?void 0:n.port)||c;d(e),e&&f(!1)}),[n,c]),(0,r.A)((()=>{h&&g()}),2e3),n?n.error?(0,k.jsx)(ht,{}):h?(0,k.jsx)(O.A,{description:"Configuring Custom Functions",icon:(0,k.jsx)("i",{className:"fa fa-spinner fa-spin"})}):u?(0,k.jsx)(mt,{refreshCustomFunctions:g,loading:p}):(0,k.jsx)(D,{setConfiguring:f}):(0,k.jsx)(ft.A,{header:"loading custom functions",spinner:!0})}},7666:(e,t,n)=>{n.d(t,{A:()=>i});var a=n(9950),s=n(7176),r=n(6114),o=n(3452),l=n(7348),c=n(4414);const i=function(e){let{text:t,beforeText:n,afterText:i,obscure:u=!1}=e;const d=(0,l.MW)(),p=navigator.clipboard,m=(0,a.useCallback)((async e=>{e.stopPropagation(),await navigator.clipboard.writeText(t),d.success("Text copied to clipboard")}),[d,t]);return(0,c.jsxs)(s.A,{className:"copyable-text-holder g-0",children:[p&&t&&(0,c.jsx)(r.A,{className:"copy-icon",children:(0,c.jsx)(o.A,{title:"Copy this value",onClick:m,color:"link",children:(0,c.jsx)("i",{className:"fa fa-copy text-small"})})}),(0,c.jsx)(r.A,{className:"text-container",children:t?(0,c.jsxs)(c.Fragment,{children:[n,u?t.replace(/./g,"*"):t,i]}):(0,c.jsx)("span",{children:"\xa0"})})]})}},4343:(e,t,n)=>{n.d(t,{A:()=>N});var a=n(9950),s=n(2043),r=n(5488),o=n(9435),l=n(9379),c=n(45),i=n(7176),u=n(6114),d=n(4414);const p=["key"],m=e=>{let{headerGroups:t,onSortedChange:n,sorted:a,showFilter:s,dynamicAttributesFromDataTable:r,tableDescriptionAttributes:o}=e;const m=e=>{let t=!1;return o.forEach((n=>{n.attribute===e&&(n.is_primary_key||n.indexed)&&(t=!0)})),t};return t.map((e=>{const t=e.getHeaderGroupProps(),{key:o}=t,h=(0,c.A)(t,p);return(0,d.jsxs)("div",(0,l.A)((0,l.A)({},h),{},{children:[(0,d.jsx)(i.A,{className:"header g-0",children:e.headers.map((e=>{var t,s;return(0,d.jsx)(u.A,{onClick:()=>{var t,s;r&&!r.includes(e.id)&&m(e.id)&&n([{id:e.id,desc:(null===(t=a[0])||void 0===t?void 0:t.id)===e.id&&!(null!==(s=a[0])&&void 0!==s&&s.desc)}])},className:"".concat((null===(t=a[0])||void 0===t?void 0:t.id)===e.id?"sorted":""," ").concat(null!==(s=a[0])&&void 0!==s&&s.desc?"desc":"asc"," ").concat(-1!==e.id.indexOf("hdb-narrow")?"action":""," px-1 ").concat(r&&!r.includes(e.id)&&m(e.id)?"":"disabled-column"),children:(0,d.jsx)("div",{className:"text-renderer",children:e.render("Header")})},e.id)}))}),s&&(0,d.jsx)(i.A,{className:"filter g-0",children:e.headers.map((e=>(0,d.jsx)(u.A,{className:-1!==e.id.indexOf("hdb-narrow")?"action":"",children:e.render("Filter")},e.id)))})]}),o)}))};var h=n(3452);const f=function(e){let{page:t,pageSize:n,totalPages:a,onPageChange:s,onPageSizeChange:o,loading:l}=e;return(0,d.jsxs)(i.A,{className:"pagination",children:[(0,d.jsx)(u.A,{xs:"12",sm:"2",className:"previous",children:(0,d.jsx)(h.A,{className:"mb-2 btn-pagination",color:"purple",block:!0,onClick:()=>s(t-1),disabled:!a||0===t,children:(0,d.jsx)("i",{className:"fa fa-chevron-left"})})}),(0,d.jsxs)(u.A,{xs:"12",sm:"4",className:"paginator",children:[(0,d.jsx)("i",{className:"fa fa-book me-2"}),(0,d.jsx)(r.A,{className:"mb-2",type:"number",value:t+1,min:1,max:a,onChange:e=>s(e.target.value-1)}),(0,d.jsxs)("div",{className:"page-count",children:["\xa0/\xa0",l?(0,d.jsx)("i",{className:"fa fa-spinner fa-spin"}):a]})]}),(0,d.jsx)(u.A,{xs:"12",sm:"4",className:"page-size",children:(0,d.jsx)(r.A,{className:"mb-2",type:"select",value:n,onChange:e=>o(e.target.value),children:[20,50,100,250].map((e=>(0,d.jsxs)("option",{value:e,children:[e," rows"]},e)))})}),(0,d.jsx)(u.A,{xs:"12",sm:"2",className:"next",children:(0,d.jsx)(h.A,{className:"mb-2 pull-right btn-pagination",block:!0,color:"purple",onClick:()=>s(t+1),disabled:!a||t+1===a,children:(0,d.jsx)("i",{className:"fa fa-chevron-right"})})})]})};const g=function(e){let{previousPage:t,canPreviousPage:n,pageIndex:a,gotoPage:s,setPageSize:o,pageCount:l,nextPage:c,canNextPage:p,loading:m}=e;return(0,d.jsxs)(i.A,{className:"pagination",children:[(0,d.jsx)(u.A,{xs:"12",sm:"2",className:"previous",children:(0,d.jsx)(h.A,{className:"mb-2 btn-pagination",color:"purple",block:!0,onClick:t,disabled:!l||!n,children:(0,d.jsx)("i",{className:"fa fa-chevron-left"})})}),(0,d.jsxs)(u.A,{xs:"12",sm:"4",className:"paginator",children:[(0,d.jsx)("i",{className:"fa fa-book me-2"}),(0,d.jsx)(r.A,{className:"mb-2",type:"number",value:a+1||1,min:1,max:l,onChange:e=>s(e.target.value?Number(e.target.value)-1:0)}),(0,d.jsxs)("div",{className:"page-count",children:["\xa0/\xa0",m?(0,d.jsx)("i",{className:"fa fa-spinner fa-spin"}):l]})]}),(0,d.jsx)(u.A,{xs:"12",sm:"4",className:"page-size",children:(0,d.jsx)(r.A,{className:"mb-2",type:"select",onChange:e=>{s(0),setTimeout((()=>o(e.target.value)),1e3)},children:[20,50,100,250].map((e=>(0,d.jsxs)("option",{value:e,children:[e," rows"]},e)))})}),(0,d.jsx)(u.A,{xs:"12",sm:"2",className:"next",children:(0,d.jsx)(h.A,{className:"mb-2 pull-right btn-pagination",block:!0,color:"purple",onClick:c,disabled:!l||!p,children:(0,d.jsx)("i",{className:"fa fa-chevron-right"})})})]})};const x=function(e){let{prepareRow:t,row:n,onRowClick:a=!1}=e;return t(n),(0,d.jsx)(i.A,{onClick:()=>a&&a(n.original),className:"g-0",children:n.cells.map((e=>(0,d.jsx)(u.A,{className:-1!==e.column.id.indexOf("hdb-narrow")?"action":"",children:e.render("Cell")},"".concat(e.row.id,"-").concat(e.column.id))))})};var j=n(3628),v=n(3150);function b(e){let{value:t}=e;return(0,d.jsx)("div",{className:"text-renderer",children:t})}function y(e){let{src:t}=e;const[n,s]=(0,a.useState)(!1),[r,o]=(0,a.useState)(!1);return(0,d.jsxs)("div",{className:"image-renderer",onMouseEnter:()=>s(!0),onMouseLeave:()=>s(!1),children:[(0,d.jsx)("i",{className:"fa fa-image"}),n&&r?(0,d.jsxs)("div",{className:"preview-image no-image",children:[(0,d.jsx)("i",{className:"fa fa-ban text-danger"}),(0,d.jsx)("div",{className:"mt-2",children:"image failed to load"})]}):n?(0,d.jsx)("img",{onError:o,alt:t,src:t,className:"preview-image"}):null]})}const A={Filter:e=>{let{column:{filterValue:t,setFilter:n}}=e;return(0,d.jsx)(r.A,{type:"text",value:t||"",onChange:e=>n(e.target.value||void 0)})},Cell:e=>{let{value:t}=e;return(e=>{switch(Object.prototype.toString.call(e)){case"[object Array]":case"[object Object]":return(0,d.jsx)(b,{value:JSON.stringify(e)});case"[object Boolean]":return(0,d.jsx)(b,{value:e?"true":"false"});case"[object String]":return(t=e)&&(t.match(/^https?.*\.(jpeg|jpg|gif|png)$/)||-1!==t.indexOf("data:image"))?(0,d.jsx)(y,{src:e}):(0,d.jsx)(b,{value:e});default:return(0,d.jsx)(b,{value:e})}var t})(t)}};const N=function(e){let{columns:t,data:n,error:r,currentPage:l,pageSize:c,totalPages:i,onFilteredChange:u,onSortedChange:p,onPageChange:h,onPageSizeChange:b,showFilter:y,onRowClick:N,sorted:k,loading:C,dynamicAttributesFromDataTable:w,tableDescriptionAttributes:_,manual:S=!1}=e;const{headerGroups:F,page:O,rows:P,prepareRow:E,state:D,setAllFilters:I,canPreviousPage:T,canNextPage:R,pageOptions:z,pageCount:U,gotoPage:$,nextPage:L,previousPage:W,setPageSize:M}=(0,s.useTable)({columns:t,data:n,defaultColumn:A,onFilteredChange:u,onSortedChange:p,onPageChange:h,onPageSizeChange:b,onRowClick:N,manualPagination:S,manualFilters:S,initialState:{pageIndex:l,pageSize:c}},s.useFilters,s.usePagination),[q,H]=(0,a.useState)(!0),G=S||!O.length?P:O;return(0,a.useEffect)((()=>{!y&&D.filters.length?I([]):u(D.filters)}),[D.filters,y]),(0,a.useEffect)((()=>{setTimeout((()=>H(!1)),100)}),[null===G||void 0===G?void 0:G.length]),(0,d.jsxs)(o.tH,{onError:(e,t)=>(0,j.A)({error:{message:e.message,componentStack:t}}),FallbackComponent:v.A,children:[(0,d.jsxs)("div",{className:"react-table-scroller",children:[(0,d.jsx)(m,{headerGroups:F,tableDescriptionAttributes:_,dynamicAttributesFromDataTable:w,onSortedChange:p,sorted:k,showFilter:y}),C||q?(0,d.jsx)("div",{className:"centered text-center",children:(0,d.jsx)("i",{className:"fa fa-spinner fa-spin"})}):G.length?G.map((e=>(0,d.jsx)(x,{row:e,prepareRow:E,onRowClick:N},e.id))):(0,d.jsxs)("div",{className:"centered text-center",children:[(0,d.jsx)("i",{className:"fa fa-exclamation-triangle text-danger"}),(0,d.jsx)("div",{className:"mt-2 text-darkgrey",children:r?"Error loading data: ".concat(r):"no records"})]})]}),S?(0,d.jsx)(f,{page:l,pageSize:c,totalPages:i,onPageChange:h,onPageSizeChange:b,loading:C}):(0,d.jsx)(g,{previousPage:W,pageSize:c,canPreviousPage:T,pageIndex:D.pageIndex,pageOptions:z,gotoPage:$,setPageSize:M,pageCount:U,nextPage:L,canNextPage:R,loading:C})]})}},8750:(e,t,n)=>{n.d(t,{A:()=>s});var a=n(127);const s=async e=>{let{auth:t,url:n}=e;return(0,a.A)({operation:{operation:"get_configuration"},auth:t,url:n})}},2415:(e,t,n)=>{n.d(t,{A:()=>r});var a=n(127),s=n(5269);const r=async e=>{let{auth:t,url:n}=e;const r=await(0,a.A)({operation:{operation:"list_roles"},auth:t,url:n}),o=[...Array.isArray(r)?r:[]].sort(((e,t)=>e.role.toLowerCase()>t.role.toLowerCase()?1:-1));return s.A.update((e=>{e.roles=o})),o}},8222:(e,t,n)=>{n.d(t,{A:()=>r});var a=n(127),s=n(5269);const r=async e=>{let{auth:t,url:n,signal:r}=e;const o=await(0,a.A)({operation:{operation:"list_users"},auth:t,url:n,signal:r}),l=Array.isArray(o)?[...o].map((e=>({username:e.username,role:e.role.role}))).sort(((e,t)=>e.username.toLowerCase()>t.username.toLowerCase()?1:-1)):[];return s.A.update((e=>{e.users=l})),l}},2010:(e,t,n)=>{n.d(t,{A:()=>r});var a=n(127),s=n(5269);const r=async e=>{let{auth:t,url:n}=e;return s.A.update((e=>{e.restarting=!0})),(0,a.A)({operation:{operation:"restart"},auth:t,url:n})}},1534:(e,t,n)=>{n.d(t,{A:()=>r});var a=n(127),s=n(5269);const r=async e=>{let{auth:t,url:n,service:r=null}=e;return r?(s.A.update((e=>{e.restarting_service=r})),(0,a.A)({operation:{operation:"restart_service",service:r},auth:t,url:n})):{error:!0,message:"You must specify a service"}}},4834:(e,t,n)=>{n.d(t,{A:()=>l});var a=n(9379),s=n(45),r=n(127);const o=["auth","url"],l=async e=>{let{auth:t,url:n}=e,l=(0,s.A)(e,o);return(0,r.A)({operation:(0,a.A)({operation:"set_configuration"},l),auth:t,url:n})}},6177:(e,t,n)=>{n.d(t,{A:()=>c});var a=n(8750),s=n(2415),r=n(8222),o=n(717),l=n(127);const c=async e=>{var t,n,c,i,u,d,p;let{auth:m,url:h}=e;const f=await(0,a.A)({auth:m,url:h}),g=await(0,o.A)({auth:m,url:h}),x=await(async e=>{let{auth:t,url:n}=e;return(0,l.A)({operation:{operation:"cluster_status"},auth:t,url:n})})({auth:m,url:h}),j=parseFloat(null===g||void 0===g?void 0:g.version)>=4?"nats":"socketcluster",v=await(0,s.A)({auth:m,url:h});let b=!1;v.error||(b=v.find((e=>e.permission.cluster_user)));const y=await(0,r.A)({auth:m,url:h});let A=!1;y.error||(A=b&&y.find((e=>e.role===b.role)));const N="nats"===j?null===(t=f.clustering)||void 0===t?void 0:t.enabled:f.CLUSTERING,k="nats"===j?null===(n=f.clustering)||void 0===n?void 0:n.user:f.CLUSTERING_USER,C="nats"===j?null===(c=f.clustering)||void 0===c||null===(i=c.hubServer)||void 0===i||null===(u=i.cluster)||void 0===u||null===(d=u.network)||void 0===d?void 0:d.port:f.CLUSTERING_PORT,w="nats"===j?null===(p=f.clustering)||void 0===p?void 0:p.nodeName:f.NODE_NAME;return{is_ready:!!N&&!!A&&!!k&&!!b&&!!C&&!!w,cluster_role:b,cluster_user:A,is_enabled:N,config_cluster_user:k,config_cluster_port:C,node_name:w,engine:j,status:null===x||void 0===x?void 0:x.status,message:null===x||void 0===x?void 0:x.message,connections:null===x||void 0===x?void 0:x.connections}}},9561:(e,t,n)=>{n.d(t,{A:()=>a});const a=e=>e.match(/^[-a-zA-Z0-9_]+$/)},5488:(e,t,n)=>{n.d(t,{A:()=>b});var a=n(9950),s=n(1942),r=n.n(s),o=n(8738),l=n.n(o),c=n(1497);function i(e){return i="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},i(e)}var u=["className","cssModule","type","bsSize","valid","invalid","tag","addon","plaintext","innerRef"];function d(){return d=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var a in n)Object.prototype.hasOwnProperty.call(n,a)&&(e[a]=n[a])}return e},d.apply(this,arguments)}function p(e,t){if(null==e)return{};var n,a,s=function(e,t){if(null==e)return{};var n,a,s={},r=Object.keys(e);for(a=0;a<r.length;a++)n=r[a],t.indexOf(n)>=0||(s[n]=e[n]);return s}(e,t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);for(a=0;a<r.length;a++)n=r[a],t.indexOf(n)>=0||Object.prototype.propertyIsEnumerable.call(e,n)&&(s[n]=e[n])}return s}function m(e,t){for(var n=0;n<t.length;n++){var a=t[n];a.enumerable=a.enumerable||!1,a.configurable=!0,"value"in a&&(a.writable=!0),Object.defineProperty(e,a.key,a)}}function h(e,t){return h=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(e,t){return e.__proto__=t,e},h(e,t)}function f(e){var t=function(){if("undefined"===typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"===typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}();return function(){var n,a=x(e);if(t){var s=x(this).constructor;n=Reflect.construct(a,arguments,s)}else n=a.apply(this,arguments);return function(e,t){if(t&&("object"===i(t)||"function"===typeof t))return t;if(void 0!==t)throw new TypeError("Derived constructors may only return object or undefined");return g(e)}(this,n)}}function g(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function x(e){return x=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(e){return e.__proto__||Object.getPrototypeOf(e)},x(e)}var j={children:r().node,type:r().string,size:r().oneOfType([r().number,r().string]),bsSize:r().string,valid:r().bool,invalid:r().bool,tag:c.Wx,innerRef:r().oneOfType([r().object,r().func,r().string]),plaintext:r().bool,addon:r().bool,className:r().string,cssModule:r().object},v=function(e){!function(e,t){if("function"!==typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),Object.defineProperty(e,"prototype",{writable:!1}),t&&h(e,t)}(o,e);var t,n,s,r=f(o);function o(e){var t;return function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,o),(t=r.call(this,e)).getRef=t.getRef.bind(g(t)),t.focus=t.focus.bind(g(t)),t}return t=o,(n=[{key:"getRef",value:function(e){this.props.innerRef&&this.props.innerRef(e),this.ref=e}},{key:"focus",value:function(){this.ref&&this.ref.focus()}},{key:"render",value:function(){var e=this.props,t=e.className,n=e.cssModule,s=e.type,r=void 0===s?"text":s,o=e.bsSize,i=e.valid,m=e.invalid,h=e.tag,f=e.addon,g=e.plaintext,x=e.innerRef,j=p(e,u),v=["switch","radio","checkbox"].indexOf(r)>-1,b="select"===r,y="range"===r,A=h||(b||"textarea"===r?r:"input"),N="form-control";g?(N="".concat(N,"-plaintext"),A=h||"input"):y?N="form-range":b?N="form-select":v&&(N=f?null:"form-check-input"),j.size&&/\D/g.test(j.size)&&((0,c.mc)('Please use the prop "bsSize" instead of the "size" to bootstrap\'s input sizing.'),o=j.size,delete j.size);var k=(0,c.qO)(l()(t,m&&"is-invalid",i&&"is-valid",!!o&&(b?"form-select-".concat(o):"form-control-".concat(o)),N),n);return("input"===A||h&&"function"===typeof h)&&(j.type="switch"===r?"checkbox":r),j.children&&!g&&"select"!==r&&"string"===typeof A&&"select"!==A&&((0,c.mc)('Input with a type of "'.concat(r,'" cannot have children. Please use "value"/"defaultValue" instead.')),delete j.children),a.createElement(A,d({},j,{ref:x,className:k,"aria-invalid":m}))}}])&&m(t.prototype,n),s&&m(t,s),Object.defineProperty(t,"prototype",{writable:!1}),o}(a.Component);v.propTypes=j;const b=v}}]);
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";(self.webpackChunkharperdb_studio=self.webpackChunkharperdb_studio||[]).push([[575],{1679:(e,t,n)=>{n.r(t),n.d(t,{default:()=>ce});var a=n(9950),s=n(6713),r=n(135),l=n(5077),i=n(5269),o=n(7176),c=n(6114),u=n(4084),d=n(8156),h=n(9435),m=n(6165),p=n(3150),g=n(3628),f=n(9379),v=n(3452),b=n(2010),_=n(4834),x=n(127);var j=n(8198),A=n(8738),N=n.n(A),k=n(4414);function y(e){let{error:t,style:n={}}=e;return(0,k.jsx)("div",{style:n,className:N()("form-validation-error",{error:t}),children:t||"input is valid"})}var w=n(5488);const C=function(e){let{label:t,value:n,type:s="text",max:r=null,min:l=null,editable:i=!1,handleChange:o,validator:c=()=>!0,errorMessage:u="is required",addSpace:d=!0,valid:h=!1}=e;const[m,p]=(0,a.useState)(null);return i?(0,k.jsxs)(k.Fragment,{children:[d&&(0,k.jsx)("br",{}),(0,k.jsxs)("div",{className:N()("text-nowrap mt-2 mb-1",{"text-danger":m}),children:[t," ",m]}),(0,k.jsx)(w.A,{id:"cluster-field-".concat(t),type:s,className:N()("cluster-field form-control",{error:m}),max:r,min:l,defaultValue:n,valid:h,onChange:e=>o(e.target.value),onBlur:e=>{const t=c(e.target.value);p(t?null:u)}})]}):(0,k.jsxs)(k.Fragment,{children:[d&&(0,k.jsx)("br",{}),(0,k.jsx)("div",{className:"text-nowrap mt-2 mb-1",children:t}),(0,k.jsx)(w.A,{readOnly:!0,valid:!0,type:s,value:n})]})};var S=n(2765);const P=function(e){var t,n,r,l,o,c,u,d,h;let{setConfiguring:m,clusterStatus:p,refreshStatus:g,compute_stack_id:A}=e;const N=(0,s.O$)(i.A,(e=>e.auth)),w=(0,s.O$)(i.A,(e=>e.url)),P=p.engine,O=1024,E=65535,[T,R]=(0,a.useState)({clusterRole:null===p||void 0===p||null===(t=p.cluster_role)||void 0===t?void 0:t.role,clusterUsername:(null===p||void 0===p||null===(n=p.cluster_user)||void 0===n?void 0:n.username)||"cluster_user",clusterPassword:(null===p||void 0===p||null===(r=p.cluster_user)||void 0===r?void 0:r.password)||"",clusterPort:(null===p||void 0===p?void 0:p.config_cluster_port)||"",clusterNodeName:(null===p||void 0===p?void 0:p.node_name)||A}),[F,M]=(0,a.useState)(null);function I(e){R((0,f.A)((0,f.A)({},T),e))}return(0,k.jsxs)(k.Fragment,{children:[(0,k.jsx)(C,{label:"Cluster Role",handleChange:e=>I({clusterRole:e}),value:T.clusterRole,valid:(null===(l=T.clusterRole)||void 0===l?void 0:l.trim().length)>0,validator:e=>(null===e||void 0===e?void 0:e.trim().length)>0,editable:!(null!==p&&void 0!==p&&null!==(o=p.cluster_role)&&void 0!==o&&o.role),addSpace:!1}),(0,k.jsx)(C,{label:"Cluster User",handleChange:e=>I({clusterUsername:e}),value:T.clusterUsername,valid:T.clusterUsername.trim().length>0,validator:e=>e.trim().length>0,editable:!(null!==p&&void 0!==p&&null!==(c=p.cluster_user)&&void 0!==c&&c.username)}),(0,k.jsx)(C,{label:"Cluster Password",type:"password",handleChange:e=>I({clusterPassword:e}),value:null!==p&&void 0!==p&&null!==(u=p.cluster_user)&&void 0!==u&&u.username?"********":T.clusterPassword,valid:(null===p||void 0===p||null===(d=p.cluster_user)||void 0===d?void 0:d.username)||T.clusterPassword.trim().length>0,validator:e=>e.trim().length>0,editable:!(null!==p&&void 0!==p&&null!==(h=p.cluster_user)&&void 0!==h&&h.username),showDivider:!1}),(0,k.jsx)(C,{label:"Cluster Port",type:"number",max:E,min:O,handleChange:e=>I({clusterPort:e}),value:T.clusterPort,valid:T.clusterPort>=O&&T.clusterPort<=E,validator:e=>e>=O&&e<=E,errorMessage:"must be between ".concat(O," and ").concat(E),editable:!(null!==p&&void 0!==p&&p.config_cluster_port)}),(0,k.jsx)(C,{label:"Cluster Node Name",handleChange:e=>I({clusterNodeName:e}),value:T.clusterNodeName,valid:T.clusterNodeName.length>0,validator:e=>e.length>0,editable:!(null!==p&&void 0!==p&&p.node_name)}),(0,k.jsx)("hr",{className:"my-3"}),(0,k.jsx)(v.A,{block:!0,color:"success",disabled:!function(e){var t;let{clusterRole:n,clusterUsername:a,clusterPassword:s,clusterPort:r,clusterNodeName:l}=e;return(null===n||void 0===n?void 0:n.length)>0&&a.length>0&&((null===p||void 0===p||null===(t=p.cluster_user)||void 0===t?void 0:t.username)||s.length>0)&&l.length>0&&r>=O&&r<=E}(T),onClick:async function(){var e;if(M(null),null===(e=p.cluster_role)||void 0===e||!e.role){const e=await(0,S.A)({auth:N,url:w,role:T.clusterRole,permission:{cluster_user:!0}});if(e.error)return M(e.message)}if(!p.cluster_user){const e=await(0,j.A)({auth:N,url:w,role:T.clusterRole,username:T.clusterUsername,password:T.clusterPassword});if(e.error)return M(e.message)}const t="nats"===P?await(0,_.A)({auth:N,url:w,clustering_enabled:!0,clustering_nodeName:T.clusterNodeName,clustering_port:T.clusterPort,clustering_user:T.clusterUsername}):await(async e=>{let{CLUSTERING:t=!1,CLUSTERING_PORT:n,CLUSTERING_USER:a,NODE_NAME:s,auth:r,url:l}=e;return(0,x.A)({operation:{operation:"configure_cluster",CLUSTERING:t,CLUSTERING_PORT:n,CLUSTERING_USER:a,NODE_NAME:s},auth:r,url:l})})({auth:N,url:w,CLUSTERING:!0,CLUSTERING_PORT:T.clusterPort,CLUSTERING_USER:T.clusterUsername,NODE_NAME:T.clusterNodeName});return t.error?M(t.message):(window._kmq&&window._kmq.push(["record","enabled clustering"]),await(0,b.A)({auth:N,url:w}),setTimeout((()=>m(!0)),0),g())},children:"Enable Clustering"}),(0,k.jsx)("br",{}),F&&(0,k.jsx)(y,{error:F})]})};const O=function(e){let{setConfiguring:t,clusterStatus:n,refreshStatus:a}=e;const{compute_stack_id:r}=(0,l.g)(),f=null===n||void 0===n?void 0:n.cluster_role,v=(null===n||void 0===n?void 0:n.cluster_role)&&(null===n||void 0===n?void 0:n.cluster_user),b=(null===n||void 0===n?void 0:n.cluster_role)&&(null===n||void 0===n?void 0:n.cluster_user),_=(null===n||void 0===n?void 0:n.cluster_role)&&(null===n||void 0===n?void 0:n.cluster_user)&&(null===n||void 0===n?void 0:n.node_name),x=(0,s.O$)(i.A,(e=>e.rule_arn)),j=Boolean(x);return(0,k.jsxs)(o.A,{id:"clustering",children:[(0,k.jsxs)(c.A,{xl:"3",lg:"4",md:"5",xs:"12",children:[(0,k.jsx)("span",{className:"floating-card-header",children:"enable clustering"}),(0,k.jsx)(u.A,{className:"my-3",children:(0,k.jsx)(d.A,{children:(0,k.jsx)(h.tH,{onError:(e,t)=>(0,g.A)({error:{message:e.message,componentStack:t}}),FallbackComponent:p.A,children:(0,k.jsx)(P,{setConfiguring:t,refreshStatus:a,clusterStatus:n,compute_stack_id:r})})})})]}),(0,k.jsx)(c.A,{xl:"9",lg:"8",md:"7",xs:"12",children:_?(0,k.jsx)(m.A,{headline:"You're all set!",description:"Click the button at left to enable clustering. NOTE: We'll restart the instance when you click this button.",icon:(0,k.jsx)("i",{className:"fa fa-thumbs-up text-success"})}):b?(0,k.jsx)(m.A,{headline:"Set Instance Cluster Name",description:'We need to set a unique node name to identify your instance in the cluster. By default, we set it to "'.concat(r,'", but you can choose your own unique node name.'),icon:(0,k.jsx)("i",{className:"fa fa-exclamation-triangle text-warning"})}):v?(0,k.jsx)(m.A,{headline:"Cluster Port Set To: 12345",description:"If your instance is behind a firewall, you'll need to ensure this port is accessible by other instances if you want to publish/subscribe to/from this instance.",icon:(0,k.jsx)("i",{className:"fa fa-thumbs-up text-success"})}):f?(0,k.jsx)(m.A,{headline:"Create a Cluster User",description:"If you have other instances you want to cluster together with this one, make sure the cluster user has the same name and password as those other instances.",warning:j?"Harper clustering functionality will not work between AWS cloud instances. We are working on upgrading our cloud infrastructure to support clustering functionality.":null,icon:(0,k.jsx)("i",{className:"fa fa-exclamation-triangle text-warning"})}):(0,k.jsx)(m.A,{headline:"Create a Cluster Role",description:"This role subscribes to instance transaction logs and handles operations that result from its pub/sub configuration.",icon:(0,k.jsx)("i",{className:"fa fa-exclamation-triangle text-warning"})})})]})};var E=n(7348);const T=function(e){let{handleAddNode:t,loading:n}=e;return(0,k.jsx)(v.A,{color:"purple",className:"round",title:"Connect To This Instance",disabled:n,onClick:t,children:(0,k.jsx)("i",{className:"fa ".concat(n?"fa-spin fa-spinner":"fa-plus"," text-white")})})};const R=function(e){let{handleRemoveNode:t,showModal:n,loading:a}=e;return(0,k.jsxs)(k.Fragment,{children:[(0,k.jsx)(v.A,{color:"danger",className:"round me-1",title:"Why isn't this instance clustering?",disabled:a,onClick:n,children:(0,k.jsx)("i",{className:"fa fa-exclamation"})}),(0,k.jsx)(v.A,{color:"purple",className:"round",title:"Disconnect From This Instance",disabled:a,onClick:t,children:(0,k.jsx)("i",{className:"fa ".concat(a?"fa-spin fa-spinner":"fa-minus"," text-white")})})]})};const F=function(e){let{handleRemoveNode:t,loading:n}=e;return(0,k.jsx)(v.A,{color:"purple",className:"round",title:"Disconnect From This Instance",disabled:n,onClick:t,children:(0,k.jsx)("i",{className:"fa ".concat(n?"fa-spin fa-spinner":"fa-minus"," text-white")})})};const M=function(){return(0,k.jsx)(v.A,{color:"purple",className:"round",title:"Connecting to this instance",disabled:!0,children:(0,k.jsx)("i",{className:"fa fa-spin fa-spinner text-white"})})};const I=function(e){let{handleConfigureNode:t,loading:n}=e;return(0,k.jsx)(v.A,{color:"success",className:"round me-1",title:"Enable Clustering",disabled:n,onClick:t,children:(0,k.jsx)("i",{className:"fa ".concat(n?"fa-spin fa-spinner":"fa-share"," text-white")})})};const L=function(e){var t,n,a;let{setShowModal:s,item:r,itemType:l,loading:i,handleAddNode:u,handleRemoveNode:d,handleConfigureNode:h,refreshNetwork:m}=e;const p=r.compute_stack_id===i;return(0,k.jsxs)(o.A,{className:"item-row",children:[(0,k.jsx)(c.A,{className:"item-label ".concat("closed"===(null===(t=r.connection)||void 0===t?void 0:t.state)?"text-danger":""),children:r.instance_name}),(0,k.jsx)(c.A,{className:"item-action",children:"incompatible/unreachable"===l?null:"unconfigured"===l?(0,k.jsx)(I,{loading:p,handleConfigureNode:()=>h({compute_stack_id:r.compute_stack_id})}):"CREATE_IN_PROGRESS"===r.instance_status?(0,k.jsx)(v.A,{color:"grey",className:"round",title:"Creating Instance",disabled:!0,children:(0,k.jsx)("i",{className:"fa fa-spin fa-spinner"})}):r.connection?"closed"===(null===(n=r.connection)||void 0===n?void 0:n.state)?(0,k.jsx)(R,{loading:p,handleRemoveNode:()=>d({compute_stack_id:r.compute_stack_id}),showModal:()=>s(r.instance_name)}):"connecting"===(null===(a=r.connection)||void 0===a?void 0:a.state)?(0,k.jsx)(M,{refreshNetwork:m}):(0,k.jsx)(F,{loading:p,handleRemoveNode:()=>d({compute_stack_id:r.compute_stack_id,instance_host:r.instance_host,clusterPort:r.clusterPort})}):(0,k.jsx)(T,{loading:p,handleAddNode:()=>u({compute_stack_id:r.compute_stack_id,instance_url:r.instance_url,instance_host:r.instance_host,clusterPort:r.clusterPort})})})]})};var U=n(1534);const z=function(e){let{items:t,itemType:n,setShowModal:r,loading:h,setLoading:m,refreshNetwork:p}=e;const{customer_id:g}=(0,l.g)(),v=(0,l.Zp)(),b=(0,E.MW)(),_=(0,s.O$)(i.A,(e=>e.compute_stack_id)),j=(0,s.O$)(i.A,(e=>e.auth),[_]),A=(0,s.O$)(i.A,(e=>e.url),[_]),N=(0,s.O$)(i.A,(e=>e.is_local),[_]),y=(0,s.O$)(i.A,(e=>{var t;return parseFloat(null===(t=e.auth)||void 0===t?void 0:t.version)>=4?"nats":"socketcluster"}),[_]),w=(0,a.useCallback)((async e=>{m(e.compute_stack_id);const t="nats"===y?await(async e=>{let{auth:t,url:n,server:a="hub",routes:s}=e;return(0,x.A)({operation:{operation:"cluster_set_routes",server:a,routes:s},auth:t,url:n})})({auth:j,url:A,routes:[{host:e.instance_host,port:e.clusterPort}]}):await(async e=>{let{compute_stack_id:t,instance_host:n,clusterPort:a,auth:s,url:r}=e;return(0,x.A)({operation:{operation:"add_node",name:t,node_name:t,host:n,port:a,subscriptions:[]},auth:s,url:r})})((0,f.A)((0,f.A)({},e),{},{auth:j,url:A,is_local:N,customer_id:g}));t.error?(b.error("localhost"===e.instance_host?"External instances cannot reach that instance's URL":t.message),m(!1)):("nats"===y&&await(0,U.A)({auth:j,url:A,service:"clustering config"}),await p()),m(!1)}),[m,j,A,N,g,p,b,y]),C=(0,a.useCallback)((async e=>{m(e.compute_stack_id);const t="nats"===y?await(async e=>{let{auth:t,url:n,routes:a}=e;return(0,x.A)({operation:{operation:"cluster_delete_routes",routes:a},auth:t,url:n})})({auth:j,url:A,routes:[{host:e.instance_host,port:e.clusterPort}]}):await(async e=>{let{compute_stack_id:t,auth:n,url:a}=e;return(0,x.A)({operation:{operation:"remove_node",name:t,node_name:t},auth:n,url:a})})((0,f.A)((0,f.A)({},e),{},{auth:j,url:A,is_local:N,customer_id:g}));t.error?(b.error(t.message),m(!1)):("nats"===y&&await(0,U.A)({auth:j,url:A,service:"clustering config"}),await p()),m(!1)}),[m,j,A,N,g,p,b,y]),S=(0,a.useCallback)((e=>v("/o/".concat(g,"/i/").concat(e.compute_stack_id,"/cluster"))),[v,g]);return(0,k.jsxs)("div",{className:"entity-manager",children:[(0,k.jsxs)("div",{className:"floating-card-header",children:[n," instances"]}),(0,k.jsx)(u.A,{className:"my-3",children:(0,k.jsx)(d.A,{children:null!==t&&void 0!==t&&t.length?t.map((e=>(0,k.jsx)(L,{item:e,itemType:n,setShowModal:r,handleAddNode:w,handleRemoveNode:C,handleConfigureNode:S,loading:h,refreshNetwork:p},e.instance_name))):t?(0,k.jsx)(o.A,{className:"item-row",children:(0,k.jsxs)(c.A,{className:"item-label",children:["There are no ",n," instances"]})}):(0,k.jsx)(o.A,{className:"item-row",children:(0,k.jsx)(c.A,{className:"item-label",children:(0,k.jsx)("i",{className:"fa fa-spinner fa-spin"})})})})})]})};var D=n(4343);const $={filtered:[],sorted:[],page:0,totalPages:1,pageSize:20,autoRefresh:!1,showFilter:!1,lastUpdate:!1};const G=function(e){let{refreshNetwork:t,loading:n,setLoading:r}=e;const l=(0,s.O$)(i.A,(e=>e.clusterDataTable||[])),h=(0,s.O$)(i.A,(e=>e.clusterDataTableColumns||[])),[m,p]=(0,a.useState)($);(0,a.useEffect)((()=>{p((0,f.A)((0,f.A)({},m),{},{totalPages:Math.ceil((l.length||m.pageSize)/m.pageSize)}))}),[p,m.pageSize]);const g=(0,a.useCallback)((async()=>{r(!0),t()}),[r,t]);return(0,k.jsxs)(k.Fragment,{children:[(0,k.jsxs)(o.A,{className:"floating-card-header",children:[(0,k.jsx)(c.A,{children:"manage clustering"}),(0,k.jsx)(c.A,{className:"text-end",children:(0,k.jsxs)(v.A,{color:"link",onClick:g,className:"me-2",children:[(0,k.jsx)("span",{className:"me-2",children:"refresh network"}),(0,k.jsx)("i",{title:"Refresh Roles",className:"fa ".concat(n?"fa-spinner fa-spin":"fa-sync-alt")})]})})]}),(0,k.jsx)(u.A,{className:"my-3",children:(0,k.jsx)(d.A,{className:"react-table-holder ".concat(n?"loading":""),children:null!==l&&void 0!==l&&l.length?(0,k.jsx)(D.A,{columns:h,data:l,page:m.page,pageSize:m.pageSize,totalPages:m.totalPages,showFilter:m.showFilter,sorted:m.sorted,onFilteredChange:e=>p((0,f.A)((0,f.A)({},m),{},{filtered:e})),onSortedChange:e=>p((0,f.A)((0,f.A)({},m),{},{sorted:e})),onPageChange:e=>p((0,f.A)((0,f.A)({},m),{},{pageSize:e})),onPageSizeChange:e=>p((0,f.A)((0,f.A)({},m),{},{page:0,pageSize:e}))}):(0,k.jsx)("div",{className:"empty-prompt",children:"Please connect at least one instance to configure clustering"})})})]})};var B=n(6685),X=n(1340),H=n(877);const q=function(e){let{showModal:t,setShowModal:n}=e;const{compute_stack_id:a}=(0,l.g)(),r=(0,s.O$)(i.A,(e=>e.instance_name),[a]);return(0,k.jsxs)(B.A,{id:"cluster-state-modal",isOpen:!!t,toggle:()=>n(!1),centered:!0,fade:!1,children:[(0,k.jsx)(X.A,{toggle:()=>n(!1),children:"Instance Cluster Error"}),(0,k.jsx)(H.A,{children:(0,k.jsx)(u.A,{children:(0,k.jsxs)(d.A,{children:[(0,k.jsx)("b",{children:r})," is unable to open a connection to ",(0,k.jsx)("b",{children:t}),".",(0,k.jsx)("hr",{className:"my-3"}),(0,k.jsxs)("ul",{children:[(0,k.jsx)("li",{children:"Clustered instances must be able to reach each other. This may require allowing access through a firewall."}),(0,k.jsx)("li",{children:"Both instances must be running. In the event of a restart, instances will automatically attempt to reconnect."}),(0,k.jsxs)("li",{children:["Clustered instances must have the same cluster user ",(0,k.jsx)("b",{children:"name"})," and ",(0,k.jsx)("b",{children:"password"}),". You can edit an instance's cluster user credentials in the ",(0,k.jsx)("b",{children:"config"})," section."]})]}),(0,k.jsx)("hr",{className:"my-3"}),"If none of these help fix the issue, you can disconnect ",(0,k.jsx)("b",{children:t})," from ",(0,k.jsx)("b",{children:r})," by clicking the purple disconnect button with the minus sign."]})})})]})};var W=n(2414),Y=n.n(W);var J=n(1110);const V=async e=>{let{channel:t,subscriptions:n,buttonState:a,instance_host:s,clusterPort:r,clusterName:l,auth:o,url:c}=e;const u=JSON.parse(JSON.stringify(n)),d=u.findIndex((e=>e.channel===t)),[h,m]=t.split(":");-1===d?u.push({channel:t,schema:h,table:m,publish:"togglePublish"===a,subscribe:"toggleSubscribe"===a}):"togglePublish"===a?u[d].publish=!u[d].publish:"toggleSubscribe"===a&&(u[d].subscribe=!u[d].subscribe),u[d]&&!u[d].publish&&u[d].subscribe;const p={operation:"update_node",name:l,node_name:l,host:s,port:r,subscriptions:u},g=await(0,x.A)({operation:p,auth:o,url:c});return g.error&&-1!==g.message.indexOf("add_node")&&(p.operation="add_node",await(0,x.A)({operation:p,auth:o,url:c})),i.A.update((e=>{e.lastUpdate=Date.now()}))};var K=n(5346),Z=n(396),Q=n(6177);const ee=async e=>{let{instance:t,auth:n}=e;const a=n&&await(0,Q.A)({auth:n,url:t.url}),s=n&&await(0,K.A)({auth:n,url:t.url}),{structure:r}=s?(0,Z.A)(s):{structure:{}},l=new URL(t.url),i=(0,f.A)((0,f.A)({},t),{},{auth:n,structure:r,host:l.hostname,clustering:a});return Object.entries(i).reduce(((e,t)=>{let[n,a]=t;return null==a||(e[n]=a),e}),{})},te=async e=>{let{auth:t,url:n,instances:a,connections:s}=e;const r=await(async e=>{let{auth:t,url:n}=e;return(0,x.A)({operation:{operation:"cluster_get_routes"},auth:t,url:n})})({auth:t,url:n});return r.hub.map((e=>{var t;const n=a.find((t=>t.host===e.host||t.private_ip===e.host));if(!n)return!1;const r=n.host===n.private_ip?n.private_ip:n.host,l=s.find((e=>{var t;return e.node_name===(null===n||void 0===n||null===(t=n.clustering)||void 0===t?void 0:t.node_name)})),i=(null===l||void 0===l||null===(t=l.subscriptions)||void 0===t?void 0:t.map((e=>(0,f.A)({channel:"".concat(e.schema,":").concat(e.table)},e))))||[];return{host:r,port:e.port,state:"open",name:null===n||void 0===n?void 0:n.compute_stack_id,subscriptions:i}})).filter((e=>!1!==e))},ne=e=>{let{connections:t}=e;return t?t.filter((e=>-1===e.host_address.indexOf("::ffff"))).map((e=>({name:e.node_name,host:e.host_address,port:e.host_port,state:e.state,subscriptions:e.subscriptions}))):[]},ae=async e=>{let{auth:t,url:n,instances:a,compute_stack_id:s,instanceAuths:r,setLoading:l}=e;const o=await Promise.all(a.filter((e=>!!r[e.compute_stack_id])).map((e=>ee({instance:e,auth:r[e.compute_stack_id]})))),c=o.find((e=>e.compute_stack_id===s)),u=c.clustering.message||!c.clustering.is_enabled?[]:"nats"===c.clustering.engine?await te({auth:t,url:n,instances:o,connections:c.clustering.connections}):ne({connections:c.clustering.status.outbound_connections}),d={is_enabled:c.clustering.is_enabled,connections:u},h=(e=>{let{instances:t,network:n,instance_region:a,instance_wavelength_zone_id:s,instance_cluster_engine:r}=e;const l=t.filter((e=>e.url&&"DELETE_IN_PROGRESS"!==e.status)).filter((e=>e.clustering.engine===r)).map((e=>{var t,l;const i="socketcluster"===r?null===n||void 0===n?void 0:n.connections.find((t=>t.name===e.compute_stack_id)):null===n||void 0===n?void 0:n.connections.find((t=>t.host===e.host)),o=(null===i||void 0===i?void 0:i.subscriptions)||[],c=null===e||void 0===e||null===(t=e.clustering)||void 0===t?void 0:t.config_cluster_port,u=e.is_local?"OK":e.status,d=!a||a!==e.instance_region||e.wavelength_zone_id||s?e.url.match(/^https?:\/\/([^/:?#]+)(?:[/:?#]|$)/i)[1]:e.private_ip,h=e.clustering.node_name;return{instance_name:e.instance_name,instance_url:e.url,compute_stack_id:e.compute_stack_id,instance_status:u,instance_host:d,clusterPort:c,clusterName:h,connection:i,subscriptions:o,structure:e.structure,configured:null===(l=e.clustering)||void 0===l?void 0:l.is_ready}})),i=t.filter((e=>e.clustering.engine!==r)).map((e=>({instance_name:e.instance_name,compute_stack_id:e.name})));return{connected:l.filter((e=>e.connection&&e.configured)),unconnected:l.filter((e=>!e.connection&&e.configured)),unconfigured:l.filter((e=>!e.configured)),unreachable:i}})({instances:o.filter((e=>r[e.compute_stack_id]&&e.compute_stack_id!==s)),network:d,instance_region:c.instance_region,instance_wavelength_zone_id:c.wavelength_zone_id,instance_cluster_engine:c.clustering.engine}),m=(e=>{let{instances:t,structure:n}=e;if(!n||!t.length)return[];const a=[];return t.map((e=>{const t=Y()(e.structure,n);return Object.keys(t).sort().map(((n,s)=>(Object.keys(t[n]).sort().map(((t,r)=>{const l="".concat(n,":").concat(t),i=l&&e.subscriptions.find((e=>e.channel===l)),o=i&&i.publish,c=i&&i.subscribe;return a.push({is_first_instance:0===s&&0===r,is_first_schema:0===r,instance_name:e.instance_name,schema:n,table:t,compute_stack_id:e.compute_stack_id,instance_host:e.instance_host,clusterPort:e.clusterPort,clusterName:e.clusterName,subscriptions:e.subscriptions,channel:l,publish:o,subscribe:c}),!0})),!0))),!0})),a})({instances:h.connected.filter((e=>"closed"!==e.connection.state)),structure:c.structure}),p=(e=>{let{auth:t,url:n,buildNetwork:a,setLoading:s}=e;return[{Header:"instance",Cell:e=>{let{row:{original:{is_first_instance:t,instance_name:n}}}=e;return(0,k.jsx)("div",{className:"".concat(t?"text-bold":"text-grey"),children:n})}},{Header:"schema",Cell:e=>{let{row:{original:{is_first_schema:t,schema:n}}}=e;return(0,k.jsx)("div",{className:"".concat(t?"text-bold":"text-grey"),children:n})}},{Header:"table",accessor:"table"},{Header:"publish",id:"hdb-narrow-publish",Cell:e=>{let{row:{original:{compute_stack_id:r,instance_host:l,instance_name:i,clusterPort:o,clusterName:c,subscriptions:u,publish:d,channel:h}}}=e;return(0,k.jsx)(J.A,{checked:d||!1,onChange:async()=>{s(r),await V({channel:h,subscriptions:u,instance_host:l,instance_name:i,clusterPort:o,clusterName:c,auth:t,url:n,buttonState:"togglePublish"}),a()}})}},{Header:"subscribe",id:"hdb-narrow-subscribe",Cell:e=>{let{row:{original:{compute_stack_id:r,instance_host:l,instance_name:i,clusterPort:o,clusterName:c,subscriptions:u,subscribe:d,channel:h}}}=e;return(0,k.jsx)(J.A,{checked:d||!1,onChange:async()=>{s(r),await V({channel:h,subscriptions:u,instance_host:l,instance_name:i,clusterPort:o,clusterName:c,auth:t,url:n,buttonState:"toggleSubscribe"}),a()}})}}]})({auth:t,url:c.url,compute_stack_id:s,buildNetwork:()=>ae({auth:t,url:n,instances:a,compute_stack_id:s,instanceAuths:r,setLoading:l}),setLoading:l});return i.A.update((e=>{e.network=d,e.clusterPartners=h,e.clusterDataTable=m,e.clusterDataTableColumns=p,e.instances=o})),l(!1),{network:d,clusterPartners:h,clusterDataTable:m,clusterDataTableColumns:p}},se=ae;var re=n(5553),le=n(4319);const ie=function(e){let{configuring:t}=e;const{compute_stack_id:n}=(0,l.g)(),u=(0,s.O$)(re.A,(e=>e.instances)),[d]=(0,le.A)({}),m=(0,s.O$)(i.A,(e=>e.auth),[n]),f=(0,s.O$)(i.A,(e=>e.url),[n]),v=(0,s.O$)(i.A,(e=>e.clusterPartners),[n]),b=(0,s.O$)(i.A,(e=>e.restarting),[n]),_="socketcluster"===(0,s.O$)(i.A,(e=>{var t;return parseFloat(null===(t=e.registration)||void 0===t?void 0:t.version)>=4?"nats":"socketcluster"}),[n])&&(null===v||void 0===v?void 0:v.connected.some((e=>"connecting"===e.connection.state))),[x,j]=(0,a.useState)(!1),[A,N]=(0,a.useState)(!1),y=(0,a.useCallback)((async()=>{m&&f&&u&&n&&!b&&!t&&await se({auth:m,url:f,instances:u,compute_stack_id:n,instanceAuths:d,setLoading:N})}),[m,f,u,n,b,d,t]);return(0,a.useEffect)((()=>{y()}),[y]),(0,r.A)((()=>_&&y()),1500),(0,k.jsxs)(k.Fragment,{children:[(0,k.jsxs)(o.A,{id:"clustering",children:[(0,k.jsx)(c.A,{xl:"3",lg:"4",md:"6",xs:"12",children:(0,k.jsxs)(h.tH,{onError:(e,t)=>(0,g.A)({error:{message:e.message,componentStack:t}}),FallbackComponent:p.A,children:[(0,k.jsx)(z,{items:null===v||void 0===v?void 0:v.connected,itemType:"connected",loading:A,refreshNetwork:y,setLoading:N,setShowModal:j}),(0,k.jsx)(z,{items:null===v||void 0===v?void 0:v.unconnected,itemType:"unconnected",loading:A,refreshNetwork:y,setLoading:N}),(0,k.jsx)(z,{items:null===v||void 0===v?void 0:v.unconfigured,itemType:"unconfigured",loading:A}),(0,k.jsx)(z,{items:null===v||void 0===v?void 0:v.unreachable,itemType:"incompatible/unreachable",loading:A})]})}),(0,k.jsx)(c.A,{xl:"9",lg:"8",md:"6",xs:"12",children:(0,k.jsx)(G,{refreshNetwork:y,loading:A,setLoading:N})})]}),(0,k.jsx)(q,{showModal:x,setShowModal:j})]})};var oe=n(4979);const ce=function(){const{compute_stack_id:e}=(0,l.g)(),t=(0,s.O$)(i.A,(e=>e.auth),[e]),n=(0,s.O$)(i.A,(e=>e.url),[e]),[o,c]=(0,a.useState)(!1),[u,d]=(0,a.useState)(!1),h=(0,a.useCallback)((async()=>{if(t&&n){const e=await(0,Q.A)({auth:t,url:n});c(e),e.is_ready&&d(!1)}}),[t,n]);return(0,r.A)((async()=>{u&&h()}),3e3),(0,a.useEffect)((()=>{h()}),[h]),(0,a.useEffect)((()=>{c(!1)}),[e]),o?u?(0,k.jsx)(m.A,{description:"Configuring Clustering",icon:(0,k.jsx)("i",{className:"fa fa-spinner fa-spin"})}):o.is_ready?(0,k.jsx)(ie,{configuring:u}):(0,k.jsx)(O,{setConfiguring:d,clusterStatus:o,refreshStatus:h}):(0,k.jsx)(oe.A,{header:"loading network",spinner:!0})}},4343:(e,t,n)=>{n.d(t,{A:()=>N});var a=n(9950),s=n(2043),r=n(5488),l=n(9435),i=n(9379),o=n(45),c=n(7176),u=n(6114),d=n(4414);const h=["key"],m=e=>{let{headerGroups:t,onSortedChange:n,sorted:a,showFilter:s,dynamicAttributesFromDataTable:r,tableDescriptionAttributes:l}=e;const m=e=>{let t=!1;return l.forEach((n=>{n.attribute===e&&(n.is_primary_key||n.indexed)&&(t=!0)})),t};return t.map((e=>{const t=e.getHeaderGroupProps(),{key:l}=t,p=(0,o.A)(t,h);return(0,d.jsxs)("div",(0,i.A)((0,i.A)({},p),{},{children:[(0,d.jsx)(c.A,{className:"header g-0",children:e.headers.map((e=>{var t,s;return(0,d.jsx)(u.A,{onClick:()=>{var t,s;r&&!r.includes(e.id)&&m(e.id)&&n([{id:e.id,desc:(null===(t=a[0])||void 0===t?void 0:t.id)===e.id&&!(null!==(s=a[0])&&void 0!==s&&s.desc)}])},className:"".concat((null===(t=a[0])||void 0===t?void 0:t.id)===e.id?"sorted":""," ").concat(null!==(s=a[0])&&void 0!==s&&s.desc?"desc":"asc"," ").concat(-1!==e.id.indexOf("hdb-narrow")?"action":""," px-1 ").concat(r&&!r.includes(e.id)&&m(e.id)?"":"disabled-column"),children:(0,d.jsx)("div",{className:"text-renderer",children:e.render("Header")})},e.id)}))}),s&&(0,d.jsx)(c.A,{className:"filter g-0",children:e.headers.map((e=>(0,d.jsx)(u.A,{className:-1!==e.id.indexOf("hdb-narrow")?"action":"",children:e.render("Filter")},e.id)))})]}),l)}))};var p=n(3452);const g=function(e){let{page:t,pageSize:n,totalPages:a,onPageChange:s,onPageSizeChange:l,loading:i}=e;return(0,d.jsxs)(c.A,{className:"pagination",children:[(0,d.jsx)(u.A,{xs:"12",sm:"2",className:"previous",children:(0,d.jsx)(p.A,{className:"mb-2 btn-pagination",color:"purple",block:!0,onClick:()=>s(t-1),disabled:!a||0===t,children:(0,d.jsx)("i",{className:"fa fa-chevron-left"})})}),(0,d.jsxs)(u.A,{xs:"12",sm:"4",className:"paginator",children:[(0,d.jsx)("i",{className:"fa fa-book me-2"}),(0,d.jsx)(r.A,{className:"mb-2",type:"number",value:t+1,min:1,max:a,onChange:e=>s(e.target.value-1)}),(0,d.jsxs)("div",{className:"page-count",children:["\xa0/\xa0",i?(0,d.jsx)("i",{className:"fa fa-spinner fa-spin"}):a]})]}),(0,d.jsx)(u.A,{xs:"12",sm:"4",className:"page-size",children:(0,d.jsx)(r.A,{className:"mb-2",type:"select",value:n,onChange:e=>l(e.target.value),children:[20,50,100,250].map((e=>(0,d.jsxs)("option",{value:e,children:[e," rows"]},e)))})}),(0,d.jsx)(u.A,{xs:"12",sm:"2",className:"next",children:(0,d.jsx)(p.A,{className:"mb-2 pull-right btn-pagination",block:!0,color:"purple",onClick:()=>s(t+1),disabled:!a||t+1===a,children:(0,d.jsx)("i",{className:"fa fa-chevron-right"})})})]})};const f=function(e){let{previousPage:t,canPreviousPage:n,pageIndex:a,gotoPage:s,setPageSize:l,pageCount:i,nextPage:o,canNextPage:h,loading:m}=e;return(0,d.jsxs)(c.A,{className:"pagination",children:[(0,d.jsx)(u.A,{xs:"12",sm:"2",className:"previous",children:(0,d.jsx)(p.A,{className:"mb-2 btn-pagination",color:"purple",block:!0,onClick:t,disabled:!i||!n,children:(0,d.jsx)("i",{className:"fa fa-chevron-left"})})}),(0,d.jsxs)(u.A,{xs:"12",sm:"4",className:"paginator",children:[(0,d.jsx)("i",{className:"fa fa-book me-2"}),(0,d.jsx)(r.A,{className:"mb-2",type:"number",value:a+1||1,min:1,max:i,onChange:e=>s(e.target.value?Number(e.target.value)-1:0)}),(0,d.jsxs)("div",{className:"page-count",children:["\xa0/\xa0",m?(0,d.jsx)("i",{className:"fa fa-spinner fa-spin"}):i]})]}),(0,d.jsx)(u.A,{xs:"12",sm:"4",className:"page-size",children:(0,d.jsx)(r.A,{className:"mb-2",type:"select",onChange:e=>{s(0),setTimeout((()=>l(e.target.value)),1e3)},children:[20,50,100,250].map((e=>(0,d.jsxs)("option",{value:e,children:[e," rows"]},e)))})}),(0,d.jsx)(u.A,{xs:"12",sm:"2",className:"next",children:(0,d.jsx)(p.A,{className:"mb-2 pull-right btn-pagination",block:!0,color:"purple",onClick:o,disabled:!i||!h,children:(0,d.jsx)("i",{className:"fa fa-chevron-right"})})})]})};const v=function(e){let{prepareRow:t,row:n,onRowClick:a=!1}=e;return t(n),(0,d.jsx)(c.A,{onClick:()=>a&&a(n.original),className:"g-0",children:n.cells.map((e=>(0,d.jsx)(u.A,{className:-1!==e.column.id.indexOf("hdb-narrow")?"action":"",children:e.render("Cell")},"".concat(e.row.id,"-").concat(e.column.id))))})};var b=n(3628),_=n(3150);function x(e){let{value:t}=e;return(0,d.jsx)("div",{className:"text-renderer",children:t})}function j(e){let{src:t}=e;const[n,s]=(0,a.useState)(!1),[r,l]=(0,a.useState)(!1);return(0,d.jsxs)("div",{className:"image-renderer",onMouseEnter:()=>s(!0),onMouseLeave:()=>s(!1),children:[(0,d.jsx)("i",{className:"fa fa-image"}),n&&r?(0,d.jsxs)("div",{className:"preview-image no-image",children:[(0,d.jsx)("i",{className:"fa fa-ban text-danger"}),(0,d.jsx)("div",{className:"mt-2",children:"image failed to load"})]}):n?(0,d.jsx)("img",{onError:l,alt:t,src:t,className:"preview-image"}):null]})}const A={Filter:e=>{let{column:{filterValue:t,setFilter:n}}=e;return(0,d.jsx)(r.A,{type:"text",value:t||"",onChange:e=>n(e.target.value||void 0)})},Cell:e=>{let{value:t}=e;return(e=>{switch(Object.prototype.toString.call(e)){case"[object Array]":case"[object Object]":return(0,d.jsx)(x,{value:JSON.stringify(e)});case"[object Boolean]":return(0,d.jsx)(x,{value:e?"true":"false"});case"[object String]":return(t=e)&&(t.match(/^https?.*\.(jpeg|jpg|gif|png)$/)||-1!==t.indexOf("data:image"))?(0,d.jsx)(j,{src:e}):(0,d.jsx)(x,{value:e});default:return(0,d.jsx)(x,{value:e})}var t})(t)}};const N=function(e){let{columns:t,data:n,error:r,currentPage:i,pageSize:o,totalPages:c,onFilteredChange:u,onSortedChange:h,onPageChange:p,onPageSizeChange:x,showFilter:j,onRowClick:N,sorted:k,loading:y,dynamicAttributesFromDataTable:w,tableDescriptionAttributes:C,manual:S=!1}=e;const{headerGroups:P,page:O,rows:E,prepareRow:T,state:R,setAllFilters:F,canPreviousPage:M,canNextPage:I,pageOptions:L,pageCount:U,gotoPage:z,nextPage:D,previousPage:$,setPageSize:G}=(0,s.useTable)({columns:t,data:n,defaultColumn:A,onFilteredChange:u,onSortedChange:h,onPageChange:p,onPageSizeChange:x,onRowClick:N,manualPagination:S,manualFilters:S,initialState:{pageIndex:i,pageSize:o}},s.useFilters,s.usePagination),[B,X]=(0,a.useState)(!0),H=S||!O.length?E:O;return(0,a.useEffect)((()=>{!j&&R.filters.length?F([]):u(R.filters)}),[R.filters,j]),(0,a.useEffect)((()=>{setTimeout((()=>X(!1)),100)}),[null===H||void 0===H?void 0:H.length]),(0,d.jsxs)(l.tH,{onError:(e,t)=>(0,b.A)({error:{message:e.message,componentStack:t}}),FallbackComponent:_.A,children:[(0,d.jsxs)("div",{className:"react-table-scroller",children:[(0,d.jsx)(m,{headerGroups:P,tableDescriptionAttributes:C,dynamicAttributesFromDataTable:w,onSortedChange:h,sorted:k,showFilter:j}),y||B?(0,d.jsx)("div",{className:"centered text-center",children:(0,d.jsx)("i",{className:"fa fa-spinner fa-spin"})}):H.length?H.map((e=>(0,d.jsx)(v,{row:e,prepareRow:T,onRowClick:N},e.id))):(0,d.jsxs)("div",{className:"centered text-center",children:[(0,d.jsx)("i",{className:"fa fa-exclamation-triangle text-danger"}),(0,d.jsx)("div",{className:"mt-2 text-darkgrey",children:r?"Error loading data: ".concat(r):"no records"})]})]}),S?(0,d.jsx)(g,{page:i,pageSize:o,totalPages:c,onPageChange:p,onPageSizeChange:x,loading:y}):(0,d.jsx)(f,{previousPage:$,pageSize:o,canPreviousPage:M,pageIndex:R.pageIndex,pageOptions:L,gotoPage:z,setPageSize:G,pageCount:U,nextPage:D,canNextPage:I,loading:y})]})}},2765:(e,t,n)=>{n.d(t,{A:()=>s});var a=n(127);const s=async e=>{let{auth:t,url:n,role:s,permission:r}=e;return(0,a.A)({operation:{operation:"add_role",role:s,permission:r},auth:t,url:n})}},8198:(e,t,n)=>{n.d(t,{A:()=>s});var a=n(127);const s=async e=>{let{auth:t,role:n,username:s,password:r,url:l}=e;return(0,a.A)({operation:{operation:"add_user",role:n,username:s,password:r,active:!0},auth:t,url:l})}},8750:(e,t,n)=>{n.d(t,{A:()=>s});var a=n(127);const s=async e=>{let{auth:t,url:n}=e;return(0,a.A)({operation:{operation:"get_configuration"},auth:t,url:n})}},2415:(e,t,n)=>{n.d(t,{A:()=>r});var a=n(127),s=n(5269);const r=async e=>{let{auth:t,url:n}=e;const r=await(0,a.A)({operation:{operation:"list_roles"},auth:t,url:n}),l=[...Array.isArray(r)?r:[]].sort(((e,t)=>e.role.toLowerCase()>t.role.toLowerCase()?1:-1));return s.A.update((e=>{e.roles=l})),l}},8222:(e,t,n)=>{n.d(t,{A:()=>r});var a=n(127),s=n(5269);const r=async e=>{let{auth:t,url:n,signal:r}=e;const l=await(0,a.A)({operation:{operation:"list_users"},auth:t,url:n,signal:r}),i=Array.isArray(l)?[...l].map((e=>({username:e.username,role:e.role.role}))).sort(((e,t)=>e.username.toLowerCase()>t.username.toLowerCase()?1:-1)):[];return s.A.update((e=>{e.users=i})),i}},2010:(e,t,n)=>{n.d(t,{A:()=>r});var a=n(127),s=n(5269);const r=async e=>{let{auth:t,url:n}=e;return s.A.update((e=>{e.restarting=!0})),(0,a.A)({operation:{operation:"restart"},auth:t,url:n})}},1534:(e,t,n)=>{n.d(t,{A:()=>r});var a=n(127),s=n(5269);const r=async e=>{let{auth:t,url:n,service:r=null}=e;return r?(s.A.update((e=>{e.restarting_service=r})),(0,a.A)({operation:{operation:"restart_service",service:r},auth:t,url:n})):{error:!0,message:"You must specify a service"}}},4834:(e,t,n)=>{n.d(t,{A:()=>i});var a=n(9379),s=n(45),r=n(127);const l=["auth","url"],i=async e=>{let{auth:t,url:n}=e,i=(0,s.A)(e,l);return(0,r.A)({operation:(0,a.A)({operation:"set_configuration"},i),auth:t,url:n})}},6177:(e,t,n)=>{n.d(t,{A:()=>o});var a=n(8750),s=n(2415),r=n(8222),l=n(717),i=n(127);const o=async e=>{var t,n,o,c,u,d,h;let{auth:m,url:p}=e;const g=await(0,a.A)({auth:m,url:p}),f=await(0,l.A)({auth:m,url:p}),v=await(async e=>{let{auth:t,url:n}=e;return(0,i.A)({operation:{operation:"cluster_status"},auth:t,url:n})})({auth:m,url:p}),b=parseFloat(null===f||void 0===f?void 0:f.version)>=4?"nats":"socketcluster",_=await(0,s.A)({auth:m,url:p});let x=!1;_.error||(x=_.find((e=>e.permission.cluster_user)));const j=await(0,r.A)({auth:m,url:p});let A=!1;j.error||(A=x&&j.find((e=>e.role===x.role)));const N="nats"===b?null===(t=g.clustering)||void 0===t?void 0:t.enabled:g.CLUSTERING,k="nats"===b?null===(n=g.clustering)||void 0===n?void 0:n.user:g.CLUSTERING_USER,y="nats"===b?null===(o=g.clustering)||void 0===o||null===(c=o.hubServer)||void 0===c||null===(u=c.cluster)||void 0===u||null===(d=u.network)||void 0===d?void 0:d.port:g.CLUSTERING_PORT,w="nats"===b?null===(h=g.clustering)||void 0===h?void 0:h.nodeName:g.NODE_NAME;return{is_ready:!!N&&!!A&&!!k&&!!x&&!!y&&!!w,cluster_role:x,cluster_user:A,is_enabled:N,config_cluster_user:k,config_cluster_port:y,node_name:w,engine:b,status:null===v||void 0===v?void 0:v.status,message:null===v||void 0===v?void 0:v.message,connections:null===v||void 0===v?void 0:v.connections}}},2414:e=>{var t=function(e){return function(e){return!!e&&"object"===typeof e}(e)&&!function(e){var t=Object.prototype.toString.call(e);return"[object RegExp]"===t||"[object Date]"===t||function(e){return e.$$typeof===n}(e)}(e)};var n="function"===typeof Symbol&&Symbol.for?Symbol.for("react.element"):60103;function a(e,t){return!1!==t.clone&&t.isMergeableObject(e)?o((n=e,Array.isArray(n)?[]:{}),e,t):e;var n}function s(e,t,n){return e.concat(t).map((function(e){return a(e,n)}))}function r(e){return Object.keys(e).concat(function(e){return Object.getOwnPropertySymbols?Object.getOwnPropertySymbols(e).filter((function(t){return Object.propertyIsEnumerable.call(e,t)})):[]}(e))}function l(e,t){try{return t in e}catch(n){return!1}}function i(e,t,n){var s={};return n.isMergeableObject(e)&&r(e).forEach((function(t){s[t]=a(e[t],n)})),r(t).forEach((function(r){(function(e,t){return l(e,t)&&!(Object.hasOwnProperty.call(e,t)&&Object.propertyIsEnumerable.call(e,t))})(e,r)||(l(e,r)&&n.isMergeableObject(t[r])?s[r]=function(e,t){if(!t.customMerge)return o;var n=t.customMerge(e);return"function"===typeof n?n:o}(r,n)(e[r],t[r],n):s[r]=a(t[r],n))})),s}function o(e,n,r){(r=r||{}).arrayMerge=r.arrayMerge||s,r.isMergeableObject=r.isMergeableObject||t,r.cloneUnlessOtherwiseSpecified=a;var l=Array.isArray(n);return l===Array.isArray(e)?l?r.arrayMerge(e,n,r):i(e,n,r):a(n,r)}o.all=function(e,t){if(!Array.isArray(e))throw new Error("first argument should be an array");return e.reduce((function(e,n){return o(e,n,t)}),{})};var c=o;e.exports=c},4010:(e,t,n)=>{Object.defineProperty(t,"__esModule",{value:!0});var a,s=n(9950),r=(a=s)&&a.__esModule?a:{default:a};t.default=function(){return r.default.createElement("svg",{width:"14",height:"11",viewBox:"0 0 14 11"},r.default.createElement("path",{d:"M11.264 0L5.26 6.004 2.103 2.847 0 4.95l5.26 5.26 8.108-8.107L11.264 0",fill:"#fff",fillRule:"evenodd"}))}},1110:(e,t,n)=>{var a=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var a in n)Object.prototype.hasOwnProperty.call(n,a)&&(e[a]=n[a])}return e},s=function(){function e(e,t){for(var n=0;n<t.length;n++){var a=t[n];a.enumerable=a.enumerable||!1,a.configurable=!0,"value"in a&&(a.writable=!0),Object.defineProperty(e,a.key,a)}}return function(t,n,a){return n&&e(t.prototype,n),a&&e(t,a),t}}(),r=n(9950),l=h(r),i=h(n(8738)),o=h(n(1942)),c=h(n(4010)),u=h(n(4990)),d=n(6104);function h(e){return e&&e.__esModule?e:{default:e}}var m=function(e){function t(e){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,t);var n=function(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!==typeof t&&"function"!==typeof t?e:t}(this,(t.__proto__||Object.getPrototypeOf(t)).call(this,e));return n.handleClick=n.handleClick.bind(n),n.handleTouchStart=n.handleTouchStart.bind(n),n.handleTouchMove=n.handleTouchMove.bind(n),n.handleTouchEnd=n.handleTouchEnd.bind(n),n.handleFocus=n.handleFocus.bind(n),n.handleBlur=n.handleBlur.bind(n),n.previouslyChecked=!(!e.checked&&!e.defaultChecked),n.state={checked:!(!e.checked&&!e.defaultChecked),hasFocus:!1},n}return function(e,t){if("function"!==typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}(t,e),s(t,[{key:"componentDidUpdate",value:function(e){e.checked!==this.props.checked&&this.setState({checked:!!this.props.checked})}},{key:"handleClick",value:function(e){if(!this.props.disabled){var t=this.input;if(e.target!==t&&!this.moved)return this.previouslyChecked=t.checked,e.preventDefault(),t.focus(),void t.click();var n=this.props.hasOwnProperty("checked")?this.props.checked:t.checked;this.setState({checked:n})}}},{key:"handleTouchStart",value:function(e){this.props.disabled||(this.startX=(0,d.pointerCoord)(e).x,this.activated=!0)}},{key:"handleTouchMove",value:function(e){if(this.activated&&(this.moved=!0,this.startX)){var t=(0,d.pointerCoord)(e).x;this.state.checked&&t+15<this.startX?(this.setState({checked:!1}),this.startX=t,this.activated=!0):t-15>this.startX&&(this.setState({checked:!0}),this.startX=t,this.activated=t<this.startX+5)}}},{key:"handleTouchEnd",value:function(e){if(this.moved){var t=this.input;if(e.preventDefault(),this.startX){var n=(0,d.pointerCoord)(e).x;!0===this.previouslyChecked&&this.startX+4>n?this.previouslyChecked!==this.state.checked&&(this.setState({checked:!1}),this.previouslyChecked=this.state.checked,t.click()):this.startX-4<n&&this.previouslyChecked!==this.state.checked&&(this.setState({checked:!0}),this.previouslyChecked=this.state.checked,t.click()),this.activated=!1,this.startX=null,this.moved=!1}}}},{key:"handleFocus",value:function(e){var t=this.props.onFocus;t&&t(e),this.setState({hasFocus:!0})}},{key:"handleBlur",value:function(e){var t=this.props.onBlur;t&&t(e),this.setState({hasFocus:!1})}},{key:"getIcon",value:function(e){var n=this.props.icons;return n?void 0===n[e]?t.defaultProps.icons[e]:n[e]:null}},{key:"render",value:function(){var e=this,t=this.props,n=t.className,s=(t.icons,function(e,t){var n={};for(var a in e)t.indexOf(a)>=0||Object.prototype.hasOwnProperty.call(e,a)&&(n[a]=e[a]);return n}(t,["className","icons"])),r=(0,i.default)("react-toggle",{"react-toggle--checked":this.state.checked,"react-toggle--focus":this.state.hasFocus,"react-toggle--disabled":this.props.disabled},n);return l.default.createElement("div",{className:r,onClick:this.handleClick,onTouchStart:this.handleTouchStart,onTouchMove:this.handleTouchMove,onTouchEnd:this.handleTouchEnd},l.default.createElement("div",{className:"react-toggle-track"},l.default.createElement("div",{className:"react-toggle-track-check"},this.getIcon("checked")),l.default.createElement("div",{className:"react-toggle-track-x"},this.getIcon("unchecked"))),l.default.createElement("div",{className:"react-toggle-thumb"}),l.default.createElement("input",a({},s,{ref:function(t){e.input=t},onFocus:this.handleFocus,onBlur:this.handleBlur,className:"react-toggle-screenreader-only",type:"checkbox"})))}}]),t}(r.PureComponent);t.A=m,m.displayName="Toggle",m.defaultProps={icons:{checked:l.default.createElement(c.default,null),unchecked:l.default.createElement(u.default,null)}},m.propTypes={checked:o.default.bool,disabled:o.default.bool,defaultChecked:o.default.bool,onChange:o.default.func,onFocus:o.default.func,onBlur:o.default.func,className:o.default.string,name:o.default.string,value:o.default.string,id:o.default.string,"aria-labelledby":o.default.string,"aria-label":o.default.string,icons:o.default.oneOfType([o.default.bool,o.default.shape({checked:o.default.node,unchecked:o.default.node})])}},6104:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.pointerCoord=function(e){if(e){var t=e.changedTouches;if(t&&t.length>0){var n=t[0];return{x:n.clientX,y:n.clientY}}var a=e.pageX;if(void 0!==a)return{x:a,y:e.pageY}}return{x:0,y:0}}},4990:(e,t,n)=>{Object.defineProperty(t,"__esModule",{value:!0});var a,s=n(9950),r=(a=s)&&a.__esModule?a:{default:a};t.default=function(){return r.default.createElement("svg",{width:"10",height:"10",viewBox:"0 0 10 10"},r.default.createElement("path",{d:"M9.9 2.12L7.78 0 4.95 2.828 2.12 0 0 2.12l2.83 2.83L0 7.776 2.123 9.9 4.95 7.07 7.78 9.9 9.9 7.776 7.072 4.95 9.9 2.12",fill:"#fff",fillRule:"evenodd"}))}}}]);
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";(self.webpackChunkharperdb_studio=self.webpackChunkharperdb_studio||[]).push([[741],{7368:(e,t,s)=>{s.r(t),s.d(t,{default:()=>Z});var n=s(9950),a=s(7176),i=s(6114),r=s(3452),c=s(4084),o=s(8156),l=s(6713),d=s(5077),u=s(9435),m=s(9163),p=s.n(m),h=s(5269),_=s(5553),x=s(9379),A=s(8547),v=s(7348),j=s(5996),g=s(4414);const f=function(e){let{which:t,compute:s,storage:n,total:r}=e;return(0,g.jsx)(c.A,{className:"my-3",children:(0,g.jsxs)(o.A,{className:"p-2 text-small",children:[(0,g.jsxs)(a.A,{children:[(0,g.jsxs)(i.A,{xs:"6",className:"text-nowrap",children:["Compute","compute"===t&&" (new)"]}),(0,g.jsx)(i.A,{xs:"6",className:"text-nowrap text-end text-truncate",children:s}),(0,g.jsx)(i.A,{xs:"12",children:(0,g.jsx)("hr",{className:"my-1"})})]}),(0,g.jsxs)(a.A,{children:[(0,g.jsxs)(i.A,{xs:"6",className:"text-nowrap",children:["Storage","storage"===t&&" (new)"]}),(0,g.jsx)(i.A,{xs:"6",className:"text-nowrap text-end text-truncate",children:n}),(0,g.jsx)(i.A,{xs:"12",children:(0,g.jsx)("hr",{className:"my-1"})})]}),(0,g.jsxs)(a.A,{children:[(0,g.jsx)(i.A,{xs:"6",className:"text-nowrap",children:(0,g.jsx)("b",{children:"New Total"})}),(0,g.jsx)(i.A,{xs:"6",className:"text-nowrap text-end text-truncate",children:(0,g.jsx)("b",{children:r})})]})]})})};var b=s(5887),y=s(1943),w=s(2714);const O=async e=>(0,w.A)({endpoint:"updateInstance",method:"POST",payload:Object.entries({stripe_plan_id:e.stripe_plan_id,compute_stack_id:e.compute_stack_id,customer_id:e.customer_id,data_volume_size:e.data_volume_size,stripe_storage_plan_id:e.stripe_storage_plan_id,compute_subscription_id:e.compute_subscription_id,storage_subscription_id:e.storage_subscription_id}).reduce(((e,t)=>{let[s,n]=t;return null==n||(e[s]=n),e}),{}),auth:e.auth});var N=s(4549);const k=function(e){let{setInstanceAction:t,showPrepaidStorage:s}=e;const{customer_id:u,compute_stack_id:m}=(0,d.g)(),w=(0,d.Zp)(),k=(0,v.MW)(),C=(0,l.O$)(_.A,(e=>e.auth)),S=(0,l.O$)(_.A,(e=>e.hasCard)),E=(0,l.O$)(_.A,(e=>{var t,s;return"invoice.payment_failed"===(null===(t=e.customer)||void 0===t||null===(s=t.current_payment_status)||void 0===s?void 0:s.status)})),P=(0,l.O$)(h.A,(e=>e.compute)),T=(0,l.O$)(h.A,(e=>e.storage)),$=(0,l.O$)(h.A,(e=>e.is_local)),R=(0,l.O$)(h.A,(e=>!["CREATE_COMPLETE","UPDATE_COMPLETE"].includes(e.status))),I=(0,l.O$)(h.A,(e=>e.last_volume_resize)),z=(0,l.O$)(h.A,(e=>e.data_volume_size)),D=(0,l.O$)(_.A,(e=>e.products.cloud_storage.filter((e=>e.value.data_volume_size>=(null===T||void 0===T?void 0:T.data_volume_size))))),L=(0,l.O$)(_.A,(e=>e.subscriptions.cloud_storage.filter((e=>(e.value.data_volume_size===z||e.value.storage_quantity_available>=e.value.data_volume_size)&&e.value.data_volume_size>=(null===T||void 0===T?void 0:T.data_volume_size))))),[F,M]=(0,n.useState)({}),[U,H]=(0,n.useState)((0,x.A)({compute_stack_id:m,customer_id:u},T)),[B,W]=(0,n.useState)(!1),q=s?L:D,V=q.find((e=>e.value.data_volume_size===U.data_volume_size&&e.value.stripe_storage_plan_id===U.stripe_storage_plan_id&&e.value.storage_subscription_id===U.storage_subscription_id)),Y=C.orgs.filter((e=>C.user_id===e.owner_user_id)).reduce(((e,t)=>e+t.free_cloud_instance_count),0)<j.A.free_cloud_instance_limit,Z=((null===U||void 0===U?void 0:U.storage_price)||0)+((null===P||void 0===P?void 0:P.compute_price)||0),G=Z?"".concat((0,N.A)(Z.toFixed(2)),"/").concat(P.compute_interval):"FREE",K=!I||(Date.now()-new Date(I).getTime())/1e3/3600>6,J=()=>H((0,x.A)({compute_stack_id:m,customer_id:u},T));return p()(J,[s]),p()((()=>{W((null===T||void 0===T?void 0:T.data_volume_size)!==U.data_volume_size||(null===T||void 0===T?void 0:T.stripe_storage_plan_id)!==U.stripe_storage_plan_id||(null===T||void 0===T?void 0:T.storage_subscription_id)!==U.storage_subscription_id)}),[U]),p()((()=>{W(!1)}),[m]),p()((async()=>{const{submitted:e}=F;if(e){t("Updating");(await O((0,x.A)({auth:C},U))).error?(k.error("There was an error updating your instance. Please try again later."),t(!1)):(window._kmq&&window._kmq.push(["record","upgrade instance - disk size",{totalPrice:null===U||void 0===U?void 0:U.compute_price,currency:"USD",products:[{name:"storage",id:V.data_volume_size_string,price:(null===U||void 0===U?void 0:U.storage_price)||0}]}]),k.success("Instance update initialized successfully"),_.A.update((e=>{e.lastUpdate=Date.now()})),setTimeout((()=>w("/o/".concat(u,"/instances"))),100))}}),[F]),R?(0,g.jsx)(c.A,{className:"error",children:(0,g.jsx)(o.A,{children:"instance updating. please wait."})}):(0,g.jsxs)(g.Fragment,{children:[(0,g.jsx)(A.Ay,{className:"react-select-container",classNamePrefix:"react-select",onChange:e=>{let{value:t}=e;return H((0,x.A)((0,x.A)({},U),t))},options:q.filter((e=>e.value.active)),value:V,defaultValue:T,isSearchable:!1,isClearable:!1,isLoading:!q,placeholder:"Select Data Volume Size",styles:{placeholder:e=>(0,x.A)((0,x.A)({},e),{},{textAlign:"center",width:"100%",color:"#BCBCBC"})}}),!B||U.storage_subscription_id||Z||$||Y?B&&!K?(0,g.jsx)(c.A,{className:"error mt-3 text-start",children:(0,g.jsxs)(o.A,{children:["You may update disk size every 6 hours",(0,g.jsx)("br",{}),(0,g.jsx)("br",{}),"Last resize: ",new Date(I).toLocaleTimeString(),(0,g.jsx)("br",{}),(0,g.jsx)("br",{}),"Try again at: ",new Date(new Date(I).getTime()+216e5).toLocaleTimeString()]})}):B&&(null!==U&&void 0!==U&&U.storage_price||null!==P&&void 0!==P&&P.compute_price)&&E?(0,g.jsxs)("div",{className:"mt-3",children:[(0,g.jsx)(b.A,{}),(0,g.jsx)(y.A,{disabled:!B||F.submitted,label:"Update Credit Card",onClick:()=>w("/o/".concat(u,"/billing?returnURL=/").concat(u,"/i/").concat(m,"/config"))})]}):B&&(null!==U&&void 0!==U&&U.storage_price||null!==P&&void 0!==P&&P.compute_price)&&!S?(0,g.jsx)(y.A,{disabled:!B||F.submitted,label:"Add Credit Card To Account",onClick:()=>w("/o/".concat(u,"/billing?returnURL=/").concat(u,"/i/").concat(m,"/config"))}):B?(0,g.jsxs)(g.Fragment,{children:[(0,g.jsx)(f,{which:"storage",compute:null===P||void 0===P?void 0:P.compute_price_string_with_interval,storage:(null===U||void 0===U?void 0:U.storage_price_string_with_interval)||"FREE",total:G}),(0,g.jsxs)(a.A,{children:[(0,g.jsx)(i.A,{children:(0,g.jsx)(r.A,{id:"cancelChange",onClick:J,title:"Cancel",block:!0,disabled:F.submitted,color:"grey",children:"Cancel"})}),(0,g.jsx)(i.A,{children:(0,g.jsx)(r.A,{id:"confirmChange",onClick:()=>M({submitted:!0}),title:"Confirm Instance Details",block:!0,disabled:!B||F.submitted,color:"success",children:"Update"})})]})]}):null:(0,g.jsx)(c.A,{className:"error mt-3",children:(0,g.jsxs)(o.A,{children:["You are limited to ",j.A.free_cloud_instance_limit," free cloud instance",1!==j.A.free_cloud_instance_limit?"s":""]})})]})};const C=function(e){let{setInstanceAction:t,showPrepaidCompute:s}=e;const{customer_id:u,compute_stack_id:m}=(0,d.g)(),w=(0,d.Zp)(),k=(0,v.MW)(),C=(0,l.O$)(_.A,(e=>e.auth)),S=(0,l.O$)(_.A,(e=>e.hasCard)),E=(0,l.O$)(_.A,(e=>{var t,s;return"invoice.payment_failed"===(null===(t=e.customer)||void 0===t||null===(s=t.current_payment_status)||void 0===s?void 0:s.status)})),P=(0,l.O$)(h.A,(e=>e.compute)),T=(0,l.O$)(h.A,(e=>e.storage)),$=(0,l.O$)(h.A,(e=>e.is_local)),R=(0,l.O$)(h.A,(e=>e.wavelength_zone_id)),I=(0,l.O$)(h.A,(e=>e.compute_subscription_id)),z=(0,l.O$)(h.A,(e=>!["CREATE_COMPLETE","UPDATE_COMPLETE"].includes(e.status))),D=(0,l.O$)(_.A,(e=>{var t;return null===(t=e.customer)||void 0===t?void 0:t.is_unpaid})),L=(0,l.O$)(_.A,(e=>e.products[$?"local_compute":R?"wavelength_compute":"cloud_compute"])),F=(0,l.O$)(_.A,(e=>e.subscriptions[$?"local_compute":R?"wavelength_compute":"cloud_compute"].filter((e=>e.value.compute_subscription_id===I||e.value.compute_quantity_available)))),[M,U]=(0,n.useState)({}),[H,B]=(0,n.useState)((0,x.A)({compute_stack_id:m,customer_id:u},P)),[W,q]=(0,n.useState)(!1),V=s?F:L,Y=V.find((e=>e.value.stripe_plan_id===H.stripe_plan_id&&e.value.compute_subscription_id===H.compute_subscription_id)),Z=C.orgs.filter((e=>C.user_id===e.owner_user_id)).reduce(((e,t)=>e+t.free_cloud_instance_count),0)<j.A.free_cloud_instance_limit,G=((null===T||void 0===T?void 0:T.storage_price)||0)+((null===H||void 0===H?void 0:H.compute_price)||0),K=G?"".concat((0,N.A)(G.toFixed(2)),"/").concat(P.compute_interval):"FREE",J=()=>B((0,x.A)({compute_stack_id:m,customer_id:u},P));return p()(J,[s]),p()((()=>{q((null===P||void 0===P?void 0:P.stripe_plan_id)!==H.stripe_plan_id||H.compute_subscription_id!==(null===P||void 0===P?void 0:P.compute_subscription_id))}),[H]),p()((()=>{q(!1)}),[m]),p()((async()=>{const{submitted:e}=M;if(e)if(G||H.compute_subscription_id||$||Z){t("Updating");(await O((0,x.A)({auth:C},H))).error?(k.error("There was an error updating your instance. Please try again later."),t(!1)):(window._kmq&&window._kmq.push(["record","upgrade instance - RAM",{totalPrice:null===H||void 0===H?void 0:H.compute_price,currency:"USD",products:[{name:"compute",id:Y.compute_ram_string,price:(null===H||void 0===H?void 0:H.compute_price)||0}]}]),k.success("Instance update initialized successfully"),_.A.update((e=>{e.lastUpdate=Date.now()})),setTimeout((()=>w("/o/".concat(u,"/instances"))),100))}else k.error("You are limited to ".concat(j.A.free_cloud_instance_limit," free cloud instance").concat(1!==j.A.free_cloud_instance_limit?"s":"")),J(),U({})}),[M]),z?(0,g.jsx)(c.A,{className:"error",children:(0,g.jsx)(o.A,{children:"instance updating. please wait."})}):(0,g.jsxs)(g.Fragment,{children:[(0,g.jsx)(A.Ay,{className:"react-select-container",classNamePrefix:"react-select",onChange:e=>{let{value:t}=e;return B((0,x.A)((0,x.A)({},H),t))},options:V.filter((e=>e.value.active)),value:Y,defaultValue:P,isSearchable:!1,isClearable:!1,isLoading:!V,placeholder:"select a RAM allotment",styles:{placeholder:e=>(0,x.A)((0,x.A)({},e),{},{textAlign:"center",width:"100%",color:"#BCBCBC"})}}),!W||G||H.compute_subscription_id||$||Z?W&&(null!==T&&void 0!==T&&T.storage_price||null!==H&&void 0!==H&&H.compute_price)&&E?(0,g.jsxs)("div",{className:"mt-3",children:[(0,g.jsx)(b.A,{}),(0,g.jsx)(y.A,{disabled:!W||M.submitted,label:"Update Credit Card",onClick:()=>w("/o/".concat(u,"/billing?returnURL=/").concat(u,"/i/").concat(m,"/config"))})]}):W&&(null!==T&&void 0!==T&&T.storage_price||null!==H&&void 0!==H&&H.compute_price)&&!S&&!D?(0,g.jsx)(y.A,{disabled:!W||M.submitted,label:"Add Credit Card To Account",onClick:()=>w("/o/".concat(u,"/billing?returnURL=/").concat(u,"/i/").concat(m,"/config"))}):W?(0,g.jsxs)(g.Fragment,{children:[(0,g.jsx)(f,{which:"compute",compute:H.compute_price_string_with_interval,storage:(null===T||void 0===T?void 0:T.storage_price_string_with_interval)||"FREE",total:K}),(0,g.jsxs)(a.A,{children:[(0,g.jsx)(i.A,{children:(0,g.jsx)(r.A,{id:"cancelChange",onClick:J,title:"Cancel",block:!0,disabled:M.submitted,color:"grey",children:"Cancel"})}),(0,g.jsx)(i.A,{children:(0,g.jsx)(r.A,{id:"confirmChange",onClick:()=>U({submitted:!0}),title:"Confirm Instance Details",block:!0,disabled:!W||M.submitted,color:"success",children:"Update"})})]})]}):null:(0,g.jsx)(c.A,{className:"error mt-2",children:(0,g.jsxs)(o.A,{children:["You are limited to ",j.A.free_cloud_instance_limit," free cloud instance",1!==j.A.free_cloud_instance_limit?"s":""]})})]})};var S=s(5488),E=s(6404);const P=function(e){let{setInstanceAction:t}=e;const{customer_id:s,compute_stack_id:u}=(0,d.g)(),m=(0,d.Zp)(),x=(0,v.MW)(),A=(0,l.O$)(_.A,(e=>e.auth)),j=(0,l.O$)(h.A,(e=>e.instance_name)),f=(0,l.O$)(h.A,(e=>e.is_local)),b=(0,l.O$)(h.A,(e=>e.wavelength_zone_id)),y=(0,l.O$)(h.A,(e=>!["CREATE_COMPLETE","UPDATE_COMPLETE"].includes(e.status))),[w,O]=(0,n.useState)({}),[N,k]=(0,n.useState)({});return p()((async()=>{const{submitted:e}=w;if(e){const{delete_instance_name:e}=N;if(j!==e)O({error:"instance name is not correct"});else{t("Removing");(await(0,E.A)({auth:A,customer_id:s,compute_stack_id:u,wavelength_zone_id:b})).error?(x.error("There was an error removing your instance. Please try again later."),t(!1)):(x.success("Instance deletion initiated"),_.A.update((e=>{e.lastUpdate=Date.now()})),setTimeout((()=>m("/o/".concat(s,"/instances"))),3e3))}}}),[w]),y?(0,g.jsx)(c.A,{className:"error",children:(0,g.jsx)(o.A,{children:"instance updating. please wait."})}):(0,g.jsxs)(g.Fragment,{children:[(0,g.jsx)(S.A,{id:"instance_name_remove",onChange:e=>k({delete_instance_name:e.target.value}),type:"text",title:"instance_name",placeholder:'Enter "'.concat(j,'" here to confirm.'),value:N.delete_instance_name||""}),N.delete_instance_name===j&&(0,g.jsxs)(g.Fragment,{children:[(0,g.jsx)(c.A,{className:"my-2",children:(0,g.jsx)(o.A,{className:"px-2 pb-2 pt-3 text-small",children:f?(0,g.jsxs)("ul",{className:"text-small mb-0",children:[(0,g.jsxs)("li",{children:[(0,g.jsx)("b",{children:"DOES NOT"})," uninstall Harper."]}),(0,g.jsxs)("li",{children:[(0,g.jsx)("b",{children:"DOES"})," leave all your data intact."]}),(0,g.jsx)("li",{children:"REMOVES your instance license."}),(0,g.jsx)("li",{children:"STOPS recurring license charges."}),(0,g.jsx)("li",{children:"LIMITS instance to 1GB RAM."}),(0,g.jsx)("li",{children:"REMOVES instance from the Studio."}),(0,g.jsx)("li",{children:"RESTARTS the instance."})]}):(0,g.jsxs)("ul",{className:"text-small mb-0",children:[(0,g.jsxs)("li",{children:[(0,g.jsx)("b",{children:"THIS IS"})," an irreversible process."]}),(0,g.jsxs)("li",{children:[(0,g.jsx)("b",{children:"IT CANNOT"})," be undone."]}),(0,g.jsx)("li",{children:"DELETES your instance completely."}),(0,g.jsx)("li",{children:"STOPS recurring license charges."}),(0,g.jsx)("li",{children:"REMOVES instance from the Studio."})]})})}),(0,g.jsxs)(a.A,{children:[(0,g.jsx)(i.A,{children:(0,g.jsx)(r.A,{id:"cancelDeleteInstance",onClick:()=>k({delete_instance_name:""}),title:"Cancel",block:!0,disabled:w.submitted,color:"grey",children:"Cancel"})}),(0,g.jsx)(i.A,{children:(0,g.jsx)(r.A,{id:"removeInstance",onClick:()=>O({submitted:!0}),title:"Confirm Instance Details",block:!0,disabled:w.submitted,color:"danger",children:"Remove"})})]})]})]})};var T=s(135),$=s(5911),R=s(2010);const I=function(e){let{instanceAction:t,setInstanceAction:s}=e;const d=(0,v.MW)(),u=(0,l.O$)(h.A,(e=>e.auth)),m=(0,l.O$)(h.A,(e=>e.url)),_=(0,l.O$)(h.A,(e=>e.instance_name)),x=(0,l.O$)(h.A,(e=>!["CREATE_COMPLETE","UPDATE_COMPLETE"].includes(e.status))),[A,f]=(0,n.useState)({}),[b,y]=(0,n.useState)({});return p()((async()=>{const{submitted:e}=A;if(e){s("Restarting");const e=await(0,R.A)({auth:u,url:m});null!==e&&void 0!==e&&e.error&&(s(!1),d.error("There was an error restarting your instance. Please try again later."))}}),[A]),(0,T.A)((()=>{"Restarting"===t&&(async()=>{(await(0,$.A)({auth:u,url:m})).error||(y({}),f({}),s(!1),d.success("Instance restarted successfully"))})()}),j.A.refresh_content_interval),"Restarting"===t?(0,g.jsx)(c.A,{className:"error",children:(0,g.jsxs)(o.A,{children:[(0,g.jsx)("i",{className:"fa fa-spin fa-spinner me-2"}),"instance restarting. please wait."]})}):!j.A.is_local_studio&&x?(0,g.jsx)(c.A,{className:"error",children:(0,g.jsx)(o.A,{children:"instance updating. please wait."})}):(0,g.jsxs)(g.Fragment,{children:[(0,g.jsx)(S.A,{id:"instance_name_restart",onChange:e=>y({restart_instance_name:e.target.value}),type:"text",title:"instance_name",placeholder:'Enter "'.concat(_,'" here to confirm.'),value:b.restart_instance_name||""}),b.restart_instance_name===_&&(0,g.jsxs)(g.Fragment,{children:[(0,g.jsx)(c.A,{className:"my-2",children:(0,g.jsx)(o.A,{className:"px-2 pb-2 pt-3 text-small",children:(0,g.jsxs)("ul",{className:"text-small mb-0",children:[(0,g.jsxs)("li",{children:[(0,g.jsx)("b",{children:"WILL"})," interrupt connectivity."]}),(0,g.jsxs)("li",{children:[(0,g.jsx)("b",{children:"WILL"})," leave all your data intact."]})]})})}),(0,g.jsxs)(a.A,{children:[(0,g.jsx)(i.A,{children:(0,g.jsx)(r.A,{onClick:()=>y({restart_instance_name:""}),title:"Cancel",block:!0,disabled:A.submitted,color:"grey",children:"Cancel"})}),(0,g.jsx)(i.A,{children:(0,g.jsx)(r.A,{onClick:()=>f({submitted:!0}),title:"Confirm Instance Details",block:!0,disabled:A.submitted,color:"danger",children:"Restart"})})]})]})]})};var z=s(1652),D=s(7666);const L=function(e){var t,s,n,r,d,u,m,p,_,x,A,v,f,b,y,w,O,N;let{clusterNodeName:k,instanceConfig:C}=e;const S=(0,l.O$)(h.A,(e=>e.url)),E=(0,l.O$)(h.A,(e=>e.auth)),P=(0,l.O$)(h.A,(e=>e.totalPriceStringWithInterval)),T=(0,l.O$)(h.A,(e=>e.compute)),$=(0,l.O$)(h.A,(e=>!!e.compute_subscription_id)),R=(0,l.O$)(h.A,(e=>!!e.storage_subscription_id)),I=(0,l.O$)(h.A,(e=>e.creation_date)),L=(0,l.O$)(h.A,(e=>e.instance_region)),F=(0,l.O$)(h.A,(e=>e.storage)),M=(0,l.O$)(h.A,(e=>e.is_local)),U=null!==E&&void 0!==E&&E.user?"".concat(btoa("".concat(E.user,":").concat(E.pass))):"...",H=M?"HARDWARE LIMIT":"".concat(null===F||void 0===F?void 0:F.iops),B=I?new Date(I).toLocaleDateString():"N/A",{hostname:W,origin:q}=window.location,V=new URL(j.A.is_local_studio?q:S),Y=j.A.is_local_studio?"".concat(null!==(m=C.operationsApi)&&void 0!==m&&null!==(p=m.network)&&void 0!==p&&p.securePort?"https://":"http://").concat(W,":").concat((null===(_=C.operationsApi)||void 0===_||null===(x=_.network)||void 0===x?void 0:x.securePort)||(null===(A=C.operationsApi)||void 0===A||null===(v=A.network)||void 0===v?void 0:v.port)):"".concat(null!==(t=C.operationsApi)&&void 0!==t&&null!==(s=t.network)&&void 0!==s&&s.securePort?"https://":"http://").concat(V.hostname,":").concat((null===(n=C.operationsApi)||void 0===n||null===(r=n.network)||void 0===r?void 0:r.securePort)||(null===(d=C.operationsApi)||void 0===d||null===(u=d.network)||void 0===u?void 0:u.port)),Z=j.A.is_local_studio?"".concat(null!==(w=C.http)&&void 0!==w&&w.securePort?"https://":"http://").concat(W,":").concat((null===(O=C.http)||void 0===O?void 0:O.securePort)||(null===(N=C.http)||void 0===N?void 0:N.port)):"".concat(null!==(f=C.http)&&void 0!==f&&f.securePort?"https://":"http://").concat(V.hostname,":").concat((null===(b=C.http)||void 0===b?void 0:b.securePort)||(null===(y=C.http)||void 0===y?void 0:y.port)),G=(0,l.O$)(h.A,(e=>{var t;return null===(t=e.registration)||void 0===t?void 0:t.version})),[K,J]=(null===G||void 0===G?void 0:G.split("."))||[],Q=parseFloat("".concat(K,".").concat(J));return(0,g.jsxs)(g.Fragment,{children:[(0,g.jsx)("span",{className:"floating-card-header",children:"instance overview"}),(0,g.jsx)(c.A,{className:"mt-3 mb-4 instance-details",children:(0,g.jsx)(o.A,{children:(0,g.jsxs)(a.A,{children:[(0,g.jsx)(i.A,{md:"4",xs:"12",children:(0,g.jsx)(z.A,{header:"Instance URL",className:"mb-3",children:(0,g.jsx)("div",{className:"nowrap-scroll",children:(0,g.jsx)(D.A,{text:Y})})})}),(0,g.jsx)(i.A,{md:"4",xs:"12",children:(0,g.jsx)(z.A,{header:"".concat(Q>=4.2?"Applications":"Custom Functions"," URL"),className:"mb-3",children:(0,g.jsx)("div",{className:"nowrap-scroll",children:(0,g.jsx)(D.A,{text:Z})})})}),(0,g.jsx)(i.A,{md:"4",xs:"12",children:(0,g.jsx)(z.A,{header:"Instance Node Name (for clustering)",className:"mb-3",children:(0,g.jsx)("div",{className:"nowrap-scroll",children:k?(0,g.jsx)(D.A,{text:k}):"clustering not enabled"})})}),!j.A.is_local_studio&&(0,g.jsxs)(g.Fragment,{children:[(0,g.jsx)(i.A,{md:"4",xs:"12",children:(0,g.jsx)(z.A,{header:"Instance API Auth Header (this user)",className:"mb-3",children:(0,g.jsx)("div",{className:"nowrap-scroll",children:(0,g.jsx)(D.A,{text:U,beforeText:"Basic ",obscure:!0})})})}),(0,g.jsx)(i.A,{md:"2",sm:"4",xs:"6",children:(0,g.jsx)(z.A,{header:"Created",className:"mb-3",children:(0,g.jsx)("div",{className:"nowrap-scroll",children:B})})}),L&&(0,g.jsx)(i.A,{md:"2",sm:"4",xs:"6",children:(0,g.jsx)(z.A,{header:"Region",className:"mb-3",children:(0,g.jsx)("div",{className:"nowrap-scroll",children:L})})}),(0,g.jsx)(i.A,{md:"2",sm:"4",xs:"6",children:(0,g.jsx)(z.A,{header:"Total Price",className:"mb-3",children:(0,g.jsx)("div",{className:"nowrap-scroll",children:P})})}),(0,g.jsx)(i.A,{md:"2",sm:"4",xs:"6",children:(0,g.jsx)(z.A,{header:"RAM",className:"mb-3",children:(0,g.jsxs)("div",{className:"nowrap-scroll",children:[null===T||void 0===T?void 0:T.compute_ram_string," ",$&&"(PREPAID)"]})})}),!M&&(0,g.jsxs)(g.Fragment,{children:[(0,g.jsx)(i.A,{md:"2",sm:"4",xs:"6",children:(0,g.jsx)(z.A,{header:"Storage",className:"mb-3 text-nowrap",children:(0,g.jsxs)("div",{className:"nowrap-scroll",children:[null===F||void 0===F?void 0:F.data_volume_size_string," ",R&&"(PREPAID)"]})})}),(0,g.jsx)(i.A,{md:"2",sm:"4",xs:"6",children:(0,g.jsx)(z.A,{header:"Disk IOPS",className:"mb-3 text-nowrap",children:(0,g.jsx)("div",{className:"nowrap-scroll",children:H})})})]})]})]})})})]})};var F=s(4979),M=s(3150),U=s(3628),H=s(7596),B=s(5012),W=s(2594);const q=function(e){let{instanceConfig:t}=e;const s=(0,l.O$)(_.A,(e=>e.theme));return(0,g.jsx)(W.A,{placeholder:t,height:"calc(100vh - 568px)",theme:"light_mitsuketa_tribute",viewOnly:!0,colors:{background:"transparent",default:"dark"===s?"#aaa":"#000",colon:"dark"===s?"#aaa":"#000",keys:"dark"===s?"#aaa":"#000",string:"#13c664",number:"#ea4c89",primitive:"#ffa500"},style:{warningBox:{display:"none"},body:{padding:"8px 0 0 0"}},locale:B.A,width:"100%",confirmGood:!1,waitAfterKeyPress:3e4})};var V=s(8750);const Y=function(){return(0,g.jsx)("div",{className:"configLoader",children:(0,g.jsx)("i",{className:"fa fa-spinner fa-spin"})})};const Z=function(){const{customer_id:e,compute_stack_id:t}=(0,d.g)(),s=(0,l.O$)(_.A,(e=>e.auth)),m=(0,l.O$)(_.A,(e=>e.theme)),x=(0,l.O$)(h.A,(e=>e.auth),[t]),A=(0,l.O$)(h.A,(e=>e.url),[t]),v=(0,l.O$)(_.A,(e=>{var t;return null===(t=e.customer)||void 0===t?void 0:t.stripe_id})),j=(0,l.O$)(h.A,(e=>e.is_local),[t]),f=(0,l.O$)(h.A,(e=>{var t;return parseFloat(null===(t=e.registration)||void 0===t?void 0:t.version)>=4?"nats":"socketcluster"}),[t]),b=(0,l.O$)(h.A,(e=>e.compute_subscription_id),[t]),y=(0,l.O$)(h.A,(e=>e.storage_subscription_id),[t]),w=(0,l.O$)(_.A,(t=>{var s,n;return null===(s=t.auth)||void 0===s||null===(n=s.orgs)||void 0===n?void 0:n.find((t=>{var s;return(null===(s=t.customer_id)||void 0===s?void 0:s.toString())===e}))}),[e]),O="owner"===(null===w||void 0===w?void 0:w.status),[N,S]=(0,n.useState)(!1),[E,T]=(0,n.useState)(!1),[$,R]=(0,n.useState)(""),z=(0,l.O$)(_.A,(e=>{var t;return(null===(t=e.subscriptions[j?"local_compute":"cloud_compute"])||void 0===t?void 0:t.filter((e=>!e.value.compute_subscription_name||e.value.compute_quantity_available)))||[]})),D=(0,l.O$)(_.A,(e=>{var t,s;return(null===(t=e.subscriptions)||void 0===t||null===(s=t.cloud_storage)||void 0===s?void 0:s.filter((e=>!e.value.storage_subscription_name||e.value.storage_quantity_available)))||[]})),[B,W]=(0,n.useState)(!!b),[Z,G]=(0,n.useState)(!!y);return p()((async()=>{s&&e&&v&&(0,H.A)({auth:s,customer_id:e,stripe_id:v})}),[s,e,v]),p()((async()=>{if(x&&A){R("..."),T(!1);const t=await(0,V.A)({auth:x,url:A});if(!t.error){var e;const s="nats"===f?null===(e=t.clustering)||void 0===e?void 0:e.nodeName:t.NODE_NAME;R(s),T(t)}}}),[x]),N&&"Restarting"!==N?(0,g.jsx)(F.A,{header:"".concat(N," Instance"),spinner:!0}):(0,g.jsxs)(a.A,{id:"config",children:[(0,g.jsx)(i.A,{xs:"12",children:(0,g.jsx)(u.tH,{onError:(e,t)=>(0,U.A)({error:{message:e.message,componentStack:t}}),FallbackComponent:M.A,children:(0,g.jsx)(L,{clusterNodeName:$,instanceConfig:E})})}),O&&"akamai"!==m&&(0,g.jsxs)(i.A,{lg:"3",sm:"6",xs:"12",children:[(0,g.jsxs)(a.A,{children:[(0,g.jsx)(i.A,{children:(0,g.jsx)("span",{className:"floating-card-header",children:"update ram"})}),(0,g.jsx)(i.A,{className:"text-end",children:(!!b||!!z.length)&&(0,g.jsxs)("span",{className:"floating-card-header",children:["prepaid:"," ",(0,g.jsx)(r.A,{id:"showPrepaidCompute",color:"link",onClick:()=>W(!B),children:(0,g.jsx)("i",{className:"fa fa-lg fa-toggle-".concat(B?"on":"off")})})]})})]}),(0,g.jsx)(c.A,{className:"my-3",children:(0,g.jsx)(o.A,{children:(0,g.jsx)(u.tH,{onError:(e,t)=>(0,U.A)({error:{message:e.message,componentStack:t}}),FallbackComponent:M.A,children:E?(0,g.jsx)(C,{setInstanceAction:S,showPrepaidCompute:B}):(0,g.jsx)(Y,{})})})})]}),O&&!j&&"akamai"!==m&&(0,g.jsxs)(i.A,{lg:"3",sm:"6",xs:"12",children:[(0,g.jsxs)(a.A,{children:[(0,g.jsx)(i.A,{children:(0,g.jsx)("span",{className:"floating-card-header",children:"update storage"})}),(0,g.jsx)(i.A,{className:"text-end",children:(!!y||!!D.length)&&(0,g.jsxs)("span",{className:"floating-card-header",children:["prepaid:"," ",(0,g.jsx)(r.A,{id:"showPrepaidStorage",color:"link",onClick:()=>G(!Z),children:(0,g.jsx)("i",{className:"fa fa-lg fa-toggle-".concat(Z?"on":"off")})})]})})]}),(0,g.jsx)(c.A,{className:"my-3",children:(0,g.jsx)(o.A,{children:(0,g.jsx)(u.tH,{onError:(e,t)=>(0,U.A)({error:{message:e.message,componentStack:t}}),FallbackComponent:M.A,children:E?(0,g.jsx)(k,{setInstanceAction:S,showPrepaidStorage:Z}):(0,g.jsx)(Y,{})})})})]}),O&&(0,g.jsxs)(i.A,{lg:"3",sm:"6",xs:"12",children:[(0,g.jsx)("span",{className:"floating-card-header",children:"remove instance"}),(0,g.jsx)(c.A,{className:"my-3",children:(0,g.jsx)(o.A,{children:(0,g.jsx)(u.tH,{onError:(e,t)=>(0,U.A)({error:{message:e.message,componentStack:t}}),FallbackComponent:M.A,children:(0,g.jsx)(P,{setInstanceAction:S,instanceAction:N})})})})]}),(0,g.jsxs)(i.A,{lg:"3",sm:"6",xs:"12",children:[(0,g.jsx)("span",{className:"floating-card-header",children:"restart instance"}),(0,g.jsx)(c.A,{className:"my-3",children:(0,g.jsx)(o.A,{children:(0,g.jsx)(u.tH,{onError:(e,t)=>(0,U.A)({error:{message:e.message,componentStack:t}}),FallbackComponent:M.A,children:(0,g.jsx)(I,{setInstanceAction:S,instanceAction:N})})})})]}),(0,g.jsxs)(i.A,{xs:"12",children:[(0,g.jsx)("span",{className:"floating-card-header",children:"instance config (read only)"}),(0,g.jsx)(c.A,{className:"mt-3 mb-4",children:(0,g.jsx)(o.A,{className:"p-0",children:(0,g.jsx)(u.tH,{onError:(e,t)=>(0,U.A)({error:{message:e.message,componentStack:t}}),FallbackComponent:M.A,children:E?(0,g.jsx)(q,{instanceConfig:E}):(0,g.jsx)(Y,{})})})})]})]})}},5887:(e,t,s)=>{s.d(t,{A:()=>a});s(9950);var n=s(4414);const a=function(){return(0,n.jsxs)("div",{className:"text-danger",children:[(0,n.jsx)("i",{children:"Your most recent card payment failed. Please update your card below."}),(0,n.jsx)("hr",{className:"mt-3 mb-2"})]})}},1652:(e,t,s)=>{s.d(t,{A:()=>a});s(9950);var n=s(4414);const a=function(e){let{children:t,header:s,subheader:a,maxHeight:i="auto",minHeight:r="auto",className:c}=e;return(0,n.jsxs)("div",{className:"content-container ".concat(c),children:[(0,n.jsxs)("div",{className:"header-container",children:[(0,n.jsx)("span",{className:"header",children:s}),(0,n.jsx)("span",{className:"subheader",children:a})]}),(0,n.jsx)("div",{className:"auto"!==i?"scrollable":"",style:{maxHeight:i,minHeight:r},children:t})]})}},7666:(e,t,s)=>{s.d(t,{A:()=>l});var n=s(9950),a=s(7176),i=s(6114),r=s(3452),c=s(7348),o=s(4414);const l=function(e){let{text:t,beforeText:s,afterText:l,obscure:d=!1}=e;const u=(0,c.MW)(),m=navigator.clipboard,p=(0,n.useCallback)((async e=>{e.stopPropagation(),await navigator.clipboard.writeText(t),u.success("Text copied to clipboard")}),[u,t]);return(0,o.jsxs)(a.A,{className:"copyable-text-holder g-0",children:[m&&t&&(0,o.jsx)(i.A,{className:"copy-icon",children:(0,o.jsx)(r.A,{title:"Copy this value",onClick:p,color:"link",children:(0,o.jsx)("i",{className:"fa fa-copy text-small"})})}),(0,o.jsx)(i.A,{className:"text-container",children:t?(0,o.jsxs)(o.Fragment,{children:[s,d?t.replace(/./g,"*"):t,l]}):(0,o.jsx)("span",{children:"\xa0"})})]})}},1943:(e,t,s)=>{s.d(t,{A:()=>i});s(9950);var n=s(3452),a=s(4414);const i=function(e){let{disabled:t,label:s,onClick:i}=e;return(0,a.jsx)(n.A,{onClick:i,title:s,block:!0,disabled:t,color:"danger",className:"mt-2",id:"visitCreditCard",children:s})}},8750:(e,t,s)=>{s.d(t,{A:()=>a});var n=s(127);const a=async e=>{let{auth:t,url:s}=e;return(0,n.A)({operation:{operation:"get_configuration"},auth:t,url:s})}},2010:(e,t,s)=>{s.d(t,{A:()=>i});var n=s(127),a=s(5269);const i=async e=>{let{auth:t,url:s}=e;return a.A.update((e=>{e.restarting=!0})),(0,n.A)({operation:{operation:"restart"},auth:t,url:s})}},6404:(e,t,s)=>{s.d(t,{A:()=>a});var n=s(2714);const a=async e=>{let{auth:t,customer_id:s,compute_stack_id:a,is_verizon:i,is_akamai:r}=e;return(0,n.A)({endpoint:i?"wl/removeWavelengthInstance":r?"removeAkamaiInstance":"removeInstance",method:"POST",payload:{customer_id:s,compute_stack_id:a,compute_stack_wl_id:a},auth:t})}},5488:(e,t,s)=>{s.d(t,{A:()=>g});var n=s(9950),a=s(1942),i=s.n(a),r=s(8738),c=s.n(r),o=s(1497);function l(e){return l="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},l(e)}var d=["className","cssModule","type","bsSize","valid","invalid","tag","addon","plaintext","innerRef"];function u(){return u=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var s=arguments[t];for(var n in s)Object.prototype.hasOwnProperty.call(s,n)&&(e[n]=s[n])}return e},u.apply(this,arguments)}function m(e,t){if(null==e)return{};var s,n,a=function(e,t){if(null==e)return{};var s,n,a={},i=Object.keys(e);for(n=0;n<i.length;n++)s=i[n],t.indexOf(s)>=0||(a[s]=e[s]);return a}(e,t);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);for(n=0;n<i.length;n++)s=i[n],t.indexOf(s)>=0||Object.prototype.propertyIsEnumerable.call(e,s)&&(a[s]=e[s])}return a}function p(e,t){for(var s=0;s<t.length;s++){var n=t[s];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}function h(e,t){return h=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(e,t){return e.__proto__=t,e},h(e,t)}function _(e){var t=function(){if("undefined"===typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"===typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}();return function(){var s,n=A(e);if(t){var a=A(this).constructor;s=Reflect.construct(n,arguments,a)}else s=n.apply(this,arguments);return function(e,t){if(t&&("object"===l(t)||"function"===typeof t))return t;if(void 0!==t)throw new TypeError("Derived constructors may only return object or undefined");return x(e)}(this,s)}}function x(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function A(e){return A=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(e){return e.__proto__||Object.getPrototypeOf(e)},A(e)}var v={children:i().node,type:i().string,size:i().oneOfType([i().number,i().string]),bsSize:i().string,valid:i().bool,invalid:i().bool,tag:o.Wx,innerRef:i().oneOfType([i().object,i().func,i().string]),plaintext:i().bool,addon:i().bool,className:i().string,cssModule:i().object},j=function(e){!function(e,t){if("function"!==typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),Object.defineProperty(e,"prototype",{writable:!1}),t&&h(e,t)}(r,e);var t,s,a,i=_(r);function r(e){var t;return function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,r),(t=i.call(this,e)).getRef=t.getRef.bind(x(t)),t.focus=t.focus.bind(x(t)),t}return t=r,(s=[{key:"getRef",value:function(e){this.props.innerRef&&this.props.innerRef(e),this.ref=e}},{key:"focus",value:function(){this.ref&&this.ref.focus()}},{key:"render",value:function(){var e=this.props,t=e.className,s=e.cssModule,a=e.type,i=void 0===a?"text":a,r=e.bsSize,l=e.valid,p=e.invalid,h=e.tag,_=e.addon,x=e.plaintext,A=e.innerRef,v=m(e,d),j=["switch","radio","checkbox"].indexOf(i)>-1,g="select"===i,f="range"===i,b=h||(g||"textarea"===i?i:"input"),y="form-control";x?(y="".concat(y,"-plaintext"),b=h||"input"):f?y="form-range":g?y="form-select":j&&(y=_?null:"form-check-input"),v.size&&/\D/g.test(v.size)&&((0,o.mc)('Please use the prop "bsSize" instead of the "size" to bootstrap\'s input sizing.'),r=v.size,delete v.size);var w=(0,o.qO)(c()(t,p&&"is-invalid",l&&"is-valid",!!r&&(g?"form-select-".concat(r):"form-control-".concat(r)),y),s);return("input"===b||h&&"function"===typeof h)&&(v.type="switch"===i?"checkbox":i),v.children&&!x&&"select"!==i&&"string"===typeof b&&"select"!==b&&((0,o.mc)('Input with a type of "'.concat(i,'" cannot have children. Please use "value"/"defaultValue" instead.')),delete v.children),n.createElement(b,u({},v,{ref:A,className:w,"aria-invalid":p}))}}])&&p(t.prototype,s),a&&p(t,a),Object.defineProperty(t,"prototype",{writable:!1}),r}(n.Component);j.propTypes=v;const g=j}}]);
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";(self.webpackChunkharperdb_studio=self.webpackChunkharperdb_studio||[]).push([[18],{4016:(e,l,s)=>{s.r(l),s.d(l,{default:()=>E});var a=s(9950),t=s(7176),r=s(6114),n=s(1646),o=s(5488),c=s(3452),i=s(8547),d=s(7348),m=s(6713),u=s(4084),x=s(8156),h=s(6685),g=s(1340),p=s(877),v=s(135),f=s(9435),j=s(5077),b=s(5269),A=s(5553),N=s(5996),w=s(9379),y=s(127);var O=s(7209),S=s(4414);const k=function(e){let{onRowClick:l,level:s,timestamp:a,message:n,tags:o,thread:c}=e;return(0,S.jsxs)(t.A,{xs:"12",md:"12",className:"item-row",onClick:l,children:[(0,S.jsx)(r.A,{xs:"2",md:"1",className:"text-nowrap ".concat(null===s||void 0===s?void 0:s.toLowerCase()),children:(null===s||void 0===s?void 0:s.toUpperCase())||"UNKNOWN"}),(0,S.jsx)(r.A,{xs:"2",md:"2",lg:"1",children:new Date(a||null).toLocaleDateString()}),(0,S.jsx)(r.A,{xs:"2",md:"2",lg:"1",children:new Date(a||null).toLocaleTimeString()}),(0,S.jsx)(r.A,{xs:"2",md:"1",lg:"1",children:c}),(0,S.jsx)(r.A,{xs:"2",md:"2",lg:"1",children:null===o||void 0===o?void 0:o.join(", ")}),(0,S.jsx)(r.A,{xs:"2",md:"4",lg:"7",children:(0,O.A)(n)&&n.error?n.error:(0,S.jsx)("pre",{children:(0,S.jsx)("code",{children:n})})})]})};var L=s(3150),C=s(3628);let F;const T=async e=>{let{auth:l,url:s,logsFilter:a}=e;F=new AbortController,await(async e=>{let{auth:l,url:s,signal:a,logsFilter:t}=e;const r=await(0,y.A)({operation:(0,w.A)((0,w.A)({operation:"read_log",start:0},t),{},{order:"desc"}),auth:l,url:s,signal:a});return b.A.update((e=>{e.logs=r.error?[]:(null===r||void 0===r?void 0:r.filter((e=>e.message)))||[],e.logsError=!1}))})({auth:l,url:s,signal:F.signal,logsFilter:a})};const D=function(e){var l,s,n,o,i;let{logsFilter:d}=e;const{compute_stack_id:w}=(0,j.g)(),y=(0,m.O$)(b.A,(e=>e.auth)),O=(0,m.O$)(b.A,(e=>e.url)),D=(0,m.O$)(b.A,(e=>e.logs),[w]),I=(0,m.O$)(b.A,(e=>e.logsError)),E=(0,m.O$)(A.A,(e=>e.theme)),[U,z]=(0,a.useState)(!1),[P,R]=(0,a.useState)(!0),[_,M]=(0,a.useState)(!0),[$,V]=(0,a.useState)(!1),[W,q]=(0,a.useState)({}),G=()=>V(!$);return(0,a.useEffect)((()=>(y&&(R(!0),T({auth:y,url:O,logsFilter:d}),R(!1)),()=>{var e;null===(e=F)||void 0===e||e.abort()})),[y,_,d]),(0,v.A)((()=>y&&U&&M(Date.now())),N.A.refresh_content_interval),(0,S.jsxs)(f.tH,{onError:(e,l)=>(0,C.A)({error:{message:e.message,componentStack:l}}),FallbackComponent:L.A,children:[(0,S.jsxs)(t.A,{className:"floating-card-header",children:[(0,S.jsx)(r.A,{children:"logs"}),(0,S.jsxs)(r.A,{className:"text-end",children:[(0,S.jsx)(c.A,{color:"link",title:"Update Logs",className:"me-2",onClick:()=>M(Date.now()),children:(0,S.jsx)("i",{className:"fa ".concat(P?"fa-spinner fa-spin":"fa-sync-alt")})}),(0,S.jsxs)(c.A,{color:"link",title:"Turn on auto refresh",onClick:()=>z(!U),children:[(0,S.jsx)("span",{className:"me-2",children:"auto"}),(0,S.jsx)("i",{className:"fa fa-lg fa-toggle-".concat(U?"on":"off")})]})]})]}),(0,S.jsx)(u.A,{className:"my-3",children:(0,S.jsxs)(x.A,{className:"item-list",children:[(0,S.jsxs)(t.A,{xs:"12",md:"12",className:"header",children:[(0,S.jsx)(r.A,{xs:"2",md:"1",className:"text-bold text-nowrap",children:"Status"}),(0,S.jsx)(r.A,{xs:"2",md:"2",lg:"1",className:"text-bold text-nowrap",children:"Date"}),(0,S.jsx)(r.A,{xs:"2",md:"2",lg:"1",className:"text-left text-bold text-nowrap",children:!P&&I?(0,S.jsxs)("span",{className:"text-danger",children:["log fetch error: ",(new Date).toLocaleTimeString().toLowerCase()]}):(0,S.jsx)("span",{children:"Time"})}),(0,S.jsx)(r.A,{xs:"2",md:"1",lg:"1",className:"text-bold text-nowrap",children:"Thread"}),(0,S.jsx)(r.A,{xs:"2",md:"2",lg:"1",className:"text-bold text-nowrap",children:"Tags"}),(0,S.jsx)(r.A,{xs:"2",md:"3",lg:"7",className:"text-bold text-nowrap",children:"Message"})]}),(0,S.jsx)("hr",{className:"mt-1 mb-0"}),(0,S.jsx)("div",{className:"item-scroller",children:!P||D||U?D&&D.length?D.map(((e,l)=>(0,S.jsx)(k,{level:e.level,timestamp:e.timestamp,message:e.message,tags:e.tags,thread:e.thread,onRowClick:()=>{q(e),G()}},e.timestamp+l))):D&&!D.length?(0,S.jsx)("div",{className:"pt-5 text-center",children:"no logs found"}):(0,S.jsx)("div",{className:"pt-5 text-center",children:"no logs found in this view"}):(0,S.jsx)("div",{className:"pt-5 text-center",children:(0,S.jsx)("i",{className:"fa fa-spinner fa-spin text-lightgrey"})})})]})}),(0,S.jsx)("br",{}),(0,S.jsxs)(h.A,{isOpen:$,className:E,centered:!0,fade:!1,id:"log-info-modal",children:[(0,S.jsx)(g.A,{toggle:G,children:"View Log Info"}),(0,S.jsx)(p.A,{children:W&&(0,S.jsxs)("div",{children:[(0,S.jsxs)("p",{children:[(0,S.jsx)("b",{children:"Level:"})," ",(0,S.jsx)("span",{className:"".concat(null===W||void 0===W||null===(l=W.level)||void 0===l?void 0:l.toLowerCase()),children:null===W||void 0===W||null===(s=W.level)||void 0===s?void 0:s.toUpperCase()})]}),(0,S.jsx)("p",{className:"mb-1",children:(0,S.jsx)("b",{children:"Timestamp(UTC):"})}),(0,S.jsx)("span",{children:null===W||void 0===W?void 0:W.timestamp}),(0,S.jsxs)("p",{className:"mt-4",children:[(0,S.jsx)("b",{children:"Thread:"})," ",null===W||void 0===W?void 0:W.thread]}),(0,S.jsxs)("p",{children:[(0,S.jsx)("b",{children:"Tags:"})," ",null===W||void 0===W||null===(n=W.tags)||void 0===n?void 0:n.join(", ")]}),(0,S.jsx)("p",{className:"mb-2",children:(0,S.jsx)("b",{children:"Message:"})}),(0,S.jsx)("pre",{children:null!==W&&void 0!==W&&null!==(o=W.message)&&void 0!==o&&o.error?null===W||void 0===W||null===(i=W.message)||void 0===i?void 0:i.error:null===W||void 0===W?void 0:W.message})]})})]})]})},I={limit:1e3,level:void 0,from:void 0,until:void 0};const E=function(){const[e,l]=(0,a.useState)(I),s=(0,a.useRef)(),m=(0,a.useRef)(),u=(0,a.useRef)(),x=(0,d.MW)();return(0,S.jsxs)(t.A,{id:"logs",children:[(0,S.jsxs)(r.A,{lg:"2",xs:"12",children:[(0,S.jsx)("h2",{className:"mb-3 filters-header",children:"Log Filters"}),(0,S.jsx)("form",{onSubmit:e=>{var s,a;(e.preventDefault(),s=e.target.elements.logFromInput.value,a=e.target.elements.logUntilInput.value,!s&&!a||!s||!a||new Date(s)<=new Date(a))?l({limit:parseInt(e.target.elements.logLimitSelect.value,10)||1e3,level:e.target.elements.logLevelSelect.value||void 0,from:e.target.elements.logFromInput.value||void 0,until:e.target.elements.logUntilInput.value||void 0}):x.error("Please provide a valid date range.")},onReset:()=>{s.current.reset(),m.current.clearValue(),u.current.clearValue(),l(I)},ref:s,children:(0,S.jsxs)(t.A,{children:[(0,S.jsx)(r.A,{xs:"6",lg:"12",className:"mb-3",children:(0,S.jsx)(i.Ay,{name:"logLimitSelect",isSearchable:!1,className:"react-select-container",classNamePrefix:"react-select",ref:m,placeholder:"Log Limit",options:[{value:1e3,label:"1000"},{value:500,label:"500"},{value:250,label:"250"},{value:100,label:"100"},{value:10,label:"10"}]})}),(0,S.jsx)(r.A,{xs:"6",lg:"12",className:"mb-3",children:(0,S.jsx)(i.Ay,{name:"logLevelSelect",isSearchable:!1,className:"react-select-container",classNamePrefix:"react-select",ref:u,placeholder:"Log Level",defaultValue:null,options:[{value:null,label:"All"},{value:"notify",label:"Notify"},{value:"error",label:"Error"},{value:"warn",label:"Warn"},{value:"info",label:"Info"},{value:"debug",label:"Debug"},{value:"trace",label:"Trace"}]})}),(0,S.jsxs)(r.A,{xs:"8",lg:"12",className:"mb-3",children:[(0,S.jsx)(n.A,{htmlFor:"logFromInput",className:"input-label",children:"Start Date:"}),(0,S.jsx)(o.A,{name:"logFromInput",type:"datetime-local"})]}),(0,S.jsxs)(r.A,{xs:"8",lg:"12",className:"mb-3",children:[(0,S.jsx)(n.A,{htmlFor:"logUntilInput",className:"input-label",children:"End Date:"}),(0,S.jsx)(o.A,{name:"logUntilInput",type:"datetime-local"})]}),(0,S.jsx)(r.A,{xs:"6",lg:"12",className:"mb-3",children:(0,S.jsx)(c.A,{type:"submit",className:"btn btn-purple px-4 w-100",children:"Apply"})}),(0,S.jsx)(r.A,{xs:"6",lg:"12",className:"mb-3",children:(0,S.jsx)(c.A,{type:"reset",className:"btn btn-purple px-4 w-100",children:"Reset"})})]})})]}),(0,S.jsx)(r.A,{lg:"10",xs:"12",children:(0,S.jsx)(D,{logsFilter:e})})]})}},7209:(e,l,s)=>{s.d(l,{A:()=>a});const a=e=>"object"===typeof e&&!Array.isArray(e)&&null!==e},1646:(e,l,s)=>{s.d(l,{A:()=>j});var a=s(9950),t=s(1942),r=s.n(t),n=s(8738),o=s.n(n),c=s(1497),i=["className","cssModule","hidden","widths","tag","check","size","for"];function d(){return d=Object.assign?Object.assign.bind():function(e){for(var l=1;l<arguments.length;l++){var s=arguments[l];for(var a in s)Object.prototype.hasOwnProperty.call(s,a)&&(e[a]=s[a])}return e},d.apply(this,arguments)}function m(e,l,s){return l in e?Object.defineProperty(e,l,{value:s,enumerable:!0,configurable:!0,writable:!0}):e[l]=s,e}function u(e,l){if(null==e)return{};var s,a,t=function(e,l){if(null==e)return{};var s,a,t={},r=Object.keys(e);for(a=0;a<r.length;a++)s=r[a],l.indexOf(s)>=0||(t[s]=e[s]);return t}(e,l);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);for(a=0;a<r.length;a++)s=r[a],l.indexOf(s)>=0||Object.prototype.propertyIsEnumerable.call(e,s)&&(t[s]=e[s])}return t}var x=["xs","sm","md","lg","xl","xxl"],h=r().oneOfType([r().number,r().string]),g=r().oneOfType([r().bool,r().string,r().number,r().shape({size:h,order:h,offset:h})]),p={children:r().node,hidden:r().bool,check:r().bool,size:r().string,for:r().string,tag:c.Wx,className:r().string,cssModule:r().object,xs:g,sm:g,md:g,lg:g,xl:g,xxl:g,widths:r().array},v=function(e,l,s){return!0===s||""===s?e?"col":"col-".concat(l):"auto"===s?e?"col-auto":"col-".concat(l,"-auto"):e?"col-".concat(s):"col-".concat(l,"-").concat(s)};function f(e){var l=e.className,s=e.cssModule,t=e.hidden,r=e.widths,n=void 0===r?x:r,h=e.tag,g=void 0===h?"label":h,p=e.check,f=e.size,j=e.for,b=u(e,i),A=[];n.forEach((function(l,a){var t=e[l];if(delete b[l],t||""===t){var r,n=!a;if((0,c.Gv)(t)){var i,d=n?"-":"-".concat(l,"-");r=v(n,l,t.size),A.push((0,c.qO)(o()((m(i={},r,t.size||""===t.size),m(i,"order".concat(d).concat(t.order),t.order||0===t.order),m(i,"offset".concat(d).concat(t.offset),t.offset||0===t.offset),i))),s)}else r=v(n,l,t),A.push(r)}}));var N=f||A.length,w=!(p||N),y=(0,c.qO)(o()(l,!!t&&"visually-hidden",!!p&&"form-check-label",!!f&&"col-form-label-".concat(f),A,!!N&&"col-form-label",!!w&&"form-label"),s);return a.createElement(g,d({htmlFor:j},b,{className:y}))}f.propTypes=p;const j=f}}]);
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";(self.webpackChunkharperdb_studio=self.webpackChunkharperdb_studio||[]).push([[522],{7591:(e,t,r)=>{r.r(t),r.d(t,{default:()=>E});var n=r(9379),o=r(9950),s=r(5077),i=r(7176),a=r(6114),c=r(3452),l=r(4084),u=r(8156),f=r(6713),p=r(5269),d=r(9435),m=r(9708),h=r(5488),y=r(7348),b=r(2765),g=r(2415),j=r(6196),v=r(4414);const x=function(e){let{itemType:t,toggleDropItem:r,toggleCreate:l,baseUrl:u}=e;const{compute_stack_id:d,customer_id:x}=(0,s.g)(),A=(0,s.Zp)(),O=(0,y.MW)(),w=(0,f.O$)(p.A,(e=>e.auth)),N=(0,f.O$)(p.A,(e=>e.url)),_=(0,f.O$)(p.A,(e=>e.is_local)),k=(0,f.O$)(p.A,(e=>e.roles&&e.roles.map((e=>e.role)))),[R,S]=(0,o.useState)({});return(0,o.useEffect)((()=>{r()}),[r]),(0,v.jsx)(m.A,{onSubmit:async e=>{if(e.preventDefault(),!R.name)return S((0,n.A)((0,n.A)({},R),{},{error:!0})),O.error("You must provide a role name");if(k.includes(R.name))return S((0,n.A)((0,n.A)({},R),{},{error:!0})),O.error("Role with that name already exists");if(!(0,j.A)(R.name))return S((0,n.A)((0,n.A)({},R),{},{error:!0})),O.error("Role names must have only letters and underscores");const r="cluster user"===t?{cluster_user:!0}:"super user"===t?{super_user:!0}:{},o=await(0,b.A)({auth:w,url:N,is_local:_,compute_stack_id:d,customer_id:x,role:R.name,permission:r});return o.error?(S((0,n.A)((0,n.A)({},R),{},{error:!0})),O.error(o.message)):(S({}),await(0,g.A)({auth:w,url:N}),A("".concat(u,"/").concat(o.id)))},children:(0,v.jsxs)(i.A,{className:"item-row form",children:[(0,v.jsx)(a.A,{className:"input-holder",children:(0,v.jsx)(h.A,{id:"name",invalid:R.error,onChange:e=>S({name:e.target.value.toString()}),type:"text",name:"name",placeholder:"name"})}),(0,v.jsxs)(a.A,{className:"item-action",children:[(0,v.jsx)(c.A,{id:"createRole",color:"success",className:"round me-1",children:(0,v.jsx)("i",{className:"fa fa-check text-white"})}),(0,v.jsx)(c.A,{color:"black",className:"round",onClick:()=>l(!1),children:(0,v.jsx)("i",{className:"fa fa-times text-white"})})]})]})})};var A=r(127);const O=function(e){let{item:t,baseUrl:r,isActive:n,toggleDropItem:l,isDropping:u}=e;const d=(0,s.Zp)(),m=(0,y.MW)(),[h,b]=(0,o.useState)(!1),j=(0,f.O$)(p.A,(e=>e.auth)),x=(0,f.O$)(p.A,(e=>e.url)),O=async()=>{if(!h)return!1;const e=await(async e=>{let{auth:t,id:r,url:n}=e;return(0,A.A)({operation:{operation:"drop_role",id:r},auth:t,url:n})})({auth:j,url:x,id:t.id});return e.error?m.error(e.message):((0,g.A)({auth:j,url:x}),!!n&&setTimeout((()=>d(r)),100))};return(0,v.jsxs)(i.A,{className:"item-row ".concat(n?"active":""),onClick:()=>!(n||u||h)&&d("".concat(r,"/").concat(t.id)),children:[(0,v.jsx)(a.A,{className:"item-label ".concat(h?"text-danger text-nowrap":""),children:h?"drop ".concat(t.role,"?"):t.role}),(0,v.jsx)(a.A,{className:"item-action",children:h?(0,v.jsxs)(v.Fragment,{children:[(0,v.jsx)(c.A,{id:"confirmDropRole",color:"danger",className:"round me-1",title:"confirm drop ".concat(t.role),onClick:()=>{b(!1),O()},children:(0,v.jsx)("i",{className:"fa fa-check text-white"})}),(0,v.jsx)(c.A,{color:"black",className:"round",title:"Cancel drop ".concat(t.role),onClick:()=>{b(!1)},children:(0,v.jsx)("i",{className:"fa fa-times text-white"})})]}):u?(0,v.jsx)(c.A,{id:"drop".concat(t.role),color:"danger",className:"round",title:"Drop ".concat(t.role),onClick:()=>{b(t),l(!1)},children:(0,v.jsx)("i",{className:"fa fa-minus text-white"})}):n?(0,v.jsx)(c.A,{color:"purple",className:"round",title:"Viewing ".concat(t.role),children:(0,v.jsx)("i",{className:"fa fa-chevron-right"})}):null})]},t)};const w=function(e){let{items:t,itemType:r,toggleDropItem:n,isDropping:o,toggleCreate:s,isCreating:l,showForm:u}=e;return(0,v.jsxs)(i.A,{className:"floating-card-header",children:[(0,v.jsxs)(a.A,{children:[r,"s"]}),u&&t&&t.length?(0,v.jsxs)(a.A,{className:"text-end",children:[(0,v.jsx)(c.A,{color:"link",title:"Remove ".concat(r,"s"),className:"add-remove me-3",onClick:()=>{n(!o),s(!1)},children:(0,v.jsx)("i",{className:"fa fa-minus"})}),(0,v.jsx)(c.A,{color:"link",title:"Add ".concat(r),className:"add-remove me-1",onClick:()=>{s(!l),n(!1)},children:(0,v.jsx)("i",{className:"fa fa-plus"})})]}):null]})};var N=r(3150),_=r(3628);const k=function(e){let{items:t,activeItem:r,showForm:n,baseUrl:s,itemType:i}=e;const[a,c]=(0,o.useState)(!1),[f,p]=(0,o.useState)(!1);(0,o.useEffect)((()=>{p(),c()}),[r,t]);const m=t&&[...t].sort(((e,t)=>e.role<t.role?-1:1));return(0,v.jsx)(d.tH,{onError:(e,t)=>(0,_.A)({error:{message:e.message,componentStack:t}}),FallbackComponent:N.A,children:(0,v.jsxs)("div",{className:"entity-manager",children:[(0,v.jsx)(w,{items:t,itemType:i,isDropping:a,toggleDropItem:c,isCreating:f,toggleCreate:p,showForm:n}),(0,v.jsx)(l.A,{className:"my-3",children:(0,v.jsxs)(u.A,{children:[m&&m.length?m.map((e=>(0,v.jsx)(O,{item:e,baseUrl:s,isActive:r===e.id,isDropping:a,toggleDropItem:c},e.id))):null,(t&&!t.length||f)&&(0,v.jsx)(x,{itemType:i,baseUrl:s,isDropping:a,toggleDropItem:c,isCreating:f,toggleCreate:p})]})})]})})};var R=r(4979),S=r(717);const C=(0,o.lazy)((()=>Promise.all([r.e(239),r.e(831)]).then(r.bind(r,3109)))),P={roleName:!1,canEdit:!1,superUsers:[],clusterUsers:[],standardUsers:[],showAttributes:!1};const E=function(){const{role_id:e,customer_id:t}=(0,s.g)(),r=(0,f.O$)(p.A,(e=>e.compute_stack_id)),d=(0,f.O$)(p.A,(e=>e.auth)),m=(0,f.O$)(p.A,(e=>e.url)),h=(0,f.O$)(p.A,(e=>e.roles),[r]),[y,b]=(0,o.useState)(!1),[j,x]=(0,o.useState)(P),A="/o/".concat(t,"/i/").concat(r,"/roles"),O=(0,f.O$)(p.A,(e=>{var t;return null===(t=e.registration)||void 0===t?void 0:t.version})),[w,N]=(null===O||void 0===O?void 0:O.split("."))||[],_=parseFloat("".concat(w,".").concat(N)),E=(0,o.useCallback)((async()=>{b(!0),await(0,g.A)({auth:d,url:m}),await(0,S.A)({auth:d,url:m}),b(!1)}),[d,m]);return(0,o.useEffect)((()=>{if(h){const t=e&&h.find((t=>t.id===e));x((0,n.A)((0,n.A)({},j),{},{roleName:t&&t.role,canEdit:t&&!t.permission.cluster_user&&!t.permission.super_user,clusterUsers:h.filter((e=>e.permission.cluster_user)),superUsers:h.filter((e=>e.permission.super_user)),standardUsers:h.filter((e=>!e.permission.super_user&&!e.permission.cluster_user)),showAttributes:!1}))}else x(P)}),[e,h]),(0,o.useEffect)((()=>{E()}),[E,r]),(0,v.jsxs)(i.A,{id:"roles",children:[(0,v.jsxs)(a.A,{xl:"3",lg:"4",md:"5",xs:"12",children:[(0,v.jsx)(k,{showForm:!0,activeItem:e,items:j.superUsers,baseUrl:A,itemType:"super user"}),(0,v.jsx)(k,{showForm:!0,activeItem:e,items:j.clusterUsers,baseUrl:A,itemType:"cluster user"}),(0,v.jsx)(k,{showForm:!0,activeItem:e,items:j.standardUsers,baseUrl:A,itemType:"standard role"})]}),(0,v.jsxs)(a.A,{xl:"9",lg:"8",md:"7",xs:"12",children:[(0,v.jsxs)(i.A,{className:"floating-card-header",children:[j.canEdit&&(0,v.jsxs)(a.A,{children:["edit role > ",j.roleName]}),(0,v.jsxs)(a.A,{className:"text-md-end",children:[j.canEdit&&(0,v.jsxs)(v.Fragment,{children:[(0,v.jsxs)(c.A,{color:"link",tabIndex:"0",title:"Show Attributes",onClick:()=>x((0,n.A)((0,n.A)({},j),{},{showAttributes:!j.showAttributes})),children:[(0,v.jsx)("span",{className:"me-2",children:"show all attributes"}),(0,v.jsx)("i",{className:"fa fa-lg fa-toggle-".concat(j.showAttributes?"on":"off")})]}),(0,v.jsx)("span",{className:"mx-3 text",children:"|"})]}),(0,v.jsxs)(c.A,{color:"link",onClick:E,className:"me-2",children:[(0,v.jsx)("span",{className:"me-2",children:"refresh roles"}),(0,v.jsx)("i",{title:"Refresh Roles",className:"fa ".concat(y?"fa-spinner fa-spin":"fa-sync-alt")})]})]})]}),j.canEdit?(0,v.jsx)(l.A,{className:"my-3",children:(0,v.jsx)(u.A,{className:"full-height",children:(0,v.jsx)(o.Suspense,{fallback:(0,v.jsx)(R.A,{header:" ",spinner:!0}),children:(0,v.jsx)(C,{showAttributes:j.showAttributes,fetchRoles:E})})})}):(0,v.jsx)(l.A,{className:"my-3",children:(0,v.jsx)(u.A,{children:e?(0,v.jsxs)("div",{className:"empty-prompt",children:["Super Users and Cluster Users have full access to all"," ",_>=4.2?"databases":"schemas",", tables, and attributes."]}):(0,v.jsx)("div",{className:"empty-prompt",children:"Please choose or add a role to manage it."})})})]})]})}},2765:(e,t,r)=>{r.d(t,{A:()=>o});var n=r(127);const o=async e=>{let{auth:t,url:r,role:o,permission:s}=e;return(0,n.A)({operation:{operation:"add_role",role:o,permission:s},auth:t,url:r})}},2415:(e,t,r)=>{r.d(t,{A:()=>s});var n=r(127),o=r(5269);const s=async e=>{let{auth:t,url:r}=e;const s=await(0,n.A)({operation:{operation:"list_roles"},auth:t,url:r}),i=[...Array.isArray(s)?s:[]].sort(((e,t)=>e.role.toLowerCase()>t.role.toLowerCase()?1:-1));return o.A.update((e=>{e.roles=i})),i}},6196:(e,t,r)=>{r.d(t,{A:()=>n});const n=e=>e.match(/^[a-zA-Z_]+$/)},9708:(e,t,r)=>{r.d(t,{A:()=>g});var n=r(9950),o=r(1942),s=r.n(o),i=r(1497);function a(e){return a="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},a(e)}var c=["className","cssModule","tag","innerRef"];function l(){return l=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var r=arguments[t];for(var n in r)Object.prototype.hasOwnProperty.call(r,n)&&(e[n]=r[n])}return e},l.apply(this,arguments)}function u(e,t){if(null==e)return{};var r,n,o=function(e,t){if(null==e)return{};var r,n,o={},s=Object.keys(e);for(n=0;n<s.length;n++)r=s[n],t.indexOf(r)>=0||(o[r]=e[r]);return o}(e,t);if(Object.getOwnPropertySymbols){var s=Object.getOwnPropertySymbols(e);for(n=0;n<s.length;n++)r=s[n],t.indexOf(r)>=0||Object.prototype.propertyIsEnumerable.call(e,r)&&(o[r]=e[r])}return o}function f(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}function p(e,t){return p=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(e,t){return e.__proto__=t,e},p(e,t)}function d(e){var t=function(){if("undefined"===typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"===typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}();return function(){var r,n=h(e);if(t){var o=h(this).constructor;r=Reflect.construct(n,arguments,o)}else r=n.apply(this,arguments);return function(e,t){if(t&&("object"===a(t)||"function"===typeof t))return t;if(void 0!==t)throw new TypeError("Derived constructors may only return object or undefined");return m(e)}(this,r)}}function m(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function h(e){return h=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(e){return e.__proto__||Object.getPrototypeOf(e)},h(e)}var y={children:s().node,tag:i.Wx,innerRef:s().oneOfType([s().object,s().func,s().string]),className:s().string,cssModule:s().object},b=function(e){!function(e,t){if("function"!==typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),Object.defineProperty(e,"prototype",{writable:!1}),t&&p(e,t)}(a,e);var t,r,o,s=d(a);function a(e){var t;return function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,a),(t=s.call(this,e)).getRef=t.getRef.bind(m(t)),t.submit=t.submit.bind(m(t)),t}return t=a,(r=[{key:"getRef",value:function(e){this.props.innerRef&&this.props.innerRef(e),this.ref=e}},{key:"submit",value:function(){this.ref&&this.ref.submit()}},{key:"render",value:function(){var e=this.props,t=e.className,r=e.cssModule,o=e.tag,s=void 0===o?"form":o,a=e.innerRef,f=u(e,c),p=(0,i.qO)(t,r);return n.createElement(s,l({},f,{ref:a,className:p}))}}])&&f(t.prototype,r),o&&f(t,o),Object.defineProperty(t,"prototype",{writable:!1}),a}(n.Component);b.propTypes=y;const g=b},5488:(e,t,r)=>{r.d(t,{A:()=>v});var n=r(9950),o=r(1942),s=r.n(o),i=r(8738),a=r.n(i),c=r(1497);function l(e){return l="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},l(e)}var u=["className","cssModule","type","bsSize","valid","invalid","tag","addon","plaintext","innerRef"];function f(){return f=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var r=arguments[t];for(var n in r)Object.prototype.hasOwnProperty.call(r,n)&&(e[n]=r[n])}return e},f.apply(this,arguments)}function p(e,t){if(null==e)return{};var r,n,o=function(e,t){if(null==e)return{};var r,n,o={},s=Object.keys(e);for(n=0;n<s.length;n++)r=s[n],t.indexOf(r)>=0||(o[r]=e[r]);return o}(e,t);if(Object.getOwnPropertySymbols){var s=Object.getOwnPropertySymbols(e);for(n=0;n<s.length;n++)r=s[n],t.indexOf(r)>=0||Object.prototype.propertyIsEnumerable.call(e,r)&&(o[r]=e[r])}return o}function d(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}function m(e,t){return m=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(e,t){return e.__proto__=t,e},m(e,t)}function h(e){var t=function(){if("undefined"===typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"===typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}();return function(){var r,n=b(e);if(t){var o=b(this).constructor;r=Reflect.construct(n,arguments,o)}else r=n.apply(this,arguments);return function(e,t){if(t&&("object"===l(t)||"function"===typeof t))return t;if(void 0!==t)throw new TypeError("Derived constructors may only return object or undefined");return y(e)}(this,r)}}function y(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function b(e){return b=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(e){return e.__proto__||Object.getPrototypeOf(e)},b(e)}var g={children:s().node,type:s().string,size:s().oneOfType([s().number,s().string]),bsSize:s().string,valid:s().bool,invalid:s().bool,tag:c.Wx,innerRef:s().oneOfType([s().object,s().func,s().string]),plaintext:s().bool,addon:s().bool,className:s().string,cssModule:s().object},j=function(e){!function(e,t){if("function"!==typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),Object.defineProperty(e,"prototype",{writable:!1}),t&&m(e,t)}(i,e);var t,r,o,s=h(i);function i(e){var t;return function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,i),(t=s.call(this,e)).getRef=t.getRef.bind(y(t)),t.focus=t.focus.bind(y(t)),t}return t=i,(r=[{key:"getRef",value:function(e){this.props.innerRef&&this.props.innerRef(e),this.ref=e}},{key:"focus",value:function(){this.ref&&this.ref.focus()}},{key:"render",value:function(){var e=this.props,t=e.className,r=e.cssModule,o=e.type,s=void 0===o?"text":o,i=e.bsSize,l=e.valid,d=e.invalid,m=e.tag,h=e.addon,y=e.plaintext,b=e.innerRef,g=p(e,u),j=["switch","radio","checkbox"].indexOf(s)>-1,v="select"===s,x="range"===s,A=m||(v||"textarea"===s?s:"input"),O="form-control";y?(O="".concat(O,"-plaintext"),A=m||"input"):x?O="form-range":v?O="form-select":j&&(O=h?null:"form-check-input"),g.size&&/\D/g.test(g.size)&&((0,c.mc)('Please use the prop "bsSize" instead of the "size" to bootstrap\'s input sizing.'),i=g.size,delete g.size);var w=(0,c.qO)(a()(t,d&&"is-invalid",l&&"is-valid",!!i&&(v?"form-select-".concat(i):"form-control-".concat(i)),O),r);return("input"===A||m&&"function"===typeof m)&&(g.type="switch"===s?"checkbox":s),g.children&&!y&&"select"!==s&&"string"===typeof A&&"select"!==A&&((0,c.mc)('Input with a type of "'.concat(s,'" cannot have children. Please use "value"/"defaultValue" instead.')),delete g.children),n.createElement(A,f({},g,{ref:b,className:w,"aria-invalid":d}))}}])&&d(t.prototype,r),o&&d(t,o),Object.defineProperty(t,"prototype",{writable:!1}),i}(n.Component);j.propTypes=g;const v=j}}]);
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";(self.webpackChunkharperdb_studio=self.webpackChunkharperdb_studio||[]).push([[541],{6812:(e,s,t)=>{t.r(s),t.d(s,{default:()=>E});var a=t(9950),r=t(7176),n=t(6114),l=t(6713),o=t(3452),i=t(4084),c=t(8156),d=t(9435),u=t(5269),m=t(127);const x=1e9,h=1073741824;var p=t(1652),j=t(3150),v=t(3628),A=t(4414);let f;const y=function(){const e=(0,l.O$)(u.A,(e=>e.auth)),s=(0,l.O$)(u.A,(e=>e.url)),t=(0,l.O$)(u.A,(e=>e.systemInfo)),y=(0,l.O$)(u.A,(e=>e.is_local)),[g,N]=(0,a.useState)(!(null!==t&&void 0!==t&&t.totalMemory)),w=async()=>{N(!0),f=new AbortController,await(async e=>{var s,t,a,r,n,l,o,i,c,d,p,j;let{auth:v,url:A,signal:f,refresh:y,is_local:g,cachedSystemInfo:N,skip:w=[]}=e;const k=["network","disk","cpu","memory","system"],b=await(0,m.A)({operation:{operation:"system_information",attributes:null!==w&&void 0!==w&&w.length?k.filter((e=>!w.includes(e))):k},auth:v,url:A,signal:f});if(b.error&&y)return u.A.update((e=>{e.systemInfoError=!0}));if(b.error)return u.A.update((e=>{e.systemInfo={totalMemory:"...",usedMemory:"...",freeMemory:"...",memoryStatus:"grey",totalDisk:"...",usedDisk:"...",freeDisk:"...",diskStatus:"grey",cpuInfo:"...",cpuCores:"...",cpuLoad:"...",cpuStatus:"grey",networkTransferred:"...",networkReceived:"...",networkLatency:"...",networkLatencyStatus:"grey"},e.systemInfoError=!0}));const S=w.includes("memory")?parseFloat(N.totalMemory):b.memory.total/h,_=w.includes("memory")?parseFloat(N.usedMemory):b.memory.active/h,C=w.includes("memory")?parseFloat(N.freeMemory):b.memory.available/h,F=w.includes("memory")?N.memoryStatus:C/S<.1?"danger":C/S<.25?"warning":"success",D=w.includes("disk")?parseFloat(N.totalDisk):"darwin"===b.system.platform?(null===(s=b.disk)||void 0===s||null===(t=s.size)||void 0===t?void 0:t[0].size)/x:g?(null===(n=b.disk)||void 0===n||null===(l=n.size)||void 0===l?void 0:l[0].size)/h:(null===(a=b.disk)||void 0===a||null===(r=a.size)||void 0===r?void 0:r.find((e=>"/home/ubuntu/hdb"===e.mount)).size)/h,L=w.includes("disk")?parseFloat(N.usedDisk):"darwin"===b.system.platform?(null===(o=b.disk)||void 0===o||null===(i=o.size)||void 0===i?void 0:i.reduce(((e,s)=>e+s.used),0))/x:g?(null===(p=b.disk)||void 0===p||null===(j=p.size)||void 0===j?void 0:j.reduce(((e,s)=>e+s.used),0))/h:(null===(c=b.disk)||void 0===c||null===(d=c.size)||void 0===d?void 0:d.find((e=>"/home/ubuntu/hdb"===e.mount)).used)/h,M=w.includes("disk")?parseFloat(N.freeDisk):D-L,O=w.includes("disk")?N.diskStatus:M/D<.1?"danger":M/D<.25?"warning":"success",E=w.includes("cpu")?N.cpuInfo:"".concat(b.cpu.manufacturer," ").concat(b.cpu.brand),I=w.includes("cpu")?N.cpuCores:"".concat(b.cpu.physicalCores," physical / ").concat(b.cpu.cores," virtual"),T=w.includes("cpu")?parseFloat(N.cpuLoad):b.cpu.current_load.currentLoad||b.cpu.current_load.currentload||0,$=w.includes("cpu")?N.cpuStatus:T>90?"danger":T>75?"warning":"success",z=w.includes("network")?parseFloat(N.networkTransferred):b.network.stats.reduce(((e,s)=>e+s.tx_bytes),0)/x,H=w.includes("network")?parseFloat(N.networkReceived):b.network.stats.reduce(((e,s)=>e+s.rx_bytes),0)/x,J=w.includes("network")?parseFloat(N.networkLatency):b.network.latency.ms,U=w.includes("network")?parseFloat(N.networkLatencyStatus):J>1e3?"danger":J>500?"warning":"success",B={totalMemory:null===S||void 0===S?void 0:S.toFixed(2),usedMemory:null===_||void 0===_?void 0:_.toFixed(2),freeMemory:null===C||void 0===C?void 0:C.toFixed(2),memoryStatus:F,totalDisk:null===D||void 0===D?void 0:D.toFixed(2),usedDisk:null===L||void 0===L?void 0:L.toFixed(2),freeDisk:null===M||void 0===M?void 0:M.toFixed(2),diskStatus:O,cpuInfo:E,cpuCores:I,cpuLoad:null===T||void 0===T?void 0:T.toFixed(2),cpuStatus:$,networkTransferred:null===z||void 0===z?void 0:z.toFixed(2),networkReceived:null===H||void 0===H?void 0:H.toFixed(2),networkLatency:J,networkLatencyStatus:U};return u.A.update((e=>{e.systemInfo=B}))})({auth:e,url:s,is_local:y,signal:f.signal,refresh:!!t,previousSystemInfo:t}),N(!1)};return(0,a.useEffect)((()=>(!e||null!==t&&void 0!==t&&t.totalMemory||w(),()=>{var e;null===(e=f)||void 0===e||e.abort()})),[e]),(0,A.jsxs)(d.tH,{onError:(e,s)=>(0,v.A)({error:{message:e.message,componentStack:s}}),FallbackComponent:j.A,children:[(0,A.jsxs)(r.A,{className:"floating-card-header",children:[(0,A.jsx)(n.A,{children:"host system"}),(0,A.jsx)(n.A,{className:"text-end",children:(0,A.jsx)(o.A,{color:"link",title:"Update Metrics",className:"me-2",onClick:w,children:(0,A.jsx)("i",{className:"fa ".concat(g?"fa-spinner fa-spin":"fa-sync-alt")})})})]}),(0,A.jsx)(i.A,{className:"my-3 instance-details",children:(0,A.jsx)(c.A,{children:t?(0,A.jsxs)(r.A,{children:[(0,A.jsx)(n.A,{children:(0,A.jsx)(p.A,{header:"Total Memory",className:"mb-3",children:(0,A.jsxs)("div",{className:"nowrap-scroll",children:[(null===t||void 0===t?void 0:t.totalMemory)||"...","GB"]})})}),(0,A.jsx)(n.A,{children:(0,A.jsx)(p.A,{header:"Active Memory",className:"mb-3",children:(0,A.jsxs)("div",{className:"nowrap-scroll",children:[(null===t||void 0===t?void 0:t.usedMemory)||"...","GB"]})})}),(0,A.jsx)(n.A,{children:(0,A.jsx)(p.A,{header:"Available Memory",className:"mb-3",children:(0,A.jsxs)("div",{className:"nowrap-scroll text-".concat((null===t||void 0===t?void 0:t.memoryStatus)||"grey"),children:[(null===t||void 0===t?void 0:t.freeMemory)||"...","GB"]})})}),(0,A.jsx)(n.A,{children:(0,A.jsx)(p.A,{header:"CPU Cores",className:"mb-3",children:(0,A.jsx)("div",{className:"nowrap-scroll",children:(null===t||void 0===t?void 0:t.cpuCores)||"..."})})}),(0,A.jsx)(n.A,{children:(0,A.jsx)(p.A,{header:"CPU Load",className:"mb-3",children:(0,A.jsxs)("div",{className:"nowrap-scroll text-".concat((null===t||void 0===t?void 0:t.cpuStatus)||"grey"),children:[(null===t||void 0===t?void 0:t.cpuLoad)||"...","%"]})})})]}):(0,A.jsx)("div",{className:"pt-5 text-center",children:(0,A.jsx)("i",{className:"fa fa-spinner fa-spin text-purple"})})})}),(0,A.jsx)("br",{})]})};var g=t(9379),N=t(135),w=t(5996);var k=t(7209);const b=function(e){let{end_datetime:s,start_datetime:t,status:a,message:l}=e;return(0,A.jsx)("div",{className:"item-row",children:(0,A.jsxs)(r.A,{children:[(0,A.jsx)(n.A,{xs:"3",className:"text-nowrap ".concat(a.toLowerCase()),children:a}),(0,A.jsx)(n.A,{xs:"3",className:"text-nowrap",children:new Date(t).toLocaleDateString()}),(0,A.jsx)(n.A,{xs:"3",className:"text-nowrap",children:new Date(t).toLocaleTimeString()}),(0,A.jsx)(n.A,{xs:"3",className:"text-nowrap",children:new Date(s).toLocaleTimeString()}),(0,A.jsx)(n.A,{xs:"12",className:"mt-1",children:(0,k.A)(l)?JSON.stringify(l):l})]})})};let S;const _=function(){const e=(0,l.O$)(u.A,(e=>e.auth)),s=(0,l.O$)(u.A,(e=>e.url)),t=(0,l.O$)(u.A,(e=>e.jobs)),x=(0,l.O$)(u.A,(e=>e.jobsError)),[h,p]=(0,a.useState)(!1),[f,y]=(0,a.useState)(!0),[k,_]=(0,a.useState)(!0);return(0,a.useEffect)((()=>{let a=!0;return e&&(async()=>{y(!0),S=new AbortController;const r=new Date;r.setDate(r.getDate()+1);const n=r.toISOString().split("T")[0];r.setFullYear(r.getFullYear()-1);const l=r.toISOString().split("T")[0];await(async e=>{let{auth:s,url:t,signal:a,from_date:r,to_date:n,currentJobCount:l}=e;const o=await(0,m.A)({operation:{operation:"search_jobs_by_start_date",from_date:r,to_date:n},auth:s,url:t,signal:a});return o.error&&l?u.A.update((e=>{e.jobsError=!0})):!Array.isArray(o)||o.error?u.A.update((e=>{e.jobs=[],e.jobsError=!0})):u.A.update((e=>{e.jobs=[...o].sort(((e,s)=>s.start_datetime-e.end_datetime)),e.jobsError=!1}))})({auth:e,url:s,signal:S.signal,currentJobCount:(null===t||void 0===t?void 0:t.length)||0,from_date:l,to_date:n}),a&&y(!1)})(),()=>{var e;null===(e=S)||void 0===e||e.abort(),a=!1}}),[e,k]),(0,N.A)((()=>e&&h&&_(Date.now())),w.A.refresh_content_interval),(0,A.jsxs)(d.tH,{onError:(e,s)=>(0,v.A)({error:{message:e.message,componentStack:s}}),FallbackComponent:j.A,children:[(0,A.jsxs)(r.A,{className:"floating-card-header",children:[(0,A.jsx)(n.A,{children:"jobs"}),(0,A.jsxs)(n.A,{className:"text-end",children:[(0,A.jsx)(o.A,{color:"link",title:"Update Jobs",className:"me-2",onClick:()=>_(Date.now()),children:(0,A.jsx)("i",{className:"fa ".concat(f?"fa-spinner fa-spin":"fa-sync-alt")})}),(0,A.jsxs)(o.A,{color:"link",title:"Turn on autofresh",onClick:()=>p(!h),children:[(0,A.jsx)("span",{className:"me-2",children:"auto"}),(0,A.jsx)("i",{className:"fa fa-lg fa-toggle-".concat(h?"on":"off")})]})]})]}),(0,A.jsx)(i.A,{className:"my-3",children:(0,A.jsxs)(c.A,{className:"item-list",children:[(0,A.jsxs)(r.A,{className:"header",children:[(0,A.jsx)(n.A,{xs:"3",className:"text-bold text-nowrap",children:"status"}),(0,A.jsx)(n.A,{xs:"3",className:"text-bold text-nowrap",children:"date"}),!f&&x?(0,A.jsx)(n.A,{xs:"6",className:"text-end text-danger text-bold text-nowrap",children:(0,A.jsxs)("b",{children:["job fetch error: ",(new Date).toLocaleTimeString().toLowerCase()]})}):(0,A.jsxs)(A.Fragment,{children:[(0,A.jsx)(n.A,{xs:"3",className:"text-bold text-nowrap",children:"start"}),(0,A.jsx)(n.A,{xs:"3",className:"text-bold text-nowrap",children:"end"})]})]}),(0,A.jsx)("hr",{className:"mt-1 mb-0"}),(0,A.jsx)("div",{className:"item-scroller",children:!f||t||h?null!==t&&void 0!==t&&t.length?t.map((e=>(0,A.jsx)(b,(0,g.A)({},e),e.id))):(0,A.jsx)("div",{className:"pt-5 text-center",children:"no jobs found"}):(0,A.jsx)("div",{className:"pt-5 text-center",children:(0,A.jsx)("i",{className:"fa fa-spinner fa-spin text-lightgrey"})})})]})}),(0,A.jsx)("br",{})]})};var C=t(5077),F=t(5553);const D=function(e){let{date:s,type:t,message:a}=e;return(0,A.jsx)("div",{className:"item-row",children:(0,A.jsxs)(r.A,{children:[(0,A.jsx)(n.A,{xs:"3",className:"text-danger text-nowrap",children:t}),(0,A.jsx)(n.A,{xs:"9",className:"text-nowrap",children:new Date(s).toLocaleString()}),(0,A.jsx)(n.A,{xs:"12",className:"mt-1",children:(0,k.A)(a)?JSON.stringify(a):a})]})})};var L=t(4817);let M;const O=function(){const{customer_id:e}=(0,C.g)(),s=(0,l.O$)(u.A,(e=>e.compute_stack_id)),t=(0,l.O$)(F.A,(e=>e.auth)),m=(0,l.O$)(F.A,(e=>{var t;return e.alarms&&(null===(t=e.alarms[s])||void 0===t?void 0:t.alarms)}),[s]),x=(0,l.O$)(F.A,(e=>e.alarmsError)),[h,p]=(0,a.useState)(!1),[f,y]=(0,a.useState)(!1),[k,b]=(0,a.useState)(!0);return(0,a.useEffect)((()=>{let s=!0;return t&&(async()=>{y(!0),M=new AbortController,await(0,L.A)({auth:t,signal:M.signal,customer_id:e,currentAlarmsLength:null===m||void 0===m?void 0:m.length}),s&&y(!1)})(),()=>{var e;null===(e=M)||void 0===e||e.abort(),s=!1}}),[t,k]),(0,N.A)((()=>t&&h&&b(Date.now())),w.A.refresh_content_interval),(0,A.jsxs)(d.tH,{onError:(e,s)=>(0,v.A)({error:{message:e.message,componentStack:s}}),FallbackComponent:j.A,children:[(0,A.jsxs)(r.A,{className:"floating-card-header",children:[(0,A.jsx)(n.A,{children:"alarms"}),(0,A.jsxs)(n.A,{className:"text-end",children:[(0,A.jsx)(o.A,{color:"link",title:"Update Jobs",className:"me-2",onClick:()=>b(Date.now()),children:(0,A.jsx)("i",{className:"fa ".concat(f?"fa-spinner fa-spin":"fa-sync-alt")})}),(0,A.jsxs)(o.A,{color:"link",title:"Turn on autofresh",onClick:()=>p(!h),children:[(0,A.jsx)("span",{className:"me-2",children:"auto"}),(0,A.jsx)("i",{className:"fa fa-lg fa-toggle-".concat(h?"on":"off")})]})]})]}),(0,A.jsx)(i.A,{className:"my-3",children:(0,A.jsxs)(c.A,{className:"item-list",children:[(0,A.jsxs)(r.A,{className:"header",children:[(0,A.jsx)(n.A,{xs:"3",className:"text-bold text-nowrap",children:"status"}),(0,A.jsx)(n.A,{xs:"3",className:"text-bold text-nowrap",children:"date"}),(0,A.jsx)(n.A,{xs:"6",className:"text-end text-danger text-bold",children:!f&&x&&(0,A.jsxs)("span",{children:["alarms fetch error: ",(new Date).toLocaleTimeString().toLowerCase()]})})]}),(0,A.jsx)("hr",{className:"mt-1 mb-0"}),(0,A.jsx)("div",{className:"item-scroller",children:!f||m||h?null!==m&&void 0!==m&&m.length?m.map((e=>(0,A.jsx)(D,(0,g.A)({},e),e.id))):(0,A.jsx)("div",{className:"pt-5 text-center",children:"no alarms found"}):(0,A.jsx)("div",{className:"pt-5 text-center",children:(0,A.jsx)("i",{className:"fa fa-spinner fa-spin text-lightgrey"})})})]})}),(0,A.jsx)("br",{})]})};const E=function(){return(0,A.jsxs)(r.A,{id:"config",children:[(0,A.jsx)(n.A,{xs:"12",children:(0,A.jsx)(y,{})}),(0,A.jsx)(n.A,{lg:6,xs:"12",children:(0,A.jsx)(_,{})}),!w.A.is_local_studio&&(0,A.jsx)(n.A,{lg:"6",xs:"12",children:(0,A.jsx)(O,{})})]})}},1652:(e,s,t)=>{t.d(s,{A:()=>r});t(9950);var a=t(4414);const r=function(e){let{children:s,header:t,subheader:r,maxHeight:n="auto",minHeight:l="auto",className:o}=e;return(0,a.jsxs)("div",{className:"content-container ".concat(o),children:[(0,a.jsxs)("div",{className:"header-container",children:[(0,a.jsx)("span",{className:"header",children:t}),(0,a.jsx)("span",{className:"subheader",children:r})]}),(0,a.jsx)("div",{className:"auto"!==n?"scrollable":"",style:{maxHeight:n,minHeight:l},children:s})]})}},7209:(e,s,t)=>{t.d(s,{A:()=>a});const a=e=>"object"===typeof e&&!Array.isArray(e)&&null!==e}}]);
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";(self.webpackChunkharperdb_studio=self.webpackChunkharperdb_studio||[]).push([[642],{7695:(e,a,s)=>{s.r(a),s.d(a,{default:()=>v});var t=s(9379),n=s(9950),r=s(7176),l=s(6114),i=s(3452),o=s(4084),c=s(8156),d=s(6713),g=s(5077),u=s(9435),m=s(5269),p=s(8222),h=s(3150),x=s(3628),j=s(4343),f=s(4414);const A={tableData:[],dataTableColumns:[],totalRecords:0,filtered:[],sorted:[{id:"username",desc:!1}],page:0,loading:!1,totalPages:1,pageSize:20,autoRefresh:!1,showFilter:!1,lastUpdate:!1};let b;const v=function(e){var a,s;let{lastUpdate:v,setLastUpdate:N}=e;const{customer_id:C}=(0,g.g)(),P=(0,g.Zp)(),S=(0,d.O$)(m.A,(e=>e.compute_stack_id)),w=(0,d.O$)(m.A,(e=>e.auth)),k=(0,d.O$)(m.A,(e=>e.url)),[F,z]=(0,n.useState)(A),[y,D]=(0,n.useState)(!0),O=null===(a=F.sorted[0])||void 0===a?void 0:a.id,R=null===(s=F.sorted[0])||void 0===s?void 0:s.desc,E=(0,n.useCallback)((e=>{P("/o/".concat(C,"/i/").concat(S,"/users/").concat(e))}),[S,C]);return(0,n.useEffect)((()=>{let e=!0;return w&&(async()=>{D(!0),b=new AbortController;const a=await(0,p.A)({auth:w,url:k,signal:b.signal});e&&(D(!1),z((0,t.A)((0,t.A)({},F),{},{tableData:a,dataTableColumns:[{Header:"username",accessor:"username"},{Header:"role",accessor:"role"}],totalPages:Math.ceil((a.length||F.pageSize)/F.pageSize),loading:!1})))})(),()=>{var a;e=!1,null===(a=b)||void 0===a||a.abort()}}),[w,v,F.pageSize]),(0,n.useEffect)((()=>{let e=!0;if(F.tableData.length&&O){const a=[...[...F.tableData]].sort(((e,a)=>e[O]>a[O]&&R?1:e[O]>a[O]||R?-1:1));e&&z((0,t.A)((0,t.A)({},F),{},{tableData:a}))}return()=>{var a;e=!1,null===(a=b)||void 0===a||a.abort()}}),[O,R]),(0,f.jsxs)(u.tH,{onError:(e,a)=>(0,x.A)({error:{message:e.message,componentStack:a}}),FallbackComponent:h.A,children:[(0,f.jsxs)(r.A,{className:"floating-card-header",children:[(0,f.jsx)(l.A,{children:"existing users"}),(0,f.jsxs)(l.A,{className:"text-end",children:[(0,f.jsx)(i.A,{color:"link",onClick:()=>N(Date.now()),className:"me-2",children:(0,f.jsx)("i",{title:"Refresh Structure",className:"fa ".concat(y?"fa-spinner fa-spin":"fa-sync-alt")})}),(0,f.jsx)("span",{className:"mx-3 text",children:"|"}),(0,f.jsx)(i.A,{color:"link",title:"Filter Users",className:"me-2",onClick:()=>z((0,t.A)((0,t.A)({},F),{},{filtered:F.showFilter?[]:F.filtered,showFilter:!F.showFilter})),children:(0,f.jsx)("i",{className:"fa fa-search"})})]})]}),(0,f.jsx)(o.A,{className:"mt-3",children:(0,f.jsx)(c.A,{className:"react-table-holder",children:(0,f.jsx)(j.A,{columns:F.dataTableColumns,data:F.tableData,currentPage:F.page,pageSize:F.pageSize,totalPages:F.totalPages,showFilter:F.showFilter,sorted:F.sorted,loading:y,onFilteredChange:e=>z((0,t.A)((0,t.A)({},F),{},{filtered:e})),onSortedChange:e=>z((0,t.A)((0,t.A)({},F),{},{sorted:e})),onPageChange:e=>z((0,t.A)((0,t.A)({},F),{},{pageSize:e})),onPageSizeChange:e=>z((0,t.A)((0,t.A)({},F),{},{page:0,pageSize:e})),onRowClick:e=>E(e.username)})})})]})}},4343:(e,a,s)=>{s.d(a,{A:()=>C});var t=s(9950),n=s(2043),r=s(5488),l=s(9435),i=s(9379),o=s(45),c=s(7176),d=s(6114),g=s(4414);const u=["key"],m=e=>{let{headerGroups:a,onSortedChange:s,sorted:t,showFilter:n,dynamicAttributesFromDataTable:r,tableDescriptionAttributes:l}=e;const m=e=>{let a=!1;return l.forEach((s=>{s.attribute===e&&(s.is_primary_key||s.indexed)&&(a=!0)})),a};return a.map((e=>{const a=e.getHeaderGroupProps(),{key:l}=a,p=(0,o.A)(a,u);return(0,g.jsxs)("div",(0,i.A)((0,i.A)({},p),{},{children:[(0,g.jsx)(c.A,{className:"header g-0",children:e.headers.map((e=>{var a,n;return(0,g.jsx)(d.A,{onClick:()=>{var a,n;r&&!r.includes(e.id)&&m(e.id)&&s([{id:e.id,desc:(null===(a=t[0])||void 0===a?void 0:a.id)===e.id&&!(null!==(n=t[0])&&void 0!==n&&n.desc)}])},className:"".concat((null===(a=t[0])||void 0===a?void 0:a.id)===e.id?"sorted":""," ").concat(null!==(n=t[0])&&void 0!==n&&n.desc?"desc":"asc"," ").concat(-1!==e.id.indexOf("hdb-narrow")?"action":""," px-1 ").concat(r&&!r.includes(e.id)&&m(e.id)?"":"disabled-column"),children:(0,g.jsx)("div",{className:"text-renderer",children:e.render("Header")})},e.id)}))}),n&&(0,g.jsx)(c.A,{className:"filter g-0",children:e.headers.map((e=>(0,g.jsx)(d.A,{className:-1!==e.id.indexOf("hdb-narrow")?"action":"",children:e.render("Filter")},e.id)))})]}),l)}))};var p=s(3452);const h=function(e){let{page:a,pageSize:s,totalPages:t,onPageChange:n,onPageSizeChange:l,loading:i}=e;return(0,g.jsxs)(c.A,{className:"pagination",children:[(0,g.jsx)(d.A,{xs:"12",sm:"2",className:"previous",children:(0,g.jsx)(p.A,{className:"mb-2 btn-pagination",color:"purple",block:!0,onClick:()=>n(a-1),disabled:!t||0===a,children:(0,g.jsx)("i",{className:"fa fa-chevron-left"})})}),(0,g.jsxs)(d.A,{xs:"12",sm:"4",className:"paginator",children:[(0,g.jsx)("i",{className:"fa fa-book me-2"}),(0,g.jsx)(r.A,{className:"mb-2",type:"number",value:a+1,min:1,max:t,onChange:e=>n(e.target.value-1)}),(0,g.jsxs)("div",{className:"page-count",children:["\xa0/\xa0",i?(0,g.jsx)("i",{className:"fa fa-spinner fa-spin"}):t]})]}),(0,g.jsx)(d.A,{xs:"12",sm:"4",className:"page-size",children:(0,g.jsx)(r.A,{className:"mb-2",type:"select",value:s,onChange:e=>l(e.target.value),children:[20,50,100,250].map((e=>(0,g.jsxs)("option",{value:e,children:[e," rows"]},e)))})}),(0,g.jsx)(d.A,{xs:"12",sm:"2",className:"next",children:(0,g.jsx)(p.A,{className:"mb-2 pull-right btn-pagination",block:!0,color:"purple",onClick:()=>n(a+1),disabled:!t||a+1===t,children:(0,g.jsx)("i",{className:"fa fa-chevron-right"})})})]})};const x=function(e){let{previousPage:a,canPreviousPage:s,pageIndex:t,gotoPage:n,setPageSize:l,pageCount:i,nextPage:o,canNextPage:u,loading:m}=e;return(0,g.jsxs)(c.A,{className:"pagination",children:[(0,g.jsx)(d.A,{xs:"12",sm:"2",className:"previous",children:(0,g.jsx)(p.A,{className:"mb-2 btn-pagination",color:"purple",block:!0,onClick:a,disabled:!i||!s,children:(0,g.jsx)("i",{className:"fa fa-chevron-left"})})}),(0,g.jsxs)(d.A,{xs:"12",sm:"4",className:"paginator",children:[(0,g.jsx)("i",{className:"fa fa-book me-2"}),(0,g.jsx)(r.A,{className:"mb-2",type:"number",value:t+1||1,min:1,max:i,onChange:e=>n(e.target.value?Number(e.target.value)-1:0)}),(0,g.jsxs)("div",{className:"page-count",children:["\xa0/\xa0",m?(0,g.jsx)("i",{className:"fa fa-spinner fa-spin"}):i]})]}),(0,g.jsx)(d.A,{xs:"12",sm:"4",className:"page-size",children:(0,g.jsx)(r.A,{className:"mb-2",type:"select",onChange:e=>{n(0),setTimeout((()=>l(e.target.value)),1e3)},children:[20,50,100,250].map((e=>(0,g.jsxs)("option",{value:e,children:[e," rows"]},e)))})}),(0,g.jsx)(d.A,{xs:"12",sm:"2",className:"next",children:(0,g.jsx)(p.A,{className:"mb-2 pull-right btn-pagination",block:!0,color:"purple",onClick:o,disabled:!i||!u,children:(0,g.jsx)("i",{className:"fa fa-chevron-right"})})})]})};const j=function(e){let{prepareRow:a,row:s,onRowClick:t=!1}=e;return a(s),(0,g.jsx)(c.A,{onClick:()=>t&&t(s.original),className:"g-0",children:s.cells.map((e=>(0,g.jsx)(d.A,{className:-1!==e.column.id.indexOf("hdb-narrow")?"action":"",children:e.render("Cell")},"".concat(e.row.id,"-").concat(e.column.id))))})};var f=s(3628),A=s(3150);function b(e){let{value:a}=e;return(0,g.jsx)("div",{className:"text-renderer",children:a})}function v(e){let{src:a}=e;const[s,n]=(0,t.useState)(!1),[r,l]=(0,t.useState)(!1);return(0,g.jsxs)("div",{className:"image-renderer",onMouseEnter:()=>n(!0),onMouseLeave:()=>n(!1),children:[(0,g.jsx)("i",{className:"fa fa-image"}),s&&r?(0,g.jsxs)("div",{className:"preview-image no-image",children:[(0,g.jsx)("i",{className:"fa fa-ban text-danger"}),(0,g.jsx)("div",{className:"mt-2",children:"image failed to load"})]}):s?(0,g.jsx)("img",{onError:l,alt:a,src:a,className:"preview-image"}):null]})}const N={Filter:e=>{let{column:{filterValue:a,setFilter:s}}=e;return(0,g.jsx)(r.A,{type:"text",value:a||"",onChange:e=>s(e.target.value||void 0)})},Cell:e=>{let{value:a}=e;return(e=>{switch(Object.prototype.toString.call(e)){case"[object Array]":case"[object Object]":return(0,g.jsx)(b,{value:JSON.stringify(e)});case"[object Boolean]":return(0,g.jsx)(b,{value:e?"true":"false"});case"[object String]":return(a=e)&&(a.match(/^https?.*\.(jpeg|jpg|gif|png)$/)||-1!==a.indexOf("data:image"))?(0,g.jsx)(v,{src:e}):(0,g.jsx)(b,{value:e});default:return(0,g.jsx)(b,{value:e})}var a})(a)}};const C=function(e){let{columns:a,data:s,error:r,currentPage:i,pageSize:o,totalPages:c,onFilteredChange:d,onSortedChange:u,onPageChange:p,onPageSizeChange:b,showFilter:v,onRowClick:C,sorted:P,loading:S,dynamicAttributesFromDataTable:w,tableDescriptionAttributes:k,manual:F=!1}=e;const{headerGroups:z,page:y,rows:D,prepareRow:O,state:R,setAllFilters:E,canPreviousPage:T,canNextPage:_,pageOptions:H,pageCount:G,gotoPage:I,nextPage:L,previousPage:U,setPageSize:$}=(0,n.useTable)({columns:a,data:s,defaultColumn:N,onFilteredChange:d,onSortedChange:u,onPageChange:p,onPageSizeChange:b,onRowClick:C,manualPagination:F,manualFilters:F,initialState:{pageIndex:i,pageSize:o}},n.useFilters,n.usePagination),[M,B]=(0,t.useState)(!0),J=F||!y.length?D:y;return(0,t.useEffect)((()=>{!v&&R.filters.length?E([]):d(R.filters)}),[R.filters,v]),(0,t.useEffect)((()=>{setTimeout((()=>B(!1)),100)}),[null===J||void 0===J?void 0:J.length]),(0,g.jsxs)(l.tH,{onError:(e,a)=>(0,f.A)({error:{message:e.message,componentStack:a}}),FallbackComponent:A.A,children:[(0,g.jsxs)("div",{className:"react-table-scroller",children:[(0,g.jsx)(m,{headerGroups:z,tableDescriptionAttributes:k,dynamicAttributesFromDataTable:w,onSortedChange:u,sorted:P,showFilter:v}),S||M?(0,g.jsx)("div",{className:"centered text-center",children:(0,g.jsx)("i",{className:"fa fa-spinner fa-spin"})}):J.length?J.map((e=>(0,g.jsx)(j,{row:e,prepareRow:O,onRowClick:C},e.id))):(0,g.jsxs)("div",{className:"centered text-center",children:[(0,g.jsx)("i",{className:"fa fa-exclamation-triangle text-danger"}),(0,g.jsx)("div",{className:"mt-2 text-darkgrey",children:r?"Error loading data: ".concat(r):"no records"})]})]}),F?(0,g.jsx)(h,{page:i,pageSize:o,totalPages:c,onPageChange:p,onPageSizeChange:b,loading:S}):(0,g.jsx)(x,{previousPage:U,pageSize:o,canPreviousPage:T,pageIndex:R.pageIndex,pageOptions:H,gotoPage:I,setPageSize:$,pageCount:G,nextPage:L,canNextPage:_,loading:S})]})}},8222:(e,a,s)=>{s.d(a,{A:()=>r});var t=s(127),n=s(5269);const r=async e=>{let{auth:a,url:s,signal:r}=e;const l=await(0,t.A)({operation:{operation:"list_users"},auth:a,url:s,signal:r}),i=Array.isArray(l)?[...l].map((e=>({username:e.username,role:e.role.role}))).sort(((e,a)=>e.username.toLowerCase()>a.username.toLowerCase()?1:-1)):[];return n.A.update((e=>{e.users=i})),i}}}]);
|