Bloc A - Code mort: - Suppression Studio (components, views, features) - Suppression gamification + services mock (projectService, storageService, gamificationService) - Mise à jour Sidebar, Navbar, locales Bloc B - Frontend: - Suppression modal.tsx deprecated, Modal.stories (doublon Dialog) - Feature flags: PLAYLIST_SEARCH, PLAYLIST_RECOMMENDATIONS, ROLE_MANAGEMENT = true - Suppression 19 tests orphelins, retrait exclusions vitest.config Bloc C - Backend: - Extraction routes_auth.go depuis router.go Bloc D - Rust: - Suppression security_legacy.rs (code mort, patterns déjà dans security/)
1 line
18 KiB
JavaScript
1 line
18 KiB
JavaScript
import{a as l,j as e}from"./vendor-react-yWUy5XPk.js";import{g as T,l as R,u as I,B as h,c as p,C as o,S as r,i as U}from"./index-CYK_b1Uz.js";import{am as _,R as z,t as B,an as M,ao as H,ap as k,aq as G,Q as V,a as K,ar as F,b as $,U as Q,F as Y,h as q,as as W}from"./vendor-icons-DJFb1Tiw.js";import{A as J}from"./AnimatedNumber-e5YD_LEJ.js";import{T as X,a as Z,b as w,c as S}from"./Tabs-jry2MOtG.js";import{m as E}from"./vendor-motion-B3XPS3Jc.js";import"./vendor-CveO81sn.js";import"./vendor-security-DsrNJhpn.js";import"./vendor-router-BNNHboN9.js";import"./vendor-tanstack-kPY9uK0s.js";import"./vendor-http-Cz8wfb0q.js";import"./vendor-utils-DtoSyhX2.js";import"./vendor-i18n-CMcqpBLz.js";const ee=[{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"}],se=[{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"}],g={getDashboardStats:async()=>{try{const s=await T.get("/audit/stats");return!s.data||Object.keys(s.data).length===0?{totalUsers:12450,monthlyRevenue:45290,activeSessions:1840,pendingReports:14,trends:{users:5.2,revenue:12.8,sessions:-2.4,reports:0}}:{totalUsers:s.data.total_users||12450,monthlyRevenue:s.data.total_revenue||45290,activeSessions:s.data.active_sessions||1840,pendingReports:s.data.pending_reports||14,trends:s.data.trends||{users:0,revenue:0,sessions:0,reports:0}}}catch(s){return R.error("[Admin] Failed to fetch dashboard stats",{error:s}),{totalUsers:12450,monthlyRevenue:45290,activeSessions:1840,pendingReports:14,trends:{users:5.2,revenue:12.8,sessions:-2.4,reports:0}}}},getModerationQueue:async(s="pending")=>(await new Promise(t=>setTimeout(t,600)),ee.filter(t=>s==="all"||t.status===s)),resolveReport:async(s,t)=>(await new Promise(n=>setTimeout(n,400)),{success:!0}),getRecentUploads:async()=>(await new Promise(s=>setTimeout(s,400)),se),getAuditLogs:async s=>(await T.get("/audit/logs",{params:s})).data};function ae(){const{addToast:s}=I(),[t,n]=l.useState({}),[d,a]=l.useState([]),[m,v]=l.useState([]),[f,u]=l.useState([]),[b,c]=l.useState(!0),[D,A]=l.useState(null),[L,C]=l.useState(null),N=l.useCallback(async()=>{c(!0),A(null);try{const[i,x,j,y]=await Promise.all([g.getDashboardStats(),g.getModerationQueue("pending"),g.getRecentUploads(),g.getAuditLogs({limit:10})]);n(i),a(x||[]),v(j||[]),u(y?.logs||[])}catch(i){R.error("Error loading admin dashboard",{error:i}),A(i instanceof Error?i:new Error(String(i)))}finally{c(!1)}},[]);l.useEffect(()=>{N()},[N]);const P=l.useCallback(async(i,x)=>{await g.resolveReport(i,x),a(j=>j.filter(y=>y.id!==i)),s(`Protocol "${x.toUpperCase()}" executed successfully.`,"success")},[s]),O=l.useCallback((i,x)=>{C(i),s(`INITIALIZING ${i.toUpperCase()}...`,"info"),setTimeout(()=>{s(`${i.toUpperCase()} DEPLOYED`,x),C(null)},2e3)},[s]);return{stats:t,reports:d,uploads:m,auditLogs:f,loading:b,error:D,protocolActive:L,handleAction:P,triggerProtocol:O,retry:N}}function te({protocolActive:s,onRescan:t,onLockdown:n}){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-heading font-bold text-foreground mb-2 flex items-center gap-3",children:[e.jsx(_,{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-success 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-border","aria-hidden":!0}),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(h,{variant:"outline",className:"border-border hover:bg-muted/50 font-mono text-xs h-10 tracking-widest",onClick:t,children:[e.jsx(z,{className:p("w-3 h-3 mr-2",s==="RESCAN"&&"animate-spin")})," ","FULL RESCAN"]}),e.jsxs(h,{variant:"outline",className:"border-destructive/20 text-destructive hover:bg-destructive/10 font-mono text-xs h-10 tracking-widest",onClick:n,children:[e.jsx(B,{className:"w-3 h-3 mr-2"})," LOCKDOWN"]})]})]})}const re={cyan:"bg-primary",gold:"bg-gold-500",lime:"bg-success",red:"bg-destructive"},ie={cyan:"text-primary",gold:"text-gold-500",lime:"text-success",red:"text-destructive"};function oe({label:s,value:t,icon:n,color:d,trend:a}){return e.jsxs(o,{variant:"elevated",className:"p-5 relative overflow-hidden group hover:border-primary/50 transition-all cursor-default",children:[e.jsx("div",{className:p("absolute -right-4 -top-4 w-24 h-24 rounded-full opacity-10 blur-2xl transition-all group-hover:opacity-20",re[d])}),e.jsxs("div",{className:"flex justify-between items-start mb-3 relative z-10",children:[e.jsx("div",{className:p("p-2.5 rounded-xl bg-white/5 shadow-inner",ie[d]),children:n}),a!==void 0&&e.jsxs("span",{className:p("text-xs font-mono font-bold px-2 py-0.5 rounded-full border tracking-tighter",a>0&&"text-success border-success/20 bg-success/10",a<0&&"text-destructive border-destructive/20 bg-destructive/10",a===0&&"text-muted-foreground border-border bg-muted/30"),children:[a>0?"+":"",a,"%"]})]}),e.jsx("div",{className:"text-3xl font-heading font-bold text-foreground mb-1 relative z-10",children:typeof t=="number"?e.jsx(J,{value:t}):t??"—"}),e.jsx("div",{className:"text-xs text-muted-foreground uppercase tracking-widest font-mono relative z-10",children:s})]})}function ne(){return e.jsxs(o,{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-foreground flex items-center gap-3",children:[e.jsx(M,{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(H,{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 le=[{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(G,{className:"w-5 h-5 text-primary"}),color:"cyan"},{id:"sales",label:"SALES RT",icon:e.jsx(V,{className:"w-5 h-5 text-success"}),color:"lime"},{id:"logs",label:"SEC LOGS",icon:e.jsx(K,{className:"w-5 h-5 text-foreground"}),color:"primary"}];function de({onTrigger:s}){return e.jsxs(o,{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:le.map(t=>e.jsxs("button",{type:"button",onClick:()=>s(t.label,t.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:p("absolute inset-0 bg-gradient-to-br transition-opacity opacity-0 group-hover:opacity-5 to-transparent",t.color==="gold"&&"from-gold-500",t.color==="cyan"&&"from-cyan-500",t.color==="lime"&&"from-lime-500",t.color==="primary"&&"from-primary")}),e.jsx("div",{className:"transition-transform group-hover:-translate-y-1 relative z-10",children:t.icon}),e.jsx("span",{className:"text-xs font-mono tracking-widest text-muted-foreground group-hover:text-foreground relative z-10",children:t.label})]},t.id))})]})}const ce=[{l:"CORE_KERNEL",s:"STABLE",c:"text-success"},{l:"STORAGE_HIVE",s:"88% CAPACITY",c:"text-gold-500"},{l:"REST_UPLINK",s:"12ms",c:"text-primary"},{l:"SECURITY_GRID",s:"ACTIVE",c:"text-success"}];function me(){return e.jsxs(o,{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:ce.map((s,t)=>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-foreground transition-colors uppercase",children:s.l}),e.jsx("span",{className:p("text-xs font-bold font-mono tracking-widest",s.c),children:s.s})]},t))})]})}function xe({reports:s,uploads:t,auditLogs:n,onReportAction:d}){return e.jsxs(X,{defaultValue:"reports",className:"w-full",children:[e.jsxs(Z,{className:"bg-muted/30 border-b border-border w-full justify-start h-auto p-0 rounded-none gap-10 mb-8 backdrop-blur-md",children:[e.jsx(w,{value:"reports",className:"relative group rounded-none border-b-2 border-transparent data-[state=active]:bg-transparent data-[state=active]:border-destructive data-[state=active]:text-destructive py-5 px-0 text-lg font-heading bg-transparent transition-all",children:e.jsxs("div",{className:"flex items-center gap-3",children:["MODERATION",e.jsx("span",{className:"bg-destructive/20 text-destructive px-2 py-0.5 rounded-full text-xs font-mono",children:s.length})]})}),e.jsx(w,{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-heading 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:t.length})]})}),e.jsx(w,{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-heading bg-transparent transition-all",children:e.jsxs("div",{className:"flex items-center gap-3",children:["SYSTEM LOGS",e.jsx(F,{className:"w-4 h-4 opacity-50"})]})})]}),e.jsx(S,{value:"reports",className:"animate-fadeIn",children:e.jsx(o,{variant:"glass",className:"bg-card/80 border-border overflow-hidden",children:e.jsx("div",{className:"divide-y divide-white/5",children:s.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."}):s.map(a=>e.jsxs("div",{className:"flex items-center justify-between p-6 hover:bg-muted/50 transition-colors group",children:[e.jsxs("div",{className:"flex items-center gap-5",children:[e.jsx("div",{className:"p-3 bg-destructive/10 rounded-xl text-destructive group-hover:scale-110 transition-transform",children:e.jsx($,{className:"w-5 h-5"})}),e.jsxs("div",{children:[e.jsx("div",{className:"font-bold text-lg text-foreground group-hover:text-destructive transition-colors uppercase tracking-tight",children:a.targetName}),e.jsxs("div",{className:"text-xs text-muted-foreground font-mono uppercase flex items-center gap-2",children:[e.jsx("span",{className:"text-destructive/70",children:a.targetType})," •"," ",e.jsx("span",{className:"opacity-60",children:a.reason})," •"," ",e.jsx("span",{className:"opacity-40",children:a.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(h,{variant:"outline",size:"sm",className:"border-success/20 text-success hover:bg-success/10",onClick:()=>d(a.id,"cleared"),children:"APPROVE"}),e.jsx(h,{variant:"outline",size:"sm",className:"border-destructive/20 text-destructive hover:bg-destructive/10",onClick:()=>d(a.id,"quarantined"),children:"QUARANTINE"})]})]},a.id))})})}),e.jsx(S,{value:"uploads",className:"animate-fadeIn",children:e.jsx(o,{variant:"glass",className:"bg-card/80 border-border overflow-hidden",children:e.jsx("div",{className:"divide-y divide-white/5",children:t.map(a=>e.jsxs("div",{className:"flex items-center justify-between p-6 hover:bg-muted/50 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-foreground",children:a.name}),e.jsxs("div",{className:"text-xs text-muted-foreground font-mono uppercase",children:["User: ",a.user," • Payload: ",a.size," • Handshake: ",a.date]})]})]}),e.jsx(h,{variant:"ghost",size:"sm",className:"group-hover:bg-primary/10 hover:text-primary",children:"INSPECT"})]},a.id))})})}),e.jsx(S,{value:"logs",className:"animate-fadeIn",children:e.jsxs(o,{variant:"glass",className:"bg-card/80 border-border font-mono overflow-hidden",children:[e.jsxs("div",{className:"bg-muted/30 p-4 border-b border-border 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:n.map((a,m)=>e.jsxs("div",{className:"flex gap-4 p-4 hover:bg-muted/50 transition-colors",children:[e.jsx("span",{className:"w-32 text-muted-foreground",children:a.timestamp?new Date(a.timestamp).toLocaleTimeString():"—"}),e.jsx("span",{className:"w-24 text-primary font-bold",children:a.action??"AUTH_VAL"}),e.jsxs("span",{className:"w-24 text-destructive",children:["USER_",a.user_id!=null?String(a.user_id).slice(0,4):"???"]}),e.jsx("span",{className:"text-foreground opacity-80 truncate",children:JSON.stringify(a.details??a.metadata??{})})]},m))})]})})]})}function pe(){return e.jsxs("div",{className:"space-y-8 pb-24 animate-fadeIn container mx-auto px-4 py-8 max-w-layout-content",children:[e.jsxs("div",{className:"flex flex-col md:flex-row items-start md:items-end justify-between gap-6",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(r,{className:"h-12 w-80"}),e.jsxs("div",{className:"flex items-center gap-4",children:[e.jsx(r,{className:"h-4 w-24"}),e.jsx(r,{className:"h-4 w-28"})]})]}),e.jsxs("div",{className:"flex gap-3",children:[e.jsx(r,{className:"h-10 w-32"}),e.jsx(r,{className:"h-10 w-28"})]})]}),e.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-4 gap-6",children:[1,2,3,4].map(s=>e.jsxs(o,{variant:"glass",className:"p-5",children:[e.jsx(r,{className:"h-10 w-10 rounded-xl mb-3"}),e.jsx(r,{className:"h-9 w-20 mb-2"}),e.jsx(r,{className:"h-4 w-24"})]},s))}),e.jsxs("div",{className:"grid grid-cols-1 lg:grid-cols-3 gap-8",children:[e.jsxs(o,{variant:"glass",className:"lg:col-span-2 p-8",children:[e.jsx(r,{className:"h-6 w-32 mb-4"}),e.jsx(r,{className:"h-64 w-full rounded-lg"})]}),e.jsxs("div",{className:"space-y-6",children:[e.jsxs(o,{variant:"glass",className:"p-6",children:[e.jsx(r,{className:"h-4 w-24 mb-6"}),e.jsx("div",{className:"grid grid-cols-2 gap-4",children:[1,2,3,4].map(s=>e.jsx(r,{className:"h-24 rounded-2xl"},s))})]}),e.jsxs(o,{variant:"glass",className:"p-6",children:[e.jsx(r,{className:"h-4 w-28 mb-6"}),e.jsx("div",{className:"space-y-4",children:[1,2,3,4].map(s=>e.jsx(r,{className:"h-8 w-full"},s))})]})]})]}),e.jsxs("div",{className:"space-y-4",children:[e.jsx(r,{className:"h-12 w-full"}),e.jsx(o,{variant:"glass",className:"p-6",children:e.jsx("div",{className:"space-y-4",children:[1,2,3].map(s=>e.jsx(r,{className:"h-16 w-full"},s))})})]})]})}function Te(){const{stats:s,reports:t,uploads:n,auditLogs:d,loading:a,error:m,protocolActive:v,handleAction:f,triggerProtocol:u,retry:b}=ae();return a?e.jsx(pe,{}):m?e.jsx("div",{className:"container mx-auto px-4 py-8 max-w-layout-content",children:e.jsx(U,{error:m,onRetry:b,title:"Failed to load admin dashboard",context:{action:"loading",resource:"admin dashboard"},variant:"card"})}):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(te,{protocolActive:v,onRescan:()=>u("RESCAN","success"),onLockdown:()=>u("LOCKDOWN","error")}),e.jsx(E.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:s.totalUsers?.toLocaleString(),icon:Q,trend:s.trends?.users,color:"cyan"},{label:"Credit Volume",value:`$${s.monthlyRevenue?.toLocaleString()}`,icon:Y,trend:s.trends?.revenue,color:"gold"},{label:"Active Uplinks",value:s.activeSessions?.toLocaleString(),icon:q,trend:s.trends?.sessions,color:"lime"},{label:"Threat Reports",value:s.pendingReports,icon:W,trend:s.trends?.reports,color:"red"}].map(c=>e.jsx(E.div,{variants:{hidden:{opacity:0,y:8},visible:{opacity:1,y:0}},children:e.jsx(oe,{label:c.label,value:c.value,icon:e.jsx(c.icon,{className:"w-5 h-5"}),trend:c.trend,color:c.color})},c.label))}),e.jsxs("div",{className:"grid grid-cols-1 lg:grid-cols-3 gap-8",children:[e.jsx(ne,{}),e.jsxs("div",{className:"space-y-6",children:[e.jsx(de,{onTrigger:u}),e.jsx(me,{})]})]}),e.jsx(xe,{reports:t,uploads:n,auditLogs:d,onReportAction:f})]})}export{Te as AdminDashboardView};
|