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
1 lines • 3.42 kB
JavaScript
import{d as L}from"./main-OCJB5534.js";import{ct as N,mn as YQ,vt as P}from"./chunk-CHqDEyfr.js";import{t as Q}from"./chunk-CyniViPG.js";import{n as bi}from"./chunk-DjVJBOYc.js";import{n as Le}from"./chunk-CyaMV1f5.js";import{t as It}from"./chunk-BM0xjj91.js";import{n as b,t as P$1}from"./chunk-BTZfv3-Q.js";var C=(()=>{class i{dialog;openRef=null;constructor(t){this.dialog=t}show(){return L(this,null,function*(){if(this.openRef)return;let{CommandPaletteDialogComponent:t}=yield import(`./chunk-CEhrCz5y.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 ɵfac=function(e){return new(e||i)(N(Le))};static ɵprov=P({token:i,factory:i.ɵfac,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 ɵfac=function(e){return new(e||i)(N(YQ),N(b),N(P$1),N(bi),N(It),N(C),N(Q))};static ɵprov=P({token:i,factory:i.ɵfac,providedIn:`root`})}return i})();export{D as t};