refactor: ts on ipc api

This commit is contained in:
Fabio Di Stasio 2022-06-05 17:57:44 +02:00
parent 7fc01227e7
commit be70b5be7f
36 changed files with 510 additions and 476 deletions

View File

@ -1,4 +1,5 @@
node_modules
assets
out
dist
dist
build

View File

@ -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"
},

View File

@ -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<T = any> {
status: 'success' | 'error';
response?: T;
}
/**
* Pasameters needed to create a new Antares connection to a database
*/

View File

@ -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);
});

View File

@ -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}[] = [];

View File

@ -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;
};
});
}

View File

@ -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;
}
}
}
</style>

View File

@ -380,48 +380,49 @@ export default defineComponent({
<style lang="scss" scoped>
.select {
display: block;
display: block;
&:focus, &--open {
z-index: 10;
}
&:focus,
&--open {
z-index: 10;
}
&__search-input {
appearance: none;
border: none;
background: transparent;
outline: none;
color: currentColor;
max-width: 100%;
width: 100%;
}
&__search-input {
appearance: none;
border: none;
background: transparent;
outline: none;
color: currentColor;
max-width: 100%;
width: 100%;
}
&__list-wrapper {
cursor: pointer;
position: fixed;
display: block;
z-index: 5;
-webkit-overflow-scrolling: touch;
max-height: 240px;
overflow: auto;
left: 0;
top: 40px;
}
&__list-wrapper {
cursor: pointer;
position: fixed;
display: block;
z-index: 5;
-webkit-overflow-scrolling: touch;
max-height: 240px;
overflow: auto;
left: 0;
top: 40px;
}
&__list {
list-style: none;
}
&__list {
list-style: none;
}
&__option {
&--disabled {
opacity: 0.6;
cursor: not-allowed;
}
}
&--disabled {
&__option {
&--disabled {
opacity: 0.6;
cursor: not-allowed;
}
}
}
&--disabled {
opacity: 0.6;
cursor: not-allowed;
}
}
</style>

View File

@ -8,7 +8,7 @@
dropdown-class="select-sm"
dropdown-container=".workspace-query-results > .vscroll"
@change="onChange"
@blur="$emit('blur')"
@blur="emit('blur')"
/>
</template>
@ -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

View File

@ -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%;
}
</style>

View File

@ -166,24 +166,23 @@ defineExpose({ startImport });
<style lang="scss" scoped>
.modal {
.modal-container {
max-width: 800px;
}
.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%;
}
</style>

View File

@ -79,7 +79,7 @@
/>
</div>
<div class="col-4 col-sm-12 px-2 p-vcentered">
<small class="d-block" style="line-height:1.1; font-size:70%;">
<small class="d-block" style="line-height: 1.1; font-size: 70%;">
{{ t('message.missingOrIncompleteTranslation') }}<br>
<a class="text-bold c-hand" @click="openOutside('https://github.com/antares-sql/antares/wiki/Translate-Antares')">{{ t('message.findOutHowToContribute') }}</a>
</small>

View File

@ -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

View File

@ -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 });

View File

@ -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');
}
}

View File

@ -0,0 +1,12 @@
import { ipcRenderer, OpenDialogOptions, OpenDialogReturnValue } from 'electron';
import { unproxify } from '../libs/unproxify';
export default class {
static showOpenDialog (options: OpenDialogOptions): Promise<OpenDialogReturnValue> {
return ipcRenderer.invoke('show-open-dialog', unproxify(options));
}
static getDownloadPathDirectory (): Promise<string> {
return ipcRenderer.invoke('get-download-dir-path');
}
}

View File

@ -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);
}
}

View File

@ -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<IpcResponse> {
const newParams = connStringConstruct(params) as ConnectionParams;
return ipcRenderer.invoke('test-connection', unproxify(newParams));
}
static connect (params: ConnectionParams & { pgConnString: string }): Promise<IpcResponse> {
const newParams = connStringConstruct(params) as ConnectionParams;
return ipcRenderer.invoke('connect', unproxify(newParams));
}
static checkConnection (uid: string): Promise<boolean> {
return ipcRenderer.invoke('check-connection', uid);
}
static disconnect (uid: string): Promise<void> {
return ipcRenderer.invoke('disconnect', uid);
}
}

View File

@ -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));
}
}

View File

