PageSourceSearch

https://javawhiskers.co.uk/assets/AdminMediaLibrary-Cg6_k34N.js

js javawhiskers.co.uk collected 2026-10-05 01:09:47 UTC 3,728 bytes, 1 lines download raw bytes

1import{r,j as t}from"./vendor-react-Bt3w6bFX.js";import{supabase as i}from"./client-Dq1sIdUg.js";import{B as d}from"./button-Df1CPV9Y.js";import{I as C}from"./input-CV5g6U6p.js";import{b as z}from"./index-B3NwW_rO.js";import{l as j}from"./adminLog-CbuPSbPm.js";import{aW as S,ac as B,as as A,a0 as L,aV as k}from"./vendor-icons-Bt7APd9S.js";import"./vendor-supabase-B8wCO4e6.js";const l="page-images";function R(){const[o,v]=r.useState([]),[m,y]=r.useState(""),[u,p]=r.useState(!1),{toast:s}=z(),n=async()=>{const{data:e,error:a}=await i.storage.from(l).list("",{limit:1e3,sortBy:{column:"created_at",order:"desc"}});if(a){s({title:"Could not load media",description:a.message,variant:"destructive"});return}v((e||[]).filter(c=>c.id))};r.useEffect(()=>{n()},[]);const N=async e=>{if(e?.length){p(!0);for(const a of Array.from(e)){const c=a.name.replace(/[^a-zA-Z0-9._-]/g,"_"),g=`${Date.now()}-${c}`,{error:h}=await i.storage.from(l).upload(g,a,{upsert:!1});h?s({title:"Upload failed",description:h.message,variant:"destructive"}):j("upload","media",g,{size:a.size})}p(!1),s({title:"Upload complete"}),n()}},b=async e=>{if(!confirm("Delete file?"))return;const{error:a}=await i.storage.from(l).remove([e]);if(a){s({title:"Could not delete",description:a.message,variant:"destructive"});return}j("delete","media",e),s({title:"Deleted"}),n()},f=e=>i.storage.from(l).getPublicUrl(e).data.publicUrl,w=async e=>{await navigator.clipboard.writeText(f(e)),s({title:"URL copied"})},x=o.filter(e=>e.name.toLowerCase().includes(m.toLowerCase())),U=o.reduce((e,a)=>e+(a.metadata?.size||0),0);return t.jsxs("div",{className:"space-y-6",children:[t.jsxs("div",{className:"flex items-center justify-between",children:[t.jsxs("div",{children:[t.jsx("h1",{className:"font-display text-3xl text-foreground",children:"Media Library"}),t.jsxs("p",{className:"text-muted-foreground text-sm",children:[o.length," files · ",(U/1024/1024).toFixed(1)," MB"]})]}),t.jsxs("label",{children:[t.jsx("input",{type:"file",multiple:!0,accept:"image/*",className:"hidden",onChange:e=>N(e.target.files)}),t.jsx(d,{asChild:!0,disabled:u,children:t.jsxs("span",{children:[t.jsx(S,{className:"h-4 w-4 mr-1"}),u?"Uploading...":"Upload"]})})]})]}),t.jsxs("div",{className:"relative max-w-md",children:[t.jsx(B,{className:"h-4 w-4 absolute left-3 top-1/2 -translate-y-1/2 text-muted-foreground"}),t.jsx(C,{value:m,onChange:e=>y(e.target.value),placeholder:"Search filename...",className:"pl-9"})]}),t.jsxs("div",{className:"grid grid-cols-2 md:grid-cols-4 lg:grid-cols-6 gap-3",children:[x.map(e=>t.jsxs("div",{className:"group relative bg-card border border-border rounded-lg overflow-hidden",children:[t.jsx("div",{className:"aspect-square bg-muted flex items-center justify-center",children:e.metadata?.mimetype?.startsWith("image/")?t.jsx("img",{src:f(e.name),alt:e.name,loading:"lazy",className:"w-full h-full object-cover"}):t.jsx(A,{className:"h-8 w-8 text-muted-foreground"})}),t.jsxs("div",{className:"p-2",children:[t.jsx("p",{className:"text-xs text-foreground truncate",title:e.name,children:e.name}),t.jsxs("p",{className:"text-[10px] text-muted-foreground",children:[((e.metadata?.size||0)/1024).toFixed(0)," KB"]})]}),t.jsxs("div",{className:"absolute inset-0 bg-background/80 opacity-0 group-hover:opacity-100 transition-opacity flex items-center justify-center gap-2",children:[t.jsx(d,{size:"sm",variant:"outline",onClick:()=>w(e.name),children:t.jsx(L,{className:"h-3 w-3"})}),t.jsx(d,{size:"sm",variant:"outline",onClick:()=>b(e.name),children:t.jsx(k,{className:"h-3 w-3 text-destructive"})})]})]},e.name)),x.length===0&&t.jsx("p",{className:"text-muted-foreground col-span-full text-sm",children:"No files match."})]})]})}export{R 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.