PageSourceSearch

https://boombam.app/assets/database-management-D-c-9Sa9.js

js boombam.app collected 2026-10-04 13:34:38 UTC 15,597 bytes, 1 lines download raw bytes

1import{r as m,_ as ne,a as y,a6 as b,j as e,bh as le,C as c,e as r,d9 as ce,d8 as re,U as de,c_ as oe,b as j,d as u,o as f,ab as g,bm as W,bj as L,B as h,bS as xe,bM as K,bN as I,bO as w,bP as n,bQ as G,bR as l,s as v,ak as me,cb as he,al as pe,am as je,an as ue,ao as fe,aq as ge,Z as Ne,k as ye,f as be,b5 as we,m as ve,w as Ce}from"./index-CuSEeJFb.js";import{T as ke,a as ze,b as C,c as k}from"./tabs-CcPOXtvT.js";import{R as Se}from"./rotate-ccw-Tvprt-zs.js";import{R as q,T as H,a3 as Te,a2 as Q}from"./generateCategoricalChart-lXkql-gd.js";import{a as Be,L as Fe}from"./LineChart-QmF0f0aq.js";import{C as U,X as V,Y as R}from"./YAxis-edJjQlh1.js";import{B as De}from"./BarChart-CPEOGCBJ.js";import"./throttle-Bgu_Mp4s.js";import"./debounce-BH2V1_7f.js";import"./tiny-invariant-BaFNuDhB.js";import"./string-CFFdVFMV.js";function Ve(){const[P,Y]=m.useState("0 2 * * *"),[z,$]=m.useState(30),[S,J]=m.useState(!0),[T,X]=m.useState(!1),[M,Z]=m.useState(!1),[O,B]=m.useState(null),{toast:d}=ne(),{data:a,isLoading:Ae,refetch:_}=y({queryKey:["/api/database/stats"]}),{data:F,isLoading:Ee,refetch:ee}=y({queryKey:["/api/database/backups"]}),{data:p,isLoading:Le}=y({queryKey:["/api/database/slow-queries"]}),{data:t,isLoading:Re}=y({queryKey:["/api/database/growth-analysis"]}),D=b({mutationFn:async()=>{const s=await fetch("/api/database/backup",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({type:"manual",compressionEnabled:S,encryptionEnabled:T,retentionDays:z})});if(!s.ok)throw new Error("Failed to create backup");return s.json()},onSuccess:()=>{d({title:"Backup Created",description:"Database backup has been created successfully."}),ee()},onError:()=>{d({title:"Backup Failed",description:"Failed to create database backup. Please try again.",variant:"destructive"})}}),se=b({mutationFn:async s=>{const i=await fetch(`/api/database/restore/${s}`,{method:"POST"});if(!i.ok)throw new Error("Failed to restore backup");return i.json()},onSuccess:()=>{d({title:"Restore Successful",description:"Database has been restored from backup."})},onError:()=>{d({title:"Restore Failed",description:"Failed to restore database. Please contact support.",variant:"destructive"})}}),A=b({mutationFn:async()=>{const s=await fetch("/api/database/optimize",{method:"POST"});if(!s.ok)throw new Error("Failed to optimize database");return s.json()},onSuccess:()=>{d({title:"Optimization Complete",description:"Database has been optimized successfully."}),_()},onError:()=>{d({title:"Optimization Failed",description:"Failed to optimize database. Please try again.",variant:"destructive"})}}),E=b({mutationFn:async()=>{const s=await fetch("/api/database/backup-schedule",{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({schedule:P,retentionDays:z,compressionEnabled:S,encryptionEnabled:T,enabled:M})});if(!s.ok)throw new Error("Failed to update schedule");return s.json()},onSuccess:()=>{d({title:"Schedule Updated",description:"Backup schedule has been updated successfully."})}}),ae=s=>{const i=["B","KB","MB","GB","TB"];let o=0,x=s;for(;x>=1024&&o<i.length-1;)x/=1024,o++;return`${x.toFixed(2)} ${i[o]}`},N=s=>new Date(s).toLocaleString(),te=(a==null?void 0:a.tables.slice(0,5).map(s=>({name:s.name,rows:s.rowCount/1e3,size:parseFloat(s.size.split(" ")[0])})))||[],ie=[{period:"Current",size:parseFloat((t==null?void 0:t.currentSize.split(" ")[0])||"0")},{period:"30 Days",size:parseFloat((t==null?void 0:t.projectedSize30Days.split(" ")[0])||"0")},{period:"90 Days",size:parseFloat((t==null?void 0:t.projectedSize90Days.split(" ")[0])||"0")},{period:"1 Year",size:parseFloat((t==null?void 0:t.projectedSize365Days.split(" ")[0])||"0")}];return e.jsxs("div",{className:"container mx-auto p-6 max-w-7xl",children:[e.jsxs("div",{className:"mb-8",children:[e.jsxs("h1",{className:"text-3xl font-bold flex items-center gap-3",children:[e.jsx(le,{className:"w-8 h-8 text-orange-500"}),"Database Management"]}),e.jsx("p",{className:"text-gray-600 dark:text-gray-400 mt-2",children:"Manage backups, optimize performance, and plan for data growth"})]}),e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-4 gap-4 mb-6",children:[e.jsx(c,{children:e.jsx(r,{className:"p-6",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx("p",{className:"text-sm font-medium text-gray-600",children:"Database Size"}),e.jsx("p",{className:"text-2xl font-bold",children:(a==null?void 0:a.totalSize)||"0 MB"})]}),e.jsx(ce,{className:"w-8 h-8 text-orange-500"})]})})}),e.jsx(c,{children:e.jsx(r,{className:"p-6",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx("p",{className:"text-sm font-medium text-gray-600",children:"Total Tables"}),e.jsx("p",{className:"text-2xl font-bold",children:(a==null?void 0:a.tableCount)||0})]}),e.jsx(re,{className:"w-8 h-8 text-blue-500"})]})})}),e.jsx(c,{children:e.jsx(r,{className:"p-6",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx("p",{className:"text-sm font-medium text-gray-600",children:"Active Connections"}),e.jsx("p",{className:"text-2xl font-bold",children:(a==null?void 0:a.connectionCount)||0})]}),e.jsx(de,{className:"w-8 h-8 text-green-500"})]})})}),e.jsx(c,{children:e.jsx(r,{className:"p-6",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx("p",{className:"text-sm font-medium text-gray-600",children:"Slow Queries"}),e.jsx("p",{className:"text-2xl font-bold",children:(a==null?void 0:a.slowQueryCount)||0})]}),e.jsx(oe,{className:"w-8 h-8 text-red-500"})]})})})]}),e.jsxs(ke,{defaultValue:"backups",className:"space-y-4",children:[e.jsxs(ze,{className:"grid w-full grid-cols-2 lg:grid-cols-4 gap-1",children:[e.jsx(C,{value:"backups",className:"text-xs sm:text-sm",children:"Backups"}),e.jsx(C,{value:"performance",className:"text-xs sm:text-sm",children:"Performance"}),e.jsx(C,{value:"growth",className:"text-xs sm:text-sm",children:"Growth"}),e.jsx(C,{value:"tables",className:"text-xs sm:text-sm",children:"Tables"})]}),e.jsxs(k,{value:"backups",className:"space-y-4",children:[e.jsxs(c,{children:[e.jsxs(j,{children:[e.jsx(u,{children:"Backup Configuration"}),e.jsx(f,{children:"Configure automated backup settings"})]}),e.jsxs(r,{className:"space-y-4",children:[e.jsxs("div",{className:"grid grid-cols-1 lg:grid-cols-2 gap-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(g,{htmlFor:"schedule",className:"text-sm",children:"Backup Schedule (Cron Format)"}),e.jsx(W,{id:"schedule",value:P,onChange:s=>Y(s),placeholder:"0 2 * * * (Daily at 2 AM)",className:"text-sm"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(g,{htmlFor:"retention",className:"text-sm",children:"Retention Period (Days)"}),e.jsx(W,{id:"retention",type:"number",value:z,onChange:s=>$(parseInt(s)),className:"text-sm"})]})]}),e.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-3 gap-4",children:[e.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsx(L,{id:"compression",checked:S,onCheckedChange:J}),e.jsx(g,{htmlFor:"compression",className:"text-sm",children:"Enable Compression"})]}),e.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsx(L,{id:"encryption",checked:T,onCheckedChange:X}),e.jsx(g,{htmlFor:"encryption",className:"text-sm",children:"Enable Encryption"})]}),e.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsx(L,{id:"autobackup",checked:M,onCheckedChange:Z}),e.jsx(g,{htmlFor:"autobackup",className:"text-sm",children:"Enable Auto Backup"})]})]}),e.jsxs("div",{className:"flex flex-col sm:flex-row gap-2",children:[e.jsx(h,{onClick:()=>E.mutate(),disabled:E.isPending,className:"w-full sm:w-auto text-sm",children:E.isPending?"Upd
1ating...":"Save Configuration"}),e.jsxs(h,{variant:"outline",onClick:()=>D.mutate(),disabled:D.isPending,className:"w-full sm:w-auto text-sm",children:[e.jsx(xe,{className:"w-4 h-4 mr-2"}),D.isPending?"Creating...":"Create Backup Now"]})]})]})]}),e.jsxs(c,{children:[e.jsxs(j,{children:[e.jsx(u,{children:"Backup History"}),e.jsx(f,{children:"View and manage database backups"})]}),e.jsx(r,{children:e.jsx("div",{className:"overflow-x-auto",children:e.jsxs(K,{children:[e.jsx(I,{children:e.jsxs(w,{children:[e.jsx(n,{className:"text-xs sm:text-sm",children:"Timestamp"}),e.jsx(n,{className:"text-xs sm:text-sm",children:"Type"}),e.jsx(n,{className:"text-xs sm:text-sm",children:"Size"}),e.jsx(n,{className:"text-xs sm:text-sm",children:"Status"}),e.jsx(n,{className:"text-xs sm:text-sm",children:"Actions"})]})}),e.jsx(G,{children:F==null?void 0:F.map(s=>e.jsxs(w,{children:[e.jsx(l,{className:"text-xs sm:text-sm",children:N(s.timestamp)}),e.jsx(l,{children:e.jsx(v,{variant:s.type==="scheduled"?"default":"secondary",className:"text-xs",children:s.type})}),e.jsx(l,{className:"text-xs sm:text-sm",children:ae(s.size)}),e.jsx(l,{children:e.jsx(v,{variant:s.status==="completed"?"default":s.status==="failed"?"destructive":"secondary",className:"text-xs",children:s.status})}),e.jsx(l,{children:e.jsxs(me,{children:[e.jsx(he,{asChild:!0,children:e.jsxs(h,{variant:"outline",size:"sm",disabled:s.status!=="completed",onClick:()=>B(s.id),className:"text-xs",children:[e.jsx(Se,{className:"w-3 h-3 mr-1 sm:w-4 sm:h-4 sm:mr-2"}),e.jsx("span",{className:"hidden sm:inline",children:"Restore"}),e.jsx("span",{className:"sm:hidden",children:"⟲"})]})}),e.jsxs(pe,{children:[e.jsxs(je,{children:[e.jsx(ue,{children:"Confirm Restore"}),e.jsx(fe,{children:"Are you sure you want to restore from this backup? This will replace your current database."})]}),e.jsxs(ge,{children:[e.jsx(h,{variant:"outline",onClick:()=>B(null),children:"Cancel"}),e.jsx(h,{variant:"destructive",onClick:()=>{O&&(se.mutate(O),B(null))},children:"Restore Database"})]})]})]})})]},s.id))})]})})})]})]}),e.jsx(k,{value:"performance",className:"space-y-4",children:e.jsxs(c,{children:[e.jsxs(j,{className:"flex flex-row items-center justify-between",children:[e.jsxs("div",{children:[e.jsx(u,{children:"Query Performance"}),e.jsx(f,{children:"Identify and optimize slow queries"})]}),e.jsxs(h,{onClick:()=>A.mutate(),disabled:A.isPending,children:[e.jsx(Ne,{className:"w-4 h-4 mr-2"}),A.isPending?"Optimizing...":"Optimize Database"]})]}),e.jsx(r,{children:e.jsxs("div",{className:"space-y-4",children:[p==null?void 0:p.map((s,i)=>e.jsxs("div",{className:"border rounded-lg p-4 space-y-2",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs(v,{variant:"destructive",children:[s.executionTime.toFixed(2),"ms"]}),e.jsxs("span",{className:"text-sm text-gray-600",children:[s.rowsAffected," rows affected"]})]}),e.jsx("span",{className:"text-xs text-gray-500",children:N(s.timestamp)})]}),e.jsx("pre",{className:"text-xs bg-gray-100 dark:bg-gray-800 p-2 rounded overflow-x-auto",children:s.query}),s.optimizationSuggestions&&s.optimizationSuggestions.length>0&&e.jsxs("div",{className:"space-y-1",children:[e.jsx("p",{className:"text-sm font-medium",children:"Optimization Suggestions:"}),e.jsx("ul",{className:"list-disc list-inside text-sm text-gray-600",children:s.optimizationSuggestions.map((o,x)=>e.jsx("li",{children:o},x))})]})]},i)),(!p||p.length===0)&&e.jsxs(ye,{children:[e.jsx(be,{className:"h-4 w-4"}),e.jsx(we,{children:"No Slow Queries"}),e.jsx(ve,{children:"Your database is performing well with no slow queries detected."})]})]})})]})}),e.jsx(k,{value:"growth",className:"space-y-4",children:e.jsxs(c,{children:[e.jsxs(j,{children:[e.jsx(u,{children:"Data Growth Projections"}),e.jsx(f,{children:"Plan for future storage requirements"})]}),e.jsxs(r,{children:[e.jsx("div",{className:"h-48 sm:h-64",children:e.jsx(q,{width:"100%",height:"100%",children:e.jsxs(Be,{data:ie,children:[e.jsx(U,{strokeDasharray:"3 3"}),e.jsx(V,{dataKey:"period",tick:{fontSize:window.innerWidth<640?10:12}}
1),e.jsx(R,{label:{value:"Size (GB)",angle:-90,position:"insideLeft",style:{fontSize:window.innerWidth<640?"10px":"12px"}},tick:{fontSize:window.innerWidth<640?10:12}}),e.jsx(H,{}),e.jsx(Fe,{type:"monotone",dataKey:"size",stroke:"#FF6B35",strokeWidth:2,dot:{fill:"#FF6B35",r:window.innerWidth<640?3:4}})]})})}),e.jsxs("div",{className:"mt-6 space-y-4",children:[e.jsxs("div",{children:[e.jsx("h4",{className:"font-medium mb-2",children:"Growth Recommendations"}),e.jsx("ul",{className:"space-y-1",children:t==null?void 0:t.recommendations.map((s,i)=>e.jsxs("li",{className:"flex items-center gap-2 text-sm",children:[e.jsx(Ce,{className:"w-4 h-4 text-orange-500"}),s]},i))})]}),e.jsxs("div",{children:[e.jsx("h4",{className:"font-medium mb-2",children:"Largest Tables"}),e.jsx("div",{className:"space-y-2",children:t==null?void 0:t.largestTables.map((s,i)=>e.jsxs("div",{className:"border rounded-lg p-3",children:[e.jsxs("div",{className:"flex items-center justify-between mb-2",children:[e.jsx("span",{className:"font-medium",children:s.name}),e.jsx(v,{children:s.currentSize})]}),s.recommendedActions.length>0&&e.jsx("ul",{className:"text-xs text-gray-600 space-y-1",children:s.recommendedActions.map((o,x)=>e.jsxs("li",{children:["• ",o]},x))})]},i))})]})]})]})]})}),e.jsx(k,{value:"tables",className:"space-y-4",children:e.jsxs(c,{children:[e.jsxs(j,{children:[e.jsx(u,{children:"Table Statistics"}),e.jsx(f,{children:"Detailed analysis of database tables"})]}),e.jsxs(r,{children:[e.jsx("div",{className:"h-48 sm:h-64 mb-6",children:e.jsx(q,{width:"100%",height:"100%",children:e.jsxs(De,{data:te,children:[e.jsx(U,{strokeDasharray:"3 3"}),e.jsx(V,{dataKey:"name",tick:{fontSize:window.innerWidth<640?8:10}}),e.jsx(R,{yAxisId:"left",label:{value:"Rows (k)",angle:-90,position:"insideLeft",style:{fontSize:window.innerWidth<640?"8px":"10px"}},tick:{fontSize:window.innerWidth<640?8:10}}),e.jsx(R,{yAxisId:"right",orientation:"right",label:{value:"Size (MB)",angle:90,position:"insideRight",style:{fontSize:window.innerWidth<640?"8px":"10px"}},tick:{fontSize:window.innerWidth<640?8:10}}),e.jsx(H,{}),e.jsx(Te,{wrapperStyle:{fontSize:window.innerWidth<640?"10px":"12px"}}),e.jsx(Q,{yAxisId:"left",dataKey:"rows",fill:"#FF6B35",name:"Rows (k)"}),e.jsx(Q,{yAxisId:"right",dataKey:"size",fill:"#4ECDC4",name:"Size (MB)"})]})})}),e.jsx("div",{className:"overflow-x-auto",children:e.jsxs(K,{children:[e.jsx(I,{children:e.jsxs(w,{children:[e.jsx(n,{className:"text-xs sm:text-sm",children:"Table Name"}),e.jsx(n,{className:"text-xs sm:text-sm",children:"Row Count"}),e.jsx(n,{className:"text-xs sm:text-sm",children:"Total Size"}),e.jsx(n,{className:"text-xs sm:text-sm",children:"Index Size"}),e.jsx(n,{className:"text-xs sm:text-sm hidden sm:table-cell",children:"Last Vacuum"}),e.jsx(n,{className:"text-xs sm:text-sm hidden sm:table-cell",children:"Last Analyze"})]})}),e.jsx(G,{children:a==null?void 0:a.tables.map(s=>e.jsxs(w,{children:[e.jsx(l,{className:"font-medium text-xs sm:text-sm",children:s.name}),e.jsx(l,{className:"text-xs sm:text-sm",children:s.rowCount.toLocaleString()}),e.jsx(l,{className:"text-xs sm:text-sm",children:s.size}),e.jsx(l,{className:"text-xs sm:text-sm",children:s.indexSize}),e.jsx(l,{className:"text-xs sm:text-sm hidden sm:table-cell",children:s.lastVacuum?N(s.lastVacuum):e.jsx("span",{className:"text-yellow-600",children:"Never"})}),e.jsx(l,{className:"text-xs sm:text-sm hidden sm:table-cell",children:s.lastAnalyze?N(s.lastAnalyze):e.jsx("span",{className:"text-yellow-600",children:"Never"})})]},s.name))})]})})]})]})})]})]})}export{Ve as default};

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.