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 (3 loc) • 4.68 kB
JavaScript
import{a as P}from"./chunk-6B7LFLHT.js";import{a as k}from"./chunk-5MKOZDXN.js";import{a as R}from"./chunk-IKY2Z6UX.js";import{b as O}from"./chunk-W32HPWBA.js";import"./chunk-53CQV6LZ.js";import{c as C}from"./chunk-4GIODJCK.js";import{Da as o,Ia as x,Pd as H,Rd as I,ba as d,bb as s,ca as m,cb as a,db as c,eb as v,jb as y,ka as h,lb as f,oa as g,oc as _,rb as b,sb as w,tb as E,xa as u}from"./chunk-MHKTEXY5.js";import"./chunk-ENGD2CVB.js";import"./chunk-O7S4L63H.js";var T=["profilerOutput"],q=(()=>{class l{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,g(()=>{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||l)(o(I),o(P),o(O),o(h))};static \u0275cmp=x({type:l,selectors:[["p3xr-profiler"]],viewQuery:function(t,r){if(t&1&&b(T,5),t&2){let i;w(i=E())&&(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=y();a(0,"p3xr-ng-accordion",1)(1,"div",2)(2,"p3xr-ng-button",3),f("click",function(p){return d(i),r.clearProfiler(),m(p.stopPropagation())}),c(),a(3,"p3xr-ng-button",4),f("click",function(p){return d(i),r.exportProfiler(),m(p.stopPropagation())}),c()(),a(4,"div",5),v(5,"div",6,0),c()()}if(t&2){let i,n;s("collapsible",!1),u(2),s("label",(i=r.strings().intention)==null?null:i.clear),u(),s("label",(n=r.strings().intention)==null?null:n.export)}},dependencies:[_,H,C,R,k],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})}return l})();export{q as ProfilerComponent};