@ -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<IpcResponse<FunctionInfos>> {
return ipcRenderer.invoke('get-function-informations', unproxify(params));
}
static dropFunction (params: { uid: string; schema: string; func: string}): Promise<IpcResponse> {
return ipcRenderer.invoke('drop-function', unproxify(params));
}
static alterFunction (params: { func: AlterFunctionParams }): Promise<IpcResponse> {
return ipcRenderer.invoke('alter-function', unproxify(params));
}
static alterTriggerFunction (params: {func: CreateFunctionParams & { uid: string }}): Promise<IpcResponse> {
return ipcRenderer.invoke('alter-trigger-function', unproxify(params));
}
static createFunction (params: CreateFunctionParams & { uid: string }): Promise<IpcResponse> {
return ipcRenderer.invoke('create-function', unproxify(params));
}
static createTriggerFunction (params: CreateFunctionParams & { uid: string }): Promise<IpcResponse> {
return ipcRenderer.invoke('create-trigger-function', unproxify(params));
}
}

View File

@ -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));
}
}

View File

@ -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<IpcResponse<RoutineInfos>> {
return ipcRenderer.invoke('get-routine-informations', unproxify(params));
}
static dropRoutine (params: { uid: string; schema: string; routine: string}): Promise<IpcResponse> {
return ipcRenderer.invoke('drop-routine', unproxify(params));
}
static alterRoutine (params: { routine: AlterRoutineParams & { uid: string } }): Promise<IpcResponse> {
return ipcRenderer.invoke('alter-routine', unproxify(params));
}
static createRoutine (params: { routine: CreateRoutineParams & { uid: string } }): Promise<IpcResponse> {
return ipcRenderer.invoke('create-routine', unproxify(params));
}
}

View File

@ -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));
}
}

View File

@ -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<IpcResponse<EventInfos>> {
return ipcRenderer.invoke('get-scheduler-informations', unproxify(params));
}
static dropScheduler (params: { uid: string; schema: string; scheduler: string}): Promise<IpcResponse> {
return ipcRenderer.invoke('drop-scheduler', unproxify(params));
}
static alterScheduler (params: { scheduler: AlterEventParams & { uid: string } }): Promise<IpcResponse> {
return ipcRenderer.invoke('alter-scheduler', unproxify(params));
}
static createScheduler (params: CreateEventParams & { uid: string }): Promise<IpcResponse> {
return ipcRenderer.invoke('create-scheduler', unproxify(params));
}
static toggleScheduler (params: { uid: string; schema: string; scheduler: string}): Promise<IpcResponse> {
return ipcRenderer.invoke('toggle-scheduler', unproxify(params));
}
}

View File

@ -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');
}
}

View File

@ -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<IpcResponse> {
return ipcRenderer.invoke('create-schema', unproxify(params));
}
static updateSchema (params: { uid: string; name: string; collation?: string }): Promise<IpcResponse> {
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<IpcResponse> {
return ipcRenderer.invoke('delete-schema', unproxify(params));
}
static getStructure (params: { uid: string; schemas: Set<string> }): Promise<IpcResponse/* <{
name: string;
size: number;
tables: TableInfos[];
functions: RoutineInfos[];
procedures: RoutineInfos[];
triggers: TriggerInfos[];
schedulers: EventInfos[];
}[]> */> {
return ipcRenderer.invoke('get-structure', unproxify(params, false));
}
static getCollations (uid: string): Promise<IpcResponse/* <{
charset: string;
collation: string;
compiled: boolean;
default: boolean;
id: number;
sortLen: number;
}[]> */> {
return ipcRenderer.invoke('get-collations', uid);
}
static getVariables (uid: string): Promise<IpcResponse/* <{ name: string; value: string }[]> */> {
return ipcRenderer.invoke('get-variables', uid);
}
static getEngines (uid: string): Promise<IpcResponse/* <{
name: string;
support: string;
comment: string;
transactions: string;
xa: string;
savepoints: string;
isDefault: boolean;
}[]> */> {
return ipcRenderer.invoke('get-engines', uid);
}
static getVersion (uid: string): Promise<IpcResponse/* <{
number: string;
name: string;
arch: string;
os: string;
}> */> {
return ipcRenderer.invoke('get-version', uid);
}
static getProcesses (uid: string): Promise<IpcResponse/* <{
id: number;
user: string;
host: string;
db: string;
command: string;
time: number;
state: string;
info: string;
}[]> */> {
return ipcRenderer.invoke('get-processes', uid);
}
static killProcess (params: { uid: string; pid: string }): Promise<IpcResponse> {
return ipcRenderer.invoke('kill-process', unproxify(params));
}
static killTabQuery (params: { uid: string; tabUid: string }): Promise<IpcResponse> {
return ipcRenderer.invoke('kill-tab-query', unproxify(params));
}
static commitTab (params: { uid: string; tabUid: string }): Promise<IpcResponse> {
return ipcRenderer.invoke('commit-tab', unproxify(params));
}
static rollbackTab (params: { uid: string; tabUid: string }): Promise<IpcResponse> {
return ipcRenderer.invoke('rollback-tab', unproxify(params));
}
static destroyConnectionToCommit (params: { uid: string; tabUid: string }): Promise<IpcResponse> {
return ipcRenderer.invoke('destroy-connection-to-commit', unproxify(params));
}
static useSchema (params: { uid: string; schema: string }): Promise<IpcResponse> {
return ipcRenderer.invoke('use-schema', unproxify(params));
}
static rawQuery (params: { uid: string; query: string; schema: string; tabUid: string; autocommit?: boolean }): Promise<IpcResponse/* <QueryResult> */> {
return ipcRenderer.invoke('raw-query', unproxify(params));
}
static export (params: { uid: string; type: string; tables: string; options: ExportOptions }): Promise<IpcResponse> {
return ipcRenderer.invoke('export', unproxify(params));
}
static abortExport (): Promise<IpcResponse> {
return ipcRenderer.invoke('abort-export');
}
static import (params: ImportOptions): Promise<IpcResponse> {
return ipcRenderer.invoke('import-sql', unproxify(params));
}
static abortImport (): Promise<IpcResponse> {
return ipcRenderer.invoke('abort-import-sql');
}
}

