1
1
mirror of https://github.com/Fabio286/antares.git synced 2025-06-05 21:59:22 +02:00

Compare commits

...

25 Commits

Author SHA1 Message Date
4d1a81033d chore(release): 0.7.30 2024-12-04 18:14:31 +01:00
5887eea2ed Merge branch 'master' of https://github.com/antares-sql/antares 2024-12-04 18:14:11 +01:00
6c69583c90 Merge pull request #899 from antares-sql/all-contributors/add-carvalhods
docs: add carvalhods as a contributor for platform
2024-11-22 09:16:26 +01:00
allcontributors[bot]
03461522b7 docs: update .all-contributorsrc [skip ci] 2024-11-22 08:13:36 +00:00
allcontributors[bot]
11807e3bb6 docs: update README.md [skip ci] 2024-11-22 08:13:35 +00:00
a54b8d719c fix: issue saving queries as file 2024-11-21 13:28:33 +01:00
d1f68da495 chore(release): 0.7.30-beta.1 2024-11-15 14:27:20 +01:00
d666281daa Update README.md 2024-11-11 15:50:55 +01:00
481ae842dd Merge pull request #894 from leaked/master
Update README.md
2024-11-11 15:49:43 +01:00
Mohsen Nasiri
acf5d459e2 Update README.md 2024-11-10 02:47:52 +03:30
2ee9cfcf0b fix: missing support check for table check features 2024-11-08 18:12:02 +01:00
f0d312fb59 perf(PostgreSQL): improved support of connection strings, closes #893 2024-11-08 18:09:37 +01:00
c97ade949c chore(release): 0.7.30-beta.0 2024-10-25 18:46:27 +02:00
38af648440 refactor: ts fix 2024-10-25 18:44:49 +02:00
ccbcffc7f0 Merge pull request #890 from antares-sql/feat/mysql-check-support
Feat: MySQL check support
2024-10-25 18:34:06 +02:00
dfa7cf9905 perf: added more notifications in debug console 2024-10-25 18:32:07 +02:00
6365e07534 feat(MySQL): check constraints management support 2024-10-25 18:30:34 +02:00
24605d01e1 Merge pull request #887 from antares-sql/all-contributors/add-SawGoD
docs: add SawGoD as a contributor for translation
2024-10-22 15:53:15 +02:00
f083a8a185 Merge pull request #886 from SawGoD/master
feat: update ru-RU.ts file and update translation
2024-10-22 15:52:58 +02:00
allcontributors[bot]
f639bc7983 docs: update .all-contributorsrc [skip ci] 2024-10-22 13:26:01 +00:00
allcontributors[bot]
5e51997e5b docs: update README.md [skip ci] 2024-10-22 13:26:00 +00:00
SawGoD
1e3c9edb50 Update ru-RU.ts file and update translation 2024-10-22 11:41:36 +03:00
60e1e59505 fix: incorrect behavior sorting tables with numeric values 2024-10-18 18:24:46 +02:00
dba490f226 fix(MySQL): routines do not return results, fixes #885 2024-10-17 18:14:41 +02:00
b6c5dff15c fix: incorrect behavior in sorting tables with null/empty values, fixes #883 2024-10-17 18:12:34 +02:00
30 changed files with 699 additions and 111 deletions

View File

@@ -320,6 +320,24 @@
"contributions": [ "contributions": [
"translation" "translation"
] ]
},
{
"login": "SawGoD",
"name": "Nikita Karelikov",
"avatar_url": "https://avatars.githubusercontent.com/u/67802757?v=4",
"profile": "http://telegram.dog/SawGoD",
"contributions": [
"translation"
]
},
{
"login": "carvalhods",
"name": "David Carvalho",
"avatar_url": "https://avatars.githubusercontent.com/u/6569255?v=4",
"profile": "https://github.com/carvalhods",
"contributions": [
"platform"
]
} }
], ],
"contributorsPerLine": 7, "contributorsPerLine": 7,

View File

@@ -3,3 +3,4 @@ assets
out out
dist dist
build build
misc

View File

