PageSourceSearch

https://procontent.renewedvision.com/js/procontent/assets/ConnectionMonitorModal-aOSOAkfx.js

js renewedvision.com collected 2026-09-24 17:48:01 UTC 10,945 bytes, 1 lines download raw bytes

1import{r as c,b as F,d as J,j as e}from"./app-BeGqF6ux.js";import{M as V,a5 as Y,a6 as q,a7 as G,a8 as K,a9 as Q,aa as X,a as j}from"./Tooltip-DYcxt1UG.js";import{P as Z}from"./index-Dkf2GVy1.js";import{d as N}from"./dayjs-BlgjZc9C.js";import{u as O,S as R,C}from"./useWorkspaceWebSocket-DiVhfRrO.js";import"./button.styles-7lPNyjJO.js";import"./iconBase-CN8tsjra.js";import"./useTranslation-kJHeU9i8.js";import"./helpers-CgA5RTdO.js";const T={docs:{label:"Docs",tagClass:"bg-blue-900 text-blue-200",chipClass:"bg-blue-100 text-blue-700 border-blue-200"},media:{label:"Media",tagClass:"bg-amber-900 text-amber-200",chipClass:"bg-amber-100 text-amber-800 border-amber-200"},organization:{label:"Organization",tagClass:"bg-emerald-900 text-emerald-200",chipClass:"bg-emerald-100 text-emerald-800 border-emerald-200"}};function oe({workspace:n,organizationUuid:u,open:i,onClose:f}){const[g,M]=c.useState([]),[S,w]=c.useState([]),[z,E]=c.useState([]),[k,$]=c.useState([]),[D,I]=c.useState(!0),[h,b]=c.useState("all"),U=c.useRef(0),y=c.useRef(null);c.useEffect(()=>{!i||!n||F.post(Z("admin.workspaces.connection-monitor-log",{organization:n.organization_id,workspace:n.id})).catch(s=>{F.isAxiosError(s)&&s.response?.status===403&&(f(),J.reload({only:["documentsViewable"],preserveScroll:!0,preserveState:!0}))})},[f,i,n?.id,n?.organization_id]);const l=O({workspaceUuid:i&&n?n.id:null,enabled:i&&!!n,channel:R.Workspace}),o=O({workspaceUuid:i&&n?n.id:null,enabled:i&&!!n,channel:R.WorkspaceMedia}),d=O({workspaceUuid:i&&n?u:null,enabled:i&&!!n&&!!u,channel:R.Organization}),p=c.useCallback((s,t,r)=>{M(a=>{const m={id:U.current++,timestamp:new Date,channel:s,type:t,payload:r};return[...a,m].slice(-200)})},[]);c.useEffect(()=>{if(!l.isConnected)return;const s=[];return s.push(l.subscribe("*",t=>{const r=t,a=r.type||r.event_type||r.event||"unknown";p("docs",String(a),t)})),s.push(l.subscribe("workspace_presence",t=>{w(t.presence||[])})),()=>{s.forEach(t=>t()),w([])}},[l.isConnected,l.subscribe,p]),c.useEffect(()=>{if(!o.isConnected)return;const s=[];return s.push(o.subscribe("*",t=>{const r=t,a=r.type||r.event_type||r.event||"unknown";p("media",String(a),t)})),s.push(o.subscribe("workspace_presence",t=>{E(t.presence||[])})),()=>{s.forEach(t=>t()),E([])}},[o.isConnected,o.subscribe,p]),c.useEffect(()=>{if(!d.isConnected)return;const s=[];return s.push(d.subscribe("*",t=>{const r=t,a=r.type||r.event_type||r.event||"unknown";p("organization",String(a),t)})),s.push(d.subscribe("org_presence",t=>{$(t.data?.clients||[])})),()=>{s.forEach(t=>t()),$([])}},[d.isConnected,d.subscribe,p]),c.useEffect(()=>{D&&y.current&&(y.current.scrollTop=y.current.scrollHeight)},[g,D]),c.useEffect(()=>{i||(M([]),w([]),E([]),$([]),b("all"),U.current=0)},[i]);const P=c.useMemo(()=>{const s=new Map,t=a=>a.client?.endsWith("_portal")?`portal:${a.client}:${a.user_id??"anon"}`:a.device_id!=null?`device:${a.device_id}`:`session:${a.client}:${a.user_id??a.display_name??"unknown"}`,r=(a,m)=>{const H=t(a),x=s.get(H);x?(x[m]=a,!x.display_name&&a.display_name&&(x.display_name=a.display_name),!x.device_id&&a.device_id&&(x.device_id=a.device_id),!x.user_id&&a.user_id&&(x.user_id=a.user_id),x.status=a.status):s.set(H,{key:H,display_name:a.display_name,device_id:a.device_id,user_id:a.user_id,client:a.client,status:a.status,docs:m==="docs"?a:null,media:m==="media"?a:null,organization:m==="organization"?a:null})};return S.forEach(a=>r(a,"docs")),z.forEach(a=>r(a,"media")),k.forEach(a=>r(a,"organization")),Array.from(s.values())},[S,z,k]),W=c.useMemo(()=>h==="all"?g:g.filter(s=>s.channel===h),[g,h]);if(!n)return null;const A=s=>{switch(s){case C.Connected:return e.jsx(j,{label:"Connected",variant:"complete"});case C.Connecting:return e.jsx(j,{label:"Connecting...",variant:"partial"});case C.Reconnecting:return e.jsx(j,{label:"Reconnecting...",variant:"partial"});case C.Error:return e.jsx(j,{label:"Error",variant:"incomplete"});default:return e.jsx(j,{label:"Disconnected",variant:"default"})}},B=s=>{try{return JSON.stringify(s,null,2)}catch{return String(s)}},v={all:g.length,docs:g.filter(s=>s.channel==="docs").length,media:g.filter(s=>s.channel==="media").length,organization:g.filter(s=>s.channel==="organization").length};return e.jsx(V,{open:i,onClose:f,header:{title:`Connection Monitor - ${n.name}`},size:"xl",children:e.jsxs("div",{className:"flex h-[70vh] flex-col gap-4 pt-4",children:[e.jsx("div",{className:"flex flex-col gap-2 rounded-lg bg-gray-100 p-3",children:e.jsxs("div",{className:"flex flex-wrap items-center gap-4",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"text-sm font-medium",children:"Docs:"}),A(l.connectionStatus),l.error&&e.jsx("span",{className:"text-xs text-red-600",children:l.error})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"text-sm font-medium",children:"Media:"}),A(o.connectionStatus),o.error&&e.jsx("span",{className:"text-xs text-red-600",children:o.error})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"text-sm font-medium",children:"Organization:"}),A(d.connectionStatus),d.error&&e.jsx("span",{className:"text-xs text-red-600",children:d.error})]}),e.jsxs("div",{className:"ml-auto text-sm text-gray-600",children:["Workspace UUID: ",n.id]})]})}),e.jsxs("div",{className:"flex flex-1 gap-4 overflow-hidden",children:[e.jsxs("div",{className:"flex w-72 flex-col rounded-lg border border-gray-200 bg-white",children:[e.jsxs("div",{className:"border-b border-gray-200 bg-gray-50 px-3 py-2",children:[e.jsxs("h3",{className:"text-sm font-semibold",children:["Presence (",P.length,")"]}),e.jsxs("p",{className:"mt-0.5 text-xs text-gray-500",children:[S.length," on docs · ",z.length," on media ·"," ",k.length," on org"]})]}),e.jsx("div",{className:"flex-1 overflow-y-auto p-2",children:P.length===0?e.jsx("p",{className:"p-2 text-center text-sm text-gray-500",children:"No members connected"}):e.jsx(Y,{delayDuration:500,children:e.jsx("div",{className:"flex flex-col gap-2",children:P.map(s=>e.jsxs(q,{children:[e.jsx(G,{asChild:!0,children:e.jsxs("div",{className:"cursor-pointer rounded border border-gray-100 bg-gray-50 p-2 text-xs hover:border-gray-300 hover:bg-gray-100",children:[e.jsxs("div",{className:"flex items-center justify-between gap-2",children:[e.jsx("span",{className:"min-w-0 flex-1 truncate font-medium",children:s.display_name||s.device_id||"Unknown"}),e.jsx("span",{className:"text-[10px] uppercase text-gray-500",children:s.client})]}),e.jsxs("div",{className:"mt-1.5 flex gap-1",children:[e.jsx(L,{channel:"docs",connected:!!s.docs}),e.jsx(L,{channel:"media",connected:!!s.media}),e.jsx(L,{channel:"organization",connected:!!s.organization})]}),e.jsxs("div",{className:"mt-1 text-gray-500",children:["Status: ",s.status]})]})}),e.jsx(K,{children:e.jsxs(Q,{side:"right",sideOffset:5,className:"z-50 max-w-xs overflow-hidden rounded-lg bg-gray-900 p-3 text-xs text-white shadow-lg",children:[e.jsxs("div",{className:"flex flex-col gap-1.5",children:[e.jsx("div",{className:"border-b border-gray-700 pb-1.5 font-semibold",children:"Member Details"}),e.jsxs("div",{className:"break-all",children:[e.jsx("span",{className:"text-gray-400",children:"Display Name:"})," ",s.display_name||"N/A"]}),e.jsxs("div",{className:"break-all",children:[e.jsx("span",{className:"text-gray-400",children:"Device ID:"})," ",s.device_id||"N/A"]}),e.jsxs("div",{className:"break-all",children:[e.jsx("span",{className:"text-gray-400",children:"User ID:"})," ",s.user_id||"N/A"]}),e.jsxs("div",{className:"break-all",children:[e.jsx("span",{className:"text-gray-400",children:"Client:"})," ",s.client]}),e.jsxs("div",{className:"border-t border-gray-700 pt-1.5",children:[e.jsx("span",{className:"text-gray-400",children:"Docs:"})," ",s.docs?`connected at ${N(s.docs.connected_at).format("HH:mm:ss")}`:"not connected"]}),e.jsxs("div",{children:[e.jsx("span",{className:"text-gray-400",children:"Media:"})," ",s.media?`connected at ${N(s.media.connected_at).format("HH:mm:ss")}`:"not connected"]}),e.jsxs("div",{children:[e.jsx("span",{className:"text-gray-400",children:"Organization:"})," ",s.organization?`connected at ${N(s.organization.connected_at).format("HH:mm:ss")}`:"not connected"]})]}),e.jsx(X,{className:"fill-gray-900"})]})})]},s.key))})})})]}),e.jsxs("div",{className:"flex flex-1 flex-col rounded-lg border border-gray-200 bg-white",children:[e.jsxs("div",{className:"flex items-center justify-between border-b border-gray-200 bg-gray-50 px-3 py-2",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("h3",{className:"text-sm font-semibold",children:"Message Log"}),e.jsxs("div",{className:"flex gap-1",children:[e.jsx(_,{label:`All (${v.all})`,active:h==="all",onClick:()=>b("all")}),e.jsx(_,{label:`Docs (${v.docs})`,active:h==="docs",onClick:()=>b("docs"),activeClass:"bg-blue-600 text-white"}),e.jsx(_,{label:`Media (${v.media})`,active:h==="media",onClick:()=>b("media"),activeClass:"bg-amber-600 text-white"}),e.jsx(_,{label:`Organization (${v.organization})`,active:h==="organization",onClick:()=>b("organization"),activeClass:"bg-emerald-600 text-white"})]})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs("label",{className:"flex items-center gap-1 text-xs",children:[e.jsx("input",{type:"checkbox",checked:D,onChange:s=>I(s.target.checked),className:"rounded"}),"Auto-scroll"]}),e.jsx("button",{onClick:()=>M([]),className:"rounded bg-gray-200 px-2 py-1 text-xs hover:bg-gray-300",children:"Clear"})]})]}),e.jsx("div",{ref:y,className:"flex-1 overflow-y-auto bg-gray-900 p-2 font-mono text-xs",children:W.length===0?e.jsx("p",{className:"p-4 text-center text-gray-500",children:l.isConnected||o.isConnected||d.isConnected?"Waiting for messages...":"Not connected"}):e.jsx("div",{className:"flex flex-col gap-1",children:W.map(s=>e.jsxs("div",{className:"rounded bg-gray-800 p-2",children:[e.jsxs("div",{className:"flex items-center gap-2 text-gray-400",children:[e.jsx("span",{children:N(s.timestamp).format("HH:mm:ss.SSS")}),e.jsx("span",{className:`rounded px-1.5 py-0.5 text-[10px] font-bold uppercase ${T[s.channel].tagClass}`,children:T[s.channel].label}),e.jsx("span",{className:"text-green-400 font-semibold",children:s.type})]}),e.jsx("pre",{className:"mt-1 overflow-x-auto whitespace-pre-wrap text-gray-300",children:B(s.payload)})]},s.id))})})]})]})]})})}function L({channel:n,connected:u}){const i=T[n];return e.jsx("span",{className:`rounded border px-1.5 py-0.5 text-[10px] font-medium uppercase ${u?i.chipClass:"border-gray-200 bg-gray-100 text-gray-400"}`,title:u?`Connected to ${i.label}`:`Not connected to ${i.label}`,children:i.label})}function _({label:n,active:u,onClick:i,activeClass:f="bg-gray-700 text-white"}){return e.jsx("button",{onClick:i,className:`rounded px-2 py-0.5 text-xs ${u?f:"bg-gray-200 text-gray-700 hover:bg-gray-300"}`,children:n})}export{oe 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.