14 lines
4.0 KiB
JavaScript
14 lines
4.0 KiB
JavaScript
"use strict";exports.id=3247,exports.ids=[3247],exports.modules={43001:(e,t,s)=>{s.d(t,{A:()=>b});var a=s(8732),r=s(82015),i=s.n(r),n=s(26295),d=s(58548),l=s(24671);s(37515);var c=s(16291);function x(e){let{databases:t,setTargetDatabase:s,user:r}=i().useContext(n.DashboardContext);return(0,a.jsx)(i().Fragment,{children:(0,a.jsx)(c.A,{databases:t,setTargetDatabase:s,title:"Recently added Databases",more:!0,user:r})})}var o=s(92736),u=s(34637),m=s(93213),h=s(83158);let j=(0,s(82544).A)("Key",[["circle",{cx:"7.5",cy:"15.5",r:"5.5",key:"yqb3hr"}],["path",{d:"m21 2-9.6 9.6",key:"1j0ho8"}],["path",{d:"m15.5 7.5 3 3L22 7l-3-3",key:"1rn1fs"}]]);function y({icon:e,metric:t,count:s,url:r}){return(0,a.jsxs)("a",{href:r,className:"card col w-full",children:[(0,a.jsx)("div",{className:"absolute top-4 right-4",children:e}),(0,a.jsxs)("div",{className:"content-block",children:[(0,a.jsx)("span",{className:"metric text-slate-800 dark:text-white",children:s}),(0,a.jsx)("span",{className:"text-sm text-slate-600 dark:text-slate-400",children:t})]})]})}function C(e){let{databases:t,setTargetDatabase:s,metrics:r,user:d}=i().useContext(n.DashboardContext);return(0,a.jsx)("section",{className:"p-0",children:(0,a.jsxs)("div",{className:"grid grid-cols-1 md:grid-cols-2 xl:grid-cols-4 w-full gap-6 items-stretch",children:[(0,a.jsx)(y,{metric:"Databases Created",count:r?.dbCount||0,icon:(0,a.jsx)(u.A,{size:20,className:"text-secondary2"}),url:`/admin/${d?.id}/databases`}),(0,a.jsx)(y,{metric:"Tables Created",count:r?.tablesCount||0,icon:(0,a.jsx)(m.A,{size:20,className:"text-primary"})}),(0,a.jsx)(y,{metric:"Media Added",count:r?.mediaCount||0,icon:(0,a.jsx)(h.A,{size:20,className:"text-slate-500"}),url:`/admin/${d?.id}/media`}),(0,a.jsx)(y,{metric:"API Keys",count:r?.apiKeysCount||0,icon:(0,a.jsx)(j,{size:20,className:"text-slate-900 dark:text-white"}),url:`/admin/${d?.id}/api-keys`})]})})}function b(e){let{databases:t,user:s}=i().useContext(n.DashboardContext);return(0,a.jsxs)(i().Fragment,{children:[(0,a.jsxs)("div",{className:"flex-col items-start gap-0",children:[(0,a.jsx)("h1",{className:"text-3xl m-0",children:"Dashboard"}),(0,a.jsx)(d.A,{user:s})]}),s?.verification_status?.toString().match(/1/)?(0,a.jsxs)(i().Fragment,{children:[(0,a.jsx)(C,{}),(0,a.jsx)(x,{}),(0,a.jsx)(o.A,{user:s})]}):(0,a.jsx)(l.A,{})]})}},93213:(e,t,s)=>{s.d(t,{A:()=>a});let a=(0,s(82544).A)("Sheet",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",ry:"2",key:"1m3agn"}],["line",{x1:"3",x2:"21",y1:"9",y2:"9",key:"1vqk6q"}],["line",{x1:"3",x2:"21",y1:"15",y2:"15",key:"o2sbyz"}],["line",{x1:"9",x2:"9",y1:"9",y2:"21",key:"1ib60c"}],["line",{x1:"15",x2:"15",y1:"9",y2:"21",key:"1n26ft"}]])},26295:(e,t,s)=>{s.r(t),s.d(t,{DashboardContext:()=>m,default:()=>h,getServerSideProps:()=>j});var a=s(8732),r=s(82015),i=s.n(r),n=s(95222),d=s(20048),l=s.n(d),c=s(43001),x=s(34033),o=s(67216),u=s.n(o);let m=i().createContext({});function h({user:e,databases:t,metrics:s}){let r=(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)("title",{children:"User Dashboard | Datasquirel"}),(0,a.jsx)("meta",{name:"description",content:"Welcome to your data app"})]}),[d,l]=i().useState(null);return(0,a.jsx)(n.A,{head:r,user:e,children:(0,a.jsxs)(m.Provider,{value:{user:e,databases:t,targetDatabase:d,setTargetDatabase:l,metrics:s},children:[(0,a.jsx)(c.A,{}),(0,a.jsx)(x.A,{targetDatabase:d})]})})}async function j({req:e,res:t,query:s}){let a=await l()(e,t);if(!a?.logged_in_status)return{redirect:{destination:"/login",permanent:!1}};let r=await u()("SELECT * FROM user_databases WHERE user_id=? ORDER BY id DESC LIMIT 3",[a.id]),i=await u()(`
|
|
SELECT (
|
|
SELECT COUNT(id) FROM user_databases WHERE user_id=?
|
|
) AS dbCount,
|
|
(
|
|
SELECT COUNT(id) FROM user_database_tables WHERE user_id=?
|
|
) AS tablesCount,
|
|
(
|
|
SELECT COUNT(id) FROM user_media WHERE user_id=?
|
|
) AS mediaCount,
|
|
(
|
|
SELECT COUNT(id) FROM api_keys WHERE user_id=?
|
|
) AS apiKeysCount
|
|
`,[a.id,a.id,a.id,a.id]);return{props:{user:a,databases:r,metrics:i&&i[0]?i[0]:{}}}}}}; |