2025-01-13 08:00:21 +00:00
|
|
|
"use strict";exports.id=3474,exports.ids=[3474],exports.modules={30671:(e,a)=>{Object.defineProperty(a,"M",{enumerable:!0,get:function(){return function e(a,t){return t in a?a[t]:"then"in a&&"function"==typeof a.then?a.then(a=>e(a,t)):"function"==typeof a&&"default"===t?a:void 0}}})},92090:(e,a,t)=>{t.a(e,async(e,r)=>{try{t.d(a,{A:()=>h});var l=t(8732),s=t(82015),n=t.n(s),i=t(53926),d=t(59023),o=t(46169),c=t(16757),u=t(20136),m=t(50264),p=e([m]);function h(){let{singleUser:e,database:a,user:t}=n().useContext(m.SingleDbUserContext),r=Object.keys(e).filter(e=>!e.match(/^id$|^date_|^user_id$|^social_|^disk_usage|user_type/)),[s,p]=n().useState(!1),[h,y]=n().useState(e.image);return(0,l.jsxs)(n().Fragment,{children:[(0,l.jsxs)("div",{className:"flex-col items-start gap-0 w-full",children:[(0,l.jsxs)("div",{className:"w-full justify-between flex-wrap",children:[(0,l.jsxs)("div",{children:[(0,l.jsx)(d.A,{}),h&&"string"==typeof h&&(0,l.jsx)("img",{src:h,alt:"",className:"avatar large outlined"}),(0,l.jsxs)("h1",{className:"text-3xl m-0",children:[e.first_name," ",e.last_name]})]}),(0,l.jsxs)("div",{children:[(0,l.jsx)("a",{href:`/admin/${t?.id}/databases/${a.db_slug}/users/${e.id}/change-password`,className:"button outlined gray",children:"Change Password"}),(0,l.jsx)("button",{className:"bg-red-500",onClick:r=>{p(!0),window.confirm("Delete this user?")&&(0,o.A)("/api/deleteDbUser",{method:"post",body:{userId:e.id,dbFullName:a.db_full_name}},!0).then(e=>{e.success&&(window.location.pathname=`/admin/${t?.id}/databases/${a.db_slug}/users`)})},children:"Delete User"})]})]}),(0,l.jsx)(i.A,{user:t})]}),(0,l.jsxs)("section",{className:"paper",children:[s&&(0,l.jsx)(c.A,{}),(0,l.jsx)("div",{className:"w-full flex-col items-stretch",children:(0,l.jsxs)("form",{className:"flex flex-col items-stretch gap-4",onSubmit:t=>{t.preventDefault(),p(!0);let r=t.target,l=Array.from(r),s={};l.forEach(e=>{!e?.nodeName?.match(/button/i)&&e?.name&&e?.value?.match(/./)&&(e?.name?.match(/username|email/)||(s[e.name]=e.value))});let n={dbFullName:a.db_full_name,payload:{...s,id:e.id}};(0,o.A)("/api/updateDbUser",{method:"post",body:n},!0).then(t=>{"object"==typeof h&&h?.imageBase64?(h.imageName=`${a.db_slug}-user-${e.id}`,h.mimeType="jpeg",delete h.imageBase64Full,(0,o.A)("/api/addUserMedia",{method:"post",body:{media:[h],folder:a.db_slug.replace(/_/g,"-"),type:"image"}},!0).then(t=>{t&&t.mediaData&&t.mediaData[0]?.media_url?(0,o.A)("/api/updateDbUser",{method:"post",body:{dbFullName:a.db_full_name,payload:{id:e.id,image:t.mediaData[0].media_url,image_thumbnail:t.mediaData[0].media_thumbnail_url}}},!0).then(e=>{e.success&&window.location.reload(),setTimeout(()=>{p(!1)},500)}):window.location.reload()})):window.location.reload()})},children:[r.map((a,t)=>a?.match(/password|^database|email|username/)?(0,l.jsxs)("div",{className:"flex-col items-start w-full gap-1",children:[(0,l.jsx)("label",{htmlFor:a,children:a}),(0,l.jsx)("input",{type:"text",name:a,id:a,value:e[a],placeholder:a,className:"opacity-40 pointer-events-none",onChange:e=>{e.preventDefault()}},t+1)]},t+1):a?.match(/more_user_data/)?(0,l.jsxs)("div",{className:"flex-col items-start w-full gap-1",children:[(0,l.jsx)("label",{htmlFor:a,children:a}),(0,l.jsx)("textarea",{name:a,id:a,defaultValue:e[a]?e[a]:void 0,placeholder:a,rows:6},t+1)]},t+1):(0,l.jsxs)("div",{className:"flex-col items-start w-full gap-1",children:[(0,l.jsx)("label",{htmlFor:a,children:a}),(0,l.jsx)("input",{type:"text",name:a,id:a,defaultValue:e[a]?e[a]:void 0,placeholder:a},t+1)]},t+1)),(0,l.jsxs)("div",{className:"border border-slate-300 dark:border-slate-600 border-solid bg-slate-100 dark:bg-slate-700 rounded p-6 flex-col items-start w-full",children:[(0,l.jsx)("h3",{className:"m-0 text-lg font-semibold mb-1 text-slate-600",children:"Update Image"}),(0,l.jsx)(u.A,{userImage:h,setUserImage:y})]}),(0,l.jsx)("button",{children:"Update User"})]})})]})]})}m=(p.then?(await p)():p)[0],r()}catch(e){r(e)}})},20136:(e,a,t)=>{t.d(a,{A:()=>i});var r=t(8732),l=t(82015),s=t.n(l),n=t(65842);function i({user:e,userImage:a,setUserImage:t,d
|
2025-01-14 06:10:36 +00:00
|
|
|
${d}`)}catch(e){console.log("Server Error Reporting Error:",e.message)}}},52854:(e,a,t)=>{t.d(a,{A:()=>c});var r=t(71205);let l=/^id$|^uuid$|^date_created$|^date_created_code$|^date_created_timestamp$|^date_updated$|^date_updated_code$|^date_updated_timestamp$/;async function s({unparsedResults:e,tableSchema:a}){let t=[];try{for(let s=0;s<e.length;s++){let n=e[s],i=Object.keys(n);for(let e=0;e<i.length;e++){let t=i[e],s=a?.fields[e];if(t?.match(l))continue;let d=n[t];("number"==typeof d||d)&&s?.encrypted&&d?.match(/./)&&(n[t]=(0,r.A)({encryptedString:d}))}t.push(n)}return t}catch(a){return console.log("ERROR in parseDbResults Function =>",a.message),e}}var n=t(77047),i=t(71934),d=t(43651),o=t(16175);async function c({queryString:e,queryValuesArray:a,database:t,tableSchema:r,useLocal:l}){let c;let u=!!l||!!t?.match(/^datasquirel$/),m=l?o.A:u?i.A:d.A;try{c=e&&a&&Array.isArray(a)&&a[0]?u?await m(e,a):await m({paradigm:"Full Access",queryString:e,queryValues:a}):u?await m(e):await m({paradigm:"Full Access",queryString:e})}catch(e){console.log(`varDatabaseDbHandler Error: ${e.message}`),(0,n.A)({component:"varDatabaseDbHandler/lines-29-32",message:e.message})}if(c&&r)try{let e=c;return await s({unparsedResults:e,tableSchema:r})}catch(e){return console.log("\x1b[31mvarDatabaseDbHandler ERROR\x1b[0m =>",t,e),(0,n.A)({component:"varDatabaseDbHandler/lines-52-53",message:e.message}),null}else if(c)return c;else return null}},43651:(e,a,t)=>{async function r(e,a,t){try{if("string"==typeof a){let r=await e.query(l(a),t);return JSON.parse(JSON.stringify(r))}if("object"!=typeof a)return null;{let t=[];for(let r=0;r<a.length;r++)try{let s=a[r],n=await e.query(l(s.query),s.values);t.push(JSON.parse(JSON.stringify(n)))}catch(e){t.push(null)}return t}}catch(e){return null}finally{e.end()}}function l(e){return e.replace(/\n/gm,"").replace(/ {2,}/g,"").trim()}async function s({paradigm:e,queryString:a,queryValues:t}){try{switch(e){case"Read Only":return await r(global.DSQL_READ_ONLY_DB_CONN,a,t);case"Full Access":case"FA":return await r(global.DSQL_FULL_ACCESS_DB_CONN,a,t);default:return null}}catch(e){return console.log(`DSQL_USER_DB_HANDLER Error: ${e.message}`),null}}t.d(a,{A:()=>s})},16175:(e,a,t)=>{t.d(a,{A:()=>i});var r=t(9973),l=t.n(r),s=t(29021),n=t.n(s);async function i(...e){let a=l()({config:{host:process.env.DSQL_DB_HOST,user:process.env.DSQL_DB_USERNAME,password:process.env.DSQL_DB_PASSWORD,database:process.env.DSQL_DB_NAME,port:process.env.DSQL_DB_PORT?Number(process.env.DSQL_DB_PORT):void 0,charset:"utf8mb4",ssl:function(){let e=process.env.DSQL_SSL_DIR;if(!e?.match(/./))return;let a=`${e}/ca-cert.pem`;if(!n().existsSync(a)){console.log(`${a} does not exist`);return}return{ca:n().readFileSync(`${e}/ca-cert.pem`),rejectUnauthorized:!1}}()},onConnect:()=>{console.log("Connection Successful!")},onConnectError:e=>{console.log("Connection Error",e.message)},onError:e=>{console.log("Client Error",e.message)}});console.log("Querying ...");try{let t=await a.query(...e);return await a.end(),JSON.parse(JSON.stringify(t))}catch(e){return console.log("DB Error =>",e.message),{success:!1,error:e.message}}}},50264:(e,a,t)=>{t.a(e,async(e,r)=>{try{t.r(a),t.d(a,{SingleDbUserContext:()=>x,default:()=>f,getServerSideProps:()=>b});var l=t(8732),s=t(29021),n=t.n(s),i=t(82015),d=t.n(i),o=t(25562),c=t(92702),u=t(55880),m=t(22873),p=t(92090),h=t(71934),y=t(52854),g=e([u,p]);[u,p]=g.then?(await g)():g;let x=d().createContext({});function f({user:e,database:a,table:t,dbSchemaData:r,singleUser:s,query:n,confirmedDelegetedUser:i}){let d=`${s.first_name} ${s.last_name} Users | Datasquirel"`,c=(0,l.jsxs)(l.Fragment,{children:[(0,l.jsx)("title",{children:d}),(0,l.jsx)("meta",{name:"description",content:"Welcome to your data app"})]});return(0,l.jsx)(o.A,{head:c,user:e,extraHeaderContent:(0,l.jsx)(u.A,{database:a,query:n,confirmedDelegetedUser:i,user:e}),children:(0,l.jsx)(x.Provider,{value:{user:e,database:a,table:t,dbSchemaData:r,singleUser:s,query:n,confirmedDelegetedUser:i},children:(0,l.jsx)(p.A,{})})})}async function b({req:e,res:a,query:t}){let r=
|