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.68 kB
JavaScript
import"./main-OCJB5534.js";import{Bi as ym,Di as wf,Dn as _y,Dt as Qe,Gn as dT,In as by,It as Sn,Lt as Sy,Pi as xf,Pn as bm,T as Ee,Vn as cr,_ as Cf,gt as O,in as Wa,mn as YQ,t as $Y,w as Eb,wr as lc}from"./chunk-CHqDEyfr.js";import{t as Q}from"./chunk-CyniViPG.js";import"./chunk-CNSP-oVC.js";import{r as yt}from"./chunk-CGgWGJ3E.js";import{t as lt}from"./chunk-Cc4dc3EH2.js";import{t as X}from"./chunk-BfFSlGI12.js";import{t as Oe}from"./chunk-HfFSBPyS2.js";var T=[`profilerOutput`];var q=(()=>{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,cr(()=>{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 ɵfac=function(t){return new(t||s)(Qe(YQ),Qe(Oe),Qe(Q),Qe(O))};static ɵcmp=Ee({type:s,selectors:[[`p3xr-profiler`]],viewQuery:function(t,r){if(t&1&&lc(T,5),t&2){let i;Cf(i=xf())&&(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=dT();Wa(0,`p3xr-ng-accordion`,1)(1,`div`,2)(2,`p3xr-ng-button`,3),Sy(`click`,function(p){return ym(i),r.clearProfiler(),bm(p.stopPropagation())}),wf(),Wa(3,`p3xr-ng-button`,4),Sy(`click`,function(p){return ym(i),r.exportProfiler(),bm(p.stopPropagation())}),wf()(),Wa(4,`div`,5),_y(5,`div`,6,0),wf()()}t&2&&(by(`collapsible`,!1),Sn(2),by(`label`,r.strings().intention?.clear),Sn(),by(`label`,r.strings().intention?.export))},dependencies:[Eb,$Y,yt,X,lt],styles:[`p3xr-profiler{display:block;color:var(--%NS%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(--%NS%p3xr-list-odd-bg)}
`],encapsulation:2,changeDetection:1})}return s})();export{q as ProfilerComponent};