mirror of
https://github.com/dbgate/dbgate
synced 2024-11-07 20:26:23 +00:00
allowed databases config
This commit is contained in:
parent
7c8156fbb9
commit
61b9fd9210
@ -16,7 +16,18 @@ let afterConnectCallbacks = [];
|
||||
async function handleRefresh() {
|
||||
const driver = requireEngineDriver(storedConnection);
|
||||
try {
|
||||
const databases = await driver.listDatabases(systemConnection);
|
||||
let databases = await driver.listDatabases(systemConnection);
|
||||
if (storedConnection?.allowedDatabases?.trim()) {
|
||||
const allowedDatabaseList = storedConnection.allowedDatabases
|
||||
.split('\n')
|
||||
.map(x => x.trim().toLowerCase())
|
||||
.filter(x => x);
|
||||
databases = databases.filter(x => allowedDatabaseList.includes(x.name.toLocaleLowerCase()));
|
||||
}
|
||||
if (storedConnection?.allowedDatabasesRegex?.trim()) {
|
||||
const regex = new RegExp(storedConnection.allowedDatabasesRegex, 'i');
|
||||
databases = databases.filter(x => regex.test(x.name));
|
||||
}
|
||||
setStatusName('ok');
|
||||
const databasesString = stableStringify(databases);
|
||||
if (lastDatabases != databasesString) {
|
||||
|
@ -121,6 +121,15 @@ body {
|
||||
border-radius: 4px;
|
||||
}
|
||||
|
||||
.largeFormMarker textarea {
|
||||
width: 100%;
|
||||
padding: 10px 10px;
|
||||
font-size: 14px;
|
||||
box-sizing: border-box;
|
||||
border-radius: 4px;
|
||||
border: 1px solid var(--theme-border);
|
||||
}
|
||||
|
||||
body *::-webkit-scrollbar {
|
||||
height: 0.8em;
|
||||
width: 0.8em;
|
||||
@ -169,6 +178,10 @@ textarea {
|
||||
border: 1px solid var(--theme-border);
|
||||
}
|
||||
|
||||
textarea[disabled] {
|
||||
background-color: var(--theme-bg-1);
|
||||
}
|
||||
|
||||
.ace_gutter-cell.ace-gutter-sql-run {
|
||||
background-repeat: no-repeat;
|
||||
background-position: 2px center;
|
||||
|
15
packages/web/src/forms/FormTextAreaField.svelte
Normal file
15
packages/web/src/forms/FormTextAreaField.svelte
Normal file
@ -0,0 +1,15 @@
|
||||
<script lang="ts">
|
||||
import { getFormContext } from './FormProviderCore.svelte';
|
||||
import FormTextAreaFieldRaw from './FormTextAreaFieldRaw.svelte';
|
||||
|
||||
export let label;
|
||||
export let name;
|
||||
export let templateProps = {};
|
||||
export let focused = false;
|
||||
|
||||
const { template } = getFormContext();
|
||||
</script>
|
||||
|
||||
<svelte:component this={template} type="text" {label} {...templateProps}>
|
||||
<FormTextAreaFieldRaw {name} {...$$restProps} {focused} />
|
||||
</svelte:component>
|
21
packages/web/src/forms/FormTextAreaFieldRaw.svelte
Normal file
21
packages/web/src/forms/FormTextAreaFieldRaw.svelte
Normal file
@ -0,0 +1,21 @@
|
||||
<script lang="ts">
|
||||
import { getFormContext } from './FormProviderCore.svelte';
|
||||
import TextAreaField from './TextAreaField.svelte';
|
||||
|
||||
export let name;
|
||||
export let defaultValue = undefined;
|
||||
export let saveOnInput = false;
|
||||
|
||||
const { values, setFieldValue } = getFormContext();
|
||||
</script>
|
||||
|
||||
<TextAreaField
|
||||
{...$$restProps}
|
||||
value={$values[name] ?? defaultValue}
|
||||
on:input={e => setFieldValue(name, e.target['value'])}
|
||||
on:input={e => {
|
||||
if (saveOnInput) {
|
||||
setFieldValue(name, e.target['value']);
|
||||
}
|
||||
}}
|
||||
/>
|
@ -2,7 +2,7 @@
|
||||
import { onMount } from 'svelte';
|
||||
|
||||
export let value;
|
||||
export let focused;
|
||||
export let focused = false;
|
||||
|
||||
let domEditor;
|
||||
|
||||
|
@ -0,0 +1,13 @@
|
||||
<script lang="ts">
|
||||
import FormTextField from '../forms/FormTextField.svelte';
|
||||
import { openedConnections, openedSingleDatabaseConnections } from '../stores';
|
||||
import { getFormContext } from '../forms/FormProviderCore.svelte';
|
||||
import FormTextAreaField from '../forms/FormTextAreaField.svelte';
|
||||
|
||||
const { values } = getFormContext();
|
||||
|
||||
$: isConnected = $openedConnections.includes($values._id) || $openedSingleDatabaseConnections.includes($values._id);
|
||||
</script>
|
||||
|
||||
<FormTextAreaField label="Allowed databases, one per line" name="allowedDatabases" disabled={isConnected} rows={8} />
|
||||
<FormTextField label="Allowed databases regular expression" name="allowedDatabasesRegex" disabled={isConnected} />
|
@ -33,6 +33,7 @@
|
||||
import { disconnectServerConnection, openConnection } from '../appobj/ConnectionAppObject.svelte';
|
||||
import { disconnectDatabaseConnection } from '../appobj/DatabaseAppObject.svelte';
|
||||
import { useConfig } from '../utility/metadataLoaders';
|
||||
import ConnectionAdvancedDriverFields from '../settings/ConnectionAdvancedDriverFields.svelte';
|
||||
|
||||
export let connection;
|
||||
export let tabid;
|
||||
@ -210,6 +211,10 @@
|
||||
label: 'SSL',
|
||||
component: ConnectionSslFields,
|
||||
},
|
||||
{
|
||||
label: 'Advanced',
|
||||
component: ConnectionAdvancedDriverFields,
|
||||
},
|
||||
]}
|
||||
/>
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user