mirror of
https://github.com/DeNNiiInc/dbgate.git
synced 2026-04-23 03:26:00 +00:00
db widget UX
This commit is contained in:
@@ -50,7 +50,7 @@
|
|||||||
<svelte:component
|
<svelte:component
|
||||||
this={module.default}
|
this={module.default}
|
||||||
{data}
|
{data}
|
||||||
on:click={handleExpand}
|
on:dblclick={handleExpand}
|
||||||
on:expand={handleExpandButton}
|
on:expand={handleExpandButton}
|
||||||
expandIcon={getExpandIcon(!isExpandedBySearch && expandable, subItemsComponent, isExpanded, expandIconFunc)}
|
expandIcon={getExpandIcon(!isExpandedBySearch && expandable, subItemsComponent, isExpanded, expandIconFunc)}
|
||||||
{checkedObjectsStore}
|
{checkedObjectsStore}
|
||||||
|
|||||||
@@ -12,6 +12,16 @@
|
|||||||
return filterName(filter, ...databases.map(x => x.name));
|
return filterName(filter, ...databases.map(x => x.name));
|
||||||
};
|
};
|
||||||
export function openConnection(connection) {
|
export function openConnection(connection) {
|
||||||
|
if (connection.singleDatabase) {
|
||||||
|
if (getOpenedSingleDatabaseConnections().includes(connection._id)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
if (getOpenedConnections().includes(connection._id)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
const config = getCurrentConfig();
|
const config = getCurrentConfig();
|
||||||
if (connection.singleDatabase) {
|
if (connection.singleDatabase) {
|
||||||
switchCurrentDatabase({ connection, name: connection.defaultDatabase });
|
switchCurrentDatabase({ connection, name: connection.defaultDatabase });
|
||||||
@@ -88,6 +98,7 @@
|
|||||||
getCurrentDatabase,
|
getCurrentDatabase,
|
||||||
getCurrentSettings,
|
getCurrentSettings,
|
||||||
getOpenedConnections,
|
getOpenedConnections,
|
||||||
|
getOpenedSingleDatabaseConnections,
|
||||||
getOpenedTabs,
|
getOpenedTabs,
|
||||||
openedConnections,
|
openedConnections,
|
||||||
openedSingleDatabaseConnections,
|
openedSingleDatabaseConnections,
|
||||||
@@ -159,8 +170,17 @@
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
const handleClick = async (e) => {
|
const handleClick = async e => {
|
||||||
focusedConnectionOrDatabase.set({ conid: data?._id });
|
focusedConnectionOrDatabase.set({ conid: data?._id });
|
||||||
|
openNewTab({
|
||||||
|
title: getConnectionLabel(data),
|
||||||
|
icon: 'img connection',
|
||||||
|
tabComponent: 'ConnectionTab',
|
||||||
|
tabPreviewMode: true,
|
||||||
|
props: {
|
||||||
|
conid: data._id,
|
||||||
|
},
|
||||||
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
const handleSqlRestore = () => {
|
const handleSqlRestore = () => {
|
||||||
@@ -333,9 +353,8 @@
|
|||||||
{extInfo}
|
{extInfo}
|
||||||
colorMark={passProps?.connectionColorFactory && passProps?.connectionColorFactory({ conid: data._id })}
|
colorMark={passProps?.connectionColorFactory && passProps?.connectionColorFactory({ conid: data._id })}
|
||||||
menu={getContextMenu}
|
menu={getContextMenu}
|
||||||
on:dblclick={handleDoubleClick}
|
|
||||||
on:click={handleClick}
|
on:click={handleClick}
|
||||||
on:click
|
on:dblclick
|
||||||
on:expand
|
on:expand
|
||||||
on:dblclick={handleConnect}
|
on:dblclick={handleConnect}
|
||||||
on:middleclick={() => {
|
on:middleclick={() => {
|
||||||
|
|||||||
@@ -515,9 +515,10 @@ await dbgateApi.dropAllDbObjects(${JSON.stringify(
|
|||||||
extractDbNameFromComposite($currentDatabase?.name) == data.name}
|
extractDbNameFromComposite($currentDatabase?.name) == data.name}
|
||||||
on:dblclick={() => {
|
on:dblclick={() => {
|
||||||
switchCurrentDatabase(data);
|
switchCurrentDatabase(data);
|
||||||
passProps?.onFocusSqlObjectList?.();
|
// passProps?.onFocusSqlObjectList?.();
|
||||||
}}
|
}}
|
||||||
on:click={() => {
|
on:click={() => {
|
||||||
|
// switchCurrentDatabase(data);
|
||||||
$focusedConnectionOrDatabase = { conid: data.connection?._id, database: data.name };
|
$focusedConnectionOrDatabase = { conid: data.connection?._id, database: data.name };
|
||||||
}}
|
}}
|
||||||
on:dragstart
|
on:dragstart
|
||||||
|
|||||||
@@ -23,8 +23,12 @@
|
|||||||
|
|
||||||
const debouncedSet = _.debounce(x => (value = x), 500);
|
const debouncedSet = _.debounce(x => (value = x), 500);
|
||||||
|
|
||||||
export function focus() {
|
export function focus(text) {
|
||||||
domInput.focus();
|
domInput.focus();
|
||||||
|
if (text) {
|
||||||
|
domInput.value = text;
|
||||||
|
value = text;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
|||||||
@@ -346,3 +346,9 @@ focusedConnectionOrDatabase.subscribe(value => {
|
|||||||
focusedConnectionOrDatabaseValue = value;
|
focusedConnectionOrDatabaseValue = value;
|
||||||
});
|
});
|
||||||
export const getFocusedConnectionOrDatabase = () => focusedConnectionOrDatabaseValue;
|
export const getFocusedConnectionOrDatabase = () => focusedConnectionOrDatabaseValue;
|
||||||
|
|
||||||
|
let openedSingleDatabaseConnectionsValue = [];
|
||||||
|
openedSingleDatabaseConnections.subscribe(value => {
|
||||||
|
openedSingleDatabaseConnectionsValue = value;
|
||||||
|
});
|
||||||
|
export const getOpenedSingleDatabaseConnections = () => openedSingleDatabaseConnectionsValue;
|
||||||
|
|||||||
@@ -78,6 +78,20 @@
|
|||||||
handleObjectClick?.(listInstance[listInstance.length - 1], { tabPreviewMode: true });
|
handleObjectClick?.(listInstance[listInstance.length - 1], { tabPreviewMode: true });
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (
|
||||||
|
!ev.ctrlKey &&
|
||||||
|
!ev.altKey &&
|
||||||
|
!ev.metaKey &&
|
||||||
|
((ev.keyCode >= keycodes.a && ev.keyCode <= keycodes.z) ||
|
||||||
|
(ev.keyCode >= keycodes.n0 && ev.keyCode <= keycodes.n9) ||
|
||||||
|
(ev.keyCode >= keycodes.numPad0 && ev.keyCode <= keycodes.numPad9) ||
|
||||||
|
ev.keyCode == keycodes.dash)
|
||||||
|
) {
|
||||||
|
const text = ev.key;
|
||||||
|
onFocusFilterBox?.(text);
|
||||||
|
ev.preventDefault();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export function focusFirst() {
|
export function focusFirst() {
|
||||||
@@ -90,6 +104,16 @@
|
|||||||
onScrollTop?.();
|
onScrollTop?.();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function handleFocus() {
|
||||||
|
isListFocused = true;
|
||||||
|
const listInstance = _.isFunction(list) ? list() : list;
|
||||||
|
const selected = getSelectedObject();
|
||||||
|
const index = _.findIndex(listInstance, x => selectedObjectMatcher(x, selected));
|
||||||
|
if (index < 0) {
|
||||||
|
focusFirst();
|
||||||
|
}
|
||||||
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<div
|
<div
|
||||||
@@ -97,9 +121,7 @@
|
|||||||
on:keydown={handleKeyDown}
|
on:keydown={handleKeyDown}
|
||||||
class="wrapper"
|
class="wrapper"
|
||||||
class:app-object-list-focused={isListFocused}
|
class:app-object-list-focused={isListFocused}
|
||||||
on:focus={() => {
|
on:focus={handleFocus}
|
||||||
isListFocused = true;
|
|
||||||
}}
|
|
||||||
on:blur={() => {
|
on:blur={() => {
|
||||||
isListFocused = false;
|
isListFocused = false;
|
||||||
}}
|
}}
|
||||||
|
|||||||
@@ -1,10 +1,4 @@
|
|||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
connectionAppObject.
|
|
||||||
|
|
||||||
connectionAppObject.
|
|
||||||
|
|
||||||
connectionAppObject.
|
|
||||||
|
|
||||||
import _ from 'lodash';
|
import _ from 'lodash';
|
||||||
import InlineButton from '../buttons/InlineButton.svelte';
|
import InlineButton from '../buttons/InlineButton.svelte';
|
||||||
import SearchInput from '../elements/SearchInput.svelte';
|
import SearchInput from '../elements/SearchInput.svelte';
|
||||||
@@ -41,7 +35,7 @@ connectionAppObject.
|
|||||||
import { getLocalStorage } from '../utility/storageCache';
|
import { getLocalStorage } from '../utility/storageCache';
|
||||||
import { switchCurrentDatabase } from '../utility/common';
|
import { switchCurrentDatabase } from '../utility/common';
|
||||||
import openNewTab from '../utility/openNewTab';
|
import openNewTab from '../utility/openNewTab';
|
||||||
import {openConnection} from '../appobj/ConnectionAppObject.svelte';
|
import { openConnection } from '../appobj/ConnectionAppObject.svelte';
|
||||||
|
|
||||||
const connections = useConnectionList();
|
const connections = useConnectionList();
|
||||||
const serverStatus = useServerStatus();
|
const serverStatus = useServerStatus();
|
||||||
@@ -212,14 +206,15 @@ connectionAppObject.
|
|||||||
onScrollTop={() => {
|
onScrollTop={() => {
|
||||||
domContainer?.scrollTop();
|
domContainer?.scrollTop();
|
||||||
}}
|
}}
|
||||||
onFocusFilterBox={() => {
|
onFocusFilterBox={text => {
|
||||||
domFilter?.focus();
|
domFilter?.focus(text);
|
||||||
}}
|
}}
|
||||||
handleObjectClick={(data, options) => {
|
handleObjectClick={(data, options) => {
|
||||||
if (data.database) {
|
if (data.database) {
|
||||||
if (options.focusTab) {
|
if (options.focusTab) {
|
||||||
switchCurrentDatabase(data.dbobj);
|
switchCurrentDatabase(data.dbobj);
|
||||||
passProps?.onFocusSqlObjectList?.();
|
// console.log('FOCUSING DB', passProps);
|
||||||
|
// passProps?.onFocusSqlObjectList?.();
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (options.focusTab) {
|
if (options.focusTab) {
|
||||||
|
|||||||
@@ -203,8 +203,8 @@
|
|||||||
onScrollTop={() => {
|
onScrollTop={() => {
|
||||||
domContainer?.scrollTop();
|
domContainer?.scrollTop();
|
||||||
}}
|
}}
|
||||||
onFocusFilterBox={() => {
|
onFocusFilterBox={text => {
|
||||||
domFilter?.focus();
|
domFilter?.focus(text);
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
<AppObjectList
|
<AppObjectList
|
||||||
|
|||||||
Reference in New Issue
Block a user