mirror of
https://github.com/DeNNiiInc/dbgate.git
synced 2026-04-21 17:36:01 +00:00
Merge branch 'master' of https://github.com/dbgate/dbgate
This commit is contained in:
@@ -222,6 +222,7 @@
|
||||
|
||||
'icon premium': 'mdi mdi-star',
|
||||
'icon upload': 'mdi mdi-upload',
|
||||
'icon limit': 'mdi mdi-car-speed-limiter',
|
||||
|
||||
'img ok': 'mdi mdi-check-circle color-icon-green',
|
||||
'img ok-inv': 'mdi mdi-check-circle color-icon-inv-green',
|
||||
|
||||
41
packages/web/src/modals/RowsLimitModal.svelte
Normal file
41
packages/web/src/modals/RowsLimitModal.svelte
Normal file
@@ -0,0 +1,41 @@
|
||||
<script lang="ts">
|
||||
import FormStyledButton from '../buttons/FormStyledButton.svelte';
|
||||
|
||||
import FormProvider from '../forms/FormProvider.svelte';
|
||||
import FormSubmit from '../forms/FormSubmit.svelte';
|
||||
import FormTextField from '../forms/FormTextField.svelte';
|
||||
import ModalBase from './ModalBase.svelte';
|
||||
import { closeCurrentModal } from './modalTools';
|
||||
|
||||
export let value;
|
||||
export let onConfirm;
|
||||
|
||||
const handleSubmit = async value => {
|
||||
closeCurrentModal();
|
||||
onConfirm(value);
|
||||
};
|
||||
</script>
|
||||
|
||||
<FormProvider initialValues={{ value }}>
|
||||
<ModalBase {...$$restProps}>
|
||||
<svelte:fragment slot="header">Rows limit</svelte:fragment>
|
||||
|
||||
<FormTextField
|
||||
label="Return only N rows from query"
|
||||
name="value"
|
||||
focused
|
||||
data-testid="RowsLimitModal_value"
|
||||
placeholder="(No rows limit)"
|
||||
/>
|
||||
|
||||
<svelte:fragment slot="footer">
|
||||
<FormSubmit
|
||||
value="OK"
|
||||
on:click={e => handleSubmit(parseInt(e.detail.value) || null)}
|
||||
data-testid="RowsLimitModal_setLimit"
|
||||
/>
|
||||
<FormStyledButton value="Set no limit" on:click={e => handleSubmit(null)} data-testid="RowsLimitModal_setNoLimit" />
|
||||
<FormStyledButton type="button" value="Cancel" on:click={closeCurrentModal} data-testid="RowsLimitModal_cancel" />
|
||||
</svelte:fragment>
|
||||
</ModalBase>
|
||||
</FormProvider>
|
||||
@@ -227,6 +227,12 @@ ORDER BY
|
||||
</FormFieldTemplateLarge>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<FormTextField
|
||||
name="sqlEditor.limitRows"
|
||||
label="Return only N rows from query"
|
||||
placeholder="(No rows limit)"
|
||||
/>
|
||||
</svelte:fragment>
|
||||
<svelte:fragment slot="2">
|
||||
<div class="heading">Connection</div>
|
||||
|
||||
@@ -144,6 +144,9 @@
|
||||
import HorizontalSplitter from '../elements/HorizontalSplitter.svelte';
|
||||
import QueryAiAssistant from '../query/QueryAiAssistant.svelte';
|
||||
import uuidv1 from 'uuid/v1';
|
||||
import ToolStripButton from '../buttons/ToolStripButton.svelte';
|
||||
import { getIntSettingsValue } from '../settings/settingsTools';
|
||||
import RowsLimitModal from '../modals/RowsLimitModal.svelte';
|
||||
|
||||
export let tabid;
|
||||
export let conid;
|
||||
@@ -197,6 +200,21 @@
|
||||
let isInTransaction = false;
|
||||
let isAutocommit = false;
|
||||
|
||||
const queryRowsLimitLocalStorageKey = `tabdata_limitRows_${tabid}`;
|
||||
function getInitialRowsLimit() {
|
||||
const storageValue = localStorage.getItem(queryRowsLimitLocalStorageKey);
|
||||
if (storageValue == 'nolimit') {
|
||||
return null;
|
||||
}
|
||||
if (storageValue) {
|
||||
return parseInt(storageValue) ?? null;
|
||||
}
|
||||
return getIntSettingsValue('sqlEditor.limitRows', null, 1);
|
||||
}
|
||||
|
||||
let queryRowsLimit = getInitialRowsLimit();
|
||||
$: localStorage.setItem(queryRowsLimitLocalStorageKey, queryRowsLimit ? queryRowsLimit.toString() : 'nolimit');
|
||||
|
||||
onMount(() => {
|
||||
intervalId = setInterval(() => {
|
||||
if (!driver?.singleConnectionOnly && sessionId) {
|
||||
@@ -362,6 +380,7 @@
|
||||
sesid,
|
||||
sql,
|
||||
autoCommit: driver?.implicitTransactions && isAutocommit,
|
||||
limitRows: queryRowsLimit ? queryRowsLimit : undefined,
|
||||
});
|
||||
}
|
||||
await apiCall('query-history/write', {
|
||||
@@ -713,6 +732,20 @@
|
||||
<ToolStripCommandButton command="query.kill" data-testid="QueryTab_killButton" />
|
||||
<ToolStripSaveButton idPrefix="query" />
|
||||
<ToolStripCommandButton command="query.formatCode" />
|
||||
{#if !driver?.singleConnectionOnly}
|
||||
<ToolStripButton
|
||||
icon="icon limit"
|
||||
on:click={() =>
|
||||
showModal(RowsLimitModal, {
|
||||
value: queryRowsLimit,
|
||||
onConfirm: value => {
|
||||
queryRowsLimit = value;
|
||||
},
|
||||
})}
|
||||
>
|
||||
{queryRowsLimit ? `Limit ${queryRowsLimit} rows` : 'Unlimited rows'}</ToolStripButton
|
||||
>
|
||||
{/if}
|
||||
{#if resultCount == 1}
|
||||
<ToolStripExportButton command="jslTableGrid.export" {quickExportHandlerRef} label="Export result" />
|
||||
{/if}
|
||||
|
||||
Reference in New Issue
Block a user