mirror of
https://github.com/dbgate/dbgate
synced 2024-11-07 20:26:23 +00:00
customizable redis key separator #379
This commit is contained in:
parent
53b6b71a29
commit
18b7792370
@ -173,6 +173,10 @@
|
|||||||
/>
|
/>
|
||||||
{/if}
|
{/if}
|
||||||
|
|
||||||
|
{#if driver?.showConnectionField('treeKeySeparator', $values)}
|
||||||
|
<FormTextField label="Key separator" name="treeKeySeparator" disabled={isConnected} placeholder=":" />
|
||||||
|
{/if}
|
||||||
|
|
||||||
{#if driver?.showConnectionField('windowsDomain', $values)}
|
{#if driver?.showConnectionField('windowsDomain', $values)}
|
||||||
<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}
|
||||||
|
@ -81,7 +81,7 @@ function splitCommandLine(str) {
|
|||||||
const driver = {
|
const driver = {
|
||||||
...driverBase,
|
...driverBase,
|
||||||
analyserClass: Analyser,
|
analyserClass: Analyser,
|
||||||
async connect({ server, port, password, database, useDatabaseUrl, databaseUrl }) {
|
async connect({ server, port, password, database, useDatabaseUrl, databaseUrl, treeKeySeparator }) {
|
||||||
let db = 0;
|
let db = 0;
|
||||||
let pool;
|
let pool;
|
||||||
if (useDatabaseUrl) {
|
if (useDatabaseUrl) {
|
||||||
@ -95,6 +95,7 @@ const driver = {
|
|||||||
password,
|
password,
|
||||||
db,
|
db,
|
||||||
});
|
});
|
||||||
|
pool.__treeKeySeparator = treeKeySeparator || ':';
|
||||||
}
|
}
|
||||||
|
|
||||||
return pool;
|
return pool;
|
||||||
@ -146,7 +147,7 @@ const driver = {
|
|||||||
info
|
info
|
||||||
.split('\n')
|
.split('\n')
|
||||||
.filter((x) => x.trim() && !x.trim().startsWith('#'))
|
.filter((x) => x.trim() && !x.trim().startsWith('#'))
|
||||||
.map((x) => x.split(':'))
|
.map((x) => x.split(pool.__treeKeySeparator))
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
async getVersion(pool) {
|
async getVersion(pool) {
|
||||||
@ -164,7 +165,7 @@ const driver = {
|
|||||||
},
|
},
|
||||||
|
|
||||||
async loadKeys(pool, root = '', filter = null) {
|
async loadKeys(pool, root = '', filter = null) {
|
||||||
const keys = await this.getKeys(pool, root ? `${root}:*` : '*');
|
const keys = await this.getKeys(pool, root ? `${root}${pool.__treeKeySeparator}*` : '*');
|
||||||
const keysFiltered = keys.filter((x) => filterName(filter, x));
|
const keysFiltered = keys.filter((x) => filterName(filter, x));
|
||||||
const res = this.extractKeysFromLevel(root, keysFiltered);
|
const res = this.extractKeysFromLevel(root, keysFiltered);
|
||||||
await this.enrichKeyInfo(pool, res);
|
await this.enrichKeyInfo(pool, res);
|
||||||
@ -197,12 +198,12 @@ const driver = {
|
|||||||
},
|
},
|
||||||
|
|
||||||
extractKeysFromLevel(root, keys) {
|
extractKeysFromLevel(root, keys) {
|
||||||
const prefix = root ? `${root}:` : '';
|
const prefix = root ? `${root}${pool.__treeKeySeparator}` : '';
|
||||||
const rootSplit = _.compact(root.split(':'));
|
const rootSplit = _.compact(root.split(pool.__treeKeySeparator));
|
||||||
const res = {};
|
const res = {};
|
||||||
for (const key of keys) {
|
for (const key of keys) {
|
||||||
if (!key.startsWith(prefix)) continue;
|
if (!key.startsWith(prefix)) continue;
|
||||||
const keySplit = key.split(':');
|
const keySplit = key.split(pool.__treeKeySeparator);
|
||||||
if (keySplit.length > rootSplit.length) {
|
if (keySplit.length > rootSplit.length) {
|
||||||
const text = keySplit[rootSplit.length];
|
const text = keySplit[rootSplit.length];
|
||||||
if (keySplit.length == rootSplit.length + 1) {
|
if (keySplit.length == rootSplit.length + 1) {
|
||||||
@ -216,9 +217,9 @@ const driver = {
|
|||||||
res[dctKey].count++;
|
res[dctKey].count++;
|
||||||
} else {
|
} else {
|
||||||
res[dctKey] = {
|
res[dctKey] = {
|
||||||
text: text + ':*',
|
text: text + pool.__treeKeySeparator + '*',
|
||||||
type: 'dir',
|
type: 'dir',
|
||||||
root: keySplit.slice(0, rootSplit.length + 1).join(':'),
|
root: keySplit.slice(0, rootSplit.length + 1).join(pool.__treeKeySeparator),
|
||||||
count: 1,
|
count: 1,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
@ -78,9 +78,9 @@ const driver = {
|
|||||||
showConnectionField: (field, values) => {
|
showConnectionField: (field, values) => {
|
||||||
if (field == 'useDatabaseUrl') return true;
|
if (field == 'useDatabaseUrl') return true;
|
||||||
if (values.useDatabaseUrl) {
|
if (values.useDatabaseUrl) {
|
||||||
return ['databaseUrl', 'isReadOnly'].includes(field);
|
return ['databaseUrl', 'isReadOnly', 'treeKeySeparator'].includes(field);
|
||||||
}
|
}
|
||||||
return ['server', 'port', 'password', 'isReadOnly'].includes(field);
|
return ['server', 'port', 'password', 'isReadOnly', 'treeKeySeparator'].includes(field);
|
||||||
},
|
},
|
||||||
|
|
||||||
showConnectionTab: (field) => field == 'sshTunnel',
|
showConnectionTab: (field) => field == 'sshTunnel',
|
||||||
|
Loading…
Reference in New Issue
Block a user