mirror of
https://github.com/dbgate/dbgate
synced 2024-11-07 20:26:23 +00:00
oracle thick mode available for electron app
This commit is contained in:
parent
5e68ce3218
commit
dc45b1e75f
@ -42,6 +42,7 @@ module.exports = {
|
||||
allowShellConnection: platformInfo.allowShellConnection,
|
||||
allowShellScripting: platformInfo.allowShellScripting,
|
||||
isDocker: platformInfo.isDocker,
|
||||
isElectron: platformInfo.isElectron,
|
||||
permissions,
|
||||
login,
|
||||
...additionalConfigProps,
|
||||
|
@ -11,6 +11,7 @@ const loadedPlugins = {};
|
||||
const dbgateEnv = {
|
||||
dbgateApi: null,
|
||||
nativeModules,
|
||||
platformInfo,
|
||||
};
|
||||
function requirePlugin(packageName, requiredPlugin = null) {
|
||||
if (!packageName) throw new Error('Missing packageName in plugin');
|
||||
|
8
packages/types/engines.d.ts
vendored
8
packages/types/engines.d.ts
vendored
@ -90,7 +90,13 @@ export interface EngineDriver {
|
||||
profilerChartMeasures?: { label: string; field: string }[];
|
||||
isElectronOnly?: boolean;
|
||||
supportedCreateDatabase?: boolean;
|
||||
showConnectionField?: (field: string, values: any) => boolean;
|
||||
showConnectionField?: (
|
||||
field: string,
|
||||
values: any,
|
||||
{
|
||||
config: {},
|
||||
}
|
||||
) => boolean;
|
||||
showConnectionTab?: (tab: 'ssl' | 'sshTunnel', values: any) => boolean;
|
||||
beforeConnectionSave?: (values: any) => any;
|
||||
databaseUrlPlaceholder?: string;
|
||||
|
@ -12,7 +12,7 @@
|
||||
import FormTextField from '../forms/FormTextField.svelte';
|
||||
import { extensions, getCurrentConfig, openedConnections, openedSingleDatabaseConnections } from '../stores';
|
||||
import getElectron from '../utility/getElectron';
|
||||
import { useAuthTypes } from '../utility/metadataLoaders';
|
||||
import { useAuthTypes, useConfig } from '../utility/metadataLoaders';
|
||||
import FormColorField from '../forms/FormColorField.svelte';
|
||||
import FontIcon from '../icons/FontIcon.svelte';
|
||||
|
||||
@ -27,13 +27,16 @@
|
||||
$: disabledFields = (currentAuthType ? currentAuthType.disabledFields : null) || [];
|
||||
$: driver = $extensions.drivers.find(x => x.engine == engine);
|
||||
$: defaultDatabase = $values.defaultDatabase;
|
||||
$: config = useConfig();
|
||||
|
||||
$: showUser = driver?.showConnectionField('user', $values) && $values.passwordMode != 'askUser';
|
||||
$: showConnectionFieldArgs = { config: $config };
|
||||
|
||||
$: showUser = driver?.showConnectionField('user', $values, showConnectionFieldArgs) && $values.passwordMode != 'askUser';
|
||||
$: showPassword =
|
||||
driver?.showConnectionField('password', $values) &&
|
||||
driver?.showConnectionField('password', $values, showConnectionFieldArgs) &&
|
||||
$values.passwordMode != 'askPassword' &&
|
||||
$values.passwordMode != 'askUser';
|
||||
$: showPasswordMode = driver?.showConnectionField('password', $values);
|
||||
$: showPasswordMode = driver?.showConnectionField('password', $values, showConnectionFieldArgs);
|
||||
$: isConnected = $openedConnections.includes($values._id) || $openedSingleDatabaseConnections.includes($values._id);
|
||||
</script>
|
||||
|
||||
@ -53,11 +56,11 @@
|
||||
]}
|
||||
/>
|
||||
|
||||
{#if driver?.showConnectionField('databaseFile', $values)}
|
||||
{#if driver?.showConnectionField('databaseFile', $values, showConnectionFieldArgs)}
|
||||
<FormElectronFileSelector label="Database file" name="databaseFile" disabled={isConnected || !electron} />
|
||||
{/if}
|
||||
|
||||
{#if driver?.showConnectionField('useDatabaseUrl', $values)}
|
||||
{#if driver?.showConnectionField('useDatabaseUrl', $values, showConnectionFieldArgs)}
|
||||
<div class="radio">
|
||||
<FormRadioGroupField
|
||||
disabled={isConnected}
|
||||
@ -70,7 +73,7 @@
|
||||
</div>
|
||||
{/if}
|
||||
|
||||
{#if driver?.showConnectionField('databaseUrl', $values)}
|
||||
{#if driver?.showConnectionField('databaseUrl', $values, showConnectionFieldArgs)}
|
||||
<FormTextField
|
||||
label="Database URL"
|
||||
name="databaseUrl"
|
||||
@ -79,7 +82,7 @@
|
||||
/>
|
||||
{/if}
|
||||
|
||||
{#if $authTypes && driver?.showConnectionField('authType', $values)}
|
||||
{#if $authTypes && driver?.showConnectionField('authType', $values, showConnectionFieldArgs)}
|
||||
<FormSelectField
|
||||
label={driver?.authTypeLabel ?? 'Authentication'}
|
||||
name="authType"
|
||||
@ -93,15 +96,11 @@
|
||||
/>
|
||||
{/if}
|
||||
|
||||
{#if driver?.showConnectionField('clientLibraryPath', $values)}
|
||||
<FormTextField
|
||||
label="Client library path"
|
||||
name="clientLibraryPath"
|
||||
disabled={isConnected}
|
||||
/>
|
||||
{#if driver?.showConnectionField('clientLibraryPath', $values, showConnectionFieldArgs)}
|
||||
<FormTextField label="Client library path" name="clientLibraryPath" disabled={isConnected} />
|
||||
{/if}
|
||||
|
||||
{#if driver?.showConnectionField('server', $values)}
|
||||
{#if driver?.showConnectionField('server', $values, showConnectionFieldArgs)}
|
||||
<div class="row">
|
||||
<div class="col-9 mr-1">
|
||||
<FormTextField
|
||||
@ -111,7 +110,7 @@
|
||||
templateProps={{ noMargin: true }}
|
||||
/>
|
||||
</div>
|
||||
{#if driver?.showConnectionField('port', $values)}
|
||||
{#if driver?.showConnectionField('port', $values, showConnectionFieldArgs)}
|
||||
<div class="col-3 mr-1">
|
||||
<FormTextField
|
||||
label="Port"
|
||||
@ -131,11 +130,11 @@
|
||||
{/if}
|
||||
{/if}
|
||||
|
||||
{#if driver?.showConnectionField('serviceName', $values)}
|
||||
{#if driver?.showConnectionField('serviceName', $values, showConnectionFieldArgs)}
|
||||
<FormTextField label="Service name" name="serviceName" disabled={isConnected} />
|
||||
{/if}
|
||||
|
||||
{#if driver?.showConnectionField('socketPath', $values)}
|
||||
{#if driver?.showConnectionField('socketPath', $values, showConnectionFieldArgs)}
|
||||
<FormTextField
|
||||
label="Socket path"
|
||||
name="socketPath"
|
||||
@ -191,27 +190,27 @@
|
||||
/>
|
||||
{/if}
|
||||
|
||||
{#if driver?.showConnectionField('treeKeySeparator', $values)}
|
||||
{#if driver?.showConnectionField('treeKeySeparator', $values, showConnectionFieldArgs)}
|
||||
<FormTextField label="Key separator" name="treeKeySeparator" disabled={isConnected} placeholder=":" />
|
||||
{/if}
|
||||
|
||||
{#if driver?.showConnectionField('windowsDomain', $values)}
|
||||
{#if driver?.showConnectionField('windowsDomain', $values, showConnectionFieldArgs)}
|
||||
<FormTextField label="Domain (specify to use NTLM authentication)" name="windowsDomain" disabled={isConnected} />
|
||||
{/if}
|
||||
|
||||
{#if driver?.showConnectionField('isReadOnly', $values)}
|
||||
{#if driver?.showConnectionField('isReadOnly', $values, showConnectionFieldArgs)}
|
||||
<FormCheckboxField label="Is read only" name="isReadOnly" disabled={isConnected} />
|
||||
{/if}
|
||||
|
||||
{#if driver?.showConnectionField('trustServerCertificate', $values)}
|
||||
{#if driver?.showConnectionField('trustServerCertificate', $values, showConnectionFieldArgs)}
|
||||
<FormCheckboxField label="Trust server certificate" name="trustServerCertificate" disabled={isConnected} />
|
||||
{/if}
|
||||
|
||||
{#if driver?.showConnectionField('defaultDatabase', $values)}
|
||||
{#if driver?.showConnectionField('defaultDatabase', $values, showConnectionFieldArgs)}
|
||||
<FormTextField label="Default database" name="defaultDatabase" disabled={isConnected} />
|
||||
{/if}
|
||||
|
||||
{#if defaultDatabase && driver?.showConnectionField('singleDatabase', $values)}
|
||||
{#if defaultDatabase && driver?.showConnectionField('singleDatabase', $values, showConnectionFieldArgs)}
|
||||
<FormCheckboxField label={`Use only database ${defaultDatabase}`} name="singleDatabase" disabled={isConnected} />
|
||||
{/if}
|
||||
|
||||
|
@ -32,6 +32,7 @@
|
||||
import { onMount } from 'svelte';
|
||||
import { disconnectServerConnection, openConnection } from '../appobj/ConnectionAppObject.svelte';
|
||||
import { disconnectDatabaseConnection } from '../appobj/DatabaseAppObject.svelte';
|
||||
import { useConfig } from '../utility/metadataLoaders';
|
||||
|
||||
export let connection;
|
||||
export let tabid;
|
||||
@ -57,6 +58,7 @@
|
||||
|
||||
$: engine = $values.engine;
|
||||
$: driver = $extensions.drivers.find(x => x.engine == engine);
|
||||
$: config = useConfig();
|
||||
|
||||
const testIdRef = createRef(0);
|
||||
|
||||
@ -91,7 +93,7 @@
|
||||
'socketPath',
|
||||
'serviceName',
|
||||
];
|
||||
const visibleProps = allProps.filter(x => driver?.showConnectionField(x, $values));
|
||||
const visibleProps = allProps.filter(x => driver?.showConnectionField(x, $values, { config: $config }));
|
||||
const omitProps = _.difference(allProps, visibleProps);
|
||||
if (!$values.defaultDatabase) omitProps.push('singleDatabase');
|
||||
|
||||
|
@ -5,8 +5,10 @@ const driverBase = require('../frontend/driver');
|
||||
const Analyser = require('./Analyser');
|
||||
const { createBulkInsertStreamBase, makeUniqueColumnNames } = require('dbgate-tools');
|
||||
const createOracleBulkInsertStream = require('./createOracleBulkInsertStream');
|
||||
const { platform } = require('os');
|
||||
|
||||
let requireOracledb;
|
||||
let platformInfo;
|
||||
|
||||
let oracledbValue;
|
||||
function getOracledb() {
|
||||
@ -16,7 +18,6 @@ function getOracledb() {
|
||||
return oracledbValue;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
pg.types.setTypeParser(1082, 'text', val => val); // date
|
||||
pg.types.setTypeParser(1114, 'text', val => val); // timestamp without timezone
|
||||
@ -327,23 +328,26 @@ const driver = {
|
||||
},
|
||||
|
||||
getAuthTypes() {
|
||||
return [
|
||||
{
|
||||
title: 'Thin mode (default) - direct connection to Oracle database',
|
||||
name: 'thin',
|
||||
},
|
||||
{
|
||||
title: 'Thick mode - connection via Oracle instant client',
|
||||
name: 'thick',
|
||||
},
|
||||
];
|
||||
if (platformInfo?.isElectron || process.env.ORACLE_INSTANT_CLIENT) {
|
||||
return [
|
||||
{
|
||||
title: 'Thin mode (default) - direct connection to Oracle database',
|
||||
name: 'thin',
|
||||
},
|
||||
{
|
||||
title: 'Thick mode - connection via Oracle instant client',
|
||||
name: 'thick',
|
||||
},
|
||||
];
|
||||
}
|
||||
},
|
||||
};
|
||||
|
||||
driver.initialize = (dbgateEnv) => {
|
||||
driver.initialize = dbgateEnv => {
|
||||
if (dbgateEnv.nativeModules && dbgateEnv.nativeModules['oracledb']) {
|
||||
requireOracledb = dbgateEnv.nativeModules['oracledb'];
|
||||
}
|
||||
platformInfo = dbgateEnv.platformInfo;
|
||||
};
|
||||
|
||||
module.exports = driver;
|
||||
|
@ -98,11 +98,10 @@ const oracleDriver = {
|
||||
|
||||
databaseUrlPlaceholder: 'e.g. localhost:1521/orcl',
|
||||
|
||||
|
||||
showConnectionField: (field, values) => {
|
||||
showConnectionField: (field, values, { config }) => {
|
||||
if (field == 'useDatabaseUrl') return true;
|
||||
if (field == 'authType') return true;
|
||||
if (field == 'clientLibraryPath') return values.authType == 'thick';
|
||||
if (field == 'clientLibraryPath') return config?.isElectron && values.authType == 'thick';
|
||||
|
||||
if (values.useDatabaseUrl) {
|
||||
return ['databaseUrl', 'user', 'password'].includes(field);
|
||||
|
Loading…
Reference in New Issue
Block a user