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

2 lines (1 loc) • 4.59 kB
import{d}from"./chunk-OTFMRDKW.js";import{c as u}from"./chunk-3QQZQR3D.js";import{c as y,e as v}from"./chunk-TEXSADK3.js";import{a as f,b as l}from"./chunk-AN7C4JCR.js";import{Rd as m,U as g,Y as i,d as s}from"./chunk-KQUCMSSK.js";import{h as c}from"./chunk-O7S4L63H.js";var b=(()=>{class a{router;constructor(t){this.router=t}navigateTo(t,e){switch(t){case"info":this.router.navigate(["/info"]);break;case"settings":this.router.navigate(["/settings"]);break;case"monitoring":this.router.navigate(["/monitoring"]);break;case"search":this.router.navigate(["/search"]);break;case"database.statistics":case"main.statistics":this.router.navigate(["/database/statistics"]);break;case"database.key":case"main.key":this.router.navigate(["/database/key",e?.key??""]);break;default:console.warn(`[NavigationService] Unknown state: ${t}`),this.router.navigate(["/settings"])}}get currentUrl(){return this.router.url}getParam(t){let e=this.router.url;return t==="key"&&e.startsWith("/database/key/")?decodeURIComponent(e.substring(14)):null}static \u0275fac=function(e){return new(e||a)(i(d))};static \u0275prov=g({token:a,factory:a.\u0275fac,providedIn:"root"})}return a})();var P=(()=>{class a{socket;common;redisParser;state;settings;i18n;nav;refreshKey$=new s;keyNew$=new s;keyDelete$=new s;keyRename$=new s;treeControlEnabled$=new s;mainResizer$=new s;treeRefresh$=new s;consoleEmbeddedResize$=new s;consoleActivate$=new s;consoleDeactivate$=new s;connectRequest$=new s;disconnectRequest$=new s;constructor(t,e,n,r,o,h,k){this.socket=t,this.common=e,this.redisParser=n,this.state=r,this.settings=o,this.i18n=h,this.nav=k}get currentDatabase(){let t=this.state.currentDatabase();return t===void 0&&(t=this.readStorageItem(this.getStorageKey())),t==null&&(t=0),Number(t)}set currentDatabase(t){this.state.currentDatabase.set(t);let e=this.getStorageKey();if(e)try{localStorage.setItem(e,String(t))}catch(n){}}selectDatabase(t){return c(this,null,function*(){this.currentDatabase=t,this.socket.stateChanged$.next();try{this.state.page.set(1),yield this.socket.request({action:"redis/console",payload:{command:`select ${t}`}});let e=this.i18n.strings();this.common.toast({message:e.status?.dbChanged?.({db:t})??`Database changed to ${t}`}),yield this.statistics()}catch(e){this.common.generalHandleError(e)}finally{this.socket.stateChanged$.next()}})}save(){return c(this,null,function*(){try{let t=yield this.socket.request({action:"redis/save"}),e=this.redisParser.info(t.info);this.state.info.set(e);let n=this.i18n.strings();this.common.toast({message:n.status?.savedRedis??"Redis saved"})}catch(t){this.common.generalHandleError(t)}})}statistics(){return c(this,null,function*(){try{this.navigateTo("database.statistics"),yield this.refresh({force:!0})}catch(t){this.common.generalHandleError(t)}})}lastRefreshAt=0;refresh(){return c(this,arguments,function*(t={}){if(this.state.connectionState()!=="connected")return;let e=Date.now();if(!t.force&&e-this.lastRefreshAt<2e3)return;this.lastRefreshAt=e;let{withoutParent:n=!1}=t;console.time("refresh");try{let r={},o=this.state.search();!this.settings.searchClientSide()&&typeof o=="string"&&o.length>0&&(this.settings.searchStartsWith()?r.match=o+"*":r.match="*"+o+"*");let h=yield this.socket.request({action:"redis/refresh",payload:r});if(!h)return;this.state.dbsize.set(h.dbsize),this.state.redisChanged.set(!0),yield this.common.loadRedisInfoResponse({response:h}),this.treeRefresh$.next(),n||this.refreshKey$.next()}catch(r){this.common.generalHandleError(r)}finally{console.timeEnd("refresh"),this.socket.stateChanged$.next()}})}addKey(t){let{event:e,node:n}=t;e.stopPropagation(),this.keyNew$.next({event:e,node:n})}disconnect(){return c(this,null,function*(){let t=this.state.connection(),e=this.settings.connectInfoStorageKey;if(e)try{localStorage.removeItem(e)}catch(n){}this.state.connection.set(void 0),this.state.connectionState.set("none"),this.state.redisConnections.set({}),this.state.monitor.set(!1),this.socket.stateChanged$.next();try{yield this.socket.request({action:"connection/disconnect",payload:{connectionId:t?.id}})}catch(n){}finally{this.nav.navigateTo("settings")}})}navigateTo(t,e){this.nav.navigateTo(t,e)}getStorageKey(){try{return this.settings.getStorageKeyCurrentDatabase(this.state.connection()?.id)??""}catch(t){return""}}readStorageItem(t){if(!t)return null;try{return localStorage.getItem(t)}catch(e){return null}}static \u0275fac=function(e){return new(e||a)(i(u),i(v),i(y),i(l),i(f),i(m),i(b))};static \u0275prov=g({token:a,factory:a.\u0275fac,providedIn:"root"})}return a})();export{b as a,P as b};