mirror of
https://github.com/DeNNiiInc/dbgate.git
synced 2026-04-25 09:45:59 +00:00
Merge branch 'feature/redis-key-navigation'
This commit is contained in:
@@ -175,3 +175,23 @@ export function dbKeys_reloadFolder(tree: DbKeysTreeModel, root: string): DbKeys
|
|||||||
},
|
},
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function addFlatItems(tree: DbKeysTreeModel, root: string, res: DbKeysNodeModel[]) {
|
||||||
|
const item = tree.dirsByKey[root];
|
||||||
|
if (!item.isExpanded) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
const children = tree.childrenByKey[root] || [];
|
||||||
|
for (const child of children) {
|
||||||
|
res.push(child);
|
||||||
|
if (child.type == 'dir') {
|
||||||
|
addFlatItems(tree, child.root, res);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export function dbKeys_getFlatList(tree: DbKeysTreeModel) {
|
||||||
|
const res: DbKeysNodeModel[] = [];
|
||||||
|
addFlatItems(tree, '', res);
|
||||||
|
return res;
|
||||||
|
}
|
||||||
|
|||||||
@@ -161,6 +161,8 @@ 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; text: string }>(null);
|
||||||
|
|
||||||
export const DEFAULT_OBJECT_SEARCH_SETTINGS = {
|
export const DEFAULT_OBJECT_SEARCH_SETTINGS = {
|
||||||
pureName: true,
|
pureName: true,
|
||||||
schemaName: false,
|
schemaName: false,
|
||||||
@@ -408,3 +410,9 @@ connectionAppObjectSearchSettings.subscribe(value => {
|
|||||||
connectionAppObjectSearchSettingsValue = value;
|
connectionAppObjectSearchSettingsValue = value;
|
||||||
});
|
});
|
||||||
export const getConnectionAppObjectSearchSettings = () => connectionAppObjectSearchSettingsValue;
|
export const getConnectionAppObjectSearchSettings = () => connectionAppObjectSearchSettingsValue;
|
||||||
|
|
||||||
|
let focusedTreeDbKeyValue = null;
|
||||||
|
focusedTreeDbKey.subscribe(value => {
|
||||||
|
focusedTreeDbKeyValue = value;
|
||||||
|
});
|
||||||
|
export const getFocusedTreeDbKey = () => focusedTreeDbKeyValue;
|
||||||
|
|||||||
@@ -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,7 +1,6 @@
|
|||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
import keycodes from '../utility/keycodes';
|
import keycodes from '../utility/keycodes';
|
||||||
import _ from 'lodash';
|
import _ from 'lodash';
|
||||||
import { sleep } from '../utility/common';
|
|
||||||
|
|
||||||
export let list;
|
export let list;
|
||||||
export let selectedObjectStore;
|
export let selectedObjectStore;
|
||||||
|
|||||||
@@ -1,5 +1,11 @@
|
|||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
import { 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';
|
||||||
@@ -9,17 +15,32 @@
|
|||||||
import FontIcon from '../icons/FontIcon.svelte';
|
import FontIcon from '../icons/FontIcon.svelte';
|
||||||
import AddDbKeyModal from '../modals/AddDbKeyModal.svelte';
|
import AddDbKeyModal from '../modals/AddDbKeyModal.svelte';
|
||||||
import { showModal } from '../modals/modalTools';
|
import { showModal } from '../modals/modalTools';
|
||||||
import { currentDatabase, focusedConnectionOrDatabase, getExtensions } from '../stores';
|
import {
|
||||||
|
activeDbKeysStore,
|
||||||
|
currentDatabase,
|
||||||
|
focusedConnectionOrDatabase,
|
||||||
|
focusedTreeDbKey,
|
||||||
|
getExtensions,
|
||||||
|
getFocusedTreeDbKey,
|
||||||
|
} from '../stores';
|
||||||
import { apiCall } from '../utility/api';
|
import { apiCall } from '../utility/api';
|
||||||
import { useConnectionInfo } from '../utility/metadataLoaders';
|
import { useConnectionInfo } from '../utility/metadataLoaders';
|
||||||
|
|
||||||
import DbKeysSubTree from './DbKeysSubTree.svelte';
|
import DbKeysSubTree from './DbKeysSubTree.svelte';
|
||||||
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 { 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 domContainer = null;
|
||||||
|
let domFilter = null;
|
||||||
|
|
||||||
let filter;
|
let filter;
|
||||||
|
|
||||||
let model = dbKeys_refreshAll();
|
let model = dbKeys_refreshAll();
|
||||||
@@ -86,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" />
|
||||||
@@ -98,6 +127,48 @@
|
|||||||
{#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
|
||||||
|
bind:this={domListHandler}
|
||||||
|
list={dbKeys_getFlatList(model)}
|
||||||
|
selectedObjectStore={focusedTreeDbKey}
|
||||||
|
getSelectedObject={getFocusedTreeDbKey}
|
||||||
|
selectedObjectMatcher={(o1, o2) => o1?.key == o2?.key && o1?.type == o2?.type && o1?.root == o2?.root}
|
||||||
|
handleObjectClick={(data, clickAction) => {
|
||||||
|
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} />
|
||||||
|
</AppObjectListHandler>
|
||||||
</WidgetsInnerContainer>
|
</WidgetsInnerContainer>
|
||||||
|
|||||||
@@ -13,9 +13,10 @@
|
|||||||
import InputTextModal from '../modals/InputTextModal.svelte';
|
import InputTextModal from '../modals/InputTextModal.svelte';
|
||||||
import { showModal } from '../modals/modalTools';
|
import { showModal } from '../modals/modalTools';
|
||||||
import newQuery from '../query/newQuery';
|
import newQuery from '../query/newQuery';
|
||||||
import { activeDbKeysStore } from '../stores';
|
import { activeDbKeysStore, focusedTreeDbKey } from '../stores';
|
||||||
import { apiCall } from '../utility/api';
|
import { apiCall } from '../utility/api';
|
||||||
import { getConnectionInfo } from '../utility/metadataLoaders';
|
import { getConnectionInfo } from '../utility/metadataLoaders';
|
||||||
|
import _ from 'lodash';
|
||||||
import openNewTab from '../utility/openNewTab';
|
import openNewTab from '../utility/openNewTab';
|
||||||
import { showSnackbarError } from '../utility/snackbar';
|
import { showSnackbarError } from '../utility/snackbar';
|
||||||
|
|
||||||
@@ -162,9 +163,16 @@
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
}}
|
}}
|
||||||
|
on:mousedown={() => {
|
||||||
|
$focusedTreeDbKey = _.pick(item, ['type', 'key', 'root', 'text']);
|
||||||
|
}}
|
||||||
extInfo={item.count ? `(${item.count})` : null}
|
extInfo={item.count ? `(${item.count})` : null}
|
||||||
{indentLevel}
|
{indentLevel}
|
||||||
menu={createMenu}
|
menu={createMenu}
|
||||||
|
isChoosed={$focusedTreeDbKey &&
|
||||||
|
item.key == $focusedTreeDbKey.key &&
|
||||||
|
item.root == $focusedTreeDbKey.root &&
|
||||||
|
item.type == $focusedTreeDbKey.type}
|
||||||
/>
|
/>
|
||||||
<!-- <div on:click={() => (isExpanded = !isExpanded)}>
|
<!-- <div on:click={() => (isExpanded = !isExpanded)}>
|
||||||
<FontIcon icon={} />
|
<FontIcon icon={} />
|
||||||
|
|||||||
Reference in New Issue
Block a user