View File

@ -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));
}
}

View File

@ -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<IpcResponse> {
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<IpcResponse> {
return ipcRenderer.invoke('get-table-data', unproxify(params));
}
static getTableApproximateCount (params: { uid: string; schema: string; table: string }): Promise<IpcResponse<number>> {
return ipcRenderer.invoke('get-table-count', unproxify(params));
}
static getTableOptions (params: { uid: string; schema: string; table: string }): Promise<IpcResponse<TableInfos>> {
return ipcRenderer.invoke('get-table-options', unproxify(params));
}
static getTableIndexes (params: { uid: string; schema: string; table: string }): Promise<IpcResponse<TableIndex[]>> {
return ipcRenderer.invoke('get-table-indexes', unproxify(params));
}
static getKeyUsage (params: { uid: string; schema: string; table: string }): Promise<IpcResponse<TableForeign[]>> {
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<IpcResponse> {
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<IpcResponse> {
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<IpcResponse> {
return ipcRenderer.invoke('insert-table-fake-rows', unproxify(params));
}
static getForeignList (params: {
uid: string;
schema: string;
table: string;
column: string;
description: string | false;
}): Promise<IpcResponse> {
return ipcRenderer.invoke('get-foreign-list', unproxify(params));
}
static createTable (params: CreateTableParams): Promise<IpcResponse> {
return ipcRenderer.invoke('create-table', unproxify(params));
}
static alterTable (params: AlterTableParams): Promise<IpcResponse> {
return ipcRenderer.invoke('alter-table', unproxify(params));
}
static duplicateTable (params: { uid: string; schema: string; table: string }): Promise<IpcResponse> {
return ipcRenderer.invoke('duplicate-table', unproxify(params));
}
static truncateTable (params: { uid: string; schema: string; table: string }): Promise<IpcResponse> {
return ipcRenderer.invoke('truncate-table', unproxify(params));
}
static dropTable (params: { uid: string; schema: string; table: string }): Promise<IpcResponse> {
return ipcRenderer.invoke('drop-table', unproxify(params));
}
}

View File

@ -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));
}
}

View File

@ -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<IpcResponse> {
return ipcRenderer.invoke('get-trigger-informations', unproxify(params));
}
static dropTrigger (params: { schema: string; trigger: string }): Promise<IpcResponse> {
return ipcRenderer.invoke('drop-trigger', unproxify(params));
}
static alterTrigger (params: { trigger: AlterTriggerParams & { uid: string }}): Promise<IpcResponse> {
return ipcRenderer.invoke('alter-trigger', unproxify(params));
}
static createTrigger (params: CreateTriggerParams & { uid: string }): Promise<IpcResponse> {
return ipcRenderer.invoke('create-trigger', unproxify(params));
}
static toggleTrigger (params: { uid: string; schema: string; trigger: string }): Promise<IpcResponse> {
return ipcRenderer.invoke('toggle-trigger', unproxify(params));
}
}

View File

@ -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<IpcResponse> {
return ipcRenderer.invoke('get-users', unproxify(params));
}
}

View File

@ -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));
}
}

View File

@ -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<IpcResponse> {
return ipcRenderer.invoke('get-view-informations', unproxify(params));
}
static dropView (params: { uid: string; schema: string; view: string }): Promise<IpcResponse> {
return ipcRenderer.invoke('drop-view', unproxify(params));
}
static alterView (params: { view: AlterViewParams & { uid: string }}): Promise<IpcResponse> {
return ipcRenderer.invoke('alter-view', unproxify(params));
}
static createView (params: CreateViewParams & { uid: string }): Promise<IpcResponse> {
return ipcRenderer.invoke('create-view', unproxify(params));
}
}

View File

@ -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 {

View File

@ -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;

View File

@ -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,