dsql-admin/dsql-app/.local_dist/server/pages/admin/[user_id]/api-keys.js

1 line
21 KiB
JavaScript
Raw Normal View History

2025-02-19 19:38:56 +00:00
"use strict";(()=>{var e={};e.id=9419,e.ids=[9419],e.modules={30671:(e,t)=>{Object.defineProperty(t,"M",{enumerable:!0,get:function(){return function e(t,a){return a in t?t[a]:"then"in t&&"function"==typeof t.then?t.then(t=>e(t,a)):"function"==typeof t&&"default"===a?t:void 0}}})},88214:(e,t,a)=>{a.a(e,async(e,s)=>{try{a.r(t),a.d(t,{config:()=>m,default:()=>p,getServerSideProps:()=>y,getStaticPaths:()=>h,getStaticProps:()=>u,reportWebVitals:()=>x,routeModule:()=>S,unstable_getServerProps:()=>_,unstable_getServerSideProps:()=>v,unstable_getStaticParams:()=>g,unstable_getStaticPaths:()=>f,unstable_getStaticProps:()=>A});var r=a(63865),l=a(9455),i=a(30671),n=a(5583),c=a(53881),o=a(11045),d=e([o]);o=(d.then?(await d)():d)[0];let p=(0,i.M)(o,"default"),u=(0,i.M)(o,"getStaticProps"),h=(0,i.M)(o,"getStaticPaths"),y=(0,i.M)(o,"getServerSideProps"),m=(0,i.M)(o,"config"),x=(0,i.M)(o,"reportWebVitals"),A=(0,i.M)(o,"unstable_getStaticProps"),f=(0,i.M)(o,"unstable_getStaticPaths"),g=(0,i.M)(o,"unstable_getStaticParams"),_=(0,i.M)(o,"unstable_getServerProps"),v=(0,i.M)(o,"unstable_getServerSideProps"),S=new r.PagesRouteModule({definition:{kind:l.A.PAGES,page:"/admin/[user_id]/api-keys",pathname:"/admin/[user_id]/api-keys",bundlePath:"",filename:""},components:{App:c.default,Document:n.default},userland:o});s()}catch(e){s(e)}})},48963:(e,t,a)=>{a.d(t,{A:()=>p});var s,r=a(8732),l=a(82015),i=a.n(l),n=a(24872),c=a(46169),o=a(91140),d=a(16757);function p(){async function e(e){return await (0,n.A)({tableName:"api_keys",columnName:"slug",value:e})}let[t,a]=i().useState(!1),[l,p]=i().useState(null);return(0,r.jsxs)(o.Ay,{title:"add-new-api-key-popup",children:[t&&(0,r.jsx)(d.A,{}),(0,r.jsx)("h4",{className:"m-0",children:"Add New Api Key"}),(0,r.jsxs)("form",{className:"w-full flex flex-col items-stretch gap-2",onSubmit:e=>{e.preventDefault(),a(!0);let t=e.target,s={api_key_name:t.api_key_name.value,api_key_slug:t.api_key_slug.value,api_key_scope:t.api_key_scope.value,target_database:t.target_database?.value||void 0,target_table:t.target_table?.value||void 0};(0,c.A)("/api/addApiKey",{method:"post",body:s},!0).then(e=>{e.success?window.location.reload():setTimeout(()=>{a(!1)},2e3)})},children:[l&&(0,r.jsx)("div",{children:(0,r.jsx)("span",{children:l})}),(0,r.jsxs)("div",{className:"flex flex-col items-start gap-0.5 w-full",children:[(0,r.jsx)("label",{htmlFor:"api_key_name",children:"Api Key Name"}),(0,r.jsx)("input",{type:"text",name:"api_key_name",id:"api_key_name",placeholder:"Api Key Name",onInput:e=>{let t=e.target;t&&(t.closest("form").api_key_slug.value=t.value.toLowerCase().replace(/ /g,"_").replace(/[^a-zA-Z0-9-_]/g,""))},required:!0})]}),(0,r.jsxs)("div",{className:"flex flex-col items-start gap-0.5 w-full",children:[(0,r.jsx)("label",{htmlFor:"api_key_slug",children:"Api Key Slug"}),(0,r.jsx)("input",{type:"text",name:"api_key_slug",id:"api_key_slug",placeholder:"Api Key Slug",onInput:t=>{let a=t.target;a?.value.match(/./)?(a?.classList.remove("warning"),p(null)):a?.classList.add("warning"),window.clearTimeout(s),s=setTimeout(()=>{e(a.value).then(e=>{e.result?(a?.classList.add("warning"),p("Duplicate Table Name")):(a?.classList.remove("warning"),p(null))})},300)},required:!0})]}),(0,r.jsxs)("div",{className:"flex flex-col items-start gap-0.5 w-full",children:[(0,r.jsxs)("div",{className:"",children:[(0,r.jsx)("label",{htmlFor:"api_key_scope",children:"Api Scope"}),(0,r.jsxs)("div",{className:"dropdown-wrapper reversed",children:[(0,r.jsx)("span",{className:"px-2 py-1 bg-slate-100 rounded-full text-xs font-semibold",children:"Info"}),(0,r.jsx)("div",{className:"dropdown always left-aligned -ml-10 -mb-2",style:{minWidth:"300px"},children:(0,r.jsxs)("div",{className:"flex-col items-start gap-2 text-sm leading-snug",children:[(0,r.jsx)("span",{children:"Scope is the range of access the API Key can have"}),(0,r.jsxs)("ul",{className:"ml-0 pl-4 flex flex-col gap-2",children:[(0,r.jsx)("li",{children:(0,r.jsxs)("span",{children:[(0,r.jsx)("b",{children:"Read Only:"})," Can only read from databases"]})}),(0,r.jsx)("li",{children:(0,r.jsx