ConnectSlicerPage-ClG7ib5U.js 5.2 KB

1
  1. import{i as e}from"./rolldown-runtime-aKtaBQYM.js";import{A as t,E as n,T as r,p as i}from"./client-DJ2k8Bkd.js";import{n as a}from"./chunk-62JRHF6Z-62UIvfxE.js";import{t as o}from"./useQuery-CeIc68fT.js";import{t as s}from"./check-B5nucgMH.js";import{t as c}from"./info-LUrOYP3Y.js";import{n as l}from"./ToastContext-PXQkWm-m.js";import{t as u}from"./copy-UQ03FQV4.js";import{t as d}from"./loader-circle-s_Jy23um.js";import{t as f}from"./monitor-smartphone-BO4_pQUP.js";import{t as p}from"./printer-XRpYW3_E.js";import{n as m,r as h,t as g}from"./SlicerCaCertCard-sXxZPJUn.js";import{n as _}from"./AuthContext-BGjptJyl.js";import{n as v,t as y}from"./Card-ToEWQYwA.js";import{t as b}from"./MarkdownContent-BiChgTTR.js";var x=e(t(),1),S=r();function C(){let{t:e}=n(),{user:t,hasPermission:r}=_(),{data:s,isLoading:l,isError:u}=o({queryKey:[`vp-connect-info`,t?.id??null],queryFn:i.getConnectInfo});return(0,S.jsxs)(`div`,{className:`p-4 md:p-8 space-y-4 max-w-5xl`,children:[(0,S.jsxs)(`div`,{className:`flex items-start gap-3`,children:[(0,S.jsx)(f,{className:`w-6 h-6 text-bambu-green flex-shrink-0 mt-1`}),(0,S.jsxs)(`div`,{children:[(0,S.jsx)(`h1`,{className:`text-2xl font-bold text-white`,children:e(`connectSlicer.title`)}),(0,S.jsx)(`p`,{className:`text-sm text-bambu-gray mt-1`,children:e(`connectSlicer.subtitle`)})]})]}),l?(0,S.jsx)(`div`,{className:`flex justify-center py-8`,children:(0,S.jsx)(d,{className:`w-6 h-6 animate-spin text-bambu-green`})}):u||!s?(0,S.jsx)(y,{children:(0,S.jsx)(v,{className:`py-4 text-sm text-red-600 dark:text-red-400`,children:e(`connectSlicer.loadFailed`)})}):(0,S.jsxs)(S.Fragment,{children:[s.instructions.trim()&&(0,S.jsx)(y,{children:(0,S.jsx)(v,{className:`py-3 px-4 text-sm text-bambu-gray-light leading-relaxed`,children:(0,S.jsx)(`div`,{"data-testid":`connect-slicer-instructions`,children:(0,S.jsx)(b,{children:s.instructions})})})}),s.auth_enabled?(0,S.jsxs)(S.Fragment,{children:[(0,S.jsxs)(`ol`,{className:`text-sm text-bambu-gray list-decimal pl-5 space-y-1`,children:[(0,S.jsx)(`li`,{children:e(`connectSlicer.steps.certificate`)}),(0,S.jsx)(`li`,{children:e(`connectSlicer.steps.addPrinter`)}),(0,S.jsx)(`li`,{children:e(`connectSlicer.steps.accessCode`)})]}),(0,S.jsx)(m,{}),(0,S.jsxs)(`div`,{className:`flex items-center gap-2 pt-2`,children:[(0,S.jsx)(p,{className:`w-5 h-5 text-bambu-green`}),(0,S.jsx)(`h2`,{className:`text-lg font-semibold text-white`,children:e(`connectSlicer.printers`)})]}),s.printers.length===0?(0,S.jsx)(y,{children:(0,S.jsx)(v,{className:`py-6 text-center text-sm text-bambu-gray`,children:e(`connectSlicer.noPrinters`)})}):(0,S.jsx)(`div`,{className:`grid grid-cols-1 md:grid-cols-2 gap-4 items-start`,children:s.printers.map(e=>(0,S.jsx)(w,{printer:e},e.id))})]}):(0,S.jsx)(y,{children:(0,S.jsx)(v,{className:`py-3 px-4`,children:(0,S.jsxs)(`div`,{className:`flex items-start gap-2 text-sm`,children:[(0,S.jsx)(c,{className:`w-4 h-4 text-blue-600 dark:text-blue-400 flex-shrink-0 mt-0.5`}),(0,S.jsxs)(`div`,{children:[(0,S.jsx)(`p`,{className:`text-bambu-gray`,children:e(`connectSlicer.authOff`)}),r(`settings:read`)&&(0,S.jsx)(a,{to:`/settings?tab=virtual-printer`,className:`inline-block mt-1 text-bambu-green hover:underline`,children:e(`connectSlicer.openSettings`)})]})]})})}),(0,S.jsx)(g,{})]})]})}function w({printer:e}){let{t}=n(),r=e.mode===`library`?t(`connectSlicer.destination.library`):e.mode===`review`?t(`connectSlicer.destination.review`):e.target_printer_name?t(`connectSlicer.destination.queuePrinter`,{printer:e.target_printer_name}):t(`connectSlicer.destination.queueModel`,{model:e.model_name});return(0,S.jsx)(y,{children:(0,S.jsxs)(v,{className:`py-3 px-4 space-y-2`,children:[(0,S.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,S.jsx)(`span`,{className:`text-white font-medium`,children:e.name}),!e.running&&(0,S.jsx)(`span`,{className:`text-[10px] px-1.5 py-0.5 rounded bg-amber-100 dark:bg-amber-500/20 text-amber-700 dark:text-amber-400`,children:t(`connectSlicer.notRunning`)})]}),(0,S.jsxs)(`dl`,{className:`grid grid-cols-[auto_1fr] gap-x-3 gap-y-1 text-xs`,children:[(0,S.jsx)(T,{label:t(`connectSlicer.field.address`),value:e.address}),(0,S.jsx)(T,{label:t(`connectSlicer.field.serial`),value:e.serial}),(0,S.jsx)(`dt`,{className:`text-bambu-gray`,children:t(`connectSlicer.field.model`)}),(0,S.jsx)(`dd`,{className:`text-white`,children:e.model_name})]}),(0,S.jsx)(`p`,{className:`text-xs text-bambu-gray`,children:r}),(0,S.jsx)(`p`,{className:`text-xs text-bambu-gray`,children:e.target_printer_name?t(`connectSlicer.liveStatus`,{printer:e.target_printer_name}):t(`connectSlicer.noLiveStatus`)})]})})}function T({label:e,value:t}){let{t:r}=n(),{showToast:i}=l(),[a,o]=(0,x.useState)(!1);return(0,S.jsxs)(S.Fragment,{children:[(0,S.jsx)(`dt`,{className:`text-bambu-gray`,children:e}),(0,S.jsxs)(`dd`,{className:`flex items-center gap-1.5 min-w-0`,children:[(0,S.jsx)(`code`,{className:`font-mono text-white truncate`,children:t||`-`}),t&&(0,S.jsx)(`button`,{onClick:async()=>{await h(t)?(o(!0),setTimeout(()=>o(!1),2e3)):i(r(`slicerAccessCode.copyFailed`),`error`)},"aria-label":`${r(`slicerAccessCode.copy`)}: ${e}`,className:`p-0.5 text-bambu-gray hover:text-white flex-shrink-0`,children:a?(0,S.jsx)(s,{className:`w-3.5 h-3.5 text-bambu-green`}):(0,S.jsx)(u,{className:`w-3.5 h-3.5`})})]})]})}export{C as ConnectSlicerPage};