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 driver?.showConnectionField('treeKeySeparator', $values)}
|
||||
<FormTextField label="Key separator" name="treeKeySeparator" disabled={isConnected} placeholder=":" />
|
||||
{/if}
|
||||
|
||||
{#if driver?.showConnectionField('windowsDomain', $values)}
|
||||
<FormTextField label="Domain (specify to use NTLM authentication)" name="windowsDomain" disabled={isConnected} />
|
||||
{/if}
|
||||
|
@ -81,7 +81,7 @@ function splitCommandLine(str) {
|
||||
const driver = {
|
||||
...driverBase,
|
||||
analyserClass: Analyser,
|
||||
async connect({ server, port, password, database, useDatabaseUrl, databaseUrl }) {
|
||||
async connect({ server, port, password, database, useDatabaseUrl, databaseUrl, treeKeySeparator }) {
|
||||
let db = 0;
|
||||
let pool;
|
||||
if (useDatabaseUrl) {
|
||||
@ -95,6 +95,7 @@ const driver = {
|
||||
password,
|
||||
db,
|
||||
});
|
||||
pool.__treeKeySeparator = treeKeySeparator || ':';
|
||||
}
|
||||
|
||||
return pool;
|
||||
@ -146,7 +147,7 @@ const driver = {
|
||||
info
|
||||
.split('\n')
|
||||
.filter((x) => x.trim() && !x.trim().startsWith('#'))
|
||||
.map((x) => x.split(':'))
|
||||
.map((x) => x.split(pool.__treeKeySeparator))
|
||||
);
|
||||
},
|
||||
async getVersion(pool) {
|
||||
@ -164,7 +165,7 @@ const driver = {
|
||||
},
|
||||
|
||||
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 res = this.extractKeysFromLevel(root, keysFiltered);
|
||||
await this.enrichKeyInfo(pool, res);
|
||||
@ -197,12 +198,12 @@ const driver = {
|
||||
},
|
||||
|
||||
extractKeysFromLevel(root, keys) {
|
||||
const prefix = root ? `${root}:` : '';
|
||||
const rootSplit = _.compact(root.split(':'));
|
||||
const prefix = root ? `${root}${pool.__treeKeySeparator}` : '';
|
||||
const rootSplit = _.compact(root.split(pool.__treeKeySeparator));
|
||||
const res = {};
|
||||
for (const key of keys) {
|
||||
if (!key.startsWith(prefix)) continue;
|
||||
const keySplit = key.split(':');
|
||||
const keySplit = key.split(pool.__treeKeySeparator);
|
||||
if (keySplit.length > rootSplit.length) {
|
||||
const text = keySplit[rootSplit.length];
|
||||
if (keySplit.length == rootSplit.length + 1) {
|
||||
@ -216,9 +217,9 @@ const driver = {
|
||||
res[dctKey].count++;
|
||||
} else {
|
||||
res[dctKey] = {
|
||||
text: text + ':*',
|
||||
text: text + pool.__treeKeySeparator + '*',
|
||||
type: 'dir',
|
||||
root: keySplit.slice(0, rootSplit.length + 1).join(':'),
|
||||
root: keySplit.slice(0, rootSplit.length + 1).join(pool.__treeKeySeparator),
|
||||
count: 1,
|
||||
};
|
||||
}
|
||||
|
@ -78,9 +78,9 @@ const driver = {
|
||||
showConnectionField: (field, values) => {
|
||||
if (field == 'useDatabaseUrl') return true;
|
||||
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',
|
||||
|
Loading…
Reference in New Issue
Block a user