mirror of
https://github.com/Fabio286/antares.git
synced 2025-06-05 21:59:22 +02:00
refactor: passing schema from table context options
This commit is contained in:
@ -1280,7 +1280,7 @@ export class MySQLClient extends AntaresCore {
|
|||||||
* @memberof MySQLClient
|
* @memberof MySQLClient
|
||||||
*/
|
*/
|
||||||
async duplicateTable (params) {
|
async duplicateTable (params) {
|
||||||
const sql = `CREATE TABLE \`${this._schema}\`.\`${params.table}_copy\` LIKE \`${this._schema}\`.\`${params.table}\``;
|
const sql = `CREATE TABLE \`${params.schema}\`.\`${params.table}_copy\` LIKE \`${params.schema}\`.\`${params.table}\``;
|
||||||
return await this.raw(sql);
|
return await this.raw(sql);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1291,7 +1291,7 @@ export class MySQLClient extends AntaresCore {
|
|||||||
* @memberof MySQLClient
|
* @memberof MySQLClient
|
||||||
*/
|
*/
|
||||||
async truncateTable (params) {
|
async truncateTable (params) {
|
||||||
const sql = `TRUNCATE TABLE \`${this._schema}\`.\`${params.table}\``;
|
const sql = `TRUNCATE TABLE \`${params.schema}\`.\`${params.table}\``;
|
||||||
return await this.raw(sql);
|
return await this.raw(sql);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1302,7 +1302,7 @@ export class MySQLClient extends AntaresCore {
|
|||||||
* @memberof MySQLClient
|
* @memberof MySQLClient
|
||||||
*/
|
*/
|
||||||
async dropTable (params) {
|
async dropTable (params) {
|
||||||
const sql = `DROP TABLE \`${this._schema}\`.\`${params.table}\``;
|
const sql = `DROP TABLE \`${params.schema}\`.\`${params.table}\``;
|
||||||
return await this.raw(sql);
|
return await this.raw(sql);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1157,7 +1157,7 @@ export class PostgreSQLClient extends AntaresCore {
|
|||||||
* @memberof PostgreSQLClient
|
* @memberof PostgreSQLClient
|
||||||
*/
|
*/
|
||||||
async duplicateTable (params) {
|
async duplicateTable (params) {
|
||||||
const sql = `CREATE TABLE ${this._schema}.${params.table}_copy (LIKE ${this._schema}.${params.table} INCLUDING ALL)`;
|
const sql = `CREATE TABLE ${params.schema}.${params.table}_copy (LIKE ${params.schema}.${params.table} INCLUDING ALL)`;
|
||||||
return await this.raw(sql);
|
return await this.raw(sql);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1168,7 +1168,7 @@ export class PostgreSQLClient extends AntaresCore {
|
|||||||
* @memberof PostgreSQLClient
|
* @memberof PostgreSQLClient
|
||||||
*/
|
*/
|
||||||
async truncateTable (params) {
|
async truncateTable (params) {
|
||||||
const sql = `TRUNCATE TABLE ${this._schema}.${params.table}`;
|
const sql = `TRUNCATE TABLE ${params.schema}.${params.table}`;
|
||||||
return await this.raw(sql);
|
return await this.raw(sql);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1179,7 +1179,7 @@ export class PostgreSQLClient extends AntaresCore {
|
|||||||
* @memberof PostgreSQLClient
|
* @memberof PostgreSQLClient
|
||||||
*/
|
*/
|
||||||
async dropTable (params) {
|
async dropTable (params) {
|
||||||
const sql = `DROP TABLE ${this._schema}.${params.table}`;
|
const sql = `DROP TABLE ${params.schema}.${params.table}`;
|
||||||
return await this.raw(sql);
|
return await this.raw(sql);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -72,7 +72,7 @@ import Schema from '@/ipc-api/Schema';
|
|||||||
export default {
|
export default {
|
||||||
name: 'ModalEditSchema',
|
name: 'ModalEditSchema',
|
||||||
props: {
|
props: {
|
||||||
selectedDatabase: String
|
selectedSchema: String
|
||||||
},
|
},
|
||||||
data () {
|
data () {
|
||||||
return {
|
return {
|
||||||
@ -99,7 +99,7 @@ export default {
|
|||||||
async created () {
|
async created () {
|
||||||
let actualCollation;
|
let actualCollation;
|
||||||
try {
|
try {
|
||||||
const { status, response } = await Schema.getDatabaseCollation({ uid: this.selectedWorkspace, database: this.selectedDatabase });
|
const { status, response } = await Schema.getDatabaseCollation({ uid: this.selectedWorkspace, database: this.selectedSchema });
|
||||||
|
|
||||||
if (status === 'success')
|
if (status === 'success')
|
||||||
actualCollation = response;
|
actualCollation = response;
|
||||||
@ -112,8 +112,8 @@ export default {
|
|||||||
}
|
}
|
||||||
|
|
||||||
this.database = {
|
this.database = {
|
||||||
name: this.selectedDatabase,
|
name: this.selectedSchema,
|
||||||
prevName: this.selectedDatabase,
|
prevName: this.selectedSchema,
|
||||||
collation: actualCollation || this.defaultCollation,
|
collation: actualCollation || this.defaultCollation,
|
||||||
prevCollation: actualCollation || this.defaultCollation
|
prevCollation: actualCollation || this.defaultCollation
|
||||||
};
|
};
|
||||||
|
@ -100,7 +100,7 @@
|
|||||||
/>
|
/>
|
||||||
<DatabaseContext
|
<DatabaseContext
|
||||||
v-if="isDatabaseContext"
|
v-if="isDatabaseContext"
|
||||||
:selected-database="selectedDatabase"
|
:selected-schema="selectedSchema"
|
||||||
:context-event="databaseContextEvent"
|
:context-event="databaseContextEvent"
|
||||||
@close-context="closeDatabaseContext"
|
@close-context="closeDatabaseContext"
|
||||||
@show-create-table-modal="showCreateTableModal"
|
@show-create-table-modal="showCreateTableModal"
|
||||||
@ -114,6 +114,7 @@
|
|||||||
/>
|
/>
|
||||||
<TableContext
|
<TableContext
|
||||||
v-if="isTableContext"
|
v-if="isTableContext"
|
||||||
|
:selected-schema="selectedSchema"
|
||||||
:selected-table="selectedTable"
|
:selected-table="selectedTable"
|
||||||
:context-event="tableContextEvent"
|
:context-event="tableContextEvent"
|
||||||
@close-context="closeTableContext"
|
@close-context="closeTableContext"
|
||||||
@ -211,7 +212,7 @@ export default {
|
|||||||
tableContextEvent: null,
|
tableContextEvent: null,
|
||||||
miscContextEvent: null,
|
miscContextEvent: null,
|
||||||
|
|
||||||
selectedDatabase: '',
|
selectedSchema: '',
|
||||||
selectedTable: null,
|
selectedTable: null,
|
||||||
selectedMisc: null,
|
selectedMisc: null,
|
||||||
searchTerm: ''
|
searchTerm: ''
|
||||||
@ -315,14 +316,14 @@ export default {
|
|||||||
|
|
||||||
if (status === 'success') {
|
if (status === 'success') {
|
||||||
await this.refresh();
|
await this.refresh();
|
||||||
this.changeBreadcrumbs({ schema: this.selectedDatabase, table: payload.name });
|
this.changeBreadcrumbs({ schema: this.selectedSchema, table: payload.name });
|
||||||
this.selectTab({ uid: this.workspace.uid, tab: 'prop' });
|
this.selectTab({ uid: this.workspace.uid, tab: 'prop' });
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
this.addNotification({ status: 'error', message: response });
|
this.addNotification({ status: 'error', message: response });
|
||||||
},
|
},
|
||||||
openSchemaContext (payload) {
|
openSchemaContext (payload) {
|
||||||
this.selectedDatabase = payload.schema;
|
this.selectedSchema = payload.schema;
|
||||||
this.databaseContextEvent = payload.event;
|
this.databaseContextEvent = payload.event;
|
||||||
this.isDatabaseContext = true;
|
this.isDatabaseContext = true;
|
||||||
},
|
},
|
||||||
@ -331,6 +332,7 @@ export default {
|
|||||||
},
|
},
|
||||||
openTableContext (payload) {
|
openTableContext (payload) {
|
||||||
this.selectedTable = payload.table;
|
this.selectedTable = payload.table;
|
||||||
|
this.selectedSchema = payload.schema;
|
||||||
this.tableContextEvent = payload.event;
|
this.tableContextEvent = payload.event;
|
||||||
this.isTableContext = true;
|
this.isTableContext = true;
|
||||||
},
|
},
|
||||||
@ -371,7 +373,7 @@ export default {
|
|||||||
|
|
||||||
if (status === 'success') {
|
if (status === 'success') {
|
||||||
await this.refresh();
|
await this.refresh();
|
||||||
this.changeBreadcrumbs({ schema: this.selectedDatabase, view: payload.name });
|
this.changeBreadcrumbs({ schema: this.selectedSchema, view: payload.name });
|
||||||
this.selectTab({ uid: this.workspace.uid, tab: 'prop' });
|
this.selectTab({ uid: this.workspace.uid, tab: 'prop' });
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@ -396,7 +398,7 @@ export default {
|
|||||||
if (status === 'success') {
|
if (status === 'success') {
|
||||||
await this.refresh();
|
await this.refresh();
|
||||||
const triggerName = this.customizations.triggerTableInName ? `${payload.table}.${payload.name}` : payload.name;
|
const triggerName = this.customizations.triggerTableInName ? `${payload.table}.${payload.name}` : payload.name;
|
||||||
this.changeBreadcrumbs({ schema: this.selectedDatabase, trigger: triggerName });
|
this.changeBreadcrumbs({ schema: this.selectedSchema, trigger: triggerName });
|
||||||
this.selectTab({ uid: this.workspace.uid, tab: 'prop' });
|
this.selectTab({ uid: this.workspace.uid, tab: 'prop' });
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@ -420,7 +422,7 @@ export default {
|
|||||||
|
|
||||||
if (status === 'success') {
|
if (status === 'success') {
|
||||||
await this.refresh();
|
await this.refresh();
|
||||||
this.changeBreadcrumbs({ schema: this.selectedDatabase, procedure: payload.name });
|
this.changeBreadcrumbs({ schema: this.selectedSchema, procedure: payload.name });
|
||||||
this.selectTab({ uid: this.workspace.uid, tab: 'prop' });
|
this.selectTab({ uid: this.workspace.uid, tab: 'prop' });
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@ -460,7 +462,7 @@ export default {
|
|||||||
|
|
||||||
if (status === 'success') {
|
if (status === 'success') {
|
||||||
await this.refresh();
|
await this.refresh();
|
||||||
this.changeBreadcrumbs({ schema: this.selectedDatabase, function: payload.name });
|
this.changeBreadcrumbs({ schema: this.selectedSchema, function: payload.name });
|
||||||
this.selectTab({ uid: this.workspace.uid, tab: 'prop' });
|
this.selectTab({ uid: this.workspace.uid, tab: 'prop' });
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@ -476,7 +478,7 @@ export default {
|
|||||||
|
|
||||||
if (status === 'success') {
|
if (status === 'success') {
|
||||||
await this.refresh();
|
await this.refresh();
|
||||||
this.changeBreadcrumbs({ schema: this.selectedDatabase, triggerFunction: payload.name });
|
this.changeBreadcrumbs({ schema: this.selectedSchema, triggerFunction: payload.name });
|
||||||
this.selectTab({ uid: this.workspace.uid, tab: 'prop' });
|
this.selectTab({ uid: this.workspace.uid, tab: 'prop' });
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@ -492,7 +494,7 @@ export default {
|
|||||||
|
|
||||||
if (status === 'success') {
|
if (status === 'success') {
|
||||||
await this.refresh();
|
await this.refresh();
|
||||||
this.changeBreadcrumbs({ schema: this.selectedDatabase, scheduler: payload.name });
|
this.changeBreadcrumbs({ schema: this.selectedSchema, scheduler: payload.name });
|
||||||
this.selectTab({ uid: this.workspace.uid, tab: 'prop' });
|
this.selectTab({ uid: this.workspace.uid, tab: 'prop' });
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@ -295,7 +295,7 @@ export default {
|
|||||||
},
|
},
|
||||||
showTableContext (event, table) {
|
showTableContext (event, table) {
|
||||||
// this.setBreadcrumbs({ schema: this.database.name, [table.type]: table.name });
|
// this.setBreadcrumbs({ schema: this.database.name, [table.type]: table.name });
|
||||||
this.$emit('show-table-context', { event, table });
|
this.$emit('show-table-context', { event, schema: this.database.name, table });
|
||||||
},
|
},
|
||||||
showMiscContext (event, misc) {
|
showMiscContext (event, misc) {
|
||||||
this.setBreadcrumbs({ schema: this.database.name, [misc.type]: misc.name });
|
this.setBreadcrumbs({ schema: this.database.name, [misc.type]: misc.name });
|
||||||
|
@ -82,13 +82,13 @@
|
|||||||
</template>
|
</template>
|
||||||
<div slot="body">
|
<div slot="body">
|
||||||
<div class="mb-2">
|
<div class="mb-2">
|
||||||
{{ $t('message.deleteCorfirm') }} "<b>{{ selectedDatabase }}</b>"?
|
{{ $t('message.deleteCorfirm') }} "<b>{{ selectedSchema }}</b>"?
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</ConfirmModal>
|
</ConfirmModal>
|
||||||
<ModalEditSchema
|
<ModalEditSchema
|
||||||
v-if="isEditModal"
|
v-if="isEditModal"
|
||||||
:selected-database="selectedDatabase"
|
:selected-schema="selectedSchema"
|
||||||
@close="hideEditModal"
|
@close="hideEditModal"
|
||||||
/>
|
/>
|
||||||
</BaseContextMenu>
|
</BaseContextMenu>
|
||||||
@ -110,7 +110,7 @@ export default {
|
|||||||
},
|
},
|
||||||
props: {
|
props: {
|
||||||
contextEvent: MouseEvent,
|
contextEvent: MouseEvent,
|
||||||
selectedDatabase: String
|
selectedSchema: String
|
||||||
},
|
},
|
||||||
data () {
|
data () {
|
||||||
return {
|
return {
|
||||||
@ -173,11 +173,11 @@ export default {
|
|||||||
try {
|
try {
|
||||||
const { status, response } = await Schema.deleteSchema({
|
const { status, response } = await Schema.deleteSchema({
|
||||||
uid: this.selectedWorkspace,
|
uid: this.selectedWorkspace,
|
||||||
database: this.selectedDatabase
|
database: this.selectedSchema
|
||||||
});
|
});
|
||||||
|
|
||||||
if (status === 'success') {
|
if (status === 'success') {
|
||||||
if (this.selectedDatabase === this.workspace.breadcrumbs.schema)
|
if (this.selectedSchema === this.workspace.breadcrumbs.schema)
|
||||||
this.changeBreadcrumbs({ schema: null });
|
this.changeBreadcrumbs({ schema: null });
|
||||||
|
|
||||||
this.closeContext();
|
this.closeContext();
|
||||||
|
@ -72,7 +72,8 @@ export default {
|
|||||||
},
|
},
|
||||||
props: {
|
props: {
|
||||||
contextEvent: MouseEvent,
|
contextEvent: MouseEvent,
|
||||||
selectedTable: Object
|
selectedTable: Object,
|
||||||
|
selectedSchema: String
|
||||||
},
|
},
|
||||||
data () {
|
data () {
|
||||||
return {
|
return {
|
||||||
@ -116,7 +117,8 @@ export default {
|
|||||||
try {
|
try {
|
||||||
const { status, response } = await Tables.duplicateTable({
|
const { status, response } = await Tables.duplicateTable({
|
||||||
uid: this.selectedWorkspace,
|
uid: this.selectedWorkspace,
|
||||||
table: this.selectedTable.name
|
table: this.selectedTable.name,
|
||||||
|
schema: this.selectedSchema
|
||||||
});
|
});
|
||||||
|
|
||||||
if (status === 'success') {
|
if (status === 'success') {
|
||||||
@ -134,7 +136,8 @@ export default {
|
|||||||
try {
|
try {
|
||||||
const { status, response } = await Tables.truncateTable({
|
const { status, response } = await Tables.truncateTable({
|
||||||
uid: this.selectedWorkspace,
|
uid: this.selectedWorkspace,
|
||||||
table: this.selectedTable.name
|
table: this.selectedTable.name,
|
||||||
|
schema: this.selectedSchema
|
||||||
});
|
});
|
||||||
|
|
||||||
if (status === 'success') {
|
if (status === 'success') {
|
||||||
@ -155,13 +158,15 @@ export default {
|
|||||||
if (this.selectedTable.type === 'table') {
|
if (this.selectedTable.type === 'table') {
|
||||||
res = await Tables.dropTable({
|
res = await Tables.dropTable({
|
||||||
uid: this.selectedWorkspace,
|
uid: this.selectedWorkspace,
|
||||||
table: this.selectedTable.name
|
table: this.selectedTable.name,
|
||||||
|
schema: this.selectedSchema
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
else if (this.selectedTable.type === 'view') {
|
else if (this.selectedTable.type === 'view') {
|
||||||
res = await Views.dropView({
|
res = await Views.dropView({
|
||||||
uid: this.selectedWorkspace,
|
uid: this.selectedWorkspace,
|
||||||
view: this.selectedTable.name
|
view: this.selectedTable.name,
|
||||||
|
schema: this.selectedSchema
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user