mirror of
https://github.com/dbgate/dbgate
synced 2024-11-07 20:26:23 +00:00
ability to disable background model updates
This commit is contained in:
parent
fd6524867e
commit
e647ab471e
@ -4,6 +4,7 @@ const socket = require('../utility/socket');
|
||||
const { fork } = require('child_process');
|
||||
const { DatabaseAnalyser } = require('dbgate-tools');
|
||||
const { handleProcessCommunication } = require('../utility/processComm');
|
||||
const config = require('./config');
|
||||
|
||||
module.exports = {
|
||||
/** @type {import('dbgate-types').OpenedDatabaseConnection[]} */
|
||||
@ -79,6 +80,7 @@ module.exports = {
|
||||
msgtype: 'connect',
|
||||
connection: { ...connection, database },
|
||||
structure: lastClosed ? lastClosed.structure : null,
|
||||
globalSettings: await config.getSettings()
|
||||
});
|
||||
return newOpened;
|
||||
},
|
||||
|
@ -5,6 +5,7 @@ const _ = require('lodash');
|
||||
const AsyncLock = require('async-lock');
|
||||
const { handleProcessCommunication } = require('../utility/processComm');
|
||||
const lock = new AsyncLock();
|
||||
const config = require('./config');
|
||||
|
||||
module.exports = {
|
||||
opened: [],
|
||||
@ -65,7 +66,7 @@ module.exports = {
|
||||
if (newOpened.disconnected) return;
|
||||
this.close(conid, false);
|
||||
});
|
||||
subprocess.send({ msgtype: 'connect', ...connection });
|
||||
subprocess.send({ msgtype: 'connect', ...connection, globalSettings: await config.getSettings() });
|
||||
return newOpened;
|
||||
});
|
||||
return res;
|
||||
|
@ -1,5 +1,6 @@
|
||||
const stableStringify = require('json-stable-stringify');
|
||||
const childProcessChecker = require('../utility/childProcessChecker');
|
||||
const { extractBoolSettingsValue, extractIntSettingsValue } = require('dbgate-tools');
|
||||
const requireEngineDriver = require('../utility/requireEngineDriver');
|
||||
const connectUtility = require('../utility/connectUtility');
|
||||
const { handleProcessCommunication } = require('../utility/processComm');
|
||||
@ -64,7 +65,7 @@ async function readVersion() {
|
||||
process.send({ msgtype: 'version', version });
|
||||
}
|
||||
|
||||
async function handleConnect({ connection, structure }) {
|
||||
async function handleConnect({ connection, structure, globalSettings }) {
|
||||
storedConnection = connection;
|
||||
lastPing = new Date().getTime();
|
||||
|
||||
@ -78,7 +79,14 @@ async function handleConnect({ connection, structure }) {
|
||||
} else {
|
||||
handleFullRefresh();
|
||||
}
|
||||
setInterval(handleIncrementalRefresh, 30 * 1000);
|
||||
|
||||
if (extractBoolSettingsValue(globalSettings, 'connection.autoRefresh', true)) {
|
||||
setInterval(
|
||||
handleIncrementalRefresh,
|
||||
extractIntSettingsValue(globalSettings, 'connection.autoRefreshInterval', 30, 3, 3600) * 1000
|
||||
);
|
||||
}
|
||||
|
||||
for (const [resolve] of afterConnectCallbacks) {
|
||||
resolve();
|
||||
}
|
||||
|
@ -1,4 +1,5 @@
|
||||
const stableStringify = require('json-stable-stringify');
|
||||
const { extractBoolSettingsValue, extractIntSettingsValue } = require('dbgate-tools');
|
||||
const childProcessChecker = require('../utility/childProcessChecker');
|
||||
const requireEngineDriver = require('../utility/requireEngineDriver');
|
||||
const { decryptConnection } = require('../utility/crypting');
|
||||
@ -51,6 +52,7 @@ function setStatusName(name) {
|
||||
|
||||
async function handleConnect(connection) {
|
||||
storedConnection = connection;
|
||||
const { globalSettings } = storedConnection;
|
||||
setStatusName('pending');
|
||||
lastPing = new Date().getTime();
|
||||
|
||||
@ -59,7 +61,9 @@ async function handleConnect(connection) {
|
||||
systemConnection = await connectUtility(driver, storedConnection);
|
||||
readVersion();
|
||||
handleRefresh();
|
||||
setInterval(handleRefresh, 30 * 1000);
|
||||
if (extractBoolSettingsValue(globalSettings, 'connection.autoRefresh', true)) {
|
||||
setInterval(handleRefresh, extractIntSettingsValue(globalSettings, 'connection.autoRefreshInterval', 30, 5, 3600) * 1000);
|
||||
}
|
||||
} catch (err) {
|
||||
setStatus({
|
||||
name: 'error',
|
||||
|
@ -9,3 +9,4 @@ export * from './SqlDumper';
|
||||
export * from './testPermission';
|
||||
export * from './SqlGenerator';
|
||||
export * from './structureTools';
|
||||
export * from './settingsExtractors';
|
||||
|
20
packages/tools/src/settingsExtractors.ts
Normal file
20
packages/tools/src/settingsExtractors.ts
Normal file
@ -0,0 +1,20 @@
|
||||
import _ from 'lodash';
|
||||
|
||||
export function extractIntSettingsValue(settings, name, defaultValue, min = null, max = null) {
|
||||
const parsed = parseInt(settings[name]);
|
||||
if (_.isNaN(parsed)) {
|
||||
return defaultValue;
|
||||
}
|
||||
if (_.isNumber(parsed)) {
|
||||
if (min != null && parsed < min) return min;
|
||||
if (max != null && parsed > max) return max;
|
||||
return parsed;
|
||||
}
|
||||
return defaultValue;
|
||||
}
|
||||
|
||||
export function extractBoolSettingsValue(settings, name, defaultValue) {
|
||||
const res = settings[name];
|
||||
if (res == null) return defaultValue;
|
||||
return !!res;
|
||||
}
|
@ -7,6 +7,7 @@
|
||||
import FormProvider from '../forms/FormProvider.svelte';
|
||||
import FormSubmit from '../forms/FormSubmit.svelte';
|
||||
import FormTextField from '../forms/FormTextField.svelte';
|
||||
import FormValues from '../forms/FormValues.svelte';
|
||||
|
||||
import ModalBase from '../modals/ModalBase.svelte';
|
||||
import { closeCurrentModal } from '../modals/modalTools';
|
||||
@ -32,17 +33,32 @@
|
||||
<ModalBase {...$$restProps}>
|
||||
<div slot="header">Settings</div>
|
||||
|
||||
<div class="heading">Appearance</div>
|
||||
<FormCheckboxField name=":visibleToolbar" label="Show toolbar" defaultValue={true} />
|
||||
<FormValues let:values>
|
||||
<div class="heading">Appearance</div>
|
||||
<FormCheckboxField name=":visibleToolbar" label="Show toolbar" defaultValue={true} />
|
||||
|
||||
<div class="heading">Data grid</div>
|
||||
<FormCheckboxField name="dataGrid.hideLeftColumn" label="Hide left column by default" />
|
||||
<FormTextField
|
||||
name="dataGrid.pageSize"
|
||||
label="Page size (number of rows for incremental loading, must be between 5 and 1000)"
|
||||
defaultValue="100"
|
||||
/>
|
||||
<FormCheckboxField name="dataGrid.showHintColumns" label="Show foreign key hints" defaultValue={true} />
|
||||
<div class="heading">Data grid</div>
|
||||
<FormCheckboxField name="dataGrid.hideLeftColumn" label="Hide left column by default" />
|
||||
<FormTextField
|
||||
name="dataGrid.pageSize"
|
||||
label="Page size (number of rows for incremental loading, must be between 5 and 1000)"
|
||||
defaultValue="100"
|
||||
/>
|
||||
<FormCheckboxField name="dataGrid.showHintColumns" label="Show foreign key hints" defaultValue={true} />
|
||||
|
||||
<div class="heading">Connection</div>
|
||||
<FormCheckboxField
|
||||
name="connection.autoRefresh"
|
||||
label="Automatic refresh of database model on background"
|
||||
defaultValue={true}
|
||||
/>
|
||||
<FormTextField
|
||||
name="connection.autoRefreshInterval"
|
||||
label="Interval between automatic refreshes in seconds"
|
||||
defaultValue="30"
|
||||
disabled={values['connection.autoRefresh'] === false}
|
||||
/>
|
||||
</FormValues>
|
||||
|
||||
<div slot="footer">
|
||||
<FormSubmit value="OK" on:click={handleOk} />
|
||||
|
Loading…
Reference in New Issue
Block a user