mirror of
https://github.com/DeNNiiInc/dbgate.git
synced 2026-04-29 05:16:00 +00:00
sort tables by size/rowCount
This commit is contained in:
@@ -86,26 +86,26 @@
|
|||||||
submenuKey += 1;
|
submenuKey += 1;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (item.switchStore && item.switchValue) {
|
if (item.switchStore) {
|
||||||
item.switchStore.update(x => {
|
if (item.switchValue) {
|
||||||
const res = {
|
item.switchStore.update(x => ({
|
||||||
...x,
|
...x,
|
||||||
[item.switchValue]: !x[item.switchValue],
|
[item.switchValue]: !x[item.switchValue],
|
||||||
};
|
}));
|
||||||
if (item.switchGroupPrefix) {
|
}
|
||||||
for (const key of Object.keys(res)) {
|
|
||||||
if (key.startsWith(item.switchGroupPrefix) && key !== item.switchValue) {
|
if (item.switchOption && item.switchOptionValue) {
|
||||||
res[key] = false;
|
item.switchStore.update(x => ({
|
||||||
}
|
...x,
|
||||||
}
|
[item.switchOption]: item.switchOptionValue,
|
||||||
}
|
}));
|
||||||
return res;
|
}
|
||||||
});
|
|
||||||
switchIndex++;
|
switchIndex++;
|
||||||
if (!item.closeOnSwitchClick) {
|
if (!item.closeOnSwitchClick) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
dispatchClose();
|
dispatchClose();
|
||||||
if (onCloseParent) onCloseParent();
|
if (onCloseParent) onCloseParent();
|
||||||
if (item.onClick) item.onClick();
|
if (item.onClick) item.onClick();
|
||||||
@@ -175,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,14 +79,30 @@
|
|||||||
|
|
||||||
// $: console.log('OBJECTS', $objects);
|
// $: console.log('OBJECTS', $objects);
|
||||||
|
|
||||||
$databaseObjectAppObjectSearchSettings?.
|
$: 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 =>
|
||||||
@@ -173,20 +189,21 @@
|
|||||||
res.push({ label: _t('sqlObject.sortBy', { defaultMessage: 'Sort by:' }), isBold: true, disabled: true });
|
res.push({ label: _t('sqlObject.sortBy', { defaultMessage: 'Sort by:' }), isBold: true, disabled: true });
|
||||||
res.push({
|
res.push({
|
||||||
label: _t('sqlObject.name', { defaultMessage: 'Name' }),
|
label: _t('sqlObject.name', { defaultMessage: 'Name' }),
|
||||||
switchValue: 'sortByName',
|
switchOption: 'sortBy',
|
||||||
switchGroupPrefix: 'sortBy',
|
switchOptionValue: 'name',
|
||||||
|
switchOptionIsDefault: true,
|
||||||
closeOnSwitchClick: true,
|
closeOnSwitchClick: true,
|
||||||
});
|
});
|
||||||
res.push({
|
res.push({
|
||||||
label: _t('sqlObject.rowCount', { defaultMessage: 'Row count' }),
|
label: _t('sqlObject.rowCount', { defaultMessage: 'Row count' }),
|
||||||
switchValue: 'sortByRowCount',
|
switchOption: 'sortBy',
|
||||||
switchGroupPrefix: 'sortBy',
|
switchOptionValue: 'rowCount',
|
||||||
closeOnSwitchClick: true,
|
closeOnSwitchClick: true,
|
||||||
});
|
});
|
||||||
res.push({
|
res.push({
|
||||||
label: _t('sqlObject.sizeBytes', { defaultMessage: 'Size bytes' }),
|
label: _t('sqlObject.sizeBytes', { defaultMessage: 'Size bytes' }),
|
||||||
switchValue: 'sortBySizeBytes',
|
switchOption: 'sortBy',
|
||||||
switchGroupPrefix: 'sortBy',
|
switchOptionValue: 'sizeBytes',
|
||||||
closeOnSwitchClick: true,
|
closeOnSwitchClick: true,
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user