dsql-admin/dsql-app/.local_dist/server/chunks/4312.js

1 line
6.1 KiB
JavaScript
Raw Normal View History

2024-12-08 19:56:57 +00:00
"use strict";exports.id=4312,exports.ids=[4312],exports.modules={84312:(e,s,t)=>{t.d(s,{A:()=>u});var l=t(8732),a=t(82015),n=t.n(a),i=t(63715),r=t(55158),d=t(32415),c=t(58403),o=t(51548);function u({targetUser:e,user:s,setTargetUser:a}){let u=t(49436);if(!e)return null;let[m,h]=n().useState(!0),[x,p]=n().useState([]),[b,f]=n().useState(!1),[g,j]=n().useState(e?e.user_priviledge?.split("|"):[]),[v,w]=n().useState(e?.database_access?e.database_access.split("|"):[]),[_,N]=n().useState(e?e.database_access?.split("|")[0]:null),[y,A]=n().useState([]),[k,S]=n().useState([]);return(0,l.jsxs)(r.Ay,{title:"target-user-popup",closePopupDispatch:()=>{a(null)},children:[m&&(0,l.jsx)(d.A,{position:"relative"}),!m&&e&&(0,l.jsx)(n().Fragment,{children:(0,l.jsxs)("div",{className:"flex-col w-full items-start p-4",children:[(0,l.jsxs)("h4",{className:"m-0",children:["Edit ",e.first_name," ",e.last_name,"'s Access"]}),(0,l.jsx)("hr",{}),(0,l.jsxs)("form",{className:"flex flex-col items-start w-full",onSubmit:s=>{s.preventDefault(),h(!0),(0,i.A)("/api/updateAdminUserAccess",{method:"post",body:{userObject:e,user_priviledge:g.join("|"),database_access:v?.join("|"),db_tables:v&&v[0]?k.join("|"):"",inv_user_id:e.invited_user_id}},!0).then(e=>{window.location.reload(),setTimeout(()=>{h(!1)},500)})},children:[(0,l.jsx)("h3",{className:"m-0 text-lg font-semibold mb-1 text-slate-600",children:"User Priviledges"}),(0,l.jsx)(c.A,{checkBoxValues:u.map(e=>({title:e,name:e,default:!!g.includes(e),onChangeHandler:s=>{g.includes(e)?j([...g.filter(s=>s!=e)]):j(s=>[...s,e])}})),smallText:!0,flexRow:!0}),(0,l.jsx)("hr",{className:"my-6"}),(0,l.jsx)("h3",{className:"m-0 text-lg font-semibold mb-2 text-slate-600",children:"Databases Access"}),(0,l.jsx)("span",{className:"button outlined gray px-4 py-1 -mt-1 mb-1.5",onClick:e=>{b?(x.forEach(e=>{setTimeout(()=>{let s=document.getElementById(e.db_slug);s?.checked&&s.click()},200)}),f(!1)):(x.forEach(e=>{setTimeout(()=>{let s=document.getElementById(e.db_slug);s.checked||s.click()},200)}),f(!0))},children:b?"Deselect All":"Select All"}),(0,l.jsx)(c.A,{checkBoxValues:x.map(e=>({title:e.db_name,name:e.db_slug,onChangeHandler:s=>{v.includes(e.db_slug)?w([...v.filter(s=>s!=e.db_slug)]):w(s=>[...s,e.db_slug]),v.length===x.length?f(!0):f(!1)},default:!!v.includes(e.db_slug)})),smallText:!0,flexRow:!0}),v&&v[0]&&(0,l.jsxs)(n().Fragment,{children:[(0,l.jsx)("hr",{className:"my-6"}),(0,l.jsx)("h3",{className:"m-0 text-lg font-semibold mb-2 text-slate-600",children:"Database Tables"}),(0,l.jsx)(o.A,{required:!0,selectOptions:x.filter(e=>v.includes(e.db_slug)).map(e=>({title:e.db_name,payload:e.db_slug})),name:"databases",onChangeHandler:e=>{N(e.target.value)}}),(0,l.jsx)("div",{className:"h-2"}),y&&y[0]&&(0,l.jsx)(c.A,{checkBoxValues:y.map(e=>({title:e.table_name,name:e.table_slug,onChangeHandler:s=>{k.includes(`${_}-${e.table_slug}`)?S([...k.filter(s=>s!=`${_}-${e.table_slug}`)]):S(s=>[...s,`${_}-${e.table_slug}`])},default:!!k.includes(`${_}-${e.table_slug}`)})),smallText:!0,flexRow:!0})]}),(0,l.jsx)("button",{className:"mt-4 w-full",children:"Update User Access"})]})]})})]})}},58403:(e,s,t)=>{t.d(s,{A:()=>a});var l=t(8732);function a({name:e,checkBoxValues:s,setAlert:t,labelColor:a,flexRow:n,baseText:i,smallText:r,className:d}){return(0,l.jsx)("div",{className:"flex items-start gap-x-4"+(n?" flex-row flex-wrap gap-y-2 ":" flex-col gap-y-4 ")+(d||""),children:s.map((s,n)=>{let{payload:d,title:c,onChangeHandler:o,fixed:u,jsx:m}=s,h=s.name?`${e}-${s.name}`:d?e+"-"+d:e;return(0,l.jsxs)("div",{className:"flex items-center"+(s.default&&u?" pointer-events-none":"")+(r?" gap-1 ":" gap-2 ")+(s?.className?s.className:""),children:[(0,l.jsx)("input",{className:"m-0"+(r?" w-4 h-4":" w-5 h-5"),type:"checkbox",defaultChecked:!!s.default,name:h,id:h,onChange:e=>{t&&t(null),o&&o(e,s)},value:d,style:{minWidth:"20px"},...s.props}),m||(0,l.jsx)("label",{htmlFor:h,className:"m-0 "+(a||"text-slate-800 dark:text-white/80")+(i||r?" text-base":" text-lg"),children:c})]},n+1)})})}t(82015)},51548:(e,s,t)=>{t.d(s,{A:()=>n});var l=t(8732),a=t(585