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