diff --git a/.eslintignore b/.eslintignore index d3405a7a..b98792d3 100644 --- a/.eslintignore +++ b/.eslintignore @@ -1,4 +1,5 @@ node_modules assets out -dist \ No newline at end of file +dist +build \ No newline at end of file diff --git a/package.json b/package.json index dd8bc8ba..d2ce9eef 100644 --- a/package.json +++ b/package.json @@ -22,8 +22,8 @@ "postinstall": "electron-builder install-app-deps && npm run devtools:install", "test:e2e": "npm run compile && npm run test:e2e-dry", "test:e2e-dry": "xvfb-maybe -- playwright test", - "lint": "eslint . --ext .js,.vue && stylelint \"./src/**/*.{css,scss,sass,vue}\"", - "lint:fix": "eslint . --ext .js,.vue --fix && stylelint \"./src/**/*.{css,scss,sass,vue}\" --fix", + "lint": "eslint . --ext .js,.ts,.vue && stylelint \"./src/**/*.{css,scss,sass,vue}\"", + "lint:fix": "eslint . --ext .js,.ts,.vue --fix && stylelint \"./src/**/*.{css,scss,sass,vue}\" --fix", "contributors:add": "all-contributors add", "contributors:generate": "all-contributors generate" }, diff --git a/src/common/interfaces/antares.ts b/src/common/interfaces/antares.ts index 809d63b0..4be31ec3 100644 --- a/src/common/interfaces/antares.ts +++ b/src/common/interfaces/antares.ts @@ -14,6 +14,12 @@ export type ClientCode = 'mysql' | 'maria' | 'pg' | 'sqlite' export type Exporter = MysqlExporter | PostgreSQLExporter export type Importer = MySQLImporter | PostgreSQLImporter +// eslint-disable-next-line @typescript-eslint/no-explicit-any +export interface IpcResponse { + status: 'success' | 'error'; + response?: T; +} + /** * Pasameters needed to create a new Antares connection to a database */ diff --git a/src/main/ipc-handlers/application.ts b/src/main/ipc-handlers/application.ts index f9c17654..2d285f7b 100644 --- a/src/main/ipc-handlers/application.ts +++ b/src/main/ipc-handlers/application.ts @@ -5,11 +5,6 @@ export default () => { app.exit(); }); - ipcMain.on('get-key', async event => { - const key = false; - event.returnValue = key; - }); - ipcMain.handle('show-open-dialog', (event, options) => { return dialog.showOpenDialog(options); }); diff --git a/src/main/ipc-handlers/tables.ts b/src/main/ipc-handlers/tables.ts index 66a09be3..0acdc380 100644 --- a/src/main/ipc-handlers/tables.ts +++ b/src/main/ipc-handlers/tables.ts @@ -244,75 +244,6 @@ export default (connections: {[key: string]: antares.Client}) => { } }); - ipcMain.handle('insert-table-rows', async (event, params) => { - try { // TODO: move to client classes - const insertObj: {[key: string]: string | number | boolean | Date | Buffer} = {}; - for (const key in params.row) { - const type = params.fields[key]; - let escapedParam; - - if (params.row[key] === null) - escapedParam = 'NULL'; - else if ([...NUMBER, ...FLOAT].includes(type)) - escapedParam = +params.row[key]; - else if ([...TEXT, ...LONG_TEXT].includes(type)) { - switch (connections[params.uid]._client) { - case 'mysql': - case 'maria': - escapedParam = `"${sqlEscaper(params.row[key].value)}"`; - break; - case 'pg': - escapedParam = `'${params.row[key].value.replaceAll('\'', '\'\'')}'`; - break; - } - } - else if (BLOB.includes(type)) { - if (params.row[key].value) { - let fileBlob; - - switch (connections[params.uid]._client) { - case 'mysql': - case 'maria': - fileBlob = fs.readFileSync(params.row[key].value); - escapedParam = `0x${fileBlob.toString('hex')}`; - break; - case 'pg': - fileBlob = fs.readFileSync(params.row[key].value); - escapedParam = `decode('${fileBlob.toString('hex')}', 'hex')`; - break; - } - } - else { - switch (connections[params.uid]._client) { - case 'mysql': - case 'maria': - escapedParam = '""'; - break; - case 'pg': - escapedParam = 'decode(\'\', \'hex\')'; - break; - } - } - } - - insertObj[key] = escapedParam; - } - - const rows = new Array(+params.repeat).fill(insertObj); - - await connections[params.uid] - .schema(params.schema) - .into(params.table) - .insert(rows) - .run(); - - return { status: 'success' }; - } - catch (err) { - return { status: 'error', response: err.toString() }; - } - }); - ipcMain.handle('insert-table-fake-rows', async (event, params: InsertRowsParams) => { try { // TODO: move to client classes const rows: {[key: string]: string | number | boolean | Date | Buffer}[] = []; diff --git a/src/main/libs/clients/MySQLClient.ts b/src/main/libs/clients/MySQLClient.ts index acdf3311..4d3c7be9 100644 --- a/src/main/libs/clients/MySQLClient.ts +++ b/src/main/libs/clients/MySQLClient.ts @@ -1381,6 +1381,14 @@ export class MySQLClient extends AntaresCore { xa: row.XA, savepoints: row.Savepoints, isDefault: row.Support.includes('DEFAULT') + } as { + name: string; + support: string; + comment: string; + transactions: string; + xa: string; + savepoints: string; + isDefault: boolean; }; }); } @@ -1405,7 +1413,12 @@ export class MySQLClient extends AntaresCore { break; } return acc; - }, {}); + }, {}) as { + number: string; + name: string; + arch: string; + os: string; + }; } async getProcesses () { @@ -1423,6 +1436,15 @@ export class MySQLClient extends AntaresCore { time: row.TIME, state: row.STATE, info: row.INFO + } as { + id: number; + user: string; + host: string; + db: string; + command: string; + time: number; + state: string; + info: string; }; }); } diff --git a/src/renderer/App.vue b/src/renderer/App.vue index eae823ec..28378ee2 100644 --- a/src/renderer/App.vue +++ b/src/renderer/App.vue @@ -147,7 +147,7 @@ export default { height: calc(100vh - #{$footer-height}); } - .connection-panel-wrapper{ + .connection-panel-wrapper { height: calc(100vh - #{$excluding-size}); width: 100%; padding-top: 15vh; @@ -155,6 +155,6 @@ export default { justify-content: center; align-items: flex-start; overflow: auto; - } + } } diff --git a/src/renderer/components/BaseSelect.vue b/src/renderer/components/BaseSelect.vue index b3352d96..0f5433f2 100644 --- a/src/renderer/components/BaseSelect.vue +++ b/src/renderer/components/BaseSelect.vue @@ -380,48 +380,49 @@ export default defineComponent({ diff --git a/src/renderer/components/ForeignKeySelect.vue b/src/renderer/components/ForeignKeySelect.vue index a6de6e91..906308e5 100644 --- a/src/renderer/components/ForeignKeySelect.vue +++ b/src/renderer/components/ForeignKeySelect.vue @@ -8,7 +8,7 @@ dropdown-class="select-sm" dropdown-container=".workspace-query-results > .vscroll" @change="onChange" - @blur="$emit('blur')" + @blur="emit('blur')" /> @@ -20,6 +20,7 @@ import { useNotificationsStore } from '@/stores/notifications'; import { useWorkspacesStore } from '@/stores/workspaces'; import { TEXT, LONG_TEXT } from 'common/fieldTypes'; import BaseSelect from '@/components/BaseSelect.vue'; +import { TableField } from 'common/interfaces/antares'; const props = defineProps({ modelValue: [String, Number], @@ -56,7 +57,7 @@ const foreigns = computed(() => { return list; }); -const onChange = (opt: any) => { +const onChange = (opt: HTMLSelectElement) => { emit('update:modelValue', opt.value); }; @@ -65,7 +66,7 @@ const cutText = (val: string) => { return val.length > 15 ? `${val.substring(0, 15)}...` : val; }; -let foreignDesc; +let foreignDesc: string | false; const params = { uid: selectedWorkspace.value, schema: props.keyUsage.refSchema, @@ -77,7 +78,7 @@ const params = { const { status, response } = await Tables.getTableColumns(params); if (status === 'success') { - const textField = response.find((field: {type: string; name: string}) => [...TEXT, ...LONG_TEXT].includes(field.type) && field.name !== props.keyUsage.refField); + const textField = (response as TableField[]).find((field: {type: string; name: string}) => [...TEXT, ...LONG_TEXT].includes(field.type) && field.name !== props.keyUsage.refField); foreignDesc = textField ? textField.name : false; } else diff --git a/src/renderer/components/ModalExportSchema.vue b/src/renderer/components/ModalExportSchema.vue index 9b2db071..ff385b9e 100644 --- a/src/renderer/components/ModalExportSchema.vue +++ b/src/renderer/components/ModalExportSchema.vue @@ -469,14 +469,15 @@ onBeforeUnmount(() => { overflow: hidden; .left { - display: flex; - flex-direction: column; - flex: 1; + display: flex; + flex-direction: column; + flex: 1; } } .workspace-query-results { - flex: 1 0 1px; + flex: 1 0 1px; + .table { width: 100% !important; } @@ -492,25 +493,24 @@ onBeforeUnmount(() => { } .modal { - .modal-container { max-width: 800px; } - .modal-body { - max-height: 60vh; - display: flex; - flex-direction: column; - } + .modal-body { + max-height: 60vh; + display: flex; + flex-direction: column; + } - .modal-footer { - display: flex; - } + .modal-footer { + display: flex; + } } .progress-status { - font-style: italic; - font-size: 80%; + font-style: italic; + font-size: 80%; } diff --git a/src/renderer/components/ModalImportSchema.vue b/src/renderer/components/ModalImportSchema.vue index 6191e422..c98a0d82 100644 --- a/src/renderer/components/ModalImportSchema.vue +++ b/src/renderer/components/ModalImportSchema.vue @@ -166,24 +166,23 @@ defineExpose({ startImport }); diff --git a/src/renderer/components/ModalSettings.vue b/src/renderer/components/ModalSettings.vue index 6b70fed9..2a79e71c 100644 --- a/src/renderer/components/ModalSettings.vue +++ b/src/renderer/components/ModalSettings.vue @@ -79,7 +79,7 @@ />
- + {{ t('message.missingOrIncompleteTranslation') }}
{{ t('message.findOutHowToContribute') }}
diff --git a/src/renderer/components/WorkspaceAddConnectionPanel.vue b/src/renderer/components/WorkspaceAddConnectionPanel.vue index 9cb936f3..a54b8c8a 100644 --- a/src/renderer/components/WorkspaceAddConnectionPanel.vue +++ b/src/renderer/components/WorkspaceAddConnectionPanel.vue @@ -478,7 +478,7 @@ const startTest = async () => { isAsking.value = true; else { try { - const res = await Connection.makeTest(connection); + const res = await Connection.makeTest(connection.value); if (res.status === 'error') addNotification({ status: 'error', message: res.response.message || res.response.toString() }); else diff --git a/src/renderer/composables/useResultTables.js b/src/renderer/composables/useResultTables.js index 0eeb2d6a..23f1aa79 100644 --- a/src/renderer/composables/useResultTables.js +++ b/src/renderer/composables/useResultTables.js @@ -20,7 +20,7 @@ export default function useResultTables (uid, reloadTable, addNotification) { if (response.reload)// Needed for blob fields reloadTable(); else - tableRef.applyUpdate(payload); + tableRef.value.applyUpdate(payload); } else addNotification({ status: 'error', message: response }); diff --git a/src/renderer/ipc-api/Application.js b/src/renderer/ipc-api/Application.js deleted file mode 100644 index 75a91013..00000000 --- a/src/renderer/ipc-api/Application.js +++ /dev/null @@ -1,17 +0,0 @@ -'use strict'; -import { ipcRenderer } from 'electron'; -import { unproxify } from '../libs/unproxify'; - -export default class { - static getKey (params) { - return ipcRenderer.sendSync('get-key', unproxify(params)); - } - - static showOpenDialog (options) { - return ipcRenderer.invoke('show-open-dialog', unproxify(options)); - } - - static getDownloadPathDirectory () { - return ipcRenderer.invoke('get-download-dir-path'); - } -} diff --git a/src/renderer/ipc-api/Application.ts b/src/renderer/ipc-api/Application.ts new file mode 100644 index 00000000..78c42bf8 --- /dev/null +++ b/src/renderer/ipc-api/Application.ts @@ -0,0 +1,12 @@ +import { ipcRenderer, OpenDialogOptions, OpenDialogReturnValue } from 'electron'; +import { unproxify } from '../libs/unproxify'; + +export default class { + static showOpenDialog (options: OpenDialogOptions): Promise { + return ipcRenderer.invoke('show-open-dialog', unproxify(options)); + } + + static getDownloadPathDirectory (): Promise { + return ipcRenderer.invoke('get-download-dir-path'); + } +} diff --git a/src/renderer/ipc-api/Connection.js b/src/renderer/ipc-api/Connection.js deleted file mode 100644 index 004b2607..00000000 --- a/src/renderer/ipc-api/Connection.js +++ /dev/null @@ -1,24 +0,0 @@ -'use strict'; -import { ipcRenderer } from 'electron'; -import connStringConstruct from '../libs/connStringDecode'; -import { unproxify } from '../libs/unproxify'; - -export default class { - static makeTest (params) { - params = connStringConstruct(params); - return ipcRenderer.invoke('test-connection', unproxify(params)); - } - - static connect (params) { - params = connStringConstruct(params); - return ipcRenderer.invoke('connect', unproxify(params)); - } - - static checkConnection (uid) { - return ipcRenderer.invoke('check-connection', uid); - } - - static disconnect (uid) { - return ipcRenderer.invoke('disconnect', uid); - } -} diff --git a/src/renderer/ipc-api/Connection.ts b/src/renderer/ipc-api/Connection.ts new file mode 100644 index 00000000..538952c7 --- /dev/null +++ b/src/renderer/ipc-api/Connection.ts @@ -0,0 +1,24 @@ +import { ConnectionParams, IpcResponse } from 'common/interfaces/antares'; +import { ipcRenderer } from 'electron'; +import connStringConstruct from '../libs/connStringDecode'; +import { unproxify } from '../libs/unproxify'; + +export default class { + static makeTest (params: ConnectionParams & { pgConnString: string }): Promise { + const newParams = connStringConstruct(params) as ConnectionParams; + return ipcRenderer.invoke('test-connection', unproxify(newParams)); + } + + static connect (params: ConnectionParams & { pgConnString: string }): Promise { + const newParams = connStringConstruct(params) as ConnectionParams; + return ipcRenderer.invoke('connect', unproxify(newParams)); + } + + static checkConnection (uid: string): Promise { + return ipcRenderer.invoke('check-connection', uid); + } + + static disconnect (uid: string): Promise { + return ipcRenderer.invoke('disconnect', uid); + } +} diff --git a/src/renderer/ipc-api/Functions.js b/src/renderer/ipc-api/Functions.js deleted file mode 100644 index 6a26d425..00000000 --- a/src/renderer/ipc-api/Functions.js +++ /dev/null @@ -1,29 +0,0 @@ -'use strict'; -import { ipcRenderer } from 'electron'; -import { unproxify } from '../libs/unproxify'; - -export default class { - static getFunctionInformations (params) { - return ipcRenderer.invoke('get-function-informations', unproxify(params)); - } - - static dropFunction (params) { - return ipcRenderer.invoke('drop-function', unproxify(params)); - } - - static alterFunction (params) { - return ipcRenderer.invoke('alter-function', unproxify(params)); - } - - static alterTriggerFunction (params) { - return ipcRenderer.invoke('alter-trigger-function', unproxify(params)); - } - - static createFunction (params) { - return ipcRenderer.invoke('create-function', unproxify(params)); - } - - static createTriggerFunction (params) { - return ipcRenderer.invoke('create-trigger-function', unproxify(params)); - } -} diff --git a/src/renderer/ipc-api/Functions.ts b/src/renderer/ipc-api/Functions.ts new file mode 100644 index 00000000..c5242d3f --- /dev/null +++ b/src/renderer/ipc-api/Functions.ts @@ -0,0 +1,29 @@ +import { AlterFunctionParams, CreateFunctionParams, FunctionInfos, IpcResponse } from 'common/interfaces/antares'; +import { ipcRenderer } from 'electron'; +import { unproxify } from '../libs/unproxify'; + +export default class { + static getFunctionInformations (params: { uid: string; schema: string; func: string}): Promise> { + return ipcRenderer.invoke('get-function-informations', unproxify(params)); + } + + static dropFunction (params: { uid: string; schema: string; func: string}): Promise { + return ipcRenderer.invoke('drop-function', unproxify(params)); + } + + static alterFunction (params: { func: AlterFunctionParams }): Promise { + return ipcRenderer.invoke('alter-function', unproxify(params)); + } + + static alterTriggerFunction (params: {func: CreateFunctionParams & { uid: string }}): Promise { + return ipcRenderer.invoke('alter-trigger-function', unproxify(params)); + } + + static createFunction (params: CreateFunctionParams & { uid: string }): Promise { + return ipcRenderer.invoke('create-function', unproxify(params)); + } + + static createTriggerFunction (params: CreateFunctionParams & { uid: string }): Promise { + return ipcRenderer.invoke('create-trigger-function', unproxify(params)); + } +} diff --git a/src/renderer/ipc-api/Routines.js b/src/renderer/ipc-api/Routines.js deleted file mode 100644 index 1b39609c..00000000 --- a/src/renderer/ipc-api/Routines.js +++ /dev/null @@ -1,21 +0,0 @@ -'use strict'; -import { ipcRenderer } from 'electron'; -import { unproxify } from '../libs/unproxify'; - -export default class { - static getRoutineInformations (params) { - return ipcRenderer.invoke('get-routine-informations', unproxify(params)); - } - - static dropRoutine (params) { - return ipcRenderer.invoke('drop-routine', unproxify(params)); - } - - static alterRoutine (params) { - return ipcRenderer.invoke('alter-routine', unproxify(params)); - } - - static createRoutine (params) { - return ipcRenderer.invoke('create-routine', unproxify(params)); - } -} diff --git a/src/renderer/ipc-api/Routines.ts b/src/renderer/ipc-api/Routines.ts new file mode 100644 index 00000000..fa99bd2a --- /dev/null +++ b/src/renderer/ipc-api/Routines.ts @@ -0,0 +1,21 @@ +import { ipcRenderer } from 'electron'; +import { unproxify } from '../libs/unproxify'; +import { AlterRoutineParams, CreateRoutineParams, IpcResponse, RoutineInfos } from 'common/interfaces/antares'; + +export default class { + static getRoutineInformations (params: { uid: string; schema: string; routine: string}): Promise> { + return ipcRenderer.invoke('get-routine-informations', unproxify(params)); + } + + static dropRoutine (params: { uid: string; schema: string; routine: string}): Promise { + return ipcRenderer.invoke('drop-routine', unproxify(params)); + } + + static alterRoutine (params: { routine: AlterRoutineParams & { uid: string } }): Promise { + return ipcRenderer.invoke('alter-routine', unproxify(params)); + } + + static createRoutine (params: { routine: CreateRoutineParams & { uid: string } }): Promise { + return ipcRenderer.invoke('create-routine', unproxify(params)); + } +} diff --git a/src/renderer/ipc-api/Schedulers.js b/src/renderer/ipc-api/Schedulers.js deleted file mode 100644 index 32012b99..00000000 --- a/src/renderer/ipc-api/Schedulers.js +++ /dev/null @@ -1,24 +0,0 @@ -'use strict'; -import { ipcRenderer } from 'electron'; -import { unproxify } from '../libs/unproxify'; -export default class { - static getSchedulerInformations (params) { - return ipcRenderer.invoke('get-scheduler-informations', unproxify(params)); - } - - static dropScheduler (params) { - return ipcRenderer.invoke('drop-scheduler', unproxify(params)); - } - - static alterScheduler (params) { - return ipcRenderer.invoke('alter-scheduler', unproxify(params)); - } - - static createScheduler (params) { - return ipcRenderer.invoke('create-scheduler', unproxify(params)); - } - - static toggleScheduler (params) { - return ipcRenderer.invoke('toggle-scheduler', unproxify(params)); - } -} diff --git a/src/renderer/ipc-api/Schedulers.ts b/src/renderer/ipc-api/Schedulers.ts new file mode 100644 index 00000000..807575af --- /dev/null +++ b/src/renderer/ipc-api/Schedulers.ts @@ -0,0 +1,25 @@ +import { ipcRenderer } from 'electron'; +import { unproxify } from '../libs/unproxify'; +import { AlterEventParams, CreateEventParams, EventInfos, IpcResponse } from 'common/interfaces/antares'; + +export default class { + static getSchedulerInformations (params: { uid: string; schema: string; scheduler: string}): Promise> { + return ipcRenderer.invoke('get-scheduler-informations', unproxify(params)); + } + + static dropScheduler (params: { uid: string; schema: string; scheduler: string}): Promise { + return ipcRenderer.invoke('drop-scheduler', unproxify(params)); + } + + static alterScheduler (params: { scheduler: AlterEventParams & { uid: string } }): Promise { + return ipcRenderer.invoke('alter-scheduler', unproxify(params)); + } + + static createScheduler (params: CreateEventParams & { uid: string }): Promise { + return ipcRenderer.invoke('create-scheduler', unproxify(params)); + } + + static toggleScheduler (params: { uid: string; schema: string; scheduler: string}): Promise { + return ipcRenderer.invoke('toggle-scheduler', unproxify(params)); + } +} diff --git a/src/renderer/ipc-api/Schema.js b/src/renderer/ipc-api/Schema.js deleted file mode 100644 index d920cbf9..00000000 --- a/src/renderer/ipc-api/Schema.js +++ /dev/null @@ -1,89 +0,0 @@ -'use strict'; -import { ipcRenderer } from 'electron'; -import { unproxify } from '../libs/unproxify'; - -export default class { - static createSchema (params) { - return ipcRenderer.invoke('create-schema', unproxify(params)); - } - - static updateSchema (params) { - return ipcRenderer.invoke('update-schema', unproxify(params)); - } - - static getDatabaseCollation (params) { - return ipcRenderer.invoke('get-schema-collation', unproxify(params)); - } - - static deleteSchema (params) { - return ipcRenderer.invoke('delete-schema', unproxify(params)); - } - - static getStructure (params) { - return ipcRenderer.invoke('get-structure', unproxify(params, false)); - } - - static getCollations (uid) { - return ipcRenderer.invoke('get-collations', uid); - } - - static getVariables (uid) { - return ipcRenderer.invoke('get-variables', uid); - } - - static getEngines (uid) { - return ipcRenderer.invoke('get-engines', uid); - } - - static getVersion (uid) { - return ipcRenderer.invoke('get-version', uid); - } - - static getProcesses (uid) { - return ipcRenderer.invoke('get-processes', uid); - } - - static killProcess (params) { - return ipcRenderer.invoke('kill-process', unproxify(params)); - } - - static killTabQuery (params) { - return ipcRenderer.invoke('kill-tab-query', unproxify(params)); - } - - static commitTab (params) { - return ipcRenderer.invoke('commit-tab', unproxify(params)); - } - - static rollbackTab (params) { - return ipcRenderer.invoke('rollback-tab', unproxify(params)); - } - - static destroyConnectionToCommit (params) { - return ipcRenderer.invoke('destroy-connection-to-commit', unproxify(params)); - } - - static useSchema (params) { - return ipcRenderer.invoke('use-schema', unproxify(params)); - } - - static rawQuery (params) { - return ipcRenderer.invoke('raw-query', unproxify(params)); - } - - static export (params) { - return ipcRenderer.invoke('export', unproxify(params)); - } - - static abortExport () { - return ipcRenderer.invoke('abort-export'); - } - - static import (params) { - return ipcRenderer.invoke('import-sql', unproxify(params)); - } - - static abortImport () { - return ipcRenderer.invoke('abort-import-sql'); - } -} diff --git a/src/renderer/ipc-api/Schema.ts b/src/renderer/ipc-api/Schema.ts new file mode 100644 index 00000000..b9f17235 --- /dev/null +++ b/src/renderer/ipc-api/Schema.ts @@ -0,0 +1,128 @@ +import { ipcRenderer } from 'electron'; +import { unproxify } from '../libs/unproxify'; +import { IpcResponse/*, EventInfos, QueryResult, RoutineInfos, TableInfos, TriggerInfos */ } from 'common/interfaces/antares'; +import { ExportOptions } from 'common/interfaces/exporter'; +import { ImportOptions } from 'common/interfaces/importer'; + +export default class { + static createSchema (params: { uid: string; name: string; collation?: string }): Promise { + return ipcRenderer.invoke('create-schema', unproxify(params)); + } + + static updateSchema (params: { uid: string; name: string; collation?: string }): Promise { + return ipcRenderer.invoke('update-schema', unproxify(params)); + } + + static getDatabaseCollation (params: { uid: string; database: string }) { + return ipcRenderer.invoke('get-schema-collation', unproxify(params)); + } + + static deleteSchema (params: { uid: string; database: string }): Promise { + return ipcRenderer.invoke('delete-schema', unproxify(params)); + } + + static getStructure (params: { uid: string; schemas: Set }): Promise */> { + return ipcRenderer.invoke('get-structure', unproxify(params, false)); + } + + static getCollations (uid: string): Promise */> { + return ipcRenderer.invoke('get-collations', uid); + } + + static getVariables (uid: string): Promise */> { + return ipcRenderer.invoke('get-variables', uid); + } + + static getEngines (uid: string): Promise */> { + return ipcRenderer.invoke('get-engines', uid); + } + + static getVersion (uid: string): Promise */> { + return ipcRenderer.invoke('get-version', uid); + } + + static getProcesses (uid: string): Promise */> { + return ipcRenderer.invoke('get-processes', uid); + } + + static killProcess (params: { uid: string; pid: string }): Promise { + return ipcRenderer.invoke('kill-process', unproxify(params)); + } + + static killTabQuery (params: { uid: string; tabUid: string }): Promise { + return ipcRenderer.invoke('kill-tab-query', unproxify(params)); + } + + static commitTab (params: { uid: string; tabUid: string }): Promise { + return ipcRenderer.invoke('commit-tab', unproxify(params)); + } + + static rollbackTab (params: { uid: string; tabUid: string }): Promise { + return ipcRenderer.invoke('rollback-tab', unproxify(params)); + } + + static destroyConnectionToCommit (params: { uid: string; tabUid: string }): Promise { + return ipcRenderer.invoke('destroy-connection-to-commit', unproxify(params)); + } + + static useSchema (params: { uid: string; schema: string }): Promise { + return ipcRenderer.invoke('use-schema', unproxify(params)); + } + + static rawQuery (params: { uid: string; query: string; schema: string; tabUid: string; autocommit?: boolean }): Promise */> { + return ipcRenderer.invoke('raw-query', unproxify(params)); + } + + static export (params: { uid: string; type: string; tables: string; options: ExportOptions }): Promise { + return ipcRenderer.invoke('export', unproxify(params)); + } + + static abortExport (): Promise { + return ipcRenderer.invoke('abort-export'); + } + + static import (params: ImportOptions): Promise { + return ipcRenderer.invoke('import-sql', unproxify(params)); + } + + static abortImport (): Promise { + return ipcRenderer.invoke('abort-import-sql'); + } +} diff --git a/src/renderer/ipc-api/Tables.js b/src/renderer/ipc-api/Tables.js deleted file mode 100644 index 9cee3cc0..00000000 --- a/src/renderer/ipc-api/Tables.js +++ /dev/null @@ -1,69 +0,0 @@ -'use strict'; -import { ipcRenderer } from 'electron'; -import { unproxify } from '../libs/unproxify'; - -export default class { - static getTableColumns (params) { - return ipcRenderer.invoke('get-table-columns', unproxify(params)); - } - - static getTableData (params) { - return ipcRenderer.invoke('get-table-data', unproxify(params)); - } - - static getTableApproximateCount (params) { - return ipcRenderer.invoke('get-table-count', unproxify(params)); - } - - static getTableOptions (params) { - return ipcRenderer.invoke('get-table-options', unproxify(params)); - } - - static getTableIndexes (params) { - return ipcRenderer.invoke('get-table-indexes', unproxify(params)); - } - - static getKeyUsage (params) { - return ipcRenderer.invoke('get-key-usage', unproxify(params)); - } - - static updateTableCell (params) { - return ipcRenderer.invoke('update-table-cell', unproxify(params)); - } - - static deleteTableRows (params) { - return ipcRenderer.invoke('delete-table-rows', unproxify(params)); - } - - static insertTableRows (params) { - return ipcRenderer.invoke('insert-table-rows', unproxify(params)); - } - - static insertTableFakeRows (params) { - return ipcRenderer.invoke('insert-table-fake-rows', unproxify(params)); - } - - static getForeignList (params) { - return ipcRenderer.invoke('get-foreign-list', unproxify(params)); - } - - static createTable (params) { - return ipcRenderer.invoke('create-table', unproxify(params)); - } - - static alterTable (params) { - return ipcRenderer.invoke('alter-table', unproxify(params)); - } - - static duplicateTable (params) { - return ipcRenderer.invoke('duplicate-table', unproxify(params)); - } - - static truncateTable (params) { - return ipcRenderer.invoke('truncate-table', unproxify(params)); - } - - static dropTable (params) { - return ipcRenderer.invoke('drop-table', unproxify(params)); - } -} diff --git a/src/renderer/ipc-api/Tables.ts b/src/renderer/ipc-api/Tables.ts new file mode 100644 index 00000000..76a19d68 --- /dev/null +++ b/src/renderer/ipc-api/Tables.ts @@ -0,0 +1,108 @@ +import { ipcRenderer } from 'electron'; +import { unproxify } from '../libs/unproxify'; +import { AlterTableParams, CreateTableParams, IpcResponse, TableForeign, TableIndex, TableInfos } from 'common/interfaces/antares'; + +export default class { + static getTableColumns (params: {schema: string; table: string }): Promise { + return ipcRenderer.invoke('get-table-columns', unproxify(params)); + } + + static getTableData (params: { + uid: string; + schema: string; + table: string; + limit: number; + page: number; + sortParams: { + field: string; + dir: 'asc' | 'desc' ; + }; + // eslint-disable-next-line @typescript-eslint/no-explicit-any + where: any; + }): Promise { + return ipcRenderer.invoke('get-table-data', unproxify(params)); + } + + static getTableApproximateCount (params: { uid: string; schema: string; table: string }): Promise> { + return ipcRenderer.invoke('get-table-count', unproxify(params)); + } + + static getTableOptions (params: { uid: string; schema: string; table: string }): Promise> { + return ipcRenderer.invoke('get-table-options', unproxify(params)); + } + + static getTableIndexes (params: { uid: string; schema: string; table: string }): Promise> { + return ipcRenderer.invoke('get-table-indexes', unproxify(params)); + } + + static getKeyUsage (params: { uid: string; schema: string; table: string }): Promise> { + return ipcRenderer.invoke('get-key-usage', unproxify(params)); + } + + static updateTableCell (params: { + uid: string; + schema: string; + table: string; + primary?: string; + id: number | string; + content: number | string | boolean | Date | Blob | null; + type: string; + field: string; + }): Promise { + return ipcRenderer.invoke('update-table-cell', unproxify(params)); + } + + static deleteTableRows (params: { + uid: string; + schema: string; + table: string; + primary?: string; + field: string; + // eslint-disable-next-line @typescript-eslint/no-explicit-any + rows: {[key: string]: any}; + }): Promise { + return ipcRenderer.invoke('delete-table-rows', unproxify(params)); + } + + static insertTableFakeRows (params: { + uid: string; + schema: string; + table: string; + row: {[key: string]: string | number | boolean | Date | Buffer}; + repeat: number; + fields: {[key: string]: string}; + locale: string; + }): Promise { + return ipcRenderer.invoke('insert-table-fake-rows', unproxify(params)); + } + + static getForeignList (params: { + uid: string; + schema: string; + table: string; + column: string; + description: string | false; + }): Promise { + return ipcRenderer.invoke('get-foreign-list', unproxify(params)); + } + + static createTable (params: CreateTableParams): Promise { + return ipcRenderer.invoke('create-table', unproxify(params)); + } + + static alterTable (params: AlterTableParams): Promise { + return ipcRenderer.invoke('alter-table', unproxify(params)); + } + + static duplicateTable (params: { uid: string; schema: string; table: string }): Promise { + return ipcRenderer.invoke('duplicate-table', unproxify(params)); + } + + static truncateTable (params: { uid: string; schema: string; table: string }): Promise { + return ipcRenderer.invoke('truncate-table', unproxify(params)); + } + + static dropTable (params: { uid: string; schema: string; table: string }): Promise { + return ipcRenderer.invoke('drop-table', unproxify(params)); + } +} diff --git a/src/renderer/ipc-api/Triggers.js b/src/renderer/ipc-api/Triggers.js deleted file mode 100644 index f0833650..00000000 --- a/src/renderer/ipc-api/Triggers.js +++ /dev/null @@ -1,25 +0,0 @@ -'use strict'; -import { ipcRenderer } from 'electron'; -import { unproxify } from '../libs/unproxify'; - -export default class { - static getTriggerInformations (params) { - return ipcRenderer.invoke('get-trigger-informations', unproxify(params)); - } - - static dropTrigger (params) { - return ipcRenderer.invoke('drop-trigger', unproxify(params)); - } - - static alterTrigger (params) { - return ipcRenderer.invoke('alter-trigger', unproxify(params)); - } - - static createTrigger (params) { - return ipcRenderer.invoke('create-trigger', unproxify(params)); - } - - static toggleTrigger (params) { - return ipcRenderer.invoke('toggle-trigger', unproxify(params)); - } -} diff --git a/src/renderer/ipc-api/Triggers.ts b/src/renderer/ipc-api/Triggers.ts new file mode 100644 index 00000000..ee42cc58 --- /dev/null +++ b/src/renderer/ipc-api/Triggers.ts @@ -0,0 +1,25 @@ +import { ipcRenderer } from 'electron'; +import { unproxify } from '../libs/unproxify'; +import { AlterTriggerParams, CreateTriggerParams, IpcResponse } from 'common/interfaces/antares'; + +export default class { + static getTriggerInformations (params: { uid: string; schema: string; trigger: string }): Promise { + return ipcRenderer.invoke('get-trigger-informations', unproxify(params)); + } + + static dropTrigger (params: { schema: string; trigger: string }): Promise { + return ipcRenderer.invoke('drop-trigger', unproxify(params)); + } + + static alterTrigger (params: { trigger: AlterTriggerParams & { uid: string }}): Promise { + return ipcRenderer.invoke('alter-trigger', unproxify(params)); + } + + static createTrigger (params: CreateTriggerParams & { uid: string }): Promise { + return ipcRenderer.invoke('create-trigger', unproxify(params)); + } + + static toggleTrigger (params: { uid: string; schema: string; trigger: string }): Promise { + return ipcRenderer.invoke('toggle-trigger', unproxify(params)); + } +} diff --git a/src/renderer/ipc-api/Users.js b/src/renderer/ipc-api/Users.ts similarity index 61% rename from src/renderer/ipc-api/Users.js rename to src/renderer/ipc-api/Users.ts index 8de46f33..6146436e 100644 --- a/src/renderer/ipc-api/Users.js +++ b/src/renderer/ipc-api/Users.ts @@ -1,9 +1,9 @@ -'use strict'; import { ipcRenderer } from 'electron'; import { unproxify } from '../libs/unproxify'; +import { IpcResponse } from 'common/interfaces/antares'; export default class { - static getUsers (params) { + static getUsers (params: string): Promise { return ipcRenderer.invoke('get-users', unproxify(params)); } } diff --git a/src/renderer/ipc-api/Views.js b/src/renderer/ipc-api/Views.js deleted file mode 100644 index 3cab89ae..00000000 --- a/src/renderer/ipc-api/Views.js +++ /dev/null @@ -1,21 +0,0 @@ -'use strict'; -import { ipcRenderer } from 'electron'; -import { unproxify } from '../libs/unproxify'; - -export default class { - static getViewInformations (params) { - return ipcRenderer.invoke('get-view-informations', unproxify(params)); - } - - static dropView (params) { - return ipcRenderer.invoke('drop-view', unproxify(params)); - } - - static alterView (params) { - return ipcRenderer.invoke('alter-view', unproxify(params)); - } - - static createView (params) { - return ipcRenderer.invoke('create-view', unproxify(params)); - } -} diff --git a/src/renderer/ipc-api/Views.ts b/src/renderer/ipc-api/Views.ts new file mode 100644 index 00000000..5e674158 --- /dev/null +++ b/src/renderer/ipc-api/Views.ts @@ -0,0 +1,21 @@ +import { ipcRenderer } from 'electron'; +import { unproxify } from '../libs/unproxify'; +import { AlterViewParams, CreateViewParams, IpcResponse } from 'common/interfaces/antares'; + +export default class { + static getViewInformations (params: { uid: string; schema: string; view: string }): Promise { + return ipcRenderer.invoke('get-view-informations', unproxify(params)); + } + + static dropView (params: { uid: string; schema: string; view: string }): Promise { + return ipcRenderer.invoke('drop-view', unproxify(params)); + } + + static alterView (params: { view: AlterViewParams & { uid: string }}): Promise { + return ipcRenderer.invoke('alter-view', unproxify(params)); + } + + static createView (params: CreateViewParams & { uid: string }): Promise { + return ipcRenderer.invoke('create-view', unproxify(params)); + } +} diff --git a/src/renderer/scss/main.scss b/src/renderer/scss/main.scss index 6aab9fdf..bd5bd231 100644 --- a/src/renderer/scss/main.scss +++ b/src/renderer/scss/main.scss @@ -300,6 +300,7 @@ option:checked { &.select { &.select--open { border-color: $primary-color !important; + @include control-shadow(); } } @@ -307,6 +308,7 @@ option:checked { .select__list { margin: 0; + li { margin: 0; padding: 0.3rem 0.8rem; @@ -322,7 +324,7 @@ option:checked { z-index: 401 !important; border: 1px solid transparent; border-radius: $border-radius; - box-shadow: 0px 8px 17px 0px rgba(0, 0, 0, 0.2), 0px 6px 20px 0px rgba(0, 0, 0, 0.19); + box-shadow: 0 8px 17px 0 rgba(0, 0, 0, 0.2), 0 6px 20px 0 rgba(0, 0, 0, 0.19); } .select__option--selected { diff --git a/src/renderer/scss/themes/dark-theme.scss b/src/renderer/scss/themes/dark-theme.scss index 7416e21e..e59f242e 100644 --- a/src/renderer/scss/themes/dark-theme.scss +++ b/src/renderer/scss/themes/dark-theme.scss @@ -252,7 +252,9 @@ } .bg-checkered { - background-image: linear-gradient(to right, rgba(192, 192, 192, 0.75), rgba(192, 192, 192, 0.75)), linear-gradient(to right, black 50%, white 50%), + background-image: + linear-gradient(to right, rgba(192, 192, 192, 0.75), rgba(192, 192, 192, 0.75)), + linear-gradient(to right, black 50%, white 50%), linear-gradient(to bottom, black 50%, white 50%); background-blend-mode: normal, difference, normal; background-size: 2em 2em; diff --git a/src/renderer/stores/workspaces.ts b/src/renderer/stores/workspaces.ts index 696caf44..90a2dcf5 100644 --- a/src/renderer/stores/workspaces.ts +++ b/src/renderer/stores/workspaces.ts @@ -133,7 +133,7 @@ export const useWorkspacesStore = defineStore('workspaces', { else this.selectedWorkspace = uid; }, - async connectWorkspace (connection: ConnectionParams) { + async connectWorkspace (connection: ConnectionParams & { pgConnString: string }) { this.workspaces = (this.workspaces as Workspace[]).map(workspace => workspace.uid === connection.uid ? { ...workspace,