mirror of
https://github.com/DeNNiiInc/dbgate.git
synced 2026-04-17 22:36:01 +00:00
sort tables by size/rowCount
This commit is contained in:
@@ -86,26 +86,26 @@
|
||||
submenuKey += 1;
|
||||
return;
|
||||
}
|
||||
if (item.switchStore && item.switchValue) {
|
||||
item.switchStore.update(x => {
|
||||
const res = {
|
||||
if (item.switchStore) {
|
||||
if (item.switchValue) {
|
||||
item.switchStore.update(x => ({
|
||||
...x,
|
||||
[item.switchValue]: !x[item.switchValue],
|
||||
};
|
||||
if (item.switchGroupPrefix) {
|
||||
for (const key of Object.keys(res)) {
|
||||
if (key.startsWith(item.switchGroupPrefix) && key !== item.switchValue) {
|
||||
res[key] = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
return res;
|
||||
});
|
||||
}));
|
||||
}
|
||||
|
||||
if (item.switchOption && item.switchOptionValue) {
|
||||
item.switchStore.update(x => ({
|
||||
...x,
|
||||
[item.switchOption]: item.switchOptionValue,
|
||||
}));
|
||||
}
|
||||
switchIndex++;
|
||||
if (!item.closeOnSwitchClick) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
dispatchClose();
|
||||
if (onCloseParent) onCloseParent();
|
||||
if (item.onClick) item.onClick();
|
||||
@@ -175,6 +175,16 @@
|
||||
{/if}
|
||||
{/key}
|
||||
{/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}
|
||||
</span>
|
||||
{#if item.keyText}
|
||||
|
||||
@@ -200,6 +200,7 @@ export const DEFAULT_OBJECT_SEARCH_SETTINGS = {
|
||||
sqlObjectText: false,
|
||||
tableEngine: false,
|
||||
tablesWithRows: false,
|
||||
sortBy: undefined as string
|
||||
};
|
||||
|
||||
export const DEFAULT_CONNECTION_SEARCH_SETTINGS = {
|
||||
|
||||
@@ -79,14 +79,30 @@
|
||||
|
||||
// $: 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([
|
||||
...['tables', 'collections', 'views', 'matviews', 'procedures', 'functions', 'triggers', 'schedulerEvents'].map(
|
||||
objectTypeField =>
|
||||
_.sortBy(
|
||||
_.orderBy(
|
||||
(($objects || {})[objectTypeField] || []).map(obj => ({ ...obj, objectTypeField })),
|
||||
['schemaName', 'pureName']
|
||||
sortArgs[0],
|
||||
// @ts-ignore
|
||||
sortArgs[1]
|
||||
)
|
||||
),
|
||||
...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.name', { defaultMessage: 'Name' }),
|
||||
switchValue: 'sortByName',
|
||||
switchGroupPrefix: 'sortBy',
|
||||
switchOption: 'sortBy',
|
||||
switchOptionValue: 'name',
|
||||
switchOptionIsDefault: true,
|
||||
closeOnSwitchClick: true,
|
||||
});
|
||||
res.push({
|
||||
label: _t('sqlObject.rowCount', { defaultMessage: 'Row count' }),
|
||||
switchValue: 'sortByRowCount',
|
||||
switchGroupPrefix: 'sortBy',
|
||||
switchOption: 'sortBy',
|
||||
switchOptionValue: 'rowCount',
|
||||
closeOnSwitchClick: true,
|
||||
});
|
||||
res.push({
|
||||
label: _t('sqlObject.sizeBytes', { defaultMessage: 'Size bytes' }),
|
||||
switchValue: 'sortBySizeBytes',
|
||||
switchGroupPrefix: 'sortBy',
|
||||
switchOption: 'sortBy',
|
||||
switchOptionValue: 'sizeBytes',
|
||||
closeOnSwitchClick: true,
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user