UNPKG

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.2 kB
import {O as Oe}from'./chunk-BITan0Uq.js';import {b3 as sr,X as Xe,f as fQ,Q,V as N,_ as _e,m as mb,aJ as jn,cj as He,bd as On,be as tn,e as aY,y as yt,bc as Ut,ba as qe,cp as q,ck as Ve,cl as Be,aM as lt,x as YT,B as Ba,k as bv,v as vf,I as IS,cr as Lv,bj as Mx,h as hv,p as pv,c as In,cs as Fv,bk as Nx,a$ as rc,b0 as Df,b1 as Ef,z as fm,A as pm,cu as AS}from'./chunk-BwlFOdbx.js';import {X}from'./chunk-DeaQoucA.js';import {L}from'./main-HNF44SV3.js';var Z=["pubsubOutput"],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,sr(()=>{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,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;")}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 \u0275fac=function(t){return new(t||l)(Xe(fQ),Xe(Oe),Xe(Q),Xe(N))};static \u0275cmp=_e({type:l,selectors:[["p3xr-pubsub"]],viewQuery:function(t,n){if(t&1&&rc(Z,5),t&2){let i;Df(i=Ef())&&(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=YT();Ba(0,"p3xr-ng-accordion",1)(1,"div",2)(2,"p3xr-ng-button",3),bv("click",function(o){return fm(i),n.clearPubSub(),pm(o.stopPropagation())}),vf(),Ba(3,"p3xr-ng-button",4),bv("click",function(o){return fm(i),n.exportPubSub(),pm(o.stopPropagation())}),vf()(),Ba(4,"div",5)(5,"div",6)(6,"mat-form-field",7)(7,"mat-label"),IS(8,"Pattern"),vf(),Ba(9,"input",8),Lv("ngModelChange",function(o){return fm(i),AS(n.pubsubPattern,o)||(n.pubsubPattern=o),pm(o)}),vf(),Mx(),vf()(),hv(10,"div",9,0),vf()();}t&2&&(pv("collapsible",false),In(2),pv("label",n.strings().intention?.clear),In(),pv("label",n.strings().intention?.export),In(6),Fv("ngModel",n.pubsubPattern),Nx());},dependencies:[mb,jn,He,On,tn,aY,yt,Ut,qe,q,Ve,Be,X,lt],styles:[`p3xr-pubsub{display:block;color:var(--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(--p3xr-list-odd-bg)}.p3xr-pubsub-pattern{padding:8px 16px} `],encapsulation:2,changeDetection:1})}return l})();export{he as PubsubComponent};