@@ -2,6 +2,44 @@
All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines. All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines.
### [0.7.30](https://github.com/antares-sql/antares/compare/v0.7.30-beta.1...v0.7.30) (2024-12-04)
### Bug Fixes
* issue saving queries as file ([a54b8d7](https://github.com/antares-sql/antares/commit/a54b8d719c6454500b885050c9ce6feaf7cfae1f))
### [0.7.30-beta.1](https://github.com/antares-sql/antares/compare/v0.7.30-beta.0...v0.7.30-beta.1) (2024-11-15)
### Bug Fixes
* missing support check for table check features ([2ee9cfc](https://github.com/antares-sql/antares/commit/2ee9cfcf0bbcf86e8a194d2eff78801300ce7cb3))
### Improvements
* **PostgreSQL:** improved support of connection strings, closes [#893](https://github.com/antares-sql/antares/issues/893) ([f0d312f](https://github.com/antares-sql/antares/commit/f0d312fb59fd98d6e4501bc407959b91eb0650f2))
### [0.7.30-beta.0](https://github.com/antares-sql/antares/compare/v0.7.29...v0.7.30-beta.0) (2024-10-25)
### Features
* **MySQL:** check constraints management support ([6365e07](https://github.com/antares-sql/antares/commit/6365e075349e00caa1454cce862e918f2069878f))
### Bug Fixes
* incorrect behavior in sorting tables with null/empty values, fixes [#883](https://github.com/antares-sql/antares/issues/883) ([b6c5dff](https://github.com/antares-sql/antares/commit/b6c5dff15c165261e9a11a389ed415e59c7b7628))
* incorrect behavior sorting tables with numeric values ([60e1e59](https://github.com/antares-sql/antares/commit/60e1e595057c3ba7f36e0f829dba11b470e1069b))
* **MySQL:** routines do not return results, fixes [#885](https://github.com/antares-sql/antares/issues/885) ([dba490f](https://github.com/antares-sql/antares/commit/dba490f22634f87d3af5a3a4c0866fc3095c9842))
### Improvements
* added more notifications in debug console ([dfa7cf9](https://github.com/antares-sql/antares/commit/dfa7cf9905a4d0a79eaed823a14477574b329dfa))
### [0.7.29](https://github.com/antares-sql/antares/compare/v0.7.29-beta.3...v0.7.29) (2024-10-14) ### [0.7.29](https://github.com/antares-sql/antares/compare/v0.7.29-beta.3...v0.7.29) (2024-10-14)
### [0.7.29-beta.3](https://github.com/antares-sql/antares/compare/v0.7.29-beta.2...v0.7.29-beta.3) (2024-10-08) ### [0.7.29-beta.3](https://github.com/antares-sql/antares/compare/v0.7.29-beta.2...v0.7.29-beta.3) (2024-10-08)

View File

@@ -1,13 +1,13 @@
<!-- markdownlint-disable --> <!-- markdownlint-disable -->
<p align="center"> <p align="center">
<img width="800" src="https://raw.githubusercontent.com/Fabio286/antares/master/docs/gh-logo.png"> <img width="800" src="https://raw.githubusercontent.com/antares-sql/antares/master/docs/gh-logo.png">
</p> </p>
<!-- markdownlint-restore --> <!-- markdownlint-restore -->
# Antares SQL Client # Antares SQL Client
![GitHub package.json version](https://img.shields.io/github/package-json/v/fabio286/antares) ![GitHub](https://img.shields.io/github/license/fabio286/antares) ![Test e2e](https://github.com/antares-sql/antares/actions/workflows/test-e2e-win.yml/badge.svg?branch=develop) ![Mastodon Follow](https://img.shields.io/mastodon/follow/%20110860460902482117?domain=https%3A%2F%2Ffosstodon.org&style=social) [![Plant a Tree](https://raw.githubusercontent.com/Fabio286/treedom-badge/master/svg/plant-a-tree.svg)](https://www.treedom.net/en/user/fabio-di-stasio/event/antares-for-the-planet) ![GitHub package.json version](https://img.shields.io/github/package-json/v/antares-sql/antares) ![GitHub](https://img.shields.io/github/license/antares-sql/antares) ![Test e2e](https://github.com/antares-sql/antares/actions/workflows/test-e2e-win.yml/badge.svg?branch=develop) ![Mastodon Follow](https://img.shields.io/mastodon/follow/%20110860460902482117?domain=https%3A%2F%2Ffosstodon.org&style=social) [![Plant a Tree](https://raw.githubusercontent.com/Fabio286/treedom-badge/master/svg/plant-a-tree.svg)](https://www.treedom.net/en/user/fabio-di-stasio/event/antares-for-the-planet)
Antares is an SQL client based on [Electron.js](https://github.com/electron/electron) and [Vue.js](https://github.com/vuejs/vue) that aims to become a useful tool, especially for developers. Antares is an SQL client based on [Electron.js](https://github.com/electron/electron) and [Vue.js](https://github.com/vuejs/vue) that aims to become a useful tool, especially for developers.
Our target is to support as many databases as possible, and all major operating systems, including the ARM versions. Our target is to support as many databases as possible, and all major operating systems, including the ARM versions.
@@ -16,7 +16,7 @@ Our target is to support as many databases as possible, and all major operating
However, there are all the features necessary to have a pleasant database management experience, so give it a chance and send us your feedback, we would really appreciate it. However, there are all the features necessary to have a pleasant database management experience, so give it a chance and send us your feedback, we would really appreciate it.
We are actively working on it, hoping to provide new cool features, improvements and fixes as soon as possible. We are actively working on it, hoping to provide new cool features, improvements and fixes as soon as possible.
🔗 If you are curious to try Antares you can download and install the [latest release](https://github.com/Fabio286/antares/releases/latest). 🔗 If you are curious to try Antares you can download and install the [latest release](https://github.com/antares-sql/antares/releases/latest).
👁 To stay tuned for new releases follow Antares SQL on [Mastodon](https://fosstodon.org/@AntaresSQL). 👁 To stay tuned for new releases follow Antares SQL on [Mastodon](https://fosstodon.org/@AntaresSQL).
🌟 Don't forget to **leave a star** if you appreciate this project. 🌟 Don't forget to **leave a star** if you appreciate this project.
@@ -60,7 +60,7 @@ On Linux you can simply download and run the `.AppImage` distribution, install f
### Windows ### Windows
On Windows you can choose between downloading the app from Microsoft Store or downloading the `.exe` from our [website](https://antares-sql.app/downloads) or [this github repo](https://github.com/Fabio286/antares/releases/latest). Distributions that are not from Microsoft Store are not signed with a certificate, so to install you need to click on "More info" and then "Run anyway" on SmartScreen prompt. On Windows you can choose between downloading the app from Microsoft Store or downloading the `.exe` from our [website](https://antares-sql.app/downloads) or [this github repo](https://github.com/antares-sql/antares/releases/latest). Distributions that are not from Microsoft Store are not signed with a certificate, so to install you need to click on "More info" and then "Run anyway" on SmartScreen prompt.
### MacOS ### MacOS
@@ -99,8 +99,8 @@ On macOS you can run `.dmg` distribution following [this guide](https://support.
## How to contribute ## How to contribute
- 🌍 [Translate Antares](https://github.com/Fabio286/antares/wiki/Translate-Antares) - 🌍 [Translate Antares](https://github.com/antares-sql/antares/wiki/Translate-Antares)
- 📖 [Contributors Guide](https://github.com/Fabio286/antares/wiki/Contributors-Guide) - 📖 [Contributors Guide](https://github.com/antares-sql/antares/wiki/Contributors-Guide)
- 🚧 [Project Board](https://github.com/orgs/antares-sql/projects/3/views/2) - 🚧 [Project Board](https://github.com/orgs/antares-sql/projects/3/views/2)
## Contributors ✨ ## Contributors ✨
@@ -155,6 +155,10 @@ Thanks goes to these wonderful people ([emoji key](https://allcontributors.org/d
<td align="center" valign="top" width="14.28%"><a href="https://github.com/zwei-c"><img src="https://avatars.githubusercontent.com/u/55912811?v=4?s=100" width="100px;" alt="CHANG, CHIH WEI"/><br /><sub><b>CHANG, CHIH WEI</b></sub></a><br /><a href="#translation-zwei-c" title="Translation">🌍</a></td> <td align="center" valign="top" width="14.28%"><a href="https://github.com/zwei-c"><img src="https://avatars.githubusercontent.com/u/55912811?v=4?s=100" width="100px;" alt="CHANG, CHIH WEI"/><br /><sub><b>CHANG, CHIH WEI</b></sub></a><br /><a href="#translation-zwei-c" title="Translation">🌍</a></td>
<td align="center" valign="top" width="14.28%"><a href="https://github.com/mirrorb"><img src="https://avatars.githubusercontent.com/u/34116207?v=4?s=100" width="100px;" alt="GaoChun"/><br /><sub><b>GaoChun</b></sub></a><br /><a href="https://github.com/antares-sql/antares/commits?author=mirrorb" title="Code">💻</a></td> <td align="center" valign="top" width="14.28%"><a href="https://github.com/mirrorb"><img src="https://avatars.githubusercontent.com/u/34116207?v=4?s=100" width="100px;" alt="GaoChun"/><br /><sub><b>GaoChun</b></sub></a><br /><a href="https://github.com/antares-sql/antares/commits?author=mirrorb" title="Code">💻</a></td>
<td align="center" valign="top" width="14.28%"><a href="https://github.com/LeviEyal"><img src="https://avatars.githubusercontent.com/u/48846533?v=4?s=100" width="100px;" alt="Eyal Levi"/><br /><sub><b>Eyal Levi</b></sub></a><br /><a href="#translation-LeviEyal" title="Translation">🌍</a></td> <td align="center" valign="top" width="14.28%"><a href="https://github.com/LeviEyal"><img src="https://avatars.githubusercontent.com/u/48846533?v=4?s=100" width="100px;" alt="Eyal Levi"/><br /><sub><b>Eyal Levi</b></sub></a><br /><a href="#translation-LeviEyal" title="Translation">🌍</a></td>
<td align="center" valign="top" width="14.28%"><a href="http://telegram.dog/SawGoD"><img src="https://avatars.githubusercontent.com/u/67802757?v=4?s=100" width="100px;" alt="Nikita Karelikov"/><br /><sub><b>Nikita Karelikov</b></sub></a><br /><a href="#translation-SawGoD" title="Translation">🌍</a></td>
</tr>
<tr>
<td align="center" valign="top" width="14.28%"><a href="https://github.com/carvalhods"><img src="https://avatars.githubusercontent.com/u/6569255?v=4?s=100" width="100px;" alt="David Carvalho"/><br /><sub><b>David Carvalho</b></sub></a><br /><a href="#platform-carvalhods" title="Packaging/porting to new platform">📦</a></td>
</tr> </tr>
</tbody> </tbody>
</table> </table>

12
package-lock.json generated
View File

@@ -1,12 +1,12 @@
{ {
"name": "antares", "name": "antares",
"version": "0.7.29", "version": "0.7.30",
"lockfileVersion": 2, "lockfileVersion": 2,
"requires": true, "requires": true,
"packages": { "packages": {
"": { "": {
"name": "antares", "name": "antares",
"version": "0.7.29", "version": "0.7.30",
"hasInstallScript": true, "hasInstallScript": true,
"license": "MIT", "license": "MIT",
"dependencies": { "dependencies": {
@@ -42,7 +42,6 @@
"node-firebird": "~1.1.8", "node-firebird": "~1.1.8",
"node-loader": "~2.0.0", "node-loader": "~2.0.0",
"pg": "~8.11.5", "pg": "~8.11.5",
"pg-connection-string": "~2.5.0",
"pg-query-stream": "~4.2.3", "pg-query-stream": "~4.2.3",
"pgsql-ast-parser": "~7.2.1", "pgsql-ast-parser": "~7.2.1",
"pinia": "~2.1.7", "pinia": "~2.1.7",
@@ -12142,10 +12141,6 @@
"license": "MIT", "license": "MIT",
"optional": true "optional": true
}, },
"node_modules/pg-connection-string": {
"version": "2.5.0",
"license": "MIT"
},
"node_modules/pg-cursor": { "node_modules/pg-cursor": {
"version": "2.10.3", "version": "2.10.3",
"license": "MIT", "license": "MIT",
@@ -24507,9 +24502,6 @@
"version": "1.1.1", "version": "1.1.1",
"optional": true "optional": true
}, },
"pg-connection-string": {
"version": "2.5.0"
},
"pg-cursor": { "pg-cursor": {
"version": "2.10.3", "version": "2.10.3",
"requires": {} "requires": {}

View File

@@ -1,7 +1,7 @@
{ {
"name": "antares", "name": "antares",
"productName": "Antares", "productName": "Antares",
"version": "0.7.29", "version": "0.7.30",
"description": "A modern, fast and productivity driven SQL client with a focus in UX.", "description": "A modern, fast and productivity driven SQL client with a focus in UX.",
"license": "MIT", "license": "MIT",
"repository": "https://github.com/antares-sql/antares.git", "repository": "https://github.com/antares-sql/antares.git",
@@ -151,7 +151,6 @@
"node-firebird": "~1.1.8", "node-firebird": "~1.1.8",
"node-loader": "~2.0.0", "node-loader": "~2.0.0",
"pg": "~8.11.5", "pg": "~8.11.5",
"pg-connection-string": "~2.5.0",
"pg-query-stream": "~4.2.3", "pg-query-stream": "~4.2.3",
"pgsql-ast-parser": "~7.2.1", "pgsql-ast-parser": "~7.2.1",
"pinia": "~2.1.7", "pinia": "~2.1.7",

View File

@@ -55,6 +55,7 @@ export const defaults: Customizations = {
tableArray: false, tableArray: false,
tableRealCount: false, tableRealCount: false,
tableDuplicate: false, tableDuplicate: false,
tableCheck: false,
viewSettings: false, viewSettings: false,
triggerSettings: false, triggerSettings: false,
triggerFunctionSettings: false, triggerFunctionSettings: false,

View File

@@ -47,6 +47,7 @@ export const customizations: Customizations = {
tableTruncateDisableFKCheck: true, tableTruncateDisableFKCheck: true,
tableDuplicate: true, tableDuplicate: true,
tableDdl: true, tableDdl: true,
tableCheck: true,
viewAdd: true, viewAdd: true,
triggerAdd: true, triggerAdd: true,
routineAdd: true, routineAdd: true,

View File

@@ -57,6 +57,7 @@ export interface ConnectionParams {
cert?: string; cert?: string;
key?: string; key?: string;
ca?: string; ca?: string;
connString?: string;
untrustedConnection: boolean; untrustedConnection: boolean;
ciphers?: string; ciphers?: string;
ssh: boolean; ssh: boolean;
@@ -159,6 +160,13 @@ export interface TableForeign {
oldName?: string; oldName?: string;
} }
export interface TableCheck {
// eslint-disable-next-line camelcase
_antares_id?: string;
name: string;
clause: string;
}
export interface CreateTableParams { export interface CreateTableParams {
/** Connection UID */ /** Connection UID */
uid?: string; uid?: string;
@@ -166,6 +174,7 @@ export interface CreateTableParams {
fields: TableField[]; fields: TableField[];
foreigns: TableForeign[]; foreigns: TableForeign[];
indexes: TableIndex[]; indexes: TableIndex[];
checks?: TableCheck[];
options: TableOptions; options: TableOptions;
} }
@@ -193,6 +202,11 @@ export interface AlterTableParams {
changes: TableForeign[]; changes: TableForeign[];
deletions: TableForeign[]; deletions: TableForeign[];
}; };
checkChanges?: {
additions: TableCheck[];
changes: TableCheck[];
deletions: TableCheck[];
};
options: TableOptions; options: TableOptions;
} }

View File

@@ -43,6 +43,7 @@ export interface Customizations {
tableArray?: boolean; tableArray?: boolean;
tableRealCount?: boolean; tableRealCount?: boolean;
tableTruncateDisableFKCheck?: boolean; tableTruncateDisableFKCheck?: boolean;
tableCheck?: boolean;
tableDdl?: boolean; tableDdl?: boolean;
viewAdd?: boolean; viewAdd?: boolean;
viewSettings?: boolean; viewSettings?: boolean;

View File

@@ -26,6 +26,7 @@ export default (connections: Record<string, antares.Client>) => {
user: conn.user, user: conn.user,
password: conn.password, password: conn.password,
readonly: conn.readonly, readonly: conn.readonly,
connectionString: conn.connString,
database: '', database: '',
schema: '', schema: '',
databasePath: '', databasePath: '',
@@ -122,6 +123,7 @@ export default (connections: Record<string, antares.Client>) => {
password: conn.password, password: conn.password,
application_name: 'Antares SQL', application_name: 'Antares SQL',
readonly: conn.readonly, readonly: conn.readonly,
connectionString: conn.connString,
database: '', database: '',
schema: '', schema: '',
databasePath: '', databasePath: '',

View File

@@ -87,6 +87,19 @@ export default (connections: Record<string, antares.Client>) => {
} }
}); });
ipcMain.handle('get-table-checks', async (event, params) => {
if (!validateSender(event.senderFrame)) return { status: 'error', response: 'Unauthorized process' };
try {
const result = await connections[params.uid].getTableChecks(params);
return { status: 'success', response: result };
}
catch (err) {
return { status: 'error', response: err.toString() };
}
});
ipcMain.handle('get-table-ddl', async (event, params) => { ipcMain.handle('get-table-ddl', async (event, params) => {
if (!validateSender(event.senderFrame)) return { status: 'error', response: 'Unauthorized process' }; if (!validateSender(event.senderFrame)) return { status: 'error', response: 'Unauthorized process' };

View File

@@ -189,6 +189,10 @@ export abstract class BaseClient {
throw new Error('Method "dropSchema" not implemented'); throw new Error('Method "dropSchema" not implemented');
} }
getTableChecks (...args: any) {
throw new Error('Method "getTableDll" not implemented');
}
getTableDll (...args: any) { getTableDll (...args: any) {
throw new Error('Method "getTableDll" not implemented'); throw new Error('Method "getTableDll" not implemented');
} }

View File

@@ -161,6 +161,8 @@ export class MySQLClient extends BaseClient {
this._ssh = new SSH2Promise({ this._ssh = new SSH2Promise({
...this._params.ssh, ...this._params.ssh,
reconnect: true,
reconnectTries: 3,
debug: process.env.NODE_ENV !== 'production' ? (s) => console.log(s) : null debug: process.env.NODE_ENV !== 'production' ? (s) => console.log(s) : null
}); });
@@ -689,6 +691,34 @@ export class MySQLClient extends BaseClient {
return rows.length ? rows[0].count : 0; return rows.length ? rows[0].count : 0;
} }
async getTableChecks ({ schema, table }: { schema: string; table: string }): Promise<antares.TableCheck[]> {
const { rows } = await this.raw(`
SELECT
CONSTRAINT_NAME as name,
CHECK_CLAUSE as clausole
FROM information_schema.CHECK_CONSTRAINTS
WHERE CONSTRAINT_SCHEMA = "${schema}"
AND CONSTRAINT_NAME IN (
SELECT
CONSTRAINT_NAME
FROM
information_schema.TABLE_CONSTRAINTS
WHERE
TABLE_SCHEMA = "${schema}"
AND TABLE_NAME = "${table}"
AND CONSTRAINT_TYPE = 'CHECK'
)
`);
if (rows.length) {
return rows.map(row => ({
name: row.name,
clause: row.clausole
}));
}
return [];
}
async getTableOptions ({ schema, table }: { schema: string; table: string }) { async getTableOptions ({ schema, table }: { schema: string; table: string }) {
/* eslint-disable camelcase */ /* eslint-disable camelcase */
interface TableOptionsResult { interface TableOptionsResult {
@@ -865,11 +895,13 @@ export class MySQLClient extends BaseClient {
fields, fields,
foreigns, foreigns,
indexes, indexes,
checks,
options options
} = params; } = params;
const newColumns: string[] = []; const newColumns: string[] = [];
const newIndexes: string[] = []; const newIndexes: string[] = [];
const newForeigns: string[] = []; const newForeigns: string[] = [];
const newChecks: string[] = [];
let sql = `CREATE TABLE \`${schema}\`.\`${options.name}\``; let sql = `CREATE TABLE \`${schema}\`.\`${options.name}\``;
@@ -910,7 +942,13 @@ export class MySQLClient extends BaseClient {
newForeigns.push(`CONSTRAINT \`${foreign.constraintName}\` FOREIGN KEY (\`${foreign.field}\`) REFERENCES \`${foreign.refTable}\` (\`${foreign.refField}\`) ON UPDATE ${foreign.onUpdate} ON DELETE ${foreign.onDelete}`); newForeigns.push(`CONSTRAINT \`${foreign.constraintName}\` FOREIGN KEY (\`${foreign.field}\`) REFERENCES \`${foreign.refTable}\` (\`${foreign.refField}\`) ON UPDATE ${foreign.onUpdate} ON DELETE ${foreign.onDelete}`);
}); });
sql = `${sql} (${[...newColumns, ...newIndexes, ...newForeigns].join(', ')}) COMMENT='${options.comment}', COLLATE='${options.collation}', ENGINE=${options.engine}`; // ADD TABLE CHECKS
checks.forEach(check => {
if (!check.clause.trim().length) return;
newChecks.push(`${check.name ? `CONSTRAINT \`${check.name}\` ` : ''}CHECK (${check.clause})`);
});
sql = `${sql} (${[...newColumns, ...newIndexes, ...newForeigns, ...newChecks].join(', ')}) COMMENT='${options.comment}', COLLATE='${options.collation}', ENGINE=${options.engine}`;
return await this.raw(sql); return await this.raw(sql);
} }
@@ -924,6 +962,7 @@ export class MySQLClient extends BaseClient {
changes, changes,
indexChanges, indexChanges,
foreignChanges, foreignChanges,
checkChanges,
options options
} = params; } = params;
@@ -931,6 +970,7 @@ export class MySQLClient extends BaseClient {
const alterColumnsAdd: string[] = []; const alterColumnsAdd: string[] = [];
const alterColumnsChange: string[] = []; const alterColumnsChange: string[] = [];
const alterColumnsDrop: string[] = []; const alterColumnsDrop: string[] = [];
const alterQueryes: string[] = [];
// OPTIONS // OPTIONS
if ('comment' in options) alterColumnsChange.push(`COMMENT='${options.comment}'`); if ('comment' in options) alterColumnsChange.push(`COMMENT='${options.comment}'`);
@@ -976,6 +1016,12 @@ export class MySQLClient extends BaseClient {
alterColumnsAdd.push(`ADD CONSTRAINT \`${addition.constraintName}\` FOREIGN KEY (\`${addition.field}\`) REFERENCES \`${addition.refTable}\` (\`${addition.refField}\`) ON UPDATE ${addition.onUpdate} ON DELETE ${addition.onDelete}`); alterColumnsAdd.push(`ADD CONSTRAINT \`${addition.constraintName}\` FOREIGN KEY (\`${addition.field}\`) REFERENCES \`${addition.refTable}\` (\`${addition.refField}\`) ON UPDATE ${addition.onUpdate} ON DELETE ${addition.onDelete}`);
}); });
// ADD TABLE CHECKS
checkChanges.additions.forEach(addition => {
if (!addition.clause.trim().length) return;
alterColumnsAdd.push(`ADD ${addition.name ? `CONSTRAINT \`${addition.name}\` ` : ''}CHECK (${addition.clause})`);
});
// CHANGE FIELDS // CHANGE FIELDS
changes.forEach(change => { changes.forEach(change => {
const typeInfo = this.getTypeInfo(change.type); const typeInfo = this.getTypeInfo(change.type);
@@ -987,9 +1033,9 @@ export class MySQLClient extends BaseClient {
${change.zerofill ? 'ZEROFILL' : ''} ${change.zerofill ? 'ZEROFILL' : ''}
${change.nullable ? 'NULL' : 'NOT NULL'} ${change.nullable ? 'NULL' : 'NOT NULL'}
${change.autoIncrement ? 'AUTO_INCREMENT' : ''} ${change.autoIncrement ? 'AUTO_INCREMENT' : ''}
${change.collation ? `COLLATE ${change.collation}` : ''}
${change.default !== null ? `DEFAULT ${change.default || '\'\''}` : ''} ${change.default !== null ? `DEFAULT ${change.default || '\'\''}` : ''}
${change.comment ? `COMMENT '${change.comment}'` : ''} ${change.comment ? `COMMENT '${change.comment}'` : ''}
${change.collation ? `COLLATE ${change.collation}` : ''}
${change.onUpdate ? `ON UPDATE ${change.onUpdate}` : ''} ${change.onUpdate ? `ON UPDATE ${change.onUpdate}` : ''}
${change.after ? `AFTER \`${change.after}\`` : 'FIRST'}`); ${change.after ? `AFTER \`${change.after}\`` : 'FIRST'}`);
}); });
@@ -1020,6 +1066,13 @@ export class MySQLClient extends BaseClient {
alterColumnsChange.push(`ADD CONSTRAINT \`${change.constraintName}\` FOREIGN KEY (\`${change.field}\`) REFERENCES \`${change.refTable}\` (\`${change.refField}\`) ON UPDATE ${change.onUpdate} ON DELETE ${change.onDelete}`); alterColumnsChange.push(`ADD CONSTRAINT \`${change.constraintName}\` FOREIGN KEY (\`${change.field}\`) REFERENCES \`${change.refTable}\` (\`${change.refField}\`) ON UPDATE ${change.onUpdate} ON DELETE ${change.onDelete}`);
}); });
// CHANGE CHECK TABLE
checkChanges.changes.forEach(change => {
if (!change.clause.trim().length) return;
alterQueryes.push(`${sql} DROP CONSTRAINT \`${change.name}\``);
alterQueryes.push(`${sql} ADD ${change.name ? `CONSTRAINT \`${change.name}\` ` : ''}CHECK (${change.clause})`);
});
// DROP FIELDS // DROP FIELDS
deletions.forEach(deletion => { deletions.forEach(deletion => {
alterColumnsDrop.push(`DROP COLUMN \`${deletion.name}\``); alterColumnsDrop.push(`DROP COLUMN \`${deletion.name}\``);
@@ -1038,7 +1091,11 @@ export class MySQLClient extends BaseClient {
alterColumnsDrop.push(`DROP FOREIGN KEY \`${deletion.constraintName}\``); alterColumnsDrop.push(`DROP FOREIGN KEY \`${deletion.constraintName}\``);
}); });
const alterQueryes = []; // DROP CHECK TABLE
checkChanges.deletions.forEach(deletion => {
alterQueryes.push(`${sql} DROP CONSTRAINT \`${deletion.name}\``);
});
if (alterColumnsAdd.length) alterQueryes.push(sql+alterColumnsAdd.join(', ')); if (alterColumnsAdd.length) alterQueryes.push(sql+alterColumnsAdd.join(', '));
if (alterColumnsChange.length) alterQueryes.push(sql+alterColumnsChange.join(', ')); if (alterColumnsChange.length) alterQueryes.push(sql+alterColumnsChange.join(', '));
if (alterColumnsDrop.length) alterQueryes.push(sql+alterColumnsDrop.join(', ')); if (alterColumnsDrop.length) alterQueryes.push(sql+alterColumnsDrop.join(', '));
@@ -1714,9 +1771,10 @@ export class MySQLClient extends BaseClient {
connection.query({ sql: query, nestTables }).then(async ([response, fields]) => { connection.query({ sql: query, nestTables }).then(async ([response, fields]) => {
timeStop = new Date(); timeStop = new Date();
const queryResult = response; const queryResult = response;
const fieldsArr = fields ? Array.isArray(fields[0]) ? fields[0] : fields : false;// Some times fields are nested in an array
let remappedFields = fields let remappedFields = fieldsArr
? fields.map(field => { ? fieldsArr.map(field => {
if (!field || Array.isArray(field)) if (!field || Array.isArray(field))
return undefined; return undefined;
@@ -1785,7 +1843,7 @@ export class MySQLClient extends BaseClient {
resolve({ resolve({
duration: timeStop.getTime() - timeStart.getTime(), duration: timeStop.getTime() - timeStart.getTime(),
rows: Array.isArray(queryResult) ? queryResult.some(el => Array.isArray(el)) ? [] : queryResult : false, rows: Array.isArray(queryResult) ? queryResult.some(el => Array.isArray(el)) ? queryResult[0] : queryResult : false,
report: !Array.isArray(queryResult) ? queryResult : false, report: !Array.isArray(queryResult) ? queryResult : false,
fields: remappedFields, fields: remappedFields,
keys: keysArr keys: keysArr

View File

@@ -155,6 +155,7 @@ export class PostgreSQLClient extends BaseClient {
host: this._params.host, host: this._params.host,
port: this._params.port, port: this._params.port,
user: this._params.user, user: this._params.user,
connectionString: this._params.connectionString,
database: 'postgres' as string, database: 'postgres' as string,
password: this._params.password, password: this._params.password,
ssl: null as ConnectionOptions ssl: null as ConnectionOptions
@@ -168,6 +169,8 @@ export class PostgreSQLClient extends BaseClient {
try { try {
this._ssh = new SSH2Promise({ this._ssh = new SSH2Promise({
...this._params.ssh, ...this._params.ssh,
reconnect: true,
reconnectTries: 3,
debug: process.env.NODE_ENV !== 'production' ? (s) => console.log(s) : null debug: process.env.NODE_ENV !== 'production' ? (s) => console.log(s) : null
}); });

View File

@@ -67,7 +67,7 @@
<div class="column col-7 col-sm-12"> <div class="column col-7 col-sm-12">
<input <input
ref="pgString" ref="pgString"
v-model="connection.pgConnString" v-model="connection.connString"
class="form-input" class="form-input"
type="text" type="text"
> >
@@ -502,8 +502,8 @@ const connection = ref({
sshKey: '', sshKey: '',
sshPort: 22, sshPort: 22,
sshKeepAliveInterval: 1800, sshKeepAliveInterval: 1800,
pgConnString: '' connString: ''
}) as Ref<ConnectionParams & { pgConnString: string }>; }) as Ref<ConnectionParams & { connString: string }>;
const firstInput: Ref<HTMLInputElement> = ref(null); const firstInput: Ref<HTMLInputElement> = ref(null);
const isConnecting = ref(false); const isConnecting = ref(false);

View File

@@ -68,7 +68,7 @@
<div class="column col-7 col-sm-12"> <div class="column col-7 col-sm-12">
<input <input
ref="pgString" ref="pgString"
v-model="localConnection.pgConnString" v-model="localConnection.connString"
class="form-input" class="form-input"
type="text" type="text"
> >
@@ -502,7 +502,7 @@ const clients = [
]; ];
const firstInput: Ref<HTMLInputElement> = ref(null); const firstInput: Ref<HTMLInputElement> = ref(null);
const localConnection: Ref<ConnectionParams & { pgConnString: string }> = ref(null); const localConnection: Ref<ConnectionParams & { connString: string }> = ref(null);
const isConnecting = ref(false); const isConnecting = ref(false);
const isTesting = ref(false); const isTesting = ref(false);
const isAsking = ref(false); const isAsking = ref(false);

View File

@@ -72,6 +72,20 @@
/> />
<span>{{ t('database.foreignKeys') }}</span> <span>{{ t('database.foreignKeys') }}</span>
</button> </button>
<button
v-if="workspace.customizations.tableCheck"
class="btn btn-dark btn-sm ml-2 mr-0"
:disabled="isSaving || !localFields.length"
:title="t('database.manageTableChecks')"
@click="showTableChecksModal"
>
<BaseIcon
class="mr-1"
icon-name="mdiTableCheck"
:size="24"
/>
<span>{{ t('database.tableChecks') }}</span>
</button>
</div> </div>
<div class="workspace-query-info"> <div class="workspace-query-info">
<div class="d-flex" :title="t('database.schema')"> <div class="d-flex" :title="t('database.schema')">
@@ -183,11 +197,19 @@
@hide="hideForeignModal" @hide="hideForeignModal"
@foreigns-update="foreignsUpdate" @foreigns-update="foreignsUpdate"
/> />
<WorkspaceTabPropsTableChecksModal
v-if="isTableChecksModal"
:local-checks="localTableChecks"
table="new"
:workspace="workspace"
@hide="hideTableChecksModal"
@checks-update="checksUpdate"
/>
</div> </div>
</template> </template>
<script setup lang="ts"> <script setup lang="ts">
import { ConnectionParams, TableField, TableForeign, TableIndex, TableOptions } from 'common/interfaces/antares'; import { ConnectionParams, TableCheck, TableField, TableForeign, TableIndex, TableOptions } from 'common/interfaces/antares';
import { uidGen } from 'common/libs/uidGen'; import { uidGen } from 'common/libs/uidGen';
import { ipcRenderer } from 'electron'; import { ipcRenderer } from 'electron';
import { storeToRefs } from 'pinia'; import { storeToRefs } from 'pinia';
@@ -198,6 +220,7 @@ import BaseIcon from '@/components/BaseIcon.vue';
import BaseLoader from '@/components/BaseLoader.vue'; import BaseLoader from '@/components/BaseLoader.vue';
import BaseSelect from '@/components/BaseSelect.vue'; import BaseSelect from '@/components/BaseSelect.vue';
import WorkspaceTabNewTableEmptyState from '@/components/WorkspaceTabNewTableEmptyState.vue'; import WorkspaceTabNewTableEmptyState from '@/components/WorkspaceTabNewTableEmptyState.vue';
import WorkspaceTabPropsTableChecksModal from '@/components/WorkspaceTabPropsTableChecksModal.vue';
import WorkspaceTabPropsTableFields from '@/components/WorkspaceTabPropsTableFields.vue'; import WorkspaceTabPropsTableFields from '@/components/WorkspaceTabPropsTableFields.vue';
import WorkspaceTabPropsTableForeignModal from '@/components/WorkspaceTabPropsTableForeignModal.vue'; import WorkspaceTabPropsTableForeignModal from '@/components/WorkspaceTabPropsTableForeignModal.vue';
import WorkspaceTabPropsTableIndexesModal from '@/components/WorkspaceTabPropsTableIndexesModal.vue'; import WorkspaceTabPropsTableIndexesModal from '@/components/WorkspaceTabPropsTableIndexesModal.vue';
@@ -236,12 +259,16 @@ const isLoading = ref(false);
const isSaving = ref(false); const isSaving = ref(false);
const isIndexesModal = ref(false); const isIndexesModal = ref(false);
const isForeignModal = ref(false); const isForeignModal = ref(false);
const isTableChecksModal = ref(false);
const originalFields: Ref<TableField[]> = ref([]); const originalFields: Ref<TableField[]> = ref([]);
const localFields: Ref<TableField[]> = ref([]); const localFields: Ref<TableField[]> = ref([]);
const originalKeyUsage: Ref<TableForeign[]> = ref([]); const originalKeyUsage: Ref<TableForeign[]> = ref([]);
const localKeyUsage: Ref<TableForeign[]> = ref([]); const localKeyUsage: Ref<TableForeign[]> = ref([]);
const originalIndexes: Ref<TableIndex[]> = ref([]); const originalIndexes: Ref<TableIndex[]> = ref([]);
const localIndexes: Ref<TableIndex[]> = ref([]); const localIndexes: Ref<TableIndex[]> = ref([]);
const originalTableChecks: Ref<TableCheck[]> = ref([]);
const localTableChecks: Ref<TableCheck[]> = ref([]);
const tableOptions: Ref<TableOptions> = ref(null); const tableOptions: Ref<TableOptions> = ref(null);
const localOptions: Ref<TableOptions> = ref(null); const localOptions: Ref<TableOptions> = ref(null);
const newFieldsCounter = ref(0); const newFieldsCounter = ref(0);
@@ -274,6 +301,7 @@ const isChanged = computed(() => {
return JSON.stringify(originalFields.value) !== JSON.stringify(localFields.value) || return JSON.stringify(originalFields.value) !== JSON.stringify(localFields.value) ||
JSON.stringify(originalKeyUsage.value) !== JSON.stringify(localKeyUsage.value) || JSON.stringify(originalKeyUsage.value) !== JSON.stringify(localKeyUsage.value) ||
JSON.stringify(originalIndexes.value) !== JSON.stringify(localIndexes.value) || JSON.stringify(originalIndexes.value) !== JSON.stringify(localIndexes.value) ||
JSON.stringify(originalTableChecks.value) !== JSON.stringify(localTableChecks.value) ||
JSON.stringify(tableOptions.value) !== JSON.stringify(localOptions.value); JSON.stringify(tableOptions.value) !== JSON.stringify(localOptions.value);
}); });
@@ -291,6 +319,7 @@ const saveChanges = async () => {
fields: localFields.value, fields: localFields.value,
foreigns: localKeyUsage.value, foreigns: localKeyUsage.value,
indexes: localIndexes.value, indexes: localIndexes.value,
checks: localTableChecks.value,
options: localOptions.value options: localOptions.value
}; };
@@ -326,6 +355,7 @@ const clearChanges = () => {
localFields.value = JSON.parse(JSON.stringify(originalFields.value)); localFields.value = JSON.parse(JSON.stringify(originalFields.value));
localIndexes.value = JSON.parse(JSON.stringify(originalIndexes.value)); localIndexes.value = JSON.parse(JSON.stringify(originalIndexes.value));
localKeyUsage.value = JSON.parse(JSON.stringify(originalKeyUsage.value)); localKeyUsage.value = JSON.parse(JSON.stringify(originalKeyUsage.value));
localTableChecks.value = JSON.parse(JSON.stringify(originalTableChecks.value));
tableOptions.value = { tableOptions.value = {
name: '', name: '',
@@ -446,10 +476,22 @@ const hideForeignModal = () => {
isForeignModal.value = false; isForeignModal.value = false;
}; };
const showTableChecksModal = () => {
isTableChecksModal.value = true;
};
const hideTableChecksModal = () => {
isTableChecksModal.value = false;
};
const foreignsUpdate = (foreigns: TableForeign[]) => { const foreignsUpdate = (foreigns: TableForeign[]) => {
localKeyUsage.value = foreigns; localKeyUsage.value = foreigns;
}; };
const checksUpdate = (checks: TableCheck[]) => {
localTableChecks.value = checks;
};
const saveContentListener = () => { const saveContentListener = () => {
const hasModalOpen = !!document.querySelectorAll('.modal.active').length; const hasModalOpen = !!document.querySelectorAll('.modal.active').length;
if (props.isSelected && !hasModalOpen && isChanged.value) if (props.isSelected && !hasModalOpen && isChanged.value)

View File

@@ -62,7 +62,7 @@
<button <button
class="btn btn-dark btn-sm mr-0" class="btn btn-dark btn-sm mr-0"
:disabled="isSaving" :disabled="isSaving"
:title="t('database.manageIndexes')" :title="t('database.manageForeignKeys')"
@click="showForeignModal" @click="showForeignModal"
> >
<BaseIcon <BaseIcon
@@ -72,6 +72,20 @@
/> />
<span>{{ t('database.foreignKeys') }}</span> <span>{{ t('database.foreignKeys') }}</span>
</button> </button>
<button
v-if="workspace.customizations.tableCheck"
class="btn btn-dark btn-sm ml-2 mr-0"
:disabled="isSaving"
:title="t('database.manageTableChecks')"
@click="showTableChecksModal"
>
<BaseIcon
class="mr-1"
icon-name="mdiTableCheck"
:size="24"
/>
<span>{{ t('database.tableChecks') }}</span>
</button>
<div class="divider-vert py-3" /> <div class="divider-vert py-3" />
@@ -218,11 +232,19 @@
:workspace="workspace" :workspace="workspace"
@hide="hideDdlModal" @hide="hideDdlModal"
/> />
<WorkspaceTabPropsTableChecksModal
v-if="isTableChecksModal"
:local-checks="localTableChecks"
:table="table"
:workspace="workspace"
@hide="hideTableChecksModal"
@checks-update="checksUpdate"
/>
</div> </div>
</template> </template>
<script setup lang="ts"> <script setup lang="ts">
import { AlterTableParams, TableField, TableForeign, TableIndex, TableInfos, TableOptions } from 'common/interfaces/antares'; import { AlterTableParams, TableCheck, TableField, TableForeign, TableIndex, TableInfos, TableOptions } from 'common/interfaces/antares';
import { uidGen } from 'common/libs/uidGen'; import { uidGen } from 'common/libs/uidGen';
import { ipcRenderer } from 'electron'; import { ipcRenderer } from 'electron';
import { storeToRefs } from 'pinia'; import { storeToRefs } from 'pinia';
@@ -232,6 +254,7 @@ import { useI18n } from 'vue-i18n';
import BaseIcon from '@/components/BaseIcon.vue'; import BaseIcon from '@/components/BaseIcon.vue';
import BaseLoader from '@/components/BaseLoader.vue'; import BaseLoader from '@/components/BaseLoader.vue';
import BaseSelect from '@/components/BaseSelect.vue'; import BaseSelect from '@/components/BaseSelect.vue';
import WorkspaceTabPropsTableChecksModal from '@/components/WorkspaceTabPropsTableChecksModal.vue';
import WorkspaceTabPropsTableDdlModal from '@/components/WorkspaceTabPropsTableDdlModal.vue'; import WorkspaceTabPropsTableDdlModal from '@/components/WorkspaceTabPropsTableDdlModal.vue';
import WorkspaceTabPropsTableFields from '@/components/WorkspaceTabPropsTableFields.vue'; import WorkspaceTabPropsTableFields from '@/components/WorkspaceTabPropsTableFields.vue';
import WorkspaceTabPropsTableForeignModal from '@/components/WorkspaceTabPropsTableForeignModal.vue'; import WorkspaceTabPropsTableForeignModal from '@/components/WorkspaceTabPropsTableForeignModal.vue';
@@ -273,13 +296,17 @@ const isLoading = ref(false);
const isSaving = ref(false); const isSaving = ref(false);
const isIndexesModal = ref(false); const isIndexesModal = ref(false);
const isForeignModal = ref(false); const isForeignModal = ref(false);
const isTableChecksModal = ref(false);
const isDdlModal = ref(false); const isDdlModal = ref(false);
const originalFields: Ref<TableField[]> = ref([]); const originalFields: Ref<TableField[]> = ref([]);
const localFields: Ref<TableField[]> = ref([]); const localFields: Ref<TableField[]> = ref([]);
const originalKeyUsage: Ref<TableForeign[]> = ref([]); const originalKeyUsage: Ref<TableForeign[]> = ref([]);
const localKeyUsage: Ref<TableForeign[]> = ref([]); const localKeyUsage: Ref<TableForeign[]> = ref([]);
const originalIndexes: Ref<TableIndex[]> = ref([]); const originalIndexes: Ref<TableIndex[]> = ref([]);
const localIndexes: Ref<TableIndex[]> = ref([]); const localIndexes: Ref<TableIndex[]> = ref([]);
const originalTableChecks: Ref<TableCheck[]> = ref([]);
const localTableChecks: Ref<TableCheck[]> = ref([]);
const tableOptions: Ref<TableOptions> = ref(null); const tableOptions: Ref<TableOptions> = ref(null);
const localOptions: Ref<TableOptions> = ref({} as TableOptions); const localOptions: Ref<TableOptions> = ref({} as TableOptions);
const lastTable = ref(null); const lastTable = ref(null);
@@ -307,6 +334,7 @@ const isChanged = computed(() => {
return JSON.stringify(originalFields.value) !== JSON.stringify(localFields.value) || return JSON.stringify(originalFields.value) !== JSON.stringify(localFields.value) ||
JSON.stringify(originalKeyUsage.value) !== JSON.stringify(localKeyUsage.value) || JSON.stringify(originalKeyUsage.value) !== JSON.stringify(localKeyUsage.value) ||
JSON.stringify(originalIndexes.value) !== JSON.stringify(localIndexes.value) || JSON.stringify(originalIndexes.value) !== JSON.stringify(localIndexes.value) ||
JSON.stringify(originalTableChecks.value) !== JSON.stringify(localTableChecks.value) ||
JSON.stringify(tableOptions.value) !== JSON.stringify(localOptions.value); JSON.stringify(tableOptions.value) !== JSON.stringify(localOptions.value);
}); });
@@ -430,6 +458,27 @@ const getFieldsData = async () => {
addNotification({ status: 'error', message: err.stack }); addNotification({ status: 'error', message: err.stack });
} }
if (workspace.value.customizations.tableCheck) {
try { // Table checks
const { status, response } = await Tables.getTableChecks(params);
if (status === 'success') {
originalTableChecks.value = response.map((check: TableCheck) => {
return {
_antares_id: uidGen(),
...check
};
});
localTableChecks.value = JSON.parse(JSON.stringify(originalTableChecks.value));
}
else
addNotification({ status: 'error', message: response });
}
catch (err) {
addNotification({ status: 'error', message: err.stack });
}
}
isLoading.value = false; isLoading.value = false;
}; };
@@ -527,6 +576,33 @@ const saveChanges = async () => {
// Foreigns Deletions // Foreigns Deletions
foreignChanges.deletions = originalKeyUsage.value.filter(foreign => !localForeignIDs.includes(foreign._antares_id)); foreignChanges.deletions = originalKeyUsage.value.filter(foreign => !localForeignIDs.includes(foreign._antares_id));
// CHECKS
const checkChanges = {
additions: [] as TableCheck[],
changes: [] as TableCheck[],
deletions: [] as TableCheck[]
};
const originalCheckIDs = originalTableChecks.value.reduce((acc, curr) => [...acc, curr._antares_id], []);
const localCheckIDs = localTableChecks.value.reduce((acc, curr) => [...acc, curr._antares_id], []);
// Check Additions
checkChanges.additions = localTableChecks.value.filter(check => !originalCheckIDs.includes(check._antares_id));
// Check Changes
originalTableChecks.value.forEach(originalCheck => {
const lI = localTableChecks.value.findIndex(localCheck => localCheck._antares_id === originalCheck._antares_id);
if (JSON.stringify(originalCheck) !== JSON.stringify(localTableChecks.value[lI])) {
if (localTableChecks.value[lI]) {
checkChanges.changes.push({
...localTableChecks.value[lI]
});
}
}
});
// Check Deletions
checkChanges.deletions = originalTableChecks.value.filter(check => !localCheckIDs.includes(check._antares_id));
// ALTER // ALTER
const params = { const params = {
uid: props.connection.uid, uid: props.connection.uid,
@@ -543,6 +619,7 @@ const saveChanges = async () => {
deletions, deletions,
indexChanges, indexChanges,
foreignChanges, foreignChanges,
checkChanges,
options options
} as unknown as AlterTableParams; } as unknown as AlterTableParams;
@@ -583,6 +660,7 @@ const clearChanges = () => {
localFields.value = JSON.parse(JSON.stringify(originalFields.value)); localFields.value = JSON.parse(JSON.stringify(originalFields.value));
localIndexes.value = JSON.parse(JSON.stringify(originalIndexes.value)); localIndexes.value = JSON.parse(JSON.stringify(originalIndexes.value));
localKeyUsage.value = JSON.parse(JSON.stringify(originalKeyUsage.value)); localKeyUsage.value = JSON.parse(JSON.stringify(originalKeyUsage.value));
localTableChecks.value = JSON.parse(JSON.stringify(originalTableChecks.value));
localOptions.value = JSON.parse(JSON.stringify(tableOptions.value)); localOptions.value = JSON.parse(JSON.stringify(tableOptions.value));
newFieldsCounter.value = 0; newFieldsCounter.value = 0;
}; };
@@ -702,6 +780,14 @@ const hideForeignModal = () => {
isForeignModal.value = false; isForeignModal.value = false;
}; };
const showTableChecksModal = () => {
isTableChecksModal.value = true;
};
const hideTableChecksModal = () => {
isTableChecksModal.value = false;
};
const showDdlModal = () => { const showDdlModal = () => {
isDdlModal.value = true; isDdlModal.value = true;
}; };
@@ -714,6 +800,10 @@ const foreignsUpdate = (foreigns: TableForeign[]) => {
localKeyUsage.value = foreigns; localKeyUsage.value = foreigns;
}; };
const checksUpdate = (checks: TableCheck[]) => {
localTableChecks.value = checks;
};
const saveContentListener = () => { const saveContentListener = () => {
const hasModalOpen = !!document.querySelectorAll('.modal.active').length; const hasModalOpen = !!document.querySelectorAll('.modal.active').length;
if (props.isSelected && !hasModalOpen && isChanged.value) if (props.isSelected && !hasModalOpen && isChanged.value)

View File

@@ -0,0 +1,268 @@
<template>
<ConfirmModal
:confirm-text="t('general.confirm')"
size="medium"
class="options-modal"
@confirm="confirmChecksChange"
@hide="$emit('hide')"
>
<template #header>
<div class="d-flex">
<BaseIcon
class="mr-1"
icon-name="mdiTableCheck"
:size="24"
/>
<span class="cut-text">{{ t('database.tableChecks') }} "{{ table }}"</span>
</div>
</template>
<template #body>
<div class="columns col-gapless">
<div class="column col-5">
<div class="panel" :style="{ height: modalInnerHeight + 'px'}">
<div class="panel-header pt-0 pl-0">
<div class="d-flex">
<button class="btn btn-dark btn-sm d-flex" @click="addCheck">
<BaseIcon
class="mr-1"
icon-name="mdiCheckboxMarkedCirclePlusOutline"
:size="24"
/>
<span>{{ t('general.add') }}</span>
</button>
<button
class="btn btn-dark btn-sm d-flex ml-2 mr-0"
:title="t('database.clearChanges')"
:disabled="!isChanged"
@click.prevent="clearChanges"
>
<BaseIcon
class="mr-1"
icon-name="mdiDeleteSweep"
:size="24"
/>
<span>{{ t('general.clear') }}</span>
</button>
</div>
</div>
<div ref="checksPanel" class="panel-body p-0 pr-1">
<div
v-for="check in checksProxy"
:key="check._antares_id"
class="tile tile-centered c-hand mb-1 p-1"
:class="{'selected-element': selectedCheckID === check._antares_id}"
@click="selectCheck($event, check._antares_id)"
>
<div class="tile-icon">
<div>
<BaseIcon
class="mt-2 column-key"
icon-name="mdiCheckboxMarkedCircleOutline"
:size="24"
/>
</div>
</div>
<div class="tile-content">
<div class="tile-title">
{{ check.name }}
</div>
<small class="tile-subtitle text-gray d-inline-block cut-text" style="width: 100%;">{{ check.clause }}</small>
</div>
<div class="tile-action">
<button
class="btn btn-link remove-field p-0 mr-2"
:title="t('general.delete')"
@click.prevent="removeCheck(check._antares_id)"
>
<BaseIcon
icon-name="mdiClose"
:size="18"
class="mt-2"
/>
</button>
</div>
</div>
</div>
</div>
</div>
<div class="column col-7 pl-2 editor-col">
<form
v-if="selectedCheckObj"
:style="{ height: modalInnerHeight + 'px'}"
class="form-horizontal"
>
<div class="form-group">
<label class="form-label col-3">
{{ t('general.name') }}
</label>
<div class="column">
<input
v-model="selectedCheckObj.name"
class="form-input"
type="text"
>
</div>
</div>
<div class="form-group">
<label class="form-label col-3">
{{ t('database.checkClause') }}
</label>
<div class="column">
<textarea
v-model="selectedCheckObj.clause"
class="form-input"
style="resize: vertical;"
rows="5"
/>
</div>
</div>
</form>
<div v-if="!checksProxy.length" class="empty">
<div class="empty-icon">
<BaseIcon
class="mr-1"
icon-name="mdiCheckboxMarkedCircleOutline"
:size="48"
/>
</div>
<p class="empty-title h5">
{{ t('database.thereAreNoTableChecks') }}
</p>
<div class="empty-action">
<button class="btn btn-primary" @click="addCheck">
{{ t('database.createNewCheck') }}
</button>
</div>
</div>
</div>
</div>
</template>
</ConfirmModal>
</template>
<script setup lang="ts">
import { TableCheck } from 'common/interfaces/antares';
import { uidGen } from 'common/libs/uidGen';
import { computed, onMounted, onUnmounted, Ref, ref } from 'vue';
import { useI18n } from 'vue-i18n';
import ConfirmModal from '@/components/BaseConfirmModal.vue';
import BaseIcon from '@/components/BaseIcon.vue';
const { t } = useI18n();
const props = defineProps({
localChecks: Array,
table: String,
workspace: Object
});
const emit = defineEmits(['hide', 'checks-update']);
const checksPanel: Ref<HTMLDivElement> = ref(null);
const checksProxy: Ref<TableCheck[]> = ref([]);
const selectedCheckID = ref('');
const modalInnerHeight = ref(400);
const selectedCheckObj = computed(() => checksProxy.value.find(index => index._antares_id === selectedCheckID.value));
const isChanged = computed(() => JSON.stringify(props.localChecks) !== JSON.stringify(checksProxy.value));
const confirmChecksChange = () => {
const filteredChecks = checksProxy.value.filter(check => check.clause.trim().length);
emit('checks-update', filteredChecks);
};
const selectCheck = (event: MouseEvent, id: string) => {
// eslint-disable-next-line @typescript-eslint/no-explicit-any
if (selectedCheckID.value !== id && !(event.target as any).classList.contains('remove-field'))
selectedCheckID.value = id;
};
const getModalInnerHeight = () => {
const modalBody = document.querySelector('.modal-body');
if (modalBody)
modalInnerHeight.value = modalBody.clientHeight - (parseFloat(getComputedStyle(modalBody).paddingTop) + parseFloat(getComputedStyle(modalBody).paddingBottom));
};
const addCheck = () => {
const uid = uidGen();
checksProxy.value = [...checksProxy.value, {
_antares_id: uid,
name: `CHK_${uid.substring(0, 4)}`,
clause: ''
}];
if (checksProxy.value.length === 1)
resetSelectedID();
setTimeout(() => {
checksPanel.value.scrollTop = checksPanel.value.scrollHeight + 60;
selectedCheckID.value = uid;
}, 20);
};
const removeCheck = (id: string) => {
checksProxy.value = checksProxy.value.filter(index => index._antares_id !== id);
if (selectedCheckID.value === id && checksProxy.value.length)
resetSelectedID();
};
const clearChanges = () => {
checksProxy.value = JSON.parse(JSON.stringify(props.localChecks));
if (!checksProxy.value.some(index => index._antares_id === selectedCheckID.value))
resetSelectedID();
};
const resetSelectedID = () => {
selectedCheckID.value = checksProxy.value.length ? checksProxy.value[0]._antares_id : '';
};
onMounted(() => {
checksProxy.value = JSON.parse(JSON.stringify(props.localChecks));
if (checksProxy.value.length)
resetSelectedID();
getModalInnerHeight();
window.addEventListener('resize', getModalInnerHeight);
});
onUnmounted(() => {
window.removeEventListener('resize', getModalInnerHeight);
});
</script>
<style lang="scss" scoped>
.tile {
border-radius: $border-radius;
opacity: 0.5;
transition: background 0.2s;
transition: opacity 0.2s;
.tile-action {
opacity: 0;
transition: opacity 0.2s;
}
&:hover {
.tile-action {
opacity: 1;
}
}
&.selected-element {
opacity: 1;
}
}
.fields-list {
max-height: 300px;
overflow: auto;
}
.remove-field svg {
pointer-events: none;
}
</style>

View File

@@ -745,7 +745,7 @@ const saveFileAs = async () => {
// eslint-disable-next-line @typescript-eslint/no-explicit-any // eslint-disable-next-line @typescript-eslint/no-explicit-any
const result: any = await Application.showSaveDialog({ const result: any = await Application.showSaveDialog({
filters: [{ name: 'SQL', extensions: ['sql'] }], filters: [{ name: 'SQL', extensions: ['sql'] }],
defaultPath: (!queryName.value.includes('.sql') ? `${queryName.value}.sql` :queryName.value) || 'query.sql' defaultPath: (queryName.value !== undefined && !queryName.value.includes('.sql') ? `${queryName.value}.sql` : queryName.value) || 'query.sql'
}); });
if (result && !result.canceled) { if (result && !result.canceled) {

View File

@@ -366,12 +366,21 @@ const sortedResults = computed(() => {
const sortObj = currentSort.value[resultsetIndex.value]; const sortObj = currentSort.value[resultsetIndex.value];
return [...localResults.value].sort((a: any, b: any) => { return [...localResults.value].sort((a: any, b: any) => {
let modifier = 1; const modifier = sortObj.dir === 'desc' ? -1 : 1;
let valA = typeof a[sortObj.field] === 'string' ? a[sortObj.field].toLowerCase() : a[sortObj.field]; let valA = a[sortObj.field];
if (!isNaN(valA)) valA = Number(valA); let valB = b[sortObj.field];
let valB = typeof b[sortObj.field] === 'string' ? b[sortObj.field].toLowerCase() : b[sortObj.field];
if (!isNaN(valB)) valB = Number(valB); // Handle null values
if (sortObj.dir === 'desc') modifier = -1; if (valA === null && valB !== null) return sortObj.dir === 'asc' ? -1 : 1;
if (valA !== null && valB === null) return sortObj.dir === 'asc' ? 1 : -1;
if (valA === null && valB === null) return 0;
valA = typeof valA === 'string' ? valA.toLowerCase() : valA;
valB = typeof valB === 'string' ? valB.toLowerCase() : valB;
if (typeof valA !== 'number' && !isNaN(valA)) valA = String(Number(valA));
if (typeof valB !== 'number' && !isNaN(valB)) valB = String(Number(valB));
if (valA < valB) return -1 * modifier; if (valA < valB) return -1 * modifier;
if (valA > valB) return 1 * modifier; if (valA > valB) return 1 * modifier;
return 0; return 0;

View File

@@ -126,6 +126,7 @@ export const enUS = {
insert: 'Insert', insert: 'Insert',
indexes: 'Indexes', indexes: 'Indexes',
foreignKeys: 'Foreign keys', foreignKeys: 'Foreign keys',
tableChecks: 'Table checks',
length: 'Length', length: 'Length',
unsigned: 'Unsigned', unsigned: 'Unsigned',
default: 'Default', default: 'Default',
@@ -190,12 +191,15 @@ export const enUS = {
addNewField: 'Add new field', addNewField: 'Add new field',
manageIndexes: 'Manage indexes', manageIndexes: 'Manage indexes',
manageForeignKeys: 'Manage foreign keys', manageForeignKeys: 'Manage foreign keys',
manageTableChecks: 'Manage table checks',
allowNull: 'Allow NULL', allowNull: 'Allow NULL',
zeroFill: 'Zero fill', zeroFill: 'Zero fill',
customValue: 'Custom value', customValue: 'Custom value',
onUpdate: 'On update', onUpdate: 'On update',
deleteField: 'Delete field', deleteField: 'Delete field',
createNewIndex: 'Create new index', createNewIndex: 'Create new index',
createNewCheck: 'Create new check',
checkClause: 'Check clause',
addToIndex: 'Add to index', addToIndex: 'Add to index',
createNewTable: 'Create new table', createNewTable: 'Create new table',
emptyTable: 'Empty table', emptyTable: 'Empty table',
@@ -205,6 +209,7 @@ export const enUS = {
emptyConfirm: 'Do you confirm to empty', emptyConfirm: 'Do you confirm to empty',
thereAreNoIndexes: 'There are no indexes', thereAreNoIndexes: 'There are no indexes',
thereAreNoForeign: 'There are no foreign keys', thereAreNoForeign: 'There are no foreign keys',
thereAreNoTableChecks: 'There are no table checks',
createNewForeign: 'Create new foreign key', createNewForeign: 'Create new foreign key',
referenceTable: 'Ref. table', referenceTable: 'Ref. table',
referenceField: 'Ref. field', referenceField: 'Ref. field',

View File

@@ -61,7 +61,17 @@ export const ruRU = {
actionSuccessful: '{action} успешно', actionSuccessful: '{action} успешно',
outputFormat: 'Формат вывода', outputFormat: 'Формат вывода',
singleFile: 'Один {ext} файл', singleFile: 'Один {ext} файл',
zipCompressedFile: 'ZIP сжатие {ext} файла' zipCompressedFile: 'ZIP сжатие {ext} файла',
include: 'Включая',
none: 'Нет',
singleQuote: 'Одинарная кавычка',
doubleQuote: 'Двойная кавычка',
copyName: 'Скопировать имя',
search: 'Поиск',
title: 'Название',
archive: 'Архив',
undo: 'Отменить',
moveTo: 'Переместить в'
}, },
connection: { connection: {
connectionName: 'Название соединения', connectionName: 'Название соединения',
@@ -96,7 +106,10 @@ export const ruRU = {
readOnlyMode: 'Режим только чтение', readOnlyMode: 'Режим только чтение',
untrustedConnection: 'Ненадежное соединение', untrustedConnection: 'Ненадежное соединение',
allConnections: 'Все соединения', allConnections: 'Все соединения',
searchForConnections: 'Поиск соединений' searchForConnections: 'Поиск соединений',
keepAliveInterval: 'Интервал поддержания соединения',
singleConnection: 'Одно соединение',
connection: 'Соединение'
}, },
database: { database: {
schema: 'Схема', schema: 'Схема',
@@ -255,7 +268,16 @@ export const ruRU = {
sqlExportOptions: 'Опции SQL экспорта', sqlExportOptions: 'Опции SQL экспорта',
targetTable: 'Целевая таблица', targetTable: 'Целевая таблица',
importQueryErrors: 'Внимание: {n} ошибка возникла | Внимание: {n} ошибок произошло', importQueryErrors: 'Внимание: {n} ошибка возникла | Внимание: {n} ошибок произошло',
executedQueries: '{n} запрос выполнен | {n} запросов выполнено' executedQueries: '{n} запрос выполнен | {n} запросов выполнено',
insert: 'Вставить',
materializedview: 'Материализованное представление | Материализованные представления',
exportTable: 'Экспорт таблицы',
createNewMaterializedView: 'Создать новое материализованное представление',
newMaterializedView: 'Новое материализованное представление',
switchDatabase: 'Переключить базу данных',
searchForElements: 'Поиск элементов',
searchForSchemas: 'Поиск схем',
savedQueries: 'Сохранённые запросы'
}, },
application: { application: {
settings: 'Настройки', settings: 'Настройки',
@@ -313,9 +335,9 @@ export const ruRU = {
previousTab: 'Предыдущая вкладка', previousTab: 'Предыдущая вкладка',
selectTabNumber: 'Выбрать вкладку под номером {param}', selectTabNumber: 'Выбрать вкладку под номером {param}',
toggleConsole: 'Переключиться на консоль', toggleConsole: 'Переключиться на консоль',
addShortcut: 'Добавить горячие клавиши', addShortcut: 'Добавить горячую клавишу',
editShortcut: 'Изменить горячие клавиши', editShortcut: 'Изменить горячую клавишу',
deleteShortcut: 'Удалить горячие клавиши', deleteShortcut: 'Удалить горячую клавишу',
restoreDefaults: 'Восстановить по-умолчанию', restoreDefaults: 'Восстановить по-умолчанию',
restoreDefaultsQuestion: 'Вы подтверждаете восстановление значений по-умолчанию?', restoreDefaultsQuestion: 'Вы подтверждаете восстановление значений по-умолчанию?',
registerAShortcut: 'Зарегистрировать горячие клавиши', registerAShortcut: 'Зарегистрировать горячие клавиши',
@@ -329,13 +351,14 @@ export const ruRU = {
openFilter: 'Открыть фильтр', openFilter: 'Открыть фильтр',
nextResultsPage: 'Следующая страница', nextResultsPage: 'Следующая страница',
previousResultsPage: 'Предыдущая страница', previousResultsPage: 'Предыдущая страница',
editFolder: 'Изменить директорию', editFolder: 'Изменить папку',
folderName: 'Название директории', folderName: 'Название папки',
deleteFolder: 'Удалить директорию', deleteFolder: 'Удалить папки',
editConnectionAppearance: 'Изменить внешний вид соединения', editConnectionAppearance: 'Изменить внешний вид соединения',
defaultCopyType: 'Тип копирования по-умолчанию', defaultCopyType: 'Тип копирования по-умолчанию',
showTableSize: 'Показывать размер таблицы в сайдбаре', showTableSize: 'Показывать размер таблицы в сайдбаре',
showTableSizeDescription: 'Только MySQL/MariaDB. Включение этого параметра может повлиять на производительность схемы с большим количеством таблиц.', showTableSizeDescription:
'Только MySQL/MariaDB. Включение этого параметра может повлиять на производительность схемы с большим количеством таблиц.',
searchForSchemas: 'Поиск схем', searchForSchemas: 'Поиск схем',
searchForElements: 'Поиск элементов', searchForElements: 'Поиск элементов',
switchSearchMethod: 'Переключить способ поиска', switchSearchMethod: 'Переключить способ поиска',
@@ -343,7 +366,49 @@ export const ruRU = {
closeOtherTabs: 'Закрыть остальные вкладки', closeOtherTabs: 'Закрыть остальные вкладки',
closeTabsToLeft: 'Закрыть вкладки слева', closeTabsToLeft: 'Закрыть вкладки слева',
closeTabsToRight: 'Закрыть вкладки справа', closeTabsToRight: 'Закрыть вкладки справа',
phpArray: 'PHP массив' phpArray: 'PHP массив',
event: 'Событие',
customIcon: 'Пользовательская иконка',
fileName: 'Имя файла',
choseFile: 'Выбрать файл',
data: 'Данные',
password: 'Пароль',
required: 'Обязательный',
newFolder: 'Новая папка',
outOfFolder: 'Вне папки',
csvFieldDelimiter: 'Разделитель полей CSV',
csvLinesTerminator: 'Терминатор строк CSV',
csvStringDelimiter: 'Разделитель строк CSV',
csvIncludeHeader: 'Включить заголовок',
csvExportOptions: 'Опции экспорта CSV',
exportData: 'Экспорт данных',
exportDataExplanation:
'Экспорт сохранённых соединений в Antares. Вам будет предложено ввести пароль для шифрования экспортируемого файла.',
importData: 'Импорт данных',
importDataExplanation: 'Импортирует файл .antares, содержащий соединения. Вам нужно будет ввести пароль, заданный во время экспорта.',
includeConnectionPasswords: 'Включить пароли соединений',
includeFolders: 'Включить папки',
encryptionPassword: 'Пароль шифрования',
encryptionPasswordError: 'Пароль шифрования должен содержать не менее 8 символов.',
ignoreDuplicates: 'Игнорировать дубликаты',
wrongImportPassword: 'Неверный пароль импорта',
wrongFileFormat: 'Неверный формат файла',
dataImportSuccess: 'Данные успешно импортированы',
note: 'Заметка | Заметки',
thereAreNoNotesYet: 'Заметок пока нет',
addNote: 'Добавить заметку',
editNote: 'Редактировать заметку',
saveAsNote: 'Сохранить как заметку',
showArchivedNotes: 'Показать архивированные заметки',
hideArchivedNotes: 'Скрыть архивированные заметки',
tag: 'Тег',
saveFile: 'Сохранить файл',
saveFileAs: 'Сохранить файл как',
openFile: 'Открыть файл',
openNotes: 'Открыть заметки',
debugConsole: 'Отладочная консоль',
executedQueries: 'Выполненные запросы',
sizeLimitError: 'Превышен максимальный размер {size}'
}, },
faker: { faker: {
address: 'Адрес', address: 'Адрес',

View File

@@ -1,18 +1,15 @@
import { ConnectionParams, IpcResponse } from 'common/interfaces/antares'; import { ConnectionParams, IpcResponse } from 'common/interfaces/antares';
import { ipcRenderer } from 'electron'; import { ipcRenderer } from 'electron';
import connStringConstruct from '../libs/connStringDecode';
import { unproxify } from '../libs/unproxify'; import { unproxify } from '../libs/unproxify';
export default class { export default class {
static makeTest (params: ConnectionParams & { pgConnString?: string }): Promise<IpcResponse> { static makeTest (params: ConnectionParams & { connString?: string }): Promise<IpcResponse> {
const newParams = connStringConstruct(params) as ConnectionParams; return ipcRenderer.invoke('test-connection', unproxify(params));
return ipcRenderer.invoke('test-connection', unproxify(newParams));
} }
static connect (params: ConnectionParams & { pgConnString?: string }): Promise<IpcResponse> { static connect (params: ConnectionParams & { connString?: string }): Promise<IpcResponse> {
const newParams = connStringConstruct(params) as ConnectionParams; return ipcRenderer.invoke('connect', unproxify(params));
return ipcRenderer.invoke('connect', unproxify(newParams));
} }
static abortConnection (uid: string): void { static abortConnection (uid: string): void {

View File

@@ -36,6 +36,10 @@ export default class {
return ipcRenderer.invoke('get-table-indexes', unproxify(params)); return ipcRenderer.invoke('get-table-indexes', unproxify(params));
} }
static getTableChecks (params: { uid: string; schema: string; table: string }): Promise<IpcResponse> {
return ipcRenderer.invoke('get-table-checks', unproxify(params));
}
static getTableDll (params: { uid: string; schema: string; table: string }): Promise<IpcResponse<string>> { static getTableDll (params: { uid: string; schema: string; table: string }): Promise<IpcResponse<string>> {
return ipcRenderer.invoke('get-table-ddl', unproxify(params)); return ipcRenderer.invoke('get-table-ddl', unproxify(params));
} }

View File

@@ -1,50 +0,0 @@
import { ConnectionParams } from 'common/interfaces/antares';
import * as formatter from 'pg-connection-string'; // parses a connection string
const formatHost = (host: string) => {
const results = host === 'localhost' ? '127.0.0.1' : host;
return results;
};
const checkForSSl = (conn: string) => {
return conn.includes('ssl=true');
};
const connStringConstruct = (args: ConnectionParams & { pgConnString?: string }): ConnectionParams => {
if (!args.pgConnString)
return args;
if (typeof args.pgConnString !== 'string')
return args;
// eslint-disable-next-line @typescript-eslint/no-explicit-any
const stringArgs: any = formatter.parse(args.pgConnString);
const client = args.client || 'pg';
args.client = client;
args.host = formatHost(stringArgs.host);
args.database = stringArgs.database;
args.port = stringArgs.port || '5432';
args.user = stringArgs.user;
args.password = stringArgs.password;
// ssh
args.ssh = stringArgs.ssh || args.ssh;
args.sshHost = stringArgs.sshHost;
args.sshUser = stringArgs.sshUser;
args.sshPass = stringArgs.sshPass;
args.sshKey = stringArgs.sshKey;
args.sshPort = stringArgs.sshPort;
// ssl mode
args.ssl = checkForSSl(args.pgConnString) || args.ssl;
args.cert = stringArgs.sslcert;
args.key = stringArgs.sslkey;
args.ca = stringArgs.sslrootcert;
args.ciphers = stringArgs.ciphers;
return args;
};
export default connStringConstruct;

View File

@@ -10,7 +10,7 @@ export interface QueryLog {
} }
export interface DebugLog { export interface DebugLog {
level: 'log' | 'info' | 'warn' | 'error'; level: 'log' | 'info' | 'warn' | 'error' | string;
process: 'renderer' | 'main' | 'worker'; process: 'renderer' | 'main' | 'worker';
message: string; message: string;
date: Date; date: Date;

View File

@@ -1,6 +1,8 @@
import { uidGen } from 'common/libs/uidGen'; import { uidGen } from 'common/libs/uidGen';
import { defineStore } from 'pinia'; import { defineStore } from 'pinia';
import { useConsoleStore } from './console';
export interface Notification { export interface Notification {
uid: string; uid: string;
status: string; status: string;
@@ -15,6 +17,13 @@ export const useNotificationsStore = defineStore('notifications', {
addNotification (payload: { status: string; message: string }) { addNotification (payload: { status: string; message: string }) {
const notification: Notification = { uid: uidGen('N'), ...payload }; const notification: Notification = { uid: uidGen('N'), ...payload };
this.notifications.unshift(notification); this.notifications.unshift(notification);
useConsoleStore().putLog('debug', {
level: notification.status,
process: 'renderer',
message: notification.message,
date: new Date()
});
}, },
removeNotification (uid: string) { removeNotification (uid: string) {
this.notifications = (this.notifications as Notification[]).filter(item => item.uid !== uid); this.notifications = (this.notifications as Notification[]).filter(item => item.uid !== uid);

View File

@@ -147,7 +147,7 @@ export const useWorkspacesStore = defineStore('workspaces', {
else else
this.selectedWorkspace = uid; this.selectedWorkspace = uid;
}, },
async connectWorkspace (connection: ConnectionParams & { pgConnString?: string }, args?: {mode?: string; signal?: AbortSignal}) { async connectWorkspace (connection: ConnectionParams & { connString?: string }, args?: {mode?: string; signal?: AbortSignal}) {
this.workspaces = (this.workspaces as Workspace[]).map(workspace => workspace.uid === connection.uid this.workspaces = (this.workspaces as Workspace[]).map(workspace => workspace.uid === connection.uid
? { ? {
...workspace, ...workspace,
@@ -427,7 +427,7 @@ export const useWorkspacesStore = defineStore('workspaces', {
this.selectTab({ uid, tab: 0 }); this.selectTab({ uid, tab: 0 });
}, },
async switchConnection (connection: ConnectionParams & { pgConnString?: string }) { async switchConnection (connection: ConnectionParams & { connString?: string }) {
await Connection.disconnect(connection.uid); await Connection.disconnect(connection.uid);
return this.connectWorkspace(connection, { mode: 'switch' }); return this.connectWorkspace(connection, { mode: 'switch' });
}, },