harperdb 4.3.24 → 4.3.25
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 +22 -22
- package/bin/lite.js +17 -17
- package/launchServiceScripts/launchInstallNATSServer.js +1 -1
- package/launchServiceScripts/launchNatsIngestService.js +17 -17
- package/launchServiceScripts/launchNatsReplyService.js +17 -17
- package/launchServiceScripts/launchUpdateNodes4-0-0.js +17 -17
- package/npm-shrinkwrap.json +245 -245
- package/package.json +2 -2
- package/server/jobs/jobProcess.js +17 -17
- package/server/serverHelpers/Headers.d.ts +1 -1
- package/server/threads/threadServer.js +17 -17
- package/studio/build-local/asset-manifest.json +47 -46
- package/studio/build-local/index.html +1 -1
- package/studio/build-local/static/css/main.e1f8b48c.css +13 -0
- package/studio/build-local/static/js/23.3b9f7144.chunk.js +1 -0
- package/studio/build-local/static/js/239.183c6cbc.chunk.js +2 -0
- package/studio/build-local/static/js/{228.302d7db9.chunk.js → 279.7890bce3.chunk.js} +1 -1
- package/studio/build-local/static/js/311.3d832d8b.chunk.js +2 -0
- package/studio/build-local/static/js/311.3d832d8b.chunk.js.LICENSE.txt +38 -0
- package/studio/build-local/static/js/43.73dc432d.chunk.js +2 -0
- package/studio/build-local/static/js/452.03944f0d.chunk.js +2 -0
- package/studio/build-local/static/js/{446.5237e847.chunk.js.LICENSE.txt → 452.03944f0d.chunk.js.LICENSE.txt} +2 -2
- package/studio/build-local/static/js/545.e12f8571.chunk.js +1 -0
- package/studio/build-local/static/js/591.7498da00.chunk.js +2 -0
- package/studio/build-local/static/js/805.6aab06e2.chunk.js +1 -0
- package/studio/build-local/static/js/806.adb20036.chunk.js +1 -0
- package/studio/build-local/static/js/833.5b133801.chunk.js +1 -0
- package/studio/build-local/static/js/851.e7004b75.chunk.js +1 -0
- package/studio/build-local/static/js/860.727e7fc8.chunk.js +1 -0
- package/studio/build-local/static/js/browse-csvupload.02fdfbea.chunk.js +1 -0
- package/studio/build-local/static/js/browse-datatable.c2eb203f.chunk.js +1 -0
- package/studio/build-local/static/js/browse-entitymanager.0db076c3.chunk.js +1 -0
- package/studio/build-local/static/js/browse-jsonviewer.90814e97.chunk.js +1 -0
- package/studio/build-local/static/js/custom-functions.01f632d1.chunk.js +1 -0
- package/studio/build-local/static/js/instance-charts.217c477d.chunk.js +1 -0
- package/studio/build-local/static/js/instance-cluster.7f6df625.chunk.js +1 -0
- package/studio/build-local/static/js/instance-config.59b29ef6.chunk.js +1 -0
- package/studio/build-local/static/js/instance-query.44ba3d7b.chunk.js +1 -0
- package/studio/build-local/static/js/instance-roles.38ef8e77.chunk.js +1 -0
- package/studio/build-local/static/js/instance-status.694a7846.chunk.js +1 -0
- package/studio/build-local/static/js/instance-users-datatable.d61ab3ef.chunk.js +1 -0
- package/studio/build-local/static/js/instance-users-edit.ff5bfa06.chunk.js +1 -0
- package/studio/build-local/static/js/instance-users.c71b71f2.chunk.js +1 -0
- package/studio/build-local/static/js/instance.47c8b74b.chunk.js +1 -0
- package/studio/build-local/static/js/instances.1ec58722.chunk.js +1 -0
- package/studio/build-local/static/js/main.c58a5ba7.js +2 -0
- package/studio/build-local/static/js/{main.7106edfd.js.LICENSE.txt → main.c58a5ba7.js.LICENSE.txt} +0 -33
- package/studio/build-local/static/js/offline-app.31c18661.chunk.js +1 -0
- package/studio/build-local/static/js/online-app.0d8194e1.chunk.js +1 -0
- package/studio/build-local/static/js/organization-billing.21b2d3c9.chunk.js +1 -0
- package/studio/build-local/static/js/organization-users.532711dd.chunk.js +1 -0
- package/studio/build-local/static/js/organization.99a1e759.chunk.js +1 -0
- package/studio/build-local/static/js/organizations.4933fdbc.chunk.js +1 -0
- package/studio/build-local/static/js/profile.e4e06bdf.chunk.js +1 -0
- package/studio/build-local/static/js/resetPassword.3478535b.chunk.js +1 -0
- package/studio/build-local/static/js/roles-jsonviewer.bf1011d5.chunk.js +1 -0
- package/studio/build-local/static/js/signIn.0134746e.chunk.js +1 -0
- package/studio/build-local/static/js/signUp.c8fce52d.chunk.js +1 -0
- package/studio/build-local/static/js/structure-reloader.f65842a1.chunk.js +1 -0
- package/studio/build-local/static/js/topnav.0fa4de77.chunk.js +1 -0
- package/studio/build-local/static/js/updatePassword.bc881b36.chunk.js +1 -0
- package/utility/scripts/restartHdb.js +17 -17
- package/studio/build-local/static/css/main.6c0f1b63.css +0 -13
- package/studio/build-local/static/js/110.ca4244a6.chunk.js +0 -2
- package/studio/build-local/static/js/287.21477cf9.chunk.js +0 -1
- package/studio/build-local/static/js/409.17daa4fe.chunk.js +0 -2
- package/studio/build-local/static/js/424.ad87c8fd.chunk.js +0 -1
- package/studio/build-local/static/js/446.5237e847.chunk.js +0 -2
- package/studio/build-local/static/js/662.92e32ffc.chunk.js +0 -1
- package/studio/build-local/static/js/718.74e9355d.chunk.js +0 -1
- package/studio/build-local/static/js/723.c58acced.chunk.js +0 -2
- package/studio/build-local/static/js/731.8a941eb3.chunk.js +0 -1
- package/studio/build-local/static/js/807.510f66df.chunk.js +0 -2
- package/studio/build-local/static/js/807.510f66df.chunk.js.LICENSE.txt +0 -5
- package/studio/build-local/static/js/926.88d6f9ce.chunk.js +0 -1
- package/studio/build-local/static/js/browse-csvupload.453237f3.chunk.js +0 -1
- package/studio/build-local/static/js/browse-datatable.b9ef2d28.chunk.js +0 -1
- package/studio/build-local/static/js/browse-entitymanager.50827a5a.chunk.js +0 -1
- package/studio/build-local/static/js/browse-jsonviewer.a2534004.chunk.js +0 -1
- package/studio/build-local/static/js/custom-functions.dd7e182c.chunk.js +0 -1
- package/studio/build-local/static/js/instance-charts.34d15f02.chunk.js +0 -1
- package/studio/build-local/static/js/instance-cluster.5bce430c.chunk.js +0 -1
- package/studio/build-local/static/js/instance-config.70c17b53.chunk.js +0 -1
- package/studio/build-local/static/js/instance-query.4f6eec62.chunk.js +0 -1
- package/studio/build-local/static/js/instance-roles.507a4ed0.chunk.js +0 -1
- package/studio/build-local/static/js/instance-status.ce9d7f64.chunk.js +0 -1
- package/studio/build-local/static/js/instance-users-datatable.190640fd.chunk.js +0 -1
- package/studio/build-local/static/js/instance-users-edit.d2444479.chunk.js +0 -1
- package/studio/build-local/static/js/instance-users.eabfbbde.chunk.js +0 -1
- package/studio/build-local/static/js/instance.a163623f.chunk.js +0 -1
- package/studio/build-local/static/js/instances.6b88a87c.chunk.js +0 -1
- package/studio/build-local/static/js/main.7106edfd.js +0 -2
- package/studio/build-local/static/js/offline-app.7371216b.chunk.js +0 -1
- package/studio/build-local/static/js/online-app.db436eec.chunk.js +0 -1
- package/studio/build-local/static/js/organization-billing.b2f260f0.chunk.js +0 -1
- package/studio/build-local/static/js/organization-users.b6171b18.chunk.js +0 -1
- package/studio/build-local/static/js/organization.7800f16a.chunk.js +0 -1
- package/studio/build-local/static/js/organizations.8bb505f2.chunk.js +0 -1
- package/studio/build-local/static/js/profile.292bdd86.chunk.js +0 -1
- package/studio/build-local/static/js/resetPassword.8fdfba77.chunk.js +0 -1
- package/studio/build-local/static/js/roles-jsonviewer.c11f1816.chunk.js +0 -1
- package/studio/build-local/static/js/signIn.b11bdc50.chunk.js +0 -1
- package/studio/build-local/static/js/signUp.564d4e0b.chunk.js +0 -1
- package/studio/build-local/static/js/structure-reloader.b6de4091.chunk.js +0 -1
- package/studio/build-local/static/js/topnav.4fd41d60.chunk.js +0 -1
- package/studio/build-local/static/js/updatePassword.e23019c7.chunk.js +0 -1
- /package/studio/build-local/static/js/{723.c58acced.chunk.js.LICENSE.txt → 239.183c6cbc.chunk.js.LICENSE.txt} +0 -0
- /package/studio/build-local/static/js/{110.ca4244a6.chunk.js.LICENSE.txt → 43.73dc432d.chunk.js.LICENSE.txt} +0 -0
- /package/studio/build-local/static/js/{409.17daa4fe.chunk.js.LICENSE.txt → 591.7498da00.chunk.js.LICENSE.txt} +0 -0
|
@@ -1 +0,0 @@
|
|
|
1
|
-
"use strict";(self.webpackChunkharperdb_studio=self.webpackChunkharperdb_studio||[]).push([[641],{9716:(e,a,s)=>{s.r(a),s.d(a,{default:()=>N});var t=s(7313),r=s(9424),l=s(238),i=s(3516),n=s(6782),d=s(5399),c=s(9327),o=s(8467),h=s(3672),u=s.n(h),m=s(7387),b=s(6160),f=s(9842),p=s(5447),j=s(6449),x=s(9859),_=s(2261),Z=s(4220),k=s(6417);const N=function(e){let{newEntityAttributes:a,hashAttribute:s}=e;const{customer_id:h,schema:N,table:g,hash:v,action:w,compute_stack_id:$}=(0,o.UO)(),y=decodeURIComponent(N),C=decodeURIComponent(g),S=decodeURIComponent(v),T=(0,b.VY)(),{state:D}=(0,o.TH)(),I=(0,o.s0)(),U=(0,m.Kw)(p.Z,(e=>e.auth)),V=(0,m.Kw)(p.Z,(e=>e.url)),E=(0,m.Kw)(j.Z,(e=>e.theme)),F=(0,t.useRef)(null),[O,R]=(0,t.useState)("{}"),[A,J]=(0,t.useState)(),[K,Y]=(0,t.useState)(!0),[P,H]=(0,t.useState)(!1),[M,q]=(0,t.useState)(!1),z=`/o/${h}/i/${$}/browse/${y}/${C}`,B=async e=>{if(e.preventDefault(),K||T.error("Please insert valid JSON to proceed"),!w||!K)return!1;H(!0);const a=JSON.parse(O),s={operation:{operation:"edit"===w?"update":"insert",schema:y,table:C,records:"edit"!==w&&Array.isArray(a)?a:[a]},auth:U,url:V},{error:t,message:r}=await(0,x.Z)(s);return t?(T.error(r),H(!1)):(p.Z.update((e=>{e.lastUpdate=Date.now()})),setTimeout((()=>I(`/o/${h}/i/${$}/browse/${y}/${C}`)),1e3))};return(0,t.useEffect)((()=>{var e,a;null!==(e=F.current)&&void 0!==e&&null!==(a=e.editor)&&void 0!==a&&a.setTheme&&F.current.editor.setTheme("dark"===E?"vs-dark":"light")}),[E]),u()((()=>{a||I(z)}),[]),u()((async()=>{if("edit"===w){let a;null!==D&&void 0!==D&&D.hashValue?a=[D.hashValue]:(e=S,a=`${parseFloat(e)}`===e?[`${S}`,parseInt(S,10)]:[S]);const t=await(0,x.Z)({operation:{operation:"search_by_hash",schema:y,table:C,hash_values:a,get_attributes:["*"]},auth:U,url:V}),[r]=t;if(r){const e=r[s],a=r.__createdtime__,t=r.__updatedtime__;delete r.__createdtime__,delete r.__updatedtime__,delete r[s];const l={[s]:e,...r,__createdtime__:a,__updatedtime__:t};R(JSON.stringify(l,null,4))}else I(z),T.error("Unable to find record with that hash_attribute")}else R(JSON.stringify(a||{},null,4));var e}),[S]),(0,k.jsxs)(f.SV,{onError:(e,a)=>(0,_.Z)({error:{message:e.message,componentStack:a}}),FallbackComponent:Z.Z,children:[(0,k.jsxs)("span",{className:"floating-card-header",children:[y," ",C&&">"," ",C," ","add"===w?"> add new":S?`> edit > ${S}`:"","\xa0"]}),(0,k.jsx)(l.Z,{className:"my-3",children:(0,k.jsxs)(i.Z,{children:[(0,k.jsx)("ul",{className:"text-small",children:"add"===w&&(0,k.jsxs)(k.Fragment,{children:[(0,k.jsxs)("li",{children:['The hash_attribute for this table is "',(0,k.jsx)("b",{children:s}),'", and will auto-generate. You may manually add it if you want to specify its value.']}),(0,k.jsxs)("li",{children:[(0,k.jsx)("b",{children:"You may paste in an array"})," if you want to add more than one record at a time."]})]})}),(0,k.jsx)(l.Z,{className:"mb-2 json-editor-holder",children:(0,k.jsx)(i.Z,{children:(0,k.jsx)(r.ZP,{height:"350px",language:"json",value:O,theme:"vs-dark",onValidate:e=>{Y(0===e.length)},onChange:e=>{R(e)},onMount:(e,a)=>{F.current=a}})})}),(0,k.jsxs)(n.Z,{children:[(0,k.jsx)(d.Z,{md:"4",className:"mt-2",children:A?(0,k.jsx)("div",{className:"pt-2",children:"Delete this record?"}):(0,k.jsx)(c.Z,{disabled:P||M,id:"backToTable",block:!0,color:"black",onClick:()=>I(`/o/${h}/i/${$}/browse/${y}/${C}`),children:(0,k.jsx)("i",{className:"fa fa-chevron-left"})})}),"add"===w?(0,k.jsx)(d.Z,{md:"8",children:(0,k.jsx)(c.Z,{disabled:P||!K,id:"addEditItem",className:"mt-2",onClick:B,block:!0,color:"success",children:(0,k.jsx)("i",{className:"fa "+(P?"fa-spinner fa-spin":"fa-save")})})}):A?(0,k.jsxs)(k.Fragment,{children:[(0,k.jsx)(d.Z,{md:"4",className:"mt-2",children:(0,k.jsx)(c.Z,{disabled:P||M,id:"cancelDelete",block:!0,color:"black",onClick:()=>J(!1),children:(0,k.jsx)("i",{className:"fa fa-ban"})})}),(0,k.jsx)(d.Z,{md:"4",children:(0,k.jsx)(c.Z,{disabled:P||M,id:"deleteRecord",className:"mt-2",onClick:async e=>{if(e.preventDefault(),!w)return!1;q(!0);const{error:a,message:s}=await(0,x.Z)({operation:{operation:"delete",schema:y,table:C,hash_values:[D.hashValue]},auth:U,url:V});return a?(T.error(s),J(!1),q(!1)):setTimeout((()=>I(`/o/${h}/i/${$}/browse/${y}/${C}`)),100)},block:!0,color:"success",children:(0,k.jsx)("i",{className:"fa "+(M?"fa-spinner fa-spin":"fa-check")})})})]}):(0,k.jsxs)(k.Fragment,{children:[(0,k.jsx)(d.Z,{md:"4",className:"mt-2",children:(0,k.jsx)(c.Z,{disabled:P||M,id:"confirmDelete",block:!0,color:"danger",onClick:()=>J(S),children:(0,k.jsx)("i",{className:"fa fa-trash"})})}),(0,k.jsx)(d.Z,{md:"4",children:(0,k.jsx)(c.Z,{disabled:P||!K,id:"addEditItem",className:"mt-2",onClick:B,block:!0,color:"success",children:(0,k.jsx)("i",{className:"fa "+(P?"fa-spinner fa-spin":"fa-save")})})})]})]})]})})]})}}}]);
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
"use strict";(self.webpackChunkharperdb_studio=self.webpackChunkharperdb_studio||[]).push([[442],{3218:(e,t,n)=>{n.r(t),n.d(t,{default:()=>jt});var a=n(7313),s=n(7387),r=n(4122),l=n(5447),o=n(6782),i=n(5399),c=n(238),u=n(3516),d=n(8467),p=n(9842),m=n(1781),h=n(9327),f=n(3672),g=n.n(f),j=n(3262),x=n(9859);const v=async e=>{let{auth:t,url:n}=e;return(0,x.Z)({operation:{operation:"custom_functions_status"},auth:t,url:n,timeout:5e3})},b=async e=>{let{auth:t,url:n}=e;return(0,x.Z)({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){t===n&&(e.path=n,e.key=crypto.randomUUID());for(const s of e.entries){const e=`${t}/${s.name}`,[,r]=e.split("/");s.project=r,s.path=e,s.key=crypto.randomUUID(),s.readOnly=a||!!s.package,y(s,e,n,s.readOnly)}}}const N=async e=>{let{auth:t,url:n}=e;const a=await(0,x.Z)({operation:{operation:"get_components"},auth:t,url:n});return y(a,a.name,a.name,!1),a},w=async e=>{let{auth:t,url:n}=e;const{is_enabled:a,port:s,directory:r,error:o,message:i}=await v({auth:t,url:n}),c=await N({auth:t,url:n}),u={is_enabled:a,port:s,endpoints:a?await b({auth:t,url:n}):{},directory:r,error:o,message:i,fileTree:c};return l.Z.update((e=>{e.custom_functions=u})),{custom_functions:u}};var k=n(6417);const C=function(){const e=(0,s.Kw)(l.Z,(e=>e.auth)),t=(0,s.Kw)(l.Z,(e=>e.url)),n=(0,s.Kw)(l.Z,(e=>e.is_local)),r=(0,s.Kw)(l.Z,(e=>{var t;return null===(t=e.custom_functions)||void 0===t?void 0:t.port})),[d,p]=(0,a.useState)({}),[f,v]=(0,a.useState)({port:r||9926});return g()((async()=>{const{submitted:n}=d;if(n){const{port:n}=f;if(n)if((0,j.Z)(n)){const a=await(async e=>{let{auth:t,url:n,port:a}=e;return(0,x.Z)({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}):w({auth:e,url:t})}else p({error:"port must be a valid number"});else p({error:"All fields are required"})}}),[d]),g()((()=>{d.submitted||p({})}),[f]),n&&!r?(0,k.jsxs)(k.Fragment,{children:[(0,k.jsx)("div",{className:"text-nowrap mb-3",children:"Custom Functions Port"}),(0,k.jsx)(m.Z,{id:"custom_api_port",onChange:e=>v({...f,port:e.target.value}),className:"mb-3 "+(d.error&&!f.port?"error":""),type:"number",title:"custom api port",placeholder:"9926",value:f.port}),(0,k.jsx)(h.Z,{color:"success",block:!0,onClick:()=>p({submitted:!0}),children:"Set Custom API Port"}),!!d.error&&(0,k.jsx)(c.Z,{className:"mt-3 error",children:(0,k.jsx)(u.Z,{children:d.error})})]}):(0,k.jsxs)(o.Z,{children:[(0,k.jsxs)(i.Z,{xs:"10",children:["Custom Functions Port ",n?r:"Set"]}),(0,k.jsx)(i.Z,{xs:"2",className:"text-end",children:(0,k.jsx)("i",{className:"fa fa-check-circle fa-lg text-success"})})]})};var Z=n(4431),_=n(8147),S=n(4095);const F=function(e){let{setConfiguring:t}=e;const{compute_stack_id:n}=(0,d.UO)(),r=(0,s.Kw)(l.Z,(e=>e.auth),[n]),o=(0,s.Kw)(l.Z,(e=>e.url),[n]),i=(0,s.Kw)(l.Z,(e=>{var t;return parseFloat(null===(t=e.registration)||void 0===t?void 0:t.version)>=4?"nats":"socketcluster"}),[n]),[c,u]=(0,a.useState)({});return g()((async()=>{if(c.submitted){if("nats"===i)await(0,Z.Z)({auth:r,url:o,customFunctions_enabled:!0});else{const e=await(0,S.Z)({auth:r,url:o});await(0,Z.Z)({auth:r,url:o,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,_.Z)({auth:r,url:o}),setTimeout((()=>t(!0)),0)}}),[c.submitted]),(0,k.jsxs)(k.Fragment,{children:[(0,k.jsx)("hr",{className:"my-3"}),(0,k.jsx)(h.Z,{color:"success",disabled:c.submitted,block:!0,onClick:()=>u({submitted:!0}),children:c.submitted?(0,k.jsx)("i",{className:"fa fa-spinner fa-spin text-white"}):"Enable Custom Functions"})]})};var P=n(35),O=n(4220),E=n(2261);const D=function(e){let{setConfiguring:t}=e;const{compute_stack_id:n}=(0,d.UO)(),a=(0,s.Kw)(l.Z,(e=>{var t;return null===(t=e.custom_functions)||void 0===t?void 0:t.port}),[n]);return(0,k.jsxs)(o.Z,{id:"functions",children:[(0,k.jsxs)(i.Z,{xl:"3",lg:"4",md:"5",xs:"12",children:[(0,k.jsx)("span",{className:"floating-card-header",children:"enable custom functions"}),(0,k.jsx)(c.Z,{className:"my-3",children:(0,k.jsx)(u.Z,{children:(0,k.jsxs)(p.SV,{onError:(e,t)=>(0,E.Z)({error:{message:e.message,componentStack:t}}),FallbackComponent:O.Z,children:[(0,k.jsx)(C,{}),!!a&&(0,k.jsx)(F,{setConfiguring:t})]})})})]}),(0,k.jsx)(i.Z,{xl:"9",lg:"8",md:"7",xs:"12",children:a?(0,k.jsx)(P.Z,{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)(P.Z,{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 $=n(6160),I=n(6449);const R=async e=>{let{auth:t,url:n,project:a,file:s}=e;return(0,x.Z)({operation:{operation:"get_component_file",project:a,file:s},auth:t,url:n})},T=async e=>{let{auth:t,url:n,project:a,file:s,payload:r}=e;return(0,x.Z)({operation:{operation:"set_component_file",project:a,file:s,payload:r},auth:t,url:n})},A=async e=>{let{auth:t,url:n,project:a,file:s}=e;return(0,x.Z)({operation:{operation:"drop_component",project:a,file:s},auth:t,url:n})},U=async e=>{let{auth:t,url:n,project:a,packageUrl:s,payload:r}=e;return r?(0,x.Z)({auth:t,url:n,operation:{operation:"deploy_component",project:a,payload:r}}):(0,x.Z)({auth:t,url:n,operation:{operation:"deploy_component",project:a,package:s}})};var z=n(9358),K=n(2190);const L=(0,n(8131).Z)("editorCache");var W=n(6123),B=n.n(W);function q(){return(0,k.jsx)(c.Z,{className:"file-browser-scroll-container",children:(0,k.jsx)(u.Z,{children:(0,k.jsxs)("div",{className:"p-4",children:["You have no HarperDB 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 HarperDB Applications."]})})})}function M(e,t){const n=+Boolean(e.entries),a=+Boolean(t.entries);return n===a?e.name.localeCompare(t.name):a-n}const H=e=>Boolean(e.entries);function G(){return(0,k.jsx)("i",{className:B()("package-icon fas fa-cube")})}function V(e){let{name:t,url:n,onPackageSelect:s,selectedPackage:r}=e;const[l,o]=(0,a.useState)(Boolean(r)&&t===(null===r||void 0===r?void 0:r.name));return(0,a.useEffect)((()=>{o(r&&r.name===t)}),[r,t]),(0,k.jsxs)("button",{type:"button",onClick:e=>{s(l?null:{name:t,url:n,event:e}),o(!l)},className:B()("package",{"package-selected":l}),onKeyDown:()=>{},children:[(0,k.jsx)(G,{}),(0,k.jsx)("span",{className:"package-text",children:t})]})}function Y(e){let{directoryEntry:t,selectedFile:n,selectedFolder:a,onFileSelect:s,onFolderSelect:r,Icon:l}=e;const o=H(t),i=t.path===n,c=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");o?c&&n||r(c?null:t):s(i?null:t)},className:B()("file",{"file-selected":i,"folder-selected":c}),onKeyDown:function(){},children:[(0,k.jsx)(l,{className:"filename-icon"}),(0,k.jsx)("span",{className:"filename-text",children:t.name})]})}function J(e){let{directoryEntry:t,userOnSelect:n,onFolderSelect:s,onDeployProject:r,onFileSelect:l,onPackageSelect:o,onFileRename:i,selectedFile:c,selectedFolder:u,selectedPackage:d}=e;const[p,m]=(0,a.useState)(!0),h=[...t.entries||[]].sort(M),f=(g=t.name)&&[...g].includes(".")?g.split(".").slice(-1)[0]:null;var g;let j;return j=2===t.path.split("/").length?()=>(0,k.jsx)("i",{className:B()("project-icon fas fa-file-code")}):t.entries?()=>function(e){let{toggleClosed:t}=e;return(0,k.jsx)("i",{onClick:t,onKeyDown:t,className:B()("folder-icon fas fa-folder-open")})}({isOpen:p,toggleClosed:()=>m(!p)}):()=>function(e){let{extension:t}=e;switch(t){case"js":return(0,k.jsx)("i",{className:B()("file-icon filetype-js fab fa-js")});case"yaml":return(0,k.jsx)("i",{className:B()("file-icon filetype-yaml fas fa-cog")});default:return(0,k.jsx)("i",{className:B()("file-icon filetype-unknown far fa-file-alt")})}}({extension:f}),(0,k.jsxs)(k.Fragment,{children:["components"!==t.name?(0,k.jsx)("li",{className:B()("folder-container"),children:t.package?(0,k.jsx)(V,{selectedPackage:d,onPackageSelect:o,name:t.name,url:t.package}):(0,k.jsx)(Y,{Icon:j,selectedFile:c,selectedFolder:u,selectedPackage:d,directoryEntry:t,onDeployProject:r,onFileRename:()=>{i(t)},onFileSelect:l,onFolderSelect:s,userOnSelect:n})},t.key):null,h.map((e=>(0,k.jsx)("li",{children:(0,k.jsx)("ul",{className:B()("folder",{"folder-contents-open":!0,"folder-contents-closed":!1}),children:(0,k.jsx)(J,{selectedFile:c,selectedFolder:u,selectedPackage:d,directoryEntry:e,onFileSelect:l,onDeployProject:r,onFileRename:i,onFolderSelect:s,onPackageSelect:o,userOnSelect:n})})},e.key)))]})}const Q=function(e){var t;let{files:n,userOnSelect:a,onFileSelect:s,onPackageSelect:r,onDeployProject:l,onFileRename:o,onFolderSelect:i,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)(c.Z,{className:"file-browser-scroll-container",children:(0,k.jsx)(u.Z,{children:(0,k.jsx)("ul",{className:"file-browser",children:(0,k.jsx)(J,{selectedFile:d,selectedFolder:p,selectedPackage:m,onFileSelect:s,onFileRename:o,onFolderSelect:i,onDeployProject:l,onPackageSelect:r,userOnSelect:a,directoryEntry:n})})})}):(0,k.jsx)(q,{})};var X=n(9424);X._m.init().then((e=>{e.editor.defineTheme("hdb",{base:"vs-dark",inherit:!0,rules:[],colors:{"editor.background":"#111111"}})}));const ee={js:"javascript",yaml:"yaml",ts:"typescript",json:"json",md:"markdown",html:"html",css:"css",graphql:"graphql"};const te=function(e){let{active:t,file:n,onFileChange:s}=e;const[r,l]=(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);l(ee[e]||"plaintext")}),[n]),t?(0,k.jsx)(X.ZP,{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 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:"Create a new app",children:[(0,k.jsx)("i",{className:"fas fa-plus"}),a&&(0,k.jsxs)("span",{className:"ms-1",children:[" ",a]})]})}function ae(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 se(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 re(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 le(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=>e&&(0,k.jsx)("li",{className:"file-menu-item",children:e},crypto.randomUUID())))})};function ie(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:B()("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 ue(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:B()("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 de(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:B()("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 pe(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:B()("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 me(e){let{children:t}=e;return(0,k.jsx)("ul",{className:"editor-menu",children:t.map((e=>e&&(0,k.jsx)("li",{className:"editor-menu-item",children:e},crypto.randomUUID())))})}function he(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)(ne,{text:"Create A New Application Using The Default Template",extraClasses:"btn btn-block btn-success",onClick:n}),(0,k.jsx)(ie,{text:"Import Or Deploy A Remote Application Package",extraClasses:"btn btn-block btn-outline-success mt-2",onClick:a})]}):null}function fe(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 ge=n(8212);function je(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 ve(e,t,n){var s=this,r=(0,a.useRef)(null),l=(0,a.useRef)(0),o=(0,a.useRef)(null),i=(0,a.useRef)([]),c=(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,j="maxWait"in n,x="debounceOnServer"in n&&!!n.debounceOnServer,v=j?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=i.current,n=c.current;return i.current=c.current=null,l.current=e,u.current=d.current.apply(n,t)},n=function(e,t){h&&cancelAnimationFrame(o.current),o.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||j&&e-l.current>=v},b=function(t){return o.current=null,g&&i.current?e(t):(i.current=c.current=null,u.current)},y=function e(){var s=Date.now();if(a(s))return b(s);if(p.current){var o=t-(s-r.current),i=j?Math.min(o,v-(s-l.current)):o;n(e,i)}},N=function(){if(m||x){var d=Date.now(),h=a(d);if(i.current=[].slice.call(arguments),c.current=s,r.current=d,h){if(!o.current&&p.current)return l.current=r.current,n(y,t),f?e(r.current):u.current;if(j)return n(y,t),e(r.current)}return o.current||n(y,t),u.current}};return N.cancel=function(){o.current&&(h?cancelAnimationFrame(o.current):clearTimeout(o.current)),l.current=0,i.current=r.current=c.current=o.current=null},N.isPending=function(){return!!o.current},N.flush=function(){return o.current?b(Date.now()):u.current},N}),[f,j,t,v,g,h,m,x]);return b}function be(e,t){return e===t}function ye(e,t){return t}function Ne(e,t,n){var s=n&&n.equalityFn||be,r=(0,a.useReducer)(ye,e),l=r[0],o=r[1],i=ve((0,a.useCallback)((function(e){return o(e)}),[o]),t,n),c=(0,a.useRef)(e);return s(c.current,e)||(i(e),c.current=e),[l,i]}function we(e){let{pkg:t,setPackageSpec:n}=e;const[s,r]=(0,a.useState)((null===t||void 0===t?void 0:t.user)||""),[l]=Ne(s,300),[o,i]=(0,a.useState)((null===t||void 0===t?void 0:t.repo)||""),[c]=Ne(o,300),[u,d]=(0,a.useState)([]),[p,h]=(0,a.useState)(!1),[f,g]=(0,a.useState)((null===t||void 0===t?void 0:t.tag)||""),[j,x]=(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)||""),i((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)((()=>{l&&c?(v(!0),async function(e,t){try{const n=await fetch(`https://api.github.com/repos/${e}/${t}`),a=await n.json();return n.status<400?a.name:null}catch(n){return null}}(s,c).then((e=>{e?(x(e),y(!0),async function(e,t){const n=await fetch(`https://api.github.com/repos/${e}/${t}/git/refs/tags`);if(n.status<400)return(await n.json()).map((e=>e.ref.split("/").slice(-1)[0]));return[]}(s,c).then((e=>{v(!1),h(!0),d(e)}))):(v(!1),y(!1),x(""),d([]))})).catch((()=>{v(!1)}))):(y(!1),v(!1),d([]),g(""))}),[l,c,s]),(0,a.useEffect)((()=>{if(s&&o&&j){n(f?`${s}/${o}#semver:${f}`:`${s}/${o}`)}else n("")}),[j,f,s,n,o]),(0,k.jsxs)(k.Fragment,{children:[(0,k.jsx)(m.Z,{title:"Github Organization",className:"mt-2 form-control",valid:l.length>0&&c.length>0&&b,placeholder:"Github Organization",onChange:e=>r(e.target.value),value:s}),(0,k.jsx)(m.Z,{title:"Github Repo",className:"mt-2",placeholder:"Github Repo",onChange:e=>i(e.target.value),value:o}),(null===u||void 0===u?void 0:u.length)>0&&(0,k.jsx)(ge.ZP,{className:"react-select-container github-tag-select mt-2",classNamePrefix:"react-select",isDisabled:!j,isSearchable:!0,placeholder:"Choose a tag",onChange:e=>g(e.value),options:u.map((e=>({label:e,value:e})))})]})}function ke(e){let{pkg:t,setPackageSpec:n}=e;const[s,r]=(0,a.useState)(""),[l]=Ne(s,300),[o,i]=(0,a.useState)(""),[c,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){n(c?`${d}@${c}`:d)}else n("")}),[d,c,n]),(0,a.useEffect)((function(){l?(h(!0),async function(e){var t;const n=await fetch(`https://registry.npmjs.org/-/v1/search?text=${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}(l).then((e=>{h(!1),g(!!e),p(e),e&&async function(e){const t=await fetch(`https://registry.npmjs.org/${e}`);return(await t.json())["dist-tags"]}(e).then((e=>{i(e),u(null)})).catch((e=>{throw e}))})).catch((()=>{h(!1)}))):(p(null),i(null),u(null))}),[l]),(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:B()("input-group-text fa mt-2",{"fa-spinner fa-spin loading":m,"fa-check found":l.length>0&&f,"fa-times not-found":l.length>0&&!(m||f),"fa-check not-searching":0===l.length})})})]}),(0,k.jsx)(ge.ZP,{className:"react-select-container mt-2",classNamePrefix:"react-select",isDisabled:!s,placeholder:"Choose a tag",disabled:!o,onChange:function(e){let{value:t}=e;u(t)},options:Object.entries(o||[]).map((e=>{let[t,n]=e;return{label:`${t} (${n})`,value:t}}))})]})}function Ce(e){return function(e){try{return Boolean(new URL(e))}catch(t){return!1}}(e)&&(e.endsWith(".tar")||e.endsWith(".tar.gz")||e.endsWith(".tgz"))}function Ze(e){let{pkg:t,setPackageSpec:n}=e;const[s,r]=(0,a.useState)((null===t||void 0===t?void 0:t.url)||""),[l,o]=(0,a.useState)(Ce(null===t||void 0===t?void 0:t.url));return(0,a.useEffect)((()=>{n(l?s:"")}),[s,l,n]),(0,k.jsx)(m.Z,{type:"text",id:"tarball-url",title:"URL to gzipped tarball",className:B()("package-url-input mt-2",{invalid:!l}),value:s,onChange:e=>{o(0===e.target.value.length||Ce(e.target.value)),r(e.target.value)},placeholder:"URL to gzipped tarball"})}var _e=n(511);function Se(e){let{selectedPackage:t,onConfirm:n,onCancel:r,deployTargets:o,active:i}=e;const c=!1,[u,d]=(0,a.useState)(Boolean(t)),[p,f]=(0,a.useState)(xe(t)),[g,j]=(0,a.useState)((null===p||void 0===p?void 0:p.type)||c),[x,v]=(0,a.useState)((null===t||void 0===t?void 0:t.name)||""),[b,y]=(0,a.useState)(!0),[N,w]=(0,a.useState)(""),[C,Z]=(0,a.useState)(!1),_=(0,s.Kw)(l.Z,(e=>e.auth)),S=(0,s.Kw)(l.Z,(e=>e.url)),[F,P]=(0,a.useState)([{isCurrentInstance:!0,auth:_,instance:{url:S,instance_name:"This Instance"}}]);function O(){v(""),y(!1),j(!1),P([]),r()}return(0,a.useEffect)((function(){const e=xe(t);v((null===t||void 0===t?void 0:t.name)||""),f(xe(t)),j((null===e||void 0===e?void 0:e.type)||c),d(Boolean(t))}),[t,c]),(0,a.useEffect)((function(){y(je(x))}),[x]),i?(0,k.jsxs)("div",{className:"content-window",children:[(0,k.jsx)("h4",{className:"mb-5",children:"Import Remote App Package"}),(0,k.jsx)(m.Z,{valid:b&&x.length>0,title:"enter a name for this package",value:x,placeholder:"Application Name",onChange:e=>{v(e.target.value),y(je(e.target.value))}}),!_e.Z.is_local_studio&&(0,k.jsx)(ge.ZP,{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=o.filter((e=>t.includes(e.instance.url)));P(n)},options:o.map((e=>({label:e.instance.instance_name,value:e.instance.url})))}),(0,k.jsx)(ge.ZP,{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;j(t)},options:[{label:"A Public GitHub Repo",value:"github"},{label:"Install a gzipped .tar file from a URL",value:"url"}]}),!b&&x.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)(ke,{projectName:x,installed:u,pkg:p,setPackageSpec:w}),"github"===g&&(0,k.jsx)(we,{projectName:x,installed:u,pkg:p,setPackageSpec:w}),"url"===g&&(0,k.jsx)(Ze,{projectName:x,installed:u,pkg:p,setPackageSpec:w})]}),b&&F.length>0&&g?(0,k.jsxs)(k.Fragment,{children:[(0,k.jsx)(h.Z,{onClick:async()=>{Z(!0);try{await n(x,N,F)}catch(e){Z(!1)}Z(!1)},className:B()("btn btn-block btn-success mt-3",{loading:C}),disabled:!je(x)||!N||!F.length,children:C?(0,k.jsx)("i",{className:"install-package-status-icon fa fa-spinner fa-spin"}):"Install Package"}),(0,k.jsx)(h.Z,{onClick:O,className:"btn btn-block btn-outline-success mt-2",children:"Cancel"})]}):(0,k.jsx)(h.Z,{onClick:O,className:"btn btn-block btn-outline-success mt-3",children:"Cancel"})]}):null}function Fe(e){let{className:t,onClick:n,disabled:s,children:r}=e;const[l,o]=(0,a.useState)(!1);return(0,k.jsx)("button",{disabled:s,type:"button",onClick:async()=>{o(!0);try{await n(),o(!1)}catch(e){o(!1)}},className:B()(`${t} button-with-loader`,{loading:l}),children:l?(0,k.jsx)("i",{className:"button-with-loader-icon fas fa-spinner fa-spin"}):r})}function Pe(e){let{onCancel:t,onConfirm:n,onEnter:s,value:r,type:l,validate:o=(()=>!0)}=e;const[i,c]=(0,a.useState)(r||""),[u,d]=(0,a.useState)(!1);return(0,k.jsxs)(k.Fragment,{children:[(0,k.jsx)("input",{className:B()("w-100 text-center",{invalid:i.length>0&&!u}),autoFocus:!0,onChange:e=>{c(e.target.value),d(o(e.target.value))},onKeyDown:function(e){"Enter"===e.key?s(e.target.value):"Esc"===e.key&&t()},value:i,placeholder:`name for your new ${l}`,title:`name for your new ${l}`}),(0,k.jsx)("i",{title:"error: name must contain only alphanumeric characters, dashes and underscores.",className:B()("text-danger fa fa-warning",{hidden:u||0===i.length})}),(0,k.jsx)(Fe,{disabled:!u,className:"btn btn-success btn-block mt-3",onClick:()=>n(i),children:"OK"}),(0,k.jsx)("button",{type:"button",className:"btn btn-outline-success btn-block mt-2",onClick:t,children:"Cancel"}),i.length>0&&!u&&(0,k.jsx)("div",{className:"validation-message mt-5",children:"error: name must contain only alphanumeric characters, dashes and underscores."})]})}function Oe(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)(Pe,{type:"project",validate:je,onEnter:n,onConfirm:n,onCancel:a})]}):null}function Ee(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)(Pe,{type:"folder",selectedFolder:s,onEnter:n,onConfirm:n,onCancel:a})]}):null}function De(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)(Pe,{type:"file",onEnter:n,onConfirm:n,onCancel:a})]}):null}function $e(e){let{active:t,selectedFile:n,onConfirm:a,onCancel:s}=e;if(!t)return null;const{path:r}=n,l=r.split("/"),o=l.pop(),i=l.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:o})," File"]}),(0,k.jsx)(Fe,{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:o})," from ",(0,k.jsx)("span",{className:"text-danger",children:i.join("/")}),"?"]})]})}function Ie(e){let{active:t,selectedFolder:n,onConfirm:a,onCancel:s}=e;if(!t)return null;if(!n)return null;const r=n.path.split("/"),l=2===r.length,o=l?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:l?null===n||void 0===n?void 0:n.project:o})," ",l?"Project":"Folder"]}),(0,k.jsx)(Fe,{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:l?(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:o})," from ",(0,k.jsx)("span",{className:"text-danger",children:null===n||void 0===n?void 0:n.project}),"?"]})})]})}function Re(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)(Fe,{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",Ae="DEFAULT_FOLDER_WINDOW",Ue="CODE_EDITOR_WINDOW",ze="NAME_FILE_WINDOW",Ke="NAME_PROJECT_WINDOW",Le="NAME_PROJECT_FOLDER_WINDOW",We="INSTALL_PACKAGE_WINDOW",Be="DELETE_FILE_WINDOW",qe="DELETE_FOLDER_WINDOW",Me="DELETE_PACKAGE_WINDOW";function He(e){let{children:t}=e;return(0,k.jsx)(c.Z,{className:"editor-window",children:(0,k.jsx)(u.Z,{children:t})})}const Ge=function(e){var t,n,s,r;let{deployTargets:l,fileTree:c,onFileSave:u,onAddFile:d,onRevertFile:p,onAddProjectFolder:m,onAddProject:h,onFileChange:f,onDeleteFolder:g,onDeleteFile:j,onDeletePackage:x,onDeployProject:v,onFileSelect:b,onFileRename:y,onFolderRename:N,onInstallPackage:w,onUpdate:C,restartInstance:Z,restartingInstance:_,refreshCustomFunctions:S}=e;const[F,P]=(0,a.useState)(null),[O,E]=(0,a.useState)(null),[D,$]=(0,a.useState)(null),[I,R]=(0,a.useState)(Te),[T,A]=(0,a.useState)(null),[U,z]=(0,a.useState)(!0),[K,L]=(0,a.useState)(!1),[W,B]=(0,a.useState)(!1),q=(null===c||void 0===c||null===(t=c.entries)||void 0===t?void 0:t.length)>0,M=Boolean(q&&F),H=Boolean(q&&(F||D)),G=Boolean(F);function V(e,t){R(e),A(t)}function Y(){$(null),P(null),E(null)}function J(){V(Te,I)}return(0,k.jsxs)(o.Z,{id:"webide",children:[(0,k.jsxs)(i.Z,{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)(ne,{onClick:()=>V(Te,I),text:"app"}),(G||H)&&(0,k.jsx)("span",{className:"px-1",children:"|"}),G&&(0,k.jsx)(ae,{disabled:!G,onClick:()=>V(Le,I),text:!H&&"folder"}),H&&(0,k.jsx)(se,{disabled:!H,onClick:()=>{D?V(Me,I):F&&V(qe,I)},text:"folder"}),(M||(null===O||void 0===O?void 0:O.path))&&(0,k.jsx)("span",{className:"px-1",children:"|"}),M&&(0,k.jsx)(re,{onClick:()=>V(ze,I),disabled:!M,text:!(null!==O&&void 0!==O&&O.path)&&"file"}),(null===O||void 0===O?void 0:O.path)&&(0,k.jsx)(le,{disabled:!(null!==O&&void 0!==O&&O.path),onClick:()=>V(Be,I),text:!M&&"file"})]})}),(0,k.jsx)(Q,{files:c,root:c.path,selectedFile:null===O||void 0===O?void 0:O.path,selectedFolder:F,selectedPackage:D,onDeployProject:v,onFolderSelect:e=>{Y(),P(e),V(e?Ae:Te,I)},onPackageSelect:e=>{Y(),$(e),V(e?Ae:Te,I)},onFileSelect:async e=>{const t=!e;if(Y(),t)E(null),V(Te,I);else{const t=await b(e),{content:n,cached:a}=t;E({...e,content:n,cached:a}),V(Ue,I)}}})]}),(0,k.jsxs)(i.Z,{md:"8",xl:"9",className:"editor-window-container",children:[(0,k.jsxs)(o.Z,{className:"floating-card-header-row g-0",children:[(0,k.jsx)(i.Z,{className:"text-nowrap",children:O&&(0,k.jsxs)(k.Fragment,{children:[null===O||void 0===O||null===(n=O.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===O||void 0===O?void 0:O.size)||"..."," bytes | ",null!==O&&void 0!==O&&O.mtime?new Date(O.mtime).toLocaleTimeString():"..."]})]})}),(0,k.jsx)(i.Z,{className:"text-nowrap",children:(0,k.jsxs)(me,{children:[(0,k.jsx)(ce,{savingFile:W,disabled:!(null!==O&&void 0!==O&&O.cached&&I===Ue),onClick:async()=>{B(!0),await u(O,U),B(!1)},text:"save"}),(0,k.jsx)(pe,{loading:K,disabled:!(null!==O&&void 0!==O&&O.cached&&I===Ue),onClick:async()=>{L(!0);try{const e=await p(O),t={...O,content:e,cached:!1};E(t)}finally{L(!1)}},text:"revert"}),(0,k.jsx)("span",{className:"px-1",children:"|"}),(0,k.jsx)(ue,{restarting:_,onClick:Z,text:"restart"}),(0,k.jsx)(de,{restartAfterSave:U,onClick:()=>z(!U),text:"auto"})]})})]}),(0,k.jsxs)(He,{children:[(0,k.jsx)(he,{fileTree:c,active:I===Te,AddProjectButtonClick:()=>V(Ke,I),InstallPackageButtonClick:()=>{$(null),V(We,I)}}),(0,k.jsx)(fe,{active:I===Ae,type:D?"package":F?"folder":"nothing"}),(0,k.jsx)(Oe,{active:I===Ke,onConfirm:async function(e){await h(e),V(T,I)},onCancel:J}),(0,k.jsx)(Ee,{projectName:null===F||void 0===F?void 0:F.project,active:I===Le,selectedFolder:F,onConfirm:async function(e){await m(e,F),V(T,I)},onCancel:J}),(0,k.jsx)(De,{active:I===ze,onConfirm:async function(e){const t=await d(e,F);E(t),V(Ue,I)},onCancel:J}),(0,k.jsx)(Se,{active:I===We,onConfirm:async function(e,t,n){await w(e,t,n),$(null),V(Te,I)},onCancel:J,deployTargets:l,selectedPackage:D}),(0,k.jsx)(Re,{active:I===Me,selectedPackage:D,onConfirm:async()=>{await x(D),V(Te,I),Y()},onCancel:J}),(0,k.jsx)(Ie,{active:I===qe,selectedFolder:F,onConfirm:async()=>{await g(F),V(Te,I),Y()},onCancel:J}),(0,k.jsx)($e,{active:I===Be,selectedFile:O,onConfirm:async()=>{await j(O),V(Te,I),Y()},onCancel:J}),(0,k.jsx)(te,{active:I===Ue,file:O,onFileChange:async e=>{!function(e){const t={...O,content:e};E(t)}(e),await f({path:null===O||void 0===O?void 0:O.path,content:e}),E({...O,content:e,cached:!0})}})]})]})]})},Ve=async e=>{let{auth:t,url:n,function_content:a,project:s,type:r,file:l}=e;return(0,x.Z)({operation:{operation:"set_custom_function",function_content:a,project:s,type:r,file:l},auth:t,url:n})},Ye={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 Je=n(3517);const Qe=function(e){let{items:t,toggleDropItem:n,toggleCreate:r,baseUrl:c,restarting:u,itemType:p,project:f}=e;const g=(0,d.s0)(),j=(0,$.VY)(),v=(0,s.Kw)(l.Z,(e=>e.auth)),b=(0,s.Kw)(l.Z,(e=>e.url)),[y,N]=(0,a.useState)(!1),[C,Z]=(0,a.useState)(!1),[_,S]=(0,a.useState)(!1),F=async e=>{e.preventDefault();let n,a=!1;if(y&&!t.includes(y)||(Z(!0),a=!0),y&&!(0,Je.Z)(y)&&(Z(!0),a=!0,j.error(("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,x.Z)({operation:{operation:"add_custom_function_project",project:a},auth:t,url:n})})({auth:v,url:b,project:y});else{const e=(e=>Ye[e]||null)(p);n=await Ve({auth:v,url:b,project:f,type:p,file:y,function_content:e})}return n.error?(S(!1),r(!1),j.error(n.message)):setTimeout((async()=>(await(0,z.Z)({auth:v,url:b,service:"custom_functions"}),await w({auth:v,url:b}),g(`${c}/${y}`))),500)};return(0,a.useEffect)((()=>{n()}),[n]),(0,a.useEffect)((()=>{y&&t.find((e=>e===y))&&g(`${c}/${y}`)}),[t]),(0,k.jsxs)(o.Z,{className:"item-row form",children:[(0,k.jsx)(i.Z,{className:"input-holder",children:(0,k.jsx)(m.Z,{id:"name",invalid:C,onChange:e=>{Z(!1),N(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)(i.Z,{className:"item-action",children:_?(0,k.jsx)(h.Z,{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)(h.Z,{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)(h.Z,{id:"toggleCreate",color:"black",className:"round",onClick:()=>r(!1),children:(0,k.jsx)("i",{className:"fa fa-times text-white"})})]})})]})},Xe=async e=>{let{auth:t,url:n,project:a}=e;return(0,x.Z)({operation:{operation:"drop_custom_function_project",project:a},auth:t,url:n})};const et=function(e){let{item:t,baseUrl:n,isActive:r,toggleDropItem:c,isDropping:u,itemType:p,restarting:m}=e;const{project:f}=(0,d.UO)(),g=(0,d.s0)(),j=(0,$.VY)(),[v,b]=(0,a.useState)(!1),[y,N]=(0,a.useState)(!1),C=(0,s.Kw)(l.Z,(e=>e.auth)),Z=(0,s.Kw)(l.Z,(e=>e.url)),_=async()=>{if(!v)return!1;let e;return e="projects"===p?await Xe({auth:C,url:Z,project:t}):await(async e=>{let{auth:t,url:n,project:a,type:s,file:r}=e;return(0,x.Z)({operation:{operation:"drop_custom_function",project:a,type:s,file:r},auth:t,url:n})})({auth:C,url:Z,project:f,type:p,file:t}),e.error?(b(!1),N(!1),j.error(e.message)):(j.success(e.message),(0,z.Z)({auth:C,url:Z,service:"custom_functions"}),await w({auth:C,url:Z}),g(n))};return(0,k.jsxs)(o.Z,{title:`View${r?"ing":""} ${t}`,className:"item-row "+(r?"active":""),onClick:m?null:()=>!(r||u||v)&&g(`${n}/${t}`),tabIndex:"0",children:[(0,k.jsx)(i.Z,{className:"item-label "+(v?"text-danger text-nowrap":""),children:v?`drop ${t}?`:"projects"===p?`/${t}`:t}),(0,k.jsx)(i.Z,{className:"item-action",children:y?(0,k.jsx)(h.Z,{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)(h.Z,{id:"confirmDropItem",color:"danger",className:"round me-1",title:`confirm drop ${t}`,onClick:()=>{b(!1),N(!0),_()},children:(0,k.jsx)("i",{className:"fa fa-check text-white"})}),(0,k.jsx)(h.Z,{id:"cancelDropItem",color:"black",className:"round",title:`Cancel drop ${t}`,onClick:()=>{b(!1)},children:(0,k.jsx)("i",{className:"fa fa-times text-white"})})]}):u?(0,k.jsx)(h.Z,{id:"dropItem",color:"danger",className:"round",title:`Drop ${t}`,onClick:()=>{b(t),c(!1)},children:(0,k.jsx)("i",{className:"fa fa-minus text-white"})}):r?(0,k.jsx)(h.Z,{tabIndex:"-1",color:"purple",className:"round",children:(0,k.jsx)("i",{className:"fa fa-chevron-right"})}):null})]},t)};const tt=function(e){let{items:t,toggleDropItem:n,isDropping:a,toggleCreate:s,project:r,isCreating:l,restarting:c,itemType:u,showForm:d}=e;return(0,k.jsxs)(o.Z,{className:"floating-card-header",children:[(0,k.jsx)(i.Z,{children:"projects"===u?"projects":`/${r}/${u}`}),d&&null!==t&&void 0!==t&&t.length?(0,k.jsxs)(i.Z,{className:"text-end",children:[(0,k.jsx)(h.Z,{disabled:c,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)(h.Z,{disabled:c,id:"toggleCreate",color:"link",title:"Add Function",className:"add-remove me-1",onClick:()=>{s(!l),n(!1)},children:(0,k.jsx)("i",{className:"fa fa-plus"})})]}):null]})};const nt=function(e){let{items:t,activeItem:n,baseUrl:s,restarting:r,itemType:l,project:o,showForm:i}=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)(tt,{items:t,itemType:l,isDropping:d,toggleDropItem:p,isCreating:m,toggleCreate:h,restarting:r,project:o,showForm:i}),(0,k.jsxs)(c.Z,{className:"my-3",children:[t&&t.length?(0,k.jsx)(u.Z,{className:"scrollable "+(m?"creating":""),children:t.map((e=>(0,k.jsx)(et,{item:e,baseUrl:s,isActive:n===e,isDropping:d,toggleDropItem:p,itemType:l,restarting:r},e)))}):null,i&&t&&!t.length||m?(0,k.jsx)(u.Z,{children:(0,k.jsx)(Qe,{items:t,itemType:l,baseUrl:s,isDropping:d,toggleDropItem:p,isCreating:m,toggleCreate:h,restarting:r,project:o})}):!t||t.length||m?null:(0,k.jsx)(u.Z,{children:(0,k.jsx)("div",{className:"py-3 text-center no-content",children:"no functions found"})})]})]})};const at=function(){const e=(0,d.s0)(),t=(0,$.VY)(),{customer_id:n,compute_stack_id:r,project:p,type:m,file:f}=(0,d.UO)(),g=(0,s.Kw)(l.Z,(e=>e.auth)),j=(0,s.Kw)(l.Z,(e=>e.url)),[v,b]=(0,a.useState)(""),[y,N]=(0,a.useState)(""),w=(0,a.useCallback)((async()=>{if(p&&m&&f&&"undefined"!==f){const e=await(async e=>{let{auth:t,url:n,project:a,type:s,file:r}=e;return(0,x.Z)({operation:{operation:"get_custom_function",project:a,type:s,file:r},auth:t,url:n})})({auth:g,url:j,project:p,type:m,file:f});b(null===e||void 0===e?void 0:e.message),N(null===e||void 0===e?void 0:e.message)}else b("")}),[g,j,p,m,f,b]);return(0,a.useEffect)((()=>{w()}),[p,f,w,r]),(0,k.jsxs)(k.Fragment,{children:[(0,k.jsxs)(o.Z,{className:"floating-card-header",children:[(0,k.jsxs)(i.Z,{children:["edit >\xa0",(0,k.jsxs)("i",{children:["/",p,f&&"undefined"!==f&&`/${m}/${f}.js`]})]}),(0,k.jsxs)(i.Z,{className:"text-end",children:[(0,k.jsxs)(h.Z,{onClick:w,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)(h.Z,{onClick:()=>e(`/o/${n}/i/${r}/functions/deploy/${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)(c.Z,{className:"my-3",children:v?(0,k.jsxs)(u.Z,{children:[(0,k.jsx)("div",{className:"code-editor-holder",children:(0,k.jsx)(X.ZP,{height:"100%",defaultLanguage:"javascript",value:v,theme:"vs-dark",onChange:b})}),(0,k.jsxs)(o.Z,{children:[(0,k.jsx)(i.Z,{md:"6",className:"mt-2",children:(0,k.jsx)(h.Z,{block:!0,color:"grey",title:"Revert Code to Last Saved State",disabled:v===y,onClick:w,id:"reset",children:(0,k.jsx)("i",{className:"fa fa-undo"})})}),(0,k.jsx)(i.Z,{md:"6",className:"mt-2",children:(0,k.jsx)(h.Z,{block:!0,title:"Save Code to Instance",color:"success",id:"addEditItem",onClick:async()=>{const e=await Ve({auth:g,url:j,function_content:v,project:p,type:m,file:f});e.error?t.error(e.message):(setTimeout((()=>(0,z.Z)({auth:g,url:j,service:"custom_functions"})),500),t.success(e.message)),w()},children:(0,k.jsx)("i",{className:"fa fa-save"})})})]})]}):(0,k.jsx)(u.Z,{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 st=n(6855);const rt=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:l}}}=e;return r.is_enabled&&l?(0,k.jsx)(h.Z,{color:"success",block:!0,size:"sm",disabled:t||n[s],onClick:()=>a(s,"deploy"),children:(0,k.jsx)("i",{className:"fa "+("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:l}}}=e;return s.is_enabled&&r&&l?(0,k.jsx)(h.Z,{color:"danger",block:!0,size:"sm",disabled:n[t],onClick:()=>a(t,"drop"),children:(0,k.jsx)("i",{className:"fa "+("drop"===n[t]?"fa-spinner fa-spin":"fa-trash")})}):null}}]},lt={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.UO)(),r=(0,d.s0)(),[p]=(0,K.Z)({}),m=(0,s.Kw)(l.Z,(e=>e.auth)),f=(0,s.Kw)(l.Z,(e=>e.url)),j=(0,s.Kw)(l.Z,(e=>{var t;return null===(t=e.registration)||void 0===t?void 0:t.version})),[{payload:y,file:N},w]=(0,a.useState)([]),C=`/o/${e}/i/${t}/functions/edit/${n}`,Z=(0,s.Kw)(I.Z,(e=>e.instances.filter((e=>e.compute_stack_id!==t)))),[_,S]=j.split("."),F=_>=3&&(_>3||S>=3),[P,O]=(0,a.useState)([]),[E,D]=(0,a.useState)(F),[$,R]=(0,a.useReducer)(((e,t)=>({...e,...t})),{}),[T,A]=(0,a.useState)(lt),U=(0,a.useCallback)((()=>r(C)),[r,C]),L=(0,a.useCallback)((async(e,t)=>{const a=P.find((t=>t.compute_stack_id===e)),s=p[e];if(a&&s){R({[e]:t});let r=!1;const l=await v({auth:s,url:a.url});if(!l.error){const e=await b({auth:s,url:a.url});r=Object.keys(e).includes(n)}const o=P.map((t=>(t.compute_stack_id===e&&(t.custom_functions_status=l,t.has_current_project=r),t)));O(o),R({[e]:null})}}),[p,n,P]),W=(0,a.useCallback)((async(e,t)=>{const a=P.find((t=>t.compute_stack_id===e)),s=p[e];a&&s&&(R({[e]:t}),"deploy"===t?(await(async e=>{let{auth:t,url:n,project:a,payload:s,file:r}=e;return(0,x.Z)({operation:{operation:"deploy_custom_function_project",project:a,payload:s,file:r},auth:t,url:n})})({auth:s,url:a.url,payload:y,project:n,file:N}),E&&await(async e=>{let{auth:t,url:n,projects:a,dry_run:s=!1}=e;return(0,x.Z)({operation:{operation:"install_node_modules",projects:a,dry_run:s},auth:t,url:n})})({auth:s,url:a.url,projects:[n]}),await(0,z.Z)({auth:s,url:a.url,service:"custom_functions"})):await Xe({auth:s,url:a.url,project:n}),setTimeout((()=>{R({[e]:!1}),L(e,t)}),1e3))}),[N,p,y,n,P,L,E]);return g()((async()=>{if(m&&f&&n){w(!1);const e=await(async e=>{let{auth:t,url:n,project:a,skip_node_modules:s}=e;return(0,x.Z)({operation:{operation:"package_custom_function_project",project:a,skip_node_modules:s},auth:t,url:n})})({auth:m,url:f,project:n,skip_node_modules:E});w(e)}}),[m,f,n,E]),g()((async()=>{if(Z){const e=await Promise.all(Z.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})),{...e,custom_functions_status:s,has_auth:!0,has_current_project:Object.keys(a).includes(n)}}return{...e,custom_functions_status:!1}})));O(e)}}),[Z,n]),(0,a.useEffect)((()=>{A({...T,totalPages:Math.ceil((P.length||T.pageSize)/T.pageSize)})}),[A,T.pageSize]),(0,k.jsxs)(k.Fragment,{children:[(0,k.jsxs)(o.Z,{className:"floating-card-header",children:[(0,k.jsxs)(i.Z,{children:["deploy ",n&&`> ${n}`]}),(0,k.jsxs)(i.Z,{className:"text-end",children:[F&&(0,k.jsxs)(k.Fragment,{children:[(0,k.jsxs)(h.Z,{color:"link",title:"Turn on autofresh",onClick:()=>D(!E),children:[(0,k.jsx)("span",{className:"me-2",children:"install dependencies at destination"}),(0,k.jsx)("i",{className:"fa fa-lg fa-toggle-"+(E?"on":"off")})]}),(0,k.jsx)("span",{className:"mx-3 text",children:"|"})]}),(0,k.jsxs)(h.Z,{onClick:U,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)(c.Z,{className:"my-3",children:(0,k.jsx)(u.Z,{className:"react-table-holder",children:P.length?(0,k.jsx)(st.Z,{columns:rt({initializing:!y,loading:$,handleClick:W}),data:P,page:T.page,pageSize:T.pageSize,totalPages:T.totalPages,showFilter:T.showFilter,sorted:T.sorted,onFilteredChange:e=>A({...T,filtered:e}),onSortedChange:e=>A({...T,sorted:e}),onPageChange:e=>A({...T,pageSize:e}),onPageSizeChange:e=>A({...T,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 it=function(e){let{loading:t,refreshCustomFunctions:n,restarting:a}=e;const r=(0,s.Kw)(l.Z,(e=>e.auth)),o=(0,s.Kw)(l.Z,(e=>e.url));return(0,k.jsxs)("span",{className:"structure-reloader d-block text-center mb-4",children:[(0,k.jsxs)(h.Z,{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 "+(t?"fa-spinner fa-spin":"fa-sync-alt")})]}),(0,k.jsx)("span",{className:"mx-3 text",children:"|"}),(0,k.jsxs)(h.Z,{disabled:a,color:"link",onClick:()=>(0,z.Z)({auth:r,url:o,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 "+(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)(c.Z,{className:"my-3",children:(0,k.jsx)(u.Z,{children:(0,k.jsxs)(o.Z,{className:"item-row",children:[(0,k.jsx)(i.Z,{className:"item-label",children:a?"enabled":'"static" subfolder not found'}),(0,k.jsxs)(i.Z,{className:"item-action",children:[(0,k.jsx)(h.Z,{tabIndex:"-1",color:a?"success":"danger",disabled:!a,className:"round me-1",children:a}),(0,k.jsx)(h.Z,{tabIndex:"-1",color:"purple",className:"round",disabled:!a,href:`${t}/${n}/static`,target:"_blank",rel:"noopener noreferrer",children:(0,k.jsx)("i",{title:"View UI",className:"fa fa-share"})})]})]})})})]})};var ut=n(7266);const dt=function(e){var t,n,c;let{refreshCustomFunctions:u,loading:m}=e;const{customer_id:h,compute_stack_id:f,action:g="edit",project:j,file:x}=(0,d.UO)(),v=(0,d.s0)(),b=(0,s.Kw)(l.Z,(e=>e.custom_functions)),y=(0,s.Kw)(l.Z,(e=>e.registration)),[N,w]=((null===y||void 0===y?void 0:y.version)||"").split("."),C=parseFloat(`${N}.${w}`)<4.1,Z=(0,s.Kw)(l.Z,(e=>"custom_functions"===e.restarting_service)),_=(0,s.Kw)(l.Z,(e=>{var t;return e.custom_functions_url||`${e.url.split(":").slice(0,-1).join(":")}:${null===(t=e.custom_functions)||void 0===t?void 0:t.port}`})),S=`/o/${h}/i/${f}/functions/${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(j);if(e&&j&&!t){const e=j&&Object.keys(null===b||void 0===b?void 0:b.endpoints)[0];v(`${S}/${e}`)}else if(e&&j&&!x){var n,a;const e=j&&(null===b||void 0===b||null===(n=b.endpoints[j])||void 0===n?void 0:n.routes[0]),t=j&&(null===b||void 0===b||null===(a=b.endpoints[j])||void 0===a?void 0:a.helpers[0]);v(`${S}/${j}/${e?"routes":"helpers"}/${e||t}`)}else if(e&&!j){const e=Object.keys(null===b||void 0===b?void 0:b.endpoints)[0];v(`${S}/${e}`)}else e||v(S)}),[null===b||void 0===b?void 0:b.endpoints,h,f,v,g,j,x,S]),(0,r.Z)((async()=>{if(_&&Z)try{await fetch(_),l.Z.update((e=>{e.restarting_service=!1}))}catch(e){console.log(e)}}),1e3),(0,k.jsxs)(o.Z,{id:"functions",children:[(0,k.jsx)(i.Z,{xl:"3",lg:"4",md:"6",xs:"12",children:(0,k.jsxs)(p.SV,{onError:(e,t)=>(0,E.Z)({error:{message:e.message,componentStack:t}}),FallbackComponent:O.Z,children:[(0,k.jsx)(nt,{itemType:"projects",items:Object.keys(null===b||void 0===b?void 0:b.endpoints)||[],activeItem:j,baseUrl:S,restarting:Z,showForm:"edit"===g}),j&&"edit"===g&&(0,k.jsxs)(k.Fragment,{children:[(0,k.jsx)(nt,{itemType:"routes",items:j&&(null===b||void 0===b||null===(t=b.endpoints[j])||void 0===t?void 0:t.routes)||[],project:j,activeItem:x,baseUrl:`${S}/${j}/routes`,restarting:Z,showForm:"edit"===g}),(0,k.jsx)(nt,{itemType:"helpers",items:j&&(null===b||void 0===b||null===(n=b.endpoints[j])||void 0===n?void 0:n.helpers)||[],project:j,activeItem:x,baseUrl:`${S}/${j}/helpers`,restarting:Z,showForm:"edit"===g}),C&&(0,k.jsx)(ct,{url:_,project:j,fileCount:j&&(null===b||void 0===b||null===(c=b.endpoints[j])||void 0===c?void 0:c.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)(ut.Z,{text:b.directory}),(0,k.jsx)("div",{className:"text-bold mb-1 mt-3",children:"Custom Functions Server URL"}),(0,k.jsx)(ut.Z,{text:_})]}),(0,k.jsx)("hr",{}),(0,k.jsx)(it,{refreshCustomFunctions:u,loading:m,restarting:Z})]})}),(0,k.jsx)(i.Z,{xl:"9",lg:"8",md:"6",xs:"12",children:"deploy"===g?(0,k.jsx)(ot,{}):j?(0,k.jsx)(at,{}):(0,k.jsx)(P.Z,{refreshCustomFunctions:u,headline:`Please ${null!==b&&void 0!==b&&b.endpoints.length?"choose":"create"} a project at left.`})})]})};function pt(e){return e.split("/").slice(2).join("/")}function mt(e,t,n,a){return e.reduce(((e,s)=>{const r=s.compute_stack_id,l=t[r];if(null===l||void 0===l||!l.version)return e;const[o,i]=(null===l||void 0===l?void 0:l.version.split("."))||[];return parseInt(o,10)>=4&&parseInt(i,10)>=2&&e.push({isCurrentInstance:r===n,auth:a,instance:s}),e}),[])}const ht=function(e){let{refreshCustomFunctions:t,loading:n}=e;const{compute_stack_id:r}=(0,d.UO)(),o=(0,s.Kw)(l.Z,(e=>e.registration)),{fileTree:i}=(0,s.Kw)(l.Z,(e=>e.custom_functions)),c=(0,s.Kw)(l.Z,(e=>e.auth)),u=(0,s.Kw)(l.Z,(e=>e.url)),[p,m]=((null===o||void 0===o?void 0:o.version)||"").split(".")||[],h=parseFloat(`${p}.${m}`)>=4.2,f=(0,s.Kw)(I.Z,(e=>e.instances)),[g]=(0,K.Z)({}),[j,v]=L({}),[b,y]=(0,a.useState)(!1),N=(0,$.VY)();function w(e){let{path:t}=e;const n={...j},a=`${r}_${t}`;a in n&&delete n[a],v({...n})}async function C(e){let{auth:t,url:n}=e;y(!0),setTimeout((async()=>{await(0,z.Z)({auth:t,url:n,service:"http_workers"}),y(!1)}),100)}return h?(0,k.jsx)(Ge,{fileTree:i,deployTargets:mt(f,g,r,c),onRevertFile:async function(e){w({path:e.path});const{error:n,message:a}=await R({auth:c,url:u,project:e.project,file:pt(e.path)});return n?N.error(a):(await t(),a)},onFileChange:async function(e){const{path:t,content:n}=e,a=`${r}_${t}`;v({...j,[a]:n})},onFileSave:async function(e,n){const a=e.path.split("/").slice(2).join("/"),s={auth:c,url:u,project:e.project,file:a,payload:e.content},{error:r,message:l}=await T(s);r&&N.error(l),n&&await C({auth:c,url:u}),w({path:e.path}),e.cached=!1,await t()},onUpdate:t,onAddFile:async function(e,n){const{path:a,project:s}=n,r=pt(a),l=r?`${r}/${e}`:e;return await T({auth:c,url:u,project:s,file:l,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,x.Z)({operation:{operation:"add_component",project:a},auth:t,url:n})})({auth:c,url:u,project:e});n&&N.error(a),await(0,z.Z)({auth:c,url:u,service:"http_workers"}),await t()},onAddProjectFolder:async function(e,n){const{path:a,project:s}=n,r=pt(a),l=r?`${r}/${e}`:e,{error:o,message:i}=await T({auth:c,url:u,project:s,file:l});o&&N.error(i),await t()},onInstallPackage:async function(e,n,a){const s=a.map((async t=>{const{error:a,message:s}=await U({auth:t.auth,url:t.instance.url,project:e,packageUrl:n});a&&N.error(s),await(0,z.Z)({auth:t.auth,url:t.instance.url,service:"http_workers"})}));await Promise.all(s),await t(),await t()},onDeployProject:async function(e){let{project:n,deployTarget:a}=e;const{auth:s,instance:r}=a,{payload:l}=await(async e=>{let{auth:t,url:n,project:a,skip_node_modules:s=!0}=e;return(0,x.Z)({auth:t,url:n,operation:{operation:"package_component",project:a,skip_node_modules:s}})})({auth:c,url:u,project:n.name});await U({auth:s,url:r.url,project:n.name,payload:l}),await(0,z.Z)({auth:s,url:r.url,service:"http_workers"}),await(0,z.Z)({auth:c,url:u,service:"http_workers"}),await t()},onDeleteFile:async function(e){const{error:n,message:a}=await A({auth:c,url:u,project:e.project,file:pt(e.path)});n&&N.error(a),await t()},onDeleteFolder:async function(e){let{path:n,project:a}=e;const s=pt(n);if(s.length>0){const{error:e,message:t}=await A({auth:c,url:u,project:a,file:s});e&&N.error(t)}else{const{error:e,message:t}=await A({auth:c,url:u,project:a});e&&N.error(t)}await t()},onDeletePackage:async function(e){let{name:n}=e;const{error:a,message:s}=await A({auth:c,url:u,project:n});a?N.error(s):(await(0,z.Z)({auth:c,url:u,service:"http_workers"}),await t())},onFileSelect:async function(e){const{path:t,project:n,name:a}=e,s=pt(t),l=`${r}_${t}`,o=j[l],i=l in j;if(i)return{cached:i,content:o,path:t,project:n,name:a};const{error:d,message:p}=await R({auth:c,url:u,project:n,file:s});return d?(N.error(p),{content:"",path:t,project:n,name:a,cached:!1}):{cached:i,content:p,path:t,project:n,name:a}},onFileRename:async function(e,n){const{path:a,content:s,project:r}=n,l=pt(a).split("/").slice(0,-1).join("/"),o=l?`${l}/${e}`:e;await A({auth:c,url:u,project:r,file:pt(a)}),await T({auth:c,url:u,project:r,file:o,payload:s}),t()},onFolderRename:async function(){},refreshingCustomFunctions:n,restartInstance:async()=>C({auth:c,url:u}),restartingInstance:b}):(0,k.jsx)(dt,{refreshCustomFunctions:t,loading:n})};const ft=function(){return(0,k.jsxs)(k.Fragment,{children:[(0,k.jsx)("div",{className:"floating-card-header text-end",children:"\xa0"}),(0,k.jsx)(c.Z,{className:"my-3",children:(0,k.jsx)(u.Z,{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 HarperDB"}),(0,k.jsx)("li",{children:"Use HarperDB 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 HarperDB Studio, or use your own IDE and Version Management System"}),(0,k.jsx)("li",{children:"Distribute your Custom Functions to all your HarperDB instances with a single click"})]})})]})})})]})};var gt=n(7377);const jt=function(){const e=(0,s.Kw)(l.Z,(e=>e.auth)),t=(0,s.Kw)(l.Z,(e=>e.url)),n=(0,s.Kw)(l.Z,(e=>e.custom_functions)),o=(0,s.Kw)(l.Z,(e=>e.registration)),[i,c]=((null===o||void 0===o?void 0:o.version)||"").split(".")||[],u=parseFloat(`${i}.${c}`)>=4.2,d=(0,s.Kw)(l.Z,(e=>e.restarting)),[p,m]=(0,a.useState)(!1),[h,f]=(0,a.useState)(!0),[g,j]=(0,a.useState)(!1),x=(0,a.useCallback)((async()=>{e&&t&&!d&&(f(!0),await w({auth:e,url:t}),f(!1))}),[e,t,d]);return(0,a.useEffect)((()=>{x()}),[x]),(0,a.useEffect)((()=>{const e=(null===n||void 0===n?void 0:n.is_enabled)&&(null===n||void 0===n?void 0:n.port)||u;m(e),e&&j(!1)}),[n,u]),(0,r.Z)((()=>{g&&x()}),2e3),n?n.error?(0,k.jsx)(ft,{}):g?(0,k.jsx)(P.Z,{description:"Configuring Custom Functions",icon:(0,k.jsx)("i",{className:"fa fa-spinner fa-spin"})}):p?(0,k.jsx)(ht,{refreshCustomFunctions:x,loading:h}):(0,k.jsx)(D,{setConfiguring:j}):(0,k.jsx)(gt.Z,{header:"loading custom functions",spinner:!0})}},7266:(e,t,n)=>{n.d(t,{Z:()=>c});var a=n(7313),s=n(6782),r=n(5399),l=n(9327),o=n(6160),i=n(6417);const c=function(e){let{text:t,beforeText:n,afterText:c,obscure:u=!1}=e;const d=(0,o.VY)(),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,i.jsxs)(s.Z,{className:"copyable-text-holder g-0",children:[p&&t&&(0,i.jsx)(r.Z,{className:"copy-icon",children:(0,i.jsx)(l.Z,{title:"Copy this value",onClick:m,color:"link",children:(0,i.jsx)("i",{className:"fa fa-copy text-small"})})}),(0,i.jsx)(r.Z,{className:"text-container",children:t?(0,i.jsxs)(i.Fragment,{children:[n,u?t.replace(/./g,"*"):t,c]}):(0,i.jsx)("span",{children:"\xa0"})})]})}},6855:(e,t,n)=>{n.d(t,{Z:()=>b});var a=n(7313),s=n(5110),r=n(1781),l=n(9842),o=n(6782),i=n(5399),c=n(6417);const u=e=>{let{headerGroups:t,onSortedChange:n,sorted:a,showFilter:s}=e;return t.map((e=>(0,c.jsxs)("div",{...e.getHeaderGroupProps(),children:[(0,c.jsx)(o.Z,{className:"header g-0",children:e.headers.map((e=>{var t,s;return(0,c.jsx)(i.Z,{onClick:()=>{var t,s;return 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:`${(null===(t=a[0])||void 0===t?void 0:t.id)===e.id?"sorted":""} ${null!==(s=a[0])&&void 0!==s&&s.desc?"desc":"asc"} ${-1!==e.id.indexOf("hdb-narrow")?"action":""} px-1`,children:(0,c.jsx)("div",{className:"text-renderer",children:e.render("Header")})},e.id)}))}),s&&(0,c.jsx)(o.Z,{className:"filter g-0",children:e.headers.map((e=>(0,c.jsx)(i.Z,{className:-1!==e.id.indexOf("hdb-narrow")?"action":"",children:e.render("Filter")},e.id)))})]})))};var d=n(9327);const p=function(e){let{page:t,pageSize:n,totalPages:a,onPageChange:s,onPageSizeChange:l,loading:u}=e;return(0,c.jsxs)(o.Z,{className:"pagination",children:[(0,c.jsx)(i.Z,{xs:"12",sm:"2",className:"previous",children:(0,c.jsx)(d.Z,{className:"mb-2 btn-pagination",color:"purple",block:!0,onClick:()=>s(t-1),disabled:!a||0===t,children:(0,c.jsx)("i",{className:"fa fa-chevron-left"})})}),(0,c.jsxs)(i.Z,{xs:"12",sm:"4",className:"paginator",children:[(0,c.jsx)("i",{className:"fa fa-book me-2"}),(0,c.jsx)(r.Z,{className:"mb-2",type:"number",value:t+1,min:1,max:a,onChange:e=>s(e.target.value-1)}),(0,c.jsxs)("div",{className:"page-count",children:["\xa0/\xa0",u?(0,c.jsx)("i",{className:"fa fa-spinner fa-spin"}):a]})]}),(0,c.jsx)(i.Z,{xs:"12",sm:"4",className:"page-size",children:(0,c.jsx)(r.Z,{className:"mb-2",type:"select",value:n,onChange:e=>l(e.target.value),children:[20,50,100,250].map((e=>(0,c.jsxs)("option",{value:e,children:[e," rows"]},e)))})}),(0,c.jsx)(i.Z,{xs:"12",sm:"2",className:"next",children:(0,c.jsx)(d.Z,{className:"mb-2 pull-right btn-pagination",block:!0,color:"purple",onClick:()=>s(t+1),disabled:!a||t+1===a,children:(0,c.jsx)("i",{className:"fa fa-chevron-right"})})})]})};const m=function(e){let{previousPage:t,canPreviousPage:n,pageIndex:a,gotoPage:s,setPageSize:l,pageCount:u,nextPage:p,canNextPage:m,loading:h}=e;return(0,c.jsxs)(o.Z,{className:"pagination",children:[(0,c.jsx)(i.Z,{xs:"12",sm:"2",className:"previous",children:(0,c.jsx)(d.Z,{className:"mb-2 btn-pagination",color:"purple",block:!0,onClick:t,disabled:!u||!n,children:(0,c.jsx)("i",{className:"fa fa-chevron-left"})})}),(0,c.jsxs)(i.Z,{xs:"12",sm:"4",className:"paginator",children:[(0,c.jsx)("i",{className:"fa fa-book me-2"}),(0,c.jsx)(r.Z,{className:"mb-2",type:"number",value:a+1||1,min:1,max:u,onChange:e=>s(e.target.value?Number(e.target.value)-1:0)}),(0,c.jsxs)("div",{className:"page-count",children:["\xa0/\xa0",h?(0,c.jsx)("i",{className:"fa fa-spinner fa-spin"}):u]})]}),(0,c.jsx)(i.Z,{xs:"12",sm:"4",className:"page-size",children:(0,c.jsx)(r.Z,{className:"mb-2",type:"select",onChange:e=>{s(0),setTimeout((()=>l(e.target.value)),1e3)},children:[20,50,100,250].map((e=>(0,c.jsxs)("option",{value:e,children:[e," rows"]},e)))})}),(0,c.jsx)(i.Z,{xs:"12",sm:"2",className:"next",children:(0,c.jsx)(d.Z,{className:"mb-2 pull-right btn-pagination",block:!0,color:"purple",onClick:p,disabled:!u||!m,children:(0,c.jsx)("i",{className:"fa fa-chevron-right"})})})]})};const h=function(e){let{prepareRow:t,row:n,onRowClick:a=!1}=e;return t(n),(0,c.jsx)(o.Z,{onClick:()=>a&&a(n.original),className:"g-0",children:n.cells.map((e=>(0,c.jsx)(i.Z,{className:-1!==e.column.id.indexOf("hdb-narrow")?"action":"",children:e.render("Cell")},`${e.row.id}-${e.column.id}`)))})};var f=n(2261),g=n(4220);function j(e){let{value:t}=e;return(0,c.jsx)("div",{className:"text-renderer",children:t})}function x(e){let{src:t}=e;const[n,s]=(0,a.useState)(!1),[r,l]=(0,a.useState)(!1);return(0,c.jsxs)("div",{className:"image-renderer",onMouseEnter:()=>s(!0),onMouseLeave:()=>s(!1),children:[(0,c.jsx)("i",{className:"fa fa-image"}),n&&r?(0,c.jsxs)("div",{className:"preview-image no-image",children:[(0,c.jsx)("i",{className:"fa fa-ban text-danger"}),(0,c.jsx)("div",{className:"mt-2",children:"image failed to load"})]}):n?(0,c.jsx)("img",{onError:l,alt:t,src:t,className:"preview-image"}):null]})}const v={Filter:e=>{let{column:{filterValue:t,setFilter:n}}=e;return(0,c.jsx)(r.Z,{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,c.jsx)(j,{value:JSON.stringify(e)});case"[object Boolean]":return(0,c.jsx)(j,{value:e?"true":"false"});case"[object String]":return(t=e)&&(t.match(/^https?.*\.(jpeg|jpg|gif|png)$/)||-1!==t.indexOf("data:image"))?(0,c.jsx)(x,{src:e}):(0,c.jsx)(j,{value:e});default:return(0,c.jsx)(j,{value:e})}var t})(t)}};const b=function(e){let{columns:t,data:n,currentPage:r,pageSize:o,totalPages:i,onFilteredChange:d,onSortedChange:j,onPageChange:x,onPageSizeChange:b,showFilter:y,onRowClick:N,sorted:w,loading:k,manual:C=!1}=e;const{headerGroups:Z,page:_,rows:S,prepareRow:F,state:P,setAllFilters:O,canPreviousPage:E,canNextPage:D,pageOptions:$,pageCount:I,gotoPage:R,nextPage:T,previousPage:A,setPageSize:U}=(0,s.useTable)({columns:t,data:n,defaultColumn:v,onFilteredChange:d,onSortedChange:j,onPageChange:x,onPageSizeChange:b,onRowClick:N,manualPagination:C,manualFilters:C,initialState:{pageIndex:r,pageSize:o}},s.useFilters,s.usePagination),[z,K]=(0,a.useState)(!0),L=C||!_.length?S:_;return(0,a.useEffect)((()=>{!y&&P.filters.length?O([]):d(P.filters)}),[P.filters,y]),(0,a.useEffect)((()=>{setTimeout((()=>K(!1)),100)}),[null===L||void 0===L?void 0:L.length]),(0,c.jsxs)(l.SV,{onError:(e,t)=>(0,f.Z)({error:{message:e.message,componentStack:t}}),FallbackComponent:g.Z,children:[(0,c.jsxs)("div",{className:"react-table-scroller",children:[(0,c.jsx)(u,{headerGroups:Z,onSortedChange:j,sorted:w,showFilter:y}),k||z?(0,c.jsx)("div",{className:"centered text-center",children:(0,c.jsx)("i",{className:"fa fa-spinner fa-spin"})}):L.length?L.map((e=>(0,c.jsx)(h,{row:e,prepareRow:F,onRowClick:N},e.id))):(0,c.jsxs)("div",{className:"centered text-center",children:[(0,c.jsx)("i",{className:"fa fa-exclamation-triangle text-danger"}),(0,c.jsx)("div",{className:"mt-2 text-darkgrey",children:"no records"})]})]}),C?(0,c.jsx)(p,{page:r,pageSize:o,totalPages:i,onPageChange:x,onPageSizeChange:b,loading:k}):(0,c.jsx)(m,{previousPage:A,pageSize:o,canPreviousPage:E,pageIndex:P.pageIndex,pageOptions:$,gotoPage:R,setPageSize:U,pageCount:I,nextPage:T,canNextPage:D,loading:k})]})}},7093:(e,t,n)=>{n.d(t,{Z:()=>s});var a=n(9859);const s=async e=>{let{auth:t,url:n}=e;return(0,a.Z)({operation:{operation:"get_configuration"},auth:t,url:n})}},5200:(e,t,n)=>{n.d(t,{Z:()=>r});var a=n(9859),s=n(5447);const r=async e=>{let{auth:t,url:n}=e;const r=await(0,a.Z)({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.Z.update((e=>{e.roles=l})),l}},2066:(e,t,n)=>{n.d(t,{Z:()=>r});var a=n(9859),s=n(5447);const r=async e=>{let{auth:t,url:n,signal:r}=e;const l=await(0,a.Z)({operation:{operation:"list_users"},auth:t,url:n,signal:r}),o=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.Z.update((e=>{e.users=o})),o}},8147:(e,t,n)=>{n.d(t,{Z:()=>r});var a=n(9859),s=n(5447);const r=async e=>{let{auth:t,url:n}=e;return s.Z.update((e=>{e.restarting=!0})),(0,a.Z)({operation:{operation:"restart"},auth:t,url:n})}},9358:(e,t,n)=>{n.d(t,{Z:()=>r});var a=n(9859),s=n(5447);const r=async e=>{let{auth:t,url:n,service:r=null}=e;return r?(s.Z.update((e=>{e.restarting_service=r})),(0,a.Z)({operation:{operation:"restart_service",service:r},auth:t,url:n})):{error:!0,message:"You must specify a service"}}},4431:(e,t,n)=>{n.d(t,{Z:()=>s});var a=n(9859);const s=async e=>{let{auth:t,url:n,...s}=e;return(0,a.Z)({operation:{operation:"set_configuration",...s},auth:t,url:n})}},4095:(e,t,n)=>{n.d(t,{Z:()=>i});var a=n(7093),s=n(5200),r=n(2066),l=n(5491),o=n(9859);const i=async e=>{let{auth:t,url:n}=e;const i=await(0,a.Z)({auth:t,url:n}),c=await(0,l.Z)({auth:t,url:n}),u=await(async e=>{let{auth:t,url:n}=e;return(0,o.Z)({operation:{operation:"cluster_status"},auth:t,url:n})})({auth:t,url:n}),d=parseFloat(null===c||void 0===c?void 0:c.version)>=4?"nats":"socketcluster",p=await(0,s.Z)({auth:t,url:n});let m=!1;p.error||(m=p.find((e=>e.permission.cluster_user)));const h=await(0,r.Z)({auth:t,url:n});let f=!1;h.error||(f=m&&h.find((e=>e.role===m.role)));const g="nats"===d?i.clustering.enabled:i.CLUSTERING,j="nats"===d?i.clustering.user:i.CLUSTERING_USER,x="nats"===d?i.clustering.hubServer.cluster.network.port:i.CLUSTERING_PORT,v="nats"===d?i.clustering.nodeName:i.NODE_NAME;return{is_ready:!!g&&!!f&&!!j&&!!m&&!!x&&!!v,cluster_role:m,cluster_user:f,is_enabled:g,config_cluster_user:j,config_cluster_port:x,node_name:v,engine:d,status:null===u||void 0===u?void 0:u.status,message:null===u||void 0===u?void 0:u.message,connections:null===u||void 0===u?void 0:u.connections}}},3517:(e,t,n)=>{n.d(t,{Z:()=>a});const a=e=>e.match(/^[-a-zA-Z0-9_]+$/)},3262:(e,t,n)=>{n.d(t,{Z:()=>a});const a=e=>!Number.isNaN(parseFloat(e))&&Number.isFinite(parseFloat(e))},1781:(e,t,n)=>{n.d(t,{Z:()=>b});var a=n(7313),s=n(5192),r=n.n(s),l=n(6123),o=n.n(l),i=n(986);function c(e){return c="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},c(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=j(e);if(t){var s=j(this).constructor;n=Reflect.construct(a,arguments,s)}else n=a.apply(this,arguments);return function(e,t){if(t&&("object"===c(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 j(e){return j=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(e){return e.__proto__||Object.getPrototypeOf(e)},j(e)}var x={children:r().node,type:r().string,size:r().oneOfType([r().number,r().string]),bsSize:r().string,valid:r().bool,invalid:r().bool,tag:i.iC,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)}(l,e);var t,n,s,r=f(l);function l(e){var t;return function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,l),(t=r.call(this,e)).getRef=t.getRef.bind(g(t)),t.focus=t.focus.bind(g(t)),t}return t=l,(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,l=e.bsSize,c=e.valid,m=e.invalid,h=e.tag,f=e.addon,g=e.plaintext,j=e.innerRef,x=p(e,u),v=["switch","radio","checkbox"].indexOf(r)>-1,b="select"===r,y="range"===r,N=h||(b||"textarea"===r?r:"input"),w="form-control";g?(w="".concat(w,"-plaintext"),N=h||"input"):y?w="form-range":b?w="form-select":v&&(w=f?null:"form-check-input"),x.size&&/\D/g.test(x.size)&&((0,i.O4)('Please use the prop "bsSize" instead of the "size" to bootstrap\'s input sizing.'),l=x.size,delete x.size);var k=(0,i.mx)(o()(t,m&&"is-invalid",c&&"is-valid",!!l&&(b?"form-select-".concat(l):"form-control-".concat(l)),w),n);return("input"===N||h&&"function"===typeof h)&&(x.type="switch"===r?"checkbox":r),x.children&&!g&&"select"!==r&&"string"===typeof N&&"select"!==N&&((0,i.O4)('Input with a type of "'.concat(r,'" cannot have children. Please use "value"/"defaultValue" instead.')),delete x.children),a.createElement(N,d({},x,{ref:j,className:k,"aria-invalid":m}))}}])&&m(t.prototype,n),s&&m(t,s),Object.defineProperty(t,"prototype",{writable:!1}),l}(a.Component);v.propTypes=x;const b=v}}]);
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
"use strict";(self.webpackChunkharperdb_studio=self.webpackChunkharperdb_studio||[]).push([[60],{7606:(e,t,r)=>{r.r(t),r.d(t,{default:()=>B});var s=r(7313),a=r(238),i=r(3516),l=r(9327),o=r(6782),n=r(5399),c=r(7387),d=r(8467),u=r(6160),m=r(4122),h=r(6449),p=r(5447),f=r(5192),b=r.n(f),g=r(6123),x=r.n(g),v=r(986),j=["className","cssModule","size","vertical","tag"];function y(){return y=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var r=arguments[t];for(var s in r)Object.prototype.hasOwnProperty.call(r,s)&&(e[s]=r[s])}return e},y.apply(this,arguments)}function Z(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var s=Object.getOwnPropertySymbols(e);t&&(s=s.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),r.push.apply(r,s)}return r}function _(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function k(e,t){if(null==e)return{};var r,s,a=function(e,t){if(null==e)return{};var r,s,a={},i=Object.keys(e);for(s=0;s<i.length;s++)r=i[s],t.indexOf(r)>=0||(a[r]=e[r]);return a}(e,t);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);for(s=0;s<i.length;s++)r=i[s],t.indexOf(r)>=0||Object.prototype.propertyIsEnumerable.call(e,r)&&(a[r]=e[r])}return a}var O={"aria-label":b().string,className:b().string,cssModule:b().object,role:b().string,size:b().string,tag:v.iC,vertical:b().bool};function N(e){var t=e.className,r=e.cssModule,a=e.size,i=e.vertical,l=e.tag,o=void 0===l?"div":l,n=k(e,j),c=(0,v.mx)(x()(t,!!a&&"btn-group-"+a,i?"btn-group-vertical":"btn-group"),r);return s.createElement(o,y({},function(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?Z(Object(r),!0).forEach((function(t){_(e,t,r[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):Z(Object(r)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))}))}return e}({role:"group"},n),{className:c}))}N.propTypes=O;const w=N;var C=r(8446),D=r(3672),S=r.n(D),P=r(6512),z=r(9356),q=r(3262),K=r(511),A=r(6417);const E=function(e){let{chart:{query:t,name:r,id:o,type:u,labelAttribute:f,seriesAttributes:b,user_id:g},removeChart:x,confirmDelete:v,setConfirmDelete:j}=e;const{compute_stack_id:y}=(0,d.UO)(),Z=(0,c.Kw)(p.Z,(e=>e.auth),[y]),_=(0,c.Kw)(p.Z,(e=>e.url),[y]),k=(0,c.Kw)(h.Z,(e=>e.theme)),O=(0,c.Kw)(h.Z,(e=>{var t;return(null===(t=e.auth)||void 0===t?void 0:t.user_id)===g})),[N,D]=(0,s.useState)(!1),[E,T]=(0,s.useState)(!0),[F,H]=(0,s.useState)(!1),M=N&&!N.error&&(0,z.Z)({title:r,type:u,labels:N.map((e=>e[f])),theme:k}),Y=!N||N.error?[]:"single value"===u?N[0][b[0]]:["donut","pie"].includes(u)?N.map((e=>e[b[0]])):b.map((e=>({name:e,data:N.map((t=>t[e]))})));let B;const R=async()=>{if(Z){T(!0),B&&B.abort(),B=new AbortController;const e=await(0,P.Z)({sql:t,auth:Z,url:_,signal:B.signal});if(!e.error&&e.length){const t=Object.keys(e[0]);("single value"===u?b:[f,...b]).every((e=>t.includes(e)))?D(e):D({error:!0,message:"You do not have permission to access some of the data required to render this chart."})}else D(e);T(!1)}};S()((()=>R()),(()=>B&&B.abort()),[]),(0,m.Z)(R,K.Z.refresh_content_interval);const J=e=>{H(!0),x(e)};return N.error?(0,A.jsx)(n.Z,{lg:"6",xs:"12",className:"mb-3",children:(0,A.jsx)(a.Z,{className:"dashboard-chart",children:(0,A.jsxs)(i.Z,{className:"text-nowrap position-relative",children:[v===o?(0,A.jsxs)(w,{size:"sm",className:"chart-remove-confirm",children:[(0,A.jsxs)(l.Z,{disabled:F,title:"Remove this chart",color:"success",onClick:()=>J(v),children:[F?"deleting chart":"confirm delete chart"," ",(0,A.jsx)("i",{className:"ms-2 fa "+(F?"fa-spinner fa-spin":"fa-check")})]}),(0,A.jsxs)(l.Z,{disabled:F,title:"Do not remove this chart",color:"danger",onClick:()=>j(!1),children:["cancel ",(0,A.jsx)("i",{className:"ms-2 fa fa-times"})]})]}):(0,A.jsx)(l.Z,{title:"Remove this chart",className:"chart-remove",color:"link",onClick:()=>j(o),children:(0,A.jsx)("i",{className:"fa fa-times text-darkgrey"})}),(0,A.jsxs)("div",{className:"dashboard single-value-chart",children:[(0,A.jsx)("div",{className:"title",children:"Error Loading Chart"}),(0,A.jsx)("div",{children:N.message}),(0,A.jsx)("div",{className:"mt-3",children:'You may remove this chart by clicking the "x"'})]})]})})},r):(0,A.jsx)(n.Z,{lg:"6",xs:"12",className:"mb-3",children:(0,A.jsx)(a.Z,{className:"dashboard-chart",children:(0,A.jsxs)(i.Z,{className:"text-nowrap position-relative",children:[E&&(0,A.jsx)(l.Z,{disabled:!0,title:"loading",className:"chart-loading",color:"link",children:(0,A.jsx)("i",{className:"fa fa-spinner fa-spin text-darkgrey"})}),v===o?(0,A.jsxs)(w,{size:"sm",className:"chart-remove-confirm",children:[(0,A.jsxs)(l.Z,{disabled:F,title:"Remove this chart",color:"success",onClick:()=>J(v),children:[F?"deleting chart":"confirm delete chart"," ",(0,A.jsx)("i",{className:"ms-2 fa "+(F?"fa-spinner fa-spin":"fa-check")})]}),(0,A.jsxs)(l.Z,{disabled:F,title:"Do not remove this chart",color:"danger",onClick:()=>j(!1),children:["cancel ",(0,A.jsx)("i",{className:"ms-2 fa fa-times"})]})]}):O?(0,A.jsx)(l.Z,{title:"Remove this chart",className:"chart-remove",color:"link",onClick:()=>j(o),children:(0,A.jsx)("i",{className:"fa fa-times text-darkgrey"})}):null,N&&"single value"===u?(0,A.jsxs)("div",{className:"dashboard single-value-chart",children:[(0,A.jsx)("div",{className:"title",children:r}),(0,A.jsx)("h1",{children:(0,q.Z)(Y)?Y.toFixed(2):Y})]}):N?(0,A.jsx)(C.Z,{options:M,series:Y,type:u,height:220}):null]})})},r)},T=()=>{let e=(new Date).getMonth();const t=[],r=["January","February","March","April","May","June","July","August","September","October","November","December"];for(let s=0;s<12;s+=1)t.push(r[e]),e-=1,e<0&&(e=11);return t.reverse()};const F=function(){const e=(0,c.Kw)(h.Z,(e=>e.theme));return(0,A.jsx)(C.Z,{options:(0,z.Z)({title:"HarperDB Satisfaction Over Time (Placeholder Example)",type:"line",labels:T(),theme:e}),series:[{name:"HarperDB Core",data:[98,98,97,99,98,97,100,100,100,100,100,100]},{name:"HarperDB Studio",data:[95,97,99,97,98,96,98,100,99,98,100,99]},{name:"HarperDB Documentation",data:[90,92,94,92,94,92,95,97,99,95,97,98]}],type:"line",height:220})};var H=r(576),M=r(2261);let Y;const B=function(){const{customer_id:e}=(0,d.UO)(),t=(0,d.s0)(),r=(0,u.VY)(),f=(0,c.Kw)(h.Z,(e=>e.auth)),b=(0,c.Kw)(p.Z,(e=>e.compute_stack_id)),g=(0,c.Kw)(p.Z,(e=>e.charts)),[x,v]=(0,s.useState)(!1),[j,y]=(0,s.useState)(!0),Z=(0,s.useCallback)((async t=>{const s=await(async e=>{let{auth:t,customer_id:r,compute_stack_id:s,id:a}=e;return(0,H.Z)({endpoint:"removeChart",method:"POST",payload:{user_id:t.user_id,customer_id:r,compute_stack_id:s,id:a},auth:t})})({auth:f,customer_id:e,compute_stack_id:b,id:t});s.error?r.error(s.message):(r.success(s.message),y(Date.now()))}),[r,f,b,e]);return(0,s.useEffect)((()=>(f&&(async()=>{Y=new AbortController,await(async e=>{let{auth:t,customer_id:r,compute_stack_id:s,signal:a}=e,i=null;try{return i=await(0,H.Z)({endpoint:"getCharts",method:"POST",payload:{customer_id:r,compute_stack_id:s,user_id:t.user_id},auth:t,signal:a}),i.error||p.Z.update((e=>{e.charts=i})),i}catch(l){return(0,M.Z)({type:"lms data",status:"error",url:K.Z.lms_api_url,operation:"getCharts",request:{customer_id:r,compute_stack_id:s,user_id:t.user_id},error:{catch:l.toString()},customer_id:r})}})({auth:f,customer_id:e,compute_stack_id:b,signal:Y.signal})})(),()=>{var e;return null===(e=Y)||void 0===e?void 0:e.abort()})),[f,j]),(0,m.Z)((()=>f&&y(Date.now())),K.Z.refresh_content_interval),(0,A.jsxs)("div",{id:"charts",children:[(0,A.jsx)(a.Z,{className:"mb-4",children:(0,A.jsxs)(i.Z,{className:"text-center",children:["To add charts to the dashboard, execute a",(0,A.jsxs)(l.Z,{id:"goToQueryPage",onClick:()=>t(`/o/${e}/i/${b}/query`),size:"sm",color:"success",className:"px-2 mx-2",children:[(0,A.jsx)("i",{className:"fa fa-search text-small me-2 "})," query"]}),'Then click "create chart"']})}),(0,A.jsx)(o.Z,{children:null!==g&&void 0!==g&&g.length?g.map((e=>(0,A.jsx)(E,{chart:e,removeChart:Z,confirmDelete:x,setConfirmDelete:v},e.id))):(0,A.jsx)(n.Z,{lg:"6",xs:"12",className:"mb-3",children:(0,A.jsx)(a.Z,{className:"dashboard-chart",children:(0,A.jsx)(i.Z,{className:"text-nowrap position-relative",children:(0,A.jsx)(F,{})})})})})]})}},6512:(e,t,r)=>{r.d(t,{Z:()=>a});var s=r(9859);const a=async e=>{let{auth:t,url:r,sql:a,signal:i}=e;return(0,s.Z)({operation:{operation:"sql",sql:a},auth:t,url:r,signal:i})}},9356:(e,t,r)=>{r.d(t,{Z:()=>s});const s=e=>{let{title:t,type:r,labels:s,theme:a}=e;const i="light"===a?"#696969":"dark"===a?"#fff":"#212121";return{title:{text:t,style:{color:i}},chart:{type:r,animations:{enabled:!1},fontFamily:"Arial, Helvetica, Verdana, Sans-Serif",toolbar:{offsetX:-25,tools:{selection:!1,pan:!1,zoom:!1,zoomin:!1,zoomout:!1,reset:!1}}},labels:s,theme:{palette:"palette10"},plotOptions:{pie:{offsetY:10}},legend:{offsetY:5,labels:{colors:i}},markers:{size:[4],strokeColors:"dark"===a?"#212121":"#fff",strokeWidth:1,strokeOpacity:"dark"===a?.5:1,hover:{sizeOffset:0}},xaxis:{labels:{rotate:-60,maxHeight:80,style:{fontSize:"10px",colors:i}},tooltip:{enabled:!1}},yaxis:{labels:{style:{fontSize:"10px",colors:i}}}}}},3262:(e,t,r)=>{r.d(t,{Z:()=>s});const s=e=>!Number.isNaN(parseFloat(e))&&Number.isFinite(parseFloat(e))}}]);
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
"use strict";(self.webpackChunkharperdb_studio=self.webpackChunkharperdb_studio||[]).push([[463],{1608:(e,t,s)=>{s.r(t),s.d(t,{default:()=>oe});var n=s(7313),a=s(7387),r=s(4122),l=s(8467),i=s(5447),o=s(6782),c=s(5399),u=s(238),d=s(3516),h=s(9842),m=s(35),p=s(4220),g=s(2261),f=s(9327),v=s(8147),b=s(4431),_=s(9859);var x=s(9481),j=s(6123),w=s.n(j),N=s(6417);function k(e){let{error:t,style:s={}}=e;return(0,N.jsx)("div",{style:s,className:w()("form-validation-error",{error:t}),children:t||"input is valid"})}var y=s(1781);const Z=function(e){let{label:t,value:s,type:a="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,n.useState)(null);return i?(0,N.jsxs)(N.Fragment,{children:[d&&(0,N.jsx)("br",{}),(0,N.jsxs)("div",{className:w()("text-nowrap mt-2 mb-1",{"text-danger":m}),children:[t," ",m]}),(0,N.jsx)(y.Z,{id:`cluster-field-${t}`,type:a,className:w()("cluster-field form-control",{error:m}),max:r,min:l,defaultValue:s,valid:h,onChange:e=>o(e.target.value),onBlur:e=>{const t=c(e.target.value);p(t?null:u)}})]}):(0,N.jsxs)(N.Fragment,{children:[d&&(0,N.jsx)("br",{}),(0,N.jsx)("div",{className:"text-nowrap mt-2 mb-1",children:t}),(0,N.jsx)(y.Z,{readOnly:!0,valid:!0,type:a,value:s})]})};var C=s(4851);const S=function(e){var t,s,r,l,o,c,u,d;let{setConfiguring:h,clusterStatus:m,refreshStatus:p,compute_stack_id:g}=e;const j=(0,a.Kw)(i.Z,(e=>e.auth)),w=(0,a.Kw)(i.Z,(e=>e.url)),y=m.engine,S=1024,P=65535,[E,O]=(0,n.useState)({clusterRole:null===m||void 0===m||null===(t=m.cluster_role)||void 0===t?void 0:t.role,clusterUsername:(null===m||void 0===m||null===(s=m.cluster_user)||void 0===s?void 0:s.username)||"cluster_user",clusterPassword:(null===m||void 0===m||null===(r=m.cluster_user)||void 0===r?void 0:r.password)||"",clusterPort:(null===m||void 0===m?void 0:m.config_cluster_port)||"",clusterNodeName:(null===m||void 0===m?void 0:m.node_name)||g}),[T,R]=(0,n.useState)(null);function M(e){O({...E,...e})}return(0,N.jsxs)(N.Fragment,{children:[(0,N.jsx)(Z,{label:"Cluster Role",handleChange:e=>M({clusterRole:e}),value:E.clusterRole,valid:E.clusterRole.trim().length>0,validator:e=>e.trim().length>0,editable:!(null!==m&&void 0!==m&&null!==(l=m.cluster_role)&&void 0!==l&&l.role),addSpace:!1}),(0,N.jsx)(Z,{label:"Cluster User",handleChange:e=>M({clusterUsername:e}),value:E.clusterUsername,valid:E.clusterUsername.trim().length>0,validator:e=>e.trim().length>0,editable:!(null!==m&&void 0!==m&&null!==(o=m.cluster_user)&&void 0!==o&&o.username)}),(0,N.jsx)(Z,{label:"Cluster Password",type:"password",handleChange:e=>M({clusterPassword:e}),value:null!==m&&void 0!==m&&null!==(c=m.cluster_user)&&void 0!==c&&c.username?"********":E.clusterPassword,valid:(null===m||void 0===m||null===(u=m.cluster_user)||void 0===u?void 0:u.username)||E.clusterPassword.trim().length>0,validator:e=>e.trim().length>0,editable:!(null!==m&&void 0!==m&&null!==(d=m.cluster_user)&&void 0!==d&&d.username),showDivider:!1}),(0,N.jsx)(Z,{label:"Cluster Port",type:"number",max:P,min:S,handleChange:e=>M({clusterPort:e}),value:E.clusterPort,valid:E.clusterPort>=S&&E.clusterPort<=P,validator:e=>e>=S&&e<=P,errorMessage:"must be between 1024 and 65535",editable:!(null!==m&&void 0!==m&&m.config_cluster_port)}),(0,N.jsx)(Z,{label:"Cluster Node Name",handleChange:e=>M({clusterNodeName:e}),value:E.clusterNodeName,valid:E.clusterNodeName.length>0,validator:e=>e.length>0,editable:!(null!==m&&void 0!==m&&m.node_name)}),(0,N.jsx)("hr",{className:"my-3"}),(0,N.jsx)(f.Z,{block:!0,color:"success",disabled:!function(e){var t;let{clusterRole:s,clusterUsername:n,clusterPassword:a,clusterPort:r,clusterNodeName:l}=e;return(null===s||void 0===s?void 0:s.length)>0&&n.length>0&&((null===m||void 0===m||null===(t=m.cluster_user)||void 0===t?void 0:t.username)||a.length>0)&&l.length>0&&r>=S&&r<=P}(E),onClick:async function(){var e;if(R(null),null===(e=m.cluster_role)||void 0===e||!e.role){const e=await(0,C.Z)({auth:j,url:w,role:E.clusterRole,permission:{cluster_user:!0}});if(e.error)return R(e.message)}if(!m.cluster_user){const e=await(0,x.Z)({auth:j,url:w,role:E.clusterRole,username:E.clusterUsername,password:E.clusterPassword});if(e.error)return R(e.message)}const t="nats"===y?await(0,b.Z)({auth:j,url:w,clustering_enabled:!0,clustering_nodeName:E.clusterNodeName,clustering_port:E.clusterPort,clustering_user:E.clusterUsername}):await(async e=>{let{CLUSTERING:t=!1,CLUSTERING_PORT:s,CLUSTERING_USER:n,NODE_NAME:a,auth:r,url:l}=e;return(0,_.Z)({operation:{operation:"configure_cluster",CLUSTERING:t,CLUSTERING_PORT:s,CLUSTERING_USER:n,NODE_NAME:a},auth:r,url:l})})({auth:j,url:w,CLUSTERING:!0,CLUSTERING_PORT:E.clusterPort,CLUSTERING_USER:E.clusterUsername,NODE_NAME:E.clusterNodeName});return t.error?R(t.message):(window._kmq&&window._kmq.push(["record","enabled clustering"]),await(0,v.Z)({auth:j,url:w}),setTimeout((()=>h(!0)),0),p())},children:"Enable Clustering"}),(0,N.jsx)("br",{}),T&&(0,N.jsx)(k,{error:T})]})};const P=function(e){let{setConfiguring:t,clusterStatus:s,refreshStatus:n}=e;const{compute_stack_id:r}=(0,l.UO)(),f=null===s||void 0===s?void 0:s.cluster_role,v=(null===s||void 0===s?void 0:s.cluster_role)&&(null===s||void 0===s?void 0:s.cluster_user),b=(null===s||void 0===s?void 0:s.cluster_role)&&(null===s||void 0===s?void 0:s.cluster_user),_=(null===s||void 0===s?void 0:s.cluster_role)&&(null===s||void 0===s?void 0:s.cluster_user)&&(null===s||void 0===s?void 0:s.node_name),x=(0,a.Kw)(i.Z,(e=>e.rule_arn)),j=Boolean(x);return(0,N.jsxs)(o.Z,{id:"clustering",children:[(0,N.jsxs)(c.Z,{xl:"3",lg:"4",md:"5",xs:"12",children:[(0,N.jsx)("span",{className:"floating-card-header",children:"enable clustering"}),(0,N.jsx)(u.Z,{className:"my-3",children:(0,N.jsx)(d.Z,{children:(0,N.jsx)(h.SV,{onError:(e,t)=>(0,g.Z)({error:{message:e.message,componentStack:t}}),FallbackComponent:p.Z,children:(0,N.jsx)(S,{setConfiguring:t,refreshStatus:n,clusterStatus:s,compute_stack_id:r})})})})]}),(0,N.jsx)(c.Z,{xl:"9",lg:"8",md:"7",xs:"12",children:_?(0,N.jsx)(m.Z,{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,N.jsx)("i",{className:"fa fa-thumbs-up text-success"})}):b?(0,N.jsx)(m.Z,{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 "${r}", but you can choose your own unique node name.`,icon:(0,N.jsx)("i",{className:"fa fa-exclamation-triangle text-warning"})}):v?(0,N.jsx)(m.Z,{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,N.jsx)("i",{className:"fa fa-thumbs-up text-success"})}):f?(0,N.jsx)(m.Z,{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?"HarperDB clustering functionality will not work between AWS cloud instances. We are working on upgrading our cloud infrastructure to support clustering functionality.":null,icon:(0,N.jsx)("i",{className:"fa fa-exclamation-triangle text-warning"})}):(0,N.jsx)(m.Z,{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,N.jsx)("i",{className:"fa fa-exclamation-triangle text-warning"})})})]})};var E=s(6160);const O=function(e){let{handleAddNode:t,loading:s}=e;return(0,N.jsx)(f.Z,{color:"purple",className:"round",title:"Connect To This Instance",disabled:s,onClick:t,children:(0,N.jsx)("i",{className:`fa ${s?"fa-spin fa-spinner":"fa-plus"} text-white`})})};const T=function(e){let{handleRemoveNode:t,showModal:s,loading:n}=e;return(0,N.jsxs)(N.Fragment,{children:[(0,N.jsx)(f.Z,{color:"danger",className:"round me-1",title:"Why isn't this instance clustering?",disabled:n,onClick:s,children:(0,N.jsx)("i",{className:"fa fa-exclamation"})}),(0,N.jsx)(f.Z,{color:"purple",className:"round",title:"Disconnect From This Instance",disabled:n,onClick:t,children:(0,N.jsx)("i",{className:`fa ${n?"fa-spin fa-spinner":"fa-minus"} text-white`})})]})};const R=function(e){let{handleRemoveNode:t,loading:s}=e;return(0,N.jsx)(f.Z,{color:"purple",className:"round",title:"Disconnect From This Instance",disabled:s,onClick:t,children:(0,N.jsx)("i",{className:`fa ${s?"fa-spin fa-spinner":"fa-minus"} text-white`})})};const M=function(){return(0,N.jsx)(f.Z,{color:"purple",className:"round",title:"Connecting to this instance",disabled:!0,children:(0,N.jsx)("i",{className:"fa fa-spin fa-spinner text-white"})})};const F=function(e){let{handleConfigureNode:t,loading:s}=e;return(0,N.jsx)(f.Z,{color:"success",className:"round me-1",title:"Enable Clustering",disabled:s,onClick:t,children:(0,N.jsx)("i",{className:`fa ${s?"fa-spin fa-spinner":"fa-share"} text-white`})})};const U=function(e){var t,s,n;let{setShowModal:a,item:r,itemType:l,loading:i,handleAddNode:u,handleRemoveNode:d,handleConfigureNode:h,refreshNetwork:m}=e;const p=r.compute_stack_id===i;return(0,N.jsxs)(o.Z,{className:"item-row",children:[(0,N.jsx)(c.Z,{className:"item-label "+("closed"===(null===(t=r.connection)||void 0===t?void 0:t.state)?"text-danger":""),children:r.instance_name}),(0,N.jsx)(c.Z,{className:"item-action",children:"incompatible/unreachable"===l?null:"unconfigured"===l?(0,N.jsx)(F,{loading:p,handleConfigureNode:()=>h({compute_stack_id:r.compute_stack_id})}):"CREATE_IN_PROGRESS"===r.instance_status?(0,N.jsx)(f.Z,{color:"grey",className:"round",title:"Creating Instance",disabled:!0,children:(0,N.jsx)("i",{className:"fa fa-spin fa-spinner"})}):r.connection?"closed"===(null===(s=r.connection)||void 0===s?void 0:s.state)?(0,N.jsx)(T,{loading:p,handleRemoveNode:()=>d({compute_stack_id:r.compute_stack_id}),showModal:()=>a(r.instance_name)}):"connecting"===(null===(n=r.connection)||void 0===n?void 0:n.state)?(0,N.jsx)(M,{refreshNetwork:m}):(0,N.jsx)(R,{loading:p,handleRemoveNode:()=>d({compute_stack_id:r.compute_stack_id,instance_host:r.instance_host,clusterPort:r.clusterPort})}):(0,N.jsx)(O,{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 I=s(9358);const L=function(e){let{items:t,itemType:s,setShowModal:r,loading:h,setLoading:m,refreshNetwork:p}=e;const{customer_id:g}=(0,l.UO)(),f=(0,l.s0)(),v=(0,E.VY)(),b=(0,a.Kw)(i.Z,(e=>e.compute_stack_id)),x=(0,a.Kw)(i.Z,(e=>e.auth),[b]),j=(0,a.Kw)(i.Z,(e=>e.url),[b]),w=(0,a.Kw)(i.Z,(e=>e.is_local),[b]),k=(0,a.Kw)(i.Z,(e=>{var t;return parseFloat(null===(t=e.auth)||void 0===t?void 0:t.version)>=4?"nats":"socketcluster"}),[b]),y=(0,n.useCallback)((async e=>{m(e.compute_stack_id);const t="nats"===k?await(async e=>{let{auth:t,url:s,server:n="hub",routes:a}=e;return(0,_.Z)({operation:{operation:"cluster_set_routes",server:n,routes:a},auth:t,url:s})})({auth:x,url:j,routes:[{host:e.instance_host,port:e.clusterPort}]}):await(async e=>{let{compute_stack_id:t,instance_host:s,clusterPort:n,auth:a,url:r}=e;return(0,_.Z)({operation:{operation:"add_node",name:t,node_name:t,host:s,port:n,subscriptions:[]},auth:a,url:r})})({...e,auth:x,url:j,is_local:w,customer_id:g});t.error?(v.error("localhost"===e.instance_host?"External instances cannot reach that instance's URL":t.message),m(!1)):("nats"===k&&await(0,I.Z)({auth:x,url:j,service:"clustering config"}),await p()),m(!1)}),[m,x,j,w,g,p,v,k]),Z=(0,n.useCallback)((async e=>{m(e.compute_stack_id);const t="nats"===k?await(async e=>{let{auth:t,url:s,routes:n}=e;return(0,_.Z)({operation:{operation:"cluster_delete_routes",routes:n},auth:t,url:s})})({auth:x,url:j,routes:[{host:e.instance_host,port:e.clusterPort}]}):await(async e=>{let{compute_stack_id:t,auth:s,url:n}=e;return(0,_.Z)({operation:{operation:"remove_node",name:t,node_name:t},auth:s,url:n})})({...e,auth:x,url:j,is_local:w,customer_id:g});t.error?(v.error(t.message),m(!1)):("nats"===k&&await(0,I.Z)({auth:x,url:j,service:"clustering config"}),await p()),m(!1)}),[m,x,j,w,g,p,v,k]),C=(0,n.useCallback)((e=>f(`/o/${g}/i/${e.compute_stack_id}/cluster`)),[f,g]);return(0,N.jsxs)("div",{className:"entity-manager",children:[(0,N.jsxs)("div",{className:"floating-card-header",children:[s," instances"]}),(0,N.jsx)(u.Z,{className:"my-3",children:(0,N.jsx)(d.Z,{children:null!==t&&void 0!==t&&t.length?t.map((e=>(0,N.jsx)(U,{item:e,itemType:s,setShowModal:r,handleAddNode:y,handleRemoveNode:Z,handleConfigureNode:C,loading:h,refreshNetwork:p},e.instance_name))):t?(0,N.jsx)(o.Z,{className:"item-row",children:(0,N.jsxs)(c.Z,{className:"item-label",children:["There are no ",s," instances"]})}):(0,N.jsx)(o.Z,{className:"item-row",children:(0,N.jsx)(c.Z,{className:"item-label",children:(0,N.jsx)("i",{className:"fa fa-spinner fa-spin"})})})})})]})};var z=s(6855);const A={filtered:[],sorted:[],page:0,totalPages:1,pageSize:20,autoRefresh:!1,showFilter:!1,lastUpdate:!1};const $=function(e){let{refreshNetwork:t,loading:s,setLoading:r}=e;const l=(0,a.Kw)(i.Z,(e=>e.clusterDataTable||[])),h=(0,a.Kw)(i.Z,(e=>e.clusterDataTableColumns||[])),[m,p]=(0,n.useState)(A);(0,n.useEffect)((()=>{p({...m,totalPages:Math.ceil((l.length||m.pageSize)/m.pageSize)})}),[p,m.pageSize]);const g=(0,n.useCallback)((async()=>{r(!0),t()}),[r,t]);return(0,N.jsxs)(N.Fragment,{children:[(0,N.jsxs)(o.Z,{className:"floating-card-header",children:[(0,N.jsx)(c.Z,{children:"manage clustering"}),(0,N.jsx)(c.Z,{className:"text-end",children:(0,N.jsxs)(f.Z,{color:"link",onClick:g,className:"me-2",children:[(0,N.jsx)("span",{className:"me-2",children:"refresh network"}),(0,N.jsx)("i",{title:"Refresh Roles",className:"fa "+(s?"fa-spinner fa-spin":"fa-sync-alt")})]})})]}),(0,N.jsx)(u.Z,{className:"my-3",children:(0,N.jsx)(d.Z,{className:"react-table-holder "+(s?"loading":""),children:null!==l&&void 0!==l&&l.length?(0,N.jsx)(z.Z,{columns:h,data:l,page:m.page,pageSize:m.pageSize,totalPages:m.totalPages,showFilter:m.showFilter,sorted:m.sorted,onFilteredChange:e=>p({...m,filtered:e}),onSortedChange:e=>p({...m,sorted:e}),onPageChange:e=>p({...m,pageSize:e}),onPageSizeChange:e=>p({...m,page:0,pageSize:e})}):(0,N.jsx)("div",{className:"empty-prompt",children:"Please connect at least one instance to configure clustering"})})})]})};var D=s(1446),K=s(2020),G=s(8642);const B=function(e){let{showModal:t,setShowModal:s}=e;const{compute_stack_id:n}=(0,l.UO)(),r=(0,a.Kw)(i.Z,(e=>e.instance_name),[n]);return(0,N.jsxs)(D.Z,{id:"cluster-state-modal",isOpen:!!t,toggle:()=>s(!1),centered:!0,fade:!1,children:[(0,N.jsx)(K.Z,{toggle:()=>s(!1),children:"Instance Cluster Error"}),(0,N.jsx)(G.Z,{children:(0,N.jsx)(u.Z,{children:(0,N.jsxs)(d.Z,{children:[(0,N.jsx)("b",{children:r})," is unable to open a connection to ",(0,N.jsx)("b",{children:t}),".",(0,N.jsx)("hr",{className:"my-3"}),(0,N.jsxs)("ul",{children:[(0,N.jsx)("li",{children:"Clustered instances must be able to reach each other. This may require allowing access through a firewall."}),(0,N.jsx)("li",{children:"Both instances must be running. In the event of a restart, instances will automatically attempt to reconnect."}),(0,N.jsxs)("li",{children:["Clustered instances must have the same cluster user ",(0,N.jsx)("b",{children:"name"})," and ",(0,N.jsx)("b",{children:"password"}),". You can edit an instance's cluster user credentials in the ",(0,N.jsx)("b",{children:"config"})," ","section."]})]}),(0,N.jsx)("hr",{className:"my-3"}),"If none of these help fix the issue, you can disconnect ",(0,N.jsx)("b",{children:t})," from ",(0,N.jsx)("b",{children:r})," by clicking the purple disconnect button with the minus sign."]})})})]})};var X=s(3406),H=s.n(X);var q=s(2274);const V=async e=>{let{channel:t,subscriptions:s,buttonState:n,instance_host:a,clusterPort:r,clusterName:l,auth:o,url:c}=e;const u=JSON.parse(JSON.stringify(s)),d=u.findIndex((e=>e.channel===t)),[h,m]=t.split(":");-1===d?u.push({channel:t,schema:h,table:m,publish:"togglePublish"===n,subscribe:"toggleSubscribe"===n}):"togglePublish"===n?u[d].publish=!u[d].publish:"toggleSubscribe"===n&&(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:a,port:r,subscriptions:u},g=await(0,_.Z)({operation:p,auth:o,url:c});return g.error&&-1!==g.message.indexOf("add_node")&&(p.operation="add_node",await(0,_.Z)({operation:p,auth:o,url:c})),i.Z.update((e=>{e.lastUpdate=Date.now()}))};var Y=s(1343),W=s(3708),J=s(4095);const Q=async e=>{let{instance:t,auth:s}=e;const n=s&&await(0,J.Z)({auth:s,url:t.url}),a=s&&await(0,Y.Z)({auth:s,url:t.url}),{structure:r}=a?(0,W.Z)(a):{structure:{}},l=new URL(t.url),i={...t,auth:s,structure:r,host:l.hostname,clustering:n};return Object.entries(i).reduce(((e,t)=>{let[s,n]=t;return null==n||(e[s]=n),e}),{})},ee=async e=>{let{auth:t,url:s,instances:n,connections:a}=e;const r=await(async e=>{let{auth:t,url:s}=e;return(0,_.Z)({operation:{operation:"cluster_get_routes"},auth:t,url:s})})({auth:t,url:s});return r.hub.map((e=>{var t;const s=n.find((t=>t.host===e.host||t.private_ip===e.host));if(!s)return!1;const r=s.host===s.private_ip?s.private_ip:s.host,l=a.find((e=>{var t;return e.node_name===(null===s||void 0===s||null===(t=s.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=>({channel:`${e.schema}:${e.table}`,...e}))))||[];return{host:r,port:e.port,state:"open",name:null===s||void 0===s?void 0:s.compute_stack_id,subscriptions:i}})).filter((e=>!1!==e))},te=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}))):[]},se=async e=>{let{auth:t,url:s,instances:n,compute_stack_id:a,instanceAuths:r,setLoading:l}=e;const o=await Promise.all(n.filter((e=>!!r[e.compute_stack_id])).map((e=>Q({instance:e,auth:r[e.compute_stack_id]})))),c=o.find((e=>e.compute_stack_id===a)),u=c.clustering.message||!c.clustering.is_enabled?[]:"nats"===c.clustering.engine?await ee({auth:t,url:s,instances:o,connections:c.clustering.connections}):te({connections:c.clustering.status.outbound_connections}),d={is_enabled:c.clustering.is_enabled,connections:u},h=(e=>{let{instances:t,network:s,instance_region:n,instance_wavelength_zone_id:a,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===s||void 0===s?void 0:s.connections.find((t=>t.name===e.compute_stack_id)):null===s||void 0===s?void 0:s.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=!n||n!==e.instance_region||e.wavelength_zone_id||a?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!==a)),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:s}=e;if(!s||!t.length)return[];const n=[];return t.map((e=>{const t=H()(e.structure,s);return Object.keys(t).sort().map(((s,a)=>(Object.keys(t[s]).sort().map(((t,r)=>{const l=`${s}:${t}`,i=l&&e.subscriptions.find((e=>e.channel===l)),o=i&&i.publish,c=i&&i.subscribe;return n.push({is_first_instance:0===a&&0===r,is_first_schema:0===r,instance_name:e.instance_name,schema:s,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})),n})({instances:h.connected.filter((e=>"closed"!==e.connection.state)),structure:c.structure}),p=(e=>{let{auth:t,url:s,buildNetwork:n,setLoading:a}=e;return[{Header:"instance",Cell:e=>{let{row:{original:{is_first_instance:t,instance_name:s}}}=e;return(0,N.jsx)("div",{className:t?"text-bold":"text-grey",children:s})}},{Header:"schema",Cell:e=>{let{row:{original:{is_first_schema:t,schema:s}}}=e;return(0,N.jsx)("div",{className:t?"text-bold":"text-grey",children:s})}},{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,N.jsx)(q.Z,{checked:d||!1,onChange:async()=>{a(r),await V({channel:h,subscriptions:u,instance_host:l,instance_name:i,clusterPort:o,clusterName:c,auth:t,url:s,buttonState:"togglePublish"}),n()}})}},{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,N.jsx)(q.Z,{checked:d||!1,onChange:async()=>{a(r),await V({channel:h,subscriptions:u,instance_host:l,instance_name:i,clusterPort:o,clusterName:c,auth:t,url:s,buttonState:"toggleSubscribe"}),n()}})}}]})({auth:t,url:c.url,compute_stack_id:a,buildNetwork:()=>se({auth:t,url:s,instances:n,compute_stack_id:a,instanceAuths:r,setLoading:l}),setLoading:l});return i.Z.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}},ne=se;var ae=s(6449),re=s(2190);const le=function(e){let{configuring:t}=e;const{compute_stack_id:s}=(0,l.UO)(),u=(0,a.Kw)(ae.Z,(e=>e.instances)),[d]=(0,re.Z)({}),m=(0,a.Kw)(i.Z,(e=>e.auth),[s]),f=(0,a.Kw)(i.Z,(e=>e.url),[s]),v=(0,a.Kw)(i.Z,(e=>e.clusterPartners),[s]),b=(0,a.Kw)(i.Z,(e=>e.restarting),[s]),_="socketcluster"===(0,a.Kw)(i.Z,(e=>{var t;return parseFloat(null===(t=e.registration)||void 0===t?void 0:t.version)>=4?"nats":"socketcluster"}),[s])&&(null===v||void 0===v?void 0:v.connected.some((e=>"connecting"===e.connection.state))),[x,j]=(0,n.useState)(!1),[w,k]=(0,n.useState)(!1),y=(0,n.useCallback)((async()=>{m&&f&&u&&s&&!b&&!t&&await ne({auth:m,url:f,instances:u,compute_stack_id:s,instanceAuths:d,setLoading:k})}),[m,f,u,s,b,d,t]);return(0,n.useEffect)((()=>{y()}),[y]),(0,r.Z)((()=>_&&y()),1500),(0,N.jsxs)(N.Fragment,{children:[(0,N.jsxs)(o.Z,{id:"clustering",children:[(0,N.jsx)(c.Z,{xl:"3",lg:"4",md:"6",xs:"12",children:(0,N.jsxs)(h.SV,{onError:(e,t)=>(0,g.Z)({error:{message:e.message,componentStack:t}}),FallbackComponent:p.Z,children:[(0,N.jsx)(L,{items:null===v||void 0===v?void 0:v.connected,itemType:"connected",loading:w,refreshNetwork:y,setLoading:k,setShowModal:j}),(0,N.jsx)(L,{items:null===v||void 0===v?void 0:v.unconnected,itemType:"unconnected",loading:w,refreshNetwork:y,setLoading:k}),(0,N.jsx)(L,{items:null===v||void 0===v?void 0:v.unconfigured,itemType:"unconfigured",loading:w}),(0,N.jsx)(L,{items:null===v||void 0===v?void 0:v.unreachable,itemType:"incompatible/unreachable",loading:w})]})}),(0,N.jsx)(c.Z,{xl:"9",lg:"8",md:"6",xs:"12",children:(0,N.jsx)($,{refreshNetwork:y,loading:w,setLoading:k})})]}),(0,N.jsx)(B,{showModal:x,setShowModal:j})]})};var ie=s(7377);const oe=function(){const{compute_stack_id:e}=(0,l.UO)(),t=(0,a.Kw)(i.Z,(e=>e.auth),[e]),s=(0,a.Kw)(i.Z,(e=>e.url),[e]),[o,c]=(0,n.useState)(!1),[u,d]=(0,n.useState)(!1),h=(0,n.useCallback)((async()=>{if(t&&s){const e=await(0,J.Z)({auth:t,url:s});c(e),e.is_ready&&d(!1)}}),[t,s]);return(0,r.Z)((async()=>{u&&h()}),3e3),(0,n.useEffect)((()=>{h()}),[h]),(0,n.useEffect)((()=>{c(!1)}),[e]),o?u?(0,N.jsx)(m.Z,{description:"Configuring Clustering",icon:(0,N.jsx)("i",{className:"fa fa-spinner fa-spin"})}):o.is_ready?(0,N.jsx)(le,{configuring:u}):(0,N.jsx)(P,{setConfiguring:d,clusterStatus:o,refreshStatus:h}):(0,N.jsx)(ie.Z,{header:"loading network",spinner:!0})}},6855:(e,t,s)=>{s.d(t,{Z:()=>x});var n=s(7313),a=s(5110),r=s(1781),l=s(9842),i=s(6782),o=s(5399),c=s(6417);const u=e=>{let{headerGroups:t,onSortedChange:s,sorted:n,showFilter:a}=e;return t.map((e=>(0,c.jsxs)("div",{...e.getHeaderGroupProps(),children:[(0,c.jsx)(i.Z,{className:"header g-0",children:e.headers.map((e=>{var t,a;return(0,c.jsx)(o.Z,{onClick:()=>{var t,a;return s([{id:e.id,desc:(null===(t=n[0])||void 0===t?void 0:t.id)===e.id&&!(null!==(a=n[0])&&void 0!==a&&a.desc)}])},className:`${(null===(t=n[0])||void 0===t?void 0:t.id)===e.id?"sorted":""} ${null!==(a=n[0])&&void 0!==a&&a.desc?"desc":"asc"} ${-1!==e.id.indexOf("hdb-narrow")?"action":""} px-1`,children:(0,c.jsx)("div",{className:"text-renderer",children:e.render("Header")})},e.id)}))}),a&&(0,c.jsx)(i.Z,{className:"filter g-0",children:e.headers.map((e=>(0,c.jsx)(o.Z,{className:-1!==e.id.indexOf("hdb-narrow")?"action":"",children:e.render("Filter")},e.id)))})]})))};var d=s(9327);const h=function(e){let{page:t,pageSize:s,totalPages:n,onPageChange:a,onPageSizeChange:l,loading:u}=e;return(0,c.jsxs)(i.Z,{className:"pagination",children:[(0,c.jsx)(o.Z,{xs:"12",sm:"2",className:"previous",children:(0,c.jsx)(d.Z,{className:"mb-2 btn-pagination",color:"purple",block:!0,onClick:()=>a(t-1),disabled:!n||0===t,children:(0,c.jsx)("i",{className:"fa fa-chevron-left"})})}),(0,c.jsxs)(o.Z,{xs:"12",sm:"4",className:"paginator",children:[(0,c.jsx)("i",{className:"fa fa-book me-2"}),(0,c.jsx)(r.Z,{className:"mb-2",type:"number",value:t+1,min:1,max:n,onChange:e=>a(e.target.value-1)}),(0,c.jsxs)("div",{className:"page-count",children:["\xa0/\xa0",u?(0,c.jsx)("i",{className:"fa fa-spinner fa-spin"}):n]})]}),(0,c.jsx)(o.Z,{xs:"12",sm:"4",className:"page-size",children:(0,c.jsx)(r.Z,{className:"mb-2",type:"select",value:s,onChange:e=>l(e.target.value),children:[20,50,100,250].map((e=>(0,c.jsxs)("option",{value:e,children:[e," rows"]},e)))})}),(0,c.jsx)(o.Z,{xs:"12",sm:"2",className:"next",children:(0,c.jsx)(d.Z,{className:"mb-2 pull-right btn-pagination",block:!0,color:"purple",onClick:()=>a(t+1),disabled:!n||t+1===n,children:(0,c.jsx)("i",{className:"fa fa-chevron-right"})})})]})};const m=function(e){let{previousPage:t,canPreviousPage:s,pageIndex:n,gotoPage:a,setPageSize:l,pageCount:u,nextPage:h,canNextPage:m,loading:p}=e;return(0,c.jsxs)(i.Z,{className:"pagination",children:[(0,c.jsx)(o.Z,{xs:"12",sm:"2",className:"previous",children:(0,c.jsx)(d.Z,{className:"mb-2 btn-pagination",color:"purple",block:!0,onClick:t,disabled:!u||!s,children:(0,c.jsx)("i",{className:"fa fa-chevron-left"})})}),(0,c.jsxs)(o.Z,{xs:"12",sm:"4",className:"paginator",children:[(0,c.jsx)("i",{className:"fa fa-book me-2"}),(0,c.jsx)(r.Z,{className:"mb-2",type:"number",value:n+1||1,min:1,max:u,onChange:e=>a(e.target.value?Number(e.target.value)-1:0)}),(0,c.jsxs)("div",{className:"page-count",children:["\xa0/\xa0",p?(0,c.jsx)("i",{className:"fa fa-spinner fa-spin"}):u]})]}),(0,c.jsx)(o.Z,{xs:"12",sm:"4",className:"page-size",children:(0,c.jsx)(r.Z,{className:"mb-2",type:"select",onChange:e=>{a(0),setTimeout((()=>l(e.target.value)),1e3)},children:[20,50,100,250].map((e=>(0,c.jsxs)("option",{value:e,children:[e," rows"]},e)))})}),(0,c.jsx)(o.Z,{xs:"12",sm:"2",className:"next",children:(0,c.jsx)(d.Z,{className:"mb-2 pull-right btn-pagination",block:!0,color:"purple",onClick:h,disabled:!u||!m,children:(0,c.jsx)("i",{className:"fa fa-chevron-right"})})})]})};const p=function(e){let{prepareRow:t,row:s,onRowClick:n=!1}=e;return t(s),(0,c.jsx)(i.Z,{onClick:()=>n&&n(s.original),className:"g-0",children:s.cells.map((e=>(0,c.jsx)(o.Z,{className:-1!==e.column.id.indexOf("hdb-narrow")?"action":"",children:e.render("Cell")},`${e.row.id}-${e.column.id}`)))})};var g=s(2261),f=s(4220);function v(e){let{value:t}=e;return(0,c.jsx)("div",{className:"text-renderer",children:t})}function b(e){let{src:t}=e;const[s,a]=(0,n.useState)(!1),[r,l]=(0,n.useState)(!1);return(0,c.jsxs)("div",{className:"image-renderer",onMouseEnter:()=>a(!0),onMouseLeave:()=>a(!1),children:[(0,c.jsx)("i",{className:"fa fa-image"}),s&&r?(0,c.jsxs)("div",{className:"preview-image no-image",children:[(0,c.jsx)("i",{className:"fa fa-ban text-danger"}),(0,c.jsx)("div",{className:"mt-2",children:"image failed to load"})]}):s?(0,c.jsx)("img",{onError:l,alt:t,src:t,className:"preview-image"}):null]})}const _={Filter:e=>{let{column:{filterValue:t,setFilter:s}}=e;return(0,c.jsx)(r.Z,{type:"text",value:t||"",onChange:e=>s(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,c.jsx)(v,{value:JSON.stringify(e)});case"[object Boolean]":return(0,c.jsx)(v,{value:e?"true":"false"});case"[object String]":return(t=e)&&(t.match(/^https?.*\.(jpeg|jpg|gif|png)$/)||-1!==t.indexOf("data:image"))?(0,c.jsx)(b,{src:e}):(0,c.jsx)(v,{value:e});default:return(0,c.jsx)(v,{value:e})}var t})(t)}};const x=function(e){let{columns:t,data:s,currentPage:r,pageSize:i,totalPages:o,onFilteredChange:d,onSortedChange:v,onPageChange:b,onPageSizeChange:x,showFilter:j,onRowClick:w,sorted:N,loading:k,manual:y=!1}=e;const{headerGroups:Z,page:C,rows:S,prepareRow:P,state:E,setAllFilters:O,canPreviousPage:T,canNextPage:R,pageOptions:M,pageCount:F,gotoPage:U,nextPage:I,previousPage:L,setPageSize:z}=(0,a.useTable)({columns:t,data:s,defaultColumn:_,onFilteredChange:d,onSortedChange:v,onPageChange:b,onPageSizeChange:x,onRowClick:w,manualPagination:y,manualFilters:y,initialState:{pageIndex:r,pageSize:i}},a.useFilters,a.usePagination),[A,$]=(0,n.useState)(!0),D=y||!C.length?S:C;return(0,n.useEffect)((()=>{!j&&E.filters.length?O([]):d(E.filters)}),[E.filters,j]),(0,n.useEffect)((()=>{setTimeout((()=>$(!1)),100)}),[null===D||void 0===D?void 0:D.length]),(0,c.jsxs)(l.SV,{onError:(e,t)=>(0,g.Z)({error:{message:e.message,componentStack:t}}),FallbackComponent:f.Z,children:[(0,c.jsxs)("div",{className:"react-table-scroller",children:[(0,c.jsx)(u,{headerGroups:Z,onSortedChange:v,sorted:N,showFilter:j}),k||A?(0,c.jsx)("div",{className:"centered text-center",children:(0,c.jsx)("i",{className:"fa fa-spinner fa-spin"})}):D.length?D.map((e=>(0,c.jsx)(p,{row:e,prepareRow:P,onRowClick:w},e.id))):(0,c.jsxs)("div",{className:"centered text-center",children:[(0,c.jsx)("i",{className:"fa fa-exclamation-triangle text-danger"}),(0,c.jsx)("div",{className:"mt-2 text-darkgrey",children:"no records"})]})]}),y?(0,c.jsx)(h,{page:r,pageSize:i,totalPages:o,onPageChange:b,onPageSizeChange:x,loading:k}):(0,c.jsx)(m,{previousPage:L,pageSize:i,canPreviousPage:T,pageIndex:E.pageIndex,pageOptions:M,gotoPage:U,setPageSize:z,pageCount:F,nextPage:I,canNextPage:R,loading:k})]})}},4851:(e,t,s)=>{s.d(t,{Z:()=>a});var n=s(9859);const a=async e=>{let{auth:t,url:s,role:a,permission:r}=e;return(0,n.Z)({operation:{operation:"add_role",role:a,permission:r},auth:t,url:s})}},9481:(e,t,s)=>{s.d(t,{Z:()=>a});var n=s(9859);const a=async e=>{let{auth:t,role:s,username:a,password:r,url:l}=e;return(0,n.Z)({operation:{operation:"add_user",role:s,username:a,password:r,active:!0},auth:t,url:l})}},7093:(e,t,s)=>{s.d(t,{Z:()=>a});var n=s(9859);const a=async e=>{let{auth:t,url:s}=e;return(0,n.Z)({operation:{operation:"get_configuration"},auth:t,url:s})}},5200:(e,t,s)=>{s.d(t,{Z:()=>r});var n=s(9859),a=s(5447);const r=async e=>{let{auth:t,url:s}=e;const r=await(0,n.Z)({operation:{operation:"list_roles"},auth:t,url:s}),l=[...Array.isArray(r)?r:[]].sort(((e,t)=>e.role.toLowerCase()>t.role.toLowerCase()?1:-1));return a.Z.update((e=>{e.roles=l})),l}},2066:(e,t,s)=>{s.d(t,{Z:()=>r});var n=s(9859),a=s(5447);const r=async e=>{let{auth:t,url:s,signal:r}=e;const l=await(0,n.Z)({operation:{operation:"list_users"},auth:t,url:s,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 a.Z.update((e=>{e.users=i})),i}},8147:(e,t,s)=>{s.d(t,{Z:()=>r});var n=s(9859),a=s(5447);const r=async e=>{let{auth:t,url:s}=e;return a.Z.update((e=>{e.restarting=!0})),(0,n.Z)({operation:{operation:"restart"},auth:t,url:s})}},9358:(e,t,s)=>{s.d(t,{Z:()=>r});var n=s(9859),a=s(5447);const r=async e=>{let{auth:t,url:s,service:r=null}=e;return r?(a.Z.update((e=>{e.restarting_service=r})),(0,n.Z)({operation:{operation:"restart_service",service:r},auth:t,url:s})):{error:!0,message:"You must specify a service"}}},4431:(e,t,s)=>{s.d(t,{Z:()=>a});var n=s(9859);const a=async e=>{let{auth:t,url:s,...a}=e;return(0,n.Z)({operation:{operation:"set_configuration",...a},auth:t,url:s})}},4095:(e,t,s)=>{s.d(t,{Z:()=>o});var n=s(7093),a=s(5200),r=s(2066),l=s(5491),i=s(9859);const o=async e=>{let{auth:t,url:s}=e;const o=await(0,n.Z)({auth:t,url:s}),c=await(0,l.Z)({auth:t,url:s}),u=await(async e=>{let{auth:t,url:s}=e;return(0,i.Z)({operation:{operation:"cluster_status"},auth:t,url:s})})({auth:t,url:s}),d=parseFloat(null===c||void 0===c?void 0:c.version)>=4?"nats":"socketcluster",h=await(0,a.Z)({auth:t,url:s});let m=!1;h.error||(m=h.find((e=>e.permission.cluster_user)));const p=await(0,r.Z)({auth:t,url:s});let g=!1;p.error||(g=m&&p.find((e=>e.role===m.role)));const f="nats"===d?o.clustering.enabled:o.CLUSTERING,v="nats"===d?o.clustering.user:o.CLUSTERING_USER,b="nats"===d?o.clustering.hubServer.cluster.network.port:o.CLUSTERING_PORT,_="nats"===d?o.clustering.nodeName:o.NODE_NAME;return{is_ready:!!f&&!!g&&!!v&&!!m&&!!b&&!!_,cluster_role:m,cluster_user:g,is_enabled:f,config_cluster_user:v,config_cluster_port:b,node_name:_,engine:d,status:null===u||void 0===u?void 0:u.status,message:null===u||void 0===u?void 0:u.message,connections:null===u||void 0===u?void 0:u.connections}}},3406: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===s}(e)}(e)};var s="function"===typeof Symbol&&Symbol.for?Symbol.for("react.element"):60103;function n(e,t){return!1!==t.clone&&t.isMergeableObject(e)?o((s=e,Array.isArray(s)?[]:{}),e,t):e;var s}function a(e,t,s){return e.concat(t).map((function(e){return n(e,s)}))}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(s){return!1}}function i(e,t,s){var a={};return s.isMergeableObject(e)&&r(e).forEach((function(t){a[t]=n(e[t],s)})),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)&&s.isMergeableObject(t[r])?a[r]=function(e,t){if(!t.customMerge)return o;var s=t.customMerge(e);return"function"===typeof s?s:o}(r,s)(e[r],t[r],s):a[r]=n(t[r],s))})),a}function o(e,s,r){(r=r||{}).arrayMerge=r.arrayMerge||a,r.isMergeableObject=r.isMergeableObject||t,r.cloneUnlessOtherwiseSpecified=n;var l=Array.isArray(s);return l===Array.isArray(e)?l?r.arrayMerge(e,s,r):i(e,s,r):n(s,r)}o.all=function(e,t){if(!Array.isArray(e))throw new Error("first argument should be an array");return e.reduce((function(e,s){return o(e,s,t)}),{})};var c=o;e.exports=c},6194:(e,t,s)=>{Object.defineProperty(t,"__esModule",{value:!0});var n,a=s(7313),r=(n=a)&&n.__esModule?n:{default:n};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"}))}},2274:(e,t,s)=>{var n=Object.assign||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},a=function(){function e(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)}}return function(t,s,n){return s&&e(t.prototype,s),n&&e(t,n),t}}(),r=s(7313),l=h(r),i=h(s(6123)),o=h(s(5192)),c=h(s(6194)),u=h(s(2808)),d=s(8354);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 s=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 s.handleClick=s.handleClick.bind(s),s.handleTouchStart=s.handleTouchStart.bind(s),s.handleTouchMove=s.handleTouchMove.bind(s),s.handleTouchEnd=s.handleTouchEnd.bind(s),s.handleFocus=s.handleFocus.bind(s),s.handleBlur=s.handleBlur.bind(s),s.previouslyChecked=!(!e.checked&&!e.defaultChecked),s.state={checked:!(!e.checked&&!e.defaultChecked),hasFocus:!1},s}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),a(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 s=this.props.hasOwnProperty("checked")?this.props.checked:t.checked;this.setState({checked:s})}}},{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 s=(0,d.pointerCoord)(e).x;!0===this.previouslyChecked&&this.startX+4>s?this.previouslyChecked!==this.state.checked&&(this.setState({checked:!1}),this.previouslyChecked=this.state.checked,t.click()):this.startX-4<s&&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 s=this.props.icons;return s?void 0===s[e]?t.defaultProps.icons[e]:s[e]:null}},{key:"render",value:function(){var e=this,t=this.props,s=t.className,a=(t.icons,function(e,t){var s={};for(var n in e)t.indexOf(n)>=0||Object.prototype.hasOwnProperty.call(e,n)&&(s[n]=e[n]);return s}(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},s);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",n({},a,{ref:function(t){e.input=t},onFocus:this.handleFocus,onBlur:this.handleBlur,className:"react-toggle-screenreader-only",type:"checkbox"})))}}]),t}(r.PureComponent);t.Z=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})])}},8354:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.pointerCoord=function(e){if(e){var t=e.changedTouches;if(t&&t.length>0){var s=t[0];return{x:s.clientX,y:s.clientY}}var n=e.pageX;if(void 0!==n)return{x:n,y:e.pageY}}return{x:0,y:0}}},2808:(e,t,s)=>{Object.defineProperty(t,"__esModule",{value:!0});var n,a=s(7313),r=(n=a)&&n.__esModule?n:{default:n};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"}))}}}]);
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
"use strict";(self.webpackChunkharperdb_studio=self.webpackChunkharperdb_studio||[]).push([[490],{7535:(e,t,s)=>{s.r(t),s.d(t,{default:()=>q});var n=s(7313),i=s(6782),r=s(5399),a=s(9327),l=s(238),o=s(3516),c=s(7387),d=s(8467),u=s(9842),m=s(3672),p=s.n(m),h=s(5447),_=s(6449),x=s(8212),v=s(6160),j=s(511),g=s(6417);const f=function(e){let{which:t,compute:s,storage:n,total:a}=e;return(0,g.jsx)(l.Z,{className:"my-3",children:(0,g.jsxs)(o.Z,{className:"p-2 text-small",children:[(0,g.jsxs)(i.Z,{children:[(0,g.jsxs)(r.Z,{xs:"6",className:"text-nowrap",children:["Compute","compute"===t&&" (new)"]}),(0,g.jsx)(r.Z,{xs:"6",className:"text-nowrap text-end text-truncate",children:s}),(0,g.jsx)(r.Z,{xs:"12",children:(0,g.jsx)("hr",{className:"my-1"})})]}),(0,g.jsxs)(i.Z,{children:[(0,g.jsxs)(r.Z,{xs:"6",className:"text-nowrap",children:["Storage","storage"===t&&" (new)"]}),(0,g.jsx)(r.Z,{xs:"6",className:"text-nowrap text-end text-truncate",children:n}),(0,g.jsx)(r.Z,{xs:"12",children:(0,g.jsx)("hr",{className:"my-1"})})]}),(0,g.jsxs)(i.Z,{children:[(0,g.jsx)(r.Z,{xs:"6",className:"text-nowrap",children:(0,g.jsx)("b",{children:"New Total"})}),(0,g.jsx)(r.Z,{xs:"6",className:"text-nowrap text-end text-truncate",children:(0,g.jsx)("b",{children:a})})]})]})})};var Z=s(1216),b=s(9105),w=s(576);const y=async e=>(0,w.Z)({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(1842);const C=function(e){let{setInstanceAction:t,showPrepaidStorage:s}=e;const{customer_id:u,compute_stack_id:m}=(0,d.UO)(),w=(0,d.s0)(),C=(0,v.VY)(),k=(0,c.Kw)(_.Z,(e=>e.auth)),S=(0,c.Kw)(_.Z,(e=>e.hasCard)),E=(0,c.Kw)(_.Z,(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,c.Kw)(h.Z,(e=>e.compute)),O=(0,c.Kw)(h.Z,(e=>e.storage)),K=(0,c.Kw)(h.Z,(e=>e.is_local)),T=(0,c.Kw)(h.Z,(e=>!["CREATE_COMPLETE","UPDATE_COMPLETE"].includes(e.status))),R=(0,c.Kw)(h.Z,(e=>e.last_volume_resize)),A=(0,c.Kw)(h.Z,(e=>e.data_volume_size)),$=(0,c.Kw)(_.Z,(e=>e.products.cloud_storage.filter((e=>e.value.data_volume_size>=(null===O||void 0===O?void 0:O.data_volume_size))))),I=(0,c.Kw)(_.Z,(e=>e.subscriptions.cloud_storage.filter((e=>(e.value.data_volume_size===A||e.value.storage_quantity_available>=e.value.data_volume_size)&&e.value.data_volume_size>=(null===O||void 0===O?void 0:O.data_volume_size))))),[z,D]=(0,n.useState)({}),[L,F]=(0,n.useState)({compute_stack_id:m,customer_id:u,...O}),[U,M]=(0,n.useState)(!1),V=s?I:$,B=V.find((e=>e.value.data_volume_size===L.data_volume_size&&e.value.stripe_storage_plan_id===L.stripe_storage_plan_id&&e.value.storage_subscription_id===L.storage_subscription_id)),Y=k.orgs.filter((e=>k.user_id===e.owner_user_id)).reduce(((e,t)=>e+t.free_cloud_instance_count),0)<j.Z.free_cloud_instance_limit,q=((null===L||void 0===L?void 0:L.storage_price)||0)+((null===P||void 0===P?void 0:P.compute_price)||0),H=q?`${(0,N.Z)(q.toFixed(2))}/${P.compute_interval}`:"FREE",W=!R||(Date.now()-new Date(R).getTime())/1e3/3600>6,G=()=>F({compute_stack_id:m,customer_id:u,...O});return p()(G,[s]),p()((()=>{M((null===O||void 0===O?void 0:O.data_volume_size)!==L.data_volume_size||(null===O||void 0===O?void 0:O.stripe_storage_plan_id)!==L.stripe_storage_plan_id||(null===O||void 0===O?void 0:O.storage_subscription_id)!==L.storage_subscription_id)}),[L]),p()((()=>{M(!1)}),[m]),p()((async()=>{const{submitted:e}=z;if(e){t("Updating");(await y({auth:k,...L})).error?(C.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===L||void 0===L?void 0:L.compute_price,currency:"USD",products:[{name:"storage",id:B.data_volume_size_string,price:(null===L||void 0===L?void 0:L.storage_price)||0}]}]),C.success("Instance update initialized successfully"),_.Z.update((e=>{e.lastUpdate=Date.now()})),setTimeout((()=>w(`/o/${u}/instances`)),100))}}),[z]),T?(0,g.jsx)(l.Z,{className:"error",children:(0,g.jsx)(o.Z,{children:"instance updating. please wait."})}):(0,g.jsxs)(g.Fragment,{children:[(0,g.jsx)(x.ZP,{className:"react-select-container",classNamePrefix:"react-select",onChange:e=>{let{value:t}=e;return F({...L,...t})},options:V.filter((e=>e.value.active)),value:B,defaultValue:O,isSearchable:!1,isClearable:!1,isLoading:!V,placeholder:"Select Data Volume Size",styles:{placeholder:e=>({...e,textAlign:"center",width:"100%",color:"#BCBCBC"})}}),!U||L.storage_subscription_id||q||K||Y?U&&!W?(0,g.jsx)(l.Z,{className:"error mt-3 text-start",children:(0,g.jsxs)(o.Z,{children:["You may update disk size every 6 hours",(0,g.jsx)("br",{}),(0,g.jsx)("br",{}),"Last resize: ",new Date(R).toLocaleTimeString(),(0,g.jsx)("br",{}),(0,g.jsx)("br",{}),"Try again at: ",new Date(new Date(R).getTime()+216e5).toLocaleTimeString()]})}):U&&(null!==L&&void 0!==L&&L.storage_price||null!==P&&void 0!==P&&P.compute_price)&&E?(0,g.jsxs)("div",{className:"mt-3",children:[(0,g.jsx)(Z.Z,{}),(0,g.jsx)(b.Z,{disabled:!U||z.submitted,label:"Update Credit Card",onClick:()=>w(`/o/${u}/billing?returnURL=/${u}/i/${m}/config`)})]}):U&&(null!==L&&void 0!==L&&L.storage_price||null!==P&&void 0!==P&&P.compute_price)&&!S?(0,g.jsx)(b.Z,{disabled:!U||z.submitted,label:"Add Credit Card To Account",onClick:()=>w(`/o/${u}/billing?returnURL=/${u}/i/${m}/config`)}):U?(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===L||void 0===L?void 0:L.storage_price_string_with_interval)||"FREE",total:H}),(0,g.jsxs)(i.Z,{children:[(0,g.jsx)(r.Z,{children:(0,g.jsx)(a.Z,{id:"cancelChange",onClick:G,title:"Cancel",block:!0,disabled:z.submitted,color:"grey",children:"Cancel"})}),(0,g.jsx)(r.Z,{children:(0,g.jsx)(a.Z,{id:"confirmChange",onClick:()=>D({submitted:!0}),title:"Confirm Instance Details",block:!0,disabled:!U||z.submitted,color:"success",children:"Update"})})]})]}):null:(0,g.jsx)(l.Z,{className:"error mt-3",children:(0,g.jsxs)(o.Z,{children:["You are limited to ",j.Z.free_cloud_instance_limit," free cloud instance",1!==j.Z.free_cloud_instance_limit?"s":""]})})]})};const k=function(e){let{setInstanceAction:t,showPrepaidCompute:s}=e;const{customer_id:u,compute_stack_id:m}=(0,d.UO)(),w=(0,d.s0)(),C=(0,v.VY)(),k=(0,c.Kw)(_.Z,(e=>e.auth)),S=(0,c.Kw)(_.Z,(e=>e.hasCard)),E=(0,c.Kw)(_.Z,(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,c.Kw)(h.Z,(e=>e.compute)),O=(0,c.Kw)(h.Z,(e=>e.storage)),K=(0,c.Kw)(h.Z,(e=>e.is_local)),T=(0,c.Kw)(h.Z,(e=>e.wavelength_zone_id)),R=(0,c.Kw)(h.Z,(e=>e.compute_subscription_id)),A=(0,c.Kw)(h.Z,(e=>!["CREATE_COMPLETE","UPDATE_COMPLETE"].includes(e.status))),$=(0,c.Kw)(_.Z,(e=>e.products[K?"local_compute":T?"wavelength_compute":"cloud_compute"])),I=(0,c.Kw)(_.Z,(e=>e.subscriptions[K?"local_compute":T?"wavelength_compute":"cloud_compute"].filter((e=>e.value.compute_subscription_id===R||e.value.compute_quantity_available)))),[z,D]=(0,n.useState)({}),[L,F]=(0,n.useState)({compute_stack_id:m,customer_id:u,...P}),[U,M]=(0,n.useState)(!1),V=s?I:$,B=V.find((e=>e.value.stripe_plan_id===L.stripe_plan_id&&e.value.compute_subscription_id===L.compute_subscription_id)),Y=k.orgs.filter((e=>k.user_id===e.owner_user_id)).reduce(((e,t)=>e+t.free_cloud_instance_count),0)<j.Z.free_cloud_instance_limit,q=((null===O||void 0===O?void 0:O.storage_price)||0)+((null===L||void 0===L?void 0:L.compute_price)||0),H=q?`${(0,N.Z)(q.toFixed(2))}/${P.compute_interval}`:"FREE",W=()=>F({compute_stack_id:m,customer_id:u,...P});return p()(W,[s]),p()((()=>{M((null===P||void 0===P?void 0:P.stripe_plan_id)!==L.stripe_plan_id||L.compute_subscription_id!==(null===P||void 0===P?void 0:P.compute_subscription_id))}),[L]),p()((()=>{M(!1)}),[m]),p()((async()=>{const{submitted:e}=z;if(e)if(q||L.compute_subscription_id||K||Y){t("Updating");(await y({auth:k,...L})).error?(C.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===L||void 0===L?void 0:L.compute_price,currency:"USD",products:[{name:"compute",id:B.compute_ram_string,price:(null===L||void 0===L?void 0:L.compute_price)||0}]}]),C.success("Instance update initialized successfully"),_.Z.update((e=>{e.lastUpdate=Date.now()})),setTimeout((()=>w(`/o/${u}/instances`)),100))}else C.error(`You are limited to ${j.Z.free_cloud_instance_limit} free cloud instance${1!==j.Z.free_cloud_instance_limit?"s":""}`),W(),D({})}),[z]),A?(0,g.jsx)(l.Z,{className:"error",children:(0,g.jsx)(o.Z,{children:"instance updating. please wait."})}):(0,g.jsxs)(g.Fragment,{children:[(0,g.jsx)(x.ZP,{className:"react-select-container",classNamePrefix:"react-select",onChange:e=>{let{value:t}=e;return F({...L,...t})},options:V.filter((e=>e.value.active)),value:B,defaultValue:P,isSearchable:!1,isClearable:!1,isLoading:!V,placeholder:"select a RAM allotment",styles:{placeholder:e=>({...e,textAlign:"center",width:"100%",color:"#BCBCBC"})}}),!U||q||L.compute_subscription_id||K||Y?U&&(null!==O&&void 0!==O&&O.storage_price||null!==L&&void 0!==L&&L.compute_price)&&E?(0,g.jsxs)("div",{className:"mt-3",children:[(0,g.jsx)(Z.Z,{}),(0,g.jsx)(b.Z,{disabled:!U||z.submitted,label:"Update Credit Card",onClick:()=>w(`/o/${u}/billing?returnURL=/${u}/i/${m}/config`)})]}):U&&(null!==O&&void 0!==O&&O.storage_price||null!==L&&void 0!==L&&L.compute_price)&&!S?(0,g.jsx)(b.Z,{disabled:!U||z.submitted,label:"Add Credit Card To Account",onClick:()=>w(`/o/${u}/billing?returnURL=/${u}/i/${m}/config`)}):U?(0,g.jsxs)(g.Fragment,{children:[(0,g.jsx)(f,{which:"compute",compute:L.compute_price_string_with_interval,storage:(null===O||void 0===O?void 0:O.storage_price_string_with_interval)||"FREE",total:H}),(0,g.jsxs)(i.Z,{children:[(0,g.jsx)(r.Z,{children:(0,g.jsx)(a.Z,{id:"cancelChange",onClick:W,title:"Cancel",block:!0,disabled:z.submitted,color:"grey",children:"Cancel"})}),(0,g.jsx)(r.Z,{children:(0,g.jsx)(a.Z,{id:"confirmChange",onClick:()=>D({submitted:!0}),title:"Confirm Instance Details",block:!0,disabled:!U||z.submitted,color:"success",children:"Update"})})]})]}):null:(0,g.jsx)(l.Z,{className:"error mt-2",children:(0,g.jsxs)(o.Z,{children:["You are limited to ",j.Z.free_cloud_instance_limit," free cloud instance",1!==j.Z.free_cloud_instance_limit?"s":""]})})]})};var S=s(1781),E=s(9858);const P=function(e){let{setInstanceAction:t}=e;const{customer_id:s,compute_stack_id:u}=(0,d.UO)(),m=(0,d.s0)(),x=(0,v.VY)(),j=(0,c.Kw)(_.Z,(e=>e.auth)),f=(0,c.Kw)(h.Z,(e=>e.instance_name)),Z=(0,c.Kw)(h.Z,(e=>e.is_local)),b=(0,c.Kw)(h.Z,(e=>e.wavelength_zone_id)),w=(0,c.Kw)(h.Z,(e=>!["CREATE_COMPLETE","UPDATE_COMPLETE"].includes(e.status))),[y,N]=(0,n.useState)({}),[C,k]=(0,n.useState)({});return p()((async()=>{const{submitted:e}=y;if(e){const{delete_instance_name:e}=C;if(f!==e)N({error:"instance name is not correct"});else{t("Removing");(await(0,E.Z)({auth:j,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"),_.Z.update((e=>{e.lastUpdate=Date.now()})),setTimeout((()=>m(`/o/${s}/instances`)),3e3))}}}),[y]),w?(0,g.jsx)(l.Z,{className:"error",children:(0,g.jsx)(o.Z,{children:"instance updating. please wait."})}):(0,g.jsxs)(g.Fragment,{children:[(0,g.jsx)(S.Z,{id:"instance_name_remove",onChange:e=>k({delete_instance_name:e.target.value}),type:"text",title:"instance_name",placeholder:`Enter "${f}" here to confirm.`,value:C.delete_instance_name||""}),C.delete_instance_name===f&&(0,g.jsxs)(g.Fragment,{children:[(0,g.jsx)(l.Z,{className:"my-2",children:(0,g.jsx)(o.Z,{className:"px-2 pb-2 pt-3 text-small",children:Z?(0,g.jsxs)("ul",{className:"text-small mb-0",children:[(0,g.jsxs)("li",{children:[(0,g.jsx)("b",{children:"DOES NOT"})," uninstall HarperDB."]}),(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)(i.Z,{children:[(0,g.jsx)(r.Z,{children:(0,g.jsx)(a.Z,{id:"cancelDeleteInstance",onClick:()=>k({delete_instance_name:""}),title:"Cancel",block:!0,disabled:y.submitted,color:"grey",children:"Cancel"})}),(0,g.jsx)(r.Z,{children:(0,g.jsx)(a.Z,{id:"removeInstance",onClick:()=>N({submitted:!0}),title:"Confirm Instance Details",block:!0,disabled:y.submitted,color:"danger",children:"Remove"})})]})]})]})};var O=s(4122),K=s(2230),T=s(8147);const R=function(e){let{instanceAction:t,setInstanceAction:s}=e;const d=(0,v.VY)(),u=(0,c.Kw)(h.Z,(e=>e.auth)),m=(0,c.Kw)(h.Z,(e=>e.url)),_=(0,c.Kw)(h.Z,(e=>e.instance_name)),x=(0,c.Kw)(h.Z,(e=>!["CREATE_COMPLETE","UPDATE_COMPLETE"].includes(e.status))),[f,Z]=(0,n.useState)({}),[b,w]=(0,n.useState)({});return p()((async()=>{const{submitted:e}=f;if(e){s("Restarting");const e=await(0,T.Z)({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."))}}),[f]),(0,O.Z)((()=>{"Restarting"===t&&(async()=>{(await(0,K.Z)({auth:u,url:m})).error||(w({}),Z({}),s(!1),d.success("Instance restarted successfully"))})()}),j.Z.refresh_content_interval),"Restarting"===t?(0,g.jsx)(l.Z,{className:"error",children:(0,g.jsxs)(o.Z,{children:[(0,g.jsx)("i",{className:"fa fa-spin fa-spinner me-2"}),"instance restarting. please wait."]})}):!j.Z.is_local_studio&&x?(0,g.jsx)(l.Z,{className:"error",children:(0,g.jsx)(o.Z,{children:"instance updating. please wait."})}):(0,g.jsxs)(g.Fragment,{children:[(0,g.jsx)(S.Z,{id:"instance_name_restart",onChange:e=>w({restart_instance_name:e.target.value}),type:"text",title:"instance_name",placeholder:`Enter "${_}" here to confirm.`,value:b.restart_instance_name||""}),b.restart_instance_name===_&&(0,g.jsxs)(g.Fragment,{children:[(0,g.jsx)(l.Z,{className:"my-2",children:(0,g.jsx)(o.Z,{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)(i.Z,{children:[(0,g.jsx)(r.Z,{children:(0,g.jsx)(a.Z,{onClick:()=>w({restart_instance_name:""}),title:"Cancel",block:!0,disabled:f.submitted,color:"grey",children:"Cancel"})}),(0,g.jsx)(r.Z,{children:(0,g.jsx)(a.Z,{onClick:()=>Z({submitted:!0}),title:"Confirm Instance Details",block:!0,disabled:f.submitted,color:"danger",children:"Restart"})})]})]})]})};var A=s(2589),$=s(7266);const I=function(e){var t,s,n,a,d,u,m,p,_,x,v,f,Z,b,w,y,N,C;let{clusterNodeName:k,instanceConfig:S}=e;const E=(0,c.Kw)(h.Z,(e=>e.url)),P=(0,c.Kw)(h.Z,(e=>e.auth)),O=(0,c.Kw)(h.Z,(e=>e.totalPriceStringWithInterval)),K=(0,c.Kw)(h.Z,(e=>e.compute)),T=(0,c.Kw)(h.Z,(e=>!!e.compute_subscription_id)),R=(0,c.Kw)(h.Z,(e=>!!e.storage_subscription_id)),I=(0,c.Kw)(h.Z,(e=>e.creation_date)),z=(0,c.Kw)(h.Z,(e=>e.instance_region)),D=(0,c.Kw)(h.Z,(e=>e.storage)),L=(0,c.Kw)(h.Z,(e=>e.is_local)),F=null!==P&&void 0!==P&&P.user?`${btoa(`${P.user}:${P.pass}`)}`:"...",U=L?"HARDWARE LIMIT":`${null===D||void 0===D?void 0:D.iops}`,M=I?new Date(I).toLocaleDateString():"N/A",{hostname:V}=window.location,B=new URL(E),Y=j.Z.is_local_studio?`${null!==(m=S.operationsApi)&&void 0!==m&&null!==(p=m.network)&&void 0!==p&&p.securePort?"https://":"http://"}${V}:${(null===(_=S.operationsApi)||void 0===_||null===(x=_.network)||void 0===x?void 0:x.securePort)||(null===(v=S.operationsApi)||void 0===v||null===(f=v.network)||void 0===f?void 0:f.port)}`:`${null!==(t=S.operationsApi)&&void 0!==t&&null!==(s=t.network)&&void 0!==s&&s.securePort?"https://":"http://"}${B.hostname}:${(null===(n=S.operationsApi)||void 0===n||null===(a=n.network)||void 0===a?void 0:a.securePort)||(null===(d=S.operationsApi)||void 0===d||null===(u=d.network)||void 0===u?void 0:u.port)}`,q=j.Z.is_local_studio?`${null!==(y=S.http)&&void 0!==y&&y.securePort?"https://":"http://"}${V}:${(null===(N=S.http)||void 0===N?void 0:N.securePort)||(null===(C=S.http)||void 0===C?void 0:C.port)}`:`${null!==(Z=S.http)&&void 0!==Z&&Z.securePort?"https://":"http://"}${B.hostname}:${(null===(b=S.http)||void 0===b?void 0:b.securePort)||(null===(w=S.http)||void 0===w?void 0:w.port)}`,H=(0,c.Kw)(h.Z,(e=>{var t;return null===(t=e.registration)||void 0===t?void 0:t.version})),[W,G]=(null===H||void 0===H?void 0:H.split("."))||[],J=parseFloat(`${W}.${G}`);return(0,g.jsxs)(g.Fragment,{children:[(0,g.jsx)("span",{className:"floating-card-header",children:"instance overview"}),(0,g.jsx)(l.Z,{className:"mt-3 mb-4 instance-details",children:(0,g.jsx)(o.Z,{children:(0,g.jsxs)(i.Z,{children:[(0,g.jsx)(r.Z,{md:"4",xs:"12",children:(0,g.jsx)(A.Z,{header:"Instance URL",className:"mb-3",children:(0,g.jsx)("div",{className:"nowrap-scroll",children:(0,g.jsx)($.Z,{text:Y})})})}),(0,g.jsx)(r.Z,{md:"4",xs:"12",children:(0,g.jsx)(A.Z,{header:(J>=4.2?"Applications":"Custom Functions")+" URL",className:"mb-3",children:(0,g.jsx)("div",{className:"nowrap-scroll",children:(0,g.jsx)($.Z,{text:q})})})}),(0,g.jsx)(r.Z,{md:"4",xs:"12",children:(0,g.jsx)(A.Z,{header:"Instance Node Name (for clustering)",className:"mb-3",children:(0,g.jsx)("div",{className:"nowrap-scroll",children:k?(0,g.jsx)($.Z,{text:k}):"clustering not enabled"})})}),!j.Z.is_local_studio&&(0,g.jsxs)(g.Fragment,{children:[(0,g.jsx)(r.Z,{md:"4",xs:"12",children:(0,g.jsx)(A.Z,{header:"Instance API Auth Header (this user)",className:"mb-3",children:(0,g.jsx)("div",{className:"nowrap-scroll",children:(0,g.jsx)($.Z,{text:F,beforeText:"Basic ",obscure:!0})})})}),(0,g.jsx)(r.Z,{md:"2",sm:"4",xs:"6",children:(0,g.jsx)(A.Z,{header:"Created",className:"mb-3",children:(0,g.jsx)("div",{className:"nowrap-scroll",children:M})})}),z&&(0,g.jsx)(r.Z,{md:"2",sm:"4",xs:"6",children:(0,g.jsx)(A.Z,{header:"Region",className:"mb-3",children:(0,g.jsx)("div",{className:"nowrap-scroll",children:z})})}),(0,g.jsx)(r.Z,{md:"2",sm:"4",xs:"6",children:(0,g.jsx)(A.Z,{header:"Total Price",className:"mb-3",children:(0,g.jsx)("div",{className:"nowrap-scroll",children:O})})}),(0,g.jsx)(r.Z,{md:"2",sm:"4",xs:"6",children:(0,g.jsx)(A.Z,{header:"RAM",className:"mb-3",children:(0,g.jsxs)("div",{className:"nowrap-scroll",children:[null===K||void 0===K?void 0:K.compute_ram_string," ",T&&"(PREPAID)"]})})}),!L&&(0,g.jsxs)(g.Fragment,{children:[(0,g.jsx)(r.Z,{md:"2",sm:"4",xs:"6",children:(0,g.jsx)(A.Z,{header:"Storage",className:"mb-3 text-nowrap",children:(0,g.jsxs)("div",{className:"nowrap-scroll",children:[null===D||void 0===D?void 0:D.data_volume_size_string," ",R&&"(PREPAID)"]})})}),(0,g.jsx)(r.Z,{md:"2",sm:"4",xs:"6",children:(0,g.jsx)(A.Z,{header:"Disk IOPS",className:"mb-3 text-nowrap",children:(0,g.jsx)("div",{className:"nowrap-scroll",children:U})})})]})]})]})})})]})};var z=s(7377),D=s(4220),L=s(2261),F=s(2174),U=s(4130),M=s(8190);const V=function(e){let{instanceConfig:t}=e;const s=(0,c.Kw)(_.Z,(e=>e.theme));return(0,g.jsx)(M.Z,{placeholder:t,height:"calc(100vh - 566px)",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:U.Z,width:"100%",confirmGood:!1,waitAfterKeyPress:3e4})};var B=s(7093);const Y=function(){return(0,g.jsx)("div",{className:"configLoader",children:(0,g.jsx)("i",{className:"fa fa-spinner fa-spin"})})};const q=function(){const{customer_id:e,compute_stack_id:t}=(0,d.UO)(),s=(0,c.Kw)(_.Z,(e=>e.auth)),m=(0,c.Kw)(_.Z,(e=>e.theme)),x=(0,c.Kw)(h.Z,(e=>e.auth),[t]),v=(0,c.Kw)(h.Z,(e=>e.url),[t]),j=(0,c.Kw)(_.Z,(e=>{var t;return null===(t=e.customer)||void 0===t?void 0:t.stripe_id})),f=(0,c.Kw)(h.Z,(e=>e.is_local),[t]),Z=(0,c.Kw)(h.Z,(e=>{var t;return parseFloat(null===(t=e.registration)||void 0===t?void 0:t.version)>=4?"nats":"socketcluster"}),[t]),b=(0,c.Kw)(h.Z,(e=>e.compute_subscription_id),[t]),w=(0,c.Kw)(h.Z,(e=>e.storage_subscription_id),[t]),y=(0,c.Kw)(_.Z,(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]),N="owner"===(null===y||void 0===y?void 0:y.status),[S,E]=(0,n.useState)(!1),[O,K]=(0,n.useState)(!1),[T,A]=(0,n.useState)(""),$=(0,c.Kw)(_.Z,(e=>{var t;return(null===(t=e.subscriptions[f?"local_compute":"cloud_compute"])||void 0===t?void 0:t.filter((e=>!e.value.compute_subscription_name||e.value.compute_quantity_available)))||[]})),U=(0,c.Kw)(_.Z,(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)))||[]})),[M,q]=(0,n.useState)(!!b),[H,W]=(0,n.useState)(!!w);return p()((async()=>{s&&e&&j&&(0,F.Z)({auth:s,customer_id:e,stripe_id:j})}),[s,e,j]),p()((async()=>{if(x&&v){A("..."),K(!1);const e=await(0,B.Z)({auth:x,url:v});if(!e.error){const t="nats"===Z?e.clustering.nodeName:e.NODE_NAME;A(t),K(e)}}}),[x]),S&&"Restarting"!==S?(0,g.jsx)(z.Z,{header:`${S} Instance`,spinner:!0}):(0,g.jsxs)(i.Z,{id:"config",children:[(0,g.jsx)(r.Z,{xs:"12",children:(0,g.jsx)(u.SV,{onError:(e,t)=>(0,L.Z)({error:{message:e.message,componentStack:t}}),FallbackComponent:D.Z,children:(0,g.jsx)(I,{clusterNodeName:T,instanceConfig:O})})}),N&&"akamai"!==m&&(0,g.jsxs)(r.Z,{lg:"3",sm:"6",xs:"12",children:[(0,g.jsxs)(i.Z,{children:[(0,g.jsx)(r.Z,{children:(0,g.jsx)("span",{className:"floating-card-header",children:"update ram"})}),(0,g.jsx)(r.Z,{className:"text-end",children:(!!b||!!$.length)&&(0,g.jsxs)("span",{className:"floating-card-header",children:["prepaid:"," ",(0,g.jsx)(a.Z,{id:"showPrepaidCompute",color:"link",onClick:()=>q(!M),children:(0,g.jsx)("i",{className:"fa fa-lg fa-toggle-"+(M?"on":"off")})})]})})]}),(0,g.jsx)(l.Z,{className:"my-3",children:(0,g.jsx)(o.Z,{children:(0,g.jsx)(u.SV,{onError:(e,t)=>(0,L.Z)({error:{message:e.message,componentStack:t}}),FallbackComponent:D.Z,children:O?(0,g.jsx)(k,{setInstanceAction:E,showPrepaidCompute:M}):(0,g.jsx)(Y,{})})})})]}),N&&!f&&"akamai"!==m&&(0,g.jsxs)(r.Z,{lg:"3",sm:"6",xs:"12",children:[(0,g.jsxs)(i.Z,{children:[(0,g.jsx)(r.Z,{children:(0,g.jsx)("span",{className:"floating-card-header",children:"update storage"})}),(0,g.jsx)(r.Z,{className:"text-end",children:(!!w||!!U.length)&&(0,g.jsxs)("span",{className:"floating-card-header",children:["prepaid:"," ",(0,g.jsx)(a.Z,{id:"showPrepaidStorage",color:"link",onClick:()=>W(!H),children:(0,g.jsx)("i",{className:"fa fa-lg fa-toggle-"+(H?"on":"off")})})]})})]}),(0,g.jsx)(l.Z,{className:"my-3",children:(0,g.jsx)(o.Z,{children:(0,g.jsx)(u.SV,{onError:(e,t)=>(0,L.Z)({error:{message:e.message,componentStack:t}}),FallbackComponent:D.Z,children:O?(0,g.jsx)(C,{setInstanceAction:E,showPrepaidStorage:H}):(0,g.jsx)(Y,{})})})})]}),N&&(0,g.jsxs)(r.Z,{lg:"3",sm:"6",xs:"12",children:[(0,g.jsx)("span",{className:"floating-card-header",children:"remove instance"}),(0,g.jsx)(l.Z,{className:"my-3",children:(0,g.jsx)(o.Z,{children:(0,g.jsx)(u.SV,{onError:(e,t)=>(0,L.Z)({error:{message:e.message,componentStack:t}}),FallbackComponent:D.Z,children:(0,g.jsx)(P,{setInstanceAction:E,instanceAction:S})})})})]}),(0,g.jsxs)(r.Z,{lg:"3",sm:"6",xs:"12",children:[(0,g.jsx)("span",{className:"floating-card-header",children:"restart instance"}),(0,g.jsx)(l.Z,{className:"my-3",children:(0,g.jsx)(o.Z,{children:(0,g.jsx)(u.SV,{onError:(e,t)=>(0,L.Z)({error:{message:e.message,componentStack:t}}),FallbackComponent:D.Z,children:(0,g.jsx)(R,{setInstanceAction:E,instanceAction:S})})})})]}),(0,g.jsxs)(r.Z,{xs:"12",children:[(0,g.jsx)("span",{className:"floating-card-header",children:"instance config (read only)"}),(0,g.jsx)(l.Z,{className:"mt-3 mb-4",children:(0,g.jsx)(o.Z,{className:"p-0",children:(0,g.jsx)(u.SV,{onError:(e,t)=>(0,L.Z)({error:{message:e.message,componentStack:t}}),FallbackComponent:D.Z,children:O?(0,g.jsx)(V,{instanceConfig:O}):(0,g.jsx)(Y,{})})})})]})]})}},1216:(e,t,s)=>{s.d(t,{Z:()=>i});s(7313);var n=s(6417);const i=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"})]})}},2589:(e,t,s)=>{s.d(t,{Z:()=>i});s(7313);var n=s(6417);const i=function(e){let{children:t,header:s,subheader:i,maxHeight:r="auto",minHeight:a="auto",className:l}=e;return(0,n.jsxs)("div",{className:`content-container ${l}`,children:[(0,n.jsxs)("div",{className:"header-container",children:[(0,n.jsx)("span",{className:"header",children:s}),(0,n.jsx)("span",{className:"subheader",children:i})]}),(0,n.jsx)("div",{className:"auto"!==r?"scrollable":"",style:{maxHeight:r,minHeight:a},children:t})]})}},7266:(e,t,s)=>{s.d(t,{Z:()=>c});var n=s(7313),i=s(6782),r=s(5399),a=s(9327),l=s(6160),o=s(6417);const c=function(e){let{text:t,beforeText:s,afterText:c,obscure:d=!1}=e;const u=(0,l.VY)(),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)(i.Z,{className:"copyable-text-holder g-0",children:[m&&t&&(0,o.jsx)(r.Z,{className:"copy-icon",children:(0,o.jsx)(a.Z,{title:"Copy this value",onClick:p,color:"link",children:(0,o.jsx)("i",{className:"fa fa-copy text-small"})})}),(0,o.jsx)(r.Z,{className:"text-container",children:t?(0,o.jsxs)(o.Fragment,{children:[s,d?t.replace(/./g,"*"):t,c]}):(0,o.jsx)("span",{children:"\xa0"})})]})}},9105:(e,t,s)=>{s.d(t,{Z:()=>r});s(7313);var n=s(9327),i=s(6417);const r=function(e){let{disabled:t,label:s,onClick:r}=e;return(0,i.jsx)(n.Z,{onClick:r,title:s,block:!0,disabled:t,color:"danger",className:"mt-2",id:"visitCreditCard",children:s})}},7093:(e,t,s)=>{s.d(t,{Z:()=>i});var n=s(9859);const i=async e=>{let{auth:t,url:s}=e;return(0,n.Z)({operation:{operation:"get_configuration"},auth:t,url:s})}},8147:(e,t,s)=>{s.d(t,{Z:()=>r});var n=s(9859),i=s(5447);const r=async e=>{let{auth:t,url:s}=e;return i.Z.update((e=>{e.restarting=!0})),(0,n.Z)({operation:{operation:"restart"},auth:t,url:s})}},9858:(e,t,s)=>{s.d(t,{Z:()=>i});var n=s(576);const i=async e=>{let{auth:t,customer_id:s,compute_stack_id:i,is_verizon:r,is_akamai:a}=e;return(0,n.Z)({endpoint:r?"wl/removeWavelengthInstance":a?"removeAkamaiInstance":"removeInstance",method:"POST",payload:{customer_id:s,compute_stack_id:i,compute_stack_wl_id:i},auth:t})}},1781:(e,t,s)=>{s.d(t,{Z:()=>f});var n=s(7313),i=s(5192),r=s.n(i),a=s(6123),l=s.n(a),o=s(986);function c(e){return c="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},c(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,i=function(e,t){if(null==e)return{};var s,n,i={},r=Object.keys(e);for(n=0;n<r.length;n++)s=r[n],t.indexOf(s)>=0||(i[s]=e[s]);return i}(e,t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);for(n=0;n<r.length;n++)s=r[n],t.indexOf(s)>=0||Object.prototype.propertyIsEnumerable.call(e,s)&&(i[s]=e[s])}return i}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=v(e);if(t){var i=v(this).constructor;s=Reflect.construct(n,arguments,i)}else s=n.apply(this,arguments);return function(e,t){if(t&&("object"===c(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 v(e){return v=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(e){return e.__proto__||Object.getPrototypeOf(e)},v(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:o.iC,innerRef:r().oneOfType([r().object,r().func,r().string]),plaintext:r().bool,addon:r().bool,className:r().string,cssModule:r().object},g=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)}(a,e);var t,s,i,r=_(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=r.call(this,e)).getRef=t.getRef.bind(x(t)),t.focus=t.focus.bind(x(t)),t}return t=a,(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,i=e.type,r=void 0===i?"text":i,a=e.bsSize,c=e.valid,p=e.invalid,h=e.tag,_=e.addon,x=e.plaintext,v=e.innerRef,j=m(e,d),g=["switch","radio","checkbox"].indexOf(r)>-1,f="select"===r,Z="range"===r,b=h||(f||"textarea"===r?r:"input"),w="form-control";x?(w="".concat(w,"-plaintext"),b=h||"input"):Z?w="form-range":f?w="form-select":g&&(w=_?null:"form-check-input"),j.size&&/\D/g.test(j.size)&&((0,o.O4)('Please use the prop "bsSize" instead of the "size" to bootstrap\'s input sizing.'),a=j.size,delete j.size);var y=(0,o.mx)(l()(t,p&&"is-invalid",c&&"is-valid",!!a&&(f?"form-select-".concat(a):"form-control-".concat(a)),w),s);return("input"===b||h&&"function"===typeof h)&&(j.type="switch"===r?"checkbox":r),j.children&&!x&&"select"!==r&&"string"===typeof b&&"select"!==b&&((0,o.O4)('Input with a type of "'.concat(r,'" cannot have children. Please use "value"/"defaultValue" instead.')),delete j.children),n.createElement(b,u({},j,{ref:v,className:y,"aria-invalid":p}))}}])&&p(t.prototype,s),i&&p(t,i),Object.defineProperty(t,"prototype",{writable:!1}),a}(n.Component);g.propTypes=j;const f=g}}]);
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
"use strict";(self.webpackChunkharperdb_studio=self.webpackChunkharperdb_studio||[]).push([[255],{9951:(e,s,a)=>{a.r(s),a.d(s,{default:()=>L});var t=a(7313),r=a(6782),l=a(5399),i=a(4122),n=a(238),c=a(3516),o=a(7387),d=a(9842),u=a(511),m=a(5447),h=a(9327),x=a(1842),g=a(6417);const p=function(e){let{totalRecords:s,loading:a,autoRefresh:t,setAutoRefresh:i,showFilter:n,filtered:c,setLastUpdate:o,toggleFilter:d,setShowChartModal:m}=e;return(0,g.jsxs)(r.Z,{className:"floating-card-header",children:[(0,g.jsxs)(l.Z,{xs:"12",md:"3",children:[(0,x.Z)(s)," record",1!==s?"s":""]}),(0,g.jsxs)(l.Z,{xs:"12",md:"9",className:"text-md-end",children:[(0,g.jsx)("br",{className:"d-block d-md-none"}),!u.Z.is_local_studio&&(0,g.jsxs)(g.Fragment,{children:[(0,g.jsxs)(h.Z,{id:"createChart",color:"link",title:"Create Chart",onClick:()=>m(!0),children:[(0,g.jsx)("i",{className:"fa fa-lg fa-chart-line"}),(0,g.jsx)("span",{className:"ms-2",children:"create chart"})]}),(0,g.jsx)("span",{className:"mx-3 text",children:"|"})]}),(0,g.jsx)(h.Z,{color:"link",title:"Refresh Results",className:"me-2",onClick:()=>o(Date.now()),children:(0,g.jsx)("i",{className:"fa "+(a?"fa-spinner fa-spin":"fa-sync-alt")})}),(0,g.jsxs)(h.Z,{color:"link",title:"Turn on autofresh",onClick:()=>i(!t),children:[(0,g.jsx)("span",{className:"me-2",children:"auto"}),(0,g.jsx)("i",{className:"fa fa-lg fa-toggle-"+(t?"on":"off")})]}),(0,g.jsx)("span",{className:"mx-3 text",children:"|"}),(0,g.jsx)(h.Z,{color:"link",title:"Filter Results",className:"me-2",onClick:()=>d({filtered:n?[]:c,page:0,showFilter:!n}),children:(0,g.jsx)("i",{className:"fa fa-search"})})]})]})};var j=a(1446),b=a(2020),f=a(8642),y=a(1781),N=a(8212),v=a(8446),Z=a(8467),C=a(6160),k=a(6449),_=a(576);var S=a(9356);const w=[{type:"line"},{type:"bar"},{type:"area"},{type:"radar"},{type:"pie",singleSeriesAttribute:!0},{type:"donut",singleSeriesAttribute:!0},{type:"single value",singleSeriesAttribute:!0}];var q=a(3262);const A=function(e){var s,a;let{setShowChartModal:i,tableData:d,query:u}=e;const{compute_stack_id:m,customer_id:x}=(0,Z.UO)(),p=(0,C.VY)(),[A,P]=(0,t.useState)({customer_id:x,compute_stack_id:m,name:!1,type:"line",query:u,labelAttribute:!1,seriesAttributes:[],shared:!1}),[F,z]=(0,t.useState)(!1),R=(0,o.Kw)(k.Z,(e=>e.auth)),$=(0,o.Kw)(k.Z,(e=>e.theme)),O=Object.keys(d[0]),E=[...A.seriesAttributes,A.labelAttribute,"__createdtime__","__updatedtime__"],D="single value"===A.type?null===(s=A.seriesAttributes)||void 0===s?void 0:s.length:A.type&&(null===(a=A.seriesAttributes)||void 0===a?void 0:a.length)&&A.labelAttribute,T="single value"===A.type?A.seriesAttributes.length&&A.name:A.type&&A.labelAttribute&&A.seriesAttributes.length&&A.name,B=w.map((e=>e.singleSeriesAttribute&&e.type)).includes(A.type),Q=(0,S.Z)({title:A.name||"chart name",type:A.type,labels:d.map((e=>e[A.labelAttribute])),theme:$}),L=B?d.map((e=>e[A.seriesAttributes[0]])):A.seriesAttributes.map((e=>({name:e,data:d.map((s=>s[e]))})));return(0,g.jsxs)(j.Z,{id:"chart-modal",size:"lg",isOpen:!0,toggle:()=>i(!1),className:$,centered:!0,fade:!1,children:[(0,g.jsx)(b.Z,{toggle:()=>i(!1),children:"Create Chart From This Query Data"}),(0,g.jsxs)(f.Z,{children:[(0,g.jsxs)(r.Z,{children:[(0,g.jsx)(l.Z,{xs:"12",className:"py-2 query-text",children:(0,g.jsx)("i",{children:u})}),(0,g.jsx)(l.Z,{xs:"12",children:(0,g.jsx)("hr",{className:"my-2"})}),(0,g.jsx)(l.Z,{lg:"4",children:(0,g.jsx)(N.ZP,{className:"react-select-container limited-height",classNamePrefix:"react-select",onChange:e=>{let{value:s}=e;return(e=>{const s=w.find((s=>s.type===e)).singleSeriesAttribute!==w.find((e=>e.type===A.type)).singleSeriesAttribute;P(s?{...A,labelAttribute:!1,seriesAttributes:[],type:e}:{...A,type:e})})(s)},options:w.map((e=>({label:`${e.type}`,value:e.type}))),value:{label:`chart type: ${A.type}`,value:A.type},isSearchable:!1,isClearable:!1,placeholder:"Chart Type",styles:{placeholder:e=>({...e,textAlign:"center",width:"100%",color:"#BCBCBC"})}})}),(0,g.jsx)(l.Z,{xs:"12",className:"d-block d-lg-none",children:(0,g.jsx)("hr",{className:"my-2"})}),(0,g.jsx)(l.Z,{lg:"4",children:(0,g.jsx)(N.ZP,{className:"react-select-container limited-height",classNamePrefix:"react-select",onChange:e=>{let{value:s}=e;return a=s,P({...A,seriesAttributes:B?[a]:[...A.seriesAttributes,a]});var a},options:O.filter((e=>!E.includes(e))).sort().map((e=>({label:e,value:e}))),value:B&&A.seriesAttributes.length?{label:`data column: ${A.seriesAttributes[0]}`,value:A.seriesAttributes[0]}:null,isSearchable:!1,isClearable:!1,isDisabled:!A.type,placeholder:(B?"select":"add")+" data column",styles:{placeholder:e=>({...e,textAlign:"center",width:"100%",color:"#BCBCBC"})}})}),(0,g.jsx)(l.Z,{lg:"4",children:"single value"!==A.type&&(0,g.jsxs)(g.Fragment,{children:[(0,g.jsx)("hr",{className:"d-block d-lg-none my-2"}),(0,g.jsx)(N.ZP,{className:"react-select-container limited-height",classNamePrefix:"react-select",onChange:e=>{let{value:s}=e;return a=s,P({...A,labelAttribute:a});var a},options:O.filter((e=>!["__createdtime__","__updatedtime__"].includes(e))).sort().map((e=>({label:e,value:e}))),value:A.labelAttribute?{label:`${B?"label":"x-axis"}: ${A.labelAttribute}`,value:A.labelAttribute}:null,isSearchable:!1,isClearable:!1,isDisabled:!A.type,placeholder:`select ${B?"label":"x-axis"} column`,styles:{placeholder:e=>({...e,textAlign:"center",width:"100%",color:"#BCBCBC"})}})]})}),(0,g.jsx)(l.Z,{xs:"12",children:(0,g.jsx)("hr",{className:"my-2"})}),(0,g.jsx)(l.Z,{lg:"4",children:(0,g.jsx)(y.Z,{id:"chart_name",type:"text",placeholder:"chart name",onChange:e=>P({...A,name:e.target.value})})}),(0,g.jsx)(l.Z,{xs:"12",className:"d-block d-lg-none",children:(0,g.jsx)("hr",{className:"my-2"})}),(0,g.jsxs)(l.Z,{lg:"4",className:"py-2 text-nowrap d-flex justify-content-center align-items-center",children:[(0,g.jsx)(h.Z,{className:"me-2",color:"link",onClick:()=>P({...A,shared:!A.shared}),children:(0,g.jsx)("i",{className:"fa fa-lg text-purple fa-toggle-"+(A.shared?"on":"off")})}),"visible to all org users"]}),(0,g.jsx)(l.Z,{xs:"12",className:"d-block d-lg-none",children:(0,g.jsx)("hr",{className:"my-2"})}),(0,g.jsx)(l.Z,{lg:"4",children:(0,g.jsx)(h.Z,{onClick:async()=>{z(!0);const e=await(async e=>{let{auth:s,customer_id:a,compute_stack_id:t,name:r,type:l,query:i,labelAttribute:n,seriesAttributes:c,shared:o}=e;return(0,_.Z)({endpoint:"addChart",method:"POST",auth:s,payload:{user_id:s.user_id,customer_id:a,compute_stack_id:t,name:r,type:l,query:i,labelAttribute:n,seriesAttributes:c,shared:o}})})({auth:R,...A});e.error?(p.error(e.message),z(!1)):(p.success(e.message),i(!1))},block:!0,disabled:!T||F,color:"success",children:F?(0,g.jsx)("i",{className:"fa fa-spin fa-spinner"}):(0,g.jsx)("span",{children:"Add Chart"})})})]}),!B&&A.seriesAttributes.length?(0,g.jsxs)(g.Fragment,{children:[(0,g.jsx)("hr",{className:"my-2"}),(0,g.jsx)("div",{className:"",children:A.seriesAttributes.map((e=>(0,g.jsxs)(h.Z,{color:"danger",size:"sm",className:"me-2",onClick:()=>(e=>{const s=A.seriesAttributes.indexOf(e);A.seriesAttributes.splice(s,1),P({...A,seriesAttributes:A.seriesAttributes})})(e),children:["[x] ",e]},e)))})]}):null,(0,g.jsx)("hr",{className:"my-2"}),(0,g.jsx)("div",{className:"chart-holder",children:D&&"single value"===A.type?(0,g.jsx)(n.Z,{children:(0,g.jsxs)(c.Z,{className:"single-value-chart",children:[(0,g.jsx)("div",{className:"title",children:A.name||"chart name"}),(0,g.jsx)("h1",{children:(0,q.Z)(L[0])?L[0].toFixed(2):L[0]})]})}):D?(0,g.jsx)(v.Z,{options:Q,series:L,type:A.type,height:220}):(0,g.jsxs)("div",{className:"text-center py-5 text-grey",children:["please choose chart ",!A.type&&"type, ","label and data"]})})]})]})};var P=a(6512);const F=function(e){let{message:s,loading:a=!1,error:t=!1,accessErrors:r=!1,cancel:l=!1}=e;const i=r&&r.filter((e=>"table"===e.type)),o=r&&r.filter((e=>"attribute"===e.type));return(0,g.jsxs)(g.Fragment,{children:[(0,g.jsx)("div",{className:"floating-card-header",children:"\xa0"}),(0,g.jsx)(n.Z,{className:"my-3",children:(0,g.jsx)(c.Z,{children:(0,g.jsxs)("div",{className:"empty-prompt",children:[(0,g.jsxs)("div",{className:"mb-2",children:["\xa0",a&&(0,g.jsx)("i",{className:"fa fa-spinner fa-spin"}),"\xa0"]}),s&&(0,g.jsxs)("div",{className:"mb-2 "+(t?"text-danger":""),children:["\xa0",s,"\xa0"]}),a&&l&&(0,g.jsx)(h.Z,{color:"danger",size:"sm",className:"px-3",onClick:l,children:"cancel query"}),t&&i&&i.length?(0,g.jsxs)(g.Fragment,{children:[(0,g.jsx)("hr",{className:"my-4"}),(0,g.jsx)("ul",{children:i.map((e=>(0,g.jsxs)("li",{className:"mb-2",children:[e.schema," > ","attribute"===e.type&&(0,g.jsxs)("span",{children:[e.table," >"]})," ",(0,g.jsx)("b",{children:e.entity}),": ",e.type," requires ",(0,g.jsx)("b",{children:e.permission})," permissions"]},`${e.schema}${e.table}${e.entity}${e.permission}`)))}),(0,g.jsx)("hr",{})]}):null,t&&o&&(0,g.jsxs)(g.Fragment,{children:[(0,g.jsx)("hr",{className:"my-4"}),(0,g.jsx)("ul",{children:o.map((e=>(0,g.jsxs)("li",{className:"mb-2",children:[e.schema," > ","attribute"===e.type&&(0,g.jsxs)("span",{children:[e.table," >"]})," ",(0,g.jsx)("b",{children:e.entity}),": ",e.type," requires ",(0,g.jsx)("b",{children:e.permission})," permissions"]},`${e.schema}${e.table}${e.entity}${e.permission}`)))})]})]})})})]})};var z=a(4220),R=a(2261),$=a(6855);const O={tableData:!1,totalRecords:0,dataTableColumns:[],filtered:[],sorted:[],page:0,totalPages:1,pageSize:20,autoRefresh:!1,showFilter:!1,lastUpdate:!1};let E;const D=function(e){var s;let{query:a}=e;const[r,l]=(0,t.useState)(),h=(0,o.Kw)(m.Z,(e=>e.auth)),x=(0,o.Kw)(m.Z,(e=>e.url)),[j,b]=(0,t.useState)(O),[f,y]=(0,t.useState)(!1),[N,v]=(0,t.useState)(!1);return(0,t.useEffect)((()=>{let e=!0;return(async()=>{if(a.query&&a.lastUpdate){E&&E.abort(),E=new AbortController,v(!0);const t=await(async e=>{let{query:s,auth:a,url:t,signal:r}=e;try{const e=await(0,P.Z)({sql:s,auth:a,url:t,signal:r});if(e.error)return{message:e.message,error:!0,access_errors:e.access_errors};if(e.message)return{message:e.message};const l=e.length,i=l?Object.keys(e[0]):[],n=i.filter((e=>!["__createdtime__","__updatedtime__"].includes(e))).sort();return i.includes("__createdtime__")&&n.push("__createdtime__"),i.includes("__updatedtime__")&&n.push("__updatedtime__"),{tableData:e,totalRecords:l,dataTableColumns:n.map((e=>({Header:e.toString(),accessor:s=>s[e.toString()]})))}}catch(l){return{message:l,error:!0}}})({query:a.query.replace(/\n/g," ").trim(),auth:h,url:x,signal:E.signal});if(v(!1),t.error&&"Aborted"===t.message)b({...j,message:"query canceled, please execute a new query to proceed",error:!1});else if(t.error)b({...j,message:`error fetching data: ${t.message}`,access_errors:t.access_errors,error:!0});else if(t.message)b({...j,message:t.message,error:!1});else if(e){var s;b({...j,...t,totalPages:Math.ceil(((null===(s=t.tableData)||void 0===s?void 0:s.length)||20)/20),error:!1,message:!t.totalRecords&&"no records matched your query",sorted:[]})}}})(),()=>{var s;null===(s=E)||void 0===s||s.abort(),e=!1}}),[a,r]),(0,t.useEffect)((()=>{b(O)}),[a.query]),(0,i.Z)((()=>{j.autoRefresh&&!N&&l(Date.now())}),u.Z.refresh_content_interval),N||j.message||j.access_errors?(0,g.jsx)(F,{error:j.error,accessErrors:j.access_errors,loading:N,message:!N&&j.message,cancel:()=>{E&&E.abort(),b(O),v(!1)}}):null!==(s=j.tableData)&&void 0!==s&&s.length?(0,g.jsxs)(d.SV,{onError:(e,s)=>(0,R.Z)({error:{message:e.message,componentStack:s}}),FallbackComponent:z.Z,children:[(0,g.jsx)(p,{totalRecords:j.totalRecords,loading:N,showFilter:j.showFilter,filtered:j.filtered,toggleFilter:e=>b({...j,...e}),autoRefresh:j.autoRefresh,setAutoRefresh:()=>b({...j,autoRefresh:!j.autoRefresh}),setLastUpdate:l,setShowChartModal:y}),(0,g.jsx)(n.Z,{className:"my-3",children:(0,g.jsx)(c.Z,{className:"react-table-holder",children:(0,g.jsx)($.Z,{columns:j.dataTableColumns||[],data:j.tableData||[],currentPage:j.page,pageSize:j.pageSize,totalPages:j.totalPages,showFilter:j.showFilter,sorted:j.sorted,loading:N&&!j.autoRefresh,onFilteredChange:e=>b({...j,filtered:e}),onSortedChange:e=>b({...j,sorted:e}),onPageChange:e=>b({...j,pageSize:e}),onPageSizeChange:e=>b({...j,page:0,pageSize:e})})})}),f&&(0,g.jsx)(A,{setShowChartModal:y,tableData:j.tableData,query:a.query.replace(/\n/g," ").trim()})]}):(0,g.jsx)(F,{message:"please execute a SQL query to proceed"})};const T=function(e){let{setQuery:s,query:a}=e;const[i,o]=(0,t.useState)(""),[u,m]=(0,t.useState)(!1),x=(0,t.createRef)();return(0,t.useEffect)((()=>{a&&(m({submitted:!1}),o(a.query||a),x.current.focus())}),[a]),(0,t.useEffect)((()=>{const e=i,a=e.length?e.replace(/[\t\n\r]/gm,""):"";u.submitted&&a.length?(s({lastUpdate:Date.now(),query:i.trim()}),o(i.trim()),m({submitted:!1})):u.submitted&&(o(""),m({submitted:!1}))}),[u]),(0,g.jsx)(d.SV,{onError:(e,s)=>(0,R.Z)({error:{message:e.message,componentStack:s}}),FallbackComponent:z.Z,children:(0,g.jsxs)("div",{id:"query-window",children:[(0,g.jsx)("span",{className:"floating-card-header",children:"sql query"}),(0,g.jsx)(n.Z,{className:"mt-3 mb-4",children:(0,g.jsxs)(c.Z,{children:[(0,g.jsx)(y.Z,{id:"sql_query",type:"textarea",className:"sql-query-textarea",value:i,onKeyDown:e=>{"Enter"===e.code&&e.metaKey?m({submitted:!0}):"Tab"===e.code&&(e.preventDefault(),document.execCommand("insertHTML",!1,"	"))},onChange:e=>o(e.target.value)}),(0,g.jsxs)(r.Z,{children:[(0,g.jsx)(l.Z,{children:(0,g.jsx)(h.Z,{color:"grey",title:"clear query",block:!0,className:"mt-2",onClick:()=>{s(!1),o("")},children:"Clear"})}),(0,g.jsx)(l.Z,{children:(0,g.jsx)(h.Z,{id:"executeQuery",innerRef:x,title:"execute query",color:"success",block:!0,className:"mt-2",onClick:()=>m({submitted:!0}),children:"Execute"})})]})]})})]})})};const B=(0,a(8131).Z)("instanceQueries");const Q=function(e){var s;let{setQuery:a,query:i}=e;const{compute_stack_id:o}=(0,Z.UO)(),[u,m]=B({});return(0,t.useEffect)((()=>{if(i.lastUpdate){var e;const s=u&&(null===(e=u[o])||void 0===e?void 0:e.filter((e=>e.query.toLowerCase()!==i.query.toLowerCase())))||[];s.unshift(i),m({...u,[o]:s})}}),[i]),(0,g.jsx)(d.SV,{onError:(e,s)=>(0,R.Z)({error:{message:e.message,componentStack:s}}),FallbackComponent:z.Z,children:(0,g.jsxs)("div",{id:"query-history",children:[(0,g.jsxs)(r.Z,{className:"floating-card-header",children:[(0,g.jsx)(l.Z,{xs:"9",children:"query history (click to load)"}),(0,g.jsx)(l.Z,{xs:"3",className:"text-end",children:(0,g.jsx)(h.Z,{color:"link",title:"Refresh Results",className:"me-2",onClick:()=>m({...u,[o]:[]}),children:(0,g.jsx)("i",{className:"fa fa-trash"})})})]}),(0,g.jsx)(n.Z,{className:"my-3",children:u&&null!==(s=u[o])&&void 0!==s&&s.length?(0,g.jsx)(c.Z,{className:"query-scroller",children:u[o].map(((e,s)=>(0,g.jsxs)(t.Fragment,{children:[(0,g.jsx)("button",{id:`loadQuery${s}`,type:"button",tabIndex:"0",title:`Load query: ${e.query}`,className:"past-query",onClick:()=>a(e.query),children:(0,g.jsx)("span",{children:e.query})}),(0,g.jsx)("hr",{className:"my-0"})]},e.query)))}):(0,g.jsx)(c.Z,{className:"text-center text-grey",children:"no queries yet"})})]})})};const L=function(){const[e,s]=(0,t.useState)(!1);return(0,g.jsxs)(r.Z,{id:"query",children:[(0,g.jsxs)(l.Z,{xl:"3",lg:"4",md:"5",xs:"12",children:[(0,g.jsx)(T,{setQuery:s,query:e}),(0,g.jsx)(Q,{setQuery:s,query:e})]}),(0,g.jsx)(l.Z,{xl:"9",lg:"8",md:"7",xs:"12",children:(0,g.jsx)(D,{query:e})})]})}},6855:(e,s,a)=>{a.d(s,{Z:()=>y});var t=a(7313),r=a(5110),l=a(1781),i=a(9842),n=a(6782),c=a(5399),o=a(6417);const d=e=>{let{headerGroups:s,onSortedChange:a,sorted:t,showFilter:r}=e;return s.map((e=>(0,o.jsxs)("div",{...e.getHeaderGroupProps(),children:[(0,o.jsx)(n.Z,{className:"header g-0",children:e.headers.map((e=>{var s,r;return(0,o.jsx)(c.Z,{onClick:()=>{var s,r;return a([{id:e.id,desc:(null===(s=t[0])||void 0===s?void 0:s.id)===e.id&&!(null!==(r=t[0])&&void 0!==r&&r.desc)}])},className:`${(null===(s=t[0])||void 0===s?void 0:s.id)===e.id?"sorted":""} ${null!==(r=t[0])&&void 0!==r&&r.desc?"desc":"asc"} ${-1!==e.id.indexOf("hdb-narrow")?"action":""} px-1`,children:(0,o.jsx)("div",{className:"text-renderer",children:e.render("Header")})},e.id)}))}),r&&(0,o.jsx)(n.Z,{className:"filter g-0",children:e.headers.map((e=>(0,o.jsx)(c.Z,{className:-1!==e.id.indexOf("hdb-narrow")?"action":"",children:e.render("Filter")},e.id)))})]})))};var u=a(9327);const m=function(e){let{page:s,pageSize:a,totalPages:t,onPageChange:r,onPageSizeChange:i,loading:d}=e;return(0,o.jsxs)(n.Z,{className:"pagination",children:[(0,o.jsx)(c.Z,{xs:"12",sm:"2",className:"previous",children:(0,o.jsx)(u.Z,{className:"mb-2 btn-pagination",color:"purple",block:!0,onClick:()=>r(s-1),disabled:!t||0===s,children:(0,o.jsx)("i",{className:"fa fa-chevron-left"})})}),(0,o.jsxs)(c.Z,{xs:"12",sm:"4",className:"paginator",children:[(0,o.jsx)("i",{className:"fa fa-book me-2"}),(0,o.jsx)(l.Z,{className:"mb-2",type:"number",value:s+1,min:1,max:t,onChange:e=>r(e.target.value-1)}),(0,o.jsxs)("div",{className:"page-count",children:["\xa0/\xa0",d?(0,o.jsx)("i",{className:"fa fa-spinner fa-spin"}):t]})]}),(0,o.jsx)(c.Z,{xs:"12",sm:"4",className:"page-size",children:(0,o.jsx)(l.Z,{className:"mb-2",type:"select",value:a,onChange:e=>i(e.target.value),children:[20,50,100,250].map((e=>(0,o.jsxs)("option",{value:e,children:[e," rows"]},e)))})}),(0,o.jsx)(c.Z,{xs:"12",sm:"2",className:"next",children:(0,o.jsx)(u.Z,{className:"mb-2 pull-right btn-pagination",block:!0,color:"purple",onClick:()=>r(s+1),disabled:!t||s+1===t,children:(0,o.jsx)("i",{className:"fa fa-chevron-right"})})})]})};const h=function(e){let{previousPage:s,canPreviousPage:a,pageIndex:t,gotoPage:r,setPageSize:i,pageCount:d,nextPage:m,canNextPage:h,loading:x}=e;return(0,o.jsxs)(n.Z,{className:"pagination",children:[(0,o.jsx)(c.Z,{xs:"12",sm:"2",className:"previous",children:(0,o.jsx)(u.Z,{className:"mb-2 btn-pagination",color:"purple",block:!0,onClick:s,disabled:!d||!a,children:(0,o.jsx)("i",{className:"fa fa-chevron-left"})})}),(0,o.jsxs)(c.Z,{xs:"12",sm:"4",className:"paginator",children:[(0,o.jsx)("i",{className:"fa fa-book me-2"}),(0,o.jsx)(l.Z,{className:"mb-2",type:"number",value:t+1||1,min:1,max:d,onChange:e=>r(e.target.value?Number(e.target.value)-1:0)}),(0,o.jsxs)("div",{className:"page-count",children:["\xa0/\xa0",x?(0,o.jsx)("i",{className:"fa fa-spinner fa-spin"}):d]})]}),(0,o.jsx)(c.Z,{xs:"12",sm:"4",className:"page-size",children:(0,o.jsx)(l.Z,{className:"mb-2",type:"select",onChange:e=>{r(0),setTimeout((()=>i(e.target.value)),1e3)},children:[20,50,100,250].map((e=>(0,o.jsxs)("option",{value:e,children:[e," rows"]},e)))})}),(0,o.jsx)(c.Z,{xs:"12",sm:"2",className:"next",children:(0,o.jsx)(u.Z,{className:"mb-2 pull-right btn-pagination",block:!0,color:"purple",onClick:m,disabled:!d||!h,children:(0,o.jsx)("i",{className:"fa fa-chevron-right"})})})]})};const x=function(e){let{prepareRow:s,row:a,onRowClick:t=!1}=e;return s(a),(0,o.jsx)(n.Z,{onClick:()=>t&&t(a.original),className:"g-0",children:a.cells.map((e=>(0,o.jsx)(c.Z,{className:-1!==e.column.id.indexOf("hdb-narrow")?"action":"",children:e.render("Cell")},`${e.row.id}-${e.column.id}`)))})};var g=a(2261),p=a(4220);function j(e){let{value:s}=e;return(0,o.jsx)("div",{className:"text-renderer",children:s})}function b(e){let{src:s}=e;const[a,r]=(0,t.useState)(!1),[l,i]=(0,t.useState)(!1);return(0,o.jsxs)("div",{className:"image-renderer",onMouseEnter:()=>r(!0),onMouseLeave:()=>r(!1),children:[(0,o.jsx)("i",{className:"fa fa-image"}),a&&l?(0,o.jsxs)("div",{className:"preview-image no-image",children:[(0,o.jsx)("i",{className:"fa fa-ban text-danger"}),(0,o.jsx)("div",{className:"mt-2",children:"image failed to load"})]}):a?(0,o.jsx)("img",{onError:i,alt:s,src:s,className:"preview-image"}):null]})}const f={Filter:e=>{let{column:{filterValue:s,setFilter:a}}=e;return(0,o.jsx)(l.Z,{type:"text",value:s||"",onChange:e=>a(e.target.value||void 0)})},Cell:e=>{let{value:s}=e;return(e=>{switch(Object.prototype.toString.call(e)){case"[object Array]":case"[object Object]":return(0,o.jsx)(j,{value:JSON.stringify(e)});case"[object Boolean]":return(0,o.jsx)(j,{value:e?"true":"false"});case"[object String]":return(s=e)&&(s.match(/^https?.*\.(jpeg|jpg|gif|png)$/)||-1!==s.indexOf("data:image"))?(0,o.jsx)(b,{src:e}):(0,o.jsx)(j,{value:e});default:return(0,o.jsx)(j,{value:e})}var s})(s)}};const y=function(e){let{columns:s,data:a,currentPage:l,pageSize:n,totalPages:c,onFilteredChange:u,onSortedChange:j,onPageChange:b,onPageSizeChange:y,showFilter:N,onRowClick:v,sorted:Z,loading:C,manual:k=!1}=e;const{headerGroups:_,page:S,rows:w,prepareRow:q,state:A,setAllFilters:P,canPreviousPage:F,canNextPage:z,pageOptions:R,pageCount:$,gotoPage:O,nextPage:E,previousPage:D,setPageSize:T}=(0,r.useTable)({columns:s,data:a,defaultColumn:f,onFilteredChange:u,onSortedChange:j,onPageChange:b,onPageSizeChange:y,onRowClick:v,manualPagination:k,manualFilters:k,initialState:{pageIndex:l,pageSize:n}},r.useFilters,r.usePagination),[B,Q]=(0,t.useState)(!0),L=k||!S.length?w:S;return(0,t.useEffect)((()=>{!N&&A.filters.length?P([]):u(A.filters)}),[A.filters,N]),(0,t.useEffect)((()=>{setTimeout((()=>Q(!1)),100)}),[null===L||void 0===L?void 0:L.length]),(0,o.jsxs)(i.SV,{onError:(e,s)=>(0,g.Z)({error:{message:e.message,componentStack:s}}),FallbackComponent:p.Z,children:[(0,o.jsxs)("div",{className:"react-table-scroller",children:[(0,o.jsx)(d,{headerGroups:_,onSortedChange:j,sorted:Z,showFilter:N}),C||B?(0,o.jsx)("div",{className:"centered text-center",children:(0,o.jsx)("i",{className:"fa fa-spinner fa-spin"})}):L.length?L.map((e=>(0,o.jsx)(x,{row:e,prepareRow:q,onRowClick:v},e.id))):(0,o.jsxs)("div",{className:"centered text-center",children:[(0,o.jsx)("i",{className:"fa fa-exclamation-triangle text-danger"}),(0,o.jsx)("div",{className:"mt-2 text-darkgrey",children:"no records"})]})]}),k?(0,o.jsx)(m,{page:l,pageSize:n,totalPages:c,onPageChange:b,onPageSizeChange:y,loading:C}):(0,o.jsx)(h,{previousPage:D,pageSize:n,canPreviousPage:F,pageIndex:A.pageIndex,pageOptions:R,gotoPage:O,setPageSize:T,pageCount:$,nextPage:E,canNextPage:z,loading:C})]})}},6512:(e,s,a)=>{a.d(s,{Z:()=>r});var t=a(9859);const r=async e=>{let{auth:s,url:a,sql:r,signal:l}=e;return(0,t.Z)({operation:{operation:"sql",sql:r},auth:s,url:a,signal:l})}},9356:(e,s,a)=>{a.d(s,{Z:()=>t});const t=e=>{let{title:s,type:a,labels:t,theme:r}=e;const l="light"===r?"#696969":"dark"===r?"#fff":"#212121";return{title:{text:s,style:{color:l}},chart:{type:a,animations:{enabled:!1},fontFamily:"Arial, Helvetica, Verdana, Sans-Serif",toolbar:{offsetX:-25,tools:{selection:!1,pan:!1,zoom:!1,zoomin:!1,zoomout:!1,reset:!1}}},labels:t,theme:{palette:"palette10"},plotOptions:{pie:{offsetY:10}},legend:{offsetY:5,labels:{colors:l}},markers:{size:[4],strokeColors:"dark"===r?"#212121":"#fff",strokeWidth:1,strokeOpacity:"dark"===r?.5:1,hover:{sizeOffset:0}},xaxis:{labels:{rotate:-60,maxHeight:80,style:{fontSize:"10px",colors:l}},tooltip:{enabled:!1}},yaxis:{labels:{style:{fontSize:"10px",colors:l}}}}}},3262:(e,s,a)=>{a.d(s,{Z:()=>t});const t=e=>!Number.isNaN(parseFloat(e))&&Number.isFinite(parseFloat(e))}}]);
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
"use strict";(self.webpackChunkharperdb_studio=self.webpackChunkharperdb_studio||[]).push([[701],{7752:(e,t,r)=>{r.r(t),r.d(t,{default:()=>P});var n=r(7313),s=r(8467),o=r(6782),i=r(5399),a=r(9327),l=r(238),c=r(3516),u=r(7387),f=r(5447),p=r(9842),d=r(6597),m=r(1781),h=r(6160),y=r(4851),b=r(5200),g=r(1714),j=r(6417);const v=function(e){let{itemType:t,toggleDropItem:r,toggleCreate:l,baseUrl:c}=e;const{compute_stack_id:p,customer_id:v}=(0,s.UO)(),x=(0,s.s0)(),w=(0,h.VY)(),Z=(0,u.Kw)(f.Z,(e=>e.auth)),O=(0,u.Kw)(f.Z,(e=>e.url)),N=(0,u.Kw)(f.Z,(e=>e.is_local)),_=(0,u.Kw)(f.Z,(e=>e.roles&&e.roles.map((e=>e.role)))),[k,R]=(0,n.useState)({});return(0,n.useEffect)((()=>{r()}),[r]),(0,j.jsx)(d.Z,{onSubmit:async e=>{if(e.preventDefault(),!k.name)return R({...k,error:!0}),w.error("You must provide a role name");if(_.includes(k.name))return R({...k,error:!0}),w.error("Role with that name already exists");if(!(0,g.Z)(k.name))return R({...k,error:!0}),w.error("Role names must have only letters and underscores");const r="cluster user"===t?{cluster_user:!0}:"super user"===t?{super_user:!0}:{},n=await(0,y.Z)({auth:Z,url:O,is_local:N,compute_stack_id:p,customer_id:v,role:k.name,permission:r});return n.error?(R({...k,error:!0}),w.error(n.message)):(R({}),await(0,b.Z)({auth:Z,url:O}),x(`${c}/${n.id}`))},children:(0,j.jsxs)(o.Z,{className:"item-row form",children:[(0,j.jsx)(i.Z,{className:"input-holder",children:(0,j.jsx)(m.Z,{id:"name",invalid:k.error,onChange:e=>R({name:e.target.value.toString()}),type:"text",name:"name",placeholder:"name"})}),(0,j.jsxs)(i.Z,{className:"item-action",children:[(0,j.jsx)(a.Z,{id:"createRole",color:"success",className:"round me-1",children:(0,j.jsx)("i",{className:"fa fa-check text-white"})}),(0,j.jsx)(a.Z,{color:"black",className:"round",onClick:()=>l(!1),children:(0,j.jsx)("i",{className:"fa fa-times text-white"})})]})]})})};var x=r(9859);const w=function(e){let{item:t,baseUrl:r,isActive:l,toggleDropItem:c,isDropping:p}=e;const d=(0,s.s0)(),m=(0,h.VY)(),[y,g]=(0,n.useState)(!1),v=(0,u.Kw)(f.Z,(e=>e.auth)),w=(0,u.Kw)(f.Z,(e=>e.url)),Z=async()=>{if(!y)return!1;const e=await(async e=>{let{auth:t,id:r,url:n}=e;return(0,x.Z)({operation:{operation:"drop_role",id:r},auth:t,url:n})})({auth:v,url:w,id:t.id});return e.error?m.error(e.message):((0,b.Z)({auth:v,url:w}),!!l&&setTimeout((()=>d(r)),100))};return(0,j.jsxs)(o.Z,{className:"item-row "+(l?"active":""),onClick:()=>!(l||p||y)&&d(`${r}/${t.id}`),children:[(0,j.jsx)(i.Z,{className:"item-label "+(y?"text-danger text-nowrap":""),children:y?`drop ${t.role}?`:t.role}),(0,j.jsx)(i.Z,{className:"item-action",children:y?(0,j.jsxs)(j.Fragment,{children:[(0,j.jsx)(a.Z,{id:"confirmDropRole",color:"danger",className:"round me-1",title:`confirm drop ${t.role}`,onClick:()=>{g(!1),Z()},children:(0,j.jsx)("i",{className:"fa fa-check text-white"})}),(0,j.jsx)(a.Z,{color:"black",className:"round",title:`Cancel drop ${t.role}`,onClick:()=>{g(!1)},children:(0,j.jsx)("i",{className:"fa fa-times text-white"})})]}):p?(0,j.jsx)(a.Z,{id:`drop${t.role}`,color:"danger",className:"round",title:`Drop ${t.role}`,onClick:()=>{g(t),c(!1)},children:(0,j.jsx)("i",{className:"fa fa-minus text-white"})}):l?(0,j.jsx)(a.Z,{color:"purple",className:"round",title:`Viewing ${t.role}`,children:(0,j.jsx)("i",{className:"fa fa-chevron-right"})}):null})]},t)};const Z=function(e){let{items:t,itemType:r,toggleDropItem:n,isDropping:s,toggleCreate:l,isCreating:c,showForm:u}=e;return(0,j.jsxs)(o.Z,{className:"floating-card-header",children:[(0,j.jsxs)(i.Z,{children:[r,"s"]}),u&&t&&t.length?(0,j.jsxs)(i.Z,{className:"text-end",children:[(0,j.jsx)(a.Z,{color:"link",title:`Remove ${r}s`,className:"add-remove me-3",onClick:()=>{n(!s),l(!1)},children:(0,j.jsx)("i",{className:"fa fa-minus"})}),(0,j.jsx)(a.Z,{color:"link",title:`Add ${r}`,className:"add-remove me-1",onClick:()=>{l(!c),n(!1)},children:(0,j.jsx)("i",{className:"fa fa-plus"})})]}):null]})};var O=r(4220),N=r(2261);const _=function(e){let{items:t,activeItem:r,showForm:s,baseUrl:o,itemType:i}=e;const[a,u]=(0,n.useState)(!1),[f,d]=(0,n.useState)(!1);(0,n.useEffect)((()=>{d(),u()}),[r,t]);const m=t&&[...t].sort(((e,t)=>e.role<t.role?-1:1));return(0,j.jsx)(p.SV,{onError:(e,t)=>(0,N.Z)({error:{message:e.message,componentStack:t}}),FallbackComponent:O.Z,children:(0,j.jsxs)("div",{className:"entity-manager",children:[(0,j.jsx)(Z,{items:t,itemType:i,isDropping:a,toggleDropItem:u,isCreating:f,toggleCreate:d,showForm:s}),(0,j.jsx)(l.Z,{className:"my-3",children:(0,j.jsxs)(c.Z,{children:[m&&m.length?m.map((e=>(0,j.jsx)(w,{item:e,baseUrl:o,isActive:r===e.id,isDropping:a,toggleDropItem:u},e.id))):null,(t&&!t.length||f)&&(0,j.jsx)(v,{itemType:i,baseUrl:o,isDropping:a,toggleDropItem:u,isCreating:f,toggleCreate:d})]})})]})})};var k=r(7377),R=r(5491);const S=(0,n.lazy)((()=>Promise.all([r.e(723),r.e(500)]).then(r.bind(r,5365)))),C={roleName:!1,canEdit:!1,superUsers:[],clusterUsers:[],standardUsers:[],showAttributes:!1};const P=function(){const{role_id:e,customer_id:t}=(0,s.UO)(),r=(0,u.Kw)(f.Z,(e=>e.compute_stack_id)),p=(0,u.Kw)(f.Z,(e=>e.auth)),d=(0,u.Kw)(f.Z,(e=>e.url)),m=(0,u.Kw)(f.Z,(e=>e.roles),[r]),[h,y]=(0,n.useState)(!1),[g,v]=(0,n.useState)(C),x=`/o/${t}/i/${r}/roles`,w=(0,u.Kw)(f.Z,(e=>{var t;return null===(t=e.registration)||void 0===t?void 0:t.version})),[Z,O]=(null===w||void 0===w?void 0:w.split("."))||[],N=parseFloat(`${Z}.${O}`),P=(0,n.useCallback)((async()=>{y(!0),await(0,b.Z)({auth:p,url:d}),await(0,R.Z)({auth:p,url:d}),y(!1)}),[p,d]);return(0,n.useEffect)((()=>{if(m){const t=e&&m.find((t=>t.id===e));v({...g,roleName:t&&t.role,canEdit:t&&!t.permission.cluster_user&&!t.permission.super_user,clusterUsers:m.filter((e=>e.permission.cluster_user)),superUsers:m.filter((e=>e.permission.super_user)),standardUsers:m.filter((e=>!e.permission.super_user&&!e.permission.cluster_user)),showAttributes:!1})}else v(C)}),[e,m]),(0,n.useEffect)((()=>{P()}),[P,r]),(0,j.jsxs)(o.Z,{id:"roles",children:[(0,j.jsxs)(i.Z,{xl:"3",lg:"4",md:"5",xs:"12",children:[(0,j.jsx)(_,{showForm:!0,activeItem:e,items:g.superUsers,baseUrl:x,itemType:"super user"}),(0,j.jsx)(_,{showForm:!0,activeItem:e,items:g.clusterUsers,baseUrl:x,itemType:"cluster user"}),(0,j.jsx)(_,{showForm:!0,activeItem:e,items:g.standardUsers,baseUrl:x,itemType:"standard role"})]}),(0,j.jsxs)(i.Z,{xl:"9",lg:"8",md:"7",xs:"12",children:[(0,j.jsxs)(o.Z,{className:"floating-card-header",children:[g.canEdit&&(0,j.jsxs)(i.Z,{children:["edit role > ",g.roleName]}),(0,j.jsxs)(i.Z,{className:"text-md-end",children:[g.canEdit&&(0,j.jsxs)(j.Fragment,{children:[(0,j.jsxs)(a.Z,{color:"link",tabIndex:"0",title:"Show Attributes",onClick:()=>v({...g,showAttributes:!g.showAttributes}),children:[(0,j.jsx)("span",{className:"me-2",children:"show all attributes"}),(0,j.jsx)("i",{className:"fa fa-lg fa-toggle-"+(g.showAttributes?"on":"off")})]}),(0,j.jsx)("span",{className:"mx-3 text",children:"|"})]}),(0,j.jsxs)(a.Z,{color:"link",onClick:P,className:"me-2",children:[(0,j.jsx)("span",{className:"me-2",children:"refresh roles"}),(0,j.jsx)("i",{title:"Refresh Roles",className:"fa "+(h?"fa-spinner fa-spin":"fa-sync-alt")})]})]})]}),g.canEdit?(0,j.jsx)(l.Z,{className:"my-3",children:(0,j.jsx)(c.Z,{className:"full-height",children:(0,j.jsx)(n.Suspense,{fallback:(0,j.jsx)(k.Z,{header:" ",spinner:!0}),children:(0,j.jsx)(S,{showAttributes:g.showAttributes,fetchRoles:P})})})}):(0,j.jsx)(l.Z,{className:"my-3",children:(0,j.jsx)(c.Z,{children:e?(0,j.jsxs)("div",{className:"empty-prompt",children:["Super Users and Cluster Users have full access to all ",N>=4.2?"databases":"schemas",", tables, and attributes."]}):(0,j.jsx)("div",{className:"empty-prompt",children:"Please choose or add a role to manage it."})})})]})]})}},4851:(e,t,r)=>{r.d(t,{Z:()=>s});var n=r(9859);const s=async e=>{let{auth:t,url:r,role:s,permission:o}=e;return(0,n.Z)({operation:{operation:"add_role",role:s,permission:o},auth:t,url:r})}},5200:(e,t,r)=>{r.d(t,{Z:()=>o});var n=r(9859),s=r(5447);const o=async e=>{let{auth:t,url:r}=e;const o=await(0,n.Z)({operation:{operation:"list_roles"},auth:t,url:r}),i=[...Array.isArray(o)?o:[]].sort(((e,t)=>e.role.toLowerCase()>t.role.toLowerCase()?1:-1));return s.Z.update((e=>{e.roles=i})),i}},1714:(e,t,r)=>{r.d(t,{Z:()=>n});const n=e=>e.match(/^[a-zA-Z_]+$/)},6597:(e,t,r)=>{r.d(t,{Z:()=>g});var n=r(7313),s=r(5192),o=r.n(s),i=r(986);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 l=["className","cssModule","tag","innerRef"];function c(){return c=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},c.apply(this,arguments)}function u(e,t){if(null==e)return{};var r,n,s=function(e,t){if(null==e)return{};var r,n,s={},o=Object.keys(e);for(n=0;n<o.length;n++)r=o[n],t.indexOf(r)>=0||(s[r]=e[r]);return s}(e,t);if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(e);for(n=0;n<o.length;n++)r=o[n],t.indexOf(r)>=0||Object.prototype.propertyIsEnumerable.call(e,r)&&(s[r]=e[r])}return s}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 s=h(this).constructor;r=Reflect.construct(n,arguments,s)}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:o().node,tag:i.iC,innerRef:o().oneOfType([o().object,o().func,o().string]),className:o().string,cssModule:o().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,s,o=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=o.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,s=e.tag,o=void 0===s?"form":s,a=e.innerRef,f=u(e,l),p=(0,i.mx)(t,r);return n.createElement(o,c({},f,{ref:a,className:p}))}}])&&f(t.prototype,r),s&&f(t,s),Object.defineProperty(t,"prototype",{writable:!1}),a}(n.Component);b.propTypes=y;const g=b},1781:(e,t,r)=>{r.d(t,{Z:()=>v});var n=r(7313),s=r(5192),o=r.n(s),i=r(6123),a=r.n(i),l=r(986);function c(e){return c="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},c(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,s=function(e,t){if(null==e)return{};var r,n,s={},o=Object.keys(e);for(n=0;n<o.length;n++)r=o[n],t.indexOf(r)>=0||(s[r]=e[r]);return s}(e,t);if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(e);for(n=0;n<o.length;n++)r=o[n],t.indexOf(r)>=0||Object.prototype.propertyIsEnumerable.call(e,r)&&(s[r]=e[r])}return s}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 s=b(this).constructor;r=Reflect.construct(n,arguments,s)}else r=n.apply(this,arguments);return function(e,t){if(t&&("object"===c(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:o().node,type:o().string,size:o().oneOfType([o().number,o().string]),bsSize:o().string,valid:o().bool,invalid:o().bool,tag:l.iC,innerRef:o().oneOfType([o().object,o().func,o().string]),plaintext:o().bool,addon:o().bool,className:o().string,cssModule:o().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,s,o=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=o.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,s=e.type,o=void 0===s?"text":s,i=e.bsSize,c=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(o)>-1,v="select"===o,x="range"===o,w=m||(v||"textarea"===o?o:"input"),Z="form-control";y?(Z="".concat(Z,"-plaintext"),w=m||"input"):x?Z="form-range":v?Z="form-select":j&&(Z=h?null:"form-check-input"),g.size&&/\D/g.test(g.size)&&((0,l.O4)('Please use the prop "bsSize" instead of the "size" to bootstrap\'s input sizing.'),i=g.size,delete g.size);var O=(0,l.mx)(a()(t,d&&"is-invalid",c&&"is-valid",!!i&&(v?"form-select-".concat(i):"form-control-".concat(i)),Z),r);return("input"===w||m&&"function"===typeof m)&&(g.type="switch"===o?"checkbox":o),g.children&&!y&&"select"!==o&&"string"===typeof w&&"select"!==w&&((0,l.O4)('Input with a type of "'.concat(o,'" cannot have children. Please use "value"/"defaultValue" instead.')),delete g.children),n.createElement(w,f({},g,{ref:b,className:O,"aria-invalid":d}))}}])&&d(t.prototype,r),s&&d(t,s),Object.defineProperty(t,"prototype",{writable:!1}),i}(n.Component);j.propTypes=g;const v=j}}]);
|