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
3 lines • 4.56 kB
JavaScript
import {O as Oe}from'./chunk-BITan0Uq.js';import {b3 as sr,X as Xe,f as fQ,Q,V as N$1,_ as _e,m as mb,e as aY,y as yt,aM as lt,x as YT,B as Ba,k as bv,v as vf,h as hv,p as pv,c as In,a$ as rc,b0 as Df,b1 as Ef,z as fm,A as pm}from'./chunk-BwlFOdbx.js';import {X}from'./chunk-DeaQoucA.js';import'./main-HNF44SV3.js';var T=["profilerOutput"],N=(()=>{class s{i18n;data;state;ngZone;profilerOutputRef;strings;maxDomEntries=66;entryIndex=0;sub;resizeFn=null;constructor(e,t,r,i){this.i18n=e,this.data=t,this.state=r,this.ngZone=i,this.strings=this.i18n.strings,sr(()=>{this.state.consoleDrawerOpen(),setTimeout(()=>this.recalcHeight(),160);});}ngOnInit(){setTimeout(()=>{this.renderExistingEntries(),this.sub=this.data.profilerEntry$.subscribe(e=>this.renderEntry(e));});}ngAfterViewInit(){document.body.classList.add("p3xr-no-main-scroll"),this.ngZone.runOutsideAngular(()=>{this.resizeFn=()=>this.recalcHeight(),window.addEventListener("resize",this.resizeFn),setTimeout(()=>{this.recalcHeight();let e=this.profilerOutputRef?.nativeElement;e&&(e.scrollTop=e.scrollHeight);},50);});}ngOnDestroy(){document.body.classList.remove("p3xr-no-main-scroll"),this.sub?.unsubscribe(),this.resizeFn&&window.removeEventListener("resize",this.resizeFn);}clearProfiler(){this.data.clearProfiler(),this.entryIndex=0,this.profilerOutputRef?.nativeElement&&(this.profilerOutputRef.nativeElement.innerHTML="");}exportProfiler(){let e=this.state.connection()?.name||"redis",t=this.data.profilerEntries.map(r=>`${r.fullTimestamp} [${r.database} ${r.source}] ${r.command}`);this.downloadText(t.join(`
`),`${e}-profiler-export.txt`);}renderExistingEntries(){let e=this.profilerOutputRef?.nativeElement;if(!e)return;let t=this.data.profilerEntries,r=Math.max(0,t.length-this.maxDomEntries);this.entryIndex=r;for(let i=r;i<t.length;i++)this.renderEntry(t[i]);e.scrollTop=e.scrollHeight;}renderEntry(e){let t=this.profilerOutputRef?.nativeElement;if(!t)return;let r=this.entryIndex++%2===1?" p3xr-profiler-entry-odd":"";for(t.insertAdjacentHTML("beforeend",`<div class="p3xr-profiler-entry${r}"><span style="opacity:0.5">${this.escapeHtml(e.displayTime)}</span> <span style="opacity:0.7">[${this.escapeHtml(e.database)} ${this.escapeHtml(e.source)}]</span> ${this.escapeHtml(e.command)}</div>`);t.children.length>this.maxDomEntries;)t.removeChild(t.firstChild);t.scrollTop=t.scrollHeight;}recalcHeight(){let e=this.profilerOutputRef?.nativeElement;if(!e)return;let t=e.getBoundingClientRect(),r=document.getElementById("p3xr-layout-footer-container")?.offsetHeight||48,i=this.getDrawerHeight(),n=window.innerHeight-t.top-r-i-8;e.style.height=Math.max(n,100)+"px";}getDrawerHeight(){let e=getComputedStyle(document.documentElement).getPropertyValue("--p3xr-console-drawer-height-active").trim();return e.endsWith("vh")?Math.round(parseFloat(e)/100*window.innerHeight):e.endsWith("px")?parseFloat(e):0}escapeHtml(e){return e.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""")}downloadText(e,t){let r=new Blob([e],{type:"text/plain"}),i=URL.createObjectURL(r),n=document.createElement("a");n.href=i,n.download=t,n.click(),URL.revokeObjectURL(i);}static \u0275fac=function(t){return new(t||s)(Xe(fQ),Xe(Oe),Xe(Q),Xe(N$1))};static \u0275cmp=_e({type:s,selectors:[["p3xr-profiler"]],viewQuery:function(t,r){if(t&1&&rc(T,5),t&2){let i;Df(i=Ef())&&(r.profilerOutputRef=i.first);}},decls:7,vars:3,consts:[["profilerOutput",""],["title","","accordionKey","profiler-monitor",3,"collapsible"],["actions",""],["mdIcon","backspace",3,"click","label"],["mdIcon","download",3,"click","label"],["content",""],[1,"p3xr-profiler-output"]],template:function(t,r){if(t&1){let i=YT();Ba(0,"p3xr-ng-accordion",1)(1,"div",2)(2,"p3xr-ng-button",3),bv("click",function(p){return fm(i),r.clearProfiler(),pm(p.stopPropagation())}),vf(),Ba(3,"p3xr-ng-button",4),bv("click",function(p){return fm(i),r.exportProfiler(),pm(p.stopPropagation())}),vf()(),Ba(4,"div",5),hv(5,"div",6,0),vf()();}t&2&&(pv("collapsible",false),In(2),pv("label",r.strings().intention?.clear),In(),pv("label",r.strings().intention?.export));},dependencies:[mb,aY,yt,X,lt],styles:[`p3xr-profiler{display:block;color:var(--mat-app-text-color, inherit)}.p3xr-profiler-output{font-family:Roboto Mono,monospace;font-size:13px;overflow-y:auto;word-break:break-all;white-space:normal}.p3xr-profiler-entry{padding:6px 16px;word-break:break-all;white-space:normal}.p3xr-profiler-entry-odd{background-color:var(--p3xr-list-odd-bg)}
`],encapsulation:2,changeDetection:1})}return s})();export{N as ProfilerComponent};