mirror of https://github.com/Fabio286/antares.git
feat: new create table tabs
This commit is contained in:
parent
4048df3c7b
commit
c9fa941578
|
@ -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':
|
||||||
|
|
|
@ -1181,7 +1181,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
|
||||||
|
@ -1036,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);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1068,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);
|
||||||
|
@ -1084,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}` : ''}`);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -1106,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
|
||||||
|
@ -1163,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
|
||||||
|
|
|
@ -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>
|
||||||
|
|
|
@ -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"
|
||||||
|
@ -202,6 +219,15 @@
|
||||||
:schema="tab.schema"
|
:schema="tab.schema"
|
||||||
:element-type="tab.elementType"
|
:element-type="tab.elementType"
|
||||||
/>
|
/>
|
||||||
|
<WorkspaceTabNewTable
|
||||||
|
v-else-if="tab.type === 'new-table'"
|
||||||
|
:key="tab.uid"
|
||||||
|
:tab="tab"
|
||||||
|
:connection="connection"
|
||||||
|
:is-selected="selectedTab === tab.uid"
|
||||||
|
:table="tab.elementName"
|
||||||
|
:schema="tab.schema"
|
||||||
|
/>
|
||||||
<WorkspaceTabPropsTable
|
<WorkspaceTabPropsTable
|
||||||
v-else-if="tab.type === 'table-props'"
|
v-else-if="tab.type === 'table-props'"
|
||||||
:key="tab.uid"
|
:key="tab.uid"
|
||||||
|
@ -284,6 +310,9 @@ import WorkspaceExploreBar from '@/components/WorkspaceExploreBar';
|
||||||
import WorkspaceEditConnectionPanel from '@/components/WorkspaceEditConnectionPanel';
|
import WorkspaceEditConnectionPanel from '@/components/WorkspaceEditConnectionPanel';
|
||||||
import WorkspaceTabQuery from '@/components/WorkspaceTabQuery';
|
import WorkspaceTabQuery from '@/components/WorkspaceTabQuery';
|
||||||
import WorkspaceTabTable from '@/components/WorkspaceTabTable';
|
import WorkspaceTabTable from '@/components/WorkspaceTabTable';
|
||||||
|
|
||||||
|
import WorkspaceTabNewTable from '@/components/WorkspaceTabNewTable';
|
||||||
|
|
||||||
import WorkspaceTabPropsTable from '@/components/WorkspaceTabPropsTable';
|
import WorkspaceTabPropsTable from '@/components/WorkspaceTabPropsTable';
|
||||||
import WorkspaceTabPropsView from '@/components/WorkspaceTabPropsView';
|
import WorkspaceTabPropsView from '@/components/WorkspaceTabPropsView';
|
||||||
import WorkspaceTabPropsTrigger from '@/components/WorkspaceTabPropsTrigger';
|
import WorkspaceTabPropsTrigger from '@/components/WorkspaceTabPropsTrigger';
|
||||||
|
@ -303,6 +332,7 @@ export default {
|
||||||
WorkspaceEditConnectionPanel,
|
WorkspaceEditConnectionPanel,
|
||||||
WorkspaceTabQuery,
|
WorkspaceTabQuery,
|
||||||
WorkspaceTabTable,
|
WorkspaceTabTable,
|
||||||
|
WorkspaceTabNewTable,
|
||||||
WorkspaceTabPropsTable,
|
WorkspaceTabPropsTable,
|
||||||
WorkspaceTabPropsView,
|
WorkspaceTabPropsView,
|
||||||
WorkspaceTabPropsTrigger,
|
WorkspaceTabPropsTrigger,
|
||||||
|
|
|
@ -61,12 +61,6 @@
|
||||||
@close="hideNewDBModal"
|
@close="hideNewDBModal"
|
||||||
@reload="refresh"
|
@reload="refresh"
|
||||||
/>
|
/>
|
||||||
<ModalNewTable
|
|
||||||
v-if="isNewTableModal"
|
|
||||||
:workspace="workspace"
|
|
||||||
@close="hideCreateTableModal"
|
|
||||||
@open-create-table-editor="openCreateTableEditor"
|
|
||||||
/>
|
|
||||||
<ModalNewView
|
<ModalNewView
|
||||||
v-if="isNewViewModal"
|
v-if="isNewViewModal"
|
||||||
:workspace="workspace"
|
:workspace="workspace"
|
||||||
|
@ -108,7 +102,7 @@
|
||||||
: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="openCreateTableTab"
|
||||||
@show-create-view-modal="showCreateViewModal"
|
@show-create-view-modal="showCreateViewModal"
|
||||||
@show-create-trigger-modal="showCreateTriggerModal"
|
@show-create-trigger-modal="showCreateTriggerModal"
|
||||||
@show-create-routine-modal="showCreateRoutineModal"
|
@show-create-routine-modal="showCreateRoutineModal"
|
||||||
|
@ -165,7 +159,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 ModalNewView from '@/components/ModalNewView';
|
||||||
import ModalNewTrigger from '@/components/ModalNewTrigger';
|
import ModalNewTrigger from '@/components/ModalNewTrigger';
|
||||||
import ModalNewRoutine from '@/components/ModalNewRoutine';
|
import ModalNewRoutine from '@/components/ModalNewRoutine';
|
||||||
|
@ -182,7 +175,6 @@ export default {
|
||||||
MiscContext,
|
MiscContext,
|
||||||
MiscFolderContext,
|
MiscFolderContext,
|
||||||
ModalNewSchema,
|
ModalNewSchema,
|
||||||
ModalNewTable,
|
|
||||||
ModalNewView,
|
ModalNewView,
|
||||||
ModalNewTrigger,
|
ModalNewTrigger,
|
||||||
ModalNewRoutine,
|
ModalNewRoutine,
|
||||||
|
@ -199,7 +191,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,
|
||||||
|
@ -307,9 +298,16 @@ export default {
|
||||||
hideNewDBModal () {
|
hideNewDBModal () {
|
||||||
this.isNewDBModal = false;
|
this.isNewDBModal = false;
|
||||||
},
|
},
|
||||||
showCreateTableModal () {
|
openCreateTableTab () {
|
||||||
this.closeDatabaseContext();
|
this.closeDatabaseContext();
|
||||||
this.isNewTableModal = true;
|
|
||||||
|
this.newTab({
|
||||||
|
uid: this.workspace.uid,
|
||||||
|
schema: this.selectedSchema,
|
||||||
|
elementName: '',
|
||||||
|
elementType: 'table',
|
||||||
|
type: 'new-table'
|
||||||
|
});
|
||||||
},
|
},
|
||||||
hideCreateTableModal () {
|
hideCreateTableModal () {
|
||||||
this.isNewTableModal = false;
|
this.isNewTableModal = false;
|
||||||
|
|
|
@ -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;
|
||||||
},
|
},
|
||||||
|
|
|
@ -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;
|
||||||
},
|
},
|
||||||
|
|
|
@ -10,7 +10,7 @@
|
||||||
<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>
|
||||||
|
@ -132,8 +132,8 @@ 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 () {
|
showCreateViewModal () {
|
||||||
this.$emit('show-create-view-modal');
|
this.$emit('show-create-view-modal');
|
||||||
|
|
|
@ -116,9 +116,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;
|
||||||
},
|
},
|
||||||
|
|
|
@ -0,0 +1,458 @@
|
||||||
|
<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" />
|
||||||
|
<WorkspaceTabPropsTableFIelds
|
||||||
|
v-if="localFields"
|
||||||
|
ref="indexTable"
|
||||||
|
:fields="localFields"
|
||||||
|
:indexes="localIndexes"
|
||||||
|
:foreigns="localKeyUsage"
|
||||||
|
:tab-uid="tabUid"
|
||||||
|
:conn-uid="connection.uid"
|
||||||
|
:index-types="workspace.indexTypes"
|
||||||
|
:table="table"
|
||||||
|
: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="table"
|
||||||
|
: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';
|
||||||
|
|
||||||
|
export default {
|
||||||
|
name: 'WorkspaceTabNewTable',
|
||||||
|
components: {
|
||||||
|
BaseLoader,
|
||||||
|
WorkspaceTabPropsTableFIelds,
|
||||||
|
WorkspaceTabPropsTableIndexesModal,
|
||||||
|
WorkspaceTabPropsTableForeignModal
|
||||||
|
},
|
||||||
|
props: {
|
||||||
|
connection: Object,
|
||||||
|
tab: Object,
|
||||||
|
isSelected: Boolean,
|
||||||
|
table: String,
|
||||||
|
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: {
|
||||||
|
schema () {
|
||||||
|
if (this.isSelected)
|
||||||
|
this.lastTable = this.table;
|
||||||
|
},
|
||||||
|
table () {
|
||||||
|
if (this.isSelected)
|
||||||
|
this.lastTable = this.table;
|
||||||
|
},
|
||||||
|
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 });
|
||||||
|
}
|
||||||
|
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,
|
||||||
|
table: this.table,
|
||||||
|
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>
|
|
@ -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')">
|
||||||
|
@ -207,13 +203,6 @@
|
||||||
:height="editorHeight"
|
:height="editorHeight"
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
<!-- <WorkspaceTabPropsFunctionOptionsModal
|
|
||||||
v-if="isOptionsModal"
|
|
||||||
:local-options="localFunction"
|
|
||||||
:workspace="workspace"
|
|
||||||
@hide="hideOptionsModal"
|
|
||||||
@options-update="optionsUpdate"
|
|
||||||
/> -->
|
|
||||||
<WorkspaceTabPropsFunctionParamsModal
|
<WorkspaceTabPropsFunctionParamsModal
|
||||||
v-if="isParamsModal"
|
v-if="isParamsModal"
|
||||||
:local-parameters="localFunction.parameters"
|
:local-parameters="localFunction.parameters"
|
||||||
|
@ -237,7 +226,6 @@ 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 WorkspaceTabPropsFunctionOptionsModal from '@/components/WorkspaceTabPropsFunctionOptionsModal';
|
|
||||||
import WorkspaceTabPropsFunctionParamsModal from '@/components/WorkspaceTabPropsFunctionParamsModal';
|
import WorkspaceTabPropsFunctionParamsModal from '@/components/WorkspaceTabPropsFunctionParamsModal';
|
||||||
import ModalAskParameters from '@/components/ModalAskParameters';
|
import ModalAskParameters from '@/components/ModalAskParameters';
|
||||||
import Functions from '@/ipc-api/Functions';
|
import Functions from '@/ipc-api/Functions';
|
||||||
|
@ -247,7 +235,6 @@ export default {
|
||||||
components: {
|
components: {
|
||||||
BaseLoader,
|
BaseLoader,
|
||||||
QueryEditor,
|
QueryEditor,
|
||||||
// WorkspaceTabPropsFunctionOptionsModal,
|
|
||||||
WorkspaceTabPropsFunctionParamsModal,
|
WorkspaceTabPropsFunctionParamsModal,
|
||||||
ModalAskParameters
|
ModalAskParameters
|
||||||
},
|
},
|
||||||
|
@ -261,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,
|
||||||
|
@ -492,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;
|
||||||
},
|
},
|
||||||
|
|
|
@ -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')">
|
||||||
|
@ -164,13 +160,6 @@
|
||||||
:height="editorHeight"
|
:height="editorHeight"
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
<!-- <WorkspaceTabPropsRoutineOptionsModal
|
|
||||||
v-if="isOptionsModal"
|
|
||||||
:local-options="localRoutine"
|
|
||||||
:workspace="workspace"
|
|
||||||
@hide="hideOptionsModal"
|
|
||||||
@options-update="optionsUpdate"
|
|
||||||
/> -->
|
|
||||||
<WorkspaceTabPropsRoutineParamsModal
|
<WorkspaceTabPropsRoutineParamsModal
|
||||||
v-if="isParamsModal"
|
v-if="isParamsModal"
|
||||||
:local-parameters="localRoutine.parameters"
|
:local-parameters="localRoutine.parameters"
|
||||||
|
@ -194,7 +183,6 @@ 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 WorkspaceTabPropsRoutineOptionsModal from '@/components/WorkspaceTabPropsRoutineOptionsModal';
|
|
||||||
import WorkspaceTabPropsRoutineParamsModal from '@/components/WorkspaceTabPropsRoutineParamsModal';
|
import WorkspaceTabPropsRoutineParamsModal from '@/components/WorkspaceTabPropsRoutineParamsModal';
|
||||||
import ModalAskParameters from '@/components/ModalAskParameters';
|
import ModalAskParameters from '@/components/ModalAskParameters';
|
||||||
import Routines from '@/ipc-api/Routines';
|
import Routines from '@/ipc-api/Routines';
|
||||||
|
@ -204,7 +192,6 @@ export default {
|
||||||
components: {
|
components: {
|
||||||
QueryEditor,
|
QueryEditor,
|
||||||
BaseLoader,
|
BaseLoader,
|
||||||
// WorkspaceTabPropsRoutineOptionsModal,
|
|
||||||
WorkspaceTabPropsRoutineParamsModal,
|
WorkspaceTabPropsRoutineParamsModal,
|
||||||
ModalAskParameters
|
ModalAskParameters
|
||||||
},
|
},
|
||||||
|
@ -218,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,
|
||||||
|
@ -435,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;
|
||||||
},
|
},
|
||||||
|
|
|
@ -51,15 +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
|
|
||||||
v-if="workspace.customizations.tableOptions"
|
|
||||||
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')">
|
||||||
|
@ -160,14 +151,6 @@
|
||||||
@rename-field="renameField"
|
@rename-field="renameField"
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
<!-- <WorkspaceTabPropsTableOptionsModal
|
|
||||||
v-if="isOptionsModal"
|
|
||||||
:local-options="localOptions"
|
|
||||||
:table="table"
|
|
||||||
:workspace="workspace"
|
|
||||||
@hide="hideOptionsModal"
|
|
||||||
@options-update="optionsUpdate"
|
|
||||||
/> -->
|
|
||||||
<WorkspaceTabPropsTableIndexesModal
|
<WorkspaceTabPropsTableIndexesModal
|
||||||
v-if="isIndexesModal"
|
v-if="isIndexesModal"
|
||||||
:local-indexes="localIndexes"
|
:local-indexes="localIndexes"
|
||||||
|
@ -199,7 +182,6 @@ 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 WorkspaceTabPropsTableFIelds from '@/components/WorkspaceTabPropsTableFIelds';
|
import WorkspaceTabPropsTableFIelds from '@/components/WorkspaceTabPropsTableFIelds';
|
||||||
// import WorkspaceTabPropsTableOptionsModal from '@/components/WorkspaceTabPropsTableOptionsModal';
|
|
||||||
import WorkspaceTabPropsTableIndexesModal from '@/components/WorkspaceTabPropsTableIndexesModal';
|
import WorkspaceTabPropsTableIndexesModal from '@/components/WorkspaceTabPropsTableIndexesModal';
|
||||||
import WorkspaceTabPropsTableForeignModal from '@/components/WorkspaceTabPropsTableForeignModal';
|
import WorkspaceTabPropsTableForeignModal from '@/components/WorkspaceTabPropsTableForeignModal';
|
||||||
|
|
||||||
|
@ -208,7 +190,6 @@ export default {
|
||||||
components: {
|
components: {
|
||||||
BaseLoader,
|
BaseLoader,
|
||||||
WorkspaceTabPropsTableFIelds,
|
WorkspaceTabPropsTableFIelds,
|
||||||
// WorkspaceTabPropsTableOptionsModal,
|
|
||||||
WorkspaceTabPropsTableIndexesModal,
|
WorkspaceTabPropsTableIndexesModal,
|
||||||
WorkspaceTabPropsTableForeignModal
|
WorkspaceTabPropsTableForeignModal
|
||||||
},
|
},
|
||||||
|
@ -222,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,
|
||||||
|
@ -649,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;
|
||||||
},
|
},
|
||||||
|
|
|
@ -22,13 +22,6 @@
|
||||||
<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 class="divider-vert py-3" />
|
|
||||||
|
|
||||||
<!-- <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>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
@ -98,13 +91,6 @@
|
||||||
:height="editorHeight"
|
:height="editorHeight"
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
<!-- <WorkspaceTabPropsTriggerFunctionOptionsModal
|
|
||||||
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"
|
||||||
|
@ -120,7 +106,6 @@ 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 WorkspaceTabPropsTriggerFunctionOptionsModal from '@/components/WorkspaceTabPropsTriggerFunctionOptionsModal';
|
|
||||||
import ModalAskParameters from '@/components/ModalAskParameters';
|
import ModalAskParameters from '@/components/ModalAskParameters';
|
||||||
import Functions from '@/ipc-api/Functions';
|
import Functions from '@/ipc-api/Functions';
|
||||||
|
|
||||||
|
@ -129,7 +114,6 @@ export default {
|
||||||
components: {
|
components: {
|
||||||
BaseLoader,
|
BaseLoader,
|
||||||
QueryEditor,
|
QueryEditor,
|
||||||
// WorkspaceTabPropsTriggerFunctionOptionsModal,
|
|
||||||
ModalAskParameters
|
ModalAskParameters
|
||||||
},
|
},
|
||||||
props: {
|
props: {
|
||||||
|
@ -142,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,
|
||||||
|
@ -360,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;
|
||||||
},
|
},
|
||||||
|
|
|
@ -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,8 @@ 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',
|
||||||
|
newTable: 'New table'
|
||||||
},
|
},
|
||||||
faker: {
|
faker: {
|
||||||
address: 'Address',
|
address: 'Address',
|
||||||
|
|
|
@ -581,6 +581,24 @@ 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 'new-table':
|
||||||
|
case 'new-trigger':
|
||||||
|
case 'new-trigger-function':
|
||||||
|
case 'new-function':
|
||||||
|
case 'new-routine':
|
||||||
|
case 'new-scheduler':
|
||||||
|
tabUid = uidGen('T');
|
||||||
|
commit('NEW_TAB', {
|
||||||
|
uid,
|
||||||
|
tab: tabUid,
|
||||||
|
content,
|
||||||
|
type,
|
||||||
|
autorun,
|
||||||
|
schema,
|
||||||
|
elementName,
|
||||||
|
elementType
|
||||||
|
});
|
||||||
|
break;
|
||||||
case 'temp-data':
|
case 'temp-data':
|
||||||
case 'temp-trigger-props':
|
case 'temp-trigger-props':
|
||||||
case 'temp-trigger-function-props':
|
case 'temp-trigger-function-props':
|
||||||
|
|
Loading…
Reference in New Issue