%PDF- %PDF-
Mini Shell

Mini Shell

Direktori : /home2/rezakur1/ai.rezakurnia.com/assets/
Upload File :
Create Path :
Current File : //home2/rezakur1/ai.rezakurnia.com/assets/AdminUsagePage-BUwM-9i0.js

import{r as a,a as P,j as e}from"./index-Bu042oJp.js";import{C as H,a as I,b as $}from"./Card-TlRU04W7.js";import{B as L}from"./Button-CsqZL9Xc.js";import{S as j}from"./StatCard-CV3qBpLG.js";import{f as S,c as m}from"./format-CjhWL3Ta.js";function M({className:l="h-3.5 w-3.5"}){return e.jsxs("svg",{viewBox:"0 0 24 24",fill:"none",className:l,"aria-hidden":!0,children:[e.jsx("circle",{cx:"12",cy:"12",r:"8.5",stroke:"currentColor",strokeWidth:"1.7"}),e.jsx("path",{d:"M12 7.5V12l3 2",stroke:"currentColor",strokeWidth:"1.7",strokeLinecap:"round",strokeLinejoin:"round"})]})}function b({label:l,active:h,dir:s,onClick:f,align:c="left"}){return e.jsxs("button",{type:"button",onClick:f,className:`group inline-flex items-center gap-1 align-middle font-semibold uppercase tracking-wider transition ${h?"text-blue-300":"text-slate-500 hover:text-slate-300"}`,children:[c==="right"&&e.jsx("span",{className:"order-2",children:l}),c==="left"&&e.jsx("span",{children:l}),e.jsx("span",{className:`text-[9px] leading-none ${h?"text-blue-300":"text-slate-600 group-hover:text-slate-400"}`,children:h?s==="asc"?"▲":"▼":"↕"})]})}function W(){const[l,h]=a.useState(30),[s,f]=a.useState(null),[c,v]=a.useState(!0),[y,w]=a.useState(null),[k,q]=a.useState(""),[p,T]=a.useState(""),[i,N]=a.useState(1),[r]=a.useState(10),[n,z]=a.useState("requests"),[d,_]=a.useState("desc");a.useEffect(()=>{const t=setTimeout(()=>T(k),300);return()=>clearTimeout(t)},[k]),a.useEffect(()=>{N(1)},[l,p,n,d]);const C=a.useCallback(async()=>{v(!0);try{const t=new URLSearchParams({days:String(l),page:String(i),limit:String(r),sort:n,order:d});p.trim()&&t.set("q",p.trim());const x=await P(`/admin/usage?${t.toString()}`);f(x),w(null)}catch(t){w(t instanceof Error?t.message:"Gagal memuat")}finally{v(!1)}},[l,i,r,n,d,p]);a.useEffect(()=>{C()},[C]);const u=t=>{z(x=>x===t?(_(E=>E==="asc"?"desc":"asc"),x):(_("desc"),t))},o=(s==null?void 0:s.total)??0,B=o===0?0:(i-1)*r+1,R=Math.min(i*r,o),g={className:"h-5 w-5",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:1.7};return e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"flex flex-wrap items-center justify-end gap-3",children:[e.jsx("div",{className:"flex items-center gap-1 rounded-xl border border-white/[0.06] bg-white/[0.03] p-1",children:[7,30,90].map(t=>e.jsxs("button",{onClick:()=>h(t),className:`rounded-lg px-3.5 py-1.5 text-xs font-medium transition-colors ${l===t?"bg-white/[0.08] text-white":"text-slate-500 hover:text-slate-300"}`,children:[t," hari"]},t))}),e.jsxs("label",{className:"flex items-center gap-2 text-xs text-slate-500 md:hidden",children:[e.jsx("span",{className:"shrink-0",children:"Urutkan"}),e.jsxs("select",{value:n,onChange:t=>u(t.target.value),className:"input-solid h-9 rounded-full px-3 text-xs",children:[e.jsx("option",{value:"requests",children:"Requests"}),e.jsx("option",{value:"name",children:"Nama"}),e.jsx("option",{value:"input_tokens",children:"Input Tokens"}),e.jsx("option",{value:"last_used_at",children:"Terakhir pakai"})]})]})]}),y&&e.jsx("div",{className:"rounded-xl border border-red-500/25 bg-red-500/10 px-4 py-3 text-sm text-red-300",children:y}),c&&!s&&e.jsx("div",{className:"grid grid-cols-2 gap-3 sm:gap-4 sm:grid-cols-2 xl:grid-cols-4",children:[...Array(4)].map((t,x)=>e.jsx("div",{className:"h-24 animate-pulse rounded-2xl border border-white/[0.04] bg-white/[0.02] sm:h-28"},x))}),s&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"grid grid-cols-2 gap-3 sm:gap-4 sm:grid-cols-2 xl:grid-cols-4",children:[e.jsx(j,{label:"Total Requests",value:s.usage.requests,accent:"pink",icon:e.jsx("svg",{...g,children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M8.25 6.75h12M8.25 12h12m-12 5.25h12M3.75 6.75h.007v.008H3.75V6.75zm.375 0a.375.375 0 11-.75 0 .375.375 0 01.75 0zM3.75 12h.007v.008H3.75V12zm.375 0a.375.375 0 11-.75 0 .375.375 0 01.75 0zm-.375 5.25h.007v.008H3.75v-.008zm.375 0a.375.375 0 11-.75 0 .375.375 0 01.75 0z"})})}),e.jsx(j,{label:"Input Tokens",value:s.usage.input_tokens,accent:"fuchsia",icon:e.jsx("svg",{...g,children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M9.813 15.904L9 18.75l-.813-2.846a4.5 4.5 0 00-3.09-3.09L2.25 12l2.846-.813a4.5 4.5 0 003.09-3.09L9 5.25l.813 2.846a4.5 4.5 0 003.09 3.09L15.75 12l-2.846.813a4.5 4.5 0 00-3.09 3.09zM18.259 8.715L18 9.75l-.259-1.035a3.375 3.375 0 00-2.455-2.456L14.25 6l1.036-.259a3.375 3.375 0 002.455-2.456L18 2.25l.259 1.035a3.375 3.375 0 002.456 2.456L21.75 6l-1.035.259a3.375 3.375 0 00-2.456 2.456z"})})}),e.jsx(j,{label:"Cached Tokens",value:s.usage.cached_tokens,accent:"rose",icon:e.jsx("svg",{...g,children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M16.023 9.348h4.992v-.001M2.985 19.644v-4.992m0 0h4.992m-4.993 0l3.181 3.183a8.25 8.25 0 0013.803-3.7l4.029-1.523a.75.75 0 01.93.539v.011a.75.75 0 01-.539.93l-4.029 1.523a8.25 8.25 0 01-13.803 3.7l-3.182-3.182v-.001z"})})}),e.jsx(j,{label:"Output Tokens",value:s.usage.output_tokens,accent:"hot",icon:e.jsx("svg",{...g,children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M3.75 13.5l10.5-11.25L12 10.5h8.25L9.75 21.75 12 13.5H3.75z"})})})]}),e.jsxs(H,{children:[e.jsx(I,{title:"Rincian per Pengguna",subtitle:`Pemakaian ${l} hari terakhir`,action:e.jsx("input",{type:"search",placeholder:"Cari nama / email…",value:k,onChange:t=>q(t.target.value),className:"input-solid w-full sm:w-56"})}),e.jsx($,{className:"p-0",children:s.detail.length===0?e.jsx("div",{className:"px-5 py-10 text-center text-sm text-slate-500",children:"Belum ada pemakaian pada rentang ini."}):e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"divide-y divide-white/[0.04] md:hidden",children:s.detail.map(t=>e.jsxs("div",{className:"p-4",children:[e.jsx("p",{className:"font-medium text-white",children:t.name}),e.jsx("p",{className:"truncate text-xs text-slate-500",children:t.email}),e.jsxs("p",{className:"mt-1 flex items-center gap-1.5 text-[10px] tabular-nums text-slate-500",children:[e.jsx(M,{className:"text-slate-500"}),"Terakhir pakai: ",S(t.last_used_at)]}),e.jsxs("div",{className:"mt-2.5 grid grid-cols-2 gap-2 text-xs",children:[e.jsxs("div",{className:"rounded-lg border border-white/[0.06] bg-white/[0.02] px-2.5 py-1.5",children:[e.jsx("p",{className:"text-[10px] text-slate-500",children:"Requests"}),e.jsx("p",{className:"font-semibold tabular-nums text-slate-200",children:t.requests})]}),e.jsxs("div",{className:"rounded-lg border border-white/[0.06] bg-white/[0.02] px-2.5 py-1.5",children:[e.jsx("p",{className:"text-[10px] text-slate-500",children:"Input Tokens"}),e.jsx("p",{className:"font-medium tabular-nums text-slate-300",children:m(t.input_tokens)})]}),e.jsxs("div",{className:"rounded-lg border border-white/[0.06] bg-white/[0.02] px-2.5 py-1.5",children:[e.jsx("p",{className:"text-[10px] text-slate-500",children:"Cached Tokens"}),e.jsx("p",{className:"font-medium tabular-nums text-slate-400",children:m(t.cached_tokens)})]}),e.jsxs("div",{className:"rounded-lg border border-white/[0.06] bg-white/[0.02] px-2.5 py-1.5",children:[e.jsx("p",{className:"text-[10px] text-slate-500",children:"Output Tokens"}),e.jsx("p",{className:"font-medium tabular-nums text-slate-300",children:m(t.output_tokens)})]})]})]},t.user_id))}),e.jsx("div",{className:"hidden overflow-x-auto md:block",children:e.jsxs("table",{className:"w-full min-w-[680px] text-left text-sm",children:[e.jsx("thead",{children:e.jsxs("tr",{className:"border-b border-white/[0.06] bg-white/[0.02] text-[11px] uppercase tracking-wider text-slate-500",children:[e.jsx("th",{className:"px-4 py-2.5 font-semibold",children:e.jsx(b,{label:"Pengguna",active:n==="name",dir:d,onClick:()=>u("name")})}),e.jsx("th",{className:"px-3 py-2.5 text-right font-semibold",children:e.jsx(b,{label:"Requests",active:n==="requests",dir:d,align:"right",onClick:()=>u("requests")})}),e.jsx("th",{className:"px-3 py-2.5 text-right font-semibold",children:e.jsx(b,{label:"Input",active:n==="input_tokens",dir:d,align:"right",onClick:()=>u("input_tokens")})}),e.jsx("th",{className:"px-3 py-2.5 text-right font-semibold text-slate-500",children:"Cached"}),e.jsx("th",{className:"px-3 py-2.5 text-right font-semibold text-slate-500",children:"Output"}),e.jsx("th",{className:"px-4 py-2.5 text-right font-semibold",children:e.jsx(b,{label:"Terakhir pakai",active:n==="last_used_at",dir:d,align:"right",onClick:()=>u("last_used_at")})})]})}),e.jsx("tbody",{children:s.detail.map(t=>e.jsxs("tr",{className:"border-b border-white/[0.04] align-middle transition-colors last:border-0 hover:bg-white/[0.02]",children:[e.jsxs("td",{className:"px-4 py-2.5",children:[e.jsx("p",{className:"font-medium text-white",children:t.name}),e.jsx("p",{className:"text-[11px] text-slate-500",children:t.email})]}),e.jsx("td",{className:"px-3 py-2.5 text-right font-medium tabular-nums text-slate-300",children:t.requests}),e.jsx("td",{className:"px-3 py-2.5 text-right font-medium tabular-nums whitespace-nowrap text-slate-300",children:m(t.input_tokens)}),e.jsx("td",{className:"px-3 py-2.5 text-right font-medium tabular-nums whitespace-nowrap text-slate-400",children:m(t.cached_tokens)}),e.jsx("td",{className:"px-3 py-2.5 text-right font-medium tabular-nums whitespace-nowrap text-slate-400",children:m(t.output_tokens)}),e.jsx("td",{className:"px-4 py-2.5 text-right",children:e.jsxs("span",{className:"inline-flex items-center gap-1 text-[10px] tabular-nums text-slate-500",children:[e.jsx(M,{}),S(t.last_used_at)]})})]},t.user_id))})]})}),o>r&&e.jsxs("div",{className:"flex items-center justify-between gap-3 border-t border-white/[0.04] px-4 py-3",children:[e.jsxs("p",{className:"text-xs text-slate-500",children:["Menampilkan ",B,"–",R," dari ",o," pengguna · Halaman"," ",i," dari ",Math.max(1,Math.ceil(o/r))]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(L,{variant:"ghost",size:"sm",disabled:i<=1||c,onClick:()=>N(t=>Math.max(1,t-1)),children:"Sebelumnya"}),e.jsx(L,{variant:"ghost",size:"sm",disabled:i>=Math.ceil(o/r)||c,onClick:()=>N(t=>t+1),children:"Berikutnya"})]})]})]})})]})]})]})}export{W as default};

Zerion Mini Shell 1.0