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
4 lines • 13.7 kB
JavaScript
import{A as e,B as t,C as n,D as r,E as i,I as a,K as o,M as s,Nt as c,T as l,Y as u,Z as d,Zt as f,_t as p,at as m,k as h,lt as g,q as ee,rt as te,t as ne,w as _,y as v}from"./i18n.store-Bn0-vXNV.js";import{t as y,x as b}from"./_plugin-vue_export-helper-CSr60JSh.js";import{t as re}from"./redis-state.store-CQLjozNg.js";import{t as ie}from"./common.store-DX84iTfT.js";import{i as x,r as ae}from"./socket.service-CjKV3Am8.js";import{C as S,D as C,i as w,w as T,x as E}from"./index-fkAw1zcW.js";import{t as D}from"./P3xrAccordion-DE_gxTXw.js";a(),c(),g();var oe={key:0,style:{padding:`12px 16px`,opacity:`0.6`}},se={key:1,style:{"white-space":`pre-wrap`,"font-family":`'Roboto Mono', monospace`,"font-size":`13px`,padding:`12px 16px`,margin:`0`}},ce={key:0,class:`p3xr-analysis-loading`},le={key:1,class:`p3xr-analysis-loading`},ue={class:`p3xr-pair-row`},de={class:`p3xr-pair-label`},fe={class:`p3xr-pair-value p3xr-mono`},pe={class:`p3xr-pair-row`},me={class:`p3xr-pair-label`},he={class:`p3xr-pair-value`},ge={class:`p3xr-pair-row`},_e={class:`p3xr-pair-label`},ve={class:`p3xr-pair-value`},ye={class:`p3xr-pair-row`},be={class:`p3xr-pair-label`},xe={class:`p3xr-pair-value p3xr-mono`},Se={class:`p3xr-pair-row`},Ce={class:`p3xr-pair-label`},we={class:`p3xr-pair-value p3xr-mono`},Te={class:`p3xr-pair-row`},Ee={class:`p3xr-pair-label`},De={class:`p3xr-pair-value p3xr-mono`},Oe={class:`p3xr-pair-row`},ke={class:`p3xr-pair-label`},Ae={class:`p3xr-pair-value p3xr-mono`},je={class:`p3xr-pair-row`},Me={class:`p3xr-pair-label`},Ne={class:`p3xr-pair-value p3xr-mono`},Pe={class:`p3xr-pair-row`},Fe={class:`p3xr-pair-label`},Ie={class:`p3xr-pair-value p3xr-mono`},Le={class:`p3xr-pair-row`},Re={class:`p3xr-pair-label`},ze={class:`p3xr-pair-value p3xr-mono`},Be={class:`p3xr-pair-row`},Ve={class:`p3xr-pair-label`},He={class:`p3xr-pair-value p3xr-mono`},Ue={class:`p3xr-pair-row`},We={class:`p3xr-pair-label`},Ge={style:{"font-weight":`500`}},Ke={class:`p3xr-analysis-sub`},qe={class:`p3xr-pair-value p3xr-mono`},Je={class:`p3xr-pair-row`},Ye={class:`p3xr-pair-label`},Xe={style:{opacity:`0.4`,"margin-right":`8px`}},Ze={class:`p3xr-mono`,style:{"font-size":`13px`}},Qe={class:`p3xr-analysis-sub`},$e={class:`p3xr-pair-value p3xr-mono`},et={class:`p3xr-pair-row`},tt={class:`p3xr-pair-label`},nt={class:`p3xr-pair-value p3xr-mono`},rt={class:`p3xr-pair-row`},it={class:`p3xr-pair-label`},at={class:`p3xr-pair-value p3xr-mono`},ot={class:`p3xr-pair-row`},st={class:`p3xr-pair-label`},ct={class:`p3xr-pair-value p3xr-mono`},O=y(s({__name:`MemoryAnalysisPage`,setup(a){let s=ne(),c=re(),g=ie(),y=n(()=>s.strings),O=n(()=>y.value?.page?.analysis||{}),k=p(null),A=p(!1),j=p(20),M=p(5e3),N=p([]),P=p(null),F=p(!1),I=p(localStorage.getItem(`p3xr-monitor-auto-doctor`)===`true`),L=null,R=p(),z=p(),B=p(),V=n(()=>c.connection?.name),H=null,U=null,W,G=[];function K(e){return e==null||isNaN(e)?`-`:e<1024?e+` B`:e<1048576?(e/1024).toFixed(1)+` KB`:e<1073741824?(e/1048576).toFixed(1)+` MB`:(e/1073741824).toFixed(2)+` GB`}function q(e){return!e||e<=0?`-`:e<60?e+`s`:e<3600?Math.floor(e/60)+`m `+e%60+`s`:e<86400?Math.floor(e/3600)+`h `+Math.floor(e%3600/60)+`m`:Math.floor(e/86400)+`d `+Math.floor(e%86400/3600)+`h`}function J(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 lt(){let e=document.body.classList.contains(`p3xr-theme-dark`),t=getComputedStyle(document.body),n=t.getPropertyValue(`--p3xr-btn-primary-bg`).trim(),r=t.getPropertyValue(`--p3xr-btn-accent-bg`).trim(),i=t.getPropertyValue(`--p3xr-btn-warn-bg`).trim();return{primary:n||(e?`#90caf9`:`#1976d2`),accent:r||(e?`#ce93d8`:`#9c27b0`),warn:i||(e?`#ef9a9a`:`#f44336`),text:e?`rgba(255,255,255,0.87)`:`rgba(0,0,0,0.87)`,grid:e?`rgba(255,255,255,0.08)`:`rgba(0,0,0,0.08)`,isDark:e}}function ut(e){let t=e.isDark;return[e.primary,e.accent,e.warn,t?`#ffb74d`:`#ff9800`,t?`#81c784`:`#4caf50`,t?`#4dd0e1`:`#00bcd4`,t?`#a1887f`:`#795548`,t?`#90a4ae`:`#607d8b`]}function dt(e,t){if(!e||t.length===0||e.offsetWidth<=0)return;e.innerHTML=``;let n=lt(),r=ut(n),i=document.createElement(`canvas`),a=window.devicePixelRatio||1,o=e.offsetWidth||500,s=o-80-8,c=s-128,l=8+t.length*28+8;i.width=o*a,i.height=l*a,i.style.width=o+`px`,i.style.height=l+`px`;let u=i.getContext(`2d`);u.scale(a,a);let d=Math.max(...t.map(e=>e.value),1);t.forEach((e,t)=>{let i=8+t*28;u.fillStyle=n.text,u.font=`12px Roboto, sans-serif`,u.textAlign=`right`,u.textBaseline=`middle`,u.fillText(e.label.length>15?e.label.substring(0,14)+`…`:e.label,120,i+12),u.fillStyle=n.grid,u.fillRect(128,i,c,24);let a=e.value/d*c;u.fillStyle=r[t%r.length],u.fillRect(128,i,a,24),u.fillStyle=n.text,u.font=`11px Roboto Mono, monospace`,u.textAlign=`left`,u.fillText(K(e.value),s+8,i+12)}),e.appendChild(i)}function Y(){dt(R.value,N.value.map(e=>({label:e.type,value:e.bytes}))),dt(z.value,(k.value?.prefixMemory||[]).slice(0,20).map(e=>({label:e.prefix,value:e.totalBytes})))}async function X(){if(!A.value){A.value=!0;try{let e=await x({action:`memory/analysis`,payload:{topN:j.value,maxScanKeys:M.value}});k.value=e.data,N.value=Object.keys(k.value.typeDistribution).map(e=>({type:e,count:k.value.typeDistribution[e],bytes:k.value.typeMemory[e]||0})).sort((e,t)=>t.bytes-e.bytes),A.value=!1,t(()=>setTimeout(()=>Y(),100))}catch(e){A.value=!1,g.generalHandleError(e)}}}async function Z(){F.value=!0;try{let e=await x({action:`memory/doctor`});P.value=e.data.text}catch(e){g.generalHandleError(e)}finally{F.value=!1}}function ft(){I.value=!I.value,localStorage.setItem(`p3xr-monitor-auto-doctor`,String(I.value)),I.value?(Z(),pt()):Q()}function pt(){Q(),L=setInterval(()=>Z(),2e3)}function Q(){L&&=(clearInterval(L),null)}function mt(){P.value&&J(P.value,`${V.value}-memory-doctor.txt`)}function ht(){if(!k.value)return;let e=O.value;J([`${e.keysScanned}: ${k.value.totalScanned} / ${k.value.dbSize}`,`${e.topN}: ${j.value}`,`${e.maxScanKeys}: ${M.value}`].join(`
`),`${V.value}-analysis-overview.txt`)}function gt(){if(!k.value)return;let e=O.value,t=k.value.memoryInfo;J([`${e.totalMemory}: ${t.usedHuman}`,`${e.rssMemory}: ${t.rssHuman}`,`${e.peakMemory}: ${t.peakHuman}`,`${e.overheadMemory}: ${K(t.overhead)}`,`${e.datasetMemory}: ${K(t.dataset)}`,`${e.luaMemory}: ${K(t.lua)}`,`${e.fragmentation}: ${t.fragRatio}x`,`${e.allocator}: ${t.allocator}`].join(`
`),`${V.value}-memory-breakdown.txt`)}function _t(){if(!k.value)return;let e=O.value,t=k.value.expirationOverview;J([`${e.withTTL}: ${t.withTTL}`,`${e.persistent}: ${t.persistent}`,`${e.avgTTL}: ${q(t.avgTTL)}`].join(`
`),`${V.value}-expiration.txt`)}function $(e,t){let n=e?.querySelector(`canvas`);if(!n)return;let r=document.createElement(`canvas`);r.width=n.width,r.height=n.height;let i=r.getContext(`2d`),a=document.body.classList.contains(`p3xr-theme-dark`);i.fillStyle=getComputedStyle(document.body).getPropertyValue(`--p3xr-body-bg`).trim()||(a?`#1e1e1e`:`#ffffff`),i.fillRect(0,0,r.width,r.height),i.drawImage(n,0,0);let o=r.toDataURL(`image/png`),s=document.createElement(`a`);s.href=o,s.download=`${V.value}-${t}.png`,s.click()}return te([B,R,z],()=>{U?.disconnect(),U=null;let e=[B.value,R.value,z.value].filter(Boolean);e.length>0&&(U=new ResizeObserver(()=>{clearTimeout(W),W=setTimeout(()=>{k.value&&Y()},150)}),e.forEach(e=>U.observe(e)))}),o(()=>{I.value&&pt(),c.connection&&X(),G.push(ae(`connections`,()=>{k.value=null,c.connection&&X()})),H=new MutationObserver(()=>{k.value&&setTimeout(()=>Y(),100)}),H.observe(document.body,{attributes:!0,attributeFilter:[`class`]})}),ee(()=>{Q(),H?.disconnect(),U?.disconnect(),G.forEach(e=>e())}),(t,n)=>(u(),r(v,null,[e(D,{title:O.value.memoryDoctor,"accordion-key":`analysis-doctor`},{actions:m(()=>[e(w,{onClick:n[0]||=e=>{ft(),e.stopPropagation()},label:y.value?.label?.autoRefresh,icon:I.value?`mdi-checkbox-marked`:`mdi-checkbox-blank-outline`},null,8,[`label`,`icon`]),I.value?i(``,!0):(u(),l(w,{key:0,onClick:n[1]||=e=>{Z(),e.stopPropagation()},label:F.value?y.value?.label?.loading:y.value?.intention?.refresh,icon:F.value?`mdi-timer-sand`:`mdi-refresh`,disabled:F.value},null,8,[`label`,`icon`,`disabled`])),e(w,{onClick:n[2]||=e=>{mt(),e.stopPropagation()},label:y.value?.intention?.export,icon:`mdi-download`},null,8,[`label`])]),default:m(()=>[P.value?(u(),r(`pre`,se,f(P.value),1)):(u(),r(`div`,oe,f(O.value.doctorNoData),1))]),_:1},8,[`title`]),n[17]||=_(`br`,null,null,-1),A.value&&!k.value?(u(),r(`div`,ce,[e(b,null,{default:m(()=>[...n[11]||=[h(`mdi-timer-sand`,-1)]]),_:1}),_(`span`,null,f(O.value.running),1)])):i(``,!0),!A.value&&!k.value?(u(),r(`div`,le,[e(b,null,{default:m(()=>[...n[12]||=[h(`mdi-chart-bar`,-1)]]),_:1}),_(`span`,null,f(O.value.noData),1)])):i(``,!0),k.value?(u(),r(`div`,{key:2,ref_key:`rootEl`,ref:B},[e(D,{title:O.value.title,"accordion-key":`analysis-controls`},{actions:m(()=>[e(w,{onClick:n[3]||=e=>{X(),e.stopPropagation()},label:A.value?O.value.running:O.value.runAnalysis,icon:A.value?`mdi-timer-sand`:`mdi-play`,disabled:A.value},null,8,[`label`,`icon`,`disabled`]),e(w,{onClick:n[4]||=e=>{ht(),e.stopPropagation()},label:y.value?.intention?.export,icon:`mdi-download`},null,8,[`label`])]),default:m(()=>[e(S,{density:`compact`,class:`pa-0`},{default:m(()=>[e(T,null,{default:m(()=>[_(`div`,ue,[_(`div`,de,f(O.value.keysScanned),1),_(`div`,fe,f(k.value.totalScanned?.toLocaleString())+` / `+f(k.value.dbSize?.toLocaleString()),1)])]),_:1}),e(C),e(T,null,{default:m(()=>[_(`div`,pe,[_(`div`,me,f(O.value.topN),1),_(`div`,he,[e(E,{modelValue:j.value,"onUpdate:modelValue":n[5]||=e=>j.value=e,modelModifiers:{number:!0},type:`number`,min:`5`,max:`100`,"hide-details":``,style:{"max-width":`100px`}},null,8,[`modelValue`])])])]),_:1}),e(C),e(T,null,{default:m(()=>[_(`div`,ge,[_(`div`,_e,f(O.value.maxScanKeys),1),_(`div`,ve,[e(E,{modelValue:M.value,"onUpdate:modelValue":n[6]||=e=>M.value=e,modelModifiers:{number:!0},type:`number`,min:`100`,max:`100000`,step:`1000`,"hide-details":``,style:{"max-width":`120px`}},null,8,[`modelValue`])])])]),_:1})]),_:1})]),_:1},8,[`title`]),n[13]||=_(`br`,null,null,-1),e(D,{title:O.value.memoryBreakdown,"accordion-key":`analysis-memory-info`},{actions:m(()=>[e(w,{onClick:n[7]||=e=>{gt(),e.stopPropagation()},label:y.value?.intention?.export,icon:`mdi-download`},null,8,[`label`])]),default:m(()=>[e(S,{density:`compact`,class:`pa-0`},{default:m(()=>[e(T,null,{default:m(()=>[_(`div`,ye,[_(`div`,be,f(O.value.totalMemory),1),_(`div`,xe,f(k.value.memoryInfo.usedHuman),1)])]),_:1}),e(C),e(T,null,{default:m(()=>[_(`div`,Se,[_(`div`,Ce,f(O.value.rssMemory),1),_(`div`,we,f(k.value.memoryInfo.rssHuman),1)])]),_:1}),e(C),e(T,null,{default:m(()=>[_(`div`,Te,[_(`div`,Ee,f(O.value.peakMemory),1),_(`div`,De,f(k.value.memoryInfo.peakHuman),1)])]),_:1}),e(C),e(T,null,{default:m(()=>[_(`div`,Oe,[_(`div`,ke,f(O.value.overheadMemory),1),_(`div`,Ae,f(K(k.value.memoryInfo.overhead)),1)])]),_:1}),e(C),e(T,null,{default:m(()=>[_(`div`,je,[_(`div`,Me,f(O.value.datasetMemory),1),_(`div`,Ne,f(K(k.value.memoryInfo.dataset)),1)])]),_:1}),e(C),e(T,null,{default:m(()=>[_(`div`,Pe,[_(`div`,Fe,f(O.value.luaMemory),1),_(`div`,Ie,f(K(k.value.memoryInfo.lua)),1)])]),_:1}),e(C),e(T,null,{default:m(()=>[_(`div`,Le,[_(`div`,Re,f(O.value.fragmentation),1),_(`div`,ze,f(k.value.memoryInfo.fragRatio)+`x`,1)])]),_:1}),e(C),e(T,null,{default:m(()=>[_(`div`,Be,[_(`div`,Ve,f(O.value.allocator),1),_(`div`,He,f(k.value.memoryInfo.allocator),1)])]),_:1})]),_:1})]),_:1},8,[`title`]),n[14]||=_(`br`,null,null,-1),e(D,{title:O.value.typeDistribution,"accordion-key":`analysis-type-dist`},{actions:m(()=>[e(w,{onClick:n[8]||=e=>{$(R.value,`type-distribution`),e.stopPropagation()},label:y.value?.intention?.export,icon:`mdi-download`},null,8,[`label`])]),default:m(()=>[_(`div`,{ref_key:`typeChartEl`,ref:R,class:`p3xr-analysis-chart`},null,512),e(S,{density:`compact`,class:`pa-0`},{default:m(()=>[(u(!0),r(v,null,d(N.value,t=>(u(),r(v,{key:t.type},[e(T,null,{default:m(()=>[_(`div`,Ue,[_(`div`,We,[_(`span`,Ge,f(t.type),1),_(`span`,Ke,f(t.count)+` keys`,1)]),_(`div`,qe,f(K(t.bytes)),1)])]),_:2},1024),e(C)],64))),128))]),_:1})]),_:1},8,[`title`]),n[15]||=_(`br`,null,null,-1),e(D,{title:O.value.prefixMemory,"accordion-key":`analysis-prefix-mem`},{actions:m(()=>[e(w,{onClick:n[9]||=e=>{$(z.value,`memory-by-prefix`),e.stopPropagation()},label:y.value?.intention?.export,icon:`mdi-download`},null,8,[`label`])]),default:m(()=>[_(`div`,{ref_key:`prefixChartEl`,ref:z,class:`p3xr-analysis-chart`},null,512),e(S,{density:`compact`,class:`pa-0`},{default:m(()=>[(u(!0),r(v,null,d(k.value.prefixMemory,(t,n)=>(u(),r(v,{key:t.prefix},[e(T,null,{default:m(()=>[_(`div`,Je,[_(`div`,Ye,[_(`span`,Xe,`#`+f(n+1),1),_(`span`,Ze,f(t.prefix),1),_(`span`,Qe,f(t.keyCount)+` keys`,1)]),_(`div`,$e,f(K(t.totalBytes)),1)])]),_:2},1024),e(C)],64))),128))]),_:1})]),_:1},8,[`title`]),n[16]||=_(`br`,null,null,-1),e(D,{title:O.value.expirationOverview,"accordion-key":`analysis-expiration`},{actions:m(()=>[e(w,{onClick:n[10]||=e=>{_t(),e.stopPropagation()},label:y.value?.intention?.export,icon:`mdi-download`},null,8,[`label`])]),default:m(()=>[e(S,{density:`compact`,class:`pa-0`},{default:m(()=>[e(T,null,{default:m(()=>[_(`div`,et,[_(`div`,tt,f(O.value.withTTL),1),_(`div`,nt,f(k.value.expirationOverview.withTTL?.toLocaleString()),1)])]),_:1}),e(C),e(T,null,{default:m(()=>[_(`div`,rt,[_(`div`,it,f(O.value.persistent),1),_(`div`,at,f(k.value.expirationOverview.persistent?.toLocaleString()),1)])]),_:1}),e(C),e(T,null,{default:m(()=>[_(`div`,ot,[_(`div`,st,f(O.value.avgTTL),1),_(`div`,ct,f(q(k.value.expirationOverview.avgTTL)),1)])]),_:1})]),_:1})]),_:1},8,[`title`])],512)):i(``,!0)],64))}}),[[`__scopeId`,`data-v-ba32756c`]]);export{O as default};