mirror of
https://github.com/Fabio286/antares.git
synced 2025-06-05 21:59:22 +02:00
Compare commits
34 Commits
Author | SHA1 | Date | |
---|---|---|---|
6bfc229b77 | |||
d31b051f4b | |||
95b60df8fc | |||
ed5189fdc1 | |||
265ed66d25 | |||
09c07acd5c | |||
3c5a69adc9 | |||
0203f69e95 | |||
9a2498862c | |||
|
3a26d4f509 | ||
ce08cbd8b5 | |||
|
d91ffcccca | ||
6115eb9409 | |||
3fd26a0523 | |||
e217d5181b | |||
dcf368b350 | |||
21e3e79ddf | |||
2918c3cb92 | |||
3ad190b18c | |||
d5b2bde2ea | |||
a42348ef5c | |||
8b93c49778 | |||
0842e00098 | |||
6cef02bebb | |||
|
334c7a31d2 | ||
bc82289d54 | |||
c9fa941578 | |||
4048df3c7b | |||
198368605b | |||
8f0ac26b69 | |||
b35fc5b78b | |||
622b519cbb | |||
71e2c911ae | |||
756d49b259 |
2
.gitignore
vendored
2
.gitignore
vendored
@@ -4,6 +4,6 @@ node_modules/
|
|||||||
thumbs.db
|
thumbs.db
|
||||||
.idea/
|
.idea/
|
||||||
.vscode
|
.vscode
|
||||||
TODO.md
|
NOTES.md
|
||||||
*.txt
|
*.txt
|
||||||
package-lock.json
|
package-lock.json
|
49
CHANGELOG.md
49
CHANGELOG.md
@@ -2,6 +2,55 @@
|
|||||||
|
|
||||||
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.3.5](https://github.com/Fabio286/antares/compare/v0.3.4...v0.3.5) (2021-09-13)
|
||||||
|
|
||||||
|
|
||||||
|
### Bug Fixes
|
||||||
|
|
||||||
|
* **MySQL:** connections stuck at startup if 5 or more tabs are restored ([95b60df](https://github.com/Fabio286/antares/commit/95b60df8fc634b96a4c2c5c48dc6b10848888978))
|
||||||
|
|
||||||
|
### [0.3.4](https://github.com/Fabio286/antares/compare/v0.3.3...v0.3.4) (2021-09-12)
|
||||||
|
|
||||||
|
|
||||||
|
### Features
|
||||||
|
|
||||||
|
* new create function tabs ([0203f69](https://github.com/Fabio286/antares/commit/0203f69e95093d25a7ef3e66df1c70f76edcedf2))
|
||||||
|
* new create routine tabs ([3fd26a0](https://github.com/Fabio286/antares/commit/3fd26a05238368ae375197c79d42162a5910bb07))
|
||||||
|
* new create scheduler tabs ([3c5a69a](https://github.com/Fabio286/antares/commit/3c5a69adc9cecdc4b8f46097676005f2a60f06cf))
|
||||||
|
* new create trigger function tabs ([09c07ac](https://github.com/Fabio286/antares/commit/09c07acd5c2a6ed2b75640dbb83e782ed432bc30))
|
||||||
|
* new create trigger tabs ([e217d51](https://github.com/Fabio286/antares/commit/e217d5181b37ec6304151120b4a2aba9455c6a84))
|
||||||
|
* start search when typing with focus on the left bar ([265ed66](https://github.com/Fabio286/antares/commit/265ed66d25d35be99ed0a6b1668dab9f246ed71e))
|
||||||
|
|
||||||
|
|
||||||
|
### Bug Fixes
|
||||||
|
|
||||||
|
* **UI:** context menu of tables cut if close to bottom edge ([21e3e79](https://github.com/Fabio286/antares/commit/21e3e79ddf9e292bcfc5881b8fa76a1dc58b207c))
|
||||||
|
|
||||||
|
### [0.3.3](https://github.com/Fabio286/antares/compare/v0.3.2...v0.3.3) (2021-08-22)
|
||||||
|
|
||||||
|
|
||||||
|
### Features
|
||||||
|
|
||||||
|
* new create table tabs ([c9fa941](https://github.com/Fabio286/antares/commit/c9fa9415787c3953043db5876a99b3664c69c071))
|
||||||
|
* new create view tabs ([8b93c49](https://github.com/Fabio286/antares/commit/8b93c497784ea431f9747c5afb53f6ef075ea9d6))
|
||||||
|
* new table empty state ([0842e00](https://github.com/Fabio286/antares/commit/0842e00098ba420412937aa52276ee33bda53693))
|
||||||
|
|
||||||
|
|
||||||
|
### Bug Fixes
|
||||||
|
|
||||||
|
* **MySQL:** editing a view causes error for missing database in some conditions ([4048df3](https://github.com/Fabio286/antares/commit/4048df3c7bc2d42a60f7a57c9a4b8b5b445fcd43))
|
||||||
|
* table options not loaded on restored setting tabs at startup ([622b519](https://github.com/Fabio286/antares/commit/622b519cbb5fbe4e38a4baffb8eab169b21eed21))
|
||||||
|
* **UI:** multiple temp tabs opened switching to tables from other elements ([b35fc5b](https://github.com/Fabio286/antares/commit/b35fc5b78bdbeff1422ef088441b17c8b0df663c))
|
||||||
|
* **UI:** no round borders on left of file upload inputs ([d5b2bde](https://github.com/Fabio286/antares/commit/d5b2bde2eaf8ff3e14f49cc26acdcb201b4cb15c))
|
||||||
|
|
||||||
|
|
||||||
|
### Improvements
|
||||||
|
|
||||||
|
* **UI:** element options in setting tabs accessible directly ([71e2c91](https://github.com/Fabio286/antares/commit/71e2c911ae23e86543b2af1fa885981ff271777d))
|
||||||
|
* **UI:** improved view setting tab ([1983686](https://github.com/Fabio286/antares/commit/198368605b084bd58fd6f7ca0b19895ba23a45e6))
|
||||||
|
* **UI:** primary app color on selected text backgrouns ([756d49b](https://github.com/Fabio286/antares/commit/756d49b2596dea58376c6afa8e0bad0cd62b146c))
|
||||||
|
* **UI:** visual improvements of tables ([bc82289](https://github.com/Fabio286/antares/commit/bc82289d54550a93300fe66d7a660aa70db2fd23))
|
||||||
|
|
||||||
### [0.3.2](https://github.com/Fabio286/antares/compare/v0.3.1...v0.3.2) (2021-08-06)
|
### [0.3.2](https://github.com/Fabio286/antares/compare/v0.3.1...v0.3.2) (2021-08-06)
|
||||||
|
|
||||||
|
|
||||||
|
@@ -4,7 +4,7 @@
|
|||||||
|
|
||||||
# Antares SQL Client
|
# Antares SQL Client
|
||||||
|
|
||||||
 [](https://actions-badge.atrox.dev/fabio286/antares/goto)   [](https://snapcraft.io/antares) [](https://snapcraft.io/antares) [](https://twitter.com/AntaresSQL) [](https://www.treedom.net/en/user/fabio-di-stasio/event/antares-for-the-planet)
|
  [](https://actions-badge.atrox.dev/fabio286/antares/goto) [](https://snapcraft.io/antares) [](https://snapcraft.io/antares) [](https://twitter.com/AntaresSQL) [](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.
|
||||||
|
18
package.json
18
package.json
@@ -1,7 +1,7 @@
|
|||||||
{
|
{
|
||||||
"name": "antares",
|
"name": "antares",
|
||||||
"productName": "Antares",
|
"productName": "Antares",
|
||||||
"version": "0.3.2",
|
"version": "0.3.5",
|
||||||
"description": "A cross-platform easy to use SQL client.",
|
"description": "A cross-platform easy to use SQL client.",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"repository": "https://github.com/Fabio286/antares.git",
|
"repository": "https://github.com/Fabio286/antares.git",
|
||||||
@@ -88,18 +88,18 @@
|
|||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@electron/remote": "^1.2.1",
|
"@electron/remote": "^1.2.1",
|
||||||
"@mdi/font": "^5.9.55",
|
"@mdi/font": "^6.1.95",
|
||||||
"ace-builds": "^1.4.12",
|
"ace-builds": "^1.4.12",
|
||||||
"electron-log": "^4.4.1",
|
"electron-log": "^4.4.1",
|
||||||
"electron-store": "^8.0.0",
|
"electron-store": "^8.0.0",
|
||||||
"electron-updater": "^4.3.9",
|
"electron-updater": "^4.3.9",
|
||||||
"faker": "^5.5.3",
|
"faker": "^5.5.3",
|
||||||
"marked": "^2.1.1",
|
"marked": "^3.0.3",
|
||||||
"moment": "^2.29.1",
|
"moment": "^2.29.1",
|
||||||
"mysql2": "^2.3.0",
|
"mysql2": "^2.3.0",
|
||||||
"pg": "^8.7.1",
|
"pg": "^8.7.1",
|
||||||
"pgsql-ast-parser": "^7.2.1",
|
"pgsql-ast-parser": "^7.2.1",
|
||||||
"source-map-support": "^0.5.16",
|
"source-map-support": "^0.5.20",
|
||||||
"spectre.css": "^0.5.9",
|
"spectre.css": "^0.5.9",
|
||||||
"sql-formatter": "^4.0.2",
|
"sql-formatter": "^4.0.2",
|
||||||
"ssh2-promise": "^0.2.0",
|
"ssh2-promise": "^0.2.0",
|
||||||
@@ -109,20 +109,20 @@
|
|||||||
"vuex": "^3.6.2"
|
"vuex": "^3.6.2"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@babel/eslint-parser": "^7.15.0",
|
"@babel/eslint-parser": "^7.15.4",
|
||||||
"cross-env": "^7.0.2",
|
"cross-env": "^7.0.2",
|
||||||
"electron": "^13.1.8",
|
"electron": "^14.0.0",
|
||||||
"electron-builder": "^22.11.7",
|
"electron-builder": "^22.11.7",
|
||||||
"electron-devtools-installer": "^3.2.0",
|
"electron-devtools-installer": "^3.2.0",
|
||||||
"electron-webpack": "^2.8.2",
|
"electron-webpack": "^2.8.2",
|
||||||
"electron-webpack-vue": "^2.4.0",
|
"electron-webpack-vue": "^2.4.0",
|
||||||
"eslint": "^7.32.0",
|
"eslint": "^7.32.0",
|
||||||
"eslint-config-standard": "^16.0.3",
|
"eslint-config-standard": "^16.0.3",
|
||||||
"eslint-plugin-import": "^2.23.4",
|
"eslint-plugin-import": "^2.24.2",
|
||||||
"eslint-plugin-node": "^11.1.0",
|
"eslint-plugin-node": "^11.1.0",
|
||||||
"eslint-plugin-promise": "^5.1.0",
|
"eslint-plugin-promise": "^5.1.0",
|
||||||
"eslint-plugin-vue": "^7.15.1",
|
"eslint-plugin-vue": "^7.17.0",
|
||||||
"sass": "^1.37.5",
|
"sass": "^1.39.2",
|
||||||
"sass-loader": "^10.2.0",
|
"sass-loader": "^10.2.0",
|
||||||
"standard-version": "^9.3.1",
|
"standard-version": "^9.3.1",
|
||||||
"stylelint": "^13.13.1",
|
"stylelint": "^13.13.1",
|
||||||
|
@@ -44,6 +44,7 @@ module.exports = {
|
|||||||
unsigned: false,
|
unsigned: false,
|
||||||
nullable: false,
|
nullable: false,
|
||||||
zerofill: false,
|
zerofill: false,
|
||||||
|
tableOptions: false,
|
||||||
autoIncrement: false,
|
autoIncrement: false,
|
||||||
comment: false,
|
comment: false,
|
||||||
collation: false,
|
collation: false,
|
||||||
|
@@ -40,6 +40,7 @@ module.exports = {
|
|||||||
unsigned: true,
|
unsigned: true,
|
||||||
nullable: true,
|
nullable: true,
|
||||||
zerofill: true,
|
zerofill: true,
|
||||||
|
tableOptions: true,
|
||||||
autoIncrement: true,
|
autoIncrement: true,
|
||||||
comment: true,
|
comment: true,
|
||||||
collation: true,
|
collation: true,
|
||||||
|
@@ -48,6 +48,16 @@ export default (connections) => {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
ipcMain.handle('get-table-options', async (event, params) => {
|
||||||
|
try {
|
||||||
|
const result = await connections[params.uid].getTableOptions(params);
|
||||||
|
return { status: 'success', response: result };
|
||||||
|
}
|
||||||
|
catch (err) {
|
||||||
|
return { status: 'error', response: err.toString() };
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
ipcMain.handle('get-table-indexes', async (event, params) => {
|
ipcMain.handle('get-table-indexes', async (event, params) => {
|
||||||
try {
|
try {
|
||||||
const result = await connections[params.uid].getTableIndexes(params);
|
const result = await connections[params.uid].getTableIndexes(params);
|
||||||
|
@@ -9,7 +9,7 @@ autoUpdater.allowPrerelease = persistentStore.get('allow_prerelease', true);
|
|||||||
export default () => {
|
export default () => {
|
||||||
ipcMain.on('check-for-updates', event => {
|
ipcMain.on('check-for-updates', event => {
|
||||||
mainWindow = event;
|
mainWindow = event;
|
||||||
if (process.windowsStore)
|
if (process.windowsStore || (process.platform === 'linux' && !process.env.APPIMAGE))
|
||||||
mainWindow.reply('no-auto-update');
|
mainWindow.reply('no-auto-update');
|
||||||
else {
|
else {
|
||||||
autoUpdater.checkForUpdatesAndNotify().catch(() => {
|
autoUpdater.checkForUpdatesAndNotify().catch(() => {
|
||||||
|
@@ -2,6 +2,12 @@
|
|||||||
import { MySQLClient } from './clients/MySQLClient';
|
import { MySQLClient } from './clients/MySQLClient';
|
||||||
import { PostgreSQLClient } from './clients/PostgreSQLClient';
|
import { PostgreSQLClient } from './clients/PostgreSQLClient';
|
||||||
|
|
||||||
|
const queryLogger = sql => {
|
||||||
|
// Remove comments, newlines and multiple spaces
|
||||||
|
const escapedSql = sql.replace(/(\/\*(.|[\r\n])*?\*\/)|(--(.*|[\r\n]))/gm, '').replace(/\s\s+/g, ' ');
|
||||||
|
console.log(escapedSql);
|
||||||
|
};
|
||||||
|
|
||||||
export class ClientsFactory {
|
export class ClientsFactory {
|
||||||
/**
|
/**
|
||||||
* Returns a database connection based on received args.
|
* Returns a database connection based on received args.
|
||||||
@@ -23,6 +29,8 @@ export class ClientsFactory {
|
|||||||
* @memberof ClientsFactory
|
* @memberof ClientsFactory
|
||||||
*/
|
*/
|
||||||
static getConnection (args) {
|
static getConnection (args) {
|
||||||
|
args.logger = queryLogger;
|
||||||
|
|
||||||
switch (args.client) {
|
switch (args.client) {
|
||||||
case 'mysql':
|
case 'mysql':
|
||||||
case 'maria':
|
case 'maria':
|
||||||
|
@@ -437,6 +437,43 @@ export class MySQLClient extends AntaresCore {
|
|||||||
return rows.length ? rows[0].count : 0;
|
return rows.length ? rows[0].count : 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param {Object} params
|
||||||
|
* @param {String} params.schema
|
||||||
|
* @param {String} params.table
|
||||||
|
* @returns {Object} table options
|
||||||
|
* @memberof MySQLClient
|
||||||
|
*/
|
||||||
|
async getTableOptions ({ schema, table }) {
|
||||||
|
const { rows } = await this.raw(`SHOW TABLE STATUS FROM \`${schema}\` WHERE Name = '${table}'`);
|
||||||
|
|
||||||
|
if (rows.length) {
|
||||||
|
let tableType;
|
||||||
|
switch (rows[0].Comment) {
|
||||||
|
case 'VIEW':
|
||||||
|
tableType = 'view';
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
tableType = 'table';
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
return {
|
||||||
|
name: rows[0].Name,
|
||||||
|
type: tableType,
|
||||||
|
rows: rows[0].Rows,
|
||||||
|
created: rows[0].Create_time,
|
||||||
|
updated: rows[0].Update_time,
|
||||||
|
engine: rows[0].Engine,
|
||||||
|
comment: rows[0].Comment,
|
||||||
|
size: rows[0].Data_length + rows[0].Index_length,
|
||||||
|
autoIncrement: rows[0].Auto_increment,
|
||||||
|
collation: rows[0].Collation
|
||||||
|
};
|
||||||
|
};
|
||||||
|
return {};
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param {Object} params
|
* @param {Object} params
|
||||||
* @param {String} params.schema
|
* @param {String} params.schema
|
||||||
@@ -598,7 +635,12 @@ export class MySQLClient extends AntaresCore {
|
|||||||
*/
|
*/
|
||||||
async alterView (params) {
|
async alterView (params) {
|
||||||
const { view } = params;
|
const { view } = params;
|
||||||
let sql = `ALTER ALGORITHM = ${view.algorithm}${view.definer ? ` DEFINER=${view.definer}` : ''} SQL SECURITY ${view.security} VIEW \`${view.schema}\`.\`${view.oldName}\` AS ${view.sql} ${view.updateOption ? `WITH ${view.updateOption} CHECK OPTION` : ''}`;
|
let sql = `
|
||||||
|
USE \`${view.schema}\`;
|
||||||
|
ALTER ALGORITHM = ${view.algorithm}${view.definer ? ` DEFINER=${view.definer}` : ''}
|
||||||
|
SQL SECURITY ${view.security}
|
||||||
|
VIEW \`${view.schema}\`.\`${view.oldName}\` AS ${view.sql} ${view.updateOption ? `WITH ${view.updateOption} CHECK OPTION` : ''}
|
||||||
|
`;
|
||||||
|
|
||||||
if (view.name !== view.oldName)
|
if (view.name !== view.oldName)
|
||||||
sql += `; RENAME TABLE \`${view.schema}\`.\`${view.oldName}\` TO \`${view.schema}\`.\`${view.name}\``;
|
sql += `; RENAME TABLE \`${view.schema}\`.\`${view.oldName}\` TO \`${view.schema}\`.\`${view.name}\``;
|
||||||
@@ -913,10 +955,12 @@ export class MySQLClient extends AntaresCore {
|
|||||||
* @memberof MySQLClient
|
* @memberof MySQLClient
|
||||||
*/
|
*/
|
||||||
async createFunction (params) {
|
async createFunction (params) {
|
||||||
const parameters = params.parameters.reduce((acc, curr) => {
|
const parameters = 'parameters' in params
|
||||||
acc.push(`\`${curr.name}\` ${curr.type}${curr.length ? `(${curr.length})` : ''}`);
|
? params.parameters.reduce((acc, curr) => {
|
||||||
return acc;
|
acc.push(`\`${curr.name}\` ${curr.type}${curr.length ? `(${curr.length})` : ''}`);
|
||||||
}, []).join(',');
|
return acc;
|
||||||
|
}, []).join(',')
|
||||||
|
: '';
|
||||||
|
|
||||||
const body = params.returns ? params.sql : 'BEGIN\n RETURN 0;\nEND';
|
const body = params.returns ? params.sql : 'BEGIN\n RETURN 0;\nEND';
|
||||||
|
|
||||||
@@ -1139,7 +1183,57 @@ export class MySQLClient extends AntaresCore {
|
|||||||
* @memberof MySQLClient
|
* @memberof MySQLClient
|
||||||
*/
|
*/
|
||||||
async createTable (params) {
|
async createTable (params) {
|
||||||
const sql = `CREATE TABLE \`${params.schema}\`.\`${params.name}\` (\`${params.name}_ID\` INT NULL) COMMENT='${params.comment}', COLLATE='${params.collation}', ENGINE=${params.engine}`;
|
const {
|
||||||
|
schema,
|
||||||
|
fields,
|
||||||
|
foreigns,
|
||||||
|
indexes,
|
||||||
|
options
|
||||||
|
} = params;
|
||||||
|
const newColumns = [];
|
||||||
|
const newIndexes = [];
|
||||||
|
const newForeigns = [];
|
||||||
|
|
||||||
|
let sql = `CREATE TABLE \`${schema}\`.\`${options.name}\``;
|
||||||
|
|
||||||
|
// ADD FIELDS
|
||||||
|
fields.forEach(field => {
|
||||||
|
const typeInfo = this._getTypeInfo(field.type);
|
||||||
|
const length = typeInfo.length ? field.enumValues || field.numLength || field.charLength || field.datePrecision : false;
|
||||||
|
|
||||||
|
newColumns.push(`\`${field.name}\`
|
||||||
|
${field.type.toUpperCase()}${length ? `(${length})` : ''}
|
||||||
|
${field.unsigned ? 'UNSIGNED' : ''}
|
||||||
|
${field.zerofill ? 'ZEROFILL' : ''}
|
||||||
|
${field.nullable ? 'NULL' : 'NOT NULL'}
|
||||||
|
${field.autoIncrement ? 'AUTO_INCREMENT' : ''}
|
||||||
|
${field.default ? `DEFAULT ${field.default}` : ''}
|
||||||
|
${field.comment ? `COMMENT '${field.comment}'` : ''}
|
||||||
|
${field.collation ? `COLLATE ${field.collation}` : ''}
|
||||||
|
${field.onUpdate ? `ON UPDATE ${field.onUpdate}` : ''}`);
|
||||||
|
});
|
||||||
|
|
||||||
|
// ADD INDEX
|
||||||
|
indexes.forEach(index => {
|
||||||
|
const fields = index.fields.map(field => `\`${field}\``).join(',');
|
||||||
|
let type = index.type;
|
||||||
|
|
||||||
|
if (type === 'PRIMARY')
|
||||||
|
newIndexes.push(`PRIMARY KEY (${fields})`);
|
||||||
|
else {
|
||||||
|
if (type === 'UNIQUE')
|
||||||
|
type = 'UNIQUE INDEX';
|
||||||
|
|
||||||
|
newIndexes.push(`${type} \`${index.name}\` (${fields})`);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
// ADD FOREIGN KEYS
|
||||||
|
foreigns.forEach(foreign => {
|
||||||
|
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}`;
|
||||||
|
|
||||||
return await this.raw(sql);
|
return await this.raw(sql);
|
||||||
}
|
}
|
||||||
|
@@ -94,7 +94,7 @@ export class PostgreSQLClient extends AntaresCore {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Executes an USE query
|
* Executes an "USE" query
|
||||||
*
|
*
|
||||||
* @param {String} schema
|
* @param {String} schema
|
||||||
* @memberof PostgreSQLClient
|
* @memberof PostgreSQLClient
|
||||||
@@ -306,6 +306,40 @@ export class PostgreSQLClient extends AntaresCore {
|
|||||||
return rows.length ? rows[0].count : 0;
|
return rows.length ? rows[0].count : 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param {Object} params
|
||||||
|
* @param {String} params.schema
|
||||||
|
* @param {String} params.table
|
||||||
|
* @returns {Object} table options
|
||||||
|
* @memberof MySQLClient
|
||||||
|
*/
|
||||||
|
async getTableOptions ({ schema, table }) {
|
||||||
|
const { rows } = await this.raw(`
|
||||||
|
SELECT *,
|
||||||
|
pg_table_size(QUOTE_IDENT(t.TABLE_SCHEMA) || '.' || QUOTE_IDENT(t.TABLE_NAME))::bigint AS data_length,
|
||||||
|
pg_relation_size(QUOTE_IDENT(t.TABLE_SCHEMA) || '.' || QUOTE_IDENT(t.TABLE_NAME))::bigint AS index_length,
|
||||||
|
c.reltuples, obj_description(c.oid) AS comment
|
||||||
|
FROM "information_schema"."tables" AS t
|
||||||
|
LEFT JOIN "pg_namespace" n ON t.table_schema = n.nspname
|
||||||
|
LEFT JOIN "pg_class" c ON n.oid = c.relnamespace AND c.relname=t.table_name
|
||||||
|
WHERE t."table_schema" = '${schema}'
|
||||||
|
AND table_name = '${table}'
|
||||||
|
`);
|
||||||
|
|
||||||
|
if (rows.length) {
|
||||||
|
return {
|
||||||
|
name: rows[0].table_name,
|
||||||
|
type: rows[0].table_type === 'VIEW' ? 'view' : 'table',
|
||||||
|
rows: rows[0].reltuples,
|
||||||
|
size: +rows[0].data_length + +rows[0].index_length,
|
||||||
|
collation: rows[0].Collation,
|
||||||
|
comment: rows[0].comment,
|
||||||
|
engine: ''
|
||||||
|
};
|
||||||
|
};
|
||||||
|
return {};
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param {Object} params
|
* @param {Object} params
|
||||||
* @param {String} params.schema
|
* @param {String} params.schema
|
||||||
@@ -724,7 +758,7 @@ export class PostgreSQLClient extends AntaresCore {
|
|||||||
async createRoutine (routine) {
|
async createRoutine (routine) {
|
||||||
const parameters = 'parameters' in routine
|
const parameters = 'parameters' in routine
|
||||||
? routine.parameters.reduce((acc, curr) => {
|
? routine.parameters.reduce((acc, curr) => {
|
||||||
acc.push(`${curr.context} ${curr.name} ${curr.type}${curr.length ? `(${curr.length})` : ''}`);
|
acc.push(`${curr.context} ${curr.name} ${curr.type}`);
|
||||||
return acc;
|
return acc;
|
||||||
}, []).join(',')
|
}, []).join(',')
|
||||||
: '';
|
: '';
|
||||||
@@ -853,7 +887,7 @@ export class PostgreSQLClient extends AntaresCore {
|
|||||||
async createFunction (func) {
|
async createFunction (func) {
|
||||||
const parameters = 'parameters' in func
|
const parameters = 'parameters' in func
|
||||||
? func.parameters.reduce((acc, curr) => {
|
? func.parameters.reduce((acc, curr) => {
|
||||||
acc.push(`${curr.context} ${curr.name || ''} ${curr.type}${curr.length ? `(${curr.length})` : ''}`);
|
acc.push(`${curr.context} ${curr.name || ''} ${curr.type}`);
|
||||||
return acc;
|
return acc;
|
||||||
}, []).join(',')
|
}, []).join(',')
|
||||||
: '';
|
: '';
|
||||||
@@ -1002,8 +1036,54 @@ export class PostgreSQLClient extends AntaresCore {
|
|||||||
* @memberof PostgreSQLClient
|
* @memberof PostgreSQLClient
|
||||||
*/
|
*/
|
||||||
async createTable (params) {
|
async createTable (params) {
|
||||||
const sql = `CREATE TABLE "${params.schema}"."${params.name}" (${params.name}_id INTEGER NULL); ALTER TABLE "${params.schema}"."${params.name}" DROP COLUMN ${params.name}_id`;
|
const {
|
||||||
|
schema,
|
||||||
|
fields,
|
||||||
|
foreigns,
|
||||||
|
indexes,
|
||||||
|
options
|
||||||
|
} = params;
|
||||||
|
const newColumns = [];
|
||||||
|
const newIndexes = [];
|
||||||
|
const manageIndexes = [];
|
||||||
|
const newForeigns = [];
|
||||||
|
|
||||||
|
let sql = `CREATE TABLE "${schema}"."${options.name}"`;
|
||||||
|
|
||||||
|
// ADD FIELDS
|
||||||
|
fields.forEach(field => {
|
||||||
|
const typeInfo = this._getTypeInfo(field.type);
|
||||||
|
const length = typeInfo.length ? field.enumValues || field.numLength || field.charLength || field.datePrecision : false;
|
||||||
|
|
||||||
|
newColumns.push(`${field.name}
|
||||||
|
${field.type.toUpperCase()}${length ? `(${length})` : ''}
|
||||||
|
${field.unsigned ? 'UNSIGNED' : ''}
|
||||||
|
${field.zerofill ? 'ZEROFILL' : ''}
|
||||||
|
${field.nullable ? 'NULL' : 'NOT NULL'}
|
||||||
|
${field.default ? `DEFAULT ${field.default}` : ''}
|
||||||
|
${field.onUpdate ? `ON UPDATE ${field.onUpdate}` : ''}`);
|
||||||
|
});
|
||||||
|
|
||||||
|
// ADD INDEX
|
||||||
|
indexes.forEach(index => {
|
||||||
|
const fields = index.fields.map(field => `${field}`).join(',');
|
||||||
|
const type = index.type;
|
||||||
|
|
||||||
|
if (type === 'PRIMARY')
|
||||||
|
newIndexes.push(`PRIMARY KEY (${fields})`);
|
||||||
|
else if (type === 'UNIQUE')
|
||||||
|
newIndexes.push(`CONSTRAINT ${index.name} UNIQUE (${fields})`);
|
||||||
|
else
|
||||||
|
manageIndexes.push(`CREATE INDEX ${index.name} ON "${schema}"."${options.name}" (${fields})`);
|
||||||
|
});
|
||||||
|
|
||||||
|
// ADD FOREIGN KEYS
|
||||||
|
foreigns.forEach(foreign => {
|
||||||
|
newForeigns.push(`CONSTRAINT ${foreign.constraintName} FOREIGN KEY (${foreign.field}) REFERENCES "${schema}"."${foreign.refTable}" (${foreign.refField}) ON UPDATE ${foreign.onUpdate} ON DELETE ${foreign.onDelete}`);
|
||||||
|
});
|
||||||
|
|
||||||
|
sql = `${sql} (${[...newColumns, ...newIndexes, ...newForeigns].join(', ')})`;
|
||||||
|
if (manageIndexes.length) sql = `${sql}; ${manageIndexes.join(';')}`;
|
||||||
return await this.raw(sql);
|
return await this.raw(sql);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1034,12 +1114,6 @@ export class PostgreSQLClient extends AntaresCore {
|
|||||||
const createSequences = [];
|
const createSequences = [];
|
||||||
const manageIndexes = [];
|
const manageIndexes = [];
|
||||||
|
|
||||||
// OPTIONS
|
|
||||||
if ('comment' in options) alterColumns.push(`COMMENT='${options.comment}'`);
|
|
||||||
if ('engine' in options) alterColumns.push(`ENGINE=${options.engine}`);
|
|
||||||
if ('autoIncrement' in options) alterColumns.push(`AUTO_INCREMENT=${+options.autoIncrement}`);
|
|
||||||
if ('collation' in options) alterColumns.push(`COLLATE='${options.collation}'`);
|
|
||||||
|
|
||||||
// ADD FIELDS
|
// ADD FIELDS
|
||||||
additions.forEach(addition => {
|
additions.forEach(addition => {
|
||||||
const typeInfo = this._getTypeInfo(addition.type);
|
const typeInfo = this._getTypeInfo(addition.type);
|
||||||
@@ -1050,10 +1124,7 @@ export class PostgreSQLClient extends AntaresCore {
|
|||||||
${addition.unsigned ? 'UNSIGNED' : ''}
|
${addition.unsigned ? 'UNSIGNED' : ''}
|
||||||
${addition.zerofill ? 'ZEROFILL' : ''}
|
${addition.zerofill ? 'ZEROFILL' : ''}
|
||||||
${addition.nullable ? 'NULL' : 'NOT NULL'}
|
${addition.nullable ? 'NULL' : 'NOT NULL'}
|
||||||
${addition.autoIncrement ? 'AUTO_INCREMENT' : ''}
|
|
||||||
${addition.default ? `DEFAULT ${addition.default}` : ''}
|
${addition.default ? `DEFAULT ${addition.default}` : ''}
|
||||||
${addition.comment ? `COMMENT '${addition.comment}'` : ''}
|
|
||||||
${addition.collation ? `COLLATE ${addition.collation}` : ''}
|
|
||||||
${addition.onUpdate ? `ON UPDATE ${addition.onUpdate}` : ''}`);
|
${addition.onUpdate ? `ON UPDATE ${addition.onUpdate}` : ''}`);
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -1072,7 +1143,7 @@ export class PostgreSQLClient extends AntaresCore {
|
|||||||
|
|
||||||
// ADD FOREIGN KEYS
|
// ADD FOREIGN KEYS
|
||||||
foreignChanges.additions.forEach(addition => {
|
foreignChanges.additions.forEach(addition => {
|
||||||
alterColumns.push(`ADD CONSTRAINT ${addition.constraintName} FOREIGN KEY (${addition.field}) REFERENCES ${addition.refTable} (${addition.refField}) ON UPDATE ${addition.onUpdate} ON DELETE ${addition.onDelete}`);
|
alterColumns.push(`ADD CONSTRAINT ${addition.constraintName} FOREIGN KEY (${addition.field}) REFERENCES "${schema}"."${addition.refTable}" (${addition.refField}) ON UPDATE ${addition.onUpdate} ON DELETE ${addition.onDelete}`);
|
||||||
});
|
});
|
||||||
|
|
||||||
// CHANGE FIELDS
|
// CHANGE FIELDS
|
||||||
@@ -1129,7 +1200,7 @@ export class PostgreSQLClient extends AntaresCore {
|
|||||||
// CHANGE FOREIGN KEYS
|
// CHANGE FOREIGN KEYS
|
||||||
foreignChanges.changes.forEach(change => {
|
foreignChanges.changes.forEach(change => {
|
||||||
alterColumns.push(`DROP CONSTRAINT ${change.oldName}`);
|
alterColumns.push(`DROP CONSTRAINT ${change.oldName}`);
|
||||||
alterColumns.push(`ADD CONSTRAINT ${change.constraintName} FOREIGN KEY (${change.field}) REFERENCES ${change.refTable} (${change.refField}) ON UPDATE ${change.onUpdate} ON DELETE ${change.onDelete}`);
|
alterColumns.push(`ADD CONSTRAINT ${change.constraintName} FOREIGN KEY (${change.field}) REFERENCES "${schema}"."${change.refTable}" (${change.refField}) ON UPDATE ${change.onUpdate} ON DELETE ${change.onDelete}`);
|
||||||
});
|
});
|
||||||
|
|
||||||
// DROP FIELDS
|
// DROP FIELDS
|
||||||
|
@@ -78,6 +78,7 @@ export default {
|
|||||||
|
|
||||||
.file-uploader-message {
|
.file-uploader-message {
|
||||||
display: flex;
|
display: flex;
|
||||||
|
border-radius: $border-radius 0 0 $border-radius;
|
||||||
}
|
}
|
||||||
|
|
||||||
.file-uploader-input {
|
.file-uploader-input {
|
||||||
|
@@ -31,7 +31,11 @@
|
|||||||
class="form-input"
|
class="form-input"
|
||||||
type="text"
|
type="text"
|
||||||
>
|
>
|
||||||
<span class="input-group-addon field-type" :class="typeClass(parameter.type)">
|
<span
|
||||||
|
:title="`${parameter.type} ${parameter.length}`"
|
||||||
|
class="input-group-addon field-type cut-text"
|
||||||
|
:class="typeClass(parameter.type)"
|
||||||
|
>
|
||||||
{{ parameter.type }} {{ parameter.length | wrapNumber }}
|
{{ parameter.type }} {{ parameter.length | wrapNumber }}
|
||||||
</span>
|
</span>
|
||||||
</div>
|
</div>
|
||||||
@@ -127,4 +131,8 @@ export default {
|
|||||||
.field-type {
|
.field-type {
|
||||||
font-size: 0.6rem;
|
font-size: 0.6rem;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.input-group-addon {
|
||||||
|
max-width: 100px;
|
||||||
|
}
|
||||||
</style>
|
</style>
|
||||||
|
@@ -251,7 +251,7 @@ export default {
|
|||||||
if (field.default === 'NULL') fieldDefault = null;
|
if (field.default === 'NULL') fieldDefault = null;
|
||||||
else {
|
else {
|
||||||
if ([...NUMBER, ...FLOAT].includes(field.type))
|
if ([...NUMBER, ...FLOAT].includes(field.type))
|
||||||
fieldDefault = Number.isNaN(+field.default) ? null : +field.default;
|
fieldDefault = !field.default || Number.isNaN(+field.default.replaceAll('\'', '')) ? null : +field.default.replaceAll('\'', '');
|
||||||
else if ([...TEXT, ...LONG_TEXT].includes(field.type)) {
|
else if ([...TEXT, ...LONG_TEXT].includes(field.type)) {
|
||||||
fieldDefault = field.default
|
fieldDefault = field.default
|
||||||
? field.default.includes('\'')
|
? field.default.includes('\'')
|
||||||
|
@@ -1,170 +0,0 @@
|
|||||||
<template>
|
|
||||||
<ConfirmModal
|
|
||||||
:confirm-text="$t('word.confirm')"
|
|
||||||
size="400"
|
|
||||||
@confirm="confirmNewFunction"
|
|
||||||
@hide="$emit('close')"
|
|
||||||
>
|
|
||||||
<template :slot="'header'">
|
|
||||||
<div class="d-flex">
|
|
||||||
<i class="mdi mdi-24px mdi-plus mr-1" /> {{ $t('message.createNewFunction') }}
|
|
||||||
</div>
|
|
||||||
</template>
|
|
||||||
<div :slot="'body'">
|
|
||||||
<form class="form-horizontal">
|
|
||||||
<div class="form-group">
|
|
||||||
<label class="form-label col-4">
|
|
||||||
{{ $t('word.name') }}
|
|
||||||
</label>
|
|
||||||
<div class="column">
|
|
||||||
<input
|
|
||||||
ref="firstInput"
|
|
||||||
v-model="localFunction.name"
|
|
||||||
class="form-input"
|
|
||||||
type="text"
|
|
||||||
>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<div v-if="customizations.languages" class="form-group">
|
|
||||||
<label class="form-label col-4">
|
|
||||||
{{ $t('word.language') }}
|
|
||||||
</label>
|
|
||||||
<div class="column">
|
|
||||||
<select v-model="localFunction.language" class="form-select">
|
|
||||||
<option v-for="language in customizations.languages" :key="language">
|
|
||||||
{{ language }}
|
|
||||||
</option>
|
|
||||||
</select>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<div v-if="customizations.definer" class="form-group">
|
|
||||||
<label class="form-label col-4">
|
|
||||||
{{ $t('word.definer') }}
|
|
||||||
</label>
|
|
||||||
<div class="column">
|
|
||||||
<select
|
|
||||||
v-if="workspace.users.length"
|
|
||||||
v-model="localFunction.definer"
|
|
||||||
class="form-select"
|
|
||||||
>
|
|
||||||
<option value="">
|
|
||||||
{{ $t('message.currentUser') }}
|
|
||||||
</option>
|
|
||||||
<option
|
|
||||||
v-for="user in workspace.users"
|
|
||||||
:key="`${user.name}@${user.host}`"
|
|
||||||
:value="`\`${user.name}\`@\`${user.host}\``"
|
|
||||||
>
|
|
||||||
{{ user.name }}@{{ user.host }}
|
|
||||||
</option>
|
|
||||||
</select>
|
|
||||||
<select v-if="!workspace.users.length" class="form-select">
|
|
||||||
<option value="">
|
|
||||||
{{ $t('message.currentUser') }}
|
|
||||||
</option>
|
|
||||||
</select>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<div v-if="customizations.comment" class="form-group">
|
|
||||||
<label class="form-label col-4">
|
|
||||||
{{ $t('word.comment') }}
|
|
||||||
</label>
|
|
||||||
<div class="column">
|
|
||||||
<input
|
|
||||||
v-model="localFunction.comment"
|
|
||||||
class="form-input"
|
|
||||||
type="text"
|
|
||||||
>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<div class="form-group">
|
|
||||||
<label class="form-label col-4">
|
|
||||||
{{ $t('message.sqlSecurity') }}
|
|
||||||
</label>
|
|
||||||
<div class="column">
|
|
||||||
<select v-model="localFunction.security" class="form-select">
|
|
||||||
<option>DEFINER</option>
|
|
||||||
<option>INVOKER</option>
|
|
||||||
</select>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<div v-if="customizations.functionDataAccess" class="form-group">
|
|
||||||
<label class="form-label col-4">
|
|
||||||
{{ $t('message.dataAccess') }}
|
|
||||||
</label>
|
|
||||||
<div class="column">
|
|
||||||
<select v-model="localFunction.dataAccess" class="form-select">
|
|
||||||
<option>CONTAINS SQL</option>
|
|
||||||
<option>NO SQL</option>
|
|
||||||
<option>READS SQL DATA</option>
|
|
||||||
<option>MODIFIES SQL DATA</option>
|
|
||||||
</select>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<div v-if="customizations.functionDeterministic" class="form-group">
|
|
||||||
<div class="col-4" />
|
|
||||||
<div class="column">
|
|
||||||
<label class="form-checkbox form-inline">
|
|
||||||
<input v-model="localFunction.deterministic" type="checkbox"><i class="form-icon" /> {{ $t('word.deterministic') }}
|
|
||||||
</label>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</form>
|
|
||||||
</div>
|
|
||||||
</ConfirmModal>
|
|
||||||
</template>
|
|
||||||
|
|
||||||
<script>
|
|
||||||
import ConfirmModal from '@/components/BaseConfirmModal';
|
|
||||||
|
|
||||||
export default {
|
|
||||||
name: 'ModalNewFunction',
|
|
||||||
components: {
|
|
||||||
ConfirmModal
|
|
||||||
},
|
|
||||||
props: {
|
|
||||||
workspace: Object
|
|
||||||
},
|
|
||||||
data () {
|
|
||||||
return {
|
|
||||||
localFunction: {
|
|
||||||
definer: '',
|
|
||||||
sql: '',
|
|
||||||
parameters: [],
|
|
||||||
name: '',
|
|
||||||
comment: '',
|
|
||||||
language: null,
|
|
||||||
returns: null,
|
|
||||||
returnsLength: 10,
|
|
||||||
security: 'DEFINER',
|
|
||||||
deterministic: false,
|
|
||||||
dataAccess: 'CONTAINS SQL'
|
|
||||||
},
|
|
||||||
isOptionsChanging: false
|
|
||||||
};
|
|
||||||
},
|
|
||||||
computed: {
|
|
||||||
schema () {
|
|
||||||
return this.workspace.breadcrumbs.schema;
|
|
||||||
},
|
|
||||||
customizations () {
|
|
||||||
return this.workspace.customizations;
|
|
||||||
}
|
|
||||||
},
|
|
||||||
mounted () {
|
|
||||||
if (this.customizations.languages)
|
|
||||||
this.localFunction.language = this.customizations.languages[0];
|
|
||||||
|
|
||||||
if (this.customizations.functionSql)
|
|
||||||
this.localFunction.sql = this.customizations.functionSql;
|
|
||||||
setTimeout(() => {
|
|
||||||
this.$refs.firstInput.focus();
|
|
||||||
}, 20);
|
|
||||||
},
|
|
||||||
methods: {
|
|
||||||
confirmNewFunction () {
|
|
||||||
this.$emit('open-create-function-editor', this.localFunction);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
};
|
|
||||||
</script>
|
|
@@ -1,168 +0,0 @@
|
|||||||
<template>
|
|
||||||
<ConfirmModal
|
|
||||||
:confirm-text="$t('word.confirm')"
|
|
||||||
size="400"
|
|
||||||
@confirm="confirmNewRoutine"
|
|
||||||
@hide="$emit('close')"
|
|
||||||
>
|
|
||||||
<template :slot="'header'">
|
|
||||||
<div class="d-flex">
|
|
||||||
<i class="mdi mdi-24px mdi-plus mr-1" /> {{ $t('message.createNewRoutine') }}
|
|
||||||
</div>
|
|
||||||
</template>
|
|
||||||
<div :slot="'body'">
|
|
||||||
<form class="form-horizontal">
|
|
||||||
<div class="form-group">
|
|
||||||
<label class="form-label col-4">
|
|
||||||
{{ $t('word.name') }}
|
|
||||||
</label>
|
|
||||||
<div class="column">
|
|
||||||
<input
|
|
||||||
ref="firstInput"
|
|
||||||
v-model="localRoutine.name"
|
|
||||||
class="form-input"
|
|
||||||
type="text"
|
|
||||||
>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<div v-if="customizations.languages" class="form-group">
|
|
||||||
<label class="form-label col-4">
|
|
||||||
{{ $t('word.language') }}
|
|
||||||
</label>
|
|
||||||
<div class="column">
|
|
||||||
<select v-model="localRoutine.language" class="form-select">
|
|
||||||
<option v-for="language in customizations.languages" :key="language">
|
|
||||||
{{ language }}
|
|
||||||
</option>
|
|
||||||
</select>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<div v-if="customizations.definer" class="form-group">
|
|
||||||
<label class="form-label col-4">
|
|
||||||
{{ $t('word.definer') }}
|
|
||||||
</label>
|
|
||||||
<div class="column">
|
|
||||||
<select
|
|
||||||
v-if="workspace.users.length"
|
|
||||||
v-model="localRoutine.definer"
|
|
||||||
class="form-select"
|
|
||||||
>
|
|
||||||
<option value="">
|
|
||||||
{{ $t('message.currentUser') }}
|
|
||||||
</option>
|
|
||||||
<option
|
|
||||||
v-for="user in workspace.users"
|
|
||||||
:key="`${user.name}@${user.host}`"
|
|
||||||
:value="`\`${user.name}\`@\`${user.host}\``"
|
|
||||||
>
|
|
||||||
{{ user.name }}@{{ user.host }}
|
|
||||||
</option>
|
|
||||||
</select>
|
|
||||||
<select v-if="!workspace.users.length" class="form-select">
|
|
||||||
<option value="">
|
|
||||||
{{ $t('message.currentUser') }}
|
|
||||||
</option>
|
|
||||||
</select>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<div v-if="customizations.comment" class="form-group">
|
|
||||||
<label class="form-label col-4">
|
|
||||||
{{ $t('word.comment') }}
|
|
||||||
</label>
|
|
||||||
<div class="column">
|
|
||||||
<input
|
|
||||||
v-model="localRoutine.comment"
|
|
||||||
class="form-input"
|
|
||||||
type="text"
|
|
||||||
>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<div class="form-group">
|
|
||||||
<label class="form-label col-4">
|
|
||||||
{{ $t('message.sqlSecurity') }}
|
|
||||||
</label>
|
|
||||||
<div class="column">
|
|
||||||
<select v-model="localRoutine.security" class="form-select">
|
|
||||||
<option>DEFINER</option>
|
|
||||||
<option>INVOKER</option>
|
|
||||||
</select>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<div v-if="customizations.comment" class="form-group">
|
|
||||||
<label class="form-label col-4">
|
|
||||||
{{ $t('message.dataAccess') }}
|
|
||||||
</label>
|
|
||||||
<div class="column">
|
|
||||||
<select v-model="localRoutine.dataAccess" class="form-select">
|
|
||||||
<option>CONTAINS SQL</option>
|
|
||||||
<option>NO SQL</option>
|
|
||||||
<option>READS SQL DATA</option>
|
|
||||||
<option>MODIFIES SQL DATA</option>
|
|
||||||
</select>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<div v-if="customizations.procedureDeterministic" class="form-group">
|
|
||||||
<div class="col-4" />
|
|
||||||
<div class="column">
|
|
||||||
<label class="form-checkbox form-inline">
|
|
||||||
<input v-model="localRoutine.deterministic" type="checkbox"><i class="form-icon" /> {{ $t('word.deterministic') }}
|
|
||||||
</label>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</form>
|
|
||||||
</div>
|
|
||||||
</ConfirmModal>
|
|
||||||
</template>
|
|
||||||
|
|
||||||
<script>
|
|
||||||
import ConfirmModal from '@/components/BaseConfirmModal';
|
|
||||||
|
|
||||||
export default {
|
|
||||||
name: 'ModalNewRoutine',
|
|
||||||
components: {
|
|
||||||
ConfirmModal
|
|
||||||
},
|
|
||||||
props: {
|
|
||||||
workspace: Object
|
|
||||||
},
|
|
||||||
data () {
|
|
||||||
return {
|
|
||||||
localRoutine: {
|
|
||||||
definer: '',
|
|
||||||
sql: '',
|
|
||||||
parameters: [],
|
|
||||||
name: '',
|
|
||||||
comment: '',
|
|
||||||
language: null,
|
|
||||||
security: 'DEFINER',
|
|
||||||
deterministic: false,
|
|
||||||
dataAccess: 'CONTAINS SQL'
|
|
||||||
},
|
|
||||||
isOptionsChanging: false
|
|
||||||
};
|
|
||||||
},
|
|
||||||
computed: {
|
|
||||||
schema () {
|
|
||||||
return this.workspace.breadcrumbs.schema;
|
|
||||||
},
|
|
||||||
customizations () {
|
|
||||||
return this.workspace.customizations;
|
|
||||||
}
|
|
||||||
},
|
|
||||||
mounted () {
|
|
||||||
if (this.customizations.languages)
|
|
||||||
this.localRoutine.language = this.customizations.languages[0];
|
|
||||||
|
|
||||||
if (this.customizations.procedureSql)
|
|
||||||
this.localRoutine.sql = this.customizations.procedureSql;
|
|
||||||
setTimeout(() => {
|
|
||||||
this.$refs.firstInput.focus();
|
|
||||||
}, 20);
|
|
||||||
},
|
|
||||||
methods: {
|
|
||||||
confirmNewRoutine () {
|
|
||||||
this.$emit('open-create-routine-editor', this.localRoutine);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
};
|
|
||||||
</script>
|
|
@@ -1,109 +0,0 @@
|
|||||||
<template>
|
|
||||||
<ConfirmModal
|
|
||||||
:confirm-text="$t('word.confirm')"
|
|
||||||
size="400"
|
|
||||||
@confirm="confirmNewTrigger"
|
|
||||||
@hide="$emit('close')"
|
|
||||||
>
|
|
||||||
<template :slot="'header'">
|
|
||||||
<div class="d-flex">
|
|
||||||
<i class="mdi mdi-24px mdi-plus mr-1" /> {{ $t('message.createNewScheduler') }}
|
|
||||||
</div>
|
|
||||||
</template>
|
|
||||||
<div :slot="'body'">
|
|
||||||
<form class="form-horizontal">
|
|
||||||
<div class="form-group">
|
|
||||||
<label class="form-label col-4">
|
|
||||||
{{ $t('word.name') }}
|
|
||||||
</label>
|
|
||||||
<div class="column">
|
|
||||||
<input
|
|
||||||
ref="firstInput"
|
|
||||||
v-model="localScheduler.name"
|
|
||||||
class="form-input"
|
|
||||||
type="text"
|
|
||||||
>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<div class="form-group">
|
|
||||||
<label class="form-label col-4">
|
|
||||||
{{ $t('word.definer') }}
|
|
||||||
</label>
|
|
||||||
<div class="column">
|
|
||||||
<select
|
|
||||||
v-if="workspace.users.length"
|
|
||||||
v-model="localScheduler.definer"
|
|
||||||
class="form-select"
|
|
||||||
>
|
|
||||||
<option value="">
|
|
||||||
{{ $t('message.currentUser') }}
|
|
||||||
</option>
|
|
||||||
<option
|
|
||||||
v-for="user in workspace.users"
|
|
||||||
:key="`${user.name}@${user.host}`"
|
|
||||||
:value="`\`${user.name}\`@\`${user.host}\``"
|
|
||||||
>
|
|
||||||
{{ user.name }}@{{ user.host }}
|
|
||||||
</option>
|
|
||||||
</select>
|
|
||||||
<select v-if="!workspace.users.length" class="form-select">
|
|
||||||
<option value="">
|
|
||||||
{{ $t('message.currentUser') }}
|
|
||||||
</option>
|
|
||||||
</select>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<div class="form-group">
|
|
||||||
<label class="form-label col-4">
|
|
||||||
{{ $t('word.comment') }}
|
|
||||||
</label>
|
|
||||||
<div class="column">
|
|
||||||
<input
|
|
||||||
v-model="localScheduler.comment"
|
|
||||||
class="form-input"
|
|
||||||
type="text"
|
|
||||||
>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</form>
|
|
||||||
</div>
|
|
||||||
</ConfirmModal>
|
|
||||||
</template>
|
|
||||||
|
|
||||||
<script>
|
|
||||||
import ConfirmModal from '@/components/BaseConfirmModal';
|
|
||||||
|
|
||||||
export default {
|
|
||||||
name: 'ModalNewScheduler',
|
|
||||||
components: {
|
|
||||||
ConfirmModal
|
|
||||||
},
|
|
||||||
props: {
|
|
||||||
workspace: Object
|
|
||||||
},
|
|
||||||
data () {
|
|
||||||
return {
|
|
||||||
localScheduler: {
|
|
||||||
definer: '',
|
|
||||||
sql: 'BEGIN\r\n\r\nEND',
|
|
||||||
name: '',
|
|
||||||
comment: '',
|
|
||||||
execution: 'EVERY',
|
|
||||||
every: ['1', 'DAY'],
|
|
||||||
preserve: true,
|
|
||||||
state: 'DISABLE'
|
|
||||||
}
|
|
||||||
};
|
|
||||||
},
|
|
||||||
mounted () {
|
|
||||||
setTimeout(() => {
|
|
||||||
this.$refs.firstInput.focus();
|
|
||||||
}, 20);
|
|
||||||
},
|
|
||||||
methods: {
|
|
||||||
confirmNewTrigger () {
|
|
||||||
this.$emit('open-create-scheduler-editor', this.localScheduler);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
};
|
|
||||||
</script>
|
|
@@ -1,130 +0,0 @@
|
|||||||
<template>
|
|
||||||
<ConfirmModal
|
|
||||||
:confirm-text="$t('word.confirm')"
|
|
||||||
size="400"
|
|
||||||
@confirm="confirmOptionsChange"
|
|
||||||
@hide="$emit('close')"
|
|
||||||
>
|
|
||||||
<template :slot="'header'">
|
|
||||||
<div class="d-flex">
|
|
||||||
<i class="mdi mdi-24px mdi-table-plus mr-1" /> {{ $t('message.createNewTable') }}
|
|
||||||
</div>
|
|
||||||
</template>
|
|
||||||
<div :slot="'body'">
|
|
||||||
<form class="form-horizontal">
|
|
||||||
<div class="form-group">
|
|
||||||
<label class="form-label col-4">
|
|
||||||
{{ $t('word.name') }}
|
|
||||||
</label>
|
|
||||||
<div class="column">
|
|
||||||
<input
|
|
||||||
ref="firstInput"
|
|
||||||
v-model="localOptions.name"
|
|
||||||
class="form-input"
|
|
||||||
type="text"
|
|
||||||
>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<div v-if="workspace.customizations.comment" class="form-group">
|
|
||||||
<label class="form-label col-4">
|
|
||||||
{{ $t('word.comment') }}
|
|
||||||
</label>
|
|
||||||
<div class="column">
|
|
||||||
<input
|
|
||||||
v-model="localOptions.comment"
|
|
||||||
class="form-input"
|
|
||||||
type="text"
|
|
||||||
>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<div v-if="workspace.customizations.collations" class="form-group">
|
|
||||||
<label class="form-label col-4">
|
|
||||||
{{ $t('word.collation') }}
|
|
||||||
</label>
|
|
||||||
<div class="column">
|
|
||||||
<select v-model="localOptions.collation" class="form-select">
|
|
||||||
<option
|
|
||||||
v-for="collation in workspace.collations"
|
|
||||||
:key="collation.id"
|
|
||||||
:value="collation.collation"
|
|
||||||
>
|
|
||||||
{{ collation.collation }}
|
|
||||||
</option>
|
|
||||||
</select>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<div v-if="workspace.customizations.engines" class="form-group">
|
|
||||||
<label class="form-label col-4">
|
|
||||||
{{ $t('word.engine') }}
|
|
||||||
</label>
|
|
||||||
<div class="column">
|
|
||||||
<select v-model="localOptions.engine" class="form-select">
|
|
||||||
<option
|
|
||||||
v-for="engine in workspace.engines"
|
|
||||||
:key="engine.name"
|
|
||||||
:value="engine.name"
|
|
||||||
>
|
|
||||||
{{ engine.name }}
|
|
||||||
</option>
|
|
||||||
</select>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</form>
|
|
||||||
</div>
|
|
||||||
</ConfirmModal>
|
|
||||||
</template>
|
|
||||||
|
|
||||||
<script>
|
|
||||||
import { mapGetters } from 'vuex';
|
|
||||||
import ConfirmModal from '@/components/BaseConfirmModal';
|
|
||||||
|
|
||||||
export default {
|
|
||||||
name: 'ModalNewTable',
|
|
||||||
components: {
|
|
||||||
ConfirmModal
|
|
||||||
},
|
|
||||||
props: {
|
|
||||||
workspace: Object
|
|
||||||
},
|
|
||||||
data () {
|
|
||||||
return {
|
|
||||||
localOptions: {
|
|
||||||
name: '',
|
|
||||||
comment: '',
|
|
||||||
collation: '',
|
|
||||||
engine: ''
|
|
||||||
},
|
|
||||||
isOptionsChanging: false
|
|
||||||
};
|
|
||||||
},
|
|
||||||
computed: {
|
|
||||||
...mapGetters({
|
|
||||||
selectedWorkspace: 'workspaces/getSelected',
|
|
||||||
getDatabaseVariable: 'workspaces/getDatabaseVariable'
|
|
||||||
}),
|
|
||||||
defaultCollation () {
|
|
||||||
if (this.workspace.customizations.collations)
|
|
||||||
return this.getDatabaseVariable(this.selectedWorkspace, 'collation_server').value || '';
|
|
||||||
return '';
|
|
||||||
},
|
|
||||||
defaultEngine () {
|
|
||||||
if (this.workspace.customizations.engines)
|
|
||||||
return this.workspace.engines.find(engine => engine.isDefault).name;
|
|
||||||
return '';
|
|
||||||
}
|
|
||||||
},
|
|
||||||
mounted () {
|
|
||||||
this.localOptions.collation = this.defaultCollation;
|
|
||||||
this.localOptions.engine = this.defaultEngine;
|
|
||||||
|
|
||||||
setTimeout(() => {
|
|
||||||
this.$refs.firstInput.focus();
|
|
||||||
}, 20);
|
|
||||||
},
|
|
||||||
methods: {
|
|
||||||
confirmOptionsChange () {
|
|
||||||
this.$emit('open-create-table-editor', this.localOptions);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
};
|
|
||||||
</script>
|
|
@@ -1,183 +0,0 @@
|
|||||||
<template>
|
|
||||||
<ConfirmModal
|
|
||||||
:confirm-text="$t('word.confirm')"
|
|
||||||
size="400"
|
|
||||||
@confirm="confirmNewTrigger"
|
|
||||||
@hide="$emit('close')"
|
|
||||||
>
|
|
||||||
<template :slot="'header'">
|
|
||||||
<div class="d-flex">
|
|
||||||
<i class="mdi mdi-24px mdi-plus mr-1" /> {{ $t('message.createNewTrigger') }}
|
|
||||||
</div>
|
|
||||||
</template>
|
|
||||||
<div :slot="'body'">
|
|
||||||
<form class="form-horizontal">
|
|
||||||
<div class="form-group">
|
|
||||||
<label class="form-label col-4">
|
|
||||||
{{ $t('word.name') }}
|
|
||||||
</label>
|
|
||||||
<div class="column">
|
|
||||||
<input
|
|
||||||
ref="firstInput"
|
|
||||||
v-model="localTrigger.name"
|
|
||||||
class="form-input"
|
|
||||||
type="text"
|
|
||||||
>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<div v-if="customizations.definer" class="form-group">
|
|
||||||
<label class="form-label col-4">
|
|
||||||
{{ $t('word.definer') }}
|
|
||||||
</label>
|
|
||||||
<div class="column">
|
|
||||||
<select
|
|
||||||
v-if="workspace.users.length"
|
|
||||||
v-model="localTrigger.definer"
|
|
||||||
class="form-select"
|
|
||||||
>
|
|
||||||
<option value="">
|
|
||||||
{{ $t('message.currentUser') }}
|
|
||||||
</option>
|
|
||||||
<option
|
|
||||||
v-for="user in workspace.users"
|
|
||||||
:key="`${user.name}@${user.host}`"
|
|
||||||
:value="`\`${user.name}\`@\`${user.host}\``"
|
|
||||||
>
|
|
||||||
{{ user.name }}@{{ user.host }}
|
|
||||||
</option>
|
|
||||||
</select>
|
|
||||||
<select v-if="!workspace.users.length" class="form-select">
|
|
||||||
<option value="">
|
|
||||||
{{ $t('message.currentUser') }}
|
|
||||||
</option>
|
|
||||||
</select>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<div class="form-group">
|
|
||||||
<label class="form-label col-4">
|
|
||||||
{{ $t('word.table') }}
|
|
||||||
</label>
|
|
||||||
<div class="column">
|
|
||||||
<select v-model="localTrigger.table" class="form-select">
|
|
||||||
<option v-for="table in schemaTables" :key="table.name">
|
|
||||||
{{ table.name }}
|
|
||||||
</option>
|
|
||||||
</select>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<div class="form-group">
|
|
||||||
<label class="form-label col-4">
|
|
||||||
{{ $t('word.event') }}
|
|
||||||
</label>
|
|
||||||
<div class="column">
|
|
||||||
<div class="input-group">
|
|
||||||
<select v-model="localTrigger.activation" class="form-select">
|
|
||||||
<option>BEFORE</option>
|
|
||||||
<option>AFTER</option>
|
|
||||||
</select>
|
|
||||||
<select
|
|
||||||
v-if="!customizations.triggerMultipleEvents"
|
|
||||||
v-model="localTrigger.event"
|
|
||||||
class="form-select"
|
|
||||||
>
|
|
||||||
<option v-for="event in Object.keys(localEvents)" :key="event">
|
|
||||||
{{ event }}
|
|
||||||
</option>
|
|
||||||
</select>
|
|
||||||
<div v-if="customizations.triggerMultipleEvents" class="px-4">
|
|
||||||
<label
|
|
||||||
v-for="event in Object.keys(localEvents)"
|
|
||||||
:key="event"
|
|
||||||
class="form-checkbox form-inline"
|
|
||||||
@change.prevent="changeEvents(event)"
|
|
||||||
>
|
|
||||||
<input :checked="localEvents[event]" type="checkbox"><i class="form-icon" /> {{ event }}
|
|
||||||
</label>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</form>
|
|
||||||
<div v-if="customizations.triggerStatementInCreation" class="workspace-query-results column col-12 mt-2">
|
|
||||||
<label class="form-label ml-2">{{ $t('message.triggerStatement') }}</label>
|
|
||||||
<QueryEditor
|
|
||||||
ref="queryEditor"
|
|
||||||
:value.sync="localTrigger.sql"
|
|
||||||
:workspace="workspace"
|
|
||||||
:schema="schema"
|
|
||||||
:height="editorHeight"
|
|
||||||
/>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</ConfirmModal>
|
|
||||||
</template>
|
|
||||||
|
|
||||||
<script>
|
|
||||||
import ConfirmModal from '@/components/BaseConfirmModal';
|
|
||||||
import QueryEditor from '@/components/QueryEditor';
|
|
||||||
|
|
||||||
export default {
|
|
||||||
name: 'ModalNewTrigger',
|
|
||||||
components: {
|
|
||||||
ConfirmModal,
|
|
||||||
QueryEditor
|
|
||||||
},
|
|
||||||
props: {
|
|
||||||
workspace: Object
|
|
||||||
},
|
|
||||||
data () {
|
|
||||||
return {
|
|
||||||
localTrigger: {
|
|
||||||
definer: '',
|
|
||||||
sql: '',
|
|
||||||
name: '',
|
|
||||||
table: '',
|
|
||||||
activation: 'BEFORE',
|
|
||||||
event: 'INSERT'
|
|
||||||
},
|
|
||||||
isOptionsChanging: false,
|
|
||||||
localEvents: { INSERT: false, UPDATE: false, DELETE: false },
|
|
||||||
editorHeight: 150
|
|
||||||
};
|
|
||||||
},
|
|
||||||
computed: {
|
|
||||||
schema () {
|
|
||||||
return this.workspace.breadcrumbs.schema;
|
|
||||||
},
|
|
||||||
schemaTables () {
|
|
||||||
const schemaTables = this.workspace.structure
|
|
||||||
.filter(schema => schema.name === this.schema)
|
|
||||||
.map(schema => schema.tables);
|
|
||||||
|
|
||||||
return schemaTables.length ? schemaTables[0].filter(table => table.type === 'table') : [];
|
|
||||||
},
|
|
||||||
customizations () {
|
|
||||||
return this.workspace.customizations;
|
|
||||||
}
|
|
||||||
},
|
|
||||||
created () {
|
|
||||||
this.localTrigger.table = this.schemaTables.length ? this.schemaTables[0].name : '';
|
|
||||||
this.localTrigger.sql = this.customizations.triggerSql;
|
|
||||||
},
|
|
||||||
mounted () {
|
|
||||||
setTimeout(() => {
|
|
||||||
this.$refs.firstInput.focus();
|
|
||||||
}, 20);
|
|
||||||
},
|
|
||||||
methods: {
|
|
||||||
confirmNewTrigger () {
|
|
||||||
this.$emit('open-create-trigger-editor', this.localTrigger);
|
|
||||||
},
|
|
||||||
changeEvents (event) {
|
|
||||||
if (this.customizations.triggerMultipleEvents) {
|
|
||||||
this.localEvents[event] = !this.localEvents[event];
|
|
||||||
this.localTrigger.event = [];
|
|
||||||
for (const key in this.localEvents) {
|
|
||||||
if (this.localEvents[key])
|
|
||||||
this.localTrigger.event.push(key);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
};
|
|
||||||
</script>
|
|
@@ -1,132 +0,0 @@
|
|||||||
<template>
|
|
||||||
<ConfirmModal
|
|
||||||
:confirm-text="$t('word.confirm')"
|
|
||||||
size="400"
|
|
||||||
@confirm="confirmNewFunction"
|
|
||||||
@hide="$emit('close')"
|
|
||||||
>
|
|
||||||
<template :slot="'header'">
|
|
||||||
<div class="d-flex">
|
|
||||||
<i class="mdi mdi-24px mdi-plus mr-1" /> {{ $t('message.createNewFunction') }}
|
|
||||||
</div>
|
|
||||||
</template>
|
|
||||||
<div :slot="'body'">
|
|
||||||
<form class="form-horizontal">
|
|
||||||
<div class="form-group">
|
|
||||||
<label class="form-label col-4">
|
|
||||||
{{ $t('word.name') }}
|
|
||||||
</label>
|
|
||||||
<div class="column">
|
|
||||||
<input
|
|
||||||
ref="firstInput"
|
|
||||||
v-model="localFunction.name"
|
|
||||||
class="form-input"
|
|
||||||
type="text"
|
|
||||||
>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<div v-if="customizations.languages" class="form-group">
|
|
||||||
<label class="form-label col-4">
|
|
||||||
{{ $t('word.language') }}
|
|
||||||
</label>
|
|
||||||
<div class="column">
|
|
||||||
<select v-model="localFunction.language" class="form-select">
|
|
||||||
<option v-for="language in customizations.triggerFunctionlanguages" :key="language">
|
|
||||||
{{ language }}
|
|
||||||
</option>
|
|
||||||
</select>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<div v-if="customizations.definer" class="form-group">
|
|
||||||
<label class="form-label col-4">
|
|
||||||
{{ $t('word.definer') }}
|
|
||||||
</label>
|
|
||||||
<div class="column">
|
|
||||||
<select
|
|
||||||
v-if="workspace.users.length"
|
|
||||||
v-model="localFunction.definer"
|
|
||||||
class="form-select"
|
|
||||||
>
|
|
||||||
<option value="">
|
|
||||||
{{ $t('message.currentUser') }}
|
|
||||||
</option>
|
|
||||||
<option
|
|
||||||
v-for="user in workspace.users"
|
|
||||||
:key="`${user.name}@${user.host}`"
|
|
||||||
:value="`\`${user.name}\`@\`${user.host}\``"
|
|
||||||
>
|
|
||||||
{{ user.name }}@{{ user.host }}
|
|
||||||
</option>
|
|
||||||
</select>
|
|
||||||
<select v-if="!workspace.users.length" class="form-select">
|
|
||||||
<option value="">
|
|
||||||
{{ $t('message.currentUser') }}
|
|
||||||
</option>
|
|
||||||
</select>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<div v-if="customizations.comment" class="form-group">
|
|
||||||
<label class="form-label col-4">
|
|
||||||
{{ $t('word.comment') }}
|
|
||||||
</label>
|
|
||||||
<div class="column">
|
|
||||||
<input
|
|
||||||
v-model="localFunction.comment"
|
|
||||||
class="form-input"
|
|
||||||
type="text"
|
|
||||||
>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</form>
|
|
||||||
</div>
|
|
||||||
</ConfirmModal>
|
|
||||||
</template>
|
|
||||||
|
|
||||||
<script>
|
|
||||||
import ConfirmModal from '@/components/BaseConfirmModal';
|
|
||||||
|
|
||||||
export default {
|
|
||||||
name: 'ModalNewTriggerFunction',
|
|
||||||
components: {
|
|
||||||
ConfirmModal
|
|
||||||
},
|
|
||||||
props: {
|
|
||||||
workspace: Object
|
|
||||||
},
|
|
||||||
data () {
|
|
||||||
return {
|
|
||||||
localFunction: {
|
|
||||||
definer: '',
|
|
||||||
sql: '',
|
|
||||||
name: '',
|
|
||||||
comment: '',
|
|
||||||
language: null
|
|
||||||
},
|
|
||||||
isOptionsChanging: false
|
|
||||||
};
|
|
||||||
},
|
|
||||||
computed: {
|
|
||||||
schema () {
|
|
||||||
return this.workspace.breadcrumbs.schema;
|
|
||||||
},
|
|
||||||
customizations () {
|
|
||||||
return this.workspace.customizations;
|
|
||||||
}
|
|
||||||
},
|
|
||||||
mounted () {
|
|
||||||
if (this.customizations.triggerFunctionlanguages)
|
|
||||||
this.localFunction.language = this.customizations.triggerFunctionlanguages[0];
|
|
||||||
|
|
||||||
if (this.customizations.triggerFunctionSql)
|
|
||||||
this.localFunction.sql = this.customizations.triggerFunctionSql;
|
|
||||||
setTimeout(() => {
|
|
||||||
this.$refs.firstInput.focus();
|
|
||||||
}, 20);
|
|
||||||
},
|
|
||||||
methods: {
|
|
||||||
confirmNewFunction () {
|
|
||||||
this.$emit('open-create-function-editor', this.localFunction);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
};
|
|
||||||
</script>
|
|
@@ -1,192 +0,0 @@
|
|||||||
<template>
|
|
||||||
<ConfirmModal
|
|
||||||
:confirm-text="$t('word.confirm')"
|
|
||||||
size="medium"
|
|
||||||
@confirm="confirmOptionsChange"
|
|
||||||
@hide="$emit('close')"
|
|
||||||
>
|
|
||||||
<template :slot="'header'">
|
|
||||||
<div class="d-flex">
|
|
||||||
<i class="mdi mdi-24px mdi-eye-plus mr-1" /> {{ $t('message.createNewView') }}
|
|
||||||
</div>
|
|
||||||
</template>
|
|
||||||
<div :slot="'body'">
|
|
||||||
<div class="container">
|
|
||||||
<div class="columns mb-4">
|
|
||||||
<div class="column col-6">
|
|
||||||
<div class="form-group">
|
|
||||||
<label class="form-label">{{ $t('word.name') }}</label>
|
|
||||||
<input
|
|
||||||
ref="firstInput"
|
|
||||||
v-model="localView.name"
|
|
||||||
class="form-input"
|
|
||||||
type="text"
|
|
||||||
>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<div class="column col-6">
|
|
||||||
<div v-if="workspace.customizations.definer" class="form-group">
|
|
||||||
<label class="form-label">{{ $t('word.definer') }}</label>
|
|
||||||
<select v-model="localView.definer" class="form-select">
|
|
||||||
<option value="">
|
|
||||||
{{ $t('message.currentUser') }}
|
|
||||||
</option>
|
|
||||||
<option
|
|
||||||
v-for="user in workspace.users"
|
|
||||||
:key="`${user.name}@${user.host}`"
|
|
||||||
:value="`\`${user.name}\`@\`${user.host}\``"
|
|
||||||
>
|
|
||||||
{{ user.name }}@{{ user.host }}
|
|
||||||
</option>
|
|
||||||
</select>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<div class="columns">
|
|
||||||
<div class="column col-4">
|
|
||||||
<div v-if="workspace.customizations.viewSqlSecurity" class="form-group">
|
|
||||||
<label class="form-label">{{ $t('message.sqlSecurity') }}</label>
|
|
||||||
<label class="form-radio">
|
|
||||||
<input
|
|
||||||
v-model="localView.security"
|
|
||||||
type="radio"
|
|
||||||
name="security"
|
|
||||||
value="DEFINER"
|
|
||||||
>
|
|
||||||
<i class="form-icon" /> DEFINER
|
|
||||||
</label>
|
|
||||||
<label class="form-radio">
|
|
||||||
<input
|
|
||||||
v-model="localView.security"
|
|
||||||
type="radio"
|
|
||||||
name="security"
|
|
||||||
value="INVOKER"
|
|
||||||
>
|
|
||||||
<i class="form-icon" /> INVOKER
|
|
||||||
</label>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<div class="column col-4">
|
|
||||||
<div v-if="workspace.customizations.viewAlgorithm" class="form-group">
|
|
||||||
<label class="form-label">{{ $t('word.algorithm') }}</label>
|
|
||||||
<label class="form-radio">
|
|
||||||
<input
|
|
||||||
v-model="localView.algorithm"
|
|
||||||
type="radio"
|
|
||||||
name="algorithm"
|
|
||||||
value="UNDEFINED"
|
|
||||||
>
|
|
||||||
<i class="form-icon" /> UNDEFINED
|
|
||||||
</label>
|
|
||||||
<label class="form-radio">
|
|
||||||
<input
|
|
||||||
v-model="localView.algorithm"
|
|
||||||
type="radio"
|
|
||||||
value="MERGE"
|
|
||||||
name="algorithm"
|
|
||||||
>
|
|
||||||
<i class="form-icon" /> MERGE
|
|
||||||
</label>
|
|
||||||
<label class="form-radio">
|
|
||||||
<input
|
|
||||||
v-model="localView.algorithm"
|
|
||||||
type="radio"
|
|
||||||
value="TEMPTABLE"
|
|
||||||
name="algorithm"
|
|
||||||
>
|
|
||||||
<i class="form-icon" /> TEMPTABLE
|
|
||||||
</label>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<div class="column col-4">
|
|
||||||
<div v-if="workspace.customizations.viewUpdateOption" class="form-group">
|
|
||||||
<label class="form-label">{{ $t('message.updateOption') }}</label>
|
|
||||||
<label class="form-radio">
|
|
||||||
<input
|
|
||||||
v-model="localView.updateOption"
|
|
||||||
type="radio"
|
|
||||||
name="update"
|
|
||||||
value=""
|
|
||||||
>
|
|
||||||
<i class="form-icon" /> None
|
|
||||||
</label>
|
|
||||||
<label class="form-radio">
|
|
||||||
<input
|
|
||||||
v-model="localView.updateOption"
|
|
||||||
type="radio"
|
|
||||||
name="update"
|
|
||||||
value="CASCADED"
|
|
||||||
>
|
|
||||||
<i class="form-icon" /> CASCADED
|
|
||||||
</label>
|
|
||||||
<label class="form-radio">
|
|
||||||
<input
|
|
||||||
v-model="localView.updateOption"
|
|
||||||
type="radio"
|
|
||||||
name="update"
|
|
||||||
value="LOCAL"
|
|
||||||
>
|
|
||||||
<i class="form-icon" /> LOCAL
|
|
||||||
</label>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<div class="workspace-query-results column col-12 mt-2">
|
|
||||||
<label class="form-label ml-2">{{ $t('message.selectStatement') }}</label>
|
|
||||||
<QueryEditor
|
|
||||||
ref="queryEditor"
|
|
||||||
:value.sync="localView.sql"
|
|
||||||
:workspace="workspace"
|
|
||||||
:schema="schema"
|
|
||||||
:height="editorHeight"
|
|
||||||
/>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</ConfirmModal>
|
|
||||||
</template>
|
|
||||||
|
|
||||||
<script>
|
|
||||||
import ConfirmModal from '@/components/BaseConfirmModal';
|
|
||||||
import QueryEditor from '@/components/QueryEditor';
|
|
||||||
|
|
||||||
export default {
|
|
||||||
name: 'ModalNewView',
|
|
||||||
components: {
|
|
||||||
ConfirmModal,
|
|
||||||
QueryEditor
|
|
||||||
},
|
|
||||||
props: {
|
|
||||||
workspace: Object
|
|
||||||
},
|
|
||||||
data () {
|
|
||||||
return {
|
|
||||||
localView: {
|
|
||||||
algorithm: 'UNDEFINED',
|
|
||||||
definer: '',
|
|
||||||
security: 'DEFINER',
|
|
||||||
updateOption: '',
|
|
||||||
sql: '',
|
|
||||||
name: ''
|
|
||||||
},
|
|
||||||
isOptionsChanging: false,
|
|
||||||
editorHeight: 300
|
|
||||||
};
|
|
||||||
},
|
|
||||||
computed: {
|
|
||||||
schema () {
|
|
||||||
return this.workspace.breadcrumbs.schema;
|
|
||||||
}
|
|
||||||
},
|
|
||||||
mounted () {
|
|
||||||
setTimeout(() => {
|
|
||||||
this.$refs.firstInput.focus();
|
|
||||||
}, 20);
|
|
||||||
},
|
|
||||||
methods: {
|
|
||||||
confirmOptionsChange () {
|
|
||||||
this.$emit('open-create-view-editor', this.localView);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
};
|
|
||||||
</script>
|
|
@@ -83,7 +83,7 @@
|
|||||||
:scroll-element="scrollElement"
|
:scroll-element="scrollElement"
|
||||||
>
|
>
|
||||||
<template slot-scope="{ items }">
|
<template slot-scope="{ items }">
|
||||||
<ProcessesListRow
|
<ModalProcessesListRow
|
||||||
v-for="row in items"
|
v-for="row in items"
|
||||||
:key="row._id"
|
:key="row._id"
|
||||||
class="process-row"
|
class="process-row"
|
||||||
@@ -104,13 +104,13 @@
|
|||||||
import { mapGetters, mapActions } from 'vuex';
|
import { mapGetters, mapActions } from 'vuex';
|
||||||
import Schema from '@/ipc-api/Schema';
|
import Schema from '@/ipc-api/Schema';
|
||||||
import BaseVirtualScroll from '@/components/BaseVirtualScroll';
|
import BaseVirtualScroll from '@/components/BaseVirtualScroll';
|
||||||
import ProcessesListRow from '@/components/ProcessesListRow';
|
import ModalProcessesListRow from '@/components/ModalProcessesListRow';
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
name: 'ModalProcessesList',
|
name: 'ModalProcessesList',
|
||||||
components: {
|
components: {
|
||||||
BaseVirtualScroll,
|
BaseVirtualScroll,
|
||||||
ProcessesListRow
|
ModalProcessesListRow
|
||||||
},
|
},
|
||||||
props: {
|
props: {
|
||||||
connection: Object
|
connection: Object
|
||||||
|
@@ -11,7 +11,7 @@
|
|||||||
<template v-if="cKey !== '_id'">
|
<template v-if="cKey !== '_id'">
|
||||||
<span
|
<span
|
||||||
v-if="!isInlineEditor[cKey]"
|
v-if="!isInlineEditor[cKey]"
|
||||||
class="cell-content px-2"
|
class="cell-content"
|
||||||
:class="`${isNull(col)} type-${typeof col === 'number' ? 'int' : 'varchar'}`"
|
:class="`${isNull(col)} type-${typeof col === 'number' ? 'int' : 'varchar'}`"
|
||||||
@dblclick="dblClick(cKey)"
|
@dblclick="dblClick(cKey)"
|
||||||
>{{ col | cutText }}</span>
|
>{{ col | cutText }}</span>
|
||||||
@@ -51,7 +51,7 @@ import ConfirmModal from '@/components/BaseConfirmModal';
|
|||||||
import TextEditor from '@/components/BaseTextEditor';
|
import TextEditor from '@/components/BaseTextEditor';
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
name: 'ProcessesListRow',
|
name: 'ModalProcessesListRow',
|
||||||
components: {
|
components: {
|
||||||
ConfirmModal,
|
ConfirmModal,
|
||||||
TextEditor
|
TextEditor
|
||||||
@@ -126,6 +126,7 @@ export default {
|
|||||||
|
|
||||||
.cell-content {
|
.cell-content {
|
||||||
display: block;
|
display: block;
|
||||||
|
padding: 0 0.2rem;
|
||||||
min-height: 0.8rem;
|
min-height: 0.8rem;
|
||||||
text-overflow: ellipsis;
|
text-overflow: ellipsis;
|
||||||
white-space: nowrap;
|
white-space: nowrap;
|
@@ -68,6 +68,23 @@
|
|||||||
</span>
|
</span>
|
||||||
</a>
|
</a>
|
||||||
|
|
||||||
|
<a
|
||||||
|
v-else-if="tab.type === 'new-table'"
|
||||||
|
class="tab-link"
|
||||||
|
:class="{'badge': tab.isChanged}"
|
||||||
|
>
|
||||||
|
<i class="mdi mdi-shape-square-plus mdi-18px mr-1" />
|
||||||
|
<span :title="`${$t('word.new').toUpperCase()}: ${$tc(`word.${tab.elementType}`)}`">
|
||||||
|
{{ $t('message.newTable') }}
|
||||||
|
<span
|
||||||
|
class="btn btn-clear"
|
||||||
|
:title="$t('word.close')"
|
||||||
|
@mousedown.left.stop
|
||||||
|
@click.stop="closeTab(tab)"
|
||||||
|
/>
|
||||||
|
</span>
|
||||||
|
</a>
|
||||||
|
|
||||||
<a
|
<a
|
||||||
v-else-if="tab.type === 'table-props'"
|
v-else-if="tab.type === 'table-props'"
|
||||||
class="tab-link"
|
class="tab-link"
|
||||||
@@ -91,7 +108,7 @@
|
|||||||
:class="{'badge': tab.isChanged}"
|
:class="{'badge': tab.isChanged}"
|
||||||
>
|
>
|
||||||
<i class="mdi mdi-tune-vertical-variant mdi-18px mr-1" />
|
<i class="mdi mdi-tune-vertical-variant mdi-18px mr-1" />
|
||||||
<span :title="`${$t('word.settings').toUpperCase()}: ${$tc(`word.${tab.elementType}`)}`">
|
<span :title="`${$t('word.settings').toUpperCase()}: ${$tc(`word.view`)}`">
|
||||||
{{ tab.elementName | cutText }}
|
{{ tab.elementName | cutText }}
|
||||||
<span
|
<span
|
||||||
class="btn btn-clear"
|
class="btn btn-clear"
|
||||||
@@ -102,6 +119,108 @@
|
|||||||
</span>
|
</span>
|
||||||
</a>
|
</a>
|
||||||
|
|
||||||
|
<a
|
||||||
|
v-else-if="tab.type === 'new-view'"
|
||||||
|
class="tab-link"
|
||||||
|
:class="{'badge': tab.isChanged}"
|
||||||
|
>
|
||||||
|
<i class="mdi mdi-shape-square-plus mdi-18px mr-1" />
|
||||||
|
<span :title="`${$t('word.new').toUpperCase()}: ${$tc(`word.${tab.elementType}`)}`">
|
||||||
|
{{ $t('message.newView') }}
|
||||||
|
<span
|
||||||
|
class="btn btn-clear"
|
||||||
|
:title="$t('word.close')"
|
||||||
|
@mousedown.left.stop
|
||||||
|
@click.stop="closeTab(tab)"
|
||||||
|
/>
|
||||||
|
</span>
|
||||||
|
</a>
|
||||||
|
|
||||||
|
<a
|
||||||
|
v-else-if="tab.type === 'new-trigger'"
|
||||||
|
class="tab-link"
|
||||||
|
:class="{'badge': tab.isChanged}"
|
||||||
|
>
|
||||||
|
<i class="mdi mdi-shape-square-plus mdi-18px mr-1" />
|
||||||
|
<span :title="`${$t('word.new').toUpperCase()}: ${$tc(`word.${tab.elementType}`)}`">
|
||||||
|
{{ $t('message.newTrigger') }}
|
||||||
|
<span
|
||||||
|
class="btn btn-clear"
|
||||||
|
:title="$t('word.close')"
|
||||||
|
@mousedown.left.stop
|
||||||
|
@click.stop="closeTab(tab)"
|
||||||
|
/>
|
||||||
|
</span>
|
||||||
|
</a>
|
||||||
|
|
||||||
|
<a
|
||||||
|
v-else-if="tab.type === 'new-routine'"
|
||||||
|
class="tab-link"
|
||||||
|
:class="{'badge': tab.isChanged}"
|
||||||
|
>
|
||||||
|
<i class="mdi mdi-shape-square-plus mdi-18px mr-1" />
|
||||||
|
<span :title="`${$t('word.new').toUpperCase()}: ${$tc(`word.${tab.elementType}`)}`">
|
||||||
|
{{ $t('message.newRoutine') }}
|
||||||
|
<span
|
||||||
|
class="btn btn-clear"
|
||||||
|
:title="$t('word.close')"
|
||||||
|
@mousedown.left.stop
|
||||||
|
@click.stop="closeTab(tab)"
|
||||||
|
/>
|
||||||
|
</span>
|
||||||
|
</a>
|
||||||
|
|
||||||
|
<a
|
||||||
|
v-else-if="tab.type === 'new-function'"
|
||||||
|
class="tab-link"
|
||||||
|
:class="{'badge': tab.isChanged}"
|
||||||
|
>
|
||||||
|
<i class="mdi mdi-shape-square-plus mdi-18px mr-1" />
|
||||||
|
<span :title="`${$t('word.new').toUpperCase()}: ${$tc(`word.${tab.elementType}`)}`">
|
||||||
|
{{ $t('message.newFunction') }}
|
||||||
|
<span
|
||||||
|
class="btn btn-clear"
|
||||||
|
:title="$t('word.close')"
|
||||||
|
@mousedown.left.stop
|
||||||
|
@click.stop="closeTab(tab)"
|
||||||
|
/>
|
||||||
|
</span>
|
||||||
|
</a>
|
||||||
|
|
||||||
|
<a
|
||||||
|
v-else-if="tab.type === 'new-trigger-function'"
|
||||||
|
class="tab-link"
|
||||||
|
:class="{'badge': tab.isChanged}"
|
||||||
|
>
|
||||||
|
<i class="mdi mdi-shape-square-plus mdi-18px mr-1" />
|
||||||
|
<span :title="`${$t('word.new').toUpperCase()}: ${$tc(`word.${tab.elementType}`)}`">
|
||||||
|
{{ $t('message.newTriggerFunction') }}
|
||||||
|
<span
|
||||||
|
class="btn btn-clear"
|
||||||
|
:title="$t('word.close')"
|
||||||
|
@mousedown.left.stop
|
||||||
|
@click.stop="closeTab(tab)"
|
||||||
|
/>
|
||||||
|
</span>
|
||||||
|
</a>
|
||||||
|
|
||||||
|
<a
|
||||||
|
v-else-if="tab.type === 'new-scheduler'"
|
||||||
|
class="tab-link"
|
||||||
|
:class="{'badge': tab.isChanged}"
|
||||||
|
>
|
||||||
|
<i class="mdi mdi-shape-square-plus mdi-18px mr-1" />
|
||||||
|
<span :title="`${$t('word.new').toUpperCase()}: ${$tc(`word.${tab.elementType}`)}`">
|
||||||
|
{{ $t('message.newScheduler') }}
|
||||||
|
<span
|
||||||
|
class="btn btn-clear"
|
||||||
|
:title="$t('word.close')"
|
||||||
|
@mousedown.left.stop
|
||||||
|
@click.stop="closeTab(tab)"
|
||||||
|
/>
|
||||||
|
</span>
|
||||||
|
</a>
|
||||||
|
|
||||||
<a
|
<a
|
||||||
v-else-if="tab.type.includes('temp-')"
|
v-else-if="tab.type.includes('temp-')"
|
||||||
class="tab-link"
|
class="tab-link"
|
||||||
@@ -186,14 +305,14 @@
|
|||||||
</Draggable>
|
</Draggable>
|
||||||
<WorkspaceEmptyState v-if="!workspace.tabs.length" @new-tab="addQueryTab" />
|
<WorkspaceEmptyState v-if="!workspace.tabs.length" @new-tab="addQueryTab" />
|
||||||
<template v-for="tab of workspace.tabs">
|
<template v-for="tab of workspace.tabs">
|
||||||
<WorkspaceQueryTab
|
<WorkspaceTabQuery
|
||||||
v-if="tab.type==='query'"
|
v-if="tab.type==='query'"
|
||||||
:key="tab.uid"
|
:key="tab.uid"
|
||||||
:tab="tab"
|
:tab="tab"
|
||||||
:is-selected="selectedTab === tab.uid"
|
:is-selected="selectedTab === tab.uid"
|
||||||
:connection="connection"
|
:connection="connection"
|
||||||
/>
|
/>
|
||||||
<WorkspaceTableTab
|
<WorkspaceTabTable
|
||||||
v-else-if="['temp-data', 'data'].includes(tab.type)"
|
v-else-if="['temp-data', 'data'].includes(tab.type)"
|
||||||
:key="tab.uid"
|
:key="tab.uid"
|
||||||
:connection="connection"
|
:connection="connection"
|
||||||
@@ -202,7 +321,15 @@
|
|||||||
:schema="tab.schema"
|
:schema="tab.schema"
|
||||||
:element-type="tab.elementType"
|
:element-type="tab.elementType"
|
||||||
/>
|
/>
|
||||||
<WorkspacePropsTab
|
<WorkspaceTabNewTable
|
||||||
|
v-else-if="tab.type === 'new-table'"
|
||||||
|
:key="tab.uid"
|
||||||
|
:tab="tab"
|
||||||
|
:connection="connection"
|
||||||
|
:is-selected="selectedTab === tab.uid"
|
||||||
|
:schema="tab.schema"
|
||||||
|
/>
|
||||||
|
<WorkspaceTabPropsTable
|
||||||
v-else-if="tab.type === 'table-props'"
|
v-else-if="tab.type === 'table-props'"
|
||||||
:key="tab.uid"
|
:key="tab.uid"
|
||||||
:connection="connection"
|
:connection="connection"
|
||||||
@@ -210,7 +337,15 @@
|
|||||||
:table="tab.elementName"
|
:table="tab.elementName"
|
||||||
:schema="tab.schema"
|
:schema="tab.schema"
|
||||||
/>
|
/>
|
||||||
<WorkspacePropsTabView
|
<WorkspaceTabNewView
|
||||||
|
v-else-if="tab.type === 'new-view'"
|
||||||
|
:key="tab.uid"
|
||||||
|
:tab="tab"
|
||||||
|
:connection="connection"
|
||||||
|
:is-selected="selectedTab === tab.uid"
|
||||||
|
:schema="tab.schema"
|
||||||
|
/>
|
||||||
|
<WorkspaceTabPropsView
|
||||||
v-else-if="tab.type === 'view-props'"
|
v-else-if="tab.type === 'view-props'"
|
||||||
:key="tab.uid"
|
:key="tab.uid"
|
||||||
:is-selected="selectedTab === tab.uid"
|
:is-selected="selectedTab === tab.uid"
|
||||||
@@ -218,7 +353,16 @@
|
|||||||
:view="tab.elementName"
|
:view="tab.elementName"
|
||||||
:schema="tab.schema"
|
:schema="tab.schema"
|
||||||
/>
|
/>
|
||||||
<WorkspacePropsTabTrigger
|
<WorkspaceTabNewTrigger
|
||||||
|
v-else-if="tab.type === 'new-trigger'"
|
||||||
|
:key="tab.uid"
|
||||||
|
:tab="tab"
|
||||||
|
:connection="connection"
|
||||||
|
:is-selected="selectedTab === tab.uid"
|
||||||
|
:trigger="tab.elementName"
|
||||||
|
:schema="tab.schema"
|
||||||
|
/>
|
||||||
|
<WorkspaceTabPropsTrigger
|
||||||
v-else-if="['temp-trigger-props', 'trigger-props'].includes(tab.type)"
|
v-else-if="['temp-trigger-props', 'trigger-props'].includes(tab.type)"
|
||||||
:key="tab.uid"
|
:key="tab.uid"
|
||||||
:connection="connection"
|
:connection="connection"
|
||||||
@@ -226,7 +370,16 @@
|
|||||||
:trigger="tab.elementName"
|
:trigger="tab.elementName"
|
||||||
:schema="tab.schema"
|
:schema="tab.schema"
|
||||||
/>
|
/>
|
||||||
<WorkspacePropsTabTriggerFunction
|
<WorkspaceTabNewTriggerFunction
|
||||||
|
v-else-if="tab.type === 'new-trigger-function'"
|
||||||
|
:key="tab.uid"
|
||||||
|
:tab="tab"
|
||||||
|
:connection="connection"
|
||||||
|
:is-selected="selectedTab === tab.uid"
|
||||||
|
:trigger="tab.elementName"
|
||||||
|
:schema="tab.schema"
|
||||||
|
/>
|
||||||
|
<WorkspaceTabPropsTriggerFunction
|
||||||
v-else-if="['temp-trigger-function-props', 'trigger-function-props'].includes(tab.type)"
|
v-else-if="['temp-trigger-function-props', 'trigger-function-props'].includes(tab.type)"
|
||||||
:key="tab.uid"
|
:key="tab.uid"
|
||||||
:connection="connection"
|
:connection="connection"
|
||||||
@@ -234,7 +387,16 @@
|
|||||||
:function="tab.elementName"
|
:function="tab.elementName"
|
||||||
:schema="tab.schema"
|
:schema="tab.schema"
|
||||||
/>
|
/>
|
||||||
<WorkspacePropsTabRoutine
|
<WorkspaceTabNewRoutine
|
||||||
|
v-else-if="tab.type === 'new-routine'"
|
||||||
|
:key="tab.uid"
|
||||||
|
:tab="tab"
|
||||||
|
:connection="connection"
|
||||||
|
:is-selected="selectedTab === tab.uid"
|
||||||
|
:trigger="tab.elementName"
|
||||||
|
:schema="tab.schema"
|
||||||
|
/>
|
||||||
|
<WorkspaceTabPropsRoutine
|
||||||
v-else-if="['temp-routine-props', 'routine-props'].includes(tab.type)"
|
v-else-if="['temp-routine-props', 'routine-props'].includes(tab.type)"
|
||||||
:key="tab.uid"
|
:key="tab.uid"
|
||||||
:connection="connection"
|
:connection="connection"
|
||||||
@@ -242,7 +404,16 @@
|
|||||||
:routine="tab.elementName"
|
:routine="tab.elementName"
|
||||||
:schema="tab.schema"
|
:schema="tab.schema"
|
||||||
/>
|
/>
|
||||||
<WorkspacePropsTabFunction
|
<WorkspaceTabNewFunction
|
||||||
|
v-else-if="tab.type === 'new-function'"
|
||||||
|
:key="tab.uid"
|
||||||
|
:tab="tab"
|
||||||
|
:connection="connection"
|
||||||
|
:is-selected="selectedTab === tab.uid"
|
||||||
|
:trigger="tab.elementName"
|
||||||
|
:schema="tab.schema"
|
||||||
|
/>
|
||||||
|
<WorkspaceTabPropsFunction
|
||||||
v-else-if="['temp-function-props', 'function-props'].includes(tab.type)"
|
v-else-if="['temp-function-props', 'function-props'].includes(tab.type)"
|
||||||
:key="tab.uid"
|
:key="tab.uid"
|
||||||
:connection="connection"
|
:connection="connection"
|
||||||
@@ -250,7 +421,16 @@
|
|||||||
:function="tab.elementName"
|
:function="tab.elementName"
|
||||||
:schema="tab.schema"
|
:schema="tab.schema"
|
||||||
/>
|
/>
|
||||||
<WorkspacePropsTabScheduler
|
<WorkspaceTabNewScheduler
|
||||||
|
v-else-if="tab.type === 'new-scheduler'"
|
||||||
|
:key="tab.uid"
|
||||||
|
:tab="tab"
|
||||||
|
:connection="connection"
|
||||||
|
:is-selected="selectedTab === tab.uid"
|
||||||
|
:trigger="tab.elementName"
|
||||||
|
:schema="tab.schema"
|
||||||
|
/>
|
||||||
|
<WorkspaceTabPropsScheduler
|
||||||
v-else-if="['temp-scheduler-props', 'scheduler-props'].includes(tab.type)"
|
v-else-if="['temp-scheduler-props', 'scheduler-props'].includes(tab.type)"
|
||||||
:key="tab.uid"
|
:key="tab.uid"
|
||||||
:connection="connection"
|
:connection="connection"
|
||||||
@@ -282,15 +462,24 @@ import Connection from '@/ipc-api/Connection';
|
|||||||
import WorkspaceEmptyState from '@/components/WorkspaceEmptyState';
|
import WorkspaceEmptyState from '@/components/WorkspaceEmptyState';
|
||||||
import WorkspaceExploreBar from '@/components/WorkspaceExploreBar';
|
import WorkspaceExploreBar from '@/components/WorkspaceExploreBar';
|
||||||
import WorkspaceEditConnectionPanel from '@/components/WorkspaceEditConnectionPanel';
|
import WorkspaceEditConnectionPanel from '@/components/WorkspaceEditConnectionPanel';
|
||||||
import WorkspaceQueryTab from '@/components/WorkspaceQueryTab';
|
import WorkspaceTabQuery from '@/components/WorkspaceTabQuery';
|
||||||
import WorkspaceTableTab from '@/components/WorkspaceTableTab';
|
import WorkspaceTabTable from '@/components/WorkspaceTabTable';
|
||||||
import WorkspacePropsTab from '@/components/WorkspacePropsTab';
|
|
||||||
import WorkspacePropsTabView from '@/components/WorkspacePropsTabView';
|
import WorkspaceTabNewTable from '@/components/WorkspaceTabNewTable';
|
||||||
import WorkspacePropsTabTrigger from '@/components/WorkspacePropsTabTrigger';
|
import WorkspaceTabNewView from '@/components/WorkspaceTabNewView';
|
||||||
import WorkspacePropsTabTriggerFunction from '@/components/WorkspacePropsTabTriggerFunction';
|
import WorkspaceTabNewTrigger from '@/components/WorkspaceTabNewTrigger';
|
||||||
import WorkspacePropsTabRoutine from '@/components/WorkspacePropsTabRoutine';
|
import WorkspaceTabNewRoutine from '@/components/WorkspaceTabNewRoutine';
|
||||||
import WorkspacePropsTabFunction from '@/components/WorkspacePropsTabFunction';
|
import WorkspaceTabNewFunction from '@/components/WorkspaceTabNewFunction';
|
||||||
import WorkspacePropsTabScheduler from '@/components/WorkspacePropsTabScheduler';
|
import WorkspaceTabNewScheduler from '@/components/WorkspaceTabNewScheduler';
|
||||||
|
import WorkspaceTabNewTriggerFunction from '@/components/WorkspaceTabNewTriggerFunction';
|
||||||
|
|
||||||
|
import WorkspaceTabPropsTable from '@/components/WorkspaceTabPropsTable';
|
||||||
|
import WorkspaceTabPropsView from '@/components/WorkspaceTabPropsView';
|
||||||
|
import WorkspaceTabPropsTrigger from '@/components/WorkspaceTabPropsTrigger';
|
||||||
|
import WorkspaceTabPropsTriggerFunction from '@/components/WorkspaceTabPropsTriggerFunction';
|
||||||
|
import WorkspaceTabPropsRoutine from '@/components/WorkspaceTabPropsRoutine';
|
||||||
|
import WorkspaceTabPropsFunction from '@/components/WorkspaceTabPropsFunction';
|
||||||
|
import WorkspaceTabPropsScheduler from '@/components/WorkspaceTabPropsScheduler';
|
||||||
import ModalProcessesList from '@/components/ModalProcessesList';
|
import ModalProcessesList from '@/components/ModalProcessesList';
|
||||||
import ModalDiscardChanges from '@/components/ModalDiscardChanges';
|
import ModalDiscardChanges from '@/components/ModalDiscardChanges';
|
||||||
|
|
||||||
@@ -301,15 +490,22 @@ export default {
|
|||||||
WorkspaceEmptyState,
|
WorkspaceEmptyState,
|
||||||
WorkspaceExploreBar,
|
WorkspaceExploreBar,
|
||||||
WorkspaceEditConnectionPanel,
|
WorkspaceEditConnectionPanel,
|
||||||
WorkspaceQueryTab,
|
WorkspaceTabQuery,
|
||||||
WorkspaceTableTab,
|
WorkspaceTabTable,
|
||||||
WorkspacePropsTab,
|
WorkspaceTabNewTable,
|
||||||
WorkspacePropsTabView,
|
WorkspaceTabPropsTable,
|
||||||
WorkspacePropsTabTrigger,
|
WorkspaceTabNewView,
|
||||||
WorkspacePropsTabTriggerFunction,
|
WorkspaceTabPropsView,
|
||||||
WorkspacePropsTabRoutine,
|
WorkspaceTabNewTrigger,
|
||||||
WorkspacePropsTabFunction,
|
WorkspaceTabPropsTrigger,
|
||||||
WorkspacePropsTabScheduler,
|
WorkspaceTabNewTriggerFunction,
|
||||||
|
WorkspaceTabPropsTriggerFunction,
|
||||||
|
WorkspaceTabNewRoutine,
|
||||||
|
WorkspaceTabNewFunction,
|
||||||
|
WorkspaceTabPropsRoutine,
|
||||||
|
WorkspaceTabPropsFunction,
|
||||||
|
WorkspaceTabNewScheduler,
|
||||||
|
WorkspaceTabPropsScheduler,
|
||||||
ModalProcessesList,
|
ModalProcessesList,
|
||||||
ModalDiscardChanges
|
ModalDiscardChanges
|
||||||
},
|
},
|
||||||
@@ -589,7 +785,7 @@ export default {
|
|||||||
.th {
|
.th {
|
||||||
position: sticky;
|
position: sticky;
|
||||||
top: 0;
|
top: 0;
|
||||||
border: 1px solid;
|
border: 2px solid;
|
||||||
border-left: none;
|
border-left: none;
|
||||||
border-bottom-width: 2px;
|
border-bottom-width: 2px;
|
||||||
padding: 0;
|
padding: 0;
|
||||||
@@ -598,15 +794,15 @@ export default {
|
|||||||
z-index: 1;
|
z-index: 1;
|
||||||
|
|
||||||
> div {
|
> div {
|
||||||
padding: 0.1rem 0.4rem;
|
padding: 0.1rem 0.2rem;
|
||||||
min-width: -webkit-fill-available;
|
min-width: -webkit-fill-available;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
.td {
|
.td {
|
||||||
border-right: 1px solid;
|
border-right: 2px solid;
|
||||||
border-bottom: 1px solid;
|
border-bottom: 2px solid;
|
||||||
padding: 0 0.4rem;
|
padding: 0 0.2rem;
|
||||||
text-overflow: ellipsis;
|
text-overflow: ellipsis;
|
||||||
max-width: 200px;
|
max-width: 200px;
|
||||||
white-space: nowrap;
|
white-space: nowrap;
|
||||||
|
@@ -5,6 +5,9 @@
|
|||||||
ref="explorebar"
|
ref="explorebar"
|
||||||
class="workspace-explorebar column"
|
class="workspace-explorebar column"
|
||||||
:style="{width: localWidth ? localWidth+'px' : ''}"
|
:style="{width: localWidth ? localWidth+'px' : ''}"
|
||||||
|
tabindex="0"
|
||||||
|
@keypress="explorebarSearch"
|
||||||
|
@keydown="explorebarSearch"
|
||||||
>
|
>
|
||||||
<div class="workspace-explorebar-header">
|
<div class="workspace-explorebar-header">
|
||||||
<span class="workspace-explorebar-title">{{ connectionName }}</span>
|
<span class="workspace-explorebar-title">{{ connectionName }}</span>
|
||||||
@@ -30,6 +33,7 @@
|
|||||||
<div class="workspace-explorebar-search">
|
<div class="workspace-explorebar-search">
|
||||||
<div v-if="workspace.connectionStatus === 'connected'" class="has-icon-right">
|
<div v-if="workspace.connectionStatus === 'connected'" class="has-icon-right">
|
||||||
<input
|
<input
|
||||||
|
ref="searchInput"
|
||||||
v-model="searchTerm"
|
v-model="searchTerm"
|
||||||
class="form-input input-sm"
|
class="form-input input-sm"
|
||||||
type="text"
|
type="text"
|
||||||
@@ -43,7 +47,7 @@
|
|||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="workspace-explorebar-body">
|
<div class="workspace-explorebar-body" @click="$refs.explorebar.focus()">
|
||||||
<WorkspaceExploreBarSchema
|
<WorkspaceExploreBarSchema
|
||||||
v-for="db of workspace.structure"
|
v-for="db of workspace.structure"
|
||||||
:key="db.name"
|
:key="db.name"
|
||||||
@@ -61,67 +65,27 @@
|
|||||||
@close="hideNewDBModal"
|
@close="hideNewDBModal"
|
||||||
@reload="refresh"
|
@reload="refresh"
|
||||||
/>
|
/>
|
||||||
<ModalNewTable
|
|
||||||
v-if="isNewTableModal"
|
|
||||||
:workspace="workspace"
|
|
||||||
@close="hideCreateTableModal"
|
|
||||||
@open-create-table-editor="openCreateTableEditor"
|
|
||||||
/>
|
|
||||||
<ModalNewView
|
|
||||||
v-if="isNewViewModal"
|
|
||||||
:workspace="workspace"
|
|
||||||
@close="hideCreateViewModal"
|
|
||||||
@open-create-view-editor="openCreateViewEditor"
|
|
||||||
/>
|
|
||||||
<ModalNewTrigger
|
|
||||||
v-if="isNewTriggerModal"
|
|
||||||
:workspace="workspace"
|
|
||||||
@close="hideCreateTriggerModal"
|
|
||||||
@open-create-trigger-editor="openCreateTriggerEditor"
|
|
||||||
/>
|
|
||||||
<ModalNewRoutine
|
|
||||||
v-if="isNewRoutineModal"
|
|
||||||
:workspace="workspace"
|
|
||||||
@close="hideCreateRoutineModal"
|
|
||||||
@open-create-routine-editor="openCreateRoutineEditor"
|
|
||||||
/>
|
|
||||||
<ModalNewFunction
|
|
||||||
v-if="isNewFunctionModal"
|
|
||||||
:workspace="workspace"
|
|
||||||
@close="hideCreateFunctionModal"
|
|
||||||
@open-create-function-editor="openCreateFunctionEditor"
|
|
||||||
/>
|
|
||||||
<ModalNewTriggerFunction
|
|
||||||
v-if="isNewTriggerFunctionModal"
|
|
||||||
:workspace="workspace"
|
|
||||||
@close="hideCreateTriggerFunctionModal"
|
|
||||||
@open-create-function-editor="openCreateTriggerFunctionEditor"
|
|
||||||
/>
|
|
||||||
<ModalNewScheduler
|
|
||||||
v-if="isNewSchedulerModal"
|
|
||||||
:workspace="workspace"
|
|
||||||
@close="hideCreateSchedulerModal"
|
|
||||||
@open-create-scheduler-editor="openCreateSchedulerEditor"
|
|
||||||
/>
|
|
||||||
<DatabaseContext
|
<DatabaseContext
|
||||||
v-if="isDatabaseContext"
|
v-if="isDatabaseContext"
|
||||||
:selected-schema="selectedSchema"
|
:selected-schema="selectedSchema"
|
||||||
:context-event="databaseContextEvent"
|
:context-event="databaseContextEvent"
|
||||||
@close-context="closeDatabaseContext"
|
@close-context="closeDatabaseContext"
|
||||||
@show-create-table-modal="showCreateTableModal"
|
@open-create-table-tab="openCreateElementTab('table')"
|
||||||
@show-create-view-modal="showCreateViewModal"
|
@open-create-view-tab="openCreateElementTab('view')"
|
||||||
@show-create-trigger-modal="showCreateTriggerModal"
|
@open-create-trigger-tab="openCreateElementTab('trigger')"
|
||||||
@show-create-routine-modal="showCreateRoutineModal"
|
@open-create-routine-tab="openCreateElementTab('routine')"
|
||||||
@show-create-function-modal="showCreateFunctionModal"
|
@open-create-function-tab="openCreateElementTab('function')"
|
||||||
@show-create-trigger-function-modal="showCreateTriggerFunctionModal"
|
@open-create-trigger-function-tab="openCreateElementTab('trigger-function')"
|
||||||
@show-create-scheduler-modal="showCreateSchedulerModal"
|
@open-create-scheduler-tab="openCreateElementTab('scheduler')"
|
||||||
@reload="refresh"
|
@reload="refresh"
|
||||||
/>
|
/>
|
||||||
<TableContext
|
<TableContext
|
||||||
v-show="isTableContext"
|
v-if="isTableContext"
|
||||||
:selected-schema="selectedSchema"
|
:selected-schema="selectedSchema"
|
||||||
:selected-table="selectedTable"
|
:selected-table="selectedTable"
|
||||||
:context-event="tableContextEvent"
|
:context-event="tableContextEvent"
|
||||||
|
@delete-table="deleteTable"
|
||||||
|
@duplicate-table="duplicateTable"
|
||||||
@close-context="closeTableContext"
|
@close-context="closeTableContext"
|
||||||
@reload="refresh"
|
@reload="refresh"
|
||||||
/>
|
/>
|
||||||
@@ -138,11 +102,11 @@
|
|||||||
:selected-misc="selectedMisc"
|
:selected-misc="selectedMisc"
|
||||||
:selected-schema="selectedSchema"
|
:selected-schema="selectedSchema"
|
||||||
:context-event="miscContextEvent"
|
:context-event="miscContextEvent"
|
||||||
@show-create-trigger-modal="showCreateTriggerModal"
|
@open-create-trigger-tab="openCreateElementTab('trigger')"
|
||||||
@show-create-routine-modal="showCreateRoutineModal"
|
@open-create-routine-tab="openCreateElementTab('routine')"
|
||||||
@show-create-function-modal="showCreateFunctionModal"
|
@open-create-function-tab="openCreateElementTab('function')"
|
||||||
@show-create-trigger-function-modal="showCreateTriggerFunctionModal"
|
@open-create-trigger-function-tab="openCreateElementTab('trigger-function')"
|
||||||
@show-create-scheduler-modal="showCreateSchedulerModal"
|
@open-create-scheduler-tab="openCreateElementTab('scheduler')"
|
||||||
@close-context="closeMiscFolderContext"
|
@close-context="closeMiscFolderContext"
|
||||||
@reload="refresh"
|
@reload="refresh"
|
||||||
/>
|
/>
|
||||||
@@ -154,8 +118,6 @@ import { mapGetters, mapActions } from 'vuex';
|
|||||||
|
|
||||||
import Tables from '@/ipc-api/Tables';
|
import Tables from '@/ipc-api/Tables';
|
||||||
import Views from '@/ipc-api/Views';
|
import Views from '@/ipc-api/Views';
|
||||||
import Triggers from '@/ipc-api/Triggers';
|
|
||||||
import Routines from '@/ipc-api/Routines';
|
|
||||||
import Functions from '@/ipc-api/Functions';
|
import Functions from '@/ipc-api/Functions';
|
||||||
import Schedulers from '@/ipc-api/Schedulers';
|
import Schedulers from '@/ipc-api/Schedulers';
|
||||||
|
|
||||||
@@ -165,13 +127,6 @@ import TableContext from '@/components/WorkspaceExploreBarTableContext';
|
|||||||
import MiscContext from '@/components/WorkspaceExploreBarMiscContext';
|
import MiscContext from '@/components/WorkspaceExploreBarMiscContext';
|
||||||
import MiscFolderContext from '@/components/WorkspaceExploreBarMiscFolderContext';
|
import MiscFolderContext from '@/components/WorkspaceExploreBarMiscFolderContext';
|
||||||
import ModalNewSchema from '@/components/ModalNewSchema';
|
import ModalNewSchema from '@/components/ModalNewSchema';
|
||||||
import ModalNewTable from '@/components/ModalNewTable';
|
|
||||||
import ModalNewView from '@/components/ModalNewView';
|
|
||||||
import ModalNewTrigger from '@/components/ModalNewTrigger';
|
|
||||||
import ModalNewRoutine from '@/components/ModalNewRoutine';
|
|
||||||
import ModalNewFunction from '@/components/ModalNewFunction';
|
|
||||||
import ModalNewTriggerFunction from '@/components/ModalNewTriggerFunction';
|
|
||||||
import ModalNewScheduler from '@/components/ModalNewScheduler';
|
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
name: 'WorkspaceExploreBar',
|
name: 'WorkspaceExploreBar',
|
||||||
@@ -181,14 +136,7 @@ export default {
|
|||||||
TableContext,
|
TableContext,
|
||||||
MiscContext,
|
MiscContext,
|
||||||
MiscFolderContext,
|
MiscFolderContext,
|
||||||
ModalNewSchema,
|
ModalNewSchema
|
||||||
ModalNewTable,
|
|
||||||
ModalNewView,
|
|
||||||
ModalNewTrigger,
|
|
||||||
ModalNewRoutine,
|
|
||||||
ModalNewFunction,
|
|
||||||
ModalNewTriggerFunction,
|
|
||||||
ModalNewScheduler
|
|
||||||
},
|
},
|
||||||
props: {
|
props: {
|
||||||
connection: Object,
|
connection: Object,
|
||||||
@@ -199,7 +147,6 @@ export default {
|
|||||||
isRefreshing: false,
|
isRefreshing: false,
|
||||||
|
|
||||||
isNewDBModal: false,
|
isNewDBModal: false,
|
||||||
isNewTableModal: false,
|
|
||||||
isNewViewModal: false,
|
isNewViewModal: false,
|
||||||
isNewTriggerModal: false,
|
isNewTriggerModal: false,
|
||||||
isNewRoutineModal: false,
|
isNewRoutineModal: false,
|
||||||
@@ -280,9 +227,12 @@ export default {
|
|||||||
changeBreadcrumbs: 'workspaces/changeBreadcrumbs',
|
changeBreadcrumbs: 'workspaces/changeBreadcrumbs',
|
||||||
selectTab: 'workspaces/selectTab',
|
selectTab: 'workspaces/selectTab',
|
||||||
newTab: 'workspaces/newTab',
|
newTab: 'workspaces/newTab',
|
||||||
|
removeTabs: 'workspaces/removeTabs',
|
||||||
setSearchTerm: 'workspaces/setSearchTerm',
|
setSearchTerm: 'workspaces/setSearchTerm',
|
||||||
addNotification: 'notifications/addNotification',
|
addNotification: 'notifications/addNotification',
|
||||||
changeExplorebarSize: 'settings/changeExplorebarSize'
|
changeExplorebarSize: 'settings/changeExplorebarSize',
|
||||||
|
addLoadingElement: 'workspaces/addLoadingElement',
|
||||||
|
removeLoadingElement: 'workspaces/removeLoadingElement'
|
||||||
}),
|
}),
|
||||||
async refresh () {
|
async refresh () {
|
||||||
if (!this.isRefreshing) {
|
if (!this.isRefreshing) {
|
||||||
@@ -291,6 +241,19 @@ export default {
|
|||||||
this.isRefreshing = false;
|
this.isRefreshing = false;
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
explorebarSearch (e) {
|
||||||
|
if (e.code === 'Backspace') {
|
||||||
|
e.preventDefault();
|
||||||
|
if (this.searchTerm.length)
|
||||||
|
this.searchTerm = this.searchTerm.slice(0, -1);
|
||||||
|
else
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
else if (e.key.length > 1)// Prevent non-alphanumerics
|
||||||
|
return;
|
||||||
|
|
||||||
|
this.$refs.searchInput.focus();
|
||||||
|
},
|
||||||
resize (e) {
|
resize (e) {
|
||||||
const el = this.$refs.explorebar;
|
const el = this.$refs.explorebar;
|
||||||
let explorebarWidth = e.pageX - el.getBoundingClientRect().left;
|
let explorebarWidth = e.pageX - el.getBoundingClientRect().left;
|
||||||
@@ -307,34 +270,17 @@ export default {
|
|||||||
hideNewDBModal () {
|
hideNewDBModal () {
|
||||||
this.isNewDBModal = false;
|
this.isNewDBModal = false;
|
||||||
},
|
},
|
||||||
showCreateTableModal () {
|
openCreateElementTab (element) {
|
||||||
this.closeDatabaseContext();
|
this.closeDatabaseContext();
|
||||||
this.isNewTableModal = true;
|
this.closeMiscFolderContext();
|
||||||
},
|
|
||||||
hideCreateTableModal () {
|
this.newTab({
|
||||||
this.isNewTableModal = false;
|
uid: this.workspace.uid,
|
||||||
},
|
|
||||||
async openCreateTableEditor (payload) {
|
|
||||||
const params = {
|
|
||||||
uid: this.connection.uid,
|
|
||||||
schema: this.selectedSchema,
|
schema: this.selectedSchema,
|
||||||
...payload
|
elementName: '',
|
||||||
};
|
elementType: element,
|
||||||
|
type: `new-${element}`
|
||||||
const { status, response } = await Tables.createTable(params);
|
});
|
||||||
|
|
||||||
if (status === 'success') {
|
|
||||||
await this.refresh();
|
|
||||||
this.newTab({
|
|
||||||
uid: this.workspace.uid,
|
|
||||||
schema: this.selectedSchema,
|
|
||||||
elementName: payload.name,
|
|
||||||
elementType: 'table',
|
|
||||||
type: 'table-props'
|
|
||||||
});
|
|
||||||
}
|
|
||||||
else
|
|
||||||
this.addNotification({ status: 'error', message: response });
|
|
||||||
},
|
},
|
||||||
openSchemaContext (payload) {
|
openSchemaContext (payload) {
|
||||||
this.selectedSchema = payload.schema;
|
this.selectedSchema = payload.schema;
|
||||||
@@ -371,38 +317,6 @@ export default {
|
|||||||
closeMiscFolderContext () {
|
closeMiscFolderContext () {
|
||||||
this.isMiscFolderContext = false;
|
this.isMiscFolderContext = false;
|
||||||
},
|
},
|
||||||
showCreateViewModal () {
|
|
||||||
this.closeDatabaseContext();
|
|
||||||
this.closeMiscFolderContext();
|
|
||||||
this.isNewViewModal = true;
|
|
||||||
},
|
|
||||||
hideCreateViewModal () {
|
|
||||||
this.isNewViewModal = false;
|
|
||||||
},
|
|
||||||
async openCreateViewEditor (payload) {
|
|
||||||
const params = {
|
|
||||||
uid: this.connection.uid,
|
|
||||||
schema: this.selectedSchema,
|
|
||||||
...payload
|
|
||||||
};
|
|
||||||
|
|
||||||
const { status, response } = await Views.createView(params);
|
|
||||||
|
|
||||||
if (status === 'success') {
|
|
||||||
await this.refresh();
|
|
||||||
this.changeBreadcrumbs({ schema: this.selectedSchema, view: payload.name });
|
|
||||||
|
|
||||||
this.newTab({
|
|
||||||
uid: this.workspace.uid,
|
|
||||||
schema: this.selectedSchema,
|
|
||||||
elementName: payload.name,
|
|
||||||
elementType: 'view',
|
|
||||||
type: 'view-props'
|
|
||||||
});
|
|
||||||
}
|
|
||||||
else
|
|
||||||
this.addNotification({ status: 'error', message: response });
|
|
||||||
},
|
|
||||||
showCreateTriggerModal () {
|
showCreateTriggerModal () {
|
||||||
this.closeDatabaseContext();
|
this.closeDatabaseContext();
|
||||||
this.closeMiscFolderContext();
|
this.closeMiscFolderContext();
|
||||||
@@ -411,31 +325,6 @@ export default {
|
|||||||
hideCreateTriggerModal () {
|
hideCreateTriggerModal () {
|
||||||
this.isNewTriggerModal = false;
|
this.isNewTriggerModal = false;
|
||||||
},
|
},
|
||||||
async openCreateTriggerEditor (payload) {
|
|
||||||
const params = {
|
|
||||||
uid: this.connection.uid,
|
|
||||||
schema: this.selectedSchema,
|
|
||||||
...payload
|
|
||||||
};
|
|
||||||
|
|
||||||
const { status, response } = await Triggers.createTrigger(params);
|
|
||||||
|
|
||||||
if (status === 'success') {
|
|
||||||
await this.refresh();
|
|
||||||
const triggerName = this.customizations.triggerTableInName ? `${payload.table}.${payload.name}` : payload.name;
|
|
||||||
this.changeBreadcrumbs({ schema: this.selectedSchema, trigger: triggerName });
|
|
||||||
|
|
||||||
this.newTab({
|
|
||||||
uid: this.workspace.uid,
|
|
||||||
schema: this.selectedSchema,
|
|
||||||
elementName: triggerName,
|
|
||||||
elementType: 'trigger',
|
|
||||||
type: 'trigger-props'
|
|
||||||
});
|
|
||||||
}
|
|
||||||
else
|
|
||||||
this.addNotification({ status: 'error', message: response });
|
|
||||||
},
|
|
||||||
showCreateRoutineModal () {
|
showCreateRoutineModal () {
|
||||||
this.closeDatabaseContext();
|
this.closeDatabaseContext();
|
||||||
this.closeMiscFolderContext();
|
this.closeMiscFolderContext();
|
||||||
@@ -444,30 +333,6 @@ export default {
|
|||||||
hideCreateRoutineModal () {
|
hideCreateRoutineModal () {
|
||||||
this.isNewRoutineModal = false;
|
this.isNewRoutineModal = false;
|
||||||
},
|
},
|
||||||
async openCreateRoutineEditor (payload) {
|
|
||||||
const params = {
|
|
||||||
uid: this.connection.uid,
|
|
||||||
schema: this.selectedSchema,
|
|
||||||
...payload
|
|
||||||
};
|
|
||||||
|
|
||||||
const { status, response } = await Routines.createRoutine(params);
|
|
||||||
|
|
||||||
if (status === 'success') {
|
|
||||||
await this.refresh();
|
|
||||||
this.changeBreadcrumbs({ schema: this.selectedSchema, routine: payload.name });
|
|
||||||
|
|
||||||
this.newTab({
|
|
||||||
uid: this.workspace.uid,
|
|
||||||
schema: this.selectedSchema,
|
|
||||||
elementName: payload.name,
|
|
||||||
elementType: 'routine',
|
|
||||||
type: 'routine-props'
|
|
||||||
});
|
|
||||||
}
|
|
||||||
else
|
|
||||||
this.addNotification({ status: 'error', message: response });
|
|
||||||
},
|
|
||||||
showCreateFunctionModal () {
|
showCreateFunctionModal () {
|
||||||
this.closeDatabaseContext();
|
this.closeDatabaseContext();
|
||||||
this.closeMiscFolderContext();
|
this.closeMiscFolderContext();
|
||||||
@@ -492,6 +357,89 @@ export default {
|
|||||||
hideCreateSchedulerModal () {
|
hideCreateSchedulerModal () {
|
||||||
this.isNewSchedulerModal = false;
|
this.isNewSchedulerModal = false;
|
||||||
},
|
},
|
||||||
|
async deleteTable (payload) {
|
||||||
|
this.closeTableContext();
|
||||||
|
|
||||||
|
this.addLoadingElement({
|
||||||
|
name: payload.table.name,
|
||||||
|
schema: payload.schema,
|
||||||
|
type: 'table'
|
||||||
|
});
|
||||||
|
|
||||||
|
try {
|
||||||
|
let res;
|
||||||
|
|
||||||
|
if (payload.table.type === 'table') {
|
||||||
|
res = await Tables.dropTable({
|
||||||
|
uid: this.connection.uid,
|
||||||
|
table: payload.table.name,
|
||||||
|
schema: payload.schema
|
||||||
|
});
|
||||||
|
}
|
||||||
|
else if (payload.table.type === 'view') {
|
||||||
|
res = await Views.dropView({
|
||||||
|
uid: this.connection.uid,
|
||||||
|
view: payload.table.name,
|
||||||
|
schema: payload.schema
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
const { status, response } = res;
|
||||||
|
|
||||||
|
if (status === 'success') {
|
||||||
|
this.refresh();
|
||||||
|
|
||||||
|
this.removeTabs({
|
||||||
|
uid: this.connection.uid,
|
||||||
|
elementName: payload.table.name,
|
||||||
|
elementType: payload.table.type,
|
||||||
|
schema: payload.schema
|
||||||
|
});
|
||||||
|
}
|
||||||
|
else
|
||||||
|
this.addNotification({ status: 'error', message: response });
|
||||||
|
}
|
||||||
|
catch (err) {
|
||||||
|
this.addNotification({ status: 'error', message: err.stack });
|
||||||
|
}
|
||||||
|
|
||||||
|
this.removeLoadingElement({
|
||||||
|
name: payload.table.name,
|
||||||
|
schema: payload.schema,
|
||||||
|
type: 'table'
|
||||||
|
});
|
||||||
|
},
|
||||||
|
async duplicateTable (payload) {
|
||||||
|
this.closeTableContext();
|
||||||
|
|
||||||
|
this.addLoadingElement({
|
||||||
|
name: payload.table.name,
|
||||||
|
schema: payload.schema,
|
||||||
|
type: 'table'
|
||||||
|
});
|
||||||
|
|
||||||
|
try {
|
||||||
|
const { status, response } = await Tables.duplicateTable({
|
||||||
|
uid: this.connection.uid,
|
||||||
|
table: payload.table.name,
|
||||||
|
schema: payload.schema
|
||||||
|
});
|
||||||
|
|
||||||
|
if (status === 'success')
|
||||||
|
this.refresh();
|
||||||
|
else
|
||||||
|
this.addNotification({ status: 'error', message: response });
|
||||||
|
}
|
||||||
|
catch (err) {
|
||||||
|
this.addNotification({ status: 'error', message: err.stack });
|
||||||
|
}
|
||||||
|
|
||||||
|
this.removeLoadingElement({
|
||||||
|
name: payload.table.name,
|
||||||
|
schema: payload.schema,
|
||||||
|
type: 'table'
|
||||||
|
});
|
||||||
|
},
|
||||||
async openCreateFunctionEditor (payload) {
|
async openCreateFunctionEditor (payload) {
|
||||||
const params = {
|
const params = {
|
||||||
uid: this.connection.uid,
|
uid: this.connection.uid,
|
||||||
@@ -596,6 +544,10 @@ export default {
|
|||||||
position: relative;
|
position: relative;
|
||||||
padding: 0;
|
padding: 0;
|
||||||
|
|
||||||
|
&:focus {
|
||||||
|
outline: none;
|
||||||
|
}
|
||||||
|
|
||||||
.workspace-explorebar-header {
|
.workspace-explorebar-header {
|
||||||
width: 100%;
|
width: 100%;
|
||||||
padding: 0.3rem;
|
padding: 0.3rem;
|
||||||
|
@@ -101,9 +101,6 @@ export default {
|
|||||||
removeTabs: 'workspaces/removeTabs',
|
removeTabs: 'workspaces/removeTabs',
|
||||||
newTab: 'workspaces/newTab'
|
newTab: 'workspaces/newTab'
|
||||||
}),
|
}),
|
||||||
showCreateTableModal () {
|
|
||||||
this.$emit('show-create-table-modal');
|
|
||||||
},
|
|
||||||
showDeleteModal () {
|
showDeleteModal () {
|
||||||
this.isDeleteModal = true;
|
this.isDeleteModal = true;
|
||||||
},
|
},
|
||||||
|
@@ -6,35 +6,35 @@
|
|||||||
<div
|
<div
|
||||||
v-if="selectedMisc === 'trigger'"
|
v-if="selectedMisc === 'trigger'"
|
||||||
class="context-element"
|
class="context-element"
|
||||||
@click="$emit('show-create-trigger-modal')"
|
@click="$emit('open-create-trigger-tab')"
|
||||||
>
|
>
|
||||||
<span class="d-flex"><i class="mdi mdi-18px mdi-table-cog text-light pr-1" /> {{ $t('message.createNewTrigger') }}</span>
|
<span class="d-flex"><i class="mdi mdi-18px mdi-table-cog text-light pr-1" /> {{ $t('message.createNewTrigger') }}</span>
|
||||||
</div>
|
</div>
|
||||||
<div
|
<div
|
||||||
v-if="selectedMisc === 'procedure'"
|
v-if="selectedMisc === 'procedure'"
|
||||||
class="context-element"
|
class="context-element"
|
||||||
@click="$emit('show-create-routine-modal')"
|
@click="$emit('open-create-routine-tab')"
|
||||||
>
|
>
|
||||||
<span class="d-flex"><i class="mdi mdi-18px mdi-sync-circle text-light pr-1" /> {{ $t('message.createNewRoutine') }}</span>
|
<span class="d-flex"><i class="mdi mdi-18px mdi-sync-circle text-light pr-1" /> {{ $t('message.createNewRoutine') }}</span>
|
||||||
</div>
|
</div>
|
||||||
<div
|
<div
|
||||||
v-if="selectedMisc === 'function'"
|
v-if="selectedMisc === 'function'"
|
||||||
class="context-element"
|
class="context-element"
|
||||||
@click="$emit('show-create-function-modal')"
|
@click="$emit('open-create-function-tab')"
|
||||||
>
|
>
|
||||||
<span class="d-flex"><i class="mdi mdi-18px mdi-arrow-right-bold-box text-light pr-1" /> {{ $t('message.createNewFunction') }}</span>
|
<span class="d-flex"><i class="mdi mdi-18px mdi-arrow-right-bold-box text-light pr-1" /> {{ $t('message.createNewFunction') }}</span>
|
||||||
</div>
|
</div>
|
||||||
<div
|
<div
|
||||||
v-if="selectedMisc === 'triggerFunction'"
|
v-if="selectedMisc === 'triggerFunction'"
|
||||||
class="context-element"
|
class="context-element"
|
||||||
@click="$emit('show-create-trigger-function-modal')"
|
@click="$emit('open-create-trigger-function-tab')"
|
||||||
>
|
>
|
||||||
<span class="d-flex"><i class="mdi mdi-18px mdi-cog-clockwise text-light pr-1" /> {{ $t('message.createNewFunction') }}</span>
|
<span class="d-flex"><i class="mdi mdi-18px mdi-cog-clockwise text-light pr-1" /> {{ $t('message.createNewFunction') }}</span>
|
||||||
</div>
|
</div>
|
||||||
<div
|
<div
|
||||||
v-if="selectedMisc === 'scheduler'"
|
v-if="selectedMisc === 'scheduler'"
|
||||||
class="context-element"
|
class="context-element"
|
||||||
@click="$emit('show-create-scheduler-modal')"
|
@click="$emit('open-create-scheduler-tab')"
|
||||||
>
|
>
|
||||||
<span class="d-flex"><i class="mdi mdi-18px mdi-calendar-clock text-light pr-1" /> {{ $t('message.createNewScheduler') }}</span>
|
<span class="d-flex"><i class="mdi mdi-18px mdi-calendar-clock text-light pr-1" /> {{ $t('message.createNewScheduler') }}</span>
|
||||||
</div>
|
</div>
|
||||||
@@ -74,9 +74,6 @@ export default {
|
|||||||
addNotification: 'notifications/addNotification',
|
addNotification: 'notifications/addNotification',
|
||||||
changeBreadcrumbs: 'workspaces/changeBreadcrumbs'
|
changeBreadcrumbs: 'workspaces/changeBreadcrumbs'
|
||||||
}),
|
}),
|
||||||
showCreateTableModal () {
|
|
||||||
this.$emit('show-create-table-modal');
|
|
||||||
},
|
|
||||||
showDeleteModal () {
|
showDeleteModal () {
|
||||||
this.isDeleteModal = true;
|
this.isDeleteModal = true;
|
||||||
},
|
},
|
||||||
|
@@ -63,7 +63,7 @@
|
|||||||
:ref="breadcrumbs.schema === database.name && breadcrumbs.trigger === trigger.name ? 'explorebar-selected' : ''"
|
:ref="breadcrumbs.schema === database.name && breadcrumbs.trigger === trigger.name ? 'explorebar-selected' : ''"
|
||||||
class="menu-item"
|
class="menu-item"
|
||||||
:class="{'selected': breadcrumbs.schema === database.name && breadcrumbs.trigger === trigger.name}"
|
:class="{'selected': breadcrumbs.schema === database.name && breadcrumbs.trigger === trigger.name}"
|
||||||
@mousedown="selectMisc({schema: database.name, misc: trigger, type: 'trigger'})"
|
@mousedown.left="selectMisc({schema: database.name, misc: trigger, type: 'trigger'})"
|
||||||
@dblclick="openMiscPermanentTab({schema: database.name, misc: trigger, type: 'trigger'})"
|
@dblclick="openMiscPermanentTab({schema: database.name, misc: trigger, type: 'trigger'})"
|
||||||
@contextmenu.prevent="showMiscContext($event, {...trigger, type: 'trigger'})"
|
@contextmenu.prevent="showMiscContext($event, {...trigger, type: 'trigger'})"
|
||||||
>
|
>
|
||||||
@@ -97,7 +97,7 @@
|
|||||||
:ref="breadcrumbs.schema === database.name && breadcrumbs.routine === procedure.name ? 'explorebar-selected' : ''"
|
:ref="breadcrumbs.schema === database.name && breadcrumbs.routine === procedure.name ? 'explorebar-selected' : ''"
|
||||||
class="menu-item"
|
class="menu-item"
|
||||||
:class="{'selected': breadcrumbs.schema === database.name && breadcrumbs.routine === procedure.name}"
|
:class="{'selected': breadcrumbs.schema === database.name && breadcrumbs.routine === procedure.name}"
|
||||||
@mousedown="selectMisc({schema: database.name, misc: procedure, type: 'routine'})"
|
@mousedown.left="selectMisc({schema: database.name, misc: procedure, type: 'routine'})"
|
||||||
@dblclick="openMiscPermanentTab({schema: database.name, misc: procedure, type: 'routine'})"
|
@dblclick="openMiscPermanentTab({schema: database.name, misc: procedure, type: 'routine'})"
|
||||||
@contextmenu.prevent="showMiscContext($event, {...procedure, type: 'procedure'})"
|
@contextmenu.prevent="showMiscContext($event, {...procedure, type: 'procedure'})"
|
||||||
>
|
>
|
||||||
@@ -131,7 +131,7 @@
|
|||||||
:ref="breadcrumbs.schema === database.name && breadcrumbs.triggerFunction === func.name ? 'explorebar-selected' : ''"
|
:ref="breadcrumbs.schema === database.name && breadcrumbs.triggerFunction === func.name ? 'explorebar-selected' : ''"
|
||||||
class="menu-item"
|
class="menu-item"
|
||||||
:class="{'selected': breadcrumbs.schema === database.name && breadcrumbs.triggerFunction === func.name}"
|
:class="{'selected': breadcrumbs.schema === database.name && breadcrumbs.triggerFunction === func.name}"
|
||||||
@mousedown="selectMisc({schema: database.name, misc: func, type: 'triggerFunction'})"
|
@mousedown.left="selectMisc({schema: database.name, misc: func, type: 'triggerFunction'})"
|
||||||
@dblclick="openMiscPermanentTab({schema: database.name, misc: func, type: 'triggerFunction'})"
|
@dblclick="openMiscPermanentTab({schema: database.name, misc: func, type: 'triggerFunction'})"
|
||||||
@contextmenu.prevent="showMiscContext($event, {...func, type: 'triggerFunction'})"
|
@contextmenu.prevent="showMiscContext($event, {...func, type: 'triggerFunction'})"
|
||||||
>
|
>
|
||||||
@@ -165,7 +165,7 @@
|
|||||||
:ref="breadcrumbs.schema === database.name && breadcrumbs.function === func.name ? 'explorebar-selected' : ''"
|
:ref="breadcrumbs.schema === database.name && breadcrumbs.function === func.name ? 'explorebar-selected' : ''"
|
||||||
class="menu-item"
|
class="menu-item"
|
||||||
:class="{'selected': breadcrumbs.schema === database.name && breadcrumbs.function === func.name}"
|
:class="{'selected': breadcrumbs.schema === database.name && breadcrumbs.function === func.name}"
|
||||||
@mousedown="selectMisc({schema: database.name, misc: func, type: 'function'})"
|
@mousedown.left="selectMisc({schema: database.name, misc: func, type: 'function'})"
|
||||||
@dblclick="openMiscPermanentTab({schema: database.name, misc: func, type: 'function'})"
|
@dblclick="openMiscPermanentTab({schema: database.name, misc: func, type: 'function'})"
|
||||||
@contextmenu.prevent="showMiscContext($event, {...func, type: 'function'})"
|
@contextmenu.prevent="showMiscContext($event, {...func, type: 'function'})"
|
||||||
>
|
>
|
||||||
@@ -199,7 +199,7 @@
|
|||||||
:ref="breadcrumbs.schema === database.name && breadcrumbs.scheduler === scheduler.name ? 'explorebar-selected' : ''"
|
:ref="breadcrumbs.schema === database.name && breadcrumbs.scheduler === scheduler.name ? 'explorebar-selected' : ''"
|
||||||
class="menu-item"
|
class="menu-item"
|
||||||
:class="{'selected': breadcrumbs.schema === database.name && breadcrumbs.scheduler === scheduler.name}"
|
:class="{'selected': breadcrumbs.schema === database.name && breadcrumbs.scheduler === scheduler.name}"
|
||||||
@mousedown="selectMisc({schema: database.name, misc: scheduler, type: 'scheduler'})"
|
@mousedown.left="selectMisc({schema: database.name, misc: scheduler, type: 'scheduler'})"
|
||||||
@dblclick="openMiscPermanentTab({schema: database.name, misc: scheduler, type: 'scheduler'})"
|
@dblclick="openMiscPermanentTab({schema: database.name, misc: scheduler, type: 'scheduler'})"
|
||||||
@contextmenu.prevent="showMiscContext($event, {...scheduler, type: 'scheduler'})"
|
@contextmenu.prevent="showMiscContext($event, {...scheduler, type: 'scheduler'})"
|
||||||
>
|
>
|
||||||
@@ -320,11 +320,16 @@ export default {
|
|||||||
this.addLoadedSchema(schema);
|
this.addLoadedSchema(schema);
|
||||||
this.isLoading = false;
|
this.isLoading = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
this.changeBreadcrumbs({ schema, table: null });
|
|
||||||
},
|
},
|
||||||
selectTable ({ schema, table }) {
|
selectTable ({ schema, table }) {
|
||||||
this.newTab({ uid: this.connection.uid, elementName: table.name, schema: this.database.name, type: 'temp-data', elementType: table.type });
|
this.newTab({
|
||||||
|
uid: this.connection.uid,
|
||||||
|
elementName: table.name,
|
||||||
|
schema: this.database.name,
|
||||||
|
type: 'temp-data',
|
||||||
|
elementType: table.type
|
||||||
|
});
|
||||||
|
|
||||||
this.setBreadcrumbs({ schema, [table.type]: table.name });
|
this.setBreadcrumbs({ schema, [table.type]: table.name });
|
||||||
},
|
},
|
||||||
selectMisc ({ schema, misc, type }) {
|
selectMisc ({ schema, misc, type }) {
|
||||||
|
@@ -10,49 +10,49 @@
|
|||||||
<div
|
<div
|
||||||
v-if="workspace.customizations.tableAdd"
|
v-if="workspace.customizations.tableAdd"
|
||||||
class="context-element"
|
class="context-element"
|
||||||
@click="showCreateTableModal"
|
@click="openCreateTableTab"
|
||||||
>
|
>
|
||||||
<span class="d-flex"><i class="mdi mdi-18px mdi-table text-light pr-1" /> {{ $t('word.table') }}</span>
|
<span class="d-flex"><i class="mdi mdi-18px mdi-table text-light pr-1" /> {{ $t('word.table') }}</span>
|
||||||
</div>
|
</div>
|
||||||
<div
|
<div
|
||||||
v-if="workspace.customizations.viewAdd"
|
v-if="workspace.customizations.viewAdd"
|
||||||
class="context-element"
|
class="context-element"
|
||||||
@click="showCreateViewModal"
|
@click="openCreateViewTab"
|
||||||
>
|
>
|
||||||
<span class="d-flex"><i class="mdi mdi-18px mdi-table-eye text-light pr-1" /> {{ $t('word.view') }}</span>
|
<span class="d-flex"><i class="mdi mdi-18px mdi-table-eye text-light pr-1" /> {{ $t('word.view') }}</span>
|
||||||
</div>
|
</div>
|
||||||
<div
|
<div
|
||||||
v-if="workspace.customizations.triggerAdd"
|
v-if="workspace.customizations.triggerAdd"
|
||||||
class="context-element"
|
class="context-element"
|
||||||
@click="showCreateTriggerModal"
|
@click="openCreateTriggerTab"
|
||||||
>
|
>
|
||||||
<span class="d-flex"><i class="mdi mdi-18px mdi-table-cog text-light pr-1" /> {{ $tc('word.trigger', 1) }}</span>
|
<span class="d-flex"><i class="mdi mdi-18px mdi-table-cog text-light pr-1" /> {{ $tc('word.trigger', 1) }}</span>
|
||||||
</div>
|
</div>
|
||||||
<div
|
<div
|
||||||
v-if="workspace.customizations.routineAdd"
|
v-if="workspace.customizations.routineAdd"
|
||||||
class="context-element"
|
class="context-element"
|
||||||
@click="showCreateRoutineModal"
|
@click="openCreateRoutineTab"
|
||||||
>
|
>
|
||||||
<span class="d-flex"><i class="mdi mdi-18px mdi-sync-circle pr-1" /> {{ $tc('word.storedRoutine', 1) }}</span>
|
<span class="d-flex"><i class="mdi mdi-18px mdi-sync-circle pr-1" /> {{ $tc('word.storedRoutine', 1) }}</span>
|
||||||
</div>
|
</div>
|
||||||
<div
|
<div
|
||||||
v-if="workspace.customizations.functionAdd"
|
v-if="workspace.customizations.functionAdd"
|
||||||
class="context-element"
|
class="context-element"
|
||||||
@click="showCreateFunctionModal"
|
@click="openCreateFunctionTab"
|
||||||
>
|
>
|
||||||
<span class="d-flex"><i class="mdi mdi-18px mdi-arrow-right-bold-box pr-1" /> {{ $tc('word.function', 1) }}</span>
|
<span class="d-flex"><i class="mdi mdi-18px mdi-arrow-right-bold-box pr-1" /> {{ $tc('word.function', 1) }}</span>
|
||||||
</div>
|
</div>
|
||||||
<div
|
<div
|
||||||
v-if="workspace.customizations.triggerFunctionAdd"
|
v-if="workspace.customizations.triggerFunctionAdd"
|
||||||
class="context-element"
|
class="context-element"
|
||||||
@click="showCreateTriggerFunctionModal"
|
@click="openCreateTriggerFunctionTab"
|
||||||
>
|
>
|
||||||
<span class="d-flex"><i class="mdi mdi-18px mdi-cog-clockwise pr-1" /> {{ $tc('word.triggerFunction', 1) }}</span>
|
<span class="d-flex"><i class="mdi mdi-18px mdi-cog-clockwise pr-1" /> {{ $tc('word.triggerFunction', 1) }}</span>
|
||||||
</div>
|
</div>
|
||||||
<div
|
<div
|
||||||
v-if="workspace.customizations.schedulerAdd"
|
v-if="workspace.customizations.schedulerAdd"
|
||||||
class="context-element"
|
class="context-element"
|
||||||
@click="showCreateSchedulerModal"
|
@click="openCreateSchedulerTab"
|
||||||
>
|
>
|
||||||
<span class="d-flex"><i class="mdi mdi-18px mdi-calendar-clock text-light pr-1" /> {{ $tc('word.scheduler', 1) }}</span>
|
<span class="d-flex"><i class="mdi mdi-18px mdi-calendar-clock text-light pr-1" /> {{ $tc('word.scheduler', 1) }}</span>
|
||||||
</div>
|
</div>
|
||||||
@@ -132,26 +132,26 @@ export default {
|
|||||||
addNotification: 'notifications/addNotification',
|
addNotification: 'notifications/addNotification',
|
||||||
changeBreadcrumbs: 'workspaces/changeBreadcrumbs'
|
changeBreadcrumbs: 'workspaces/changeBreadcrumbs'
|
||||||
}),
|
}),
|
||||||
showCreateTableModal () {
|
openCreateTableTab () {
|
||||||
this.$emit('show-create-table-modal');
|
this.$emit('open-create-table-tab');
|
||||||
},
|
},
|
||||||
showCreateViewModal () {
|
openCreateViewTab () {
|
||||||
this.$emit('show-create-view-modal');
|
this.$emit('open-create-view-tab');
|
||||||
},
|
},
|
||||||
showCreateTriggerModal () {
|
openCreateTriggerTab () {
|
||||||
this.$emit('show-create-trigger-modal');
|
this.$emit('open-create-trigger-tab');
|
||||||
},
|
},
|
||||||
showCreateRoutineModal () {
|
openCreateRoutineTab () {
|
||||||
this.$emit('show-create-routine-modal');
|
this.$emit('open-create-routine-tab');
|
||||||
},
|
},
|
||||||
showCreateFunctionModal () {
|
openCreateFunctionTab () {
|
||||||
this.$emit('show-create-function-modal');
|
this.$emit('open-create-function-tab');
|
||||||
},
|
},
|
||||||
showCreateTriggerFunctionModal () {
|
openCreateTriggerFunctionTab () {
|
||||||
this.$emit('show-create-trigger-function-modal');
|
this.$emit('open-create-trigger-function-tab');
|
||||||
},
|
},
|
||||||
showCreateSchedulerModal () {
|
openCreateSchedulerTab () {
|
||||||
this.$emit('show-create-scheduler-modal');
|
this.$emit('open-create-scheduler-tab');
|
||||||
},
|
},
|
||||||
showDeleteModal () {
|
showDeleteModal () {
|
||||||
this.isDeleteModal = true;
|
this.isDeleteModal = true;
|
||||||
|
@@ -76,7 +76,6 @@ import { mapGetters, mapActions } from 'vuex';
|
|||||||
import BaseContextMenu from '@/components/BaseContextMenu';
|
import BaseContextMenu from '@/components/BaseContextMenu';
|
||||||
import ConfirmModal from '@/components/BaseConfirmModal';
|
import ConfirmModal from '@/components/BaseConfirmModal';
|
||||||
import Tables from '@/ipc-api/Tables';
|
import Tables from '@/ipc-api/Tables';
|
||||||
import Views from '@/ipc-api/Views';
|
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
name: 'WorkspaceExploreBarTableContext',
|
name: 'WorkspaceExploreBarTableContext',
|
||||||
@@ -116,9 +115,6 @@ export default {
|
|||||||
removeLoadingElement: 'workspaces/removeLoadingElement',
|
removeLoadingElement: 'workspaces/removeLoadingElement',
|
||||||
changeBreadcrumbs: 'workspaces/changeBreadcrumbs'
|
changeBreadcrumbs: 'workspaces/changeBreadcrumbs'
|
||||||
}),
|
}),
|
||||||
showCreateTableModal () {
|
|
||||||
this.$emit('show-create-table-modal');
|
|
||||||
},
|
|
||||||
showDeleteModal () {
|
showDeleteModal () {
|
||||||
this.isDeleteModal = true;
|
this.isDeleteModal = true;
|
||||||
},
|
},
|
||||||
@@ -166,36 +162,8 @@ export default {
|
|||||||
|
|
||||||
this.closeContext();
|
this.closeContext();
|
||||||
},
|
},
|
||||||
async duplicateTable () {
|
duplicateTable () {
|
||||||
this.closeContext();
|
this.$emit('duplicate-table', { schema: this.selectedSchema, table: this.selectedTable });
|
||||||
|
|
||||||
this.addLoadingElement({
|
|
||||||
name: this.selectedTable.name,
|
|
||||||
schema: this.selectedSchema,
|
|
||||||
type: 'table'
|
|
||||||
});
|
|
||||||
|
|
||||||
try {
|
|
||||||
const { status, response } = await Tables.duplicateTable({
|
|
||||||
uid: this.selectedWorkspace,
|
|
||||||
table: this.selectedTable.name,
|
|
||||||
schema: this.selectedSchema
|
|
||||||
});
|
|
||||||
|
|
||||||
if (status === 'success')
|
|
||||||
this.$emit('reload');
|
|
||||||
else
|
|
||||||
this.addNotification({ status: 'error', message: response });
|
|
||||||
}
|
|
||||||
catch (err) {
|
|
||||||
this.addNotification({ status: 'error', message: err.stack });
|
|
||||||
}
|
|
||||||
|
|
||||||
this.removeLoadingElement({
|
|
||||||
name: this.selectedTable.name,
|
|
||||||
schema: this.selectedSchema,
|
|
||||||
type: 'table'
|
|
||||||
});
|
|
||||||
},
|
},
|
||||||
async emptyTable () {
|
async emptyTable () {
|
||||||
this.closeContext();
|
this.closeContext();
|
||||||
@@ -228,57 +196,8 @@ export default {
|
|||||||
type: 'table'
|
type: 'table'
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
async deleteTable () {
|
deleteTable () {
|
||||||
this.closeContext();
|
this.$emit('delete-table', { schema: this.selectedSchema, table: this.selectedTable });
|
||||||
|
|
||||||
this.addLoadingElement({
|
|
||||||
name: this.selectedTable.name,
|
|
||||||
schema: this.selectedSchema,
|
|
||||||
type: 'table'
|
|
||||||
});
|
|
||||||
|
|
||||||
try {
|
|
||||||
let res;
|
|
||||||
|
|
||||||
if (this.selectedTable.type === 'table') {
|
|
||||||
res = await Tables.dropTable({
|
|
||||||
uid: this.selectedWorkspace,
|
|
||||||
table: this.selectedTable.name,
|
|
||||||
schema: this.selectedSchema
|
|
||||||
});
|
|
||||||
}
|
|
||||||
else if (this.selectedTable.type === 'view') {
|
|
||||||
res = await Views.dropView({
|
|
||||||
uid: this.selectedWorkspace,
|
|
||||||
view: this.selectedTable.name,
|
|
||||||
schema: this.selectedSchema
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
const { status, response } = res;
|
|
||||||
|
|
||||||
if (status === 'success') {
|
|
||||||
this.removeTabs({
|
|
||||||
uid: this.selectedWorkspace,
|
|
||||||
elementName: this.selectedTable.name,
|
|
||||||
elementType: this.selectedTable.type,
|
|
||||||
schema: this.selectedSchema
|
|
||||||
});
|
|
||||||
|
|
||||||
this.$emit('reload');
|
|
||||||
}
|
|
||||||
else
|
|
||||||
this.addNotification({ status: 'error', message: response });
|
|
||||||
}
|
|
||||||
catch (err) {
|
|
||||||
this.addNotification({ status: 'error', message: err.stack });
|
|
||||||
}
|
|
||||||
|
|
||||||
this.removeLoadingElement({
|
|
||||||
name: this.selectedTable.name,
|
|
||||||
schema: this.selectedSchema,
|
|
||||||
type: 'table'
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
@@ -1,213 +0,0 @@
|
|||||||
<template>
|
|
||||||
<ConfirmModal
|
|
||||||
:confirm-text="$t('word.confirm')"
|
|
||||||
size="400"
|
|
||||||
@confirm="confirmOptionsChange"
|
|
||||||
@hide="$emit('hide')"
|
|
||||||
>
|
|
||||||
<template :slot="'header'">
|
|
||||||
<div class="d-flex">
|
|
||||||
<i class="mdi mdi-24px mdi-cogs mr-1" />
|
|
||||||
<span class="cut-text">{{ $t('word.options') }} "{{ localOptions.name }}"</span>
|
|
||||||
</div>
|
|
||||||
</template>
|
|
||||||
<div :slot="'body'">
|
|
||||||
<form class="form-horizontal">
|
|
||||||
<div class="form-group">
|
|
||||||
<label class="form-label col-4">
|
|
||||||
{{ $t('word.name') }}
|
|
||||||
</label>
|
|
||||||
<div class="column">
|
|
||||||
<input
|
|
||||||
ref="firstInput"
|
|
||||||
v-model="optionsProxy.name"
|
|
||||||
class="form-input"
|
|
||||||
:class="{'is-error': !isTableNameValid}"
|
|
||||||
type="text"
|
|
||||||
>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<div v-if="customizations.languages" class="form-group">
|
|
||||||
<label class="form-label col-4">
|
|
||||||
{{ $t('word.language') }}
|
|
||||||
</label>
|
|
||||||
<div class="column">
|
|
||||||
<select v-model="optionsProxy.language" class="form-select">
|
|
||||||
<option v-for="language in customizations.languages" :key="language">
|
|
||||||
{{ language }}
|
|
||||||
</option>
|
|
||||||
</select>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<div v-if="customizations.definer" class="form-group">
|
|
||||||
<label class="form-label col-4">
|
|
||||||
{{ $t('word.definer') }}
|
|
||||||
</label>
|
|
||||||
<div class="column">
|
|
||||||
<select
|
|
||||||
v-if="workspace.users.length"
|
|
||||||
v-model="optionsProxy.definer"
|
|
||||||
class="form-select"
|
|
||||||
>
|
|
||||||
<option value="">
|
|
||||||
{{ $t('message.currentUser') }}
|
|
||||||
</option>
|
|
||||||
<option
|
|
||||||
v-for="user in workspace.users"
|
|
||||||
:key="`${user.name}@${user.host}`"
|
|
||||||
:value="`\`${user.name}\`@\`${user.host}\``"
|
|
||||||
>
|
|
||||||
{{ user.name }}@{{ user.host }}
|
|
||||||
</option>
|
|
||||||
</select>
|
|
||||||
<select v-if="!workspace.users.length" class="form-select">
|
|
||||||
<option value="">
|
|
||||||
{{ $t('message.currentUser') }}
|
|
||||||
</option>
|
|
||||||
</select>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<div class="form-group">
|
|
||||||
<label class="form-label col-4">
|
|
||||||
{{ $t('word.returns') }}
|
|
||||||
</label>
|
|
||||||
<div class="column">
|
|
||||||
<div class="input-group">
|
|
||||||
<select
|
|
||||||
v-model="optionsProxy.returns"
|
|
||||||
class="form-select text-uppercase"
|
|
||||||
style="width: 0;"
|
|
||||||
>
|
|
||||||
<option v-if="localOptions.returns === 'VOID'">
|
|
||||||
VOID
|
|
||||||
</option>
|
|
||||||
<option v-if="!isInDataTypes">
|
|
||||||
{{ localOptions.returns }}
|
|
||||||
</option>
|
|
||||||
<optgroup
|
|
||||||
v-for="group in workspace.dataTypes"
|
|
||||||
:key="group.group"
|
|
||||||
:label="group.group"
|
|
||||||
>
|
|
||||||
<option
|
|
||||||
v-for="type in group.types"
|
|
||||||
:key="type.name"
|
|
||||||
:selected="optionsProxy.returns === type.name"
|
|
||||||
:value="type.name"
|
|
||||||
>
|
|
||||||
{{ type.name }}
|
|
||||||
</option>
|
|
||||||
</optgroup>
|
|
||||||
</select>
|
|
||||||
<input
|
|
||||||
v-if="customizations.parametersLength"
|
|
||||||
v-model="optionsProxy.returnsLength"
|
|
||||||
class="form-input"
|
|
||||||
type="number"
|
|
||||||
min="0"
|
|
||||||
>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<div v-if="customizations.comment" class="form-group">
|
|
||||||
<label class="form-label col-4">
|
|
||||||
{{ $t('word.comment') }}
|
|
||||||
</label>
|
|
||||||
<div class="column">
|
|
||||||
<input
|
|
||||||
v-model="optionsProxy.comment"
|
|
||||||
class="form-input"
|
|
||||||
type="text"
|
|
||||||
>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<div class="form-group">
|
|
||||||
<label class="form-label col-4">
|
|
||||||
{{ $t('message.sqlSecurity') }}
|
|
||||||
</label>
|
|
||||||
<div class="column">
|
|
||||||
<select v-model="optionsProxy.security" class="form-select">
|
|
||||||
<option>DEFINER</option>
|
|
||||||
<option>INVOKER</option>
|
|
||||||
</select>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<div v-if="customizations.functionDataAccess" class="form-group">
|
|
||||||
<label class="form-label col-4">
|
|
||||||
{{ $t('message.dataAccess') }}
|
|
||||||
</label>
|
|
||||||
<div class="column">
|
|
||||||
<select v-model="optionsProxy.dataAccess" class="form-select">
|
|
||||||
<option>CONTAINS SQL</option>
|
|
||||||
<option>NO SQL</option>
|
|
||||||
<option>READS SQL DATA</option>
|
|
||||||
<option>MODIFIES SQL DATA</option>
|
|
||||||
</select>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<div v-if="customizations.functionDeterministic" class="form-group">
|
|
||||||
<div class="col-4" />
|
|
||||||
<div class="column">
|
|
||||||
<label class="form-checkbox form-inline">
|
|
||||||
<input v-model="optionsProxy.deterministic" type="checkbox"><i class="form-icon" /> {{ $t('word.deterministic') }}
|
|
||||||
</label>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</form>
|
|
||||||
</div>
|
|
||||||
</ConfirmModal>
|
|
||||||
</template>
|
|
||||||
|
|
||||||
<script>
|
|
||||||
import ConfirmModal from '@/components/BaseConfirmModal';
|
|
||||||
|
|
||||||
export default {
|
|
||||||
name: 'WorkspacePropsFunctionOptionsModal',
|
|
||||||
components: {
|
|
||||||
ConfirmModal
|
|
||||||
},
|
|
||||||
props: {
|
|
||||||
localOptions: Object,
|
|
||||||
workspace: Object
|
|
||||||
},
|
|
||||||
data () {
|
|
||||||
return {
|
|
||||||
optionsProxy: {},
|
|
||||||
isOptionsChanging: false
|
|
||||||
};
|
|
||||||
},
|
|
||||||
computed: {
|
|
||||||
isTableNameValid () {
|
|
||||||
return this.optionsProxy.name !== '';
|
|
||||||
},
|
|
||||||
customizations () {
|
|
||||||
return this.workspace.customizations;
|
|
||||||
},
|
|
||||||
isInDataTypes () {
|
|
||||||
let typeNames = [];
|
|
||||||
for (const group of this.workspace.dataTypes) {
|
|
||||||
typeNames = group.types.reduce((acc, curr) => {
|
|
||||||
acc.push(curr.name);
|
|
||||||
return acc;
|
|
||||||
}, []);
|
|
||||||
}
|
|
||||||
return typeNames.includes(this.localOptions.returns);
|
|
||||||
}
|
|
||||||
},
|
|
||||||
created () {
|
|
||||||
this.optionsProxy = JSON.parse(JSON.stringify(this.localOptions));
|
|
||||||
|
|
||||||
setTimeout(() => {
|
|
||||||
this.$refs.firstInput.focus();
|
|
||||||
}, 20);
|
|
||||||
},
|
|
||||||
methods: {
|
|
||||||
confirmOptionsChange () {
|
|
||||||
if (!this.isTableNameValid)
|
|
||||||
this.optionsProxy.name = this.localOptions.name;
|
|
||||||
|
|
||||||
this.$emit('options-update', this.optionsProxy);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
};
|
|
||||||
</script>
|
|
@@ -1,132 +0,0 @@
|
|||||||
<template>
|
|
||||||
<ConfirmModal
|
|
||||||
:confirm-text="$t('word.confirm')"
|
|
||||||
size="400"
|
|
||||||
@confirm="confirmOptionsChange"
|
|
||||||
@hide="$emit('hide')"
|
|
||||||
>
|
|
||||||
<template :slot="'header'">
|
|
||||||
<div class="d-flex">
|
|
||||||
<i class="mdi mdi-24px mdi-cogs mr-1" />
|
|
||||||
<span class="cut-text">{{ $t('word.options') }} "{{ table }}"</span>
|
|
||||||
</div>
|
|
||||||
</template>
|
|
||||||
<div :slot="'body'">
|
|
||||||
<form class="form-horizontal">
|
|
||||||
<div class="form-group">
|
|
||||||
<label class="form-label col-4">
|
|
||||||
{{ $t('word.name') }}
|
|
||||||
</label>
|
|
||||||
<div class="column">
|
|
||||||
<input
|
|
||||||
ref="firstInput"
|
|
||||||
v-model="optionsProxy.name"
|
|
||||||
class="form-input"
|
|
||||||
:class="{'is-error': !isTableNameValid}"
|
|
||||||
type="text"
|
|
||||||
>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<div v-if="workspace.customizations.comment" class="form-group">
|
|
||||||
<label class="form-label col-4">
|
|
||||||
{{ $t('word.comment') }}
|
|
||||||
</label>
|
|
||||||
<div class="column">
|
|
||||||
<input
|
|
||||||
v-model="optionsProxy.comment"
|
|
||||||
class="form-input"
|
|
||||||
type="text"
|
|
||||||
>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<div v-if="workspace.customizations.autoIncrement" class="form-group">
|
|
||||||
<label class="form-label col-4">
|
|
||||||
{{ $t('word.autoIncrement') }}
|
|
||||||
</label>
|
|
||||||
<div class="column">
|
|
||||||
<input
|
|
||||||
v-model="optionsProxy.autoIncrement"
|
|
||||||
class="form-input"
|
|
||||||
type="number"
|
|
||||||
:disabled="optionsProxy.autoIncrement === null"
|
|
||||||
>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<div v-if="workspace.customizations.collations" class="form-group">
|
|
||||||
<label class="form-label col-4">
|
|
||||||
{{ $t('word.collation') }}
|
|
||||||
</label>
|
|
||||||
<div class="column">
|
|
||||||
<select v-model="optionsProxy.collation" class="form-select">
|
|
||||||
<option
|
|
||||||
v-for="collation in workspace.collations"
|
|
||||||
:key="collation.id"
|
|
||||||
:value="collation.collation"
|
|
||||||
>
|
|
||||||
{{ collation.collation }}
|
|
||||||
</option>
|
|
||||||
</select>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<div v-if="workspace.customizations.engines" class="form-group">
|
|
||||||
<label class="form-label col-4">
|
|
||||||
{{ $t('word.engine') }}
|
|
||||||
</label>
|
|
||||||
<div class="column">
|
|
||||||
<select v-model="optionsProxy.engine" class="form-select">
|
|
||||||
<option
|
|
||||||
v-for="engine in workspace.engines"
|
|
||||||
:key="engine.name"
|
|
||||||
:value="engine.name"
|
|
||||||
>
|
|
||||||
{{ engine.name }}
|
|
||||||
</option>
|
|
||||||
</select>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</form>
|
|
||||||
</div>
|
|
||||||
</ConfirmModal>
|
|
||||||
</template>
|
|
||||||
|
|
||||||
<script>
|
|
||||||
import ConfirmModal from '@/components/BaseConfirmModal';
|
|
||||||
|
|
||||||
export default {
|
|
||||||
name: 'WorkspacePropsOptionsModal',
|
|
||||||
components: {
|
|
||||||
ConfirmModal
|
|
||||||
},
|
|
||||||
props: {
|
|
||||||
localOptions: Object,
|
|
||||||
table: String,
|
|
||||||
workspace: Object
|
|
||||||
},
|
|
||||||
data () {
|
|
||||||
return {
|
|
||||||
optionsProxy: {},
|
|
||||||
isOptionsChanging: false
|
|
||||||
};
|
|
||||||
},
|
|
||||||
computed: {
|
|
||||||
isTableNameValid () {
|
|
||||||
return this.optionsProxy.name !== '';
|
|
||||||
}
|
|
||||||
},
|
|
||||||
created () {
|
|
||||||
this.optionsProxy = JSON.parse(JSON.stringify(this.localOptions));
|
|
||||||
|
|
||||||
setTimeout(() => {
|
|
||||||
this.$refs.firstInput.focus();
|
|
||||||
}, 20);
|
|
||||||
},
|
|
||||||
methods: {
|
|
||||||
confirmOptionsChange () {
|
|
||||||
if (!this.isTableNameValid)
|
|
||||||
this.optionsProxy.name = this.localOptions.name;
|
|
||||||
|
|
||||||
this.$emit('options-update', this.optionsProxy);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
};
|
|
||||||
</script>
|
|
@@ -1,161 +0,0 @@
|
|||||||
<template>
|
|
||||||
<ConfirmModal
|
|
||||||
:confirm-text="$t('word.confirm')"
|
|
||||||
size="400"
|
|
||||||
@confirm="confirmOptionsChange"
|
|
||||||
@hide="$emit('hide')"
|
|
||||||
>
|
|
||||||
<template :slot="'header'">
|
|
||||||
<div class="d-flex">
|
|
||||||
<i class="mdi mdi-24px mdi-cogs mr-1" />
|
|
||||||
<span class="cut-text">{{ $t('word.options') }} "{{ localOptions.name }}"</span>
|
|
||||||
</div>
|
|
||||||
</template>
|
|
||||||
<div :slot="'body'">
|
|
||||||
<form class="form-horizontal">
|
|
||||||
<div class="form-group">
|
|
||||||
<label class="form-label col-4">
|
|
||||||
{{ $t('word.name') }}
|
|
||||||
</label>
|
|
||||||
<div class="column">
|
|
||||||
<input
|
|
||||||
ref="firstInput"
|
|
||||||
v-model="optionsProxy.name"
|
|
||||||
class="form-input"
|
|
||||||
:class="{'is-error': !isTableNameValid}"
|
|
||||||
type="text"
|
|
||||||
>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<div v-if="customizations.languages" class="form-group">
|
|
||||||
<label class="form-label col-4">
|
|
||||||
{{ $t('word.language') }}
|
|
||||||
</label>
|
|
||||||
<div class="column">
|
|
||||||
<select v-model="optionsProxy.language" class="form-select">
|
|
||||||
<option v-for="language in customizations.languages" :key="language">
|
|
||||||
{{ language }}
|
|
||||||
</option>
|
|
||||||
</select>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<div v-if="customizations.definer" class="form-group">
|
|
||||||
<label class="form-label col-4">
|
|
||||||
{{ $t('word.definer') }}
|
|
||||||
</label>
|
|
||||||
<div class="column">
|
|
||||||
<select
|
|
||||||
v-if="workspace.users.length"
|
|
||||||
v-model="optionsProxy.definer"
|
|
||||||
class="form-select"
|
|
||||||
>
|
|
||||||
<option value="">
|
|
||||||
{{ $t('message.currentUser') }}
|
|
||||||
</option>
|
|
||||||
<option
|
|
||||||
v-for="user in workspace.users"
|
|
||||||
:key="`${user.name}@${user.host}`"
|
|
||||||
:value="`\`${user.name}\`@\`${user.host}\``"
|
|
||||||
>
|
|
||||||
{{ user.name }}@{{ user.host }}
|
|
||||||
</option>
|
|
||||||
</select>
|
|
||||||
<select v-if="!workspace.users.length" class="form-select">
|
|
||||||
<option value="">
|
|
||||||
{{ $t('message.currentUser') }}
|
|
||||||
</option>
|
|
||||||
</select>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<div v-if="customizations.comment" class="form-group">
|
|
||||||
<label class="form-label col-4">
|
|
||||||
{{ $t('word.comment') }}
|
|
||||||
</label>
|
|
||||||
<div class="column">
|
|
||||||
<input
|
|
||||||
v-model="optionsProxy.comment"
|
|
||||||
class="form-input"
|
|
||||||
type="text"
|
|
||||||
>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<div class="form-group">
|
|
||||||
<label class="form-label col-4">
|
|
||||||
{{ $t('message.sqlSecurity') }}
|
|
||||||
</label>
|
|
||||||
<div class="column">
|
|
||||||
<select v-model="optionsProxy.security" class="form-select">
|
|
||||||
<option>DEFINER</option>
|
|
||||||
<option>INVOKER</option>
|
|
||||||
</select>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<div v-if="customizations.procedureDataAccess" class="form-group">
|
|
||||||
<label class="form-label col-4">
|
|
||||||
{{ $t('message.dataAccess') }}
|
|
||||||
</label>
|
|
||||||
<div class="column">
|
|
||||||
<select v-model="optionsProxy.dataAccess" class="form-select">
|
|
||||||
<option>CONTAINS SQL</option>
|
|
||||||
<option>NO SQL</option>
|
|
||||||
<option>READS SQL DATA</option>
|
|
||||||
<option>MODIFIES SQL DATA</option>
|
|
||||||
</select>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<div v-if="customizations.procedureDeterministic" class="form-group">
|
|
||||||
<div class="col-4" />
|
|
||||||
<div class="column">
|
|
||||||
<label class="form-checkbox form-inline">
|
|
||||||
<input v-model="optionsProxy.deterministic" type="checkbox"><i class="form-icon" /> {{ $t('word.deterministic') }}
|
|
||||||
</label>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</form>
|
|
||||||
</div>
|
|
||||||
</ConfirmModal>
|
|
||||||
</template>
|
|
||||||
|
|
||||||
<script>
|
|
||||||
import ConfirmModal from '@/components/BaseConfirmModal';
|
|
||||||
|
|
||||||
export default {
|
|
||||||
name: 'WorkspacePropsRoutineOptionsModal',
|
|
||||||
components: {
|
|
||||||
ConfirmModal
|
|
||||||
},
|
|
||||||
props: {
|
|
||||||
localOptions: Object,
|
|
||||||
workspace: Object
|
|
||||||
},
|
|
||||||
data () {
|
|
||||||
return {
|
|
||||||
optionsProxy: {},
|
|
||||||
isOptionsChanging: false
|
|
||||||
};
|
|
||||||
},
|
|
||||||
computed: {
|
|
||||||
isTableNameValid () {
|
|
||||||
return this.optionsProxy.name !== '';
|
|
||||||
},
|
|
||||||
customizations () {
|
|
||||||
return this.workspace.customizations;
|
|
||||||
}
|
|
||||||
},
|
|
||||||
created () {
|
|
||||||
this.optionsProxy = JSON.parse(JSON.stringify(this.localOptions));
|
|
||||||
|
|
||||||
setTimeout(() => {
|
|
||||||
this.$refs.firstInput.focus();
|
|
||||||
}, 20);
|
|
||||||
},
|
|
||||||
methods: {
|
|
||||||
confirmOptionsChange () {
|
|
||||||
if (!this.isTableNameValid)
|
|
||||||
this.optionsProxy.name = this.localOptions.name;
|
|
||||||
|
|
||||||
this.$emit('options-update', this.optionsProxy);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
};
|
|
||||||
</script>
|
|
@@ -1,125 +0,0 @@
|
|||||||
<template>
|
|
||||||
<ConfirmModal
|
|
||||||
:confirm-text="$t('word.confirm')"
|
|
||||||
size="400"
|
|
||||||
@confirm="confirmOptionsChange"
|
|
||||||
@hide="$emit('hide')"
|
|
||||||
>
|
|
||||||
<template :slot="'header'">
|
|
||||||
<div class="d-flex">
|
|
||||||
<i class="mdi mdi-24px mdi-cogs mr-1" />
|
|
||||||
<span class="cut-text">{{ $t('word.options') }} "{{ localOptions.name }}"</span>
|
|
||||||
</div>
|
|
||||||
</template>
|
|
||||||
<div :slot="'body'">
|
|
||||||
<form class="form-horizontal">
|
|
||||||
<div v-if="customizations.triggerFunctionlanguages" class="form-group">
|
|
||||||
<label class="form-label col-4">
|
|
||||||
{{ $t('word.language') }}
|
|
||||||
</label>
|
|
||||||
<div class="column">
|
|
||||||
<select v-model="optionsProxy.language" class="form-select">
|
|
||||||
<option v-for="language in customizations.triggerFunctionlanguages" :key="language">
|
|
||||||
{{ language }}
|
|
||||||
</option>
|
|
||||||
</select>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<div v-if="customizations.definer" class="form-group">
|
|
||||||
<label class="form-label col-4">
|
|
||||||
{{ $t('word.definer') }}
|
|
||||||
</label>
|
|
||||||
<div class="column">
|
|
||||||
<select
|
|
||||||
v-if="workspace.users.length"
|
|
||||||
v-model="optionsProxy.definer"
|
|
||||||
class="form-select"
|
|
||||||
>
|
|
||||||
<option value="">
|
|
||||||
{{ $t('message.currentUser') }}
|
|
||||||
</option>
|
|
||||||
<option
|
|
||||||
v-for="user in workspace.users"
|
|
||||||
:key="`${user.name}@${user.host}`"
|
|
||||||
:value="`\`${user.name}\`@\`${user.host}\``"
|
|
||||||
>
|
|
||||||
{{ user.name }}@{{ user.host }}
|
|
||||||
</option>
|
|
||||||
</select>
|
|
||||||
<select v-if="!workspace.users.length" class="form-select">
|
|
||||||
<option value="">
|
|
||||||
{{ $t('message.currentUser') }}
|
|
||||||
</option>
|
|
||||||
</select>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<div v-if="customizations.comment" class="form-group">
|
|
||||||
<label class="form-label col-4">
|
|
||||||
{{ $t('word.comment') }}
|
|
||||||
</label>
|
|
||||||
<div class="column">
|
|
||||||
<input
|
|
||||||
v-model="optionsProxy.comment"
|
|
||||||
class="form-input"
|
|
||||||
type="text"
|
|
||||||
>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</form>
|
|
||||||
</div>
|
|
||||||
</ConfirmModal>
|
|
||||||
</template>
|
|
||||||
|
|
||||||
<script>
|
|
||||||
import ConfirmModal from '@/components/BaseConfirmModal';
|
|
||||||
|
|
||||||
export default {
|
|
||||||
name: 'WorkspacePropsTriggerFunctionOptionsModal',
|
|
||||||
components: {
|
|
||||||
ConfirmModal
|
|
||||||
},
|
|
||||||
props: {
|
|
||||||
localOptions: Object,
|
|
||||||
workspace: Object
|
|
||||||
},
|
|
||||||
data () {
|
|
||||||
return {
|
|
||||||
optionsProxy: {},
|
|
||||||
isOptionsChanging: false
|
|
||||||
};
|
|
||||||
},
|
|
||||||
computed: {
|
|
||||||
isTableNameValid () {
|
|
||||||
return this.optionsProxy.name !== '';
|
|
||||||
},
|
|
||||||
customizations () {
|
|
||||||
return this.workspace.customizations;
|
|
||||||
},
|
|
||||||
isInDataTypes () {
|
|
||||||
let typeNames = [];
|
|
||||||
for (const group of this.workspace.dataTypes) {
|
|
||||||
typeNames = group.types.reduce((acc, curr) => {
|
|
||||||
acc.push(curr.name);
|
|
||||||
return acc;
|
|
||||||
}, []);
|
|
||||||
}
|
|
||||||
return typeNames.includes(this.localOptions.returns);
|
|
||||||
}
|
|
||||||
},
|
|
||||||
created () {
|
|
||||||
this.optionsProxy = JSON.parse(JSON.stringify(this.localOptions));
|
|
||||||
|
|
||||||
setTimeout(() => {
|
|
||||||
this.$refs.firstInput.focus();
|
|
||||||
}, 20);
|
|
||||||
},
|
|
||||||
methods: {
|
|
||||||
confirmOptionsChange () {
|
|
||||||
if (!this.isTableNameValid)
|
|
||||||
this.optionsProxy.name = this.localOptions.name;
|
|
||||||
|
|
||||||
this.$emit('options-update', this.optionsProxy);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
};
|
|
||||||
</script>
|
|
397
src/renderer/components/WorkspaceTabNewFunction.vue
Normal file
397
src/renderer/components/WorkspaceTabNewFunction.vue
Normal file
@@ -0,0 +1,397 @@
|
|||||||
|
<template>
|
||||||
|
<div v-show="isSelected" class="workspace-query-tab column col-12 columns col-gapless">
|
||||||
|
<div class="workspace-query-runner column col-12">
|
||||||
|
<div class="workspace-query-runner-footer">
|
||||||
|
<div class="workspace-query-buttons">
|
||||||
|
<button
|
||||||
|
class="btn btn-primary btn-sm"
|
||||||
|
:disabled="!isChanged"
|
||||||
|
:class="{'loading':isSaving}"
|
||||||
|
title="CTRL+S"
|
||||||
|
@click="saveChanges"
|
||||||
|
>
|
||||||
|
<i class="mdi mdi-24px mdi-content-save mr-1" />
|
||||||
|
<span>{{ $t('word.save') }}</span>
|
||||||
|
</button>
|
||||||
|
<button
|
||||||
|
:disabled="!isChanged"
|
||||||
|
class="btn btn-link btn-sm mr-0"
|
||||||
|
:title="$t('message.clearChanges')"
|
||||||
|
@click="clearChanges"
|
||||||
|
>
|
||||||
|
<i class="mdi mdi-24px mdi-delete-sweep mr-1" />
|
||||||
|
<span>{{ $t('word.clear') }}</span>
|
||||||
|
</button>
|
||||||
|
|
||||||
|
<div class="divider-vert py-3" />
|
||||||
|
|
||||||
|
<button class="btn btn-dark btn-sm" @click="showParamsModal">
|
||||||
|
<i class="mdi mdi-24px mdi-dots-horizontal mr-1" />
|
||||||
|
<span>{{ $t('word.parameters') }}</span>
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
<div class="workspace-query-info">
|
||||||
|
<div class="d-flex" :title="$t('word.schema')">
|
||||||
|
<i class="mdi mdi-18px mdi-database mr-1" /><b>{{ schema }}</b>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="container">
|
||||||
|
<div class="columns">
|
||||||
|
<div class="column col-auto">
|
||||||
|
<div class="form-group">
|
||||||
|
<label class="form-label">
|
||||||
|
{{ $t('word.name') }}
|
||||||
|
</label>
|
||||||
|
<input
|
||||||
|
ref="firstInput"
|
||||||
|
v-model="localFunction.name"
|
||||||
|
class="form-input"
|
||||||
|
type="text"
|
||||||
|
>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div v-if="customizations.languages" class="column col-auto">
|
||||||
|
<div class="form-group">
|
||||||
|
<label class="form-label">
|
||||||
|
{{ $t('word.language') }}
|
||||||
|
</label>
|
||||||
|
<select v-model="localFunction.language" class="form-select">
|
||||||
|
<option v-for="language in customizations.languages" :key="language">
|
||||||
|
{{ language }}
|
||||||
|
</option>
|
||||||
|
</select>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div v-if="customizations.definer" class="column col-auto">
|
||||||
|
<div class="form-group">
|
||||||
|
<label class="form-label">
|
||||||
|
{{ $t('word.definer') }}
|
||||||
|
</label>
|
||||||
|
<select
|
||||||
|
v-if="workspace.users.length"
|
||||||
|
v-model="localFunction.definer"
|
||||||
|
class="form-select"
|
||||||
|
>
|
||||||
|
<option value="">
|
||||||
|
{{ $t('message.currentUser') }}
|
||||||
|
</option>
|
||||||
|
<option
|
||||||
|
v-for="user in workspace.users"
|
||||||
|
:key="`${user.name}@${user.host}`"
|
||||||
|
:value="`\`${user.name}\`@\`${user.host}\``"
|
||||||
|
>
|
||||||
|
{{ user.name }}@{{ user.host }}
|
||||||
|
</option>
|
||||||
|
</select>
|
||||||
|
<select v-if="!workspace.users.length" class="form-select">
|
||||||
|
<option value="">
|
||||||
|
{{ $t('message.currentUser') }}
|
||||||
|
</option>
|
||||||
|
</select>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="column col-auto">
|
||||||
|
<div class="form-group">
|
||||||
|
<label class="form-label">
|
||||||
|
{{ $t('word.returns') }}
|
||||||
|
</label>
|
||||||
|
<div class="input-group">
|
||||||
|
<select
|
||||||
|
v-model="localFunction.returns"
|
||||||
|
class="form-select text-uppercase"
|
||||||
|
style="max-width: 150px;"
|
||||||
|
>
|
||||||
|
<option v-if="localFunction.returns === 'VOID'">
|
||||||
|
VOID
|
||||||
|
</option>
|
||||||
|
<optgroup
|
||||||
|
v-for="group in workspace.dataTypes"
|
||||||
|
:key="group.group"
|
||||||
|
:label="group.group"
|
||||||
|
>
|
||||||
|
<option
|
||||||
|
v-for="type in group.types"
|
||||||
|
:key="type.name"
|
||||||
|
:selected="localFunction.returns === type.name"
|
||||||
|
:value="type.name"
|
||||||
|
>
|
||||||
|
{{ type.name }}
|
||||||
|
</option>
|
||||||
|
</optgroup>
|
||||||
|
</select>
|
||||||
|
<input
|
||||||
|
v-if="customizations.parametersLength"
|
||||||
|
v-model="localFunction.returnsLength"
|
||||||
|
style="max-width: 150px;"
|
||||||
|
class="form-input"
|
||||||
|
type="number"
|
||||||
|
min="0"
|
||||||
|
:placeholder="$t('word.length')"
|
||||||
|
>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div v-if="customizations.comment" class="column">
|
||||||
|
<div class="form-group">
|
||||||
|
<label class="form-label">
|
||||||
|
{{ $t('word.comment') }}
|
||||||
|
</label>
|
||||||
|
<input
|
||||||
|
v-model="localFunction.comment"
|
||||||
|
class="form-input"
|
||||||
|
type="text"
|
||||||
|
>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="column col-auto">
|
||||||
|
<div class="form-group">
|
||||||
|
<label class="form-label">
|
||||||
|
{{ $t('message.sqlSecurity') }}
|
||||||
|
</label>
|
||||||
|
<select v-model="localFunction.security" class="form-select">
|
||||||
|
<option>DEFINER</option>
|
||||||
|
<option>INVOKER</option>
|
||||||
|
</select>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div v-if="customizations.functionDataAccess" class="column col-auto">
|
||||||
|
<div class="form-group">
|
||||||
|
<label class="form-label">
|
||||||
|
{{ $t('message.dataAccess') }}
|
||||||
|
</label>
|
||||||
|
<select v-model="localFunction.dataAccess" class="form-select">
|
||||||
|
<option>CONTAINS SQL</option>
|
||||||
|
<option>NO SQL</option>
|
||||||
|
<option>READS SQL DATA</option>
|
||||||
|
<option>MODIFIES SQL DATA</option>
|
||||||
|
</select>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div v-if="customizations.functionDeterministic" class="column col-auto">
|
||||||
|
<div class="form-group">
|
||||||
|
<label class="form-label d-invisible">.</label>
|
||||||
|
<label class="form-checkbox form-inline">
|
||||||
|
<input v-model="localFunction.deterministic" type="checkbox"><i class="form-icon" /> {{ $t('word.deterministic') }}
|
||||||
|
</label>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="workspace-query-results column col-12 mt-2 p-relative">
|
||||||
|
<BaseLoader v-if="isLoading" />
|
||||||
|
<label class="form-label ml-2">{{ $t('message.functionBody') }}</label>
|
||||||
|
<QueryEditor
|
||||||
|
v-show="isSelected"
|
||||||
|
ref="queryEditor"
|
||||||
|
:value.sync="localFunction.sql"
|
||||||
|
:workspace="workspace"
|
||||||
|
:schema="schema"
|
||||||
|
:height="editorHeight"
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
<WorkspaceTabPropsFunctionParamsModal
|
||||||
|
v-if="isParamsModal"
|
||||||
|
:local-parameters="localFunction.parameters"
|
||||||
|
:workspace="workspace"
|
||||||
|
:func="localFunction.name"
|
||||||
|
@hide="hideParamsModal"
|
||||||
|
@parameters-update="parametersUpdate"
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script>
|
||||||
|
import { mapGetters, mapActions } from 'vuex';
|
||||||
|
import BaseLoader from '@/components/BaseLoader';
|
||||||
|
import QueryEditor from '@/components/QueryEditor';
|
||||||
|
import WorkspaceTabPropsFunctionParamsModal from '@/components/WorkspaceTabPropsFunctionParamsModal';
|
||||||
|
import Functions from '@/ipc-api/Functions';
|
||||||
|
|
||||||
|
export default {
|
||||||
|
name: 'WorkspaceTabNewFunction',
|
||||||
|
components: {
|
||||||
|
BaseLoader,
|
||||||
|
QueryEditor,
|
||||||
|
WorkspaceTabPropsFunctionParamsModal
|
||||||
|
},
|
||||||
|
props: {
|
||||||
|
connection: Object,
|
||||||
|
tab: Object,
|
||||||
|
isSelected: Boolean,
|
||||||
|
schema: String
|
||||||
|
},
|
||||||
|
data () {
|
||||||
|
return {
|
||||||
|
isLoading: false,
|
||||||
|
isSaving: false,
|
||||||
|
isParamsModal: false,
|
||||||
|
originalFunction: {},
|
||||||
|
localFunction: {},
|
||||||
|
lastFunction: null,
|
||||||
|
sqlProxy: '',
|
||||||
|
editorHeight: 300
|
||||||
|
};
|
||||||
|
},
|
||||||
|
computed: {
|
||||||
|
...mapGetters({
|
||||||
|
selectedWorkspace: 'workspaces/getSelected',
|
||||||
|
getWorkspace: 'workspaces/getWorkspace'
|
||||||
|
}),
|
||||||
|
workspace () {
|
||||||
|
return this.getWorkspace(this.connection.uid);
|
||||||
|
},
|
||||||
|
customizations () {
|
||||||
|
return this.workspace.customizations;
|
||||||
|
},
|
||||||
|
tabUid () {
|
||||||
|
return this.$vnode.key;
|
||||||
|
},
|
||||||
|
isChanged () {
|
||||||
|
return JSON.stringify(this.originalFunction) !== JSON.stringify(this.localFunction);
|
||||||
|
},
|
||||||
|
isDefinerInUsers () {
|
||||||
|
return this.originalFunction
|
||||||
|
? this.workspace.users.some(user => this.originalFunction.definer === `\`${user.name}\`@\`${user.host}\``)
|
||||||
|
: true;
|
||||||
|
},
|
||||||
|
schemaTables () {
|
||||||
|
const schemaTables = this.workspace.structure
|
||||||
|
.filter(schema => schema.name === this.schema)
|
||||||
|
.map(schema => schema.tables);
|
||||||
|
|
||||||
|
return schemaTables.length ? schemaTables[0].filter(table => table.type === 'table') : [];
|
||||||
|
}
|
||||||
|
},
|
||||||
|
watch: {
|
||||||
|
isSelected (val) {
|
||||||
|
if (val)
|
||||||
|
this.changeBreadcrumbs({ schema: this.schema });
|
||||||
|
},
|
||||||
|
isChanged (val) {
|
||||||
|
this.setUnsavedChanges({ uid: this.connection.uid, tUid: this.tabUid, isChanged: val });
|
||||||
|
}
|
||||||
|
},
|
||||||
|
created () {
|
||||||
|
this.originalFunction = {
|
||||||
|
sql: this.customizations.functionSql,
|
||||||
|
language: this.customizations.languages ? this.customizations.languages[0] : null,
|
||||||
|
name: '',
|
||||||
|
definer: '',
|
||||||
|
comment: '',
|
||||||
|
security: 'DEFINER',
|
||||||
|
dataAccess: 'CONTAINS SQL',
|
||||||
|
deterministic: false,
|
||||||
|
returns: this.workspace.dataTypes.length ? this.workspace.dataTypes[0].types[0].name : null
|
||||||
|
};
|
||||||
|
|
||||||
|
this.localFunction = JSON.parse(JSON.stringify(this.originalFunction));
|
||||||
|
|
||||||
|
setTimeout(() => {
|
||||||
|
this.resizeQueryEditor();
|
||||||
|
}, 50);
|
||||||
|
|
||||||
|
window.addEventListener('keydown', this.onKey);
|
||||||
|
},
|
||||||
|
mounted () {
|
||||||
|
if (this.isSelected)
|
||||||
|
this.changeBreadcrumbs({ schema: this.schema });
|
||||||
|
|
||||||
|
setTimeout(() => {
|
||||||
|
this.$refs.firstInput.focus();
|
||||||
|
}, 100);
|
||||||
|
},
|
||||||
|
destroyed () {
|
||||||
|
window.removeEventListener('resize', this.resizeQueryEditor);
|
||||||
|
},
|
||||||
|
beforeDestroy () {
|
||||||
|
window.removeEventListener('keydown', this.onKey);
|
||||||
|
},
|
||||||
|
methods: {
|
||||||
|
...mapActions({
|
||||||
|
addNotification: 'notifications/addNotification',
|
||||||
|
refreshStructure: 'workspaces/refreshStructure',
|
||||||
|
changeBreadcrumbs: 'workspaces/changeBreadcrumbs',
|
||||||
|
setUnsavedChanges: 'workspaces/setUnsavedChanges',
|
||||||
|
newTab: 'workspaces/newTab',
|
||||||
|
removeTab: 'workspaces/removeTab',
|
||||||
|
renameTabs: 'workspaces/renameTabs'
|
||||||
|
}),
|
||||||
|
async saveChanges () {
|
||||||
|
if (this.isSaving) return;
|
||||||
|
this.isSaving = true;
|
||||||
|
const params = {
|
||||||
|
uid: this.connection.uid,
|
||||||
|
schema: this.schema,
|
||||||
|
...this.localFunction
|
||||||
|
};
|
||||||
|
|
||||||
|
try {
|
||||||
|
const { status, response } = await Functions.createFunction(params);
|
||||||
|
|
||||||
|
if (status === 'success') {
|
||||||
|
await this.refreshStructure(this.connection.uid);
|
||||||
|
|
||||||
|
this.newTab({
|
||||||
|
uid: this.connection.uid,
|
||||||
|
schema: this.schema,
|
||||||
|
elementName: this.localFunction.name,
|
||||||
|
elementType: 'function',
|
||||||
|
type: 'function-props'
|
||||||
|
});
|
||||||
|
|
||||||
|
this.removeTab({ uid: this.connection.uid, tab: this.tab.uid });
|
||||||
|
this.changeBreadcrumbs({ schema: this.schema, function: this.localFunction.name });
|
||||||
|
}
|
||||||
|
else
|
||||||
|
this.addNotification({ status: 'error', message: response });
|
||||||
|
}
|
||||||
|
catch (err) {
|
||||||
|
this.addNotification({ status: 'error', message: err.stack });
|
||||||
|
}
|
||||||
|
|
||||||
|
this.isSaving = false;
|
||||||
|
},
|
||||||
|
clearChanges () {
|
||||||
|
this.localFunction = JSON.parse(JSON.stringify(this.originalFunction));
|
||||||
|
this.$refs.queryEditor.editor.session.setValue(this.localFunction.sql);
|
||||||
|
},
|
||||||
|
resizeQueryEditor () {
|
||||||
|
if (this.$refs.queryEditor) {
|
||||||
|
const footer = document.getElementById('footer');
|
||||||
|
const size = window.innerHeight - this.$refs.queryEditor.$el.getBoundingClientRect().top - footer.offsetHeight;
|
||||||
|
this.editorHeight = size;
|
||||||
|
this.$refs.queryEditor.editor.resize();
|
||||||
|
}
|
||||||
|
},
|
||||||
|
optionsUpdate (options) {
|
||||||
|
this.localFunction = options;
|
||||||
|
},
|
||||||
|
parametersUpdate (parameters) {
|
||||||
|
this.localFunction = { ...this.localFunction, parameters };
|
||||||
|
},
|
||||||
|
showParamsModal () {
|
||||||
|
this.isParamsModal = true;
|
||||||
|
},
|
||||||
|
hideParamsModal () {
|
||||||
|
this.isParamsModal = false;
|
||||||
|
},
|
||||||
|
showAskParamsModal () {
|
||||||
|
this.isAskingParameters = true;
|
||||||
|
},
|
||||||
|
hideAskParamsModal () {
|
||||||
|
this.isAskingParameters = false;
|
||||||
|
},
|
||||||
|
onKey (e) {
|
||||||
|
if (this.isSelected) {
|
||||||
|
e.stopPropagation();
|
||||||
|
if (e.ctrlKey && e.keyCode === 83) { // CTRL + S
|
||||||
|
if (this.isChanged)
|
||||||
|
this.saveChanges();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
</script>
|
353
src/renderer/components/WorkspaceTabNewRoutine.vue
Normal file
353
src/renderer/components/WorkspaceTabNewRoutine.vue
Normal file
@@ -0,0 +1,353 @@
|
|||||||
|
<template>
|
||||||
|
<div v-show="isSelected" class="workspace-query-tab column col-12 columns col-gapless">
|
||||||
|
<div class="workspace-query-runner column col-12">
|
||||||
|
<div class="workspace-query-runner-footer">
|
||||||
|
<div class="workspace-query-buttons">
|
||||||
|
<button
|
||||||
|
class="btn btn-primary btn-sm"
|
||||||
|
:disabled="!isChanged"
|
||||||
|
:class="{'loading':isSaving}"
|
||||||
|
title="CTRL+S"
|
||||||
|
@click="saveChanges"
|
||||||
|
>
|
||||||
|
<i class="mdi mdi-24px mdi-content-save mr-1" />
|
||||||
|
<span>{{ $t('word.save') }}</span>
|
||||||
|
</button>
|
||||||
|
<button
|
||||||
|
:disabled="!isChanged"
|
||||||
|
class="btn btn-link btn-sm mr-0"
|
||||||
|
:title="$t('message.clearChanges')"
|
||||||
|
@click="clearChanges"
|
||||||
|
>
|
||||||
|
<i class="mdi mdi-24px mdi-delete-sweep mr-1" />
|
||||||
|
<span>{{ $t('word.clear') }}</span>
|
||||||
|
</button>
|
||||||
|
|
||||||
|
<div class="divider-vert py-3" />
|
||||||
|
|
||||||
|
<button class="btn btn-dark btn-sm" @click="showParamsModal">
|
||||||
|
<i class="mdi mdi-24px mdi-dots-horizontal mr-1" />
|
||||||
|
<span>{{ $t('word.parameters') }}</span>
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
<div class="workspace-query-info">
|
||||||
|
<div class="d-flex" :title="$t('word.schema')">
|
||||||
|
<i class="mdi mdi-18px mdi-database mr-1" /><b>{{ schema }}</b>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="container">
|
||||||
|
<div class="columns">
|
||||||
|
<div class="column col-auto">
|
||||||
|
<div class="form-group">
|
||||||
|
<label class="form-label">
|
||||||
|
{{ $t('word.name') }}
|
||||||
|
</label>
|
||||||
|
<input
|
||||||
|
ref="firstInput"
|
||||||
|
v-model="localRoutine.name"
|
||||||
|
class="form-input"
|
||||||
|
type="text"
|
||||||
|
>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div v-if="customizations.languages" class="column col-auto">
|
||||||
|
<div class="form-group">
|
||||||
|
<label class="form-label">
|
||||||
|
{{ $t('word.language') }}
|
||||||
|
</label>
|
||||||
|
<select v-model="localRoutine.language" class="form-select">
|
||||||
|
<option v-for="language in customizations.languages" :key="language">
|
||||||
|
{{ language }}
|
||||||
|
</option>
|
||||||
|
</select>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div v-if="customizations.definer" class="column col-auto">
|
||||||
|
<div class="form-group">
|
||||||
|
<label class="form-label">
|
||||||
|
{{ $t('word.definer') }}
|
||||||
|
</label>
|
||||||
|
<select
|
||||||
|
v-if="workspace.users.length"
|
||||||
|
v-model="localRoutine.definer"
|
||||||
|
class="form-select"
|
||||||
|
>
|
||||||
|
<option value="">
|
||||||
|
{{ $t('message.currentUser') }}
|
||||||
|
</option>
|
||||||
|
<option
|
||||||
|
v-for="user in workspace.users"
|
||||||
|
:key="`${user.name}@${user.host}`"
|
||||||
|
:value="`\`${user.name}\`@\`${user.host}\``"
|
||||||
|
>
|
||||||
|
{{ user.name }}@{{ user.host }}
|
||||||
|
</option>
|
||||||
|
</select>
|
||||||
|
<select v-if="!workspace.users.length" class="form-select">
|
||||||
|
<option value="">
|
||||||
|
{{ $t('message.currentUser') }}
|
||||||
|
</option>
|
||||||
|
</select>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div v-if="customizations.comment" class="column">
|
||||||
|
<div class="form-group">
|
||||||
|
<label class="form-label">
|
||||||
|
{{ $t('word.comment') }}
|
||||||
|
</label>
|
||||||
|
<input
|
||||||
|
v-model="localRoutine.comment"
|
||||||
|
class="form-input"
|
||||||
|
type="text"
|
||||||
|
>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="column col-auto">
|
||||||
|
<div class="form-group">
|
||||||
|
<label class="form-label">
|
||||||
|
{{ $t('message.sqlSecurity') }}
|
||||||
|
</label>
|
||||||
|
<select v-model="localRoutine.security" class="form-select">
|
||||||
|
<option>DEFINER</option>
|
||||||
|
<option>INVOKER</option>
|
||||||
|
</select>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div v-if="customizations.procedureDataAccess" class="column col-auto">
|
||||||
|
<div class="form-group">
|
||||||
|
<label class="form-label">
|
||||||
|
{{ $t('message.dataAccess') }}
|
||||||
|
</label>
|
||||||
|
<select v-model="localRoutine.dataAccess" class="form-select">
|
||||||
|
<option>CONTAINS SQL</option>
|
||||||
|
<option>NO SQL</option>
|
||||||
|
<option>READS SQL DATA</option>
|
||||||
|
<option>MODIFIES SQL DATA</option>
|
||||||
|
</select>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div v-if="customizations.procedureDeterministic" class="column col-auto">
|
||||||
|
<div class="form-group">
|
||||||
|
<label class="form-label d-invisible">.</label>
|
||||||
|
<label class="form-checkbox form-inline">
|
||||||
|
<input v-model="localRoutine.deterministic" type="checkbox"><i class="form-icon" /> {{ $t('word.deterministic') }}
|
||||||
|
</label>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="workspace-query-results column col-12 mt-2 p-relative">
|
||||||
|
<BaseLoader v-if="isLoading" />
|
||||||
|
<label class="form-label ml-2">{{ $t('message.routineBody') }}</label>
|
||||||
|
<QueryEditor
|
||||||
|
v-show="isSelected"
|
||||||
|
:key="`new-${_uid}`"
|
||||||
|
ref="queryEditor"
|
||||||
|
:value.sync="localRoutine.sql"
|
||||||
|
:workspace="workspace"
|
||||||
|
:schema="schema"
|
||||||
|
:height="editorHeight"
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
<WorkspaceTabPropsRoutineParamsModal
|
||||||
|
v-if="isParamsModal"
|
||||||
|
:local-parameters="localRoutine.parameters"
|
||||||
|
:workspace="workspace"
|
||||||
|
routine="new"
|
||||||
|
@hide="hideParamsModal"
|
||||||
|
@parameters-update="parametersUpdate"
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script>
|
||||||
|
import { mapGetters, mapActions } from 'vuex';
|
||||||
|
import QueryEditor from '@/components/QueryEditor';
|
||||||
|
import BaseLoader from '@/components/BaseLoader';
|
||||||
|
import WorkspaceTabPropsRoutineParamsModal from '@/components/WorkspaceTabPropsRoutineParamsModal';
|
||||||
|
import Routines from '@/ipc-api/Routines';
|
||||||
|
|
||||||
|
export default {
|
||||||
|
name: 'WorkspaceTabNewRoutine',
|
||||||
|
components: {
|
||||||
|
QueryEditor,
|
||||||
|
BaseLoader,
|
||||||
|
WorkspaceTabPropsRoutineParamsModal
|
||||||
|
},
|
||||||
|
props: {
|
||||||
|
connection: Object,
|
||||||
|
tab: Object,
|
||||||
|
isSelected: Boolean,
|
||||||
|
schema: String
|
||||||
|
},
|
||||||
|
data () {
|
||||||
|
return {
|
||||||
|
isLoading: false,
|
||||||
|
isSaving: false,
|
||||||
|
isParamsModal: false,
|
||||||
|
originalRoutine: {},
|
||||||
|
localRoutine: {},
|
||||||
|
lastRoutine: null,
|
||||||
|
sqlProxy: '',
|
||||||
|
editorHeight: 300
|
||||||
|
};
|
||||||
|
},
|
||||||
|
computed: {
|
||||||
|
...mapGetters({
|
||||||
|
selectedWorkspace: 'workspaces/getSelected',
|
||||||
|
getWorkspace: 'workspaces/getWorkspace'
|
||||||
|
}),
|
||||||
|
workspace () {
|
||||||
|
return this.getWorkspace(this.connection.uid);
|
||||||
|
},
|
||||||
|
customizations () {
|
||||||
|
return this.workspace.customizations;
|
||||||
|
},
|
||||||
|
tabUid () {
|
||||||
|
return this.$vnode.key;
|
||||||
|
},
|
||||||
|
isChanged () {
|
||||||
|
return JSON.stringify(this.originalRoutine) !== JSON.stringify(this.localRoutine);
|
||||||
|
},
|
||||||
|
isDefinerInUsers () {
|
||||||
|
return this.originalRoutine ? this.workspace.users.some(user => this.originalRoutine.definer === `\`${user.name}\`@\`${user.host}\``) : true;
|
||||||
|
},
|
||||||
|
schemaTables () {
|
||||||
|
const schemaTables = this.workspace.structure
|
||||||
|
.filter(schema => schema.name === this.schema)
|
||||||
|
.map(schema => schema.tables);
|
||||||
|
|
||||||
|
return schemaTables.length ? schemaTables[0].filter(table => table.type === 'table') : [];
|
||||||
|
}
|
||||||
|
},
|
||||||
|
watch: {
|
||||||
|
isSelected (val) {
|
||||||
|
if (val)
|
||||||
|
this.changeBreadcrumbs({ schema: this.schema });
|
||||||
|
},
|
||||||
|
isChanged (val) {
|
||||||
|
this.setUnsavedChanges({ uid: this.connection.uid, tUid: this.tabUid, isChanged: val });
|
||||||
|
}
|
||||||
|
},
|
||||||
|
created () {
|
||||||
|
this.originalRoutine = {
|
||||||
|
sql: this.customizations.procedureSql,
|
||||||
|
language: this.customizations.languages ? this.customizations.languages[0] : null,
|
||||||
|
name: '',
|
||||||
|
definer: '',
|
||||||
|
comment: '',
|
||||||
|
security: 'DEFINER',
|
||||||
|
dataAccess: 'CONTAINS SQL',
|
||||||
|
deterministic: false
|
||||||
|
};
|
||||||
|
|
||||||
|
this.localRoutine = JSON.parse(JSON.stringify(this.originalRoutine));
|
||||||
|
|
||||||
|
setTimeout(() => {
|
||||||
|
this.resizeQueryEditor();
|
||||||
|
}, 50);
|
||||||
|
|
||||||
|
window.addEventListener('keydown', this.onKey);
|
||||||
|
},
|
||||||
|
mounted () {
|
||||||
|
if (this.isSelected)
|
||||||
|
this.changeBreadcrumbs({ schema: this.schema });
|
||||||
|
|
||||||
|
setTimeout(() => {
|
||||||
|
this.$refs.firstInput.focus();
|
||||||
|
}, 100);
|
||||||
|
|
||||||
|
window.addEventListener('resize', this.resizeQueryEditor);
|
||||||
|
},
|
||||||
|
destroyed () {
|
||||||
|
window.removeEventListener('resize', this.resizeQueryEditor);
|
||||||
|
},
|
||||||
|
beforeDestroy () {
|
||||||
|
window.removeEventListener('keydown', this.onKey);
|
||||||
|
},
|
||||||
|
methods: {
|
||||||
|
...mapActions({
|
||||||
|
addNotification: 'notifications/addNotification',
|
||||||
|
refreshStructure: 'workspaces/refreshStructure',
|
||||||
|
changeBreadcrumbs: 'workspaces/changeBreadcrumbs',
|
||||||
|
setUnsavedChanges: 'workspaces/setUnsavedChanges',
|
||||||
|
newTab: 'workspaces/newTab',
|
||||||
|
removeTab: 'workspaces/removeTab',
|
||||||
|
renameTabs: 'workspaces/renameTabs'
|
||||||
|
}),
|
||||||
|
async saveChanges () {
|
||||||
|
if (this.isSaving) return;
|
||||||
|
this.isSaving = true;
|
||||||
|
const params = {
|
||||||
|
uid: this.connection.uid,
|
||||||
|
schema: this.schema,
|
||||||
|
...this.localRoutine
|
||||||
|
};
|
||||||
|
|
||||||
|
try {
|
||||||
|
const { status, response } = await Routines.createRoutine(params);
|
||||||
|
|
||||||
|
if (status === 'success') {
|
||||||
|
await this.refreshStructure(this.connection.uid);
|
||||||
|
|
||||||
|
this.newTab({
|
||||||
|
uid: this.connection.uid,
|
||||||
|
schema: this.schema,
|
||||||
|
elementName: this.localRoutine.name,
|
||||||
|
elementType: 'routine',
|
||||||
|
type: 'routine-props'
|
||||||
|
});
|
||||||
|
|
||||||
|
this.removeTab({ uid: this.connection.uid, tab: this.tab.uid });
|
||||||
|
this.changeBreadcrumbs({ schema: this.schema, routine: this.localRoutine.name });
|
||||||
|
}
|
||||||
|
else
|
||||||
|
this.addNotification({ status: 'error', message: response });
|
||||||
|
}
|
||||||
|
catch (err) {
|
||||||
|
this.addNotification({ status: 'error', message: err.stack });
|
||||||
|
}
|
||||||
|
|
||||||
|
this.isSaving = false;
|
||||||
|
},
|
||||||
|
clearChanges () {
|
||||||
|
this.localRoutine = JSON.parse(JSON.stringify(this.originalRoutine));
|
||||||
|
this.$refs.queryEditor.editor.session.setValue(this.localRoutine.sql);
|
||||||
|
},
|
||||||
|
resizeQueryEditor () {
|
||||||
|
if (this.$refs.queryEditor) {
|
||||||
|
const footer = document.getElementById('footer');
|
||||||
|
const size = window.innerHeight - this.$refs.queryEditor.$el.getBoundingClientRect().top - footer.offsetHeight;
|
||||||
|
this.editorHeight = size;
|
||||||
|
this.$refs.queryEditor.editor.resize();
|
||||||
|
}
|
||||||
|
},
|
||||||
|
parametersUpdate (parameters) {
|
||||||
|
this.localRoutine = { ...this.localRoutine, parameters };
|
||||||
|
},
|
||||||
|
showParamsModal () {
|
||||||
|
this.isParamsModal = true;
|
||||||
|
},
|
||||||
|
hideParamsModal () {
|
||||||
|
this.isParamsModal = false;
|
||||||
|
},
|
||||||
|
showAskParamsModal () {
|
||||||
|
this.isAskingParameters = true;
|
||||||
|
},
|
||||||
|
hideAskParamsModal () {
|
||||||
|
this.isAskingParameters = false;
|
||||||
|
},
|
||||||
|
onKey (e) {
|
||||||
|
if (this.isSelected) {
|
||||||
|
e.stopPropagation();
|
||||||
|
if (e.ctrlKey && e.keyCode === 83) { // CTRL + S
|
||||||
|
if (this.isChanged)
|
||||||
|
this.saveChanges();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
</script>
|
323
src/renderer/components/WorkspaceTabNewScheduler.vue
Normal file
323
src/renderer/components/WorkspaceTabNewScheduler.vue
Normal file
@@ -0,0 +1,323 @@
|
|||||||
|
<template>
|
||||||
|
<div v-show="isSelected" class="workspace-query-tab column col-12 columns col-gapless">
|
||||||
|
<div class="workspace-query-runner column col-12">
|
||||||
|
<div class="workspace-query-runner-footer">
|
||||||
|
<div class="workspace-query-buttons">
|
||||||
|
<button
|
||||||
|
class="btn btn-primary btn-sm"
|
||||||
|
:disabled="!isChanged"
|
||||||
|
:class="{'loading':isSaving}"
|
||||||
|
title="CTRL+S"
|
||||||
|
@click="saveChanges"
|
||||||
|
>
|
||||||
|
<i class="mdi mdi-24px mdi-content-save mr-1" />
|
||||||
|
<span>{{ $t('word.save') }}</span>
|
||||||
|
</button>
|
||||||
|
<button
|
||||||
|
:disabled="!isChanged"
|
||||||
|
class="btn btn-link btn-sm mr-0"
|
||||||
|
:title="$t('message.clearChanges')"
|
||||||
|
@click="clearChanges"
|
||||||
|
>
|
||||||
|
<i class="mdi mdi-24px mdi-delete-sweep mr-1" />
|
||||||
|
<span>{{ $t('word.clear') }}</span>
|
||||||
|
</button>
|
||||||
|
|
||||||
|
<div class="divider-vert py-3" />
|
||||||
|
<button class="btn btn-dark btn-sm" @click="showTimingModal">
|
||||||
|
<i class="mdi mdi-24px mdi-timer mr-1" />
|
||||||
|
<span>{{ $t('word.timing') }}</span>
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
<div class="workspace-query-info">
|
||||||
|
<div class="d-flex" :title="$t('word.schema')">
|
||||||
|
<i class="mdi mdi-18px mdi-database mr-1" /><b>{{ schema }}</b>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="container">
|
||||||
|
<div class="columns">
|
||||||
|
<div class="column col-auto">
|
||||||
|
<div class="form-group">
|
||||||
|
<label class="form-label">{{ $t('word.name') }}</label>
|
||||||
|
<input
|
||||||
|
ref="firstInput"
|
||||||
|
v-model="localScheduler.name"
|
||||||
|
class="form-input"
|
||||||
|
type="text"
|
||||||
|
>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="column col-auto">
|
||||||
|
<div class="form-group">
|
||||||
|
<label class="form-label">{{ $t('word.definer') }}</label>
|
||||||
|
<select
|
||||||
|
v-if="workspace.users.length"
|
||||||
|
v-model="localScheduler.definer"
|
||||||
|
class="form-select"
|
||||||
|
>
|
||||||
|
<option value="">
|
||||||
|
{{ $t('message.currentUser') }}
|
||||||
|
</option>
|
||||||
|
<option v-if="!isDefinerInUsers" :value="originalScheduler.definer">
|
||||||
|
{{ originalScheduler.definer.replaceAll('`', '') }}
|
||||||
|
</option>
|
||||||
|
<option
|
||||||
|
v-for="user in workspace.users"
|
||||||
|
:key="`${user.name}@${user.host}`"
|
||||||
|
:value="`\`${user.name}\`@\`${user.host}\``"
|
||||||
|
>
|
||||||
|
{{ user.name }}@{{ user.host }}
|
||||||
|
</option>
|
||||||
|
</select>
|
||||||
|
<select v-if="!workspace.users.length" class="form-select">
|
||||||
|
<option value="">
|
||||||
|
{{ $t('message.currentUser') }}
|
||||||
|
</option>
|
||||||
|
</select>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="column">
|
||||||
|
<div class="form-group">
|
||||||
|
<label class="form-label">{{ $t('word.comment') }}</label>
|
||||||
|
<input
|
||||||
|
v-model="localScheduler.comment"
|
||||||
|
class="form-input"
|
||||||
|
type="text"
|
||||||
|
>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="column">
|
||||||
|
<div class="form-group">
|
||||||
|
<label class="form-label mr-2">{{ $t('word.state') }}</label>
|
||||||
|
<label class="form-radio form-inline">
|
||||||
|
<input
|
||||||
|
v-model="localScheduler.state"
|
||||||
|
type="radio"
|
||||||
|
name="state"
|
||||||
|
value="ENABLE"
|
||||||
|
><i class="form-icon" /> ENABLE
|
||||||
|
</label>
|
||||||
|
<label class="form-radio form-inline">
|
||||||
|
<input
|
||||||
|
v-model="localScheduler.state"
|
||||||
|
type="radio"
|
||||||
|
name="state"
|
||||||
|
value="DISABLE"
|
||||||
|
><i class="form-icon" /> DISABLE
|
||||||
|
</label>
|
||||||
|
<label class="form-radio form-inline">
|
||||||
|
<input
|
||||||
|
v-model="localScheduler.state"
|
||||||
|
type="radio"
|
||||||
|
name="state"
|
||||||
|
value="DISABLE ON SLAVE"
|
||||||
|
><i class="form-icon" /> DISABLE ON SLAVE
|
||||||
|
</label>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="workspace-query-results column col-12 mt-2 p-relative">
|
||||||
|
<BaseLoader v-if="isLoading" />
|
||||||
|
<label class="form-label ml-2">{{ $t('message.schedulerBody') }}</label>
|
||||||
|
<QueryEditor
|
||||||
|
v-show="isSelected"
|
||||||
|
ref="queryEditor"
|
||||||
|
:value.sync="localScheduler.sql"
|
||||||
|
:workspace="workspace"
|
||||||
|
:schema="schema"
|
||||||
|
:height="editorHeight"
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
<WorkspaceTabPropsSchedulerTimingModal
|
||||||
|
v-if="isTimingModal"
|
||||||
|
:local-options="localScheduler"
|
||||||
|
:workspace="workspace"
|
||||||
|
@hide="hideTimingModal"
|
||||||
|
@options-update="timingUpdate"
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script>
|
||||||
|
import { mapGetters, mapActions } from 'vuex';
|
||||||
|
import BaseLoader from '@/components/BaseLoader';
|
||||||
|
import QueryEditor from '@/components/QueryEditor';
|
||||||
|
import WorkspaceTabPropsSchedulerTimingModal from '@/components/WorkspaceTabPropsSchedulerTimingModal';
|
||||||
|
import Schedulers from '@/ipc-api/Schedulers';
|
||||||
|
|
||||||
|
export default {
|
||||||
|
name: 'WorkspaceTabNewScheduler',
|
||||||
|
components: {
|
||||||
|
BaseLoader,
|
||||||
|
QueryEditor,
|
||||||
|
WorkspaceTabPropsSchedulerTimingModal
|
||||||
|
},
|
||||||
|
props: {
|
||||||
|
connection: Object,
|
||||||
|
tab: Object,
|
||||||
|
isSelected: Boolean,
|
||||||
|
schema: String
|
||||||
|
},
|
||||||
|
data () {
|
||||||
|
return {
|
||||||
|
isLoading: false,
|
||||||
|
isSaving: false,
|
||||||
|
isTimingModal: false,
|
||||||
|
originalScheduler: {},
|
||||||
|
localScheduler: {},
|
||||||
|
lastScheduler: null,
|
||||||
|
sqlProxy: '',
|
||||||
|
editorHeight: 300
|
||||||
|
};
|
||||||
|
},
|
||||||
|
computed: {
|
||||||
|
...mapGetters({
|
||||||
|
selectedWorkspace: 'workspaces/getSelected',
|
||||||
|
getWorkspace: 'workspaces/getWorkspace'
|
||||||
|
}),
|
||||||
|
workspace () {
|
||||||
|
return this.getWorkspace(this.connection.uid);
|
||||||
|
},
|
||||||
|
tabUid () {
|
||||||
|
return this.$vnode.key;
|
||||||
|
},
|
||||||
|
isChanged () {
|
||||||
|
return JSON.stringify(this.originalScheduler) !== JSON.stringify(this.localScheduler);
|
||||||
|
},
|
||||||
|
isDefinerInUsers () {
|
||||||
|
return this.originalScheduler ? this.workspace.users.some(user => this.originalScheduler.definer === `\`${user.name}\`@\`${user.host}\``) : true;
|
||||||
|
},
|
||||||
|
schemaTables () {
|
||||||
|
const schemaTables = this.workspace.structure
|
||||||
|
.filter(schema => schema.name === this.schema)
|
||||||
|
.map(schema => schema.tables);
|
||||||
|
|
||||||
|
return schemaTables.length ? schemaTables[0].filter(table => table.type === 'table') : [];
|
||||||
|
}
|
||||||
|
},
|
||||||
|
watch: {
|
||||||
|
isSelected (val) {
|
||||||
|
if (val)
|
||||||
|
this.changeBreadcrumbs({ schema: this.schema });
|
||||||
|
},
|
||||||
|
isChanged (val) {
|
||||||
|
this.setUnsavedChanges({ uid: this.connection.uid, tUid: this.tabUid, isChanged: val });
|
||||||
|
}
|
||||||
|
},
|
||||||
|
async created () {
|
||||||
|
this.originalScheduler = {
|
||||||
|
definer: '',
|
||||||
|
sql: 'BEGIN\r\n\r\nEND',
|
||||||
|
name: '',
|
||||||
|
comment: '',
|
||||||
|
execution: 'EVERY',
|
||||||
|
every: ['1', 'DAY'],
|
||||||
|
preserve: true,
|
||||||
|
state: 'DISABLE'
|
||||||
|
};
|
||||||
|
|
||||||
|
this.localScheduler = JSON.parse(JSON.stringify(this.originalScheduler));
|
||||||
|
|
||||||
|
setTimeout(() => {
|
||||||
|
this.resizeQueryEditor();
|
||||||
|
}, 50);
|
||||||
|
|
||||||
|
window.addEventListener('keydown', this.onKey);
|
||||||
|
},
|
||||||
|
mounted () {
|
||||||
|
if (this.isSelected)
|
||||||
|
this.changeBreadcrumbs({ schema: this.schema });
|
||||||
|
|
||||||
|
setTimeout(() => {
|
||||||
|
this.$refs.firstInput.focus();
|
||||||
|
}, 100);
|
||||||
|
|
||||||
|
window.addEventListener('resize', this.resizeQueryEditor);
|
||||||
|
},
|
||||||
|
destroyed () {
|
||||||
|
window.removeEventListener('resize', this.resizeQueryEditor);
|
||||||
|
},
|
||||||
|
beforeDestroy () {
|
||||||
|
window.removeEventListener('keydown', this.onKey);
|
||||||
|
},
|
||||||
|
methods: {
|
||||||
|
...mapActions({
|
||||||
|
addNotification: 'notifications/addNotification',
|
||||||
|
refreshStructure: 'workspaces/refreshStructure',
|
||||||
|
changeBreadcrumbs: 'workspaces/changeBreadcrumbs',
|
||||||
|
setUnsavedChanges: 'workspaces/setUnsavedChanges',
|
||||||
|
newTab: 'workspaces/newTab',
|
||||||
|
removeTab: 'workspaces/removeTab',
|
||||||
|
renameTabs: 'workspaces/renameTabs'
|
||||||
|
}),
|
||||||
|
async saveChanges () {
|
||||||
|
if (this.isSaving) return;
|
||||||
|
this.isSaving = true;
|
||||||
|
const params = {
|
||||||
|
uid: this.connection.uid,
|
||||||
|
schema: this.schema,
|
||||||
|
...this.localScheduler
|
||||||
|
};
|
||||||
|
|
||||||
|
try {
|
||||||
|
const { status, response } = await Schedulers.createScheduler(params);
|
||||||
|
|
||||||
|
if (status === 'success') {
|
||||||
|
await this.refreshStructure(this.connection.uid);
|
||||||
|
|
||||||
|
this.newTab({
|
||||||
|
uid: this.connection.uid,
|
||||||
|
schema: this.schema,
|
||||||
|
elementName: this.localScheduler.name,
|
||||||
|
elementType: 'scheduler',
|
||||||
|
type: 'scheduler-props'
|
||||||
|
});
|
||||||
|
|
||||||
|
this.removeTab({ uid: this.connection.uid, tab: this.tab.uid });
|
||||||
|
this.changeBreadcrumbs({ schema: this.schema, scheduler: this.localScheduler.name });
|
||||||
|
}
|
||||||
|
else
|
||||||
|
this.addNotification({ status: 'error', message: response });
|
||||||
|
}
|
||||||
|
catch (err) {
|
||||||
|
this.addNotification({ status: 'error', message: err.stack });
|
||||||
|
}
|
||||||
|
|
||||||
|
this.isSaving = false;
|
||||||
|
},
|
||||||
|
clearChanges () {
|
||||||
|
this.localScheduler = JSON.parse(JSON.stringify(this.originalScheduler));
|
||||||
|
this.$refs.queryEditor.editor.session.setValue(this.localScheduler.sql);
|
||||||
|
},
|
||||||
|
resizeQueryEditor () {
|
||||||
|
if (this.$refs.queryEditor) {
|
||||||
|
const footer = document.getElementById('footer');
|
||||||
|
const size = window.innerHeight - this.$refs.queryEditor.$el.getBoundingClientRect().top - footer.offsetHeight;
|
||||||
|
this.editorHeight = size;
|
||||||
|
this.$refs.queryEditor.editor.resize();
|
||||||
|
}
|
||||||
|
},
|
||||||
|
showTimingModal () {
|
||||||
|
this.isTimingModal = true;
|
||||||
|
},
|
||||||
|
hideTimingModal () {
|
||||||
|
this.isTimingModal = false;
|
||||||
|
},
|
||||||
|
timingUpdate (options) {
|
||||||
|
this.localScheduler = options;
|
||||||
|
},
|
||||||
|
onKey (e) {
|
||||||
|
if (this.isSelected) {
|
||||||
|
e.stopPropagation();
|
||||||
|
if (e.ctrlKey && e.keyCode === 83) { // CTRL + S
|
||||||
|
if (this.isChanged)
|
||||||
|
this.saveChanges();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
</script>
|
452
src/renderer/components/WorkspaceTabNewTable.vue
Normal file
452
src/renderer/components/WorkspaceTabNewTable.vue
Normal file
@@ -0,0 +1,452 @@
|
|||||||
|
<template>
|
||||||
|
<div v-show="isSelected" class="workspace-query-tab column col-12 columns col-gapless">
|
||||||
|
<div class="workspace-query-runner column col-12">
|
||||||
|
<div class="workspace-query-runner-footer">
|
||||||
|
<div class="workspace-query-buttons">
|
||||||
|
<button
|
||||||
|
class="btn btn-primary btn-sm"
|
||||||
|
:disabled="!isChanged"
|
||||||
|
:class="{'loading':isSaving}"
|
||||||
|
title="CTRL+S"
|
||||||
|
@click="saveChanges"
|
||||||
|
>
|
||||||
|
<i class="mdi mdi-24px mdi-content-save mr-1" />
|
||||||
|
<span>{{ $t('word.save') }}</span>
|
||||||
|
</button>
|
||||||
|
<button
|
||||||
|
:disabled="!isChanged || isSaving"
|
||||||
|
class="btn btn-link btn-sm mr-0"
|
||||||
|
:title="$t('message.clearChanges')"
|
||||||
|
@click="clearChanges"
|
||||||
|
>
|
||||||
|
<i class="mdi mdi-24px mdi-delete-sweep mr-1" />
|
||||||
|
<span>{{ $t('word.clear') }}</span>
|
||||||
|
</button>
|
||||||
|
|
||||||
|
<div class="divider-vert py-3" />
|
||||||
|
|
||||||
|
<button
|
||||||
|
:disabled="isSaving"
|
||||||
|
class="btn btn-dark btn-sm"
|
||||||
|
:title="$t('message.addNewField')"
|
||||||
|
@click="addField"
|
||||||
|
>
|
||||||
|
<i class="mdi mdi-24px mdi-playlist-plus mr-1" />
|
||||||
|
<span>{{ $t('word.add') }}</span>
|
||||||
|
</button>
|
||||||
|
<button
|
||||||
|
:disabled="isSaving || !localFields.length"
|
||||||
|
class="btn btn-dark btn-sm"
|
||||||
|
:title="$t('message.manageIndexes')"
|
||||||
|
@click="showIntdexesModal"
|
||||||
|
>
|
||||||
|
<i class="mdi mdi-24px mdi-key mdi-rotate-45 mr-1" />
|
||||||
|
<span>{{ $t('word.indexes') }}</span>
|
||||||
|
</button>
|
||||||
|
<button
|
||||||
|
class="btn btn-dark btn-sm"
|
||||||
|
:disabled="isSaving || !localFields.length"
|
||||||
|
@click="showForeignModal"
|
||||||
|
>
|
||||||
|
<i class="mdi mdi-24px mdi-key-link mr-1" />
|
||||||
|
<span>{{ $t('word.foreignKeys') }}</span>
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
<div class="workspace-query-info">
|
||||||
|
<div class="d-flex" :title="$t('word.schema')">
|
||||||
|
<i class="mdi mdi-18px mdi-database mr-1" /><b>{{ schema }}</b>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="container">
|
||||||
|
<div class="columns mb-4">
|
||||||
|
<div class="column col-auto">
|
||||||
|
<div class="form-group">
|
||||||
|
<label class="form-label">{{ $t('word.name') }}</label>
|
||||||
|
<input
|
||||||
|
ref="firstInput"
|
||||||
|
v-model="localOptions.name"
|
||||||
|
class="form-input"
|
||||||
|
type="text"
|
||||||
|
>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div v-if="workspace.customizations.comment" class="column">
|
||||||
|
<div class="form-group">
|
||||||
|
<label class="form-label">{{ $t('word.comment') }}</label>
|
||||||
|
<input
|
||||||
|
v-model="localOptions.comment"
|
||||||
|
class="form-input"
|
||||||
|
type="text"
|
||||||
|
>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div v-if="workspace.customizations.collations" class="column col-auto">
|
||||||
|
<div class="form-group">
|
||||||
|
<label class="form-label">
|
||||||
|
{{ $t('word.collation') }}
|
||||||
|
</label>
|
||||||
|
<select v-model="localOptions.collation" class="form-select">
|
||||||
|
<option
|
||||||
|
v-for="collation in workspace.collations"
|
||||||
|
:key="collation.id"
|
||||||
|
:value="collation.collation"
|
||||||
|
>
|
||||||
|
{{ collation.collation }}
|
||||||
|
</option>
|
||||||
|
</select>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div v-if="workspace.customizations.engines" class="column col-auto">
|
||||||
|
<div class="form-group">
|
||||||
|
<label class="form-label">
|
||||||
|
{{ $t('word.engine') }}
|
||||||
|
</label>
|
||||||
|
<select v-model="localOptions.engine" class="form-select">
|
||||||
|
<option
|
||||||
|
v-for="engine in workspace.engines"
|
||||||
|
:key="engine.name"
|
||||||
|
:value="engine.name"
|
||||||
|
>
|
||||||
|
{{ engine.name }}
|
||||||
|
</option>
|
||||||
|
</select>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="workspace-query-results column col-12 p-relative">
|
||||||
|
<BaseLoader v-if="isLoading" />
|
||||||
|
<WorkspaceTabNewTableEmptyState v-if="!localFields.length" @new-field="addField" />
|
||||||
|
<WorkspaceTabPropsTableFields
|
||||||
|
v-if="localFields.length"
|
||||||
|
ref="indexTable"
|
||||||
|
:fields="localFields"
|
||||||
|
:indexes="localIndexes"
|
||||||
|
:foreigns="localKeyUsage"
|
||||||
|
:tab-uid="tabUid"
|
||||||
|
:conn-uid="connection.uid"
|
||||||
|
:index-types="workspace.indexTypes"
|
||||||
|
table="new"
|
||||||
|
:schema="schema"
|
||||||
|
mode="table"
|
||||||
|
@duplicate-field="duplicateField"
|
||||||
|
@remove-field="removeField"
|
||||||
|
@add-new-index="addNewIndex"
|
||||||
|
@add-to-index="addToIndex"
|
||||||
|
@rename-field="renameField"
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
<WorkspaceTabPropsTableIndexesModal
|
||||||
|
v-if="isIndexesModal"
|
||||||
|
:local-indexes="localIndexes"
|
||||||
|
table="new"
|
||||||
|
:fields="localFields"
|
||||||
|
:index-types="workspace.indexTypes"
|
||||||
|
:workspace="workspace"
|
||||||
|
@hide="hideIndexesModal"
|
||||||
|
@indexes-update="indexesUpdate"
|
||||||
|
/>
|
||||||
|
<WorkspaceTabPropsTableForeignModal
|
||||||
|
v-if="isForeignModal"
|
||||||
|
:local-key-usage="localKeyUsage"
|
||||||
|
:connection="connection"
|
||||||
|
table="new"
|
||||||
|
:schema="schema"
|
||||||
|
:schema-tables="schemaTables"
|
||||||
|
:fields="localFields"
|
||||||
|
:workspace="workspace"
|
||||||
|
@hide="hideForeignModal"
|
||||||
|
@foreigns-update="foreignsUpdate"
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script>
|
||||||
|
import { mapGetters, mapActions } from 'vuex';
|
||||||
|
import { uidGen } from 'common/libs/uidGen';
|
||||||
|
import Tables from '@/ipc-api/Tables';
|
||||||
|
import BaseLoader from '@/components/BaseLoader';
|
||||||
|
import WorkspaceTabPropsTableFields from '@/components/WorkspaceTabPropsTableFields';
|
||||||
|
import WorkspaceTabPropsTableIndexesModal from '@/components/WorkspaceTabPropsTableIndexesModal';
|
||||||
|
import WorkspaceTabPropsTableForeignModal from '@/components/WorkspaceTabPropsTableForeignModal';
|
||||||
|
import WorkspaceTabNewTableEmptyState from '@/components/WorkspaceTabNewTableEmptyState';
|
||||||
|
|
||||||
|
export default {
|
||||||
|
name: 'WorkspaceTabNewTable',
|
||||||
|
components: {
|
||||||
|
BaseLoader,
|
||||||
|
WorkspaceTabPropsTableFields,
|
||||||
|
WorkspaceTabPropsTableIndexesModal,
|
||||||
|
WorkspaceTabPropsTableForeignModal,
|
||||||
|
WorkspaceTabNewTableEmptyState
|
||||||
|
},
|
||||||
|
props: {
|
||||||
|
connection: Object,
|
||||||
|
tab: Object,
|
||||||
|
isSelected: Boolean,
|
||||||
|
schema: String
|
||||||
|
},
|
||||||
|
data () {
|
||||||
|
return {
|
||||||
|
isLoading: false,
|
||||||
|
isSaving: false,
|
||||||
|
isIndexesModal: false,
|
||||||
|
isForeignModal: false,
|
||||||
|
isOptionsChanging: false,
|
||||||
|
originalFields: [],
|
||||||
|
localFields: [],
|
||||||
|
originalKeyUsage: [],
|
||||||
|
localKeyUsage: [],
|
||||||
|
originalIndexes: [],
|
||||||
|
localIndexes: [],
|
||||||
|
tableOptions: {},
|
||||||
|
localOptions: {},
|
||||||
|
lastTable: null,
|
||||||
|
newFieldsCounter: 0
|
||||||
|
};
|
||||||
|
},
|
||||||
|
computed: {
|
||||||
|
...mapGetters({
|
||||||
|
getWorkspace: 'workspaces/getWorkspace',
|
||||||
|
selectedWorkspace: 'workspaces/getSelected',
|
||||||
|
getDatabaseVariable: 'workspaces/getDatabaseVariable'
|
||||||
|
}),
|
||||||
|
workspace () {
|
||||||
|
return this.getWorkspace(this.connection.uid);
|
||||||
|
},
|
||||||
|
tabUid () {
|
||||||
|
return this.$vnode.key;
|
||||||
|
},
|
||||||
|
defaultCollation () {
|
||||||
|
if (this.workspace.customizations.collations)
|
||||||
|
return this.getDatabaseVariable(this.selectedWorkspace, 'collation_server').value || '';
|
||||||
|
return '';
|
||||||
|
},
|
||||||
|
defaultEngine () {
|
||||||
|
if (this.workspace.customizations.engines)
|
||||||
|
return this.workspace.engines.find(engine => engine.isDefault).name;
|
||||||
|
return '';
|
||||||
|
},
|
||||||
|
schemaTables () {
|
||||||
|
const schemaTables = this.workspace.structure
|
||||||
|
.filter(schema => schema.name === this.schema)
|
||||||
|
.map(schema => schema.tables);
|
||||||
|
|
||||||
|
return schemaTables.length ? schemaTables[0].filter(table => table.type === 'table') : [];
|
||||||
|
},
|
||||||
|
isChanged () {
|
||||||
|
return JSON.stringify(this.originalFields) !== JSON.stringify(this.localFields) ||
|
||||||
|
JSON.stringify(this.originalKeyUsage) !== JSON.stringify(this.localKeyUsage) ||
|
||||||
|
JSON.stringify(this.originalIndexes) !== JSON.stringify(this.localIndexes) ||
|
||||||
|
JSON.stringify(this.tableOptions) !== JSON.stringify(this.localOptions);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
watch: {
|
||||||
|
isSelected (val) {
|
||||||
|
if (val)
|
||||||
|
this.changeBreadcrumbs({ schema: this.schema });
|
||||||
|
},
|
||||||
|
isChanged (val) {
|
||||||
|
this.setUnsavedChanges({ uid: this.connection.uid, tUid: this.tabUid, isChanged: val });
|
||||||
|
}
|
||||||
|
},
|
||||||
|
created () {
|
||||||
|
this.tableOptions = {
|
||||||
|
name: '',
|
||||||
|
type: 'table',
|
||||||
|
engine: this.defaultEngine,
|
||||||
|
comment: '',
|
||||||
|
collation: this.defaultCollation
|
||||||
|
};
|
||||||
|
|
||||||
|
this.localOptions = JSON.parse(JSON.stringify(this.tableOptions));
|
||||||
|
window.addEventListener('keydown', this.onKey);
|
||||||
|
},
|
||||||
|
mounted () {
|
||||||
|
if (this.isSelected)
|
||||||
|
this.changeBreadcrumbs({ schema: this.schema });
|
||||||
|
|
||||||
|
setTimeout(() => {
|
||||||
|
this.$refs.firstInput.focus();
|
||||||
|
}, 100);
|
||||||
|
},
|
||||||
|
beforeDestroy () {
|
||||||
|
window.removeEventListener('keydown', this.onKey);
|
||||||
|
},
|
||||||
|
methods: {
|
||||||
|
...mapActions({
|
||||||
|
addNotification: 'notifications/addNotification',
|
||||||
|
refreshStructure: 'workspaces/refreshStructure',
|
||||||
|
setUnsavedChanges: 'workspaces/setUnsavedChanges',
|
||||||
|
newTab: 'workspaces/newTab',
|
||||||
|
renameTabs: 'workspaces/renameTabs',
|
||||||
|
removeTab: 'workspaces/removeTab',
|
||||||
|
changeBreadcrumbs: 'workspaces/changeBreadcrumbs'
|
||||||
|
}),
|
||||||
|
async saveChanges () {
|
||||||
|
if (this.isSaving) return;
|
||||||
|
this.isSaving = true;
|
||||||
|
|
||||||
|
const params = {
|
||||||
|
uid: this.connection.uid,
|
||||||
|
schema: this.schema,
|
||||||
|
fields: this.localFields,
|
||||||
|
foreigns: this.localKeyUsage,
|
||||||
|
indexes: this.localIndexes,
|
||||||
|
options: this.localOptions
|
||||||
|
};
|
||||||
|
|
||||||
|
try {
|
||||||
|
const { status, response } = await Tables.createTable(params);
|
||||||
|
|
||||||
|
if (status === 'success') {
|
||||||
|
await this.refreshStructure(this.connection.uid);
|
||||||
|
|
||||||
|
this.newTab({
|
||||||
|
uid: this.connection.uid,
|
||||||
|
schema: this.schema,
|
||||||
|
elementName: this.localOptions.name,
|
||||||
|
elementType: 'table',
|
||||||
|
type: 'table-props'
|
||||||
|
});
|
||||||
|
|
||||||
|
this.removeTab({ uid: this.connection.uid, tab: this.tab.uid });
|
||||||
|
this.changeBreadcrumbs({ schema: this.schema, table: this.localOptions.name });
|
||||||
|
}
|
||||||
|
else
|
||||||
|
this.addNotification({ status: 'error', message: response });
|
||||||
|
}
|
||||||
|
catch (err) {
|
||||||
|
this.addNotification({ status: 'error', message: err.stack });
|
||||||
|
}
|
||||||
|
|
||||||
|
this.isSaving = false;
|
||||||
|
this.newFieldsCounter = 0;
|
||||||
|
},
|
||||||
|
clearChanges () {
|
||||||
|
this.localFields = JSON.parse(JSON.stringify(this.originalFields));
|
||||||
|
this.localIndexes = JSON.parse(JSON.stringify(this.originalIndexes));
|
||||||
|
this.localKeyUsage = JSON.parse(JSON.stringify(this.originalKeyUsage));
|
||||||
|
|
||||||
|
this.tableOptions = {
|
||||||
|
name: '',
|
||||||
|
type: 'table',
|
||||||
|
engine: this.defaultEngine,
|
||||||
|
comment: '',
|
||||||
|
collation: this.defaultCollation
|
||||||
|
};
|
||||||
|
|
||||||
|
this.localOptions = JSON.parse(JSON.stringify(this.tableOptions));
|
||||||
|
this.newFieldsCounter = 0;
|
||||||
|
},
|
||||||
|
addField () {
|
||||||
|
this.localFields.push({
|
||||||
|
_id: uidGen(),
|
||||||
|
name: `${this.$tc('word.field', 1)}_${++this.newFieldsCounter}`,
|
||||||
|
key: '',
|
||||||
|
type: this.workspace.dataTypes[0].types[0].name,
|
||||||
|
schema: this.schema,
|
||||||
|
numPrecision: null,
|
||||||
|
numLength: this.workspace.dataTypes[0].types[0].length,
|
||||||
|
datePrecision: null,
|
||||||
|
charLength: null,
|
||||||
|
nullable: false,
|
||||||
|
unsigned: false,
|
||||||
|
zerofill: false,
|
||||||
|
order: this.localFields.length + 1,
|
||||||
|
default: null,
|
||||||
|
charset: null,
|
||||||
|
collation: null,
|
||||||
|
autoIncrement: false,
|
||||||
|
onUpdate: '',
|
||||||
|
comment: ''
|
||||||
|
});
|
||||||
|
|
||||||
|
setTimeout(() => {
|
||||||
|
const scrollable = this.$refs.indexTable.$refs.tableWrapper;
|
||||||
|
scrollable.scrollTop = scrollable.scrollHeight + 30;
|
||||||
|
}, 20);
|
||||||
|
},
|
||||||
|
renameField (payload) {
|
||||||
|
this.localIndexes = this.localIndexes.map(index => {
|
||||||
|
const fi = index.fields.findIndex(field => field === payload.old);
|
||||||
|
if (fi !== -1)
|
||||||
|
index.fields[fi] = payload.new;
|
||||||
|
return index;
|
||||||
|
});
|
||||||
|
|
||||||
|
this.localKeyUsage = this.localKeyUsage.map(key => {
|
||||||
|
if (key.field === payload.old)
|
||||||
|
key.field = payload.new;
|
||||||
|
return key;
|
||||||
|
});
|
||||||
|
},
|
||||||
|
duplicateField (uid) {
|
||||||
|
const fieldToClone = Object.assign({}, this.localFields.find(field => field._id === uid));
|
||||||
|
fieldToClone._id = uidGen();
|
||||||
|
fieldToClone.name = `${fieldToClone.name}_copy`;
|
||||||
|
fieldToClone.order = this.localFields.length + 1;
|
||||||
|
this.localFields = [...this.localFields, fieldToClone];
|
||||||
|
|
||||||
|
setTimeout(() => {
|
||||||
|
const scrollable = this.$refs.indexTable.$refs.tableWrapper;
|
||||||
|
scrollable.scrollTop = scrollable.scrollHeight + 30;
|
||||||
|
}, 20);
|
||||||
|
},
|
||||||
|
removeField (uid) {
|
||||||
|
this.localFields = this.localFields.filter(field => field._id !== uid);
|
||||||
|
},
|
||||||
|
addNewIndex (payload) {
|
||||||
|
this.localIndexes = [...this.localIndexes, {
|
||||||
|
_id: uidGen(),
|
||||||
|
name: payload.index === 'PRIMARY' ? 'PRIMARY' : payload.field,
|
||||||
|
fields: [payload.field],
|
||||||
|
type: payload.index,
|
||||||
|
comment: '',
|
||||||
|
indexType: 'BTREE',
|
||||||
|
indexComment: '',
|
||||||
|
cardinality: 0
|
||||||
|
}];
|
||||||
|
},
|
||||||
|
addToIndex (payload) {
|
||||||
|
this.localIndexes = this.localIndexes.map(index => {
|
||||||
|
if (index._id === payload.index) index.fields.push(payload.field);
|
||||||
|
return index;
|
||||||
|
});
|
||||||
|
},
|
||||||
|
optionsUpdate (options) {
|
||||||
|
this.localOptions = options;
|
||||||
|
},
|
||||||
|
showIntdexesModal () {
|
||||||
|
this.isIndexesModal = true;
|
||||||
|
},
|
||||||
|
hideIndexesModal () {
|
||||||
|
this.isIndexesModal = false;
|
||||||
|
},
|
||||||
|
indexesUpdate (indexes) {
|
||||||
|
this.localIndexes = indexes;
|
||||||
|
},
|
||||||
|
showForeignModal () {
|
||||||
|
this.isForeignModal = true;
|
||||||
|
},
|
||||||
|
hideForeignModal () {
|
||||||
|
this.isForeignModal = false;
|
||||||
|
},
|
||||||
|
foreignsUpdate (foreigns) {
|
||||||
|
this.localKeyUsage = foreigns;
|
||||||
|
},
|
||||||
|
onKey (e) {
|
||||||
|
if (this.isSelected) {
|
||||||
|
e.stopPropagation();
|
||||||
|
if (e.ctrlKey && e.keyCode === 83) { // CTRL + S
|
||||||
|
if (this.isChanged)
|
||||||
|
this.saveChanges();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
</script>
|
33
src/renderer/components/WorkspaceTabNewTableEmptyState.vue
Normal file
33
src/renderer/components/WorkspaceTabNewTableEmptyState.vue
Normal file
@@ -0,0 +1,33 @@
|
|||||||
|
<template>
|
||||||
|
<div class="column col-12 empty">
|
||||||
|
<p class="h6 empty-subtitle">
|
||||||
|
{{ $t('message.thereAreNoTableFields') }}
|
||||||
|
</p>
|
||||||
|
<div class="empty-action">
|
||||||
|
<button class="btn btn-gray d-flex" @click="$emit('new-field')">
|
||||||
|
<i class="mdi mdi-24px mdi-playlist-plus mr-2" />
|
||||||
|
{{ $t('message.addNewField') }}
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script>
|
||||||
|
export default {
|
||||||
|
name: 'WorkspaceTabNewTableEmptyState'
|
||||||
|
};
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<style scoped>
|
||||||
|
.empty {
|
||||||
|
border-radius: 0;
|
||||||
|
background: transparent;
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
justify-content: center;
|
||||||
|
align-items: center;
|
||||||
|
margin-left: auto;
|
||||||
|
margin-right: auto;
|
||||||
|
z-index: 9;
|
||||||
|
}
|
||||||
|
</style>
|
323
src/renderer/components/WorkspaceTabNewTrigger.vue
Normal file
323
src/renderer/components/WorkspaceTabNewTrigger.vue
Normal file
@@ -0,0 +1,323 @@
|
|||||||
|
<template>
|
||||||
|
<div v-show="isSelected" class="workspace-query-tab column col-12 columns col-gapless">
|
||||||
|
<div class="workspace-query-runner column col-12">
|
||||||
|
<div class="workspace-query-runner-footer">
|
||||||
|
<div class="workspace-query-buttons">
|
||||||
|
<button
|
||||||
|
class="btn btn-primary btn-sm"
|
||||||
|
:disabled="!isChanged"
|
||||||
|
:class="{'loading':isSaving}"
|
||||||
|
title="CTRL+S"
|
||||||
|
@click="saveChanges"
|
||||||
|
>
|
||||||
|
<i class="mdi mdi-24px mdi-content-save mr-1" />
|
||||||
|
<span>{{ $t('word.save') }}</span>
|
||||||
|
</button>
|
||||||
|
<button
|
||||||
|
:disabled="!isChanged"
|
||||||
|
class="btn btn-link btn-sm mr-0"
|
||||||
|
:title="$t('message.clearChanges')"
|
||||||
|
@click="clearChanges"
|
||||||
|
>
|
||||||
|
<i class="mdi mdi-24px mdi-delete-sweep mr-1" />
|
||||||
|
<span>{{ $t('word.clear') }}</span>
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
<div class="workspace-query-info">
|
||||||
|
<div class="d-flex" :title="$t('word.schema')">
|
||||||
|
<i class="mdi mdi-18px mdi-database mr-1" /><b>{{ schema }}</b>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="container">
|
||||||
|
<div class="columns">
|
||||||
|
<div class="column col-auto">
|
||||||
|
<div class="form-group">
|
||||||
|
<label class="form-label">{{ $t('word.name') }}</label>
|
||||||
|
<input
|
||||||
|
ref="firstInput"
|
||||||
|
v-model="localTrigger.name"
|
||||||
|
class="form-input"
|
||||||
|
type="text"
|
||||||
|
>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div v-if="customizations.definer" class="column col-auto">
|
||||||
|
<div class="form-group">
|
||||||
|
<label class="form-label">{{ $t('word.definer') }}</label>
|
||||||
|
<select
|
||||||
|
v-if="workspace.users.length"
|
||||||
|
v-model="localTrigger.definer"
|
||||||
|
class="form-select"
|
||||||
|
>
|
||||||
|
<option value="">
|
||||||
|
{{ $t('message.currentUser') }}
|
||||||
|
</option>
|
||||||
|
<option v-if="!isDefinerInUsers" :value="originalTrigger.definer">
|
||||||
|
{{ originalTrigger.definer.replaceAll('`', '') }}
|
||||||
|
</option>
|
||||||
|
<option
|
||||||
|
v-for="user in workspace.users"
|
||||||
|
:key="`${user.name}@${user.host}`"
|
||||||
|
:value="`\`${user.name}\`@\`${user.host}\``"
|
||||||
|
>
|
||||||
|
{{ user.name }}@{{ user.host }}
|
||||||
|
</option>
|
||||||
|
</select>
|
||||||
|
<select v-if="!workspace.users.length" class="form-select">
|
||||||
|
<option value="">
|
||||||
|
{{ $t('message.currentUser') }}
|
||||||
|
</option>
|
||||||
|
</select>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<fieldset class="column columns mb-0" :disabled="customizations.triggerOnlyRename">
|
||||||
|
<div class="column col-auto">
|
||||||
|
<div class="form-group">
|
||||||
|
<label class="form-label">{{ $t('word.table') }}</label>
|
||||||
|
<select v-model="localTrigger.table" class="form-select">
|
||||||
|
<option v-for="table in schemaTables" :key="table.name">
|
||||||
|
{{ table.name }}
|
||||||
|
</option>
|
||||||
|
</select>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="column col-auto">
|
||||||
|
<div class="form-group">
|
||||||
|
<label class="form-label">{{ $t('word.event') }}</label>
|
||||||
|
<div class="input-group">
|
||||||
|
<select v-model="localTrigger.activation" class="form-select">
|
||||||
|
<option>BEFORE</option>
|
||||||
|
<option>AFTER</option>
|
||||||
|
</select>
|
||||||
|
<select
|
||||||
|
v-if="!customizations.triggerMultipleEvents"
|
||||||
|
v-model="localTrigger.event"
|
||||||
|
class="form-select"
|
||||||
|
>
|
||||||
|
<option v-for="event in Object.keys(localEvents)" :key="event">
|
||||||
|
{{ event }}
|
||||||
|
</option>
|
||||||
|
</select>
|
||||||
|
<div v-if="customizations.triggerMultipleEvents" class="px-4">
|
||||||
|
<label
|
||||||
|
v-for="event in Object.keys(localEvents)"
|
||||||
|
:key="event"
|
||||||
|
class="form-checkbox form-inline"
|
||||||
|
@change.prevent="changeEvents(event)"
|
||||||
|
>
|
||||||
|
<input :checked="localEvents[event]" type="checkbox"><i class="form-icon" /> {{ event }}
|
||||||
|
</label>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</fieldset>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="workspace-query-results column col-12 mt-2 p-relative">
|
||||||
|
<BaseLoader v-if="isLoading" />
|
||||||
|
<label class="form-label ml-2">{{ $t('message.triggerStatement') }}</label>
|
||||||
|
<QueryEditor
|
||||||
|
v-show="isSelected"
|
||||||
|
ref="queryEditor"
|
||||||
|
:value.sync="localTrigger.sql"
|
||||||
|
:workspace="workspace"
|
||||||
|
:schema="schema"
|
||||||
|
:height="editorHeight"
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script>
|
||||||
|
import QueryEditor from '@/components/QueryEditor';
|
||||||
|
import { mapGetters, mapActions } from 'vuex';
|
||||||
|
import BaseLoader from '@/components/BaseLoader';
|
||||||
|
import Triggers from '@/ipc-api/Triggers';
|
||||||
|
|
||||||
|
export default {
|
||||||
|
name: 'WorkspaceTabNewTrigger',
|
||||||
|
components: {
|
||||||
|
BaseLoader,
|
||||||
|
QueryEditor
|
||||||
|
},
|
||||||
|
props: {
|
||||||
|
connection: Object,
|
||||||
|
tab: Object,
|
||||||
|
isSelected: Boolean,
|
||||||
|
schema: String
|
||||||
|
},
|
||||||
|
data () {
|
||||||
|
return {
|
||||||
|
isLoading: false,
|
||||||
|
isSaving: false,
|
||||||
|
originalTrigger: {},
|
||||||
|
localTrigger: {},
|
||||||
|
lastTrigger: null,
|
||||||
|
sqlProxy: '',
|
||||||
|
editorHeight: 300,
|
||||||
|
localEvents: { INSERT: false, UPDATE: false, DELETE: false }
|
||||||
|
};
|
||||||
|
},
|
||||||
|
computed: {
|
||||||
|
...mapGetters({
|
||||||
|
selectedWorkspace: 'workspaces/getSelected',
|
||||||
|
getWorkspace: 'workspaces/getWorkspace'
|
||||||
|
}),
|
||||||
|
workspace () {
|
||||||
|
return this.getWorkspace(this.connection.uid);
|
||||||
|
},
|
||||||
|
tabUid () {
|
||||||
|
return this.$vnode.key;
|
||||||
|
},
|
||||||
|
customizations () {
|
||||||
|
return this.workspace.customizations;
|
||||||
|
},
|
||||||
|
isChanged () {
|
||||||
|
return JSON.stringify(this.originalTrigger) !== JSON.stringify(this.localTrigger);
|
||||||
|
},
|
||||||
|
isDefinerInUsers () {
|
||||||
|
return this.originalTrigger ? this.workspace.users.some(user => this.originalTrigger.definer === `\`${user.name}\`@\`${user.host}\``) : true;
|
||||||
|
},
|
||||||
|
schemaTables () {
|
||||||
|
const schemaTables = this.workspace.structure
|
||||||
|
.filter(schema => schema.name === this.schema)
|
||||||
|
.map(schema => schema.tables);
|
||||||
|
|
||||||
|
return schemaTables.length ? schemaTables[0].filter(table => table.type === 'table') : [];
|
||||||
|
}
|
||||||
|
},
|
||||||
|
watch: {
|
||||||
|
isSelected (val) {
|
||||||
|
if (val)
|
||||||
|
this.changeBreadcrumbs({ schema: this.schema });
|
||||||
|
},
|
||||||
|
isChanged (val) {
|
||||||
|
this.setUnsavedChanges({ uid: this.connection.uid, tUid: this.tabUid, isChanged: val });
|
||||||
|
}
|
||||||
|
},
|
||||||
|
created () {
|
||||||
|
this.originalTrigger = {
|
||||||
|
sql: this.customizations.triggerSql,
|
||||||
|
definer: '',
|
||||||
|
table: this.schemaTables.length ? this.schemaTables[0].name : null,
|
||||||
|
activation: 'BEFORE',
|
||||||
|
event: this.customizations.triggerMultipleEvents ? ['INSERT'] : 'INSERT',
|
||||||
|
name: ''
|
||||||
|
};
|
||||||
|
|
||||||
|
this.localTrigger = JSON.parse(JSON.stringify(this.originalTrigger));
|
||||||
|
|
||||||
|
setTimeout(() => {
|
||||||
|
this.resizeQueryEditor();
|
||||||
|
}, 50);
|
||||||
|
|
||||||
|
window.addEventListener('keydown', this.onKey);
|
||||||
|
},
|
||||||
|
mounted () {
|
||||||
|
if (this.isSelected)
|
||||||
|
this.changeBreadcrumbs({ schema: this.schema });
|
||||||
|
|
||||||
|
setTimeout(() => {
|
||||||
|
this.$refs.firstInput.focus();
|
||||||
|
}, 100);
|
||||||
|
|
||||||
|
window.addEventListener('resize', this.resizeQueryEditor);
|
||||||
|
},
|
||||||
|
destroyed () {
|
||||||
|
window.removeEventListener('resize', this.resizeQueryEditor);
|
||||||
|
},
|
||||||
|
beforeDestroy () {
|
||||||
|
window.removeEventListener('keydown', this.onKey);
|
||||||
|
},
|
||||||
|
methods: {
|
||||||
|
...mapActions({
|
||||||
|
addNotification: 'notifications/addNotification',
|
||||||
|
refreshStructure: 'workspaces/refreshStructure',
|
||||||
|
changeBreadcrumbs: 'workspaces/changeBreadcrumbs',
|
||||||
|
setUnsavedChanges: 'workspaces/setUnsavedChanges',
|
||||||
|
newTab: 'workspaces/newTab',
|
||||||
|
removeTab: 'workspaces/removeTab',
|
||||||
|
renameTabs: 'workspaces/renameTabs'
|
||||||
|
}),
|
||||||
|
changeEvents (event) {
|
||||||
|
if (this.customizations.triggerMultipleEvents) {
|
||||||
|
this.localEvents[event] = !this.localEvents[event];
|
||||||
|
this.localTrigger.event = [];
|
||||||
|
for (const key in this.localEvents) {
|
||||||
|
if (this.localEvents[key])
|
||||||
|
this.localTrigger.event.push(key);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
async saveChanges () {
|
||||||
|
if (this.isSaving) return;
|
||||||
|
this.isSaving = true;
|
||||||
|
const params = {
|
||||||
|
uid: this.connection.uid,
|
||||||
|
schema: this.schema,
|
||||||
|
...this.localTrigger
|
||||||
|
};
|
||||||
|
|
||||||
|
try {
|
||||||
|
const { status, response } = await Triggers.createTrigger(params);
|
||||||
|
|
||||||
|
if (status === 'success') {
|
||||||
|
await this.refreshStructure(this.connection.uid);
|
||||||
|
|
||||||
|
this.newTab({
|
||||||
|
uid: this.connection.uid,
|
||||||
|
schema: this.schema,
|
||||||
|
elementName: this.localTrigger.name,
|
||||||
|
elementType: 'trigger',
|
||||||
|
type: 'trigger-props'
|
||||||
|
});
|
||||||
|
|
||||||
|
this.removeTab({ uid: this.connection.uid, tab: this.tab.uid });
|
||||||
|
this.changeBreadcrumbs({ schema: this.schema, trigger: this.localTrigger.name });
|
||||||
|
}
|
||||||
|
else
|
||||||
|
this.addNotification({ status: 'error', message: response });
|
||||||
|
}
|
||||||
|
catch (err) {
|
||||||
|
this.addNotification({ status: 'error', message: err.stack });
|
||||||
|
}
|
||||||
|
|
||||||
|
this.isSaving = false;
|
||||||
|
},
|
||||||
|
clearChanges () {
|
||||||
|
this.localTrigger = JSON.parse(JSON.stringify(this.originalTrigger));
|
||||||
|
this.$refs.queryEditor.editor.session.setValue(this.localTrigger.sql);
|
||||||
|
|
||||||
|
Object.keys(this.localEvents).forEach(event => {
|
||||||
|
this.localEvents[event] = false;
|
||||||
|
});
|
||||||
|
|
||||||
|
if (this.customizations.triggerMultipleEvents) {
|
||||||
|
this.originalTrigger.event.forEach(e => {
|
||||||
|
this.localEvents[e] = true;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
},
|
||||||
|
resizeQueryEditor () {
|
||||||
|
if (this.$refs.queryEditor) {
|
||||||
|
const footer = document.getElementById('footer');
|
||||||
|
const size = window.innerHeight - this.$refs.queryEditor.$el.getBoundingClientRect().top - footer.offsetHeight;
|
||||||
|
this.editorHeight = size;
|
||||||
|
this.$refs.queryEditor.editor.resize();
|
||||||
|
}
|
||||||
|
},
|
||||||
|
onKey (e) {
|
||||||
|
if (this.isSelected) {
|
||||||
|
e.stopPropagation();
|
||||||
|
if (e.ctrlKey && e.keyCode === 83) { // CTRL + S
|
||||||
|
if (this.isChanged)
|
||||||
|
this.saveChanges();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
</script>
|
279
src/renderer/components/WorkspaceTabNewTriggerFunction.vue
Normal file
279
src/renderer/components/WorkspaceTabNewTriggerFunction.vue
Normal file
@@ -0,0 +1,279 @@
|
|||||||
|
<template>
|
||||||
|
<div v-show="isSelected" class="workspace-query-tab column col-12 columns col-gapless">
|
||||||
|
<div class="workspace-query-runner column col-12">
|
||||||
|
<div class="workspace-query-runner-footer">
|
||||||
|
<div class="workspace-query-buttons">
|
||||||
|
<button
|
||||||
|
class="btn btn-primary btn-sm"
|
||||||
|
:disabled="!isChanged"
|
||||||
|
:class="{'loading':isSaving}"
|
||||||
|
title="CTRL+S"
|
||||||
|
@click="saveChanges"
|
||||||
|
>
|
||||||
|
<i class="mdi mdi-24px mdi-content-save mr-1" />
|
||||||
|
<span>{{ $t('word.save') }}</span>
|
||||||
|
</button>
|
||||||
|
<button
|
||||||
|
:disabled="!isChanged"
|
||||||
|
class="btn btn-link btn-sm mr-0"
|
||||||
|
:title="$t('message.clearChanges')"
|
||||||
|
@click="clearChanges"
|
||||||
|
>
|
||||||
|
<i class="mdi mdi-24px mdi-delete-sweep mr-1" />
|
||||||
|
<span>{{ $t('word.clear') }}</span>
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="container">
|
||||||
|
<div class="columns">
|
||||||
|
<div class="column col-auto">
|
||||||
|
<div class="form-group">
|
||||||
|
<label class="form-label">
|
||||||
|
{{ $t('word.name') }}
|
||||||
|
</label>
|
||||||
|
<input
|
||||||
|
ref="firstInput"
|
||||||
|
v-model="localFunction.name"
|
||||||
|
class="form-input"
|
||||||
|
type="text"
|
||||||
|
>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div v-if="customizations.triggerFunctionlanguages" class="column col-auto">
|
||||||
|
<div class="form-group">
|
||||||
|
<label class="form-label">
|
||||||
|
{{ $t('word.language') }}
|
||||||
|
</label>
|
||||||
|
<select v-model="localFunction.language" class="form-select">
|
||||||
|
<option v-for="language in customizations.triggerFunctionlanguages" :key="language">
|
||||||
|
{{ language }}
|
||||||
|
</option>
|
||||||
|
</select>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div v-if="customizations.definer" class="column col-auto">
|
||||||
|
<div class="form-group">
|
||||||
|
<label class="form-label">
|
||||||
|
{{ $t('word.definer') }}
|
||||||
|
</label>
|
||||||
|
<select
|
||||||
|
v-if="workspace.users.length"
|
||||||
|
v-model="localFunction.definer"
|
||||||
|
class="form-select"
|
||||||
|
>
|
||||||
|
<option value="">
|
||||||
|
{{ $t('message.currentUser') }}
|
||||||
|
</option>
|
||||||
|
<option
|
||||||
|
v-for="user in workspace.users"
|
||||||
|
:key="`${user.name}@${user.host}`"
|
||||||
|
:value="`\`${user.name}\`@\`${user.host}\``"
|
||||||
|
>
|
||||||
|
{{ user.name }}@{{ user.host }}
|
||||||
|
</option>
|
||||||
|
</select>
|
||||||
|
<select v-if="!workspace.users.length" class="form-select">
|
||||||
|
<option value="">
|
||||||
|
{{ $t('message.currentUser') }}
|
||||||
|
</option>
|
||||||
|
</select>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div v-if="customizations.comment" class="form-group">
|
||||||
|
<label class="form-label">
|
||||||
|
{{ $t('word.comment') }}
|
||||||
|
</label>
|
||||||
|
<input
|
||||||
|
v-model="localFunction.comment"
|
||||||
|
class="form-input"
|
||||||
|
type="text"
|
||||||
|
>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="workspace-query-results column col-12 mt-2 p-relative">
|
||||||
|
<BaseLoader v-if="isLoading" />
|
||||||
|
<label class="form-label ml-2">{{ $t('message.functionBody') }}</label>
|
||||||
|
<QueryEditor
|
||||||
|
v-show="isSelected"
|
||||||
|
ref="queryEditor"
|
||||||
|
:value.sync="localFunction.sql"
|
||||||
|
:workspace="workspace"
|
||||||
|
:schema="schema"
|
||||||
|
:height="editorHeight"
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script>
|
||||||
|
import { mapGetters, mapActions } from 'vuex';
|
||||||
|
import BaseLoader from '@/components/BaseLoader';
|
||||||
|
import QueryEditor from '@/components/QueryEditor';
|
||||||
|
import Functions from '@/ipc-api/Functions';
|
||||||
|
|
||||||
|
export default {
|
||||||
|
name: 'WorkspaceTabNewTriggerFunction',
|
||||||
|
components: {
|
||||||
|
BaseLoader,
|
||||||
|
QueryEditor
|
||||||
|
},
|
||||||
|
props: {
|
||||||
|
connection: Object,
|
||||||
|
tab: Object,
|
||||||
|
isSelected: Boolean,
|
||||||
|
schema: String
|
||||||
|
},
|
||||||
|
data () {
|
||||||
|
return {
|
||||||
|
isLoading: false,
|
||||||
|
isSaving: false,
|
||||||
|
isParamsModal: false,
|
||||||
|
isAskingParameters: false,
|
||||||
|
originalFunction: {},
|
||||||
|
localFunction: {},
|
||||||
|
lastFunction: null,
|
||||||
|
sqlProxy: '',
|
||||||
|
editorHeight: 300
|
||||||
|
};
|
||||||
|
},
|
||||||
|
computed: {
|
||||||
|
...mapGetters({
|
||||||
|
selectedWorkspace: 'workspaces/getSelected',
|
||||||
|
getWorkspace: 'workspaces/getWorkspace'
|
||||||
|
}),
|
||||||
|
workspace () {
|
||||||
|
return this.getWorkspace(this.connection.uid);
|
||||||
|
},
|
||||||
|
customizations () {
|
||||||
|
return this.workspace.customizations;
|
||||||
|
},
|
||||||
|
tabUid () {
|
||||||
|
return this.$vnode.key;
|
||||||
|
},
|
||||||
|
isChanged () {
|
||||||
|
return JSON.stringify(this.originalFunction) !== JSON.stringify(this.localFunction);
|
||||||
|
},
|
||||||
|
isDefinerInUsers () {
|
||||||
|
return this.originalFunction
|
||||||
|
? this.workspace.users.some(user => this.originalFunction.definer === `\`${user.name}\`@\`${user.host}\``)
|
||||||
|
: true;
|
||||||
|
},
|
||||||
|
schemaTables () {
|
||||||
|
const schemaTables = this.workspace.structure
|
||||||
|
.filter(schema => schema.name === this.schema)
|
||||||
|
.map(schema => schema.tables);
|
||||||
|
|
||||||
|
return schemaTables.length ? schemaTables[0].filter(table => table.type === 'table') : [];
|
||||||
|
}
|
||||||
|
},
|
||||||
|
watch: {
|
||||||
|
isSelected (val) {
|
||||||
|
if (val)
|
||||||
|
this.changeBreadcrumbs({ schema: this.schema });
|
||||||
|
},
|
||||||
|
isChanged (val) {
|
||||||
|
this.setUnsavedChanges({ uid: this.connection.uid, tUid: this.tabUid, isChanged: val });
|
||||||
|
}
|
||||||
|
},
|
||||||
|
created () {
|
||||||
|
this.originalFunction = {
|
||||||
|
sql: this.customizations.triggerFunctionSql,
|
||||||
|
language: this.customizations.triggerFunctionlanguages.length ? this.customizations.triggerFunctionlanguages[0] : null,
|
||||||
|
name: ''
|
||||||
|
};
|
||||||
|
|
||||||
|
this.localFunction = JSON.parse(JSON.stringify(this.originalFunction));
|
||||||
|
|
||||||
|
setTimeout(() => {
|
||||||
|
this.resizeQueryEditor();
|
||||||
|
}, 50);
|
||||||
|
|
||||||
|
window.addEventListener('keydown', this.onKey);
|
||||||
|
},
|
||||||
|
mounted () {
|
||||||
|
if (this.isSelected)
|
||||||
|
this.changeBreadcrumbs({ schema: this.schema });
|
||||||
|
|
||||||
|
setTimeout(() => {
|
||||||
|
this.$refs.firstInput.focus();
|
||||||
|
}, 100);
|
||||||
|
|
||||||
|
window.addEventListener('resize', this.resizeQueryEditor);
|
||||||
|
},
|
||||||
|
destroyed () {
|
||||||
|
window.removeEventListener('resize', this.resizeQueryEditor);
|
||||||
|
},
|
||||||
|
beforeDestroy () {
|
||||||
|
window.removeEventListener('keydown', this.onKey);
|
||||||
|
},
|
||||||
|
methods: {
|
||||||
|
...mapActions({
|
||||||
|
addNotification: 'notifications/addNotification',
|
||||||
|
refreshStructure: 'workspaces/refreshStructure',
|
||||||
|
changeBreadcrumbs: 'workspaces/changeBreadcrumbs',
|
||||||
|
setUnsavedChanges: 'workspaces/setUnsavedChanges',
|
||||||
|
newTab: 'workspaces/newTab',
|
||||||
|
removeTab: 'workspaces/removeTab',
|
||||||
|
renameTabs: 'workspaces/renameTabs'
|
||||||
|
}),
|
||||||
|
async saveChanges () {
|
||||||
|
if (this.isSaving) return;
|
||||||
|
this.isSaving = true;
|
||||||
|
const params = {
|
||||||
|
uid: this.connection.uid,
|
||||||
|
schema: this.schema,
|
||||||
|
...this.localFunction
|
||||||
|
};
|
||||||
|
|
||||||
|
try {
|
||||||
|
const { status, response } = await Functions.createTriggerFunction(params);
|
||||||
|
|
||||||
|
if (status === 'success') {
|
||||||
|
await this.refreshStructure(this.connection.uid);
|
||||||
|
|
||||||
|
this.newTab({
|
||||||
|
uid: this.connection.uid,
|
||||||
|
schema: this.schema,
|
||||||
|
elementName: this.localFunction.name,
|
||||||
|
elementType: 'triggerFunction',
|
||||||
|
type: 'trigger-function-props'
|
||||||
|
});
|
||||||
|
|
||||||
|
this.removeTab({ uid: this.connection.uid, tab: this.tab.uid });
|
||||||
|
this.changeBreadcrumbs({ schema: this.schema, triggerFunction: this.localFunction.name });
|
||||||
|
}
|
||||||
|
else
|
||||||
|
this.addNotification({ status: 'error', message: response });
|
||||||
|
}
|
||||||
|
catch (err) {
|
||||||
|
this.addNotification({ status: 'error', message: err.stack });
|
||||||
|
}
|
||||||
|
|
||||||
|
this.isSaving = false;
|
||||||
|
},
|
||||||
|
clearChanges () {
|
||||||
|
this.localFunction = JSON.parse(JSON.stringify(this.originalFunction));
|
||||||
|
this.$refs.queryEditor.editor.session.setValue(this.localFunction.sql);
|
||||||
|
},
|
||||||
|
resizeQueryEditor () {
|
||||||
|
if (this.$refs.queryEditor) {
|
||||||
|
const footer = document.getElementById('footer');
|
||||||
|
const size = window.innerHeight - this.$refs.queryEditor.$el.getBoundingClientRect().top - footer.offsetHeight;
|
||||||
|
this.editorHeight = size;
|
||||||
|
this.$refs.queryEditor.editor.resize();
|
||||||
|
}
|
||||||
|
},
|
||||||
|
onKey (e) {
|
||||||
|
if (this.isSelected) {
|
||||||
|
e.stopPropagation();
|
||||||
|
if (e.ctrlKey && e.keyCode === 83) { // CTRL + S
|
||||||
|
if (this.isChanged)
|
||||||
|
this.saveChanges();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
</script>
|
287
src/renderer/components/WorkspaceTabNewView.vue
Normal file
287
src/renderer/components/WorkspaceTabNewView.vue
Normal file
@@ -0,0 +1,287 @@
|
|||||||
|
<template>
|
||||||
|
<div v-show="isSelected" class="workspace-query-tab column col-12 columns col-gapless">
|
||||||
|
<div class="workspace-query-runner column col-12">
|
||||||
|
<div class="workspace-query-runner-footer">
|
||||||
|
<div class="workspace-query-buttons">
|
||||||
|
<button
|
||||||
|
class="btn btn-primary btn-sm"
|
||||||
|
:disabled="!isChanged"
|
||||||
|
:class="{'loading':isSaving}"
|
||||||
|
title="CTRL+S"
|
||||||
|
@click="saveChanges"
|
||||||
|
>
|
||||||
|
<i class="mdi mdi-24px mdi-content-save mr-1" />
|
||||||
|
<span>{{ $t('word.save') }}</span>
|
||||||
|
</button>
|
||||||
|
<button
|
||||||
|
:disabled="!isChanged"
|
||||||
|
class="btn btn-link btn-sm mr-0"
|
||||||
|
:title="$t('message.clearChanges')"
|
||||||
|
@click="clearChanges"
|
||||||
|
>
|
||||||
|
<i class="mdi mdi-24px mdi-delete-sweep mr-1" />
|
||||||
|
<span>{{ $t('word.clear') }}</span>
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
<div class="workspace-query-info">
|
||||||
|
<div class="d-flex" :title="$t('word.schema')">
|
||||||
|
<i class="mdi mdi-18px mdi-database mr-1" /><b>{{ schema }}</b>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="container">
|
||||||
|
<div class="columns">
|
||||||
|
<div class="column col-auto">
|
||||||
|
<div class="form-group">
|
||||||
|
<label class="form-label">{{ $t('word.name') }}</label>
|
||||||
|
<input
|
||||||
|
ref="firstInput"
|
||||||
|
v-model="localView.name"
|
||||||
|
class="form-input"
|
||||||
|
type="text"
|
||||||
|
>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="column col-auto">
|
||||||
|
<div v-if="workspace.customizations.definer" class="form-group">
|
||||||
|
<label class="form-label">{{ $t('word.definer') }}</label>
|
||||||
|
<select
|
||||||
|
v-if="workspace.users.length"
|
||||||
|
v-model="localView.definer"
|
||||||
|
class="form-select"
|
||||||
|
>
|
||||||
|
<option value="">
|
||||||
|
{{ $t('message.currentUser') }}
|
||||||
|
</option>
|
||||||
|
<option v-if="!isDefinerInUsers" :value="originalView.definer">
|
||||||
|
{{ originalView.definer.replaceAll('`', '') }}
|
||||||
|
</option>
|
||||||
|
<option
|
||||||
|
v-for="user in workspace.users"
|
||||||
|
:key="`${user.name}@${user.host}`"
|
||||||
|
:value="`\`${user.name}\`@\`${user.host}\``"
|
||||||
|
>
|
||||||
|
{{ user.name }}@{{ user.host }}
|
||||||
|
</option>
|
||||||
|
</select>
|
||||||
|
<select v-if="!workspace.users.length" class="form-select">
|
||||||
|
<option value="">
|
||||||
|
{{ $t('message.currentUser') }}
|
||||||
|
</option>
|
||||||
|
</select>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="column col-auto mr-2">
|
||||||
|
<div v-if="workspace.customizations.viewSqlSecurity" class="form-group">
|
||||||
|
<label class="form-label">{{ $t('message.sqlSecurity') }}</label>
|
||||||
|
<select v-model="localView.security" class="form-select">
|
||||||
|
<option>DEFINER</option>
|
||||||
|
<option>INVOKER</option>
|
||||||
|
</select>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="column col-auto mr-2">
|
||||||
|
<div v-if="workspace.customizations.viewAlgorithm" class="form-group">
|
||||||
|
<label class="form-label">{{ $t('word.algorithm') }}</label>
|
||||||
|
<select v-model="localView.algorithm" class="form-select">
|
||||||
|
<option>UNDEFINED</option>
|
||||||
|
<option>MERGE</option>
|
||||||
|
<option>TEMPTABLE</option>
|
||||||
|
</select>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div v-if="workspace.customizations.viewUpdateOption" class="column col-auto mr-2">
|
||||||
|
<div class="form-group">
|
||||||
|
<label class="form-label">{{ $t('message.updateOption') }}</label>
|
||||||
|
<select v-model="localView.updateOption" class="form-select">
|
||||||
|
<option value="">
|
||||||
|
None
|
||||||
|
</option>
|
||||||
|
<option>CASCADED</option>
|
||||||
|
<option>LOCAL</option>
|
||||||
|
</select>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="workspace-query-results column col-12 mt-2 p-relative">
|
||||||
|
<BaseLoader v-if="isLoading" />
|
||||||
|
<label class="form-label ml-2">{{ $t('message.selectStatement') }}</label>
|
||||||
|
<QueryEditor
|
||||||
|
v-show="isSelected"
|
||||||
|
ref="queryEditor"
|
||||||
|
:value.sync="localView.sql"
|
||||||
|
:workspace="workspace"
|
||||||
|
:schema="schema"
|
||||||
|
:height="editorHeight"
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script>
|
||||||
|
import { mapGetters, mapActions } from 'vuex';
|
||||||
|
import BaseLoader from '@/components/BaseLoader';
|
||||||
|
import QueryEditor from '@/components/QueryEditor';
|
||||||
|
import Views from '@/ipc-api/Views';
|
||||||
|
|
||||||
|
export default {
|
||||||
|
name: 'WorkspaceTabNewView',
|
||||||
|
components: {
|
||||||
|
BaseLoader,
|
||||||
|
QueryEditor
|
||||||
|
},
|
||||||
|
props: {
|
||||||
|
connection: Object,
|
||||||
|
tab: Object,
|
||||||
|
isSelected: Boolean,
|
||||||
|
schema: String
|
||||||
|
},
|
||||||
|
data () {
|
||||||
|
return {
|
||||||
|
isLoading: false,
|
||||||
|
isSaving: false,
|
||||||
|
originalView: {},
|
||||||
|
localView: {},
|
||||||
|
lastView: null,
|
||||||
|
sqlProxy: '',
|
||||||
|
editorHeight: 300
|
||||||
|
};
|
||||||
|
},
|
||||||
|
computed: {
|
||||||
|
...mapGetters({
|
||||||
|
selectedWorkspace: 'workspaces/getSelected',
|
||||||
|
getWorkspace: 'workspaces/getWorkspace'
|
||||||
|
}),
|
||||||
|
workspace () {
|
||||||
|
return this.getWorkspace(this.connection.uid);
|
||||||
|
},
|
||||||
|
tabUid () {
|
||||||
|
return this.$vnode.key;
|
||||||
|
},
|
||||||
|
isChanged () {
|
||||||
|
return JSON.stringify(this.originalView) !== JSON.stringify(this.localView);
|
||||||
|
},
|
||||||
|
isDefinerInUsers () {
|
||||||
|
return this.originalView ? this.workspace.users.some(user => this.originalView.definer === `\`${user.name}\`@\`${user.host}\``) : true;
|
||||||
|
}
|
||||||
|
},
|
||||||
|
watch: {
|
||||||
|
isSelected (val) {
|
||||||
|
if (val) {
|
||||||
|
this.changeBreadcrumbs({ schema: this.schema, view: this.view });
|
||||||
|
|
||||||
|
setTimeout(() => {
|
||||||
|
this.resizeQueryEditor();
|
||||||
|
}, 50);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
isChanged (val) {
|
||||||
|
this.setUnsavedChanges({ uid: this.connection.uid, tUid: this.tabUid, isChanged: val });
|
||||||
|
}
|
||||||
|
},
|
||||||
|
async created () {
|
||||||
|
this.originalView = {
|
||||||
|
algorithm: 'UNDEFINED',
|
||||||
|
definer: '',
|
||||||
|
security: 'DEFINER',
|
||||||
|
updateOption: '',
|
||||||
|
sql: '',
|
||||||
|
name: ''
|
||||||
|
};
|
||||||
|
|
||||||
|
this.localView = JSON.parse(JSON.stringify(this.originalView));
|
||||||
|
|
||||||
|
setTimeout(() => {
|
||||||
|
this.resizeQueryEditor();
|
||||||
|
}, 50);
|
||||||
|
|
||||||
|
window.addEventListener('keydown', this.onKey);
|
||||||
|
},
|
||||||
|
mounted () {
|
||||||
|
if (this.isSelected)
|
||||||
|
this.changeBreadcrumbs({ schema: this.schema });
|
||||||
|
|
||||||
|
setTimeout(() => {
|
||||||
|
this.$refs.firstInput.focus();
|
||||||
|
}, 100);
|
||||||
|
|
||||||
|
window.addEventListener('resize', this.resizeQueryEditor);
|
||||||
|
},
|
||||||
|
destroyed () {
|
||||||
|
window.removeEventListener('resize', this.resizeQueryEditor);
|
||||||
|
},
|
||||||
|
beforeDestroy () {
|
||||||
|
window.removeEventListener('keydown', this.onKey);
|
||||||
|
},
|
||||||
|
methods: {
|
||||||
|
...mapActions({
|
||||||
|
addNotification: 'notifications/addNotification',
|
||||||
|
refreshStructure: 'workspaces/refreshStructure',
|
||||||
|
setUnsavedChanges: 'workspaces/setUnsavedChanges',
|
||||||
|
changeBreadcrumbs: 'workspaces/changeBreadcrumbs',
|
||||||
|
newTab: 'workspaces/newTab',
|
||||||
|
removeTab: 'workspaces/removeTab',
|
||||||
|
renameTabs: 'workspaces/renameTabs'
|
||||||
|
}),
|
||||||
|
async saveChanges () {
|
||||||
|
if (this.isSaving) return;
|
||||||
|
this.isSaving = true;
|
||||||
|
|
||||||
|
const params = {
|
||||||
|
uid: this.connection.uid,
|
||||||
|
schema: this.schema,
|
||||||
|
...this.localView
|
||||||
|
};
|
||||||
|
|
||||||
|
try {
|
||||||
|
const { status, response } = await Views.createView(params);
|
||||||
|
|
||||||
|
if (status === 'success') {
|
||||||
|
await this.refreshStructure(this.connection.uid);
|
||||||
|
|
||||||
|
this.newTab({
|
||||||
|
uid: this.connection.uid,
|
||||||
|
schema: this.schema,
|
||||||
|
elementName: this.localView.name,
|
||||||
|
elementType: 'view',
|
||||||
|
type: 'view-props'
|
||||||
|
});
|
||||||
|
|
||||||
|
this.removeTab({ uid: this.connection.uid, tab: this.tab.uid });
|
||||||
|
this.changeBreadcrumbs({ schema: this.schema, view: this.localView.name });
|
||||||
|
}
|
||||||
|
else
|
||||||
|
this.addNotification({ status: 'error', message: response });
|
||||||
|
}
|
||||||
|
catch (err) {
|
||||||
|
this.addNotification({ status: 'error', message: err.stack });
|
||||||
|
}
|
||||||
|
|
||||||
|
this.isSaving = false;
|
||||||
|
},
|
||||||
|
clearChanges () {
|
||||||
|
this.localView = JSON.parse(JSON.stringify(this.originalView));
|
||||||
|
this.$refs.queryEditor.editor.session.setValue(this.localView.sql);
|
||||||
|
},
|
||||||
|
resizeQueryEditor () {
|
||||||
|
if (this.$refs.queryEditor) {
|
||||||
|
const footer = document.getElementById('footer');
|
||||||
|
const size = window.innerHeight - this.$refs.queryEditor.$el.getBoundingClientRect().top - footer.offsetHeight;
|
||||||
|
this.editorHeight = size;
|
||||||
|
this.$refs.queryEditor.editor.resize();
|
||||||
|
}
|
||||||
|
},
|
||||||
|
onKey (e) {
|
||||||
|
if (this.isSelected) {
|
||||||
|
e.stopPropagation();
|
||||||
|
if (e.ctrlKey && e.keyCode === 83) { // CTRL + S
|
||||||
|
if (this.isChanged)
|
||||||
|
this.saveChanges();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
</script>
|
@@ -37,10 +37,6 @@
|
|||||||
<i class="mdi mdi-24px mdi-dots-horizontal mr-1" />
|
<i class="mdi mdi-24px mdi-dots-horizontal mr-1" />
|
||||||
<span>{{ $t('word.parameters') }}</span>
|
<span>{{ $t('word.parameters') }}</span>
|
||||||
</button>
|
</button>
|
||||||
<button class="btn btn-dark btn-sm" @click="showOptionsModal">
|
|
||||||
<i class="mdi mdi-24px mdi-cogs mr-1" />
|
|
||||||
<span>{{ $t('word.options') }}</span>
|
|
||||||
</button>
|
|
||||||
</div>
|
</div>
|
||||||
<div class="workspace-query-info">
|
<div class="workspace-query-info">
|
||||||
<div class="d-flex" :title="$t('word.schema')">
|
<div class="d-flex" :title="$t('word.schema')">
|
||||||
@@ -49,6 +45,152 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
<div class="container">
|
||||||
|
<div class="columns">
|
||||||
|
<div class="column col-auto">
|
||||||
|
<div class="form-group">
|
||||||
|
<label class="form-label">
|
||||||
|
{{ $t('word.name') }}
|
||||||
|
</label>
|
||||||
|
<input
|
||||||
|
ref="firstInput"
|
||||||
|
v-model="localFunction.name"
|
||||||
|
class="form-input"
|
||||||
|
:class="{'is-error': !isTableNameValid}"
|
||||||
|
type="text"
|
||||||
|
>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div v-if="customizations.languages" class="column col-auto">
|
||||||
|
<div class="form-group">
|
||||||
|
<label class="form-label">
|
||||||
|
{{ $t('word.language') }}
|
||||||
|
</label>
|
||||||
|
<select v-model="localFunction.language" class="form-select">
|
||||||
|
<option v-for="language in customizations.languages" :key="language">
|
||||||
|
{{ language }}
|
||||||
|
</option>
|
||||||
|
</select>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div v-if="customizations.definer" class="column col-auto">
|
||||||
|
<div class="form-group">
|
||||||
|
<label class="form-label">
|
||||||
|
{{ $t('word.definer') }}
|
||||||
|
</label>
|
||||||
|
<select
|
||||||
|
v-if="workspace.users.length"
|
||||||
|
v-model="localFunction.definer"
|
||||||
|
class="form-select"
|
||||||
|
>
|
||||||
|
<option value="">
|
||||||
|
{{ $t('message.currentUser') }}
|
||||||
|
</option>
|
||||||
|
<option
|
||||||
|
v-for="user in workspace.users"
|
||||||
|
:key="`${user.name}@${user.host}`"
|
||||||
|
:value="`\`${user.name}\`@\`${user.host}\``"
|
||||||
|
>
|
||||||
|
{{ user.name }}@{{ user.host }}
|
||||||
|
</option>
|
||||||
|
</select>
|
||||||
|
<select v-if="!workspace.users.length" class="form-select">
|
||||||
|
<option value="">
|
||||||
|
{{ $t('message.currentUser') }}
|
||||||
|
</option>
|
||||||
|
</select>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="column col-auto">
|
||||||
|
<div class="form-group">
|
||||||
|
<label class="form-label">
|
||||||
|
{{ $t('word.returns') }}
|
||||||
|
</label>
|
||||||
|
<div class="input-group">
|
||||||
|
<select
|
||||||
|
v-model="localFunction.returns"
|
||||||
|
class="form-select text-uppercase"
|
||||||
|
style="max-width: 150px;"
|
||||||
|
>
|
||||||
|
<option v-if="localFunction.returns === 'VOID'">
|
||||||
|
VOID
|
||||||
|
</option>
|
||||||
|
<option v-if="!isInDataTypes">
|
||||||
|
{{ localFunction.returns }}
|
||||||
|
</option>
|
||||||
|
<optgroup
|
||||||
|
v-for="group in workspace.dataTypes"
|
||||||
|
:key="group.group"
|
||||||
|
:label="group.group"
|
||||||
|
>
|
||||||
|
<option
|
||||||
|
v-for="type in group.types"
|
||||||
|
:key="type.name"
|
||||||
|
:selected="localFunction.returns === type.name"
|
||||||
|
:value="type.name"
|
||||||
|
>
|
||||||
|
{{ type.name }}
|
||||||
|
</option>
|
||||||
|
</optgroup>
|
||||||
|
</select>
|
||||||
|
<input
|
||||||
|
v-if="customizations.parametersLength"
|
||||||
|
v-model="localFunction.returnsLength"
|
||||||
|
style="max-width: 150px;"
|
||||||
|
class="form-input"
|
||||||
|
type="number"
|
||||||
|
min="0"
|
||||||
|
:placeholder="$t('word.length')"
|
||||||
|
>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div v-if="customizations.comment" class="column">
|
||||||
|
<div class="form-group">
|
||||||
|
<label class="form-label">
|
||||||
|
{{ $t('word.comment') }}
|
||||||
|
</label>
|
||||||
|
<input
|
||||||
|
v-model="localFunction.comment"
|
||||||
|
class="form-input"
|
||||||
|
type="text"
|
||||||
|
>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="column col-auto">
|
||||||
|
<div class="form-group">
|
||||||
|
<label class="form-label">
|
||||||
|
{{ $t('message.sqlSecurity') }}
|
||||||
|
</label>
|
||||||
|
<select v-model="localFunction.security" class="form-select">
|
||||||
|
<option>DEFINER</option>
|
||||||
|
<option>INVOKER</option>
|
||||||
|
</select>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div v-if="customizations.functionDataAccess" class="column col-auto">
|
||||||
|
<div class="form-group">
|
||||||
|
<label class="form-label">
|
||||||
|
{{ $t('message.dataAccess') }}
|
||||||
|
</label>
|
||||||
|
<select v-model="localFunction.dataAccess" class="form-select">
|
||||||
|
<option>CONTAINS SQL</option>
|
||||||
|
<option>NO SQL</option>
|
||||||
|
<option>READS SQL DATA</option>
|
||||||
|
<option>MODIFIES SQL DATA</option>
|
||||||
|
</select>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div v-if="customizations.functionDeterministic" class="column col-auto">
|
||||||
|
<div class="form-group">
|
||||||
|
<label class="form-label d-invisible">.</label>
|
||||||
|
<label class="form-checkbox form-inline">
|
||||||
|
<input v-model="localFunction.deterministic" type="checkbox"><i class="form-icon" /> {{ $t('word.deterministic') }}
|
||||||
|
</label>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
<div class="workspace-query-results column col-12 mt-2 p-relative">
|
<div class="workspace-query-results column col-12 mt-2 p-relative">
|
||||||
<BaseLoader v-if="isLoading" />
|
<BaseLoader v-if="isLoading" />
|
||||||
<label class="form-label ml-2">{{ $t('message.functionBody') }}</label>
|
<label class="form-label ml-2">{{ $t('message.functionBody') }}</label>
|
||||||
@@ -61,14 +203,7 @@
|
|||||||
:height="editorHeight"
|
:height="editorHeight"
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
<WorkspacePropsFunctionOptionsModal
|
<WorkspaceTabPropsFunctionParamsModal
|
||||||
v-if="isOptionsModal"
|
|
||||||
:local-options="localFunction"
|
|
||||||
:workspace="workspace"
|
|
||||||
@hide="hideOptionsModal"
|
|
||||||
@options-update="optionsUpdate"
|
|
||||||
/>
|
|
||||||
<WorkspacePropsFunctionParamsModal
|
|
||||||
v-if="isParamsModal"
|
v-if="isParamsModal"
|
||||||
:local-parameters="localFunction.parameters"
|
:local-parameters="localFunction.parameters"
|
||||||
:workspace="workspace"
|
:workspace="workspace"
|
||||||
@@ -91,18 +226,16 @@ import { mapGetters, mapActions } from 'vuex';
|
|||||||
import { uidGen } from 'common/libs/uidGen';
|
import { uidGen } from 'common/libs/uidGen';
|
||||||
import BaseLoader from '@/components/BaseLoader';
|
import BaseLoader from '@/components/BaseLoader';
|
||||||
import QueryEditor from '@/components/QueryEditor';
|
import QueryEditor from '@/components/QueryEditor';
|
||||||
import WorkspacePropsFunctionOptionsModal from '@/components/WorkspacePropsFunctionOptionsModal';
|
import WorkspaceTabPropsFunctionParamsModal from '@/components/WorkspaceTabPropsFunctionParamsModal';
|
||||||
import WorkspacePropsFunctionParamsModal from '@/components/WorkspacePropsFunctionParamsModal';
|
|
||||||
import ModalAskParameters from '@/components/ModalAskParameters';
|
import ModalAskParameters from '@/components/ModalAskParameters';
|
||||||
import Functions from '@/ipc-api/Functions';
|
import Functions from '@/ipc-api/Functions';
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
name: 'WorkspacePropsTabFunction',
|
name: 'WorkspaceTabPropsFunction',
|
||||||
components: {
|
components: {
|
||||||
BaseLoader,
|
BaseLoader,
|
||||||
QueryEditor,
|
QueryEditor,
|
||||||
WorkspacePropsFunctionOptionsModal,
|
WorkspaceTabPropsFunctionParamsModal,
|
||||||
WorkspacePropsFunctionParamsModal,
|
|
||||||
ModalAskParameters
|
ModalAskParameters
|
||||||
},
|
},
|
||||||
props: {
|
props: {
|
||||||
@@ -115,7 +248,6 @@ export default {
|
|||||||
return {
|
return {
|
||||||
isLoading: false,
|
isLoading: false,
|
||||||
isSaving: false,
|
isSaving: false,
|
||||||
isOptionsModal: false,
|
|
||||||
isParamsModal: false,
|
isParamsModal: false,
|
||||||
isAskingParameters: false,
|
isAskingParameters: false,
|
||||||
originalFunction: null,
|
originalFunction: null,
|
||||||
@@ -133,6 +265,9 @@ export default {
|
|||||||
workspace () {
|
workspace () {
|
||||||
return this.getWorkspace(this.connection.uid);
|
return this.getWorkspace(this.connection.uid);
|
||||||
},
|
},
|
||||||
|
customizations () {
|
||||||
|
return this.workspace.customizations;
|
||||||
|
},
|
||||||
tabUid () {
|
tabUid () {
|
||||||
return this.$vnode.key;
|
return this.$vnode.key;
|
||||||
},
|
},
|
||||||
@@ -144,6 +279,19 @@ export default {
|
|||||||
? this.workspace.users.some(user => this.originalFunction.definer === `\`${user.name}\`@\`${user.host}\``)
|
? this.workspace.users.some(user => this.originalFunction.definer === `\`${user.name}\`@\`${user.host}\``)
|
||||||
: true;
|
: true;
|
||||||
},
|
},
|
||||||
|
isTableNameValid () {
|
||||||
|
return this.localFunction.name !== '';
|
||||||
|
},
|
||||||
|
isInDataTypes () {
|
||||||
|
let typeNames = [];
|
||||||
|
for (const group of this.workspace.dataTypes) {
|
||||||
|
typeNames = group.types.reduce((acc, curr) => {
|
||||||
|
acc.push(curr.name);
|
||||||
|
return acc;
|
||||||
|
}, []);
|
||||||
|
}
|
||||||
|
return typeNames.includes(this.localFunction.returns);
|
||||||
|
},
|
||||||
schemaTables () {
|
schemaTables () {
|
||||||
const schemaTables = this.workspace.structure
|
const schemaTables = this.workspace.structure
|
||||||
.filter(schema => schema.name === this.schema)
|
.filter(schema => schema.name === this.schema)
|
||||||
@@ -330,12 +478,6 @@ export default {
|
|||||||
|
|
||||||
this.newTab({ uid: this.connection.uid, content: sql, type: 'query', autorun: true });
|
this.newTab({ uid: this.connection.uid, content: sql, type: 'query', autorun: true });
|
||||||
},
|
},
|
||||||
showOptionsModal () {
|
|
||||||
this.isOptionsModal = true;
|
|
||||||
},
|
|
||||||
hideOptionsModal () {
|
|
||||||
this.isOptionsModal = false;
|
|
||||||
},
|
|
||||||
showParamsModal () {
|
showParamsModal () {
|
||||||
this.isParamsModal = true;
|
this.isParamsModal = true;
|
||||||
},
|
},
|
@@ -176,7 +176,7 @@ import { uidGen } from 'common/libs/uidGen';
|
|||||||
import ConfirmModal from '@/components/BaseConfirmModal';
|
import ConfirmModal from '@/components/BaseConfirmModal';
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
name: 'WorkspacePropsRoutineParamsModal',
|
name: 'WorkspaceTabPropsFunctionParamsModal',
|
||||||
components: {
|
components: {
|
||||||
ConfirmModal
|
ConfirmModal
|
||||||
},
|
},
|
||||||
@@ -242,7 +242,7 @@ export default {
|
|||||||
name: `Param${this.i++}`,
|
name: `Param${this.i++}`,
|
||||||
type: 'INT',
|
type: 'INT',
|
||||||
context: 'IN',
|
context: 'IN',
|
||||||
length: 10
|
length: ''
|
||||||
}];
|
}];
|
||||||
|
|
||||||
if (this.parametersProxy.length === 1)
|
if (this.parametersProxy.length === 1)
|
@@ -37,10 +37,6 @@
|
|||||||
<i class="mdi mdi-24px mdi-dots-horizontal mr-1" />
|
<i class="mdi mdi-24px mdi-dots-horizontal mr-1" />
|
||||||
<span>{{ $t('word.parameters') }}</span>
|
<span>{{ $t('word.parameters') }}</span>
|
||||||
</button>
|
</button>
|
||||||
<button class="btn btn-dark btn-sm" @click="showOptionsModal">
|
|
||||||
<i class="mdi mdi-24px mdi-cogs mr-1" />
|
|
||||||
<span>{{ $t('word.options') }}</span>
|
|
||||||
</button>
|
|
||||||
</div>
|
</div>
|
||||||
<div class="workspace-query-info">
|
<div class="workspace-query-info">
|
||||||
<div class="d-flex" :title="$t('word.schema')">
|
<div class="d-flex" :title="$t('word.schema')">
|
||||||
@@ -49,6 +45,108 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
<div class="container">
|
||||||
|
<div class="columns">
|
||||||
|
<div class="column col-auto">
|
||||||
|
<div class="form-group">
|
||||||
|
<label class="form-label">
|
||||||
|
{{ $t('word.name') }}
|
||||||
|
</label>
|
||||||
|
<input
|
||||||
|
ref="firstInput"
|
||||||
|
v-model="localRoutine.name"
|
||||||
|
class="form-input"
|
||||||
|
:class="{'is-error': !isTableNameValid}"
|
||||||
|
type="text"
|
||||||
|
>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div v-if="customizations.languages" class="column col-auto">
|
||||||
|
<div class="form-group">
|
||||||
|
<label class="form-label">
|
||||||
|
{{ $t('word.language') }}
|
||||||
|
</label>
|
||||||
|
<select v-model="localRoutine.language" class="form-select">
|
||||||
|
<option v-for="language in customizations.languages" :key="language">
|
||||||
|
{{ language }}
|
||||||
|
</option>
|
||||||
|
</select>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div v-if="customizations.definer" class="column col-auto">
|
||||||
|
<div class="form-group">
|
||||||
|
<label class="form-label">
|
||||||
|
{{ $t('word.definer') }}
|
||||||
|
</label>
|
||||||
|
<select
|
||||||
|
v-if="workspace.users.length"
|
||||||
|
v-model="localRoutine.definer"
|
||||||
|
class="form-select"
|
||||||
|
>
|
||||||
|
<option value="">
|
||||||
|
{{ $t('message.currentUser') }}
|
||||||
|
</option>
|
||||||
|
<option
|
||||||
|
v-for="user in workspace.users"
|
||||||
|
:key="`${user.name}@${user.host}`"
|
||||||
|
:value="`\`${user.name}\`@\`${user.host}\``"
|
||||||
|
>
|
||||||
|
{{ user.name }}@{{ user.host }}
|
||||||
|
</option>
|
||||||
|
</select>
|
||||||
|
<select v-if="!workspace.users.length" class="form-select">
|
||||||
|
<option value="">
|
||||||
|
{{ $t('message.currentUser') }}
|
||||||
|
</option>
|
||||||
|
</select>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div v-if="customizations.comment" class="column">
|
||||||
|
<div class="form-group">
|
||||||
|
<label class="form-label">
|
||||||
|
{{ $t('word.comment') }}
|
||||||
|
</label>
|
||||||
|
<input
|
||||||
|
v-model="localRoutine.comment"
|
||||||
|
class="form-input"
|
||||||
|
type="text"
|
||||||
|
>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="column col-auto">
|
||||||
|
<div class="form-group">
|
||||||
|
<label class="form-label">
|
||||||
|
{{ $t('message.sqlSecurity') }}
|
||||||
|
</label>
|
||||||
|
<select v-model="localRoutine.security" class="form-select">
|
||||||
|
<option>DEFINER</option>
|
||||||
|
<option>INVOKER</option>
|
||||||
|
</select>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div v-if="customizations.procedureDataAccess" class="column col-auto">
|
||||||
|
<div class="form-group">
|
||||||
|
<label class="form-label">
|
||||||
|
{{ $t('message.dataAccess') }}
|
||||||
|
</label>
|
||||||
|
<select v-model="localRoutine.dataAccess" class="form-select">
|
||||||
|
<option>CONTAINS SQL</option>
|
||||||
|
<option>NO SQL</option>
|
||||||
|
<option>READS SQL DATA</option>
|
||||||
|
<option>MODIFIES SQL DATA</option>
|
||||||
|
</select>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div v-if="customizations.procedureDeterministic" class="column col-auto">
|
||||||
|
<div class="form-group">
|
||||||
|
<label class="form-label d-invisible">.</label>
|
||||||
|
<label class="form-checkbox form-inline">
|
||||||
|
<input v-model="localRoutine.deterministic" type="checkbox"><i class="form-icon" /> {{ $t('word.deterministic') }}
|
||||||
|
</label>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
<div class="workspace-query-results column col-12 mt-2 p-relative">
|
<div class="workspace-query-results column col-12 mt-2 p-relative">
|
||||||
<BaseLoader v-if="isLoading" />
|
<BaseLoader v-if="isLoading" />
|
||||||
<label class="form-label ml-2">{{ $t('message.routineBody') }}</label>
|
<label class="form-label ml-2">{{ $t('message.routineBody') }}</label>
|
||||||
@@ -62,14 +160,7 @@
|
|||||||
:height="editorHeight"
|
:height="editorHeight"
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
<WorkspacePropsRoutineOptionsModal
|
<WorkspaceTabPropsRoutineParamsModal
|
||||||
v-if="isOptionsModal"
|
|
||||||
:local-options="localRoutine"
|
|
||||||
:workspace="workspace"
|
|
||||||
@hide="hideOptionsModal"
|
|
||||||
@options-update="optionsUpdate"
|
|
||||||
/>
|
|
||||||
<WorkspacePropsRoutineParamsModal
|
|
||||||
v-if="isParamsModal"
|
v-if="isParamsModal"
|
||||||
:local-parameters="localRoutine.parameters"
|
:local-parameters="localRoutine.parameters"
|
||||||
:workspace="workspace"
|
:workspace="workspace"
|
||||||
@@ -92,18 +183,16 @@ import { mapGetters, mapActions } from 'vuex';
|
|||||||
import { uidGen } from 'common/libs/uidGen';
|
import { uidGen } from 'common/libs/uidGen';
|
||||||
import QueryEditor from '@/components/QueryEditor';
|
import QueryEditor from '@/components/QueryEditor';
|
||||||
import BaseLoader from '@/components/BaseLoader';
|
import BaseLoader from '@/components/BaseLoader';
|
||||||
import WorkspacePropsRoutineOptionsModal from '@/components/WorkspacePropsRoutineOptionsModal';
|
import WorkspaceTabPropsRoutineParamsModal from '@/components/WorkspaceTabPropsRoutineParamsModal';
|
||||||
import WorkspacePropsRoutineParamsModal from '@/components/WorkspacePropsRoutineParamsModal';
|
|
||||||
import ModalAskParameters from '@/components/ModalAskParameters';
|
import ModalAskParameters from '@/components/ModalAskParameters';
|
||||||
import Routines from '@/ipc-api/Routines';
|
import Routines from '@/ipc-api/Routines';
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
name: 'WorkspacePropsTabRoutine',
|
name: 'WorkspaceTabPropsRoutine',
|
||||||
components: {
|
components: {
|
||||||
QueryEditor,
|
QueryEditor,
|
||||||
BaseLoader,
|
BaseLoader,
|
||||||
WorkspacePropsRoutineOptionsModal,
|
WorkspaceTabPropsRoutineParamsModal,
|
||||||
WorkspacePropsRoutineParamsModal,
|
|
||||||
ModalAskParameters
|
ModalAskParameters
|
||||||
},
|
},
|
||||||
props: {
|
props: {
|
||||||
@@ -116,7 +205,6 @@ export default {
|
|||||||
return {
|
return {
|
||||||
isLoading: false,
|
isLoading: false,
|
||||||
isSaving: false,
|
isSaving: false,
|
||||||
isOptionsModal: false,
|
|
||||||
isParamsModal: false,
|
isParamsModal: false,
|
||||||
isAskingParameters: false,
|
isAskingParameters: false,
|
||||||
originalRoutine: null,
|
originalRoutine: null,
|
||||||
@@ -134,6 +222,9 @@ export default {
|
|||||||
workspace () {
|
workspace () {
|
||||||
return this.getWorkspace(this.connection.uid);
|
return this.getWorkspace(this.connection.uid);
|
||||||
},
|
},
|
||||||
|
customizations () {
|
||||||
|
return this.workspace.customizations;
|
||||||
|
},
|
||||||
tabUid () {
|
tabUid () {
|
||||||
return this.$vnode.key;
|
return this.$vnode.key;
|
||||||
},
|
},
|
||||||
@@ -143,6 +234,9 @@ export default {
|
|||||||
isDefinerInUsers () {
|
isDefinerInUsers () {
|
||||||
return this.originalRoutine ? this.workspace.users.some(user => this.originalRoutine.definer === `\`${user.name}\`@\`${user.host}\``) : true;
|
return this.originalRoutine ? this.workspace.users.some(user => this.originalRoutine.definer === `\`${user.name}\`@\`${user.host}\``) : true;
|
||||||
},
|
},
|
||||||
|
isTableNameValid () {
|
||||||
|
return this.localRoutine.name !== '';
|
||||||
|
},
|
||||||
schemaTables () {
|
schemaTables () {
|
||||||
const schemaTables = this.workspace.structure
|
const schemaTables = this.workspace.structure
|
||||||
.filter(schema => schema.name === this.schema)
|
.filter(schema => schema.name === this.schema)
|
||||||
@@ -327,12 +421,6 @@ export default {
|
|||||||
|
|
||||||
this.newTab({ uid: this.connection.uid, content: sql, type: 'query', autorun: true });
|
this.newTab({ uid: this.connection.uid, content: sql, type: 'query', autorun: true });
|
||||||
},
|
},
|
||||||
showOptionsModal () {
|
|
||||||
this.isOptionsModal = true;
|
|
||||||
},
|
|
||||||
hideOptionsModal () {
|
|
||||||
this.isOptionsModal = false;
|
|
||||||
},
|
|
||||||
showParamsModal () {
|
showParamsModal () {
|
||||||
this.isParamsModal = true;
|
this.isParamsModal = true;
|
||||||
},
|
},
|
@@ -176,7 +176,7 @@ import { uidGen } from 'common/libs/uidGen';
|
|||||||
import ConfirmModal from '@/components/BaseConfirmModal';
|
import ConfirmModal from '@/components/BaseConfirmModal';
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
name: 'WorkspacePropsRoutineParamsModal',
|
name: 'WorkspaceTabPropsRoutineParamsModal',
|
||||||
components: {
|
components: {
|
||||||
ConfirmModal
|
ConfirmModal
|
||||||
},
|
},
|
@@ -37,7 +37,7 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="container">
|
<div class="container">
|
||||||
<div class="columns mb-4">
|
<div class="columns">
|
||||||
<div class="column col-auto">
|
<div class="column col-auto">
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
<label class="form-label">{{ $t('word.name') }}</label>
|
<label class="form-label">{{ $t('word.name') }}</label>
|
||||||
@@ -77,7 +77,7 @@
|
|||||||
</select>
|
</select>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="column col-4">
|
<div class="column">
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
<label class="form-label">{{ $t('word.comment') }}</label>
|
<label class="form-label">{{ $t('word.comment') }}</label>
|
||||||
<input
|
<input
|
||||||
@@ -87,8 +87,6 @@
|
|||||||
>
|
>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
|
||||||
<div class="columns">
|
|
||||||
<div class="column">
|
<div class="column">
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
<label class="form-label mr-2">{{ $t('word.state') }}</label>
|
<label class="form-label mr-2">{{ $t('word.state') }}</label>
|
||||||
@@ -132,7 +130,7 @@
|
|||||||
:height="editorHeight"
|
:height="editorHeight"
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
<WorkspacePropsSchedulerTimingModal
|
<WorkspaceTabPropsSchedulerTimingModal
|
||||||
v-if="isTimingModal"
|
v-if="isTimingModal"
|
||||||
:local-options="localScheduler"
|
:local-options="localScheduler"
|
||||||
:workspace="workspace"
|
:workspace="workspace"
|
||||||
@@ -146,15 +144,15 @@
|
|||||||
import { mapGetters, mapActions } from 'vuex';
|
import { mapGetters, mapActions } from 'vuex';
|
||||||
import BaseLoader from '@/components/BaseLoader';
|
import BaseLoader from '@/components/BaseLoader';
|
||||||
import QueryEditor from '@/components/QueryEditor';
|
import QueryEditor from '@/components/QueryEditor';
|
||||||
import WorkspacePropsSchedulerTimingModal from '@/components/WorkspacePropsSchedulerTimingModal';
|
import WorkspaceTabPropsSchedulerTimingModal from '@/components/WorkspaceTabPropsSchedulerTimingModal';
|
||||||
import Schedulers from '@/ipc-api/Schedulers';
|
import Schedulers from '@/ipc-api/Schedulers';
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
name: 'WorkspacePropsTabScheduler',
|
name: 'WorkspaceTabPropsScheduler',
|
||||||
components: {
|
components: {
|
||||||
BaseLoader,
|
BaseLoader,
|
||||||
QueryEditor,
|
QueryEditor,
|
||||||
WorkspacePropsSchedulerTimingModal
|
WorkspaceTabPropsSchedulerTimingModal
|
||||||
},
|
},
|
||||||
props: {
|
props: {
|
||||||
connection: Object,
|
connection: Object,
|
@@ -143,7 +143,7 @@ import { VueMaskDirective } from 'v-mask';
|
|||||||
import moment from 'moment';
|
import moment from 'moment';
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
name: 'WorkspacePropsSchedulerTimingModal',
|
name: 'WorkspaceTabPropsSchedulerTimingModal',
|
||||||
components: {
|
components: {
|
||||||
ConfirmModal
|
ConfirmModal
|
||||||
},
|
},
|
@@ -51,14 +51,6 @@
|
|||||||
<i class="mdi mdi-24px mdi-key-link mr-1" />
|
<i class="mdi mdi-24px mdi-key-link mr-1" />
|
||||||
<span>{{ $t('word.foreignKeys') }}</span>
|
<span>{{ $t('word.foreignKeys') }}</span>
|
||||||
</button>
|
</button>
|
||||||
<button
|
|
||||||
class="btn btn-dark btn-sm"
|
|
||||||
:disabled="isSaving"
|
|
||||||
@click="showOptionsModal"
|
|
||||||
>
|
|
||||||
<i class="mdi mdi-24px mdi-cogs mr-1" />
|
|
||||||
<span>{{ $t('word.options') }}</span>
|
|
||||||
</button>
|
|
||||||
</div>
|
</div>
|
||||||
<div class="workspace-query-info">
|
<div class="workspace-query-info">
|
||||||
<div class="d-flex" :title="$t('word.schema')">
|
<div class="d-flex" :title="$t('word.schema')">
|
||||||
@@ -67,9 +59,80 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
<div class="container">
|
||||||
|
<div class="columns mb-4">
|
||||||
|
<div class="column col-auto">
|
||||||
|
<div class="form-group">
|
||||||
|
<label class="form-label">{{ $t('word.name') }}</label>
|
||||||
|
<input
|
||||||
|
v-model="localOptions.name"
|
||||||
|
class="form-input"
|
||||||
|
type="text"
|
||||||
|
>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div v-if="workspace.customizations.comment" class="column">
|
||||||
|
<div class="form-group">
|
||||||
|
<label class="form-label">{{ $t('word.comment') }}</label>
|
||||||
|
<input
|
||||||
|
v-model="localOptions.comment"
|
||||||
|
class="form-input"
|
||||||
|
type="text"
|
||||||
|
>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div v-if="workspace.customizations.autoIncrement" class="column col-auto">
|
||||||
|
<div class="form-group">
|
||||||
|
<label class="form-label">
|
||||||
|
{{ $t('word.autoIncrement') }}
|
||||||
|
</label>
|
||||||
|
<input
|
||||||
|
ref="firstInput"
|
||||||
|
v-model="localOptions.autoIncrement"
|
||||||
|
class="form-input"
|
||||||
|
type="number"
|
||||||
|
:disabled="localOptions.autoIncrement === null"
|
||||||
|
>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div v-if="workspace.customizations.collations" class="column col-auto">
|
||||||
|
<div class="form-group">
|
||||||
|
<label class="form-label">
|
||||||
|
{{ $t('word.collation') }}
|
||||||
|
</label>
|
||||||
|
<select v-model="localOptions.collation" class="form-select">
|
||||||
|
<option
|
||||||
|
v-for="collation in workspace.collations"
|
||||||
|
:key="collation.id"
|
||||||
|
:value="collation.collation"
|
||||||
|
>
|
||||||
|
{{ collation.collation }}
|
||||||
|
</option>
|
||||||
|
</select>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div v-if="workspace.customizations.engines" class="column col-auto">
|
||||||
|
<div class="form-group">
|
||||||
|
<label class="form-label">
|
||||||
|
{{ $t('word.engine') }}
|
||||||
|
</label>
|
||||||
|
<select v-model="localOptions.engine" class="form-select">
|
||||||
|
<option
|
||||||
|
v-for="engine in workspace.engines"
|
||||||
|
:key="engine.name"
|
||||||
|
:value="engine.name"
|
||||||
|
>
|
||||||
|
{{ engine.name }}
|
||||||
|
</option>
|
||||||
|
</select>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
<div class="workspace-query-results column col-12 p-relative">
|
<div class="workspace-query-results column col-12 p-relative">
|
||||||
<BaseLoader v-if="isLoading" />
|
<BaseLoader v-if="isLoading" />
|
||||||
<WorkspacePropsTable
|
<WorkspaceTabPropsTableFields
|
||||||
v-if="localFields"
|
v-if="localFields"
|
||||||
ref="indexTable"
|
ref="indexTable"
|
||||||
:fields="localFields"
|
:fields="localFields"
|
||||||
@@ -88,15 +151,7 @@
|
|||||||
@rename-field="renameField"
|
@rename-field="renameField"
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
<WorkspacePropsOptionsModal
|
<WorkspaceTabPropsTableIndexesModal
|
||||||
v-if="isOptionsModal"
|
|
||||||
:local-options="localOptions"
|
|
||||||
:table="table"
|
|
||||||
:workspace="workspace"
|
|
||||||
@hide="hideOptionsModal"
|
|
||||||
@options-update="optionsUpdate"
|
|
||||||
/>
|
|
||||||
<WorkspacePropsIndexesModal
|
|
||||||
v-if="isIndexesModal"
|
v-if="isIndexesModal"
|
||||||
:local-indexes="localIndexes"
|
:local-indexes="localIndexes"
|
||||||
:table="table"
|
:table="table"
|
||||||
@@ -106,7 +161,7 @@
|
|||||||
@hide="hideIndexesModal"
|
@hide="hideIndexesModal"
|
||||||
@indexes-update="indexesUpdate"
|
@indexes-update="indexesUpdate"
|
||||||
/>
|
/>
|
||||||
<WorkspacePropsForeignModal
|
<WorkspaceTabPropsTableForeignModal
|
||||||
v-if="isForeignModal"
|
v-if="isForeignModal"
|
||||||
:local-key-usage="localKeyUsage"
|
:local-key-usage="localKeyUsage"
|
||||||
:connection="connection"
|
:connection="connection"
|
||||||
@@ -126,19 +181,17 @@ import { mapGetters, mapActions } from 'vuex';
|
|||||||
import { uidGen } from 'common/libs/uidGen';
|
import { uidGen } from 'common/libs/uidGen';
|
||||||
import Tables from '@/ipc-api/Tables';
|
import Tables from '@/ipc-api/Tables';
|
||||||
import BaseLoader from '@/components/BaseLoader';
|
import BaseLoader from '@/components/BaseLoader';
|
||||||
import WorkspacePropsTable from '@/components/WorkspacePropsTable';
|
import WorkspaceTabPropsTableFields from '@/components/WorkspaceTabPropsTableFields';
|
||||||
import WorkspacePropsOptionsModal from '@/components/WorkspacePropsOptionsModal';
|
import WorkspaceTabPropsTableIndexesModal from '@/components/WorkspaceTabPropsTableIndexesModal';
|
||||||
import WorkspacePropsIndexesModal from '@/components/WorkspacePropsIndexesModal';
|
import WorkspaceTabPropsTableForeignModal from '@/components/WorkspaceTabPropsTableForeignModal';
|
||||||
import WorkspacePropsForeignModal from '@/components/WorkspacePropsForeignModal';
|
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
name: 'WorkspacePropsTab',
|
name: 'WorkspaceTabPropsTable',
|
||||||
components: {
|
components: {
|
||||||
BaseLoader,
|
BaseLoader,
|
||||||
WorkspacePropsTable,
|
WorkspaceTabPropsTableFields,
|
||||||
WorkspacePropsOptionsModal,
|
WorkspaceTabPropsTableIndexesModal,
|
||||||
WorkspacePropsIndexesModal,
|
WorkspaceTabPropsTableForeignModal
|
||||||
WorkspacePropsForeignModal
|
|
||||||
},
|
},
|
||||||
props: {
|
props: {
|
||||||
connection: Object,
|
connection: Object,
|
||||||
@@ -150,7 +203,6 @@ export default {
|
|||||||
return {
|
return {
|
||||||
isLoading: false,
|
isLoading: false,
|
||||||
isSaving: false,
|
isSaving: false,
|
||||||
isOptionsModal: false,
|
|
||||||
isIndexesModal: false,
|
isIndexesModal: false,
|
||||||
isForeignModal: false,
|
isForeignModal: false,
|
||||||
isOptionsChanging: false,
|
isOptionsChanging: false,
|
||||||
@@ -160,6 +212,7 @@ export default {
|
|||||||
localKeyUsage: [],
|
localKeyUsage: [],
|
||||||
originalIndexes: [],
|
originalIndexes: [],
|
||||||
localIndexes: [],
|
localIndexes: [],
|
||||||
|
tableOptions: {},
|
||||||
localOptions: {},
|
localOptions: {},
|
||||||
lastTable: null,
|
lastTable: null,
|
||||||
newFieldsCounter: 0
|
newFieldsCounter: 0
|
||||||
@@ -177,12 +230,9 @@ export default {
|
|||||||
tabUid () {
|
tabUid () {
|
||||||
return this.$vnode.key;
|
return this.$vnode.key;
|
||||||
},
|
},
|
||||||
tableOptions () {
|
|
||||||
const db = this.workspace.structure.find(db => db.name === this.schema);
|
|
||||||
return db && this.table ? db.tables.find(table => table.name === this.table) : {};
|
|
||||||
},
|
|
||||||
defaultEngine () {
|
defaultEngine () {
|
||||||
return this.getDatabaseVariable(this.connection.uid, 'default_storage_engine').value || '';
|
const engine = this.getDatabaseVariable(this.connection.uid, 'default_storage_engine');
|
||||||
|
return engine ? engine.value : '';
|
||||||
},
|
},
|
||||||
schemaTables () {
|
schemaTables () {
|
||||||
const schemaTables = this.workspace.structure
|
const schemaTables = this.workspace.structure
|
||||||
@@ -238,6 +288,20 @@ export default {
|
|||||||
renameTabs: 'workspaces/renameTabs',
|
renameTabs: 'workspaces/renameTabs',
|
||||||
changeBreadcrumbs: 'workspaces/changeBreadcrumbs'
|
changeBreadcrumbs: 'workspaces/changeBreadcrumbs'
|
||||||
}),
|
}),
|
||||||
|
async getTableOptions (params) {
|
||||||
|
const db = this.workspace.structure.find(db => db.name === this.schema);
|
||||||
|
|
||||||
|
if (db && db.tables.length && this.table)
|
||||||
|
this.tableOptions = db.tables.find(table => table.name === this.table);
|
||||||
|
else {
|
||||||
|
const { status, response } = await Tables.getTableOptions(params);
|
||||||
|
|
||||||
|
if (status === 'success')
|
||||||
|
this.tableOptions = response;
|
||||||
|
else
|
||||||
|
this.addNotification({ status: 'error', message: response });
|
||||||
|
}
|
||||||
|
},
|
||||||
async getFieldsData () {
|
async getFieldsData () {
|
||||||
if (!this.table) return;
|
if (!this.table) return;
|
||||||
|
|
||||||
@@ -245,10 +309,6 @@ export default {
|
|||||||
this.lastTable = this.table;
|
this.lastTable = this.table;
|
||||||
this.newFieldsCounter = 0;
|
this.newFieldsCounter = 0;
|
||||||
this.isLoading = true;
|
this.isLoading = true;
|
||||||
try {
|
|
||||||
this.localOptions = JSON.parse(JSON.stringify(this.tableOptions));
|
|
||||||
}
|
|
||||||
catch (err) {}
|
|
||||||
|
|
||||||
const params = {
|
const params = {
|
||||||
uid: this.connection.uid,
|
uid: this.connection.uid,
|
||||||
@@ -256,6 +316,14 @@ export default {
|
|||||||
table: this.table
|
table: this.table
|
||||||
};
|
};
|
||||||
|
|
||||||
|
try {
|
||||||
|
await this.getTableOptions(params);
|
||||||
|
this.localOptions = JSON.parse(JSON.stringify(this.tableOptions));
|
||||||
|
}
|
||||||
|
catch (err) {
|
||||||
|
console.error(err);
|
||||||
|
}
|
||||||
|
|
||||||
try { // Columns data
|
try { // Columns data
|
||||||
const { status, response } = await Tables.getTableColumns(params);
|
const { status, response } = await Tables.getTableColumns(params);
|
||||||
if (status === 'success') {
|
if (status === 'success') {
|
||||||
@@ -534,6 +602,11 @@ export default {
|
|||||||
fieldToClone.name = `${fieldToClone.name}_copy`;
|
fieldToClone.name = `${fieldToClone.name}_copy`;
|
||||||
fieldToClone.order = this.localFields.length + 1;
|
fieldToClone.order = this.localFields.length + 1;
|
||||||
this.localFields = [...this.localFields, fieldToClone];
|
this.localFields = [...this.localFields, fieldToClone];
|
||||||
|
|
||||||
|
setTimeout(() => {
|
||||||
|
const scrollable = this.$refs.indexTable.$refs.tableWrapper;
|
||||||
|
scrollable.scrollTop = scrollable.scrollHeight + 30;
|
||||||
|
}, 20);
|
||||||
},
|
},
|
||||||
removeField (uid) {
|
removeField (uid) {
|
||||||
this.localFields = this.localFields.filter(field => field._id !== uid);
|
this.localFields = this.localFields.filter(field => field._id !== uid);
|
||||||
@@ -556,12 +629,6 @@ export default {
|
|||||||
return index;
|
return index;
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
showOptionsModal () {
|
|
||||||
this.isOptionsModal = true;
|
|
||||||
},
|
|
||||||
hideOptionsModal () {
|
|
||||||
this.isOptionsModal = false;
|
|
||||||
},
|
|
||||||
optionsUpdate (options) {
|
optionsUpdate (options) {
|
||||||
this.localOptions = options;
|
this.localOptions = options;
|
||||||
},
|
},
|
@@ -46,7 +46,7 @@
|
|||||||
import BaseContextMenu from '@/components/BaseContextMenu';
|
import BaseContextMenu from '@/components/BaseContextMenu';
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
name: 'WorkspaceQueryTableContext',
|
name: 'WorkspaceTabQueryTableContext',
|
||||||
components: {
|
components: {
|
||||||
BaseContextMenu
|
BaseContextMenu
|
||||||
},
|
},
|
@@ -126,11 +126,11 @@
|
|||||||
<script>
|
<script>
|
||||||
import { mapActions, mapGetters } from 'vuex';
|
import { mapActions, mapGetters } from 'vuex';
|
||||||
import Draggable from 'vuedraggable';
|
import Draggable from 'vuedraggable';
|
||||||
import TableRow from '@/components/WorkspacePropsTableRow';
|
import TableRow from '@/components/WorkspaceTabPropsTableRow';
|
||||||
import TableContext from '@/components/WorkspacePropsTableContext';
|
import TableContext from '@/components/WorkspaceTabPropsTableContext';
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
name: 'WorkspacePropsTable',
|
name: 'WorkspaceTabPropsTableFields',
|
||||||
components: {
|
components: {
|
||||||
TableRow,
|
TableRow,
|
||||||
TableContext,
|
TableContext,
|
@@ -208,7 +208,7 @@ import Tables from '@/ipc-api/Tables';
|
|||||||
import ConfirmModal from '@/components/BaseConfirmModal';
|
import ConfirmModal from '@/components/BaseConfirmModal';
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
name: 'WorkspacePropsForeignModal',
|
name: 'WorkspaceTabPropsTableForeignModal',
|
||||||
components: {
|
components: {
|
||||||
ConfirmModal
|
ConfirmModal
|
||||||
},
|
},
|
@@ -142,7 +142,7 @@ import { uidGen } from 'common/libs/uidGen';
|
|||||||
import ConfirmModal from '@/components/BaseConfirmModal';
|
import ConfirmModal from '@/components/BaseConfirmModal';
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
name: 'WorkspacePropsIndexesModal',
|
name: 'WorkspaceTabPropsTableIndexesModal',
|
||||||
components: {
|
components: {
|
||||||
ConfirmModal
|
ConfirmModal
|
||||||
},
|
},
|
@@ -1,12 +1,12 @@
|
|||||||
<template>
|
<template>
|
||||||
<div class="tr" @contextmenu.prevent="$emit('contextmenu', $event, localRow._id)">
|
<div class="tr" @contextmenu.prevent="$emit('contextmenu', $event, localRow._id)">
|
||||||
<div class="td" tabindex="0">
|
<div class="td p-0" tabindex="0">
|
||||||
<div :class="customizations.sortableFields ? 'row-draggable' : 'text-center'">
|
<div :class="customizations.sortableFields ? 'row-draggable' : 'text-center'">
|
||||||
<i v-if="customizations.sortableFields" class="mdi mdi-drag-horizontal row-draggable-icon" />
|
<i v-if="customizations.sortableFields" class="mdi mdi-drag-horizontal row-draggable-icon" />
|
||||||
{{ localRow.order }}
|
{{ localRow.order }}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="td" tabindex="0">
|
<div class="td p-0" tabindex="0">
|
||||||
<div class="text-center">
|
<div class="text-center">
|
||||||
<i
|
<i
|
||||||
v-for="(index, i) in indexes"
|
v-for="(index, i) in indexes"
|
||||||
@@ -23,7 +23,7 @@
|
|||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="td" tabindex="0">
|
<div class="td p-0" tabindex="0">
|
||||||
<span
|
<span
|
||||||
v-if="!isInlineEditor.name"
|
v-if="!isInlineEditor.name"
|
||||||
class="cell-content"
|
class="cell-content"
|
||||||
@@ -37,12 +37,12 @@
|
|||||||
v-model="editingContent"
|
v-model="editingContent"
|
||||||
type="text"
|
type="text"
|
||||||
autofocus
|
autofocus
|
||||||
class="editable-field px-2"
|
class="editable-field form-input input-sm px-1"
|
||||||
@blur="editOFF"
|
@blur="editOFF"
|
||||||
>
|
>
|
||||||
</div>
|
</div>
|
||||||
<div
|
<div
|
||||||
class="td text-uppercase"
|
class="td p-0 text-uppercase"
|
||||||
tabindex="0"
|
tabindex="0"
|
||||||
>
|
>
|
||||||
<span
|
<span
|
||||||
@@ -57,7 +57,7 @@
|
|||||||
v-else
|
v-else
|
||||||
ref="editField"
|
ref="editField"
|
||||||
v-model="editingContent"
|
v-model="editingContent"
|
||||||
class="form-select editable-field small-select text-uppercase"
|
class="form-select editable-field pl-1 pr-4 small-select text-uppercase"
|
||||||
@blur="editOFF"
|
@blur="editOFF"
|
||||||
>
|
>
|
||||||
<option v-if="!isInDataTypes">
|
<option v-if="!isInDataTypes">
|
||||||
@@ -81,7 +81,7 @@
|
|||||||
</div>
|
</div>
|
||||||
<div
|
<div
|
||||||
v-if="customizations.tableArray"
|
v-if="customizations.tableArray"
|
||||||
class="td"
|
class="td p-0"
|
||||||
tabindex="0"
|
tabindex="0"
|
||||||
>
|
>
|
||||||
<label class="form-checkbox">
|
<label class="form-checkbox">
|
||||||
@@ -89,7 +89,7 @@
|
|||||||
<i class="form-icon" />
|
<i class="form-icon" />
|
||||||
</label>
|
</label>
|
||||||
</div>
|
</div>
|
||||||
<div class="td type-int" tabindex="0">
|
<div class="td p-0 type-int" tabindex="0">
|
||||||
<template v-if="fieldType.length">
|
<template v-if="fieldType.length">
|
||||||
<span
|
<span
|
||||||
v-if="!isInlineEditor.length"
|
v-if="!isInlineEditor.length"
|
||||||
@@ -109,7 +109,7 @@
|
|||||||
v-model="editingContent"
|
v-model="editingContent"
|
||||||
type="text"
|
type="text"
|
||||||
autofocus
|
autofocus
|
||||||
class="editable-field px-2"
|
class="editable-field form-input input-sm px-1"
|
||||||
@blur="editOFF"
|
@blur="editOFF"
|
||||||
>
|
>
|
||||||
<input
|
<input
|
||||||
@@ -118,14 +118,14 @@
|
|||||||
v-model="editingContent"
|
v-model="editingContent"
|
||||||
type="number"
|
type="number"
|
||||||
autofocus
|
autofocus
|
||||||
class="editable-field px-2"
|
class="editable-field form-input input-sm px-1"
|
||||||
@blur="editOFF"
|
@blur="editOFF"
|
||||||
>
|
>
|
||||||
</template>
|
</template>
|
||||||
</div>
|
</div>
|
||||||
<div
|
<div
|
||||||
v-if="customizations.unsigned"
|
v-if="customizations.unsigned"
|
||||||
class="td"
|
class="td p-0"
|
||||||
tabindex="0"
|
tabindex="0"
|
||||||
>
|
>
|
||||||
<label class="form-checkbox">
|
<label class="form-checkbox">
|
||||||
@@ -139,7 +139,7 @@
|
|||||||
</div>
|
</div>
|
||||||
<div
|
<div
|
||||||
v-if="customizations.nullable"
|
v-if="customizations.nullable"
|
||||||
class="td"
|
class="td p-0"
|
||||||
tabindex="0"
|
tabindex="0"
|
||||||
>
|
>
|
||||||
<label class="form-checkbox">
|
<label class="form-checkbox">
|
||||||
@@ -153,7 +153,7 @@
|
|||||||
</div>
|
</div>
|
||||||
<div
|
<div
|
||||||
v-if="customizations.zerofill"
|
v-if="customizations.zerofill"
|
||||||
class="td"
|
class="td p-0"
|
||||||
tabindex="0"
|
tabindex="0"
|
||||||
>
|
>
|
||||||
<label class="form-checkbox">
|
<label class="form-checkbox">
|
||||||
@@ -165,14 +165,14 @@
|
|||||||
<i class="form-icon" />
|
<i class="form-icon" />
|
||||||
</label>
|
</label>
|
||||||
</div>
|
</div>
|
||||||
<div class="td" tabindex="0">
|
<div class="td p-0" tabindex="0">
|
||||||
<span class="cell-content" @dblclick="editON($event, localRow.default, 'default')">
|
<span class="cell-content" @dblclick="editON($event, localRow.default, 'default')">
|
||||||
{{ fieldDefault }}
|
{{ fieldDefault }}
|
||||||
</span>
|
</span>
|
||||||
</div>
|
</div>
|
||||||
<div
|
<div
|
||||||
v-if="customizations.comment"
|
v-if="customizations.comment"
|
||||||
class="td type-varchar"
|
class="td p-0 type-varchar"
|
||||||
tabindex="0"
|
tabindex="0"
|
||||||
>
|
>
|
||||||
<span
|
<span
|
||||||
@@ -188,13 +188,13 @@
|
|||||||
v-model="editingContent"
|
v-model="editingContent"
|
||||||
type="text"
|
type="text"
|
||||||
autofocus
|
autofocus
|
||||||
class="editable-field px-2"
|
class="editable-field form-input input-sm px-1"
|
||||||
@blur="editOFF"
|
@blur="editOFF"
|
||||||
>
|
>
|
||||||
</div>
|
</div>
|
||||||
<div
|
<div
|
||||||
v-if="customizations.collation"
|
v-if="customizations.collation"
|
||||||
class="td"
|
class="td p-0"
|
||||||
tabindex="0"
|
tabindex="0"
|
||||||
>
|
>
|
||||||
<template v-if="fieldType.collation">
|
<template v-if="fieldType.collation">
|
||||||
@@ -209,7 +209,7 @@
|
|||||||
v-else
|
v-else
|
||||||
ref="editField"
|
ref="editField"
|
||||||
v-model="editingContent"
|
v-model="editingContent"
|
||||||
class="form-select small-select editable-field"
|
class="form-select small-select pl-1 pr-4 editable-field"
|
||||||
@blur="editOFF"
|
@blur="editOFF"
|
||||||
>
|
>
|
||||||
<option
|
<option
|
||||||
@@ -334,7 +334,7 @@ import { mapGetters } from 'vuex';
|
|||||||
import ConfirmModal from '@/components/BaseConfirmModal';
|
import ConfirmModal from '@/components/BaseConfirmModal';
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
name: 'WorkspacePropsTableRow',
|
name: 'WorkspaceTabPropsTableRow',
|
||||||
components: {
|
components: {
|
||||||
ConfirmModal
|
ConfirmModal
|
||||||
},
|
},
|
||||||
@@ -575,12 +575,16 @@ export default {
|
|||||||
position: absolute;
|
position: absolute;
|
||||||
left: 0;
|
left: 0;
|
||||||
right: 0;
|
right: 0;
|
||||||
|
max-height: 21px;
|
||||||
|
border-radius: 3px;
|
||||||
|
font-size: 0.7rem;
|
||||||
}
|
}
|
||||||
|
|
||||||
.row-draggable {
|
.row-draggable {
|
||||||
position: relative;
|
position: relative;
|
||||||
text-align: right;
|
text-align: right;
|
||||||
padding-left: 28px;
|
padding-left: 28px;
|
||||||
|
padding-right: 2px;
|
||||||
cursor: grab;
|
cursor: grab;
|
||||||
|
|
||||||
.row-draggable-icon {
|
.row-draggable-icon {
|
||||||
@@ -602,13 +606,14 @@ export default {
|
|||||||
min-height: auto;
|
min-height: auto;
|
||||||
|
|
||||||
.form-icon {
|
.form-icon {
|
||||||
top: 0.15rem;
|
top: -0.65rem;
|
||||||
left: calc(50% - 8px);
|
left: calc(50% - 8px);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
.cell-content {
|
.cell-content {
|
||||||
display: block;
|
display: block;
|
||||||
|
padding: 0 0.2rem;
|
||||||
min-height: 0.8rem;
|
min-height: 0.8rem;
|
||||||
text-overflow: ellipsis;
|
text-overflow: ellipsis;
|
||||||
white-space: nowrap;
|
white-space: nowrap;
|
@@ -31,7 +31,7 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="container">
|
<div class="container">
|
||||||
<div class="columns mb-4">
|
<div class="columns">
|
||||||
<div class="column col-auto">
|
<div class="column col-auto">
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
<label class="form-label">{{ $t('word.name') }}</label>
|
<label class="form-label">{{ $t('word.name') }}</label>
|
||||||
@@ -71,49 +71,49 @@
|
|||||||
</select>
|
</select>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
<fieldset class="column columns mb-0" :disabled="customizations.triggerOnlyRename">
|
||||||
<fieldset class="columns" :disabled="customizations.triggerOnlyRename">
|
<div class="column col-auto">
|
||||||
<div class="column col-auto">
|
<div class="form-group">
|
||||||
<div class="form-group">
|
<label class="form-label">{{ $t('word.table') }}</label>
|
||||||
<label class="form-label">{{ $t('word.table') }}</label>
|
<select v-model="localTrigger.table" class="form-select">
|
||||||
<select v-model="localTrigger.table" class="form-select">
|
<option v-for="table in schemaTables" :key="table.name">
|
||||||
<option v-for="table in schemaTables" :key="table.name">
|
{{ table.name }}
|
||||||
{{ table.name }}
|
|
||||||
</option>
|
|
||||||
</select>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<div class="column col-auto">
|
|
||||||
<div class="form-group">
|
|
||||||
<label class="form-label">{{ $t('word.event') }}</label>
|
|
||||||
<div class="input-group">
|
|
||||||
<select v-model="localTrigger.activation" class="form-select">
|
|
||||||
<option>BEFORE</option>
|
|
||||||
<option>AFTER</option>
|
|
||||||
</select>
|
|
||||||
<select
|
|
||||||
v-if="!customizations.triggerMultipleEvents"
|
|
||||||
v-model="localTrigger.event"
|
|
||||||
class="form-select"
|
|
||||||
>
|
|
||||||
<option v-for="event in Object.keys(localEvents)" :key="event">
|
|
||||||
{{ event }}
|
|
||||||
</option>
|
</option>
|
||||||
</select>
|
</select>
|
||||||
<div v-if="customizations.triggerMultipleEvents" class="px-4">
|
</div>
|
||||||
<label
|
</div>
|
||||||
v-for="event in Object.keys(localEvents)"
|
<div class="column col-auto">
|
||||||
:key="event"
|
<div class="form-group">
|
||||||
class="form-checkbox form-inline"
|
<label class="form-label">{{ $t('word.event') }}</label>
|
||||||
@change.prevent="changeEvents(event)"
|
<div class="input-group">
|
||||||
|
<select v-model="localTrigger.activation" class="form-select">
|
||||||
|
<option>BEFORE</option>
|
||||||
|
<option>AFTER</option>
|
||||||
|
</select>
|
||||||
|
<select
|
||||||
|
v-if="!customizations.triggerMultipleEvents"
|
||||||
|
v-model="localTrigger.event"
|
||||||
|
class="form-select"
|
||||||
>
|
>
|
||||||
<input :checked="localEvents[event]" type="checkbox"><i class="form-icon" /> {{ event }}
|
<option v-for="event in Object.keys(localEvents)" :key="event">
|
||||||
</label>
|
{{ event }}
|
||||||
|
</option>
|
||||||
|
</select>
|
||||||
|
<div v-if="customizations.triggerMultipleEvents" class="px-4">
|
||||||
|
<label
|
||||||
|
v-for="event in Object.keys(localEvents)"
|
||||||
|
:key="event"
|
||||||
|
class="form-checkbox form-inline"
|
||||||
|
@change.prevent="changeEvents(event)"
|
||||||
|
>
|
||||||
|
<input :checked="localEvents[event]" type="checkbox"><i class="form-icon" /> {{ event }}
|
||||||
|
</label>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</fieldset>
|
||||||
</fieldset>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="workspace-query-results column col-12 mt-2 p-relative">
|
<div class="workspace-query-results column col-12 mt-2 p-relative">
|
||||||
<BaseLoader v-if="isLoading" />
|
<BaseLoader v-if="isLoading" />
|
||||||
@@ -137,7 +137,7 @@ import BaseLoader from '@/components/BaseLoader';
|
|||||||
import Triggers from '@/ipc-api/Triggers';
|
import Triggers from '@/ipc-api/Triggers';
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
name: 'WorkspacePropsTabTrigger',
|
name: 'WorkspaceTabPropsTrigger',
|
||||||
components: {
|
components: {
|
||||||
BaseLoader,
|
BaseLoader,
|
||||||
QueryEditor
|
QueryEditor
|
@@ -22,13 +22,60 @@
|
|||||||
<i class="mdi mdi-24px mdi-delete-sweep mr-1" />
|
<i class="mdi mdi-24px mdi-delete-sweep mr-1" />
|
||||||
<span>{{ $t('word.clear') }}</span>
|
<span>{{ $t('word.clear') }}</span>
|
||||||
</button>
|
</button>
|
||||||
|
</div>
|
||||||
<div class="divider-vert py-3" />
|
</div>
|
||||||
|
</div>
|
||||||
<button class="btn btn-dark btn-sm" @click="showOptionsModal">
|
<div class="container">
|
||||||
<i class="mdi mdi-24px mdi-cogs mr-1" />
|
<div class="columns">
|
||||||
<span>{{ $t('word.options') }}</span>
|
<div v-if="customizations.triggerFunctionlanguages" class="column col-auto">
|
||||||
</button>
|
<div class="form-group">
|
||||||
|
<label class="form-label">
|
||||||
|
{{ $t('word.language') }}
|
||||||
|
</label>
|
||||||
|
<select v-model="localFunction.language" class="form-select">
|
||||||
|
<option v-for="language in customizations.triggerFunctionlanguages" :key="language">
|
||||||
|
{{ language }}
|
||||||
|
</option>
|
||||||
|
</select>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div v-if="customizations.definer" class="column col-auto">
|
||||||
|
<div class="form-group">
|
||||||
|
<label class="form-label">
|
||||||
|
{{ $t('word.definer') }}
|
||||||
|
</label>
|
||||||
|
<select
|
||||||
|
v-if="workspace.users.length"
|
||||||
|
v-model="localFunction.definer"
|
||||||
|
class="form-select"
|
||||||
|
>
|
||||||
|
<option value="">
|
||||||
|
{{ $t('message.currentUser') }}
|
||||||
|
</option>
|
||||||
|
<option
|
||||||
|
v-for="user in workspace.users"
|
||||||
|
:key="`${user.name}@${user.host}`"
|
||||||
|
:value="`\`${user.name}\`@\`${user.host}\``"
|
||||||
|
>
|
||||||
|
{{ user.name }}@{{ user.host }}
|
||||||
|
</option>
|
||||||
|
</select>
|
||||||
|
<select v-if="!workspace.users.length" class="form-select">
|
||||||
|
<option value="">
|
||||||
|
{{ $t('message.currentUser') }}
|
||||||
|
</option>
|
||||||
|
</select>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div v-if="customizations.comment" class="form-group">
|
||||||
|
<label class="form-label">
|
||||||
|
{{ $t('word.comment') }}
|
||||||
|
</label>
|
||||||
|
<input
|
||||||
|
v-model="localFunction.comment"
|
||||||
|
class="form-input"
|
||||||
|
type="text"
|
||||||
|
>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@@ -44,13 +91,6 @@
|
|||||||
:height="editorHeight"
|
:height="editorHeight"
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
<WorkspacePropsTriggerFunctionOptionsModal
|
|
||||||
v-if="isOptionsModal"
|
|
||||||
:local-options="localFunction"
|
|
||||||
:workspace="workspace"
|
|
||||||
@hide="hideOptionsModal"
|
|
||||||
@options-update="optionsUpdate"
|
|
||||||
/>
|
|
||||||
<ModalAskParameters
|
<ModalAskParameters
|
||||||
v-if="isAskingParameters"
|
v-if="isAskingParameters"
|
||||||
:local-routine="localFunction"
|
:local-routine="localFunction"
|
||||||
@@ -66,16 +106,14 @@ import { mapGetters, mapActions } from 'vuex';
|
|||||||
import { uidGen } from 'common/libs/uidGen';
|
import { uidGen } from 'common/libs/uidGen';
|
||||||
import BaseLoader from '@/components/BaseLoader';
|
import BaseLoader from '@/components/BaseLoader';
|
||||||
import QueryEditor from '@/components/QueryEditor';
|
import QueryEditor from '@/components/QueryEditor';
|
||||||
import WorkspacePropsTriggerFunctionOptionsModal from '@/components/WorkspacePropsTriggerFunctionOptionsModal';
|
|
||||||
import ModalAskParameters from '@/components/ModalAskParameters';
|
import ModalAskParameters from '@/components/ModalAskParameters';
|
||||||
import Functions from '@/ipc-api/Functions';
|
import Functions from '@/ipc-api/Functions';
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
name: 'WorkspacePropsTabTriggerFunction',
|
name: 'WorkspaceTabPropsTriggerFunction',
|
||||||
components: {
|
components: {
|
||||||
BaseLoader,
|
BaseLoader,
|
||||||
QueryEditor,
|
QueryEditor,
|
||||||
WorkspacePropsTriggerFunctionOptionsModal,
|
|
||||||
ModalAskParameters
|
ModalAskParameters
|
||||||
},
|
},
|
||||||
props: {
|
props: {
|
||||||
@@ -88,7 +126,6 @@ export default {
|
|||||||
return {
|
return {
|
||||||
isLoading: false,
|
isLoading: false,
|
||||||
isSaving: false,
|
isSaving: false,
|
||||||
isOptionsModal: false,
|
|
||||||
isParamsModal: false,
|
isParamsModal: false,
|
||||||
isAskingParameters: false,
|
isAskingParameters: false,
|
||||||
originalFunction: null,
|
originalFunction: null,
|
||||||
@@ -106,6 +143,9 @@ export default {
|
|||||||
workspace () {
|
workspace () {
|
||||||
return this.getWorkspace(this.connection.uid);
|
return this.getWorkspace(this.connection.uid);
|
||||||
},
|
},
|
||||||
|
customizations () {
|
||||||
|
return this.workspace.customizations;
|
||||||
|
},
|
||||||
tabUid () {
|
tabUid () {
|
||||||
return this.$vnode.key;
|
return this.$vnode.key;
|
||||||
},
|
},
|
||||||
@@ -303,12 +343,6 @@ export default {
|
|||||||
|
|
||||||
this.newTab({ uid: this.connection.uid, content: sql, type: 'query', autorun: true });
|
this.newTab({ uid: this.connection.uid, content: sql, type: 'query', autorun: true });
|
||||||
},
|
},
|
||||||
showOptionsModal () {
|
|
||||||
this.isOptionsModal = true;
|
|
||||||
},
|
|
||||||
hideOptionsModal () {
|
|
||||||
this.isOptionsModal = false;
|
|
||||||
},
|
|
||||||
showParamsModal () {
|
showParamsModal () {
|
||||||
this.isParamsModal = true;
|
this.isParamsModal = true;
|
||||||
},
|
},
|
@@ -31,7 +31,7 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="container">
|
<div class="container">
|
||||||
<div class="columns mb-4">
|
<div class="columns">
|
||||||
<div class="column col-auto">
|
<div class="column col-auto">
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
<label class="form-label">{{ $t('word.name') }}</label>
|
<label class="form-label">{{ $t('word.name') }}</label>
|
||||||
@@ -71,93 +71,35 @@
|
|||||||
</select>
|
</select>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
|
||||||
<div class="columns">
|
|
||||||
<div class="column col-auto mr-2">
|
<div class="column col-auto mr-2">
|
||||||
<div v-if="workspace.customizations.viewSqlSecurity" class="form-group">
|
<div v-if="workspace.customizations.viewSqlSecurity" class="form-group">
|
||||||
<label class="form-label">{{ $t('message.sqlSecurity') }}</label>
|
<label class="form-label">{{ $t('message.sqlSecurity') }}</label>
|
||||||
<label class="form-radio">
|
<select v-model="localView.security" class="form-select">
|
||||||
<input
|
<option>DEFINER</option>
|
||||||
v-model="localView.security"
|
<option>INVOKER</option>
|
||||||
type="radio"
|
</select>
|
||||||
name="security"
|
|
||||||
value="DEFINER"
|
|
||||||
>
|
|
||||||
<i class="form-icon" /> DEFINER
|
|
||||||
</label>
|
|
||||||
<label class="form-radio">
|
|
||||||
<input
|
|
||||||
v-model="localView.security"
|
|
||||||
type="radio"
|
|
||||||
name="security"
|
|
||||||
value="INVOKER"
|
|
||||||
>
|
|
||||||
<i class="form-icon" /> INVOKER
|
|
||||||
</label>
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="column col-auto mr-2">
|
<div class="column col-auto mr-2">
|
||||||
<div v-if="workspace.customizations.viewAlgorithm" class="form-group">
|
<div v-if="workspace.customizations.viewAlgorithm" class="form-group">
|
||||||
<label class="form-label">{{ $t('word.algorithm') }}</label>
|
<label class="form-label">{{ $t('word.algorithm') }}</label>
|
||||||
<label class="form-radio">
|
<select v-model="localView.algorithm" class="form-select">
|
||||||
<input
|
<option>UNDEFINED</option>
|
||||||
v-model="localView.algorithm"
|
<option>MERGE</option>
|
||||||
type="radio"
|
<option>TEMPTABLE</option>
|
||||||
name="algorithm"
|
</select>
|
||||||
value="UNDEFINED"
|
|
||||||
>
|
|
||||||
<i class="form-icon" /> UNDEFINED
|
|
||||||
</label>
|
|
||||||
<label class="form-radio">
|
|
||||||
<input
|
|
||||||
v-model="localView.algorithm"
|
|
||||||
type="radio"
|
|
||||||
value="MERGE"
|
|
||||||
name="algorithm"
|
|
||||||
>
|
|
||||||
<i class="form-icon" /> MERGE
|
|
||||||
</label>
|
|
||||||
<label class="form-radio">
|
|
||||||
<input
|
|
||||||
v-model="localView.algorithm"
|
|
||||||
type="radio"
|
|
||||||
value="TEMPTABLE"
|
|
||||||
name="algorithm"
|
|
||||||
>
|
|
||||||
<i class="form-icon" /> TEMPTABLE
|
|
||||||
</label>
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div v-if="workspace.customizations.viewUpdateOption" class="column col-auto mr-2">
|
<div v-if="workspace.customizations.viewUpdateOption" class="column col-auto mr-2">
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
<label class="form-label">{{ $t('message.updateOption') }}</label>
|
<label class="form-label">{{ $t('message.updateOption') }}</label>
|
||||||
<label class="form-radio">
|
<select v-model="localView.updateOption" class="form-select">
|
||||||
<input
|
<option value="">
|
||||||
v-model="localView.updateOption"
|
None
|
||||||
type="radio"
|
</option>
|
||||||
name="update"
|
<option>CASCADED</option>
|
||||||
value=""
|
<option>LOCAL</option>
|
||||||
>
|
</select>
|
||||||
<i class="form-icon" /> None
|
|
||||||
</label>
|
|
||||||
<label class="form-radio">
|
|
||||||
<input
|
|
||||||
v-model="localView.updateOption"
|
|
||||||
type="radio"
|
|
||||||
name="update"
|
|
||||||
value="CASCADED"
|
|
||||||
>
|
|
||||||
<i class="form-icon" /> CASCADED
|
|
||||||
</label>
|
|
||||||
<label class="form-radio">
|
|
||||||
<input
|
|
||||||
v-model="localView.updateOption"
|
|
||||||
type="radio"
|
|
||||||
name="update"
|
|
||||||
value="LOCAL"
|
|
||||||
>
|
|
||||||
<i class="form-icon" /> LOCAL
|
|
||||||
</label>
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@@ -184,7 +126,7 @@ import QueryEditor from '@/components/QueryEditor';
|
|||||||
import Views from '@/ipc-api/Views';
|
import Views from '@/ipc-api/Views';
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
name: 'WorkspacePropsTabView',
|
name: 'WorkspaceTabPropsView',
|
||||||
components: {
|
components: {
|
||||||
BaseLoader,
|
BaseLoader,
|
||||||
QueryEditor
|
QueryEditor
|
@@ -100,10 +100,10 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<WorkspaceQueryEmptyState v-if="!results.length && !isQuering" />
|
<WorkspaceTabQueryEmptyState v-if="!results.length && !isQuering" />
|
||||||
<div class="workspace-query-results p-relative column col-12">
|
<div class="workspace-query-results p-relative column col-12">
|
||||||
<BaseLoader v-if="isQuering" />
|
<BaseLoader v-if="isQuering" />
|
||||||
<WorkspaceQueryTable
|
<WorkspaceTabQueryTable
|
||||||
v-if="results"
|
v-if="results"
|
||||||
v-show="!isQuering"
|
v-show="!isQuering"
|
||||||
ref="queryTable"
|
ref="queryTable"
|
||||||
@@ -124,18 +124,18 @@ import { format } from 'sql-formatter';
|
|||||||
import Schema from '@/ipc-api/Schema';
|
import Schema from '@/ipc-api/Schema';
|
||||||
import QueryEditor from '@/components/QueryEditor';
|
import QueryEditor from '@/components/QueryEditor';
|
||||||
import BaseLoader from '@/components/BaseLoader';
|
import BaseLoader from '@/components/BaseLoader';
|
||||||
import WorkspaceQueryTable from '@/components/WorkspaceQueryTable';
|
import WorkspaceTabQueryTable from '@/components/WorkspaceTabQueryTable';
|
||||||
import WorkspaceQueryEmptyState from '@/components/WorkspaceQueryEmptyState';
|
import WorkspaceTabQueryEmptyState from '@/components/WorkspaceTabQueryEmptyState';
|
||||||
import { mapGetters, mapActions } from 'vuex';
|
import { mapGetters, mapActions } from 'vuex';
|
||||||
import tableTabs from '@/mixins/tableTabs';
|
import tableTabs from '@/mixins/tableTabs';
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
name: 'WorkspaceQueryTab',
|
name: 'WorkspaceTabQuery',
|
||||||
components: {
|
components: {
|
||||||
BaseLoader,
|
BaseLoader,
|
||||||
QueryEditor,
|
QueryEditor,
|
||||||
WorkspaceQueryTable,
|
WorkspaceTabQueryTable,
|
||||||
WorkspaceQueryEmptyState
|
WorkspaceTabQueryEmptyState
|
||||||
},
|
},
|
||||||
mixins: [tableTabs],
|
mixins: [tableTabs],
|
||||||
props: {
|
props: {
|
@@ -29,7 +29,7 @@
|
|||||||
|
|
||||||
<script>
|
<script>
|
||||||
export default {
|
export default {
|
||||||
name: 'WorkspaceQueryEmptyState'
|
name: 'WorkspaceTabQueryEmptyState'
|
||||||
};
|
};
|
||||||
</script>
|
</script>
|
||||||
|
|
@@ -66,7 +66,7 @@
|
|||||||
:scroll-element="scrollElement"
|
:scroll-element="scrollElement"
|
||||||
>
|
>
|
||||||
<template slot-scope="{ items }">
|
<template slot-scope="{ items }">
|
||||||
<WorkspaceQueryTableRow
|
<WorkspaceTabQueryTableRow
|
||||||
v-for="row in items"
|
v-for="row in items"
|
||||||
:key="row._id"
|
:key="row._id"
|
||||||
:row="row"
|
:row="row"
|
||||||
@@ -107,17 +107,17 @@ import { uidGen } from 'common/libs/uidGen';
|
|||||||
import arrayToFile from '../libs/arrayToFile';
|
import arrayToFile from '../libs/arrayToFile';
|
||||||
import { TEXT, LONG_TEXT, BLOB } from 'common/fieldTypes';
|
import { TEXT, LONG_TEXT, BLOB } from 'common/fieldTypes';
|
||||||
import BaseVirtualScroll from '@/components/BaseVirtualScroll';
|
import BaseVirtualScroll from '@/components/BaseVirtualScroll';
|
||||||
import WorkspaceQueryTableRow from '@/components/WorkspaceQueryTableRow';
|
import WorkspaceTabQueryTableRow from '@/components/WorkspaceTabQueryTableRow';
|
||||||
import TableContext from '@/components/WorkspaceQueryTableContext';
|
import TableContext from '@/components/WorkspaceTabQueryTableContext';
|
||||||
import ConfirmModal from '@/components/BaseConfirmModal';
|
import ConfirmModal from '@/components/BaseConfirmModal';
|
||||||
import { mapActions, mapGetters } from 'vuex';
|
import { mapActions, mapGetters } from 'vuex';
|
||||||
import moment from 'moment';
|
import moment from 'moment';
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
name: 'WorkspaceQueryTable',
|
name: 'WorkspaceTabQueryTable',
|
||||||
components: {
|
components: {
|
||||||
BaseVirtualScroll,
|
BaseVirtualScroll,
|
||||||
WorkspaceQueryTableRow,
|
WorkspaceTabQueryTableRow,
|
||||||
TableContext,
|
TableContext,
|
||||||
ConfirmModal
|
ConfirmModal
|
||||||
},
|
},
|
@@ -52,7 +52,7 @@
|
|||||||
import BaseContextMenu from '@/components/BaseContextMenu';
|
import BaseContextMenu from '@/components/BaseContextMenu';
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
name: 'WorkspaceQueryTableContext',
|
name: 'WorkspaceTabQueryTableContext',
|
||||||
components: {
|
components: {
|
||||||
BaseContextMenu
|
BaseContextMenu
|
||||||
},
|
},
|
@@ -11,7 +11,7 @@
|
|||||||
<template v-if="cKey !== '_id'">
|
<template v-if="cKey !== '_id'">
|
||||||
<span
|
<span
|
||||||
v-if="!isInlineEditor[cKey] && fields[cKey]"
|
v-if="!isInlineEditor[cKey] && fields[cKey]"
|
||||||
class="cell-content px-2"
|
class="cell-content"
|
||||||
:class="`${isNull(col)} ${typeClass(fields[cKey].type)}`"
|
:class="`${isNull(col)} ${typeClass(fields[cKey].type)}`"
|
||||||
@dblclick="editON($event, col, cKey)"
|
@dblclick="editON($event, col, cKey)"
|
||||||
>{{ col | typeFormat(fields[cKey].type.toLowerCase(), fields[cKey].length) | cutText }}</span>
|
>{{ col | typeFormat(fields[cKey].type.toLowerCase(), fields[cKey].length) | cutText }}</span>
|
||||||
@@ -31,7 +31,7 @@
|
|||||||
v-mask="inputProps.mask"
|
v-mask="inputProps.mask"
|
||||||
:type="inputProps.type"
|
:type="inputProps.type"
|
||||||
autofocus
|
autofocus
|
||||||
class="editable-field px-2"
|
class="editable-field form-input input-sm px-1"
|
||||||
@blur="editOFF"
|
@blur="editOFF"
|
||||||
>
|
>
|
||||||
<select
|
<select
|
||||||
@@ -59,7 +59,7 @@
|
|||||||
v-model="editingContent"
|
v-model="editingContent"
|
||||||
:type="inputProps.type"
|
:type="inputProps.type"
|
||||||
autofocus
|
autofocus
|
||||||
class="editable-field px-2"
|
class="editable-field form-input input-sm px-1"
|
||||||
@blur="editOFF"
|
@blur="editOFF"
|
||||||
>
|
>
|
||||||
</template>
|
</template>
|
||||||
@@ -200,7 +200,7 @@ import TextEditor from '@/components/BaseTextEditor';
|
|||||||
import ForeignKeySelect from '@/components/ForeignKeySelect';
|
import ForeignKeySelect from '@/components/ForeignKeySelect';
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
name: 'WorkspaceQueryTableRow',
|
name: 'WorkspaceTabQueryTableRow',
|
||||||
components: {
|
components: {
|
||||||
ConfirmModal,
|
ConfirmModal,
|
||||||
TextEditor,
|
TextEditor,
|
||||||
@@ -528,6 +528,9 @@ export default {
|
|||||||
border: none;
|
border: none;
|
||||||
line-height: 1;
|
line-height: 1;
|
||||||
width: 100%;
|
width: 100%;
|
||||||
|
max-height: 21px;
|
||||||
|
border-radius: 3px;
|
||||||
|
font-size: 0.7rem;
|
||||||
position: absolute;
|
position: absolute;
|
||||||
left: 0;
|
left: 0;
|
||||||
right: 0;
|
right: 0;
|
||||||
@@ -535,6 +538,7 @@ export default {
|
|||||||
|
|
||||||
.cell-content {
|
.cell-content {
|
||||||
display: block;
|
display: block;
|
||||||
|
padding: 0 0.2rem;
|
||||||
min-height: 0.8rem;
|
min-height: 0.8rem;
|
||||||
text-overflow: ellipsis;
|
text-overflow: ellipsis;
|
||||||
white-space: nowrap;
|
white-space: nowrap;
|
@@ -123,7 +123,7 @@
|
|||||||
</div>
|
</div>
|
||||||
<div class="workspace-query-results p-relative column col-12">
|
<div class="workspace-query-results p-relative column col-12">
|
||||||
<BaseLoader v-if="isQuering" />
|
<BaseLoader v-if="isQuering" />
|
||||||
<WorkspaceQueryTable
|
<WorkspaceTabQueryTable
|
||||||
v-if="results"
|
v-if="results"
|
||||||
ref="queryTable"
|
ref="queryTable"
|
||||||
:results="results"
|
:results="results"
|
||||||
@@ -159,17 +159,17 @@
|
|||||||
<script>
|
<script>
|
||||||
import Tables from '@/ipc-api/Tables';
|
import Tables from '@/ipc-api/Tables';
|
||||||
import BaseLoader from '@/components/BaseLoader';
|
import BaseLoader from '@/components/BaseLoader';
|
||||||
import WorkspaceQueryTable from '@/components/WorkspaceQueryTable';
|
import WorkspaceTabQueryTable from '@/components/WorkspaceTabQueryTable';
|
||||||
import ModalNewTableRow from '@/components/ModalNewTableRow';
|
import ModalNewTableRow from '@/components/ModalNewTableRow';
|
||||||
import ModalFakerRows from '@/components/ModalFakerRows';
|
import ModalFakerRows from '@/components/ModalFakerRows';
|
||||||
import { mapGetters, mapActions } from 'vuex';
|
import { mapGetters, mapActions } from 'vuex';
|
||||||
import tableTabs from '@/mixins/tableTabs';
|
import tableTabs from '@/mixins/tableTabs';
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
name: 'WorkspaceTableTab',
|
name: 'WorkspaceTabTable',
|
||||||
components: {
|
components: {
|
||||||
BaseLoader,
|
BaseLoader,
|
||||||
WorkspaceQueryTable,
|
WorkspaceTabQueryTable,
|
||||||
ModalNewTableRow,
|
ModalNewTableRow,
|
||||||
ModalFakerRows
|
ModalFakerRows
|
||||||
},
|
},
|
||||||
@@ -287,7 +287,7 @@ export default {
|
|||||||
changeBreadcrumbs: 'workspaces/changeBreadcrumbs'
|
changeBreadcrumbs: 'workspaces/changeBreadcrumbs'
|
||||||
}),
|
}),
|
||||||
async getTableData () {
|
async getTableData () {
|
||||||
if (!this.table) return;
|
if (!this.table || !this.isSelected) return;
|
||||||
this.isQuering = true;
|
this.isQuering = true;
|
||||||
|
|
||||||
// if table changes clear cached values
|
// if table changes clear cached values
|
@@ -116,7 +116,8 @@ module.exports = {
|
|||||||
triggerFunction: 'Trigger function | Trigger functions',
|
triggerFunction: 'Trigger function | Trigger functions',
|
||||||
all: 'All',
|
all: 'All',
|
||||||
duplicate: 'Duplicate',
|
duplicate: 'Duplicate',
|
||||||
routine: 'Routine'
|
routine: 'Routine',
|
||||||
|
new: 'New'
|
||||||
},
|
},
|
||||||
message: {
|
message: {
|
||||||
appWelcome: 'Welcome to Antares SQL Client!',
|
appWelcome: 'Welcome to Antares SQL Client!',
|
||||||
@@ -229,7 +230,15 @@ module.exports = {
|
|||||||
noOpenTabs: 'There are no open tabs, navigate on the left bar or:',
|
noOpenTabs: 'There are no open tabs, navigate on the left bar or:',
|
||||||
noSchema: 'No schema',
|
noSchema: 'No schema',
|
||||||
restorePreviourSession: 'Restore previous session',
|
restorePreviourSession: 'Restore previous session',
|
||||||
runQuery: 'Run query'
|
runQuery: 'Run query',
|
||||||
|
thereAreNoTableFields: 'There are no table fields',
|
||||||
|
newTable: 'New table',
|
||||||
|
newView: 'New view',
|
||||||
|
newTrigger: 'New trigger',
|
||||||
|
newRoutine: 'New routine',
|
||||||
|
newFunction: 'New function',
|
||||||
|
newScheduler: 'New scheduler',
|
||||||
|
newTriggerFunction: 'New trigger function'
|
||||||
},
|
},
|
||||||
faker: {
|
faker: {
|
||||||
address: 'Address',
|
address: 'Address',
|
||||||
|
@@ -14,6 +14,10 @@ export default class {
|
|||||||
return ipcRenderer.invoke('get-table-count', params);
|
return ipcRenderer.invoke('get-table-count', params);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static getTableOptions (params) {
|
||||||
|
return ipcRenderer.invoke('get-table-options', params);
|
||||||
|
}
|
||||||
|
|
||||||
static getTableIndexes (params) {
|
static getTableIndexes (params) {
|
||||||
return ipcRenderer.invoke('get-table-indexes', params);
|
return ipcRenderer.invoke('get-table-indexes', params);
|
||||||
}
|
}
|
||||||
|
@@ -29,6 +29,7 @@
|
|||||||
.th {
|
.th {
|
||||||
padding: $unit-3 $unit-2;
|
padding: $unit-3 $unit-2;
|
||||||
display: table-cell;
|
display: table-cell;
|
||||||
|
border-radius: 3px;
|
||||||
}
|
}
|
||||||
|
|
||||||
.th {
|
.th {
|
||||||
|
@@ -17,7 +17,7 @@
|
|||||||
&.key-mul,
|
&.key-mul,
|
||||||
&.key-INDEX,
|
&.key-INDEX,
|
||||||
&.key-KEY {
|
&.key-KEY {
|
||||||
color: palegreen;
|
color: limegreen;
|
||||||
}
|
}
|
||||||
|
|
||||||
&.key-FULLTEXT {
|
&.key-FULLTEXT {
|
||||||
|
@@ -15,6 +15,15 @@ body {
|
|||||||
user-select: none;
|
user-select: none;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
::selection,
|
||||||
|
option:hover,
|
||||||
|
option:focus,
|
||||||
|
option:active,
|
||||||
|
option:checked {
|
||||||
|
background-color: $primary-color;
|
||||||
|
color: $light-color;
|
||||||
|
}
|
||||||
|
|
||||||
/* Additions */
|
/* Additions */
|
||||||
@include margin-variant(3, $unit-3);
|
@include margin-variant(3, $unit-3);
|
||||||
@include margin-variant(4, $unit-4);
|
@include margin-variant(4, $unit-4);
|
||||||
@@ -200,7 +209,7 @@ body {
|
|||||||
cursor: pointer;
|
cursor: pointer;
|
||||||
|
|
||||||
&.small-select {
|
&.small-select {
|
||||||
height: 1rem;
|
height: 21px;
|
||||||
font-size: 0.7rem;
|
font-size: 0.7rem;
|
||||||
padding: 1px 0.4rem 0;
|
padding: 1px 0.4rem 0;
|
||||||
}
|
}
|
||||||
|
@@ -20,6 +20,11 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
option,
|
||||||
|
optgroup {
|
||||||
|
background-color: $bg-color-gray;
|
||||||
|
}
|
||||||
|
|
||||||
// Override Spectre.css
|
// Override Spectre.css
|
||||||
.menu {
|
.menu {
|
||||||
background: $bg-color-light-dark;
|
background: $bg-color-light-dark;
|
||||||
@@ -179,16 +184,29 @@
|
|||||||
.workspace-query-results {
|
.workspace-query-results {
|
||||||
.table {
|
.table {
|
||||||
.th {
|
.th {
|
||||||
background: $bg-color-dark;
|
border-color: darken($bg-color-light-gray, 80%);
|
||||||
border-color: $bg-color-light-dark;
|
background-color: $body-bg-dark;
|
||||||
}
|
}
|
||||||
|
|
||||||
.td {
|
.tr {
|
||||||
border-color: $bg-color-light-dark;
|
background-color: darken($bg-color-light-gray, 80%);
|
||||||
|
|
||||||
&:focus {
|
.td:first-child {
|
||||||
box-shadow: inset 0 0 0 1px $body-font-color-dark;
|
border-left: 2px solid $body-bg-dark;
|
||||||
background: rgba($color: #000, $alpha: 0.3);
|
}
|
||||||
|
|
||||||
|
.td {
|
||||||
|
border-color: $body-bg-dark;
|
||||||
|
|
||||||
|
&:focus {
|
||||||
|
box-shadow: inset 0 0 0 2px darken($body-font-color-dark, 40%);
|
||||||
|
background-color: rgba($color: #000, $alpha: 0.3);
|
||||||
|
}
|
||||||
|
|
||||||
|
.editable-field {
|
||||||
|
box-shadow: inset 0 0 0 2px darken($body-font-color-dark, 40%);
|
||||||
|
background-color: rgba($color: #000, $alpha: 0.3);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -216,11 +216,29 @@
|
|||||||
.table {
|
.table {
|
||||||
.th {
|
.th {
|
||||||
background: $body-bg;
|
background: $body-bg;
|
||||||
border-color: rgba($bg-color-light-dark, 0.5);
|
border-color: lighten($bg-color-light-gray, 2%);
|
||||||
}
|
}
|
||||||
|
|
||||||
.td {
|
.tr {
|
||||||
border-color: rgba($bg-color-light-dark, 0.5);
|
background-color: lighten($bg-color-light-gray, 2%);
|
||||||
|
|
||||||
|
.td:first-child {
|
||||||
|
border-left: 2px solid $body-bg;
|
||||||
|
}
|
||||||
|
|
||||||
|
.td {
|
||||||
|
border-color: $body-bg;
|
||||||
|
|
||||||
|
&:focus {
|
||||||
|
box-shadow: inset 0 0 0 2px lighten($body-font-color, 10%);
|
||||||
|
background-color: $body-font-color-dark;
|
||||||
|
}
|
||||||
|
|
||||||
|
.editable-field {
|
||||||
|
box-shadow: inset 0 0 0 2px lighten($body-font-color, 10%);
|
||||||
|
background-color: $body-font-color-dark;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -581,70 +581,25 @@ export default {
|
|||||||
const workspaceTabs = state.workspaces.find(workspace => workspace.uid === uid);
|
const workspaceTabs = state.workspaces.find(workspace => workspace.uid === uid);
|
||||||
|
|
||||||
switch (type) {
|
switch (type) {
|
||||||
case 'temp-data': {
|
case 'new-table':
|
||||||
const existentTab = workspaceTabs
|
case 'new-trigger':
|
||||||
? workspaceTabs.tabs.find(tab =>
|
case 'new-trigger-function':
|
||||||
tab.schema === schema &&
|
case 'new-function':
|
||||||
tab.elementName === elementName &&
|
case 'new-routine':
|
||||||
tab.elementType === elementType &&
|
case 'new-scheduler':
|
||||||
['temp-data', 'data'].includes(tab.type))
|
tabUid = uidGen('T');
|
||||||
: false;
|
commit('NEW_TAB', {
|
||||||
|
uid,
|
||||||
if (existentTab) { // if data tab exists
|
tab: tabUid,
|
||||||
tabUid = existentTab.uid;
|
content,
|
||||||
}
|
type,
|
||||||
else {
|
autorun,
|
||||||
const tempTabs = workspaceTabs ? workspaceTabs.tabs.filter(tab => tab.type === 'temp-data') : false;
|
schema,
|
||||||
if (tempTabs && tempTabs.length) { // if temp table already opened
|
elementName,
|
||||||
for (const tab of tempTabs) {
|
elementType
|
||||||
commit('REPLACE_TAB', { uid, tab: tab.uid, type, schema, elementName, elementType });
|
});
|
||||||
tabUid = tab.uid;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
tabUid = uidGen('T');
|
|
||||||
commit('NEW_TAB', { uid, tab: tabUid, content, type, autorun, schema, elementName, elementType });
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case 'data': {
|
|
||||||
const existentTab = workspaceTabs
|
|
||||||
? workspaceTabs.tabs.find(tab =>
|
|
||||||
tab.schema === schema &&
|
|
||||||
tab.elementName === elementName &&
|
|
||||||
tab.elementType === elementType &&
|
|
||||||
['temp-data', 'data'].includes(tab.type))
|
|
||||||
: false;
|
|
||||||
|
|
||||||
if (existentTab) {
|
|
||||||
commit('REPLACE_TAB', { uid, tab: existentTab.uid, type, schema, elementName, elementType });
|
|
||||||
tabUid = existentTab.uid;
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
tabUid = uidGen('T');
|
|
||||||
commit('NEW_TAB', { uid, tab: tabUid, content, type, autorun, schema, elementName, elementType });
|
|
||||||
}
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case 'table-props': {
|
|
||||||
const existentTab = workspaceTabs
|
|
||||||
? workspaceTabs.tabs.find(tab =>
|
|
||||||
tab.elementName === elementName &&
|
|
||||||
tab.elementType === elementType &&
|
|
||||||
tab.type === type)
|
|
||||||
: false;
|
|
||||||
|
|
||||||
if (existentTab) {
|
|
||||||
commit('REPLACE_TAB', { uid, tab: existentTab.uid, type, schema, elementName, elementType });
|
|
||||||
tabUid = existentTab.uid;
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
tabUid = uidGen('T');
|
|
||||||
commit('NEW_TAB', { uid, tab: tabUid, content, type, autorun, schema, elementName, elementType });
|
|
||||||
}
|
|
||||||
}
|
|
||||||
break;
|
break;
|
||||||
|
case 'temp-data':
|
||||||
case 'temp-trigger-props':
|
case 'temp-trigger-props':
|
||||||
case 'temp-trigger-function-props':
|
case 'temp-trigger-function-props':
|
||||||
case 'temp-function-props':
|
case 'temp-function-props':
|
||||||
@@ -663,6 +618,7 @@ export default {
|
|||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
const tempTabs = workspaceTabs ? workspaceTabs.tabs.filter(tab => tab.type.includes('temp-')) : false;
|
const tempTabs = workspaceTabs ? workspaceTabs.tabs.filter(tab => tab.type.includes('temp-')) : false;
|
||||||
|
|
||||||
if (tempTabs && tempTabs.length) { // if temp tab already opened
|
if (tempTabs && tempTabs.length) { // if temp tab already opened
|
||||||
for (const tab of tempTabs) {
|
for (const tab of tempTabs) {
|
||||||
if (tab.isChanged) {
|
if (tab.isChanged) {
|
||||||
@@ -691,6 +647,8 @@ export default {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
case 'data':
|
||||||
|
case 'table-props':
|
||||||
case 'trigger-props':
|
case 'trigger-props':
|
||||||
case 'trigger-function-props':
|
case 'trigger-function-props':
|
||||||
case 'function-props':
|
case 'function-props':
|
||||||
|
Reference in New Issue
Block a user