dsql-admin/dsql-app/.local_dist/server/pages/admin/[user_id]/settings.js
Benjamin Toby 3ffd2d6777 Updates
2024-12-05 08:03:33 +01:00

1 line
9.3 KiB
JavaScript

"use strict";(()=>{var e={};e.id=189,e.ids=[189,636],e.modules={19881:(e,t,r)=>{r.r(t),r.d(t,{config:()=>U,default:()=>E,getServerSideProps:()=>D,getStaticPaths:()=>R,getStaticProps:()=>A,reportWebVitals:()=>F,routeModule:()=>k,unstable_getServerProps:()=>H,unstable_getServerSideProps:()=>O,unstable_getStaticParams:()=>W,unstable_getStaticPaths:()=>L,unstable_getStaticProps:()=>I});var s={};r.r(s),r.d(s,{SettingsContext:()=>_,default:()=>M,getServerSideProps:()=>C});var i=r(63865),a=r(9455),l=r(30671),u=r(49407),o=r(68268),n=r(8732),c=r(82015),m=r.n(c),d=r(95222),p=r(20048),x=r.n(p);r(26295);var g=r(58548),h=r(70045),f=r(79100),q=r(55158),S=r(62506);function j({user:e,image:t,setImage:r}){let s=m().useRef();return(0,n.jsxs)("div",{className:"paper w-full items-center",children:[(0,n.jsx)("h2",{className:"m-0 text-xl",children:"User Image"}),(0,n.jsx)("div",{className:"bg-white rounded-full overflow-hidden w-24 h-24",children:(0,n.jsx)("img",{src:t?"string"==typeof t?t:t.imageBase64Full:"/images/database-placeholder.png",alt:"User Image",width:100,className:"w-full h-full object-cover",ref:s,"data-imagepreview":"image"})}),(0,n.jsxs)("div",{className:"w-full flex-col",id:"upload-user-image-options",children:[(0,n.jsxs)(S.A,{column:!0,className:"w-full",children:[(0,n.jsx)("button",{className:"outlined gray w-full whitespace-normal",onClick:e=>{(0,q.PB)("user-media-popup")},children:"Choose image From your Uploads"}),(0,n.jsx)("button",{className:"secondary w-full whitespace-normal",onClick:e=>{let t=e.target;t.closest("#upload-user-image-options")?.querySelector("input")?.click()},children:(0,n.jsx)("span",{children:"Choose image From your Computer"})})]}),(0,n.jsx)("input",{type:"file",accept:".png,.jpg,.jpeg,.webp",placeholder:"Choose Image",className:"hidden",onChange:async e=>{let t=e.target,s=t?.files?.[0];s&&r(await (0,f.A)({imageInputFile:s,maxWidth:400}))}})]})]})}function w(e){let{user:t,image:r,setImage:s,activeUser:i}=m().useContext(_),[a,l]=m().useState(!1);return(0,n.jsxs)(m().Fragment,{children:[(0,n.jsxs)("div",{className:"flex-col items-start gap-0 w-full",children:[(0,n.jsxs)("div",{className:"w-full flex items-center justify-between",children:[(0,n.jsx)("h1",{className:"text-3xl m-0",children:"Settings"}),(0,n.jsx)("div",{children:!t?.social_login&&(0,n.jsx)("a",{href:"/send-password-reset-link",className:"button outlined",children:"Reset Password"})})]}),(0,n.jsx)(g.A,{user:t})]}),(0,n.jsx)("section",{className:"p-0",children:(0,n.jsxs)("div",{className:"w-full grid grid-cols-1 xl:grid-cols-2 gap-8 items-stretch",children:[(0,n.jsxs)("div",{className:"paper w-full",children:[(0,n.jsx)("h2",{className:"m-0 text-xl",children:"Account Information"}),(0,n.jsxs)("div",{className:"flex flex-row w-full",children:[(0,n.jsx)("span",{children:"USER ID"}),(0,n.jsx)("b",{className:"info w-auto",children:t.id})]}),(0,n.jsx)(h.A,{user:i,image:r})]}),(0,n.jsx)("div",{className:"items-stretch",children:(0,n.jsx)(j,{image:r,setImage:s})})]})}),!1]})}r(32415);var v=r(42105),b=r(41658),y=r.n(b),N=r(67216),P=r.n(N);let _=m().createContext({});function M({user:e,databases:t,activeUser:r}){let s=(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)("title",{children:"User Dashboard | Datasquirel"}),(0,n.jsx)("meta",{name:"description",content:"Welcome to your data app"})]}),[i,a]=m().useState(r.image);return(0,n.jsx)(d.A,{head:s,user:e,children:(0,n.jsxs)(_.Provider,{value:{user:e,image:i,setImage:a,activeUser:r},children:[(0,n.jsx)(w,{}),(0,n.jsx)(v.A,{setDbImage:a})]})})}async function C({req:e,res:t,query:r}){let s=await x()(e,t);if(!s?.logged_in_status)return{redirect:{destination:"/login",permanent:!1}};let i=await y()(`SELECT SCHEMA_NAME AS dbFullName FROM INFORMATION_SCHEMA.SCHEMATA WHERE SCHEMA_NAME LIKE 'user_${s.id}%'`),a=await P()(`SELECT first_name,last_name,username,email,image,image_thumbnail FROM users WHERE id='${s.id}'`);return{props:{user:s,databases:i,activeUser:a[0]}}}let E=(0,l.M)(s,"default"),A=(0,l.M)(s,"getStaticProps"),R=(0,l.M)(s,"getStaticPaths"),D=(0,l.M)(s,"getServerSideProps"),U=(0,l.M)(s,"config"),F=(0,l.M)(s,"reportWebVitals"),I=(0,l.M)(s,"unstable_getStaticProps"),L=(0,l.M)(s,"unstable_getStaticPaths"),W=(0,l.M)(s,"unstable_getStaticParams"),H=(0,l.M)(s,"unstable_getServerProps"),O=(0,l.M)(s,"unstable_getServerSideProps"),k=new i.PagesRouteModule({definition:{kind:a.A.PAGES,page:"/admin/[user_id]/settings",pathname:"/admin/[user_id]/settings",bundlePath:"",filename:""},components:{App:o.default,Document:u.default},userland:s})},42105:(e,t,r)=>{r.d(t,{A:()=>o});var s=r(8732),i=r(82015),a=r.n(i);r(63715);var l=r(55158),u=r(32415);function o({setDbImage:e}){let[t,r]=a().useState(!0),[i,o]=a().useState(null);return(0,s.jsxs)(l.Ay,{title:"user-media-popup",children:[t&&(0,s.jsx)(u.A,{width:"20px"}),(0,s.jsx)("h4",{className:"m-0 text-lg",children:"Your Uploaded Images"}),(0,s.jsx)("div",{className:"grid grid-cols-2",children:i&&i[0]&&i.filter(e=>"image"==e.media_type).map((t,r)=>(0,s.jsx)("div",{className:"w-full h-44 cursor-pointer hover:opacity-70",onClick:r=>{e(t.media_thumbnail_url||null),(0,l.fs)()},children:(0,s.jsx)("img",{src:t.media_thumbnail_url,alt:"User Media",className:"w-full h-full object-contain"})},r+1))})]})}r(64417)},79100:(e,t,r)=>{r.d(t,{A:()=>s});async function s({imageInputFile:e,maxWidth:t}){let r,s,i=document.querySelector("[data-imagepreview='image']"),a=e.name.replace(/\..*/,""),l=document.createElement("canvas"),u=e.type,o=t||null,n=URL.createObjectURL(e),c=new Image;return c.src=n,r=await new Promise((e,t)=>{c.onerror=function(){URL.revokeObjectURL(this.src),console.log("Cannot load image")},c.onload=function(){if(URL.revokeObjectURL(this.src),o){let e=o/c.naturalWidth;l.width=c.naturalWidth<o?c.naturalWidth:o,l.height=c.naturalWidth<o?c.naturalHeight:c.naturalHeight*e}else l.width=c.naturalWidth,l.height=c.naturalHeight;let t=l.getContext("2d");t?.drawImage(c,0,0,l.width,l.height);let r=l.toDataURL(u,.95);i&&document.querySelectorAll("[data-imagepreview='image']").forEach(e=>{e.src=r}),e(r)}}),s=await new Promise((e,t)=>{l.toBlob(t=>{e(t?.size)},u,.95)}),{imageBase64:r.replace(/.*?base64,/,""),imageBase64Full:r,imageName:a,imageSize:s}}},41658:(e,t,r)=>{let s=r(29021),i=r(22373),a=r(13608);e.exports=async function(e){let t;"production".match(/dev/)&&s.appendFileSync("./.tmp/sqlQuery.sql",e+"\n"+Date()+"\n\n\n","utf8");try{t=await a(e)}catch(e){i({component:"noDatabaseDbHandler",message:e.message}),console.log("ERROR in noDatabaseDbHandler =>",e.message)}return t||null}},13608:(e,t,r)=>{let s=r(9973),i=r(31976),a=s({config:{host:process.env.DSQL_DB_HOST,user:process.env.DSQL_DB_USERNAME,password:process.env.DSQL_DB_PASSWORD,charset:"utf8mb4",ssl:i()}});e.exports=function(...e){try{return new Promise((t,r)=>{a.query(...e).then(e=>{a.end(),t(JSON.parse(JSON.stringify(e)))}).catch(e=>{a.end(),t({error:e.message,sql:e.sql})})})}catch(e){return{success:!1,error:e.message}}}},66099:e=>{e.exports=require("@mui/system")},37616:e=>{e.exports=require("@mui/system/DefaultPropsProvider")},24509:e=>{e.exports=require("@mui/system/InitColorSchemeScript")},84781:e=>{e.exports=require("@mui/system/colorManipulator")},18215:e=>{e.exports=require("@mui/system/createStyled")},59989:e=>{e.exports=require("@mui/system/createTheme")},16670:e=>{e.exports=require("@mui/system/styleFunctionSx")},88698:e=>{e.exports=require("@mui/system/useThemeProps")},76831:e=>{e.exports=require("@mui/utils")},28578:e=>{e.exports=require("@mui/utils/capitalize")},14036:e=>{e.exports=require("@mui/utils/composeClasses")},31112:e=>{e.exports=require("@mui/utils/createChainedFunction")},21763:e=>{e.exports=require("@mui/utils/debounce")},7546:e=>{e.exports=require("@mui/utils/deepmerge")},5928:e=>{e.exports=require("@mui/utils/deprecatedPropType")},20985:e=>{e.exports=require("@mui/utils/formatMuiErrorMessage")},61119:e=>{e.exports=require("@mui/utils/generateUtilityClass")},81699:e=>{e.exports=require("@mui/utils/generateUtilityClasses")},29823:e=>{e.exports=require("@mui/utils/isMuiElement")},55402:e=>{e.exports=require("@mui/utils/ownerDocument")},46875:e=>{e.exports=require("@mui/utils/ownerWindow")},48080:e=>{e.exports=require("@mui/utils/requirePropFactory")},39597:e=>{e.exports=require("@mui/utils/setRef")},88190:e=>{e.exports=require("@mui/utils/unsupportedProp")},83889:e=>{e.exports=require("@mui/utils/useControlled")},21956:e=>{e.exports=require("@mui/utils/useEnhancedEffect")},4926:e=>{e.exports=require("@mui/utils/useEventCallback")},7376:e=>{e.exports=require("@mui/utils/useForkRef")},63310:e=>{e.exports=require("@mui/utils/useId")},10977:e=>{e.exports=require("@mui/utils/useIsFocusVisible")},74956:e=>{e.exports=require("clsx")},27825:e=>{e.exports=require("lodash")},40361:e=>{e.exports=require("next/dist/compiled/next-server/pages.runtime.prod.js")},27912:e=>{e.exports=require("next/head")},29825:e=>{e.exports=require("prop-types")},82015:e=>{e.exports=require("react")},22326:e=>{e.exports=require("react-dom")},1976:e=>{e.exports=require("react-dom/client")},8732:e=>{e.exports=require("react/jsx-runtime")},9973:e=>{e.exports=require("serverless-mysql")},79428:e=>{e.exports=require("buffer")},55511:e=>{e.exports=require("crypto")},29021:e=>{e.exports=require("fs")},81630:e=>{e.exports=require("http")},33873:e=>{e.exports=require("path")}};var t=require("../../../webpack-runtime.js");t.C(e);var r=e=>t(t.s=e),s=t.X(0,[9764,883,8268,7070,3737,4417,1223,2414,3247,1137],()=>r(19881));module.exports=s})();