mirror of
https://github.com/DeNNiiInc/dbgate.git
synced 2026-04-30 19:43:58 +00:00
redis key selection by keyboard
This commit is contained in:
@@ -161,7 +161,7 @@ export const lastUsedDefaultActions = writableWithStorage({}, 'lastUsedDefaultAc
|
|||||||
export const selectedDatabaseObjectAppObject = writable(null);
|
export const selectedDatabaseObjectAppObject = writable(null);
|
||||||
export const focusedConnectionOrDatabase = writable<{ conid: string; database?: string; connection: any }>(null);
|
export const focusedConnectionOrDatabase = writable<{ conid: string; database?: string; connection: any }>(null);
|
||||||
|
|
||||||
export const focusedTreeDbKey = writable<{ key: string; root: string; type: string }>(null);
|
export const focusedTreeDbKey = writable<{ key: string; root: string; type: string; text: string }>(null);
|
||||||
|
|
||||||
export const DEFAULT_OBJECT_SEARCH_SETTINGS = {
|
export const DEFAULT_OBJECT_SEARCH_SETTINGS = {
|
||||||
pureName: true,
|
pureName: true,
|
||||||
|
|||||||
@@ -7,6 +7,7 @@
|
|||||||
export const allowAddToFavorites = props => false;
|
export const allowAddToFavorites = props => false;
|
||||||
|
|
||||||
function getKeyText(key) {
|
function getKeyText(key) {
|
||||||
|
if (!key) return '(no name)';
|
||||||
const keySplit = key.split(':');
|
const keySplit = key.split(':');
|
||||||
if (keySplit.length > 1) return keySplit[keySplit.length - 1];
|
if (keySplit.length > 1) return keySplit[keySplit.length - 1];
|
||||||
return key || '(no name)';
|
return key || '(no name)';
|
||||||
|
|||||||
@@ -1,5 +1,11 @@
|
|||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
import { dbKeys_getFlatList, dbKeys_loadMissing, dbKeys_refreshAll, findEngineDriver } from 'dbgate-tools';
|
import {
|
||||||
|
dbKeys_getFlatList,
|
||||||
|
dbKeys_loadMissing,
|
||||||
|
dbKeys_markNodeExpanded,
|
||||||
|
dbKeys_refreshAll,
|
||||||
|
findEngineDriver,
|
||||||
|
} from 'dbgate-tools';
|
||||||
|
|
||||||
import CloseSearchButton from '../buttons/CloseSearchButton.svelte';
|
import CloseSearchButton from '../buttons/CloseSearchButton.svelte';
|
||||||
import InlineButton from '../buttons/InlineButton.svelte';
|
import InlineButton from '../buttons/InlineButton.svelte';
|
||||||
@@ -10,6 +16,7 @@
|
|||||||
import AddDbKeyModal from '../modals/AddDbKeyModal.svelte';
|
import AddDbKeyModal from '../modals/AddDbKeyModal.svelte';
|
||||||
import { showModal } from '../modals/modalTools';
|
import { showModal } from '../modals/modalTools';
|
||||||
import {
|
import {
|
||||||
|
activeDbKeysStore,
|
||||||
currentDatabase,
|
currentDatabase,
|
||||||
focusedConnectionOrDatabase,
|
focusedConnectionOrDatabase,
|
||||||
focusedTreeDbKey,
|
focusedTreeDbKey,
|
||||||
@@ -23,11 +30,16 @@
|
|||||||
import WidgetsInnerContainer from './WidgetsInnerContainer.svelte';
|
import WidgetsInnerContainer from './WidgetsInnerContainer.svelte';
|
||||||
import FocusedConnectionInfoWidget from './FocusedConnectionInfoWidget.svelte';
|
import FocusedConnectionInfoWidget from './FocusedConnectionInfoWidget.svelte';
|
||||||
import AppObjectListHandler from './AppObjectListHandler.svelte';
|
import AppObjectListHandler from './AppObjectListHandler.svelte';
|
||||||
|
import { getOpenDetailOnArrowsSettings } from '../settings/settingsTools';
|
||||||
|
import openNewTab from '../utility/openNewTab';
|
||||||
|
import clickOutside from '../utility/clickOutside';
|
||||||
|
|
||||||
export let conid;
|
export let conid;
|
||||||
export let database;
|
export let database;
|
||||||
|
|
||||||
let domListHandler;
|
let domListHandler;
|
||||||
|
let domContainer = null;
|
||||||
|
let domFilter = null;
|
||||||
|
|
||||||
let filter;
|
let filter;
|
||||||
|
|
||||||
@@ -95,7 +107,15 @@
|
|||||||
</script>
|
</script>
|
||||||
|
|
||||||
<SearchBoxWrapper>
|
<SearchBoxWrapper>
|
||||||
<SearchInput placeholder="Search keys" bind:value={filter} isDebounced />
|
<SearchInput
|
||||||
|
placeholder="Search keys"
|
||||||
|
bind:value={filter}
|
||||||
|
isDebounced
|
||||||
|
bind:this={domFilter}
|
||||||
|
onFocusFilteredList={() => {
|
||||||
|
domListHandler?.focusFirst();
|
||||||
|
}}
|
||||||
|
/>
|
||||||
<CloseSearchButton bind:filter />
|
<CloseSearchButton bind:filter />
|
||||||
<InlineButton on:click={handleAddKey} title="Add new key">
|
<InlineButton on:click={handleAddKey} title="Add new key">
|
||||||
<FontIcon icon="icon plus-thick" />
|
<FontIcon icon="icon plus-thick" />
|
||||||
@@ -107,7 +127,7 @@
|
|||||||
{#if differentFocusedDb}
|
{#if differentFocusedDb}
|
||||||
<FocusedConnectionInfoWidget {conid} {database} connection={$connection} />
|
<FocusedConnectionInfoWidget {conid} {database} connection={$connection} />
|
||||||
{/if}
|
{/if}
|
||||||
<WidgetsInnerContainer hideContent={differentFocusedDb}>
|
<WidgetsInnerContainer hideContent={differentFocusedDb} bind:this={domContainer}>
|
||||||
<AppObjectListHandler
|
<AppObjectListHandler
|
||||||
bind:this={domListHandler}
|
bind:this={domListHandler}
|
||||||
list={dbKeys_getFlatList(model)}
|
list={dbKeys_getFlatList(model)}
|
||||||
@@ -116,6 +136,37 @@
|
|||||||
selectedObjectMatcher={(o1, o2) => o1?.key == o2?.key && o1?.type == o2?.type && o1?.root == o2?.root}
|
selectedObjectMatcher={(o1, o2) => o1?.key == o2?.key && o1?.type == o2?.type && o1?.root == o2?.root}
|
||||||
handleObjectClick={(data, clickAction) => {
|
handleObjectClick={(data, clickAction) => {
|
||||||
focusedTreeDbKey.set(data);
|
focusedTreeDbKey.set(data);
|
||||||
|
|
||||||
|
const openDetailOnArrows = getOpenDetailOnArrowsSettings();
|
||||||
|
|
||||||
|
if (data.key && ((openDetailOnArrows && clickAction == 'keyArrow') || clickAction == 'keyEnter')) {
|
||||||
|
openNewTab({
|
||||||
|
tabComponent: 'DbKeyDetailTab',
|
||||||
|
title: data.text || '(no name)',
|
||||||
|
icon: 'img keydb',
|
||||||
|
props: {
|
||||||
|
isDefaultBrowser: true,
|
||||||
|
conid,
|
||||||
|
database,
|
||||||
|
},
|
||||||
|
});
|
||||||
|
$activeDbKeysStore = {
|
||||||
|
...$activeDbKeysStore,
|
||||||
|
[`${conid}:${database}`]: data.key,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
if (data.root && clickAction == 'keyEnter') {
|
||||||
|
changeModel(model => dbKeys_markNodeExpanded(model, data.root, !model.dirsByKey[data.root]?.isExpanded));
|
||||||
|
}
|
||||||
|
}}
|
||||||
|
handleExpansion={(data, value) => {
|
||||||
|
changeModel(model => dbKeys_markNodeExpanded(model, data.root, value));
|
||||||
|
}}
|
||||||
|
onScrollTop={() => {
|
||||||
|
domContainer?.scrollTop();
|
||||||
|
}}
|
||||||
|
onFocusFilterBox={text => {
|
||||||
|
domFilter?.focus(text);
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
<DbKeysSubTree root="" {filter} {model} {changeModel} {conid} {database} {connection} />
|
<DbKeysSubTree root="" {filter} {model} {changeModel} {conid} {database} {connection} />
|
||||||
|
|||||||
@@ -164,7 +164,7 @@
|
|||||||
}
|
}
|
||||||
}}
|
}}
|
||||||
on:mousedown={() => {
|
on:mousedown={() => {
|
||||||
$focusedTreeDbKey = _.pick(item, ['type', 'key', 'root']);
|
$focusedTreeDbKey = _.pick(item, ['type', 'key', 'root', 'text']);
|
||||||
}}
|
}}
|
||||||
extInfo={item.count ? `(${item.count})` : null}
|
extInfo={item.count ? `(${item.count})` : null}
|
||||||
{indentLevel}
|
{indentLevel}
|
||||||
|
|||||||
Reference in New Issue
Block a user