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

1 line
15 KiB
JavaScript
Raw Normal View History

2024-12-09 09:39:09 +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}}})},30284:(e,t,a)=>{a.r(t),a.d(t,{config:()=>I,default:()=>F,getServerSideProps:()=>O,getStaticPaths:()=>z,getStaticProps:()=>D,reportWebVitals:()=>G,routeModule:()=>W,unstable_getServerProps:()=>$,unstable_getServerSideProps:()=>V,unstable_getStaticParams:()=>L,unstable_getStaticPaths:()=>R,unstable_getStaticProps:()=>H});var s,l={};a.r(l),a.d(l,{ApiKeysContext:()=>q,default:()=>T,getServerSideProps:()=>E});var i=a(63865),r=a(9455),n=a(30671),c=a(49407),d=a(89600),p=a(8732),o=a(82015),u=a.n(o),x=a(95222),h=a(20048),m=a.n(h),y=a(58548),f=a(55158),g=a(24671),j=a(63715),A=a(32415),v=a(62506);function b({apiKeyObject:e,setTargetApiKey:t}){let[a,s]=u().useState(!1);return(0,p.jsxs)("div",{className:"card no-hover justify-between items-center"+(e.scope.match(/fullAccess/)?" green":""),onClick:a=>{a.target?.closest("button")||(t(e),(0,f.PB)("target-media-popup"))},children:[a&&(0,p.jsx)(A.A,{width:"20px"}),(0,p.jsxs)("div",{className:"text-sm flex-wrap",children:[(0,p.jsx)("div",{children:e.scope.match(/readOnly/)?(0,p.jsx)("span",{className:"notification"}):e.scope.match(/fullAccess/)?(0,p.jsx)("span",{className:"notification success"}):"No Scope"}),(0,p.jsx)("span",{className:"title text-xl",style:{fontSize:"16px"},children:e.name}),(0,p.jsxs)("span",{className:"text-slate-400 ",children:["Created: ",e.date_created.substring(0,24)]})]}),(0,p.jsxs)(v.A,{children:[(0,p.jsx)("button",{className:"outlined light-gray small-text",onClick:t=>{alert(e.apiKeyPayload)},children:"Reveal Api Key"}),(0,p.jsx)("button",{className:"outlined light-gray small-text",onClick:t=>{navigator.clipboard.writeText(e.apiKeyPayload).then(()=>{alert("Api Key Copied To Clipboard")})},children:"Copy Api Key"}),(0,p.jsx)("button",{className:"outlined light-gray small-text"+(a?" pointer-events-none opacity-40":""),onClick:t=>{s(!0),window.confirm("Delete this Api Key?")?(0,j.A)("/api/deleteApiKey",{method:"post",body:e},!0).then(e=>{}).finally(()=>{window.location.reload()}):s(!1)},children:"Delete Api Key"})]})]})}function k({user:e,apiKeys:t,setTargetApiKey:a}){return(0,p.jsx)(u().Fragment,{children:(0,p.jsxs)("section",{className:"p-0 items-start gap-4 overflow-visible bg-transparent border-transparent",children:[(0,p.jsx)("div",{className:"w-full flex-col items-stretch gap-4",children:t&&t[0]&&t.map((e,t)=>(0,p.jsx)(b,{apiKeyObject:e,setTargetApiKey:a},t))}),!t||!t[0]&&(0,p.jsxs)("div",{className:"button outlined gray dashed w-full p-10 flex-col",onClick:e=>{(0,f.PB)("add-new-api-key-popup")},children:[(0,p.jsx)("span",{className:"text-slate-400",children:"No Api Keys Added."}),(0,p.jsx)("span",{className:"",children:"Add Api Key"})]})]})})}function _(e){let{user:t,apiKeys:a,setApiKeys:s,setTargetApiKey:l}=u().useContext(q);return(0,p.jsxs)(u().Fragment,{children:[(0,p.jsxs)("div",{className:"flex-col items-start gap-0 w-full",children:[(0,p.jsxs)("div",{className:"w-full justify-between flex-wrap",children:[(0,p.jsx)("h1",{className:"text-3xl m-0",children:"Api Keys"}),(0,p.jsxs)("button",{className:"flex items-center gap-2",onClick:e=>{(0,f.PB)("add-new-api-key-popup")},children:[(0,p.jsx)("span",{className:"symbol",children:"+"}),(0,p.jsx)("span",{children:"Add New Api Key"})]})]}),(0,p.jsx)(y.A,{user:t})]}),t?.verification_status?.toString().match(/1/)?(0,p.jsx)(k,{apiKeys:a,setTargetApiKey:l,user:t}):(0,p.jsx)(g.A,{})]})}function w({targetApiKey:e}){let[t,a]=u().useState(!1);return(0,p.jsxs)(f.Ay,{title:"target-api-key-preview-popup",noContainer:!0,fullPage:!0,children:[t&&(0,p.jsx)(A.A,{}),e&&(0,p.jsx)(u().Fragment,{children:(0,p.jsx)("span",{children:"Target Api Key"})})]})}var N=a(27462);function S({targetApiKey:e}){async function t(e){return await (0,N.A)({tableName:"api_keys",columnName:"slug",value:e})}let[a,l]=u().useState(!1),[i,r]=u().useState(null);return(0,p.jsxs