mirror of
https://github.com/DeNNiiInc/dbgate.git
synced 2026-05-03 08:13:57 +00:00
@@ -86,14 +86,26 @@
|
|||||||
submenuKey += 1;
|
submenuKey += 1;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (item.switchStore && item.switchValue) {
|
if (item.switchStore) {
|
||||||
item.switchStore.update(x => ({
|
if (item.switchValue) {
|
||||||
...x,
|
item.switchStore.update(x => ({
|
||||||
[item.switchValue]: !x[item.switchValue],
|
...x,
|
||||||
}));
|
[item.switchValue]: !x[item.switchValue],
|
||||||
|
}));
|
||||||
|
}
|
||||||
|
|
||||||
|
if (item.switchOption && item.switchOptionValue) {
|
||||||
|
item.switchStore.update(x => ({
|
||||||
|
...x,
|
||||||
|
[item.switchOption]: item.switchOptionValue,
|
||||||
|
}));
|
||||||
|
}
|
||||||
switchIndex++;
|
switchIndex++;
|
||||||
return;
|
if (!item.closeOnSwitchClick) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
dispatchClose();
|
dispatchClose();
|
||||||
if (onCloseParent) onCloseParent();
|
if (onCloseParent) onCloseParent();
|
||||||
if (item.onClick) item.onClick();
|
if (item.onClick) item.onClick();
|
||||||
@@ -163,6 +175,16 @@
|
|||||||
{/if}
|
{/if}
|
||||||
{/key}
|
{/key}
|
||||||
{/if}
|
{/if}
|
||||||
|
{#if item.switchOption && item.switchStoreGetter}
|
||||||
|
{@const optionValue = item.switchStoreGetter()[item.switchOption]}
|
||||||
|
{#key switchIndex}
|
||||||
|
{#if optionValue === item.switchOptionValue || (item.switchOptionIsDefault && !optionValue)}
|
||||||
|
<FontIcon icon="icon check" padRight />
|
||||||
|
{:else}
|
||||||
|
<FontIcon icon="icon invisible-box" padRight />
|
||||||
|
{/if}
|
||||||
|
{/key}
|
||||||
|
{/if}
|
||||||
{item.text || item.label}
|
{item.text || item.label}
|
||||||
</span>
|
</span>
|
||||||
{#if item.keyText}
|
{#if item.keyText}
|
||||||
|
|||||||
@@ -200,6 +200,7 @@ export const DEFAULT_OBJECT_SEARCH_SETTINGS = {
|
|||||||
sqlObjectText: false,
|
sqlObjectText: false,
|
||||||
tableEngine: false,
|
tableEngine: false,
|
||||||
tablesWithRows: false,
|
tablesWithRows: false,
|
||||||
|
sortBy: undefined as string
|
||||||
};
|
};
|
||||||
|
|
||||||
export const DEFAULT_CONNECTION_SEARCH_SETTINGS = {
|
export const DEFAULT_CONNECTION_SEARCH_SETTINGS = {
|
||||||
|
|||||||
@@ -79,12 +79,30 @@
|
|||||||
|
|
||||||
// $: console.log('OBJECTS', $objects);
|
// $: console.log('OBJECTS', $objects);
|
||||||
|
|
||||||
|
$: sortArgs =
|
||||||
|
$databaseObjectAppObjectSearchSettings.sortBy == 'rowCount'
|
||||||
|
? [
|
||||||
|
['rowCount', 'sizeBytes', 'schemaName', 'pureName'],
|
||||||
|
['desc', 'desc', 'asc', 'asc'],
|
||||||
|
]
|
||||||
|
: $databaseObjectAppObjectSearchSettings.sortBy == 'sizeBytes'
|
||||||
|
? [
|
||||||
|
['sizeBytes', 'rowCount', 'schemaName', 'pureName'],
|
||||||
|
['desc', 'desc', 'asc', 'asc'],
|
||||||
|
]
|
||||||
|
: [
|
||||||
|
['schemaName', 'pureName'],
|
||||||
|
['asc', 'asc'],
|
||||||
|
];
|
||||||
|
|
||||||
$: objectList = _.flatten([
|
$: objectList = _.flatten([
|
||||||
...['tables', 'collections', 'views', 'matviews', 'procedures', 'functions', 'triggers', 'schedulerEvents'].map(
|
...['tables', 'collections', 'views', 'matviews', 'procedures', 'functions', 'triggers', 'schedulerEvents'].map(
|
||||||
objectTypeField =>
|
objectTypeField =>
|
||||||
_.sortBy(
|
_.orderBy(
|
||||||
(($objects || {})[objectTypeField] || []).map(obj => ({ ...obj, objectTypeField })),
|
(($objects || {})[objectTypeField] || []).map(obj => ({ ...obj, objectTypeField })),
|
||||||
['schemaName', 'pureName']
|
sortArgs[0],
|
||||||
|
// @ts-ignore
|
||||||
|
sortArgs[1]
|
||||||
)
|
)
|
||||||
),
|
),
|
||||||
...appsForDb.map(app =>
|
...appsForDb.map(app =>
|
||||||
@@ -133,19 +151,62 @@
|
|||||||
const res = [];
|
const res = [];
|
||||||
res.push({ label: _t('sqlObject.searchBy', { defaultMessage: 'Search by:' }), isBold: true, disabled: true });
|
res.push({ label: _t('sqlObject.searchBy', { defaultMessage: 'Search by:' }), isBold: true, disabled: true });
|
||||||
if (driver?.databaseEngineTypes?.includes('document')) {
|
if (driver?.databaseEngineTypes?.includes('document')) {
|
||||||
res.push({ label: _t('sqlObject.collectionName', { defaultMessage: 'Collection name' }), switchValue: 'pureName' });
|
res.push({
|
||||||
|
label: _t('sqlObject.collectionName', { defaultMessage: 'Collection name' }),
|
||||||
|
switchValue: 'pureName',
|
||||||
|
});
|
||||||
}
|
}
|
||||||
if (driver?.databaseEngineTypes?.includes('sql')) {
|
if (driver?.databaseEngineTypes?.includes('sql')) {
|
||||||
res.push({ label: _t('sqlObject.tableViewProcedureName', { defaultMessage: 'Table/view/procedure name' }), switchValue: 'pureName' });
|
res.push({
|
||||||
|
label: _t('sqlObject.tableViewProcedureName', { defaultMessage: 'Table/view/procedure name' }),
|
||||||
|
switchValue: 'pureName',
|
||||||
|
});
|
||||||
res.push({ label: _t('sqlObject.schemaName', { defaultMessage: 'Schema' }), switchValue: 'schemaName' });
|
res.push({ label: _t('sqlObject.schemaName', { defaultMessage: 'Schema' }), switchValue: 'schemaName' });
|
||||||
res.push({ label: _t('sqlObject.columnName', { defaultMessage: 'Column name' }), switchValue: 'columnName' });
|
res.push({ label: _t('sqlObject.columnName', { defaultMessage: 'Column name' }), switchValue: 'columnName' });
|
||||||
res.push({ label: _t('sqlObject.columnDataType', { defaultMessage: 'Column data type' }), switchValue: 'columnDataType' });
|
res.push({
|
||||||
res.push({ label: _t('sqlObject.tableComment', { defaultMessage: 'Table comment' }), switchValue: 'tableComment' });
|
label: _t('sqlObject.columnDataType', { defaultMessage: 'Column data type' }),
|
||||||
res.push({ label: _t('sqlObject.columnComment', { defaultMessage: 'Column comment' }), switchValue: 'columnComment' });
|
switchValue: 'columnDataType',
|
||||||
res.push({ label: _t('sqlObject.viewProcedureTriggerText', { defaultMessage: 'View/procedure/trigger text' }), switchValue: 'sqlObjectText' });
|
});
|
||||||
|
res.push({
|
||||||
|
label: _t('sqlObject.tableComment', { defaultMessage: 'Table comment' }),
|
||||||
|
switchValue: 'tableComment',
|
||||||
|
});
|
||||||
|
res.push({
|
||||||
|
label: _t('sqlObject.columnComment', { defaultMessage: 'Column comment' }),
|
||||||
|
switchValue: 'columnComment',
|
||||||
|
});
|
||||||
|
res.push({
|
||||||
|
label: _t('sqlObject.viewProcedureTriggerText', { defaultMessage: 'View/procedure/trigger text' }),
|
||||||
|
switchValue: 'sqlObjectText',
|
||||||
|
});
|
||||||
res.push({ label: _t('sqlObject.tableEngine', { defaultMessage: 'Table engine' }), switchValue: 'tableEngine' });
|
res.push({ label: _t('sqlObject.tableEngine', { defaultMessage: 'Table engine' }), switchValue: 'tableEngine' });
|
||||||
res.push({ label: _t('sqlObject.tablesWithRows', { defaultMessage: 'Only tables with rows' }), switchValue: 'tablesWithRows' });
|
res.push({
|
||||||
|
label: _t('sqlObject.tablesWithRows', { defaultMessage: 'Only tables with rows' }),
|
||||||
|
switchValue: 'tablesWithRows',
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
res.push({ label: _t('sqlObject.sortBy', { defaultMessage: 'Sort by:' }), isBold: true, disabled: true });
|
||||||
|
res.push({
|
||||||
|
label: _t('sqlObject.name', { defaultMessage: 'Name' }),
|
||||||
|
switchOption: 'sortBy',
|
||||||
|
switchOptionValue: 'name',
|
||||||
|
switchOptionIsDefault: true,
|
||||||
|
closeOnSwitchClick: true,
|
||||||
|
});
|
||||||
|
res.push({
|
||||||
|
label: _t('sqlObject.rowCount', { defaultMessage: 'Row count' }),
|
||||||
|
switchOption: 'sortBy',
|
||||||
|
switchOptionValue: 'rowCount',
|
||||||
|
closeOnSwitchClick: true,
|
||||||
|
});
|
||||||
|
res.push({
|
||||||
|
label: _t('sqlObject.sizeBytes', { defaultMessage: 'Size (bytes)' }),
|
||||||
|
switchOption: 'sortBy',
|
||||||
|
switchOptionValue: 'sizeBytes',
|
||||||
|
closeOnSwitchClick: true,
|
||||||
|
});
|
||||||
|
|
||||||
return res.map(item => ({
|
return res.map(item => ({
|
||||||
...item,
|
...item,
|
||||||
switchStore: databaseObjectAppObjectSearchSettings,
|
switchStore: databaseObjectAppObjectSearchSettings,
|
||||||
@@ -193,19 +254,25 @@
|
|||||||
|
|
||||||
<WidgetsInnerContainer hideContent={differentFocusedDb}>
|
<WidgetsInnerContainer hideContent={differentFocusedDb}>
|
||||||
<ErrorInfo
|
<ErrorInfo
|
||||||
message={_t('sqlObject.databaseEmpty', { defaultMessage: 'Database {database} is empty or structure is not loaded, press Refresh button to reload structure', values: { database } })}
|
message={_t('sqlObject.databaseEmpty', {
|
||||||
|
defaultMessage:
|
||||||
|
'Database {database} is empty or structure is not loaded, press Refresh button to reload structure',
|
||||||
|
values: { database },
|
||||||
|
})}
|
||||||
icon="img alert"
|
icon="img alert"
|
||||||
/>
|
/>
|
||||||
<div class="m-1" />
|
<div class="m-1" />
|
||||||
<InlineButton on:click={handleRefreshDatabase}>{_t('common.refresh', { defaultMessage: 'Refresh' })}</InlineButton>
|
<InlineButton on:click={handleRefreshDatabase}>{_t('common.refresh', { defaultMessage: 'Refresh' })}</InlineButton>
|
||||||
{#if driver?.databaseEngineTypes?.includes('sql')}
|
{#if driver?.databaseEngineTypes?.includes('sql')}
|
||||||
<div class="m-1" />
|
<div class="m-1" />
|
||||||
<InlineButton on:click={() => runCommand('new.table')}>{_t('database.newTable', { defaultMessage: 'New table' })}</InlineButton>
|
<InlineButton on:click={() => runCommand('new.table')}
|
||||||
|
>{_t('database.newTable', { defaultMessage: 'New table' })}</InlineButton
|
||||||
|
>
|
||||||
{/if}
|
{/if}
|
||||||
{#if driver?.databaseEngineTypes?.includes('document')}
|
{#if driver?.databaseEngineTypes?.includes('document')}
|
||||||
<div class="m-1" />
|
<div class="m-1" />
|
||||||
<InlineButton on:click={() => runCommand('new.collection')}
|
<InlineButton on:click={() => runCommand('new.collection')}
|
||||||
>{_t('sqlObject.newCollection', { defaultMessage: 'New collection/container'})}</InlineButton
|
>{_t('sqlObject.newCollection', { defaultMessage: 'New collection/container' })}</InlineButton
|
||||||
>
|
>
|
||||||
{/if}
|
{/if}
|
||||||
</WidgetsInnerContainer>
|
</WidgetsInnerContainer>
|
||||||
@@ -233,7 +300,7 @@
|
|||||||
{/if}
|
{/if}
|
||||||
<InlineButton
|
<InlineButton
|
||||||
on:click={handleRefreshDatabase}
|
on:click={handleRefreshDatabase}
|
||||||
title={_t('sqlObjectList.refreshDatabase', { defaultMessage: "Refresh database connection and object list" })}
|
title={_t('sqlObjectList.refreshDatabase', { defaultMessage: 'Refresh database connection and object list' })}
|
||||||
square
|
square
|
||||||
data-testid="SqlObjectList_refreshButton"
|
data-testid="SqlObjectList_refreshButton"
|
||||||
>
|
>
|
||||||
@@ -260,7 +327,10 @@
|
|||||||
data-testid="SqlObjectList_container"
|
data-testid="SqlObjectList_container"
|
||||||
>
|
>
|
||||||
{#if ($status && ($status.name == 'pending' || $status.name == 'checkStructure' || $status.name == 'loadStructure') && $objects) || !$objects}
|
{#if ($status && ($status.name == 'pending' || $status.name == 'checkStructure' || $status.name == 'loadStructure') && $objects) || !$objects}
|
||||||
<LoadingInfo message={$status?.feedback?.analysingMessage || _t('sqlObject.loadingStructure', { defaultMessage: 'Loading database structure' })} />
|
<LoadingInfo
|
||||||
|
message={$status?.feedback?.analysingMessage ||
|
||||||
|
_t('sqlObject.loadingStructure', { defaultMessage: 'Loading database structure' })}
|
||||||
|
/>
|
||||||
{:else}
|
{:else}
|
||||||
<AppObjectListHandler
|
<AppObjectListHandler
|
||||||
bind:this={domListHandler}
|
bind:this={domListHandler}
|
||||||
|
|||||||
Reference in New Issue
Block a user