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

4 lines (3 loc) • 5.38 kB
import{a as N}from"./chunk-QXHBG7MZ.js";import{a as W}from"./chunk-PVS3PBYN.js";import{a as A}from"./chunk-YPZ33LVT.js";import{b as z}from"./chunk-AN7C4JCR.js";import{c as $,d as B}from"./chunk-5ONGW7JF.js";import{a as O,i as R,j as T}from"./chunk-AN3YSLKY.js";import"./chunk-6J2GCUHA.js";import{b as k,f as F,j as L,v as V}from"./chunk-ICUC3WIE.js";import"./chunk-VMTBY4VN.js";import{c as D}from"./chunk-HFDIHHHN.js";import{Bb as P,Da as a,Hb as _,Ia as x,Ib as C,Jb as H,Pd as S,Rd as j,ba as p,bb as d,ca as c,cb as u,db as s,eb as y,jb as w,ka as g,lb as m,oa as f,oc as I,rb as v,sb as E,tb as M,xa as b}from"./chunk-KQUCMSSK.js";import"./chunk-FCVD6SGJ.js";import{h}from"./chunk-O7S4L63H.js";var Q=["pubsubOutput"],be=(()=>{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,f(()=>{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 h(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)(a(j),a(N),a(z),a(g))};static \u0275cmp=x({type:l,selectors:[["p3xr-pubsub"]],viewQuery:function(t,n){if(t&1&&v(Q,5),t&2){let i;E(i=M())&&(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=w();u(0,"p3xr-ng-accordion",1)(1,"div",2)(2,"p3xr-ng-button",3),m("click",function(o){return p(i),n.clearPubSub(),c(o.stopPropagation())}),s(),u(3,"p3xr-ng-button",4),m("click",function(o){return p(i),n.exportPubSub(),c(o.stopPropagation())}),s()(),u(4,"div",5)(5,"div",6)(6,"mat-form-field",7)(7,"mat-label"),P(8,"Pattern"),s(),u(9,"input",8),H("ngModelChange",function(o){return p(i),C(n.pubsubPattern,o)||(n.pubsubPattern=o),c(o)}),s()()(),y(10,"div",9,0),s()()}if(t&2){let i,r;d("collapsible",!1),b(2),d("label",(i=n.strings().intention)==null?null:i.clear),b(),d("label",(r=n.strings().intention)==null?null:r.export),b(6),_("ngModel",n.pubsubPattern)}},dependencies:[I,V,k,F,L,S,D,T,R,O,B,$,A,W],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})}return l})();export{be as PubsubComponent};