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 • 5.45 kB
JavaScript
import{d as L}from"./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,P as HT,Pi as xf,Pn as bm,Qr as qC,T as Ee,Vn as cr,Xt as Uy,_ as Cf,ei as qT,gt as O,in as Wa,mn as YQ,rn as WC,s as $y,t as $Y,w as Eb,wr as lc}from"./chunk-CHqDEyfr.js";import{t as Q}from"./chunk-CyniViPG.js";import{C as xn,a as He,i as Gn,y as on}from"./chunk-B_FU7ynV.js";import"./chunk-CNSP-oVC.js";import{r as yt}from"./chunk-CGgWGJ3E.js";import"./chunk-CFyh5uM7.js";import{d as qe,i as Qt,o as U}from"./chunk-CLjqwtZV.js";import{i as ze,t as Oe}from"./chunk-BYtjyP-K.js";import{t as lt}from"./chunk-Cc4dc3EH2.js";import{t as X}from"./chunk-BfFSlGI12.js";import{t as Oe$1}from"./chunk-HfFSBPyS2.js";var Z=[`pubsubOutput`];var he=(()=>{class l{i18n;data;state;ngZone;pubsubOutputRef;strings;get pubsubPattern(){return this.data.pubsubPattern}set pubsubPattern(e){this.data.pubsubPattern=e}maxDomEntries=66;entryIndex=0;sub;resizeFn=null;constructor(e,t,n,i){this.i18n=e,this.data=t,this.state=n,this.ngZone=i,this.strings=this.i18n.strings,cr(()=>{this.state.consoleDrawerOpen(),setTimeout(()=>this.recalcHeight(),160)})}ngOnInit(){setTimeout(()=>{this.renderExistingEntries(),this.sub=this.data.pubsubEntry$.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.pubsubOutputRef?.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)}restartPubSub(){return L(this,null,function*(){yield this.data.restartPubSub()})}clearPubSub(){this.data.clearPubSub(),this.entryIndex=0,this.pubsubOutputRef?.nativeElement&&(this.pubsubOutputRef.nativeElement.innerHTML=``)}exportPubSub(){let e=this.state.connection()?.name||`redis`,t=this.data.pubsubEntries.map(n=>`${n.fullTimestamp} ${n.channel} ${n.message}`);this.downloadText(t.join(`
`),`${e}-pubsub-export.txt`)}renderExistingEntries(){let e=this.pubsubOutputRef?.nativeElement;if(!e)return;let t=this.data.pubsubEntries,n=Math.max(0,t.length-this.maxDomEntries);this.entryIndex=n;for(let i=n;i<t.length;i++)this.renderEntry(t[i]);e.scrollTop=e.scrollHeight}renderEntry(e){let t=this.pubsubOutputRef?.nativeElement;if(!t)return;let n=this.entryIndex++%2===1?` p3xr-pubsub-entry-odd`:``;for(t.insertAdjacentHTML(`beforeend`,`<div class="p3xr-pubsub-entry${n}"><span style="opacity:0.5">${this.escapeHtml(e.displayTime)}</span> <strong>${this.escapeHtml(e.channel)}</strong> ${this.escapeHtml(e.message)}</div>`);t.children.length>this.maxDomEntries;)t.removeChild(t.firstChild);t.scrollTop=t.scrollHeight}recalcHeight(){let e=this.pubsubOutputRef?.nativeElement;if(!e)return;let t=e.getBoundingClientRect(),n=document.getElementById(`p3xr-layout-footer-container`)?.offsetHeight||48,i=this.getDrawerHeight(),r=window.innerHeight-t.top-n-i-8;e.style.height=Math.max(r,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 n=new Blob([e],{type:`text/plain`}),i=URL.createObjectURL(n),r=document.createElement(`a`);r.href=i,r.download=t,r.click(),URL.revokeObjectURL(i)}static ɵfac=function(t){return new(t||l)(Qe(YQ),Qe(Oe$1),Qe(Q),Qe(O))};static ɵcmp=Ee({type:l,selectors:[[`p3xr-pubsub`]],viewQuery:function(t,n){if(t&1&&lc(Z,5),t&2){let i;Cf(i=xf())&&(n.pubsubOutputRef=i.first)}},decls:12,vars:4,consts:[[`pubsubOutput`,``],[`title`,``,`accordionKey`,`profiler-pubsub`,3,`collapsible`],[`actions`,``],[`mdIcon`,`backspace`,3,`click`,`label`],[`mdIcon`,`download`,3,`click`,`label`],[`content`,``],[1,`p3xr-pubsub-pattern`],[`subscriptSizing`,`dynamic`,2,`width`,`100%`],[`matInput`,``,`placeholder`,`*`,3,`ngModelChange`,`ngModel`],[1,`p3xr-pubsub-output`]],template:function(t,n){if(t&1){let i=dT();Wa(0,`p3xr-ng-accordion`,1)(1,`div`,2)(2,`p3xr-ng-button`,3),Sy(`click`,function(o){return ym(i),n.clearPubSub(),bm(o.stopPropagation())}),wf(),Wa(3,`p3xr-ng-button`,4),Sy(`click`,function(o){return ym(i),n.exportPubSub(),bm(o.stopPropagation())}),wf()(),Wa(4,`div`,5)(5,`div`,6)(6,`mat-form-field`,7)(7,`mat-label`),HT(8,`Pattern`),wf(),Wa(9,`input`,8),$y(`ngModelChange`,function(o){return ym(i),qT(n.pubsubPattern,o)||(n.pubsubPattern=o),bm(o)}),wf(),WC(),wf()(),_y(10,`div`,9,0),wf()()}t&2&&(by(`collapsible`,!1),Sn(2),by(`label`,n.strings().intention?.clear),Sn(),by(`label`,n.strings().intention?.export),Sn(6),Uy(`ngModel`,n.pubsubPattern),qC())},dependencies:[Eb,Gn,He,xn,on,$Y,yt,Qt,qe,U,Oe,ze,X,lt],styles:[`p3xr-pubsub{display:block;color:var(--%NS%mat-app-text-color, inherit)}.p3xr-pubsub-output{font-family:Roboto Mono,monospace;font-size:13px;overflow-y:auto;word-break:break-all;white-space:normal}.p3xr-pubsub-entry{padding:6px 16px;word-break:break-all;white-space:normal}.p3xr-pubsub-entry-odd{background-color:var(--%NS%p3xr-list-odd-bg)}.p3xr-pubsub-pattern{padding:8px 16px}
`],encapsulation:2,changeDetection:1})}return l})();export{he as PubsubComponent};