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) • 3.43 kB
import{a as d,b as K}from"./chunk-UYYXUKSC.js";import{c as p}from"./chunk-VQTCYUQY.js";import{e as y}from"./chunk-TKRAWHQA.js";import{b as f}from"./chunk-W32HPWBA.js";import{c as m}from"./chunk-PFG3GPGC.js";import{Rd as u,U as c,Y as r}from"./chunk-MHKTEXY5.js";import{h}from"./chunk-O7S4L63H.js";var C=(()=>{class i{dialog;openRef=null;constructor(t){this.dialog=t}show(){return h(this,null,function*(){if(this.openRef)return;let{CommandPaletteDialogComponent:t}=yield import("./chunk-BA3OJGJ5.js");this.openRef=this.dialog.open(t,{width:"500px",maxWidth:"90vw",position:{top:"100px"},panelClass:"p3xr-command-palette-panel",autoFocus:!1}),this.openRef.afterClosed().subscribe(()=>{this.openRef=null})})}static \u0275fac=function(e){return new(e||i)(r(m))};static \u0275prov=c({token:i,factory:i.\u0275fac,providedIn:"root"})}return i})();var D=(()=>{class i{i18n;nav;cmd;socket;common;commandPalette;state;shortcuts=[];isElectron;constructor(t,e,n,o,s,a,l){this.i18n=t,this.nav=e,this.cmd=n,this.socket=o,this.common=s,this.commandPalette=a,this.state=l,this.isElectron=/electron/i.test(navigator.userAgent),this.isElectron&&this.initShortcuts()}get isConnected(){return!!this.state.connection()}requireConnection(t){if(this.isConnected)t();else{let e=this.i18n.strings();this.common.toast(e?.label?.connectFirst)}}requireConnectionAndHome(t){if(!this.isConnected){let e=this.i18n.strings();this.common.toast(e?.label?.connectFirst);return}this.nav.currentUrl.startsWith("/database")?t():(this.nav.navigateTo("database.statistics"),setTimeout(()=>t(),300))}initShortcuts(){this.shortcuts=[{key:"r",ctrlKey:!0,label:"Ctrl+R",descriptionKey:"shortcutRefresh",action:()=>this.requireConnection(()=>this.cmd.treeRefresh$.next())},{key:"F5",label:"F5",descriptionKey:"shortcutRefresh",action:()=>this.requireConnection(()=>this.cmd.treeRefresh$.next())},{key:"f",ctrlKey:!0,label:"Ctrl+F",descriptionKey:"shortcutSearch",action:()=>this.requireConnectionAndHome(()=>{let t=document.querySelector(".p3xr-database-treecontrol-controls-search input");t&&t.focus()})},{key:"n",ctrlKey:!0,label:"Ctrl+N",descriptionKey:"shortcutNewKey",action:()=>this.requireConnectionAndHome(()=>{this.cmd.keyNew$.next({event:new Event("shortcut")})})},{key:"k",ctrlKey:!0,label:"Ctrl+K",descriptionKey:"shortcutCommandPalette",action:()=>this.commandPalette.show()},{key:"d",ctrlKey:!0,label:"Ctrl+D",descriptionKey:"shortcutDisconnect",action:()=>this.requireConnection(()=>this.cmd.disconnectRequest$.next())}]}isEnabled(){return this.isElectron}getShortcuts(){return this.shortcuts}getShortcutsWithDescriptions(){let t=this.i18n.strings();return this.shortcuts.filter((e,n,o)=>o.findIndex(s=>s.descriptionKey===e.descriptionKey)===n).map(e=>({key:e.label,description:t?.label?.[e.descriptionKey]||e.descriptionKey}))}handleKeydown(t){if(!this.isElectron)return!1;let e=t.target,n=e?.tagName?.toLowerCase();if(n==="input"||n==="textarea"||e?.closest(".cm-editor"))return!1;for(let o of this.shortcuts){let s=o.ctrlKey?t.ctrlKey||t.metaKey:!t.ctrlKey&&!t.metaKey,a=o.shiftKey?t.shiftKey:!t.shiftKey,l=o.altKey?t.altKey:!t.altKey,g=t.key.toLowerCase()===o.key.toLowerCase()||t.key===o.key;if(s&&a&&l&&g)return t.preventDefault(),t.stopPropagation(),o.action(),!0}return!1}static \u0275fac=function(e){return new(e||i)(r(u),r(d),r(K),r(p),r(y),r(C),r(f))};static \u0275prov=c({token:i,factory:i.\u0275fac,providedIn:"root"})}return i})();export{D as a};