mirror of
https://github.com/DeNNiiInc/dbgate.git
synced 2026-04-25 21:15:59 +00:00
Redis "Scan all" button
This commit is contained in:
@@ -226,6 +226,7 @@
|
|||||||
'icon type-unknown': 'mdi mdi-help-box',
|
'icon type-unknown': 'mdi mdi-help-box',
|
||||||
'icon equal': 'mdi mdi-equal',
|
'icon equal': 'mdi mdi-equal',
|
||||||
'icon not-equal': 'mdi mdi-not-equal-variant',
|
'icon not-equal': 'mdi mdi-not-equal-variant',
|
||||||
|
'icon warn': 'mdi mdi-alert',
|
||||||
|
|
||||||
'icon at': 'mdi mdi-at',
|
'icon at': 'mdi mdi-at',
|
||||||
'icon expand-all': 'mdi mdi-expand-all',
|
'icon expand-all': 'mdi mdi-expand-all',
|
||||||
|
|||||||
@@ -33,6 +33,7 @@
|
|||||||
import AppObjectListHandler from './AppObjectListHandler.svelte';
|
import AppObjectListHandler from './AppObjectListHandler.svelte';
|
||||||
import { getOpenDetailOnArrowsSettings } from '../settings/settingsTools';
|
import { getOpenDetailOnArrowsSettings } from '../settings/settingsTools';
|
||||||
import openNewTab from '../utility/openNewTab';
|
import openNewTab from '../utility/openNewTab';
|
||||||
|
import ConfirmModal from '../modals/ConfirmModal.svelte';
|
||||||
|
|
||||||
export let conid;
|
export let conid;
|
||||||
export let database;
|
export let database;
|
||||||
@@ -83,20 +84,30 @@
|
|||||||
if (loadNext) loadNextPage();
|
if (loadNext) loadNextPage();
|
||||||
}
|
}
|
||||||
|
|
||||||
async function loadNextPage() {
|
async function loadNextPage(skipCount = false) {
|
||||||
isLoading = true;
|
isLoading = true;
|
||||||
const nextScan = await apiCall('database-connections/scan-keys', {
|
const nextScan = await apiCall('database-connections/scan-keys', {
|
||||||
conid,
|
conid,
|
||||||
database,
|
database,
|
||||||
pattern: filter,
|
pattern: filter,
|
||||||
cursor: model.cursor,
|
cursor: model.cursor,
|
||||||
count: model.loadCount,
|
count: skipCount ? undefined : model.loadCount,
|
||||||
});
|
});
|
||||||
|
|
||||||
model = dbKeys_mergeNextPage(model, nextScan);
|
model = dbKeys_mergeNextPage(model, nextScan);
|
||||||
isLoading = false;
|
isLoading = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async function loadAll() {
|
||||||
|
showModal(ConfirmModal, {
|
||||||
|
message:
|
||||||
|
'This will scan all keys in the database, which could affect server performance. Do you want to continue?',
|
||||||
|
onConfirm: () => {
|
||||||
|
loadNextPage(true);
|
||||||
|
},
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
function reloadModel() {
|
function reloadModel() {
|
||||||
changeModel(model => dbKeys_clearLoadedData(model), true);
|
changeModel(model => dbKeys_clearLoadedData(model), true);
|
||||||
}
|
}
|
||||||
@@ -145,9 +156,14 @@
|
|||||||
<FontIcon icon="icon loading" />
|
<FontIcon icon="icon loading" />
|
||||||
</div>
|
</div>
|
||||||
{:else}
|
{:else}
|
||||||
<InlineButton on:click={loadNextPage} title="Scan more keys">
|
<div class="flex">
|
||||||
<FontIcon icon="icon more" /> Scan more
|
<InlineButton on:click={() => loadNextPage()} title="Scan more keys">
|
||||||
</InlineButton>
|
<FontIcon icon="icon more" /> Scan more
|
||||||
|
</InlineButton>
|
||||||
|
<InlineButton on:click={() => loadAll()} title="Scan all keys">
|
||||||
|
<FontIcon icon="icon warn" /> Scan all
|
||||||
|
</InlineButton>
|
||||||
|
</div>
|
||||||
{/if}
|
{/if}
|
||||||
</div>
|
</div>
|
||||||
{/if}
|
{/if}
|
||||||
|
|||||||
@@ -203,7 +203,7 @@ const driver = {
|
|||||||
|
|
||||||
async scanKeys(dbhan, pattern, cursor = 0, count) {
|
async scanKeys(dbhan, pattern, cursor = 0, count) {
|
||||||
const match = pattern?.match(/[\?\[\{]/) ? pattern : pattern ? `*${pattern}*` : '*';
|
const match = pattern?.match(/[\?\[\{]/) ? pattern : pattern ? `*${pattern}*` : '*';
|
||||||
const [nextCursor, keys] = await dbhan.client.scan(cursor, 'MATCH', match, 'COUNT', count);
|
const [nextCursor, keys] = await dbhan.client.scan(cursor, 'MATCH', match, 'COUNT', count ?? 2 ** 32);
|
||||||
const dbsize = await dbhan.client.dbsize();
|
const dbsize = await dbhan.client.dbsize();
|
||||||
const keysMapped = keys.map((key) => ({
|
const keysMapped = keys.map((key) => ({
|
||||||
key,
|
key,
|
||||||
|
|||||||
Reference in New Issue
Block a user