1 line
16 KiB
JavaScript
1 line
16 KiB
JavaScript
import{a as o,j as e}from"./vendor-react-YMhRUmcb.js";import{a as C,l as T,m as L,B as u,d as m,C as d}from"./index-D2uzyr9g.js";import{av as P,R as O,aE as U,aT as I,aN as _,aU as k,aV as M,x as z,aM as B,aJ as H,a as G,g as V,w as K,D as $,aW as Y,aw as F}from"./vendor-icons-DINCNwpk.js";import{T as Q,a as W,b as f,c as N}from"./Tabs-C8UCeQNW.js";import{G as A}from"./vendor-fFnFILYR.js";import"./skeleton-BPDNnZ8E.js";import"./vendor-router-DX94Iu-2.js";import"./vendor-tanstack-CoFNL2zy.js";import"./vendor-utils-4BWoYre8.js";const J=[{id:"r1",targetId:"u3",targetType:"user",targetName:"Bot_User_99",reason:"Spam",description:"Posting same link in 50 channels.",reportedBy:"Admin_Dave",status:"pending",timestamp:"2023-10-25 10:30 AM"},{id:"r2",targetId:"t105",targetType:"track",targetName:"Untitled Track",reason:"Copyright",description:"Direct rip of Skrillex track.",reportedBy:"Sarah Connor",status:"pending",timestamp:"2023-10-25 09:15 AM"},{id:"r3",targetId:"c88",targetType:"comment",targetName:"Comment #8821",reason:"Hate Speech",description:"Offensive language.",reportedBy:"Cyber_Producer",status:"reviewed",timestamp:"2023-10-24 04:20 PM"}],q=[{id:"u1",name:"Bass_Drop.wav",user:"Skrillex",size:"12MB",date:"5 mins ago"},{id:"u2",name:"Project_Alpha.zip",user:"Deadmau5",size:"450MB",date:"12 mins ago"},{id:"u3",name:"Cover_Art.png",user:"Grimes",size:"4MB",date:"20 mins ago"}],h={getDashboardStats:async()=>{try{const t=await C.get("/audit/stats");return!t.data||Object.keys(t.data).length===0?{totalUsers:12450,monthlyRevenue:45290,activeSessions:1840,pendingReports:14,trends:{users:5.2,revenue:12.8,sessions:-2.4,reports:0}}:{totalUsers:t.data.total_users||12450,monthlyRevenue:t.data.total_revenue||45290,activeSessions:t.data.active_sessions||1840,pendingReports:t.data.pending_reports||14,trends:t.data.trends||{users:0,revenue:0,sessions:0,reports:0}}}catch(t){return T.error("[Admin] Failed to fetch dashboard stats",{error:t}),{totalUsers:12450,monthlyRevenue:45290,activeSessions:1840,pendingReports:14,trends:{users:5.2,revenue:12.8,sessions:-2.4,reports:0}}}},getModerationQueue:async(t="pending")=>(await new Promise(a=>setTimeout(a,600)),J.filter(a=>t==="all"||a.status===t)),resolveReport:async(t,a)=>(await new Promise(r=>setTimeout(r,400)),{success:!0}),getRecentUploads:async()=>(await new Promise(t=>setTimeout(t,400)),q),getAuditLogs:async t=>(await C.get("/audit/logs",{params:t})).data};function X(){const{addToast:t}=L(),[a,r]=o.useState({}),[n,s]=o.useState([]),[x,g]=o.useState([]),[p,l]=o.useState([]),[j,y]=o.useState(!0),[R,w]=o.useState(null),S=o.useCallback(async()=>{y(!0);try{const[i,c,v,b]=await Promise.all([h.getDashboardStats(),h.getModerationQueue("pending"),h.getRecentUploads(),h.getAuditLogs({limit:10})]);r(i),s(c||[]),g(v||[]),l(b?.logs||[])}catch(i){T.error("Error loading admin dashboard",{error:i})}finally{y(!1)}},[]);o.useEffect(()=>{S()},[S]);const D=o.useCallback(async(i,c)=>{await h.resolveReport(i,c),s(v=>v.filter(b=>b.id!==i)),t(`Protocol "${c.toUpperCase()}" executed successfully.`,"success")},[t]),E=o.useCallback((i,c)=>{w(i),t(`INITIALIZING ${i.toUpperCase()}...`,"info"),setTimeout(()=>{t(`${i.toUpperCase()} DEPLOYED`,c),w(null)},2e3)},[t]);return{stats:a,reports:n,uploads:x,auditLogs:p,loading:j,protocolActive:R,handleAction:D,triggerProtocol:E}}function Z({protocolActive:t,onRescan:a,onLockdown:r}){return e.jsxs("div",{className:"flex flex-col md:flex-row items-start md:items-end justify-between gap-6",children:[e.jsxs("div",{children:[e.jsxs("h2",{className:"text-4xl font-display font-bold text-white mb-2 flex items-center gap-3",children:[e.jsx(P,{className:"text-primary w-10 h-10"})," COMMAND CENTER"]}),e.jsxs("div",{className:"flex items-center gap-4",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("div",{className:"w-2 h-2 rounded-full bg-lime-500 animate-pulse shadow-glow-lime"}),e.jsx("span",{className:"text-muted-foreground text-xs font-mono tracking-widest uppercase",children:"Nodes Online"})]}),e.jsx("div",{className:"h-3 w-px bg-white/10"}),e.jsx("span",{className:"text-muted-foreground text-xs font-mono tracking-widest uppercase",children:"Sector: 00-ALPHA"})]})]}),e.jsxs("div",{className:"flex gap-3",children:[e.jsxs(u,{variant:"outline",className:"border-white/10 hover:bg-white/5 font-mono text-xs h-10 tracking-widest",onClick:a,children:[e.jsx(O,{className:m("w-3 h-3 mr-2",t==="RESCAN"&&"animate-spin")})," ","FULL RESCAN"]}),e.jsxs(u,{variant:"outline",className:"border-red-500/20 text-red-500 hover:bg-red-500/10 font-mono text-xs h-10 tracking-widest",onClick:r,children:[e.jsx(U,{className:"w-3 h-3 mr-2"})," LOCKDOWN"]})]})]})}const ee={cyan:"bg-cyan-500",gold:"bg-gold-500",lime:"bg-lime-500",red:"bg-red-500"},te={cyan:"text-cyan-500",gold:"text-gold-500",lime:"text-lime-500",red:"text-red-500"};function se({label:t,value:a,icon:r,color:n,trend:s}){return e.jsxs(d,{variant:"elevated",className:"p-5 relative overflow-hidden group hover:border-primary/50 transition-all cursor-default",children:[e.jsx("div",{className:m("absolute -right-4 -top-4 w-24 h-24 rounded-full opacity-10 blur-2xl transition-all group-hover:opacity-20",ee[n])}),e.jsxs("div",{className:"flex justify-between items-start mb-3 relative z-10",children:[e.jsx("div",{className:m("p-2.5 rounded-xl bg-white/5 shadow-inner",te[n]),children:r}),s!==void 0&&e.jsxs("span",{className:m("text-xs font-mono font-bold px-2 py-0.5 rounded-full border tracking-tighter",s>0&&"text-lime-500 border-lime-500/20 bg-lime-500/10",s<0&&"text-red-500 border-red-500/20 bg-red-500/10",s===0&&"text-muted-foreground border-border bg-muted/30"),children:[s>0?"+":"",s,"%"]})]}),e.jsx("div",{className:"text-3xl font-display font-bold text-white mb-1 relative z-10",children:a??"—"}),e.jsx("div",{className:"text-xs text-muted-foreground uppercase tracking-widest font-mono relative z-10",children:t})]})}function ae(){return e.jsxs(d,{variant:"elevated",className:"lg:col-span-2 p-8 relative overflow-hidden",children:[e.jsx("div",{className:"flex justify-between items-center mb-6 relative z-10",children:e.jsxs("div",{children:[e.jsxs("h3",{className:"text-lg font-bold text-white flex items-center gap-3",children:[e.jsx(I,{className:"w-5 h-5 text-primary"})," Traffic Flux"]}),e.jsx("p",{className:"text-xs text-muted-foreground font-mono mt-1",children:"Streaming traffic overview"})]})}),e.jsxs("div",{className:"h-64 flex flex-col items-center justify-center rounded-lg border border-white/10 bg-black/20",children:[e.jsx(_,{className:"w-14 h-14 text-muted-foreground/50 mb-4"}),e.jsx("p",{className:"text-sm font-medium text-muted-foreground",children:"No data available"}),e.jsx("p",{className:"text-xs text-muted-foreground/80 mt-1 font-mono",children:"Traffic metrics will appear here when available"})]})]})}const re=[{id:"purge",label:"PURGE CACHE",icon:e.jsx(k,{className:"w-5 h-5 text-gold-500"}),color:"gold"},{id:"index",label:"REINDEX DB",icon:e.jsx(M,{className:"w-5 h-5 text-cyan-500"}),color:"cyan"},{id:"sales",label:"SALES RT",icon:e.jsx(z,{className:"w-5 h-5 text-lime-500"}),color:"lime"},{id:"logs",label:"SEC LOGS",icon:e.jsx(B,{className:"w-5 h-5 text-white"}),color:"primary"}];function ie({onTrigger:t}){return e.jsxs(d,{variant:"elevated",className:"p-6",children:[e.jsx("h3",{className:"text-xs font-mono font-bold text-muted-foreground uppercase tracking-widest mb-6",children:"Protocols"}),e.jsx("div",{className:"grid grid-cols-2 gap-4",children:re.map(a=>e.jsxs("button",{type:"button",onClick:()=>t(a.label,a.color),className:"flex flex-col items-center justify-center gap-3 h-24 rounded-2xl border border-white/5 bg-white/5 hover:bg-white/10 hover:border-white/20 transition-all group overflow-hidden relative",children:[e.jsx("div",{className:m("absolute inset-0 bg-gradient-to-br transition-opacity opacity-0 group-hover:opacity-5 to-transparent",a.color==="gold"&&"from-gold-500",a.color==="cyan"&&"from-cyan-500",a.color==="lime"&&"from-lime-500",a.color==="primary"&&"from-primary")}),e.jsx("div",{className:"transition-transform group-hover:-translate-y-1 relative z-10",children:a.icon}),e.jsx("span",{className:"text-xs font-mono tracking-widest text-muted-foreground group-hover:text-white relative z-10",children:a.label})]},a.id))})]})}const oe=[{l:"CORE_KERNEL",s:"STABLE",c:"text-lime-500"},{l:"STORAGE_HIVE",s:"88% CAPACITY",c:"text-gold-500"},{l:"REST_UPLINK",s:"12ms",c:"text-cyan-500"},{l:"SECURITY_GRID",s:"ACTIVE",c:"text-lime-500"}];function ne(){return e.jsxs(d,{variant:"elevated",className:"p-6",children:[e.jsx("h3",{className:"text-xs font-mono font-bold text-muted-foreground uppercase tracking-widest mb-6",children:"Node Health"}),e.jsx("div",{className:"space-y-4",children:oe.map((t,a)=>e.jsxs("div",{className:"flex justify-between items-center py-2 border-b border-white/5 last:border-0 group",children:[e.jsx("span",{className:"text-xs font-mono text-muted-foreground group-hover:text-white transition-colors uppercase",children:t.l}),e.jsx("span",{className:m("text-xs font-bold font-mono tracking-widest",t.c),children:t.s})]},a))})]})}function le({reports:t,uploads:a,auditLogs:r,onReportAction:n}){return e.jsxs(Q,{defaultValue:"reports",className:"w-full",children:[e.jsxs(W,{className:"bg-black/20 border-b border-white/5 w-full justify-start h-auto p-0 rounded-none gap-10 mb-8 backdrop-blur-md",children:[e.jsx(f,{value:"reports",className:"relative group rounded-none border-b-2 border-transparent data-[state=active]:bg-transparent data-[state=active]:border-red-500 data-[state=active]:text-red-500 py-5 px-0 text-lg font-display bg-transparent transition-all",children:e.jsxs("div",{className:"flex items-center gap-3",children:["MODERATION",e.jsx("span",{className:"bg-red-500/20 text-red-500 px-2 py-0.5 rounded-full text-xs font-mono",children:t.length})]})}),e.jsx(f,{value:"uploads",className:"relative group rounded-none border-b-2 border-transparent data-[state=active]:bg-transparent data-[state=active]:border-primary data-[state=active]:text-primary py-5 px-0 text-lg font-display bg-transparent transition-all",children:e.jsxs("div",{className:"flex items-center gap-3",children:["SIGNALS",e.jsx("span",{className:"bg-primary/20 text-primary px-2 py-0.5 rounded-full text-xs font-mono",children:a.length})]})}),e.jsx(f,{value:"logs",className:"relative group rounded-none border-b-2 border-transparent data-[state=active]:bg-transparent data-[state=active]:border-gold-500 data-[state=active]:text-gold-500 py-5 px-0 text-lg font-display bg-transparent transition-all",children:e.jsxs("div",{className:"flex items-center gap-3",children:["SYSTEM LOGS",e.jsx(H,{className:"w-4 h-4 opacity-50"})]})})]}),e.jsx(N,{value:"reports",className:"animate-fadeIn",children:e.jsx(d,{variant:"glass",className:"bg-black/40 border-white/5 overflow-hidden",children:e.jsx("div",{className:"divide-y divide-white/5",children:t.length===0?e.jsx("div",{className:"text-center py-20 text-muted-foreground font-mono uppercase tracking-widest opacity-40",children:"No pending reports detected."}):t.map(s=>e.jsxs("div",{className:"flex items-center justify-between p-6 hover:bg-white/5 transition-colors group",children:[e.jsxs("div",{className:"flex items-center gap-5",children:[e.jsx("div",{className:"p-3 bg-red-500/10 rounded-xl text-red-500 group-hover:scale-110 transition-transform",children:e.jsx(G,{className:"w-5 h-5"})}),e.jsxs("div",{children:[e.jsx("div",{className:"font-bold text-lg text-white group-hover:text-red-400 transition-colors uppercase tracking-tight",children:s.targetName}),e.jsxs("div",{className:"text-xs text-muted-foreground font-mono uppercase flex items-center gap-2",children:[e.jsx("span",{className:"text-red-500/70",children:s.targetType})," •"," ",e.jsx("span",{className:"opacity-60",children:s.reason})," •"," ",e.jsx("span",{className:"opacity-40",children:s.timestamp})]})]})]}),e.jsxs("div",{className:"flex gap-3 opacity-0 group-hover:opacity-100 transition-all translate-x-4 group-hover:translate-x-0",children:[e.jsx(u,{variant:"outline",size:"sm",className:"border-lime-500/20 text-lime-500 hover:bg-lime-500/10",onClick:()=>n(s.id,"cleared"),children:"APPROVE"}),e.jsx(u,{variant:"outline",size:"sm",className:"border-red-500/20 text-red-500 hover:bg-red-500/10",onClick:()=>n(s.id,"quarantined"),children:"QUARANTINE"})]})]},s.id))})})}),e.jsx(N,{value:"uploads",className:"animate-fadeIn",children:e.jsx(d,{variant:"glass",className:"bg-black/40 border-white/5 overflow-hidden",children:e.jsx("div",{className:"divide-y divide-white/5",children:a.map(s=>e.jsxs("div",{className:"flex items-center justify-between p-6 hover:bg-white/5 transition-colors group",children:[e.jsxs("div",{className:"flex items-center gap-5",children:[e.jsx("div",{className:"p-3 bg-primary/10 rounded-xl text-primary",children:e.jsx(k,{className:"w-5 h-5"})}),e.jsxs("div",{children:[e.jsx("div",{className:"font-bold text-lg text-white",children:s.name}),e.jsxs("div",{className:"text-xs text-muted-foreground font-mono uppercase",children:["User: ",s.user," • Payload: ",s.size," • Handshake: ",s.date]})]})]}),e.jsx(u,{variant:"ghost",size:"sm",className:"group-hover:bg-primary/10 hover:text-primary",children:"INSPECT"})]},s.id))})})}),e.jsx(N,{value:"logs",className:"animate-fadeIn",children:e.jsxs(d,{variant:"glass",className:"bg-black/40 border-white/5 font-mono overflow-hidden",children:[e.jsxs("div",{className:"bg-black/40 p-4 border-b border-white/5 flex gap-4 text-xs font-bold text-muted-foreground uppercase tracking-widest",children:[e.jsx("span",{className:"w-32",children:"Timestamp"}),e.jsx("span",{className:"w-24",children:"Action"}),e.jsx("span",{className:"w-24",children:"Node"}),e.jsx("span",{children:"Payload Data"})]}),e.jsx("div",{className:"divide-y divide-white/5 text-xs",children:r.map((s,x)=>e.jsxs("div",{className:"flex gap-4 p-4 hover:bg-white/5 transition-colors",children:[e.jsx("span",{className:"w-32 text-muted-foreground",children:s.timestamp?new Date(s.timestamp).toLocaleTimeString():"—"}),e.jsx("span",{className:"w-24 text-primary font-bold",children:s.action??"AUTH_VAL"}),e.jsxs("span",{className:"w-24 text-magenta-500",children:["USER_",s.user_id!=null?String(s.user_id).slice(0,4):"???"]}),e.jsx("span",{className:"text-white opacity-80 truncate",children:JSON.stringify(s.details??s.metadata??{})})]},x))})]})})]})}function be(){const{stats:t,reports:a,uploads:r,auditLogs:n,loading:s,protocolActive:x,handleAction:g,triggerProtocol:p}=X();return s?e.jsx("div",{className:"flex justify-center py-24",children:e.jsx(V,{className:"w-10 h-10 text-primary animate-spin"})}):e.jsxs("div",{className:"space-y-8 pb-24 animate-fadeIn container mx-auto px-4 py-8 max-w-layout-content",children:[e.jsx(Z,{protocolActive:x,onRescan:()=>p("RESCAN","success"),onLockdown:()=>p("LOCKDOWN","error")}),e.jsx(A.div,{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-4 gap-8",initial:"hidden",animate:"visible",variants:{visible:{transition:{staggerChildren:.05}},hidden:{}},children:[{label:"Total Nodes",value:t.totalUsers?.toLocaleString(),icon:K,trend:t.trends?.users,color:"cyan"},{label:"Credit Volume",value:`$${t.monthlyRevenue?.toLocaleString()}`,icon:$,trend:t.trends?.revenue,color:"gold"},{label:"Active Uplinks",value:t.activeSessions?.toLocaleString(),icon:Y,trend:t.trends?.sessions,color:"lime"},{label:"Threat Reports",value:t.pendingReports,icon:F,trend:t.trends?.reports,color:"red"}].map((l,j)=>e.jsx(A.div,{variants:{hidden:{opacity:0,y:8},visible:{opacity:1,y:0}},children:e.jsx(se,{label:l.label,value:l.value,icon:e.jsx(l.icon,{className:"w-5 h-5"}),trend:l.trend,color:l.color})},l.label))}),e.jsxs("div",{className:"grid grid-cols-1 lg:grid-cols-3 gap-8",children:[e.jsx(ae,{}),e.jsxs("div",{className:"space-y-6",children:[e.jsx(ie,{onTrigger:p}),e.jsx(ne,{})]})]}),e.jsx(le,{reports:a,uploads:r,auditLogs:n,onReportAction:g})]})}export{be as AdminDashboardView};
|