mirror of
https://github.com/Fabio286/antares.git
synced 2025-02-01 18:06:53 +01:00
Merge branch 'postgres_con_string' into fix-and-minimize-con-string
This commit is contained in:
commit
b2ce533b82
@ -109,7 +109,7 @@
|
|||||||
"@turf/helpers": "^6.5.0",
|
"@turf/helpers": "^6.5.0",
|
||||||
"@vscode/vscode-languagedetection": "^1.0.21",
|
"@vscode/vscode-languagedetection": "^1.0.21",
|
||||||
"ace-builds": "^1.4.13",
|
"ace-builds": "^1.4.13",
|
||||||
"better-sqlite3": "^7.4.4",
|
"better-sqlite3": "^7.5.0",
|
||||||
"electron-log": "^4.4.1",
|
"electron-log": "^4.4.1",
|
||||||
"electron-store": "^8.0.1",
|
"electron-store": "^8.0.1",
|
||||||
"electron-updater": "^4.6.1",
|
"electron-updater": "^4.6.1",
|
||||||
|
@ -93,16 +93,16 @@ export default {
|
|||||||
</script>
|
</script>
|
||||||
|
|
||||||
<style lang="scss">
|
<style lang="scss">
|
||||||
.map{
|
.map {
|
||||||
height: 400px;
|
height: 400px;
|
||||||
}
|
}
|
||||||
|
|
||||||
.marker-icon{
|
.marker-icon {
|
||||||
display: flex;
|
display: flex;
|
||||||
justify-content: center;
|
justify-content: center;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
background: $primary-color;
|
background: $primary-color;
|
||||||
border-radius: 50%;
|
border-radius: 50%;
|
||||||
box-shadow: 0 0 5px 1px darken($body-font-color-dark, 40%);
|
box-shadow: 0 0 5px 1px darken($body-font-color-dark, 40%);
|
||||||
}
|
}
|
||||||
</style>
|
</style>
|
||||||
|
@ -61,6 +61,19 @@
|
|||||||
</select>
|
</select>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
<div v-if="connection.client === 'pg'" class="form-group columns">
|
||||||
|
<div class="column col-4 col-sm-12">
|
||||||
|
<label class="form-label">{{ $t('word.connectionString') }}</label>
|
||||||
|
</div>
|
||||||
|
<div class="column col-8 col-sm-12">
|
||||||
|
<input
|
||||||
|
ref="pgString"
|
||||||
|
v-model="connection.pgConnString"
|
||||||
|
class="form-input"
|
||||||
|
type="text"
|
||||||
|
>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
<div v-if="!customizations.fileConnection" class="form-group columns">
|
<div v-if="!customizations.fileConnection" class="form-group columns">
|
||||||
<div class="column col-4 col-sm-12">
|
<div class="column col-4 col-sm-12">
|
||||||
<label class="form-label">{{ $t('word.hostName') }}/IP</label>
|
<label class="form-label">{{ $t('word.hostName') }}/IP</label>
|
||||||
@ -412,7 +425,8 @@ export default {
|
|||||||
sshUser: '',
|
sshUser: '',
|
||||||
sshPass: '',
|
sshPass: '',
|
||||||
sshKey: '',
|
sshKey: '',
|
||||||
sshPort: 22
|
sshPort: 22,
|
||||||
|
pgConnString: ''
|
||||||
},
|
},
|
||||||
isConnecting: false,
|
isConnecting: false,
|
||||||
isTesting: false,
|
isTesting: false,
|
||||||
|
@ -61,6 +61,19 @@
|
|||||||
</select>
|
</select>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
<div v-if="connection.client === 'pg'" class="form-group columns">
|
||||||
|
<div class="column col-4 col-sm-12">
|
||||||
|
<label class="form-label">{{ $t('word.connectionString') }}</label>
|
||||||
|
</div>
|
||||||
|
<div class="column col-8 col-sm-12">
|
||||||
|
<input
|
||||||
|
ref="pgString"
|
||||||
|
v-model="localConnection.pgConnString"
|
||||||
|
class="form-input"
|
||||||
|
type="text"
|
||||||
|
>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
<div v-if="!customizations.fileConnection" class="form-group columns">
|
<div v-if="!customizations.fileConnection" class="form-group columns">
|
||||||
<div class="column col-4 col-sm-12">
|
<div class="column col-4 col-sm-12">
|
||||||
<label class="form-label">{{ $t('word.hostName') }}/IP</label>
|
<label class="form-label">{{ $t('word.hostName') }}/IP</label>
|
||||||
|
@ -126,7 +126,8 @@ module.exports = {
|
|||||||
enable: 'Enable',
|
enable: 'Enable',
|
||||||
disable: 'Disable',
|
disable: 'Disable',
|
||||||
commit: 'Commit',
|
commit: 'Commit',
|
||||||
rollback: 'Rollback'
|
rollback: 'Rollback',
|
||||||
|
connectionString: 'Connection string'
|
||||||
},
|
},
|
||||||
message: {
|
message: {
|
||||||
appWelcome: 'Welcome to Antares SQL Client!',
|
appWelcome: 'Welcome to Antares SQL Client!',
|
||||||
|
110
src/renderer/libs/connStringDecode.js
Normal file
110
src/renderer/libs/connStringDecode.js
Normal file
@ -0,0 +1,110 @@
|
|||||||
|
|
||||||
|
const getUrlScheme = pgString => {
|
||||||
|
const scheme = pgString ? pgString.split('://')[0] : '';
|
||||||
|
|
||||||
|
return scheme === 'postgresql' ? 'postgres' : scheme;
|
||||||
|
};
|
||||||
|
|
||||||
|
const passAndHost = part => {
|
||||||
|
const host = part.split('@')[1] === 'localhost' ? '127.0.0.1' : part.split('@')[1];
|
||||||
|
return [part.split('@')[0], host];
|
||||||
|
};
|
||||||
|
|
||||||
|
const portAndDb = part => {
|
||||||
|
return part.split('/');
|
||||||
|
};
|
||||||
|
|
||||||
|
const pass = (part) => {
|
||||||
|
return part.split('@');
|
||||||
|
};
|
||||||
|
|
||||||
|
const hostAndDb = (part) => {
|
||||||
|
return part.split('/');
|
||||||
|
};
|
||||||
|
|
||||||
|
const localConnectionString = (stringArgs, args) => {
|
||||||
|
let scheme = '';
|
||||||
|
if (getUrlScheme(stringArgs) === 'postgres' || getUrlScheme(stringArgs) === 'postgresql')
|
||||||
|
scheme = 'pg';
|
||||||
|
|
||||||
|
const values = stringArgs.split('://')[1];
|
||||||
|
const parts = values.split(':');
|
||||||
|
|
||||||
|
const userName = parts[0];
|
||||||
|
|
||||||
|
const password = passAndHost(parts[1])[0];
|
||||||
|
const host = passAndHost(parts[1])[1];
|
||||||
|
|
||||||
|
const port = portAndDb(parts[2])[0];
|
||||||
|
const dbName = portAndDb(parts[2])[1];
|
||||||
|
|
||||||
|
const client = args.client ? args.client : scheme;
|
||||||
|
|
||||||
|
args.client = client;
|
||||||
|
args.host = host;
|
||||||
|
args.database = dbName;
|
||||||
|
args.port = port;
|
||||||
|
args.user = userName;
|
||||||
|
args.password = password;
|
||||||
|
|
||||||
|
return args;
|
||||||
|
};
|
||||||
|
|
||||||
|
const onlineConnectionString = (stringArgs, args) => {
|
||||||
|
let scheme = '';
|
||||||
|
const defaultPort = '5432';
|
||||||
|
if (getUrlScheme(stringArgs) === 'postgres' || getUrlScheme(stringArgs) === 'postgresql')
|
||||||
|
scheme = 'pg';
|
||||||
|
|
||||||
|
const values = stringArgs.split('://')[1];
|
||||||
|
const parts = values.split(':');
|
||||||
|
|
||||||
|
const userName = parts[0];
|
||||||
|
|
||||||
|
const password = pass(parts[1])[0];
|
||||||
|
|
||||||
|
const host = hostAndDb(pass(parts[1])[1])[0];
|
||||||
|
const dbName = hostAndDb(pass(parts[1])[1])[1];
|
||||||
|
|
||||||
|
const port = defaultPort;
|
||||||
|
|
||||||
|
const client = args.client ? args.client : scheme;
|
||||||
|
|
||||||
|
args.client = client;
|
||||||
|
args.host = host;
|
||||||
|
args.database = dbName;
|
||||||
|
args.port = port;
|
||||||
|
args.user = userName;
|
||||||
|
args.password = password;
|
||||||
|
|
||||||
|
return args;
|
||||||
|
};
|
||||||
|
|
||||||
|
const connectionType = part => {
|
||||||
|
return part.split('=')[1];
|
||||||
|
};
|
||||||
|
|
||||||
|
const connStringConstruct = args => {
|
||||||
|
if (!args.pgConnString)
|
||||||
|
return args;
|
||||||
|
|
||||||
|
const pgConnString = args.pgConnString;
|
||||||
|
|
||||||
|
if (!pgConnString.includes('?'))
|
||||||
|
return localConnectionString(pgConnString, args);
|
||||||
|
|
||||||
|
const pgConnStringPrepared = pgConnString.split('?')[0];
|
||||||
|
|
||||||
|
switch (connectionType(pgConnString.split('?')[1])) {
|
||||||
|
case 'local':
|
||||||
|
return localConnectionString(pgConnStringPrepared, args);
|
||||||
|
|
||||||
|
case 'server':
|
||||||
|
return onlineConnectionString(pgConnStringPrepared, args);
|
||||||
|
|
||||||
|
default:
|
||||||
|
return args;
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
export default connStringConstruct;
|
Loading…
x
Reference in New Issue
Block a user