UNPKG

p3x-redis-ui-material

Version:

💿 P3X Redis UI triple frontend — Angular + React/MUI + Vue/Vuetify with 54 languages, 7 themes, Socket.IO, desktop notifications, and full feature parity

2 lines • 3.24 kB
import{i as e}from"./rolldown-runtime-aKtaBQYM.js";import{F as t,it as n,t as r}from"./Box-CN-vzd2M.js";import{n as i,o as a}from"./i18n.store-cEFY1tQT.js";import{t as o}from"./Download-TUclGRoE.js";import{r as s}from"./redis-state.store-DegzWxJZ.js";import{A as c,r as l}from"./index-B6abhTyw.js";import{t as u}from"./P3xrAccordion-DoDeoAbj.js";import{clearProfiler as d,onProfilerEntry as f,useMonitoringDataStore as p}from"./monitoring-data.store-BzyWar1_.js";var m=e(a()),h=n(),g=66,_=48;function v(e){return e.replace(/&/g,`&amp;`).replace(/</g,`&lt;`).replace(/>/g,`&gt;`).replace(/"/g,`&quot;`)}function y(e,t){let n=new Blob([e],{type:`text/plain`}),r=URL.createObjectURL(n),i=document.createElement(`a`);i.href=r,i.download=t,i.click(),URL.revokeObjectURL(r)}function b(){let e=i(e=>e.strings),n=s(e=>e.connection),a=t().palette.mode===`dark`,b=(0,m.useRef)(null),x=(0,m.useRef)(0),S=a?`rgba(255,255,255,0.05)`:`rgba(0,0,0,0.04)`,C=(0,m.useCallback)(e=>{let t=b.current;if(!t)return;let n=x.current++%2==1,r=document.createElement(`div`);for(n&&(r.style.backgroundColor=S),r.style.padding=`6px 16px`,r.style.wordBreak=`break-all`,r.style.whiteSpace=`normal`,r.innerHTML=`<span style="opacity:0.5">${v(e.displayTime)}</span> <span style="opacity:0.7">[${v(e.database)} ${v(e.source)}]</span> ${v(e.command)}`,t.appendChild(r);t.children.length>g;)t.removeChild(t.firstChild);requestAnimationFrame(()=>{t.scrollTop=t.scrollHeight})},[S]),w=(0,m.useCallback)(()=>{let e=b.current;if(!e)return;let t=e.getBoundingClientRect(),n=getComputedStyle(document.documentElement).getPropertyValue(`--p3xr-console-drawer-height-active`).trim(),r=0;n.endsWith(`vh`)?r=Math.round(parseFloat(n)/100*window.innerHeight):n.endsWith(`px`)&&(r=parseFloat(n));let i=window.innerHeight-t.top-_-r-8;e.style.height=Math.max(i,100)+`px`},[]);(0,m.useEffect)(()=>{let e=setTimeout(()=>w(),160);return()=>clearTimeout(e)},[s(e=>e.consoleDrawerOpen),w]),(0,m.useEffect)(()=>{document.body.classList.add(`p3xr-no-main-scroll`),w();let e=b.current;e&&(e.innerHTML=``);let t=p.getState().profilerEntries,n=Math.max(0,t.length-g);x.current=n;for(let e=n;e<t.length;e++)C(t[e]);e&&requestAnimationFrame(()=>{e.scrollTop=e.scrollHeight});let r=f(C),i=()=>w();return window.addEventListener(`resize`,i),()=>{document.body.classList.remove(`p3xr-no-main-scroll`),r(),window.removeEventListener(`resize`,i)}},[C,w]);let T=(0,m.useCallback)(()=>{d(),x.current=0,b.current&&(b.current.innerHTML=``)},[]),E=(0,m.useCallback)(()=>{let e=n?.name||`redis`;y(p.getState().profilerEntries.map(e=>`${e.fullTimestamp} [${e.database} ${e.source}] ${e.command}`).join(` `),`${e}-profiler-export.txt`)},[n]);return(0,h.jsx)(r,{children:(0,h.jsx)(u,{title:``,accordionKey:`profiler-monitor`,collapsible:!1,actions:(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)(l,{icon:(0,h.jsx)(c,{sx:{fontSize:18}}),label:e?.intention?.clear,color:`inherit`,onClick:e=>{e.stopPropagation(),T()}}),(0,h.jsx)(l,{icon:(0,h.jsx)(o,{sx:{fontSize:18}}),label:e?.intention?.export,color:`inherit`,onClick:e=>{e.stopPropagation(),E()}})]}),children:(0,h.jsx)(r,{ref:b,sx:{fontFamily:`'Roboto Mono', monospace`,fontSize:13,overflowY:`auto`,wordBreak:`break-all`,whiteSpace:`normal`}})})})}export{b as default};