1
1
mirror of https://github.com/Fabio286/antares.git synced 2025-02-13 02:00:36 +01:00

feat: new function, procedure and scheduler tabs

This commit is contained in:
Fabio Di Stasio 2021-07-20 16:59:59 +02:00
parent 58b91ebfe0
commit 0a9983d30d
8 changed files with 234 additions and 118 deletions

View File

@ -363,15 +363,14 @@ export class MySQLClient extends AntaresCore {
const details = fieldArr.slice(2).join(' '); const details = fieldArr.slice(2).join(' ');
let defaultValue = null; let defaultValue = null;
if (details.includes('DEFAULT')) { if (details.includes('DEFAULT'))
defaultValue = details.match(/(?<=DEFAULT ).*?$/gs)[0].split(' COMMENT')[0]; defaultValue = details.match(/(?<=DEFAULT ).*?$/gs)[0].split(' COMMENT')[0];
const defaultValueArr = defaultValue.split(''); // const defaultValueArr = defaultValue.split('');
if (defaultValueArr[0] === '\'') { // if (defaultValueArr[0] === '\'') {
defaultValueArr.shift(); // defaultValueArr.shift();
defaultValueArr.pop(); // defaultValueArr.pop();
defaultValue = defaultValueArr.join(''); // defaultValue = defaultValueArr.join('');
} // }
}
const typeAndLength = nameAndType[1].replace(')', '').split('('); const typeAndLength = nameAndType[1].replace(')', '').split('(');

View File

@ -97,7 +97,7 @@
</a> </a>
<a <a
v-else-if="tab.type === 'temp-trigger-props'" v-else-if="tab.type.includes('temp-')"
class="tab-link" class="tab-link"
:class="{'badge': tab.isChanged}" :class="{'badge': tab.isChanged}"
@dblclick="openAsPermanentTab(tab)" @dblclick="openAsPermanentTab(tab)"
@ -114,7 +114,7 @@
</a> </a>
<a <a
v-else-if="tab.type === 'trigger-props'" v-else
class="tab-link" class="tab-link"
:class="{'badge': tab.isChanged}" :class="{'badge': tab.isChanged}"
> >
@ -129,7 +129,7 @@
</span> </span>
</a> </a>
<a <!-- <a
v-else-if="tab.type === 'temp-trigger-function-props'" v-else-if="tab.type === 'temp-trigger-function-props'"
class="tab-link" class="tab-link"
:class="{'badge': tab.isChanged}" :class="{'badge': tab.isChanged}"
@ -160,7 +160,7 @@
@click.stop="closeTab(tab)" @click.stop="closeTab(tab)"
/> />
</span> </span>
</a> </a> -->
</li> </li>
<li slot="header" class="tab-item dropdown tools-dropdown"> <li slot="header" class="tab-item dropdown tools-dropdown">
<a <a
@ -209,20 +209,7 @@
</a> </a>
</li> </li>
</Draggable> </Draggable>
<!-- <!--<WorkspacePropsTabScheduler
<WorkspacePropsTabRoutine
v-show="selectedTab === 'prop' && workspace.breadcrumbs.procedure"
:is-selected="selectedTab === 'prop'"
:connection="connection"
:routine="workspace.breadcrumbs.procedure"
/>
<WorkspacePropsTabFunction
v-show="selectedTab === 'prop' && workspace.breadcrumbs.function"
:is-selected="selectedTab === 'prop'"
:connection="connection"
:function="workspace.breadcrumbs.function"
/>
<WorkspacePropsTabScheduler
v-show="selectedTab === 'prop' && workspace.breadcrumbs.scheduler" v-show="selectedTab === 'prop' && workspace.breadcrumbs.scheduler"
:is-selected="selectedTab === 'prop'" :is-selected="selectedTab === 'prop'"
:connection="connection" :connection="connection"
@ -278,6 +265,30 @@
:function="tab.elementName" :function="tab.elementName"
:schema="tab.schema" :schema="tab.schema"
/> />
<WorkspacePropsTabRoutine
v-else-if="['temp-routine-props', 'routine-props'].includes(tab.type)"
:key="tab.uid"
:connection="connection"
:is-selected="selectedTab === tab.uid"
:routine="tab.elementName"
:schema="tab.schema"
/>
<WorkspacePropsTabFunction
v-else-if="['temp-function-props', 'function-props'].includes(tab.type)"
:key="tab.uid"
:connection="connection"
:is-selected="selectedTab === tab.uid"
:function="tab.elementName"
:schema="tab.schema"
/>
<WorkspacePropsTabScheduler
v-else-if="['temp-scheduler-props', 'scheduler-props'].includes(tab.type)"
:key="tab.uid"
:connection="connection"
:is-selected="selectedTab === tab.uid"
:scheduler="tab.elementName"
:schema="tab.schema"
/>
</template> </template>
</div> </div>
<WorkspaceEditConnectionPanel v-else :connection="connection" /> <WorkspaceEditConnectionPanel v-else :connection="connection" />
@ -308,9 +319,9 @@ import WorkspacePropsTab from '@/components/WorkspacePropsTab';
import WorkspacePropsTabView from '@/components/WorkspacePropsTabView'; import WorkspacePropsTabView from '@/components/WorkspacePropsTabView';
import WorkspacePropsTabTrigger from '@/components/WorkspacePropsTabTrigger'; import WorkspacePropsTabTrigger from '@/components/WorkspacePropsTabTrigger';
import WorkspacePropsTabTriggerFunction from '@/components/WorkspacePropsTabTriggerFunction'; import WorkspacePropsTabTriggerFunction from '@/components/WorkspacePropsTabTriggerFunction';
// import WorkspacePropsTabRoutine from '@/components/WorkspacePropsTabRoutine'; import WorkspacePropsTabRoutine from '@/components/WorkspacePropsTabRoutine';
// import WorkspacePropsTabFunction from '@/components/WorkspacePropsTabFunction'; import WorkspacePropsTabFunction from '@/components/WorkspacePropsTabFunction';
// import WorkspacePropsTabScheduler from '@/components/WorkspacePropsTabScheduler'; import WorkspacePropsTabScheduler from '@/components/WorkspacePropsTabScheduler';
import ModalProcessesList from '@/components/ModalProcessesList'; import ModalProcessesList from '@/components/ModalProcessesList';
import ModalDiscardChanges from '@/components/ModalDiscardChanges'; import ModalDiscardChanges from '@/components/ModalDiscardChanges';
@ -327,9 +338,9 @@ export default {
WorkspacePropsTabView, WorkspacePropsTabView,
WorkspacePropsTabTrigger, WorkspacePropsTabTrigger,
WorkspacePropsTabTriggerFunction, WorkspacePropsTabTriggerFunction,
// WorkspacePropsTabRoutine, WorkspacePropsTabRoutine,
// WorkspacePropsTabFunction, WorkspacePropsTabFunction,
// WorkspacePropsTabScheduler, WorkspacePropsTabScheduler,
ModalProcessesList, ModalProcessesList,
ModalDiscardChanges ModalDiscardChanges
}, },

View File

@ -9,17 +9,17 @@
<div class="workspace-explorebar-header"> <div class="workspace-explorebar-header">
<span class="workspace-explorebar-title">{{ connectionName }}</span> <span class="workspace-explorebar-title">{{ connectionName }}</span>
<span v-if="workspace.connection_status === 'connected'" class="workspace-explorebar-tools"> <span v-if="workspace.connection_status === 'connected'" class="workspace-explorebar-tools">
<i
class="mdi mdi-18px mdi-database-plus c-hand mr-2"
:title="$t('message.createNewSchema')"
@click="showNewDBModal"
/>
<i <i
class="mdi mdi-18px mdi-refresh c-hand mr-2" class="mdi mdi-18px mdi-refresh c-hand mr-2"
:class="{'rotate':isRefreshing}" :class="{'rotate':isRefreshing}"
:title="$t('word.refresh')" :title="$t('word.refresh')"
@click="refresh" @click="refresh"
/> />
<i
class="mdi mdi-18px mdi-database-plus c-hand mr-2"
:title="$t('message.createNewSchema')"
@click="showNewDBModal"
/>
<i <i
class="mdi mdi-18px mdi-power-plug-off c-hand" class="mdi mdi-18px mdi-power-plug-off c-hand"
:title="$t('word.disconnect')" :title="$t('word.disconnect')"
@ -384,6 +384,7 @@ export default {
if (status === 'success') { if (status === 'success') {
await this.refresh(); await this.refresh();
this.changeBreadcrumbs({ schema: this.selectedSchema, view: payload.name }); this.changeBreadcrumbs({ schema: this.selectedSchema, view: payload.name });
this.newTab({ this.newTab({
uid: this.workspace.uid, uid: this.workspace.uid,
schema: this.selectedSchema, schema: this.selectedSchema,
@ -445,8 +446,15 @@ export default {
if (status === 'success') { if (status === 'success') {
await this.refresh(); await this.refresh();
this.changeBreadcrumbs({ schema: this.selectedSchema, procedure: payload.name }); this.changeBreadcrumbs({ schema: this.selectedSchema, routine: payload.name });
this.selectTab({ uid: this.workspace.uid, tab: 'prop' });
this.newTab({
uid: this.workspace.uid,
schema: this.selectedSchema,
elementName: payload.name,
elementType: 'procedure',
type: 'procedure-props'
});
} }
else else
this.addNotification({ status: 'error', message: response }); this.addNotification({ status: 'error', message: response });
@ -486,7 +494,14 @@ export default {
if (status === 'success') { if (status === 'success') {
await this.refresh(); await this.refresh();
this.changeBreadcrumbs({ schema: this.selectedSchema, function: payload.name }); this.changeBreadcrumbs({ schema: this.selectedSchema, function: payload.name });
this.selectTab({ uid: this.workspace.uid, tab: 'prop' });
this.newTab({
uid: this.workspace.uid,
schema: this.selectedSchema,
elementName: payload.name,
elementType: 'function',
type: 'function-props'
});
} }
else else
this.addNotification({ status: 'error', message: response }); this.addNotification({ status: 'error', message: response });
@ -502,7 +517,14 @@ export default {
if (status === 'success') { if (status === 'success') {
await this.refresh(); await this.refresh();
this.changeBreadcrumbs({ schema: this.selectedSchema, triggerFunction: payload.name }); this.changeBreadcrumbs({ schema: this.selectedSchema, triggerFunction: payload.name });
this.selectTab({ uid: this.workspace.uid, tab: 'prop' });
this.newTab({
uid: this.workspace.uid,
schema: this.selectedSchema,
elementName: payload.name,
elementType: 'triggerFunction',
type: 'trigger-function-props'
});
} }
else else
this.addNotification({ status: 'error', message: response }); this.addNotification({ status: 'error', message: response });
@ -518,7 +540,14 @@ export default {
if (status === 'success') { if (status === 'success') {
await this.refresh(); await this.refresh();
this.changeBreadcrumbs({ schema: this.selectedSchema, scheduler: payload.name }); this.changeBreadcrumbs({ schema: this.selectedSchema, scheduler: payload.name });
this.selectTab({ uid: this.workspace.uid, tab: 'prop' });
this.newTab({
uid: this.workspace.uid,
schema: this.selectedSchema,
elementName: payload.name,
elementType: 'scheduler',
type: 'scheduler-props'
});
} }
else else
this.addNotification({ status: 'error', message: response }); this.addNotification({ status: 'error', message: response });

View File

@ -75,7 +75,7 @@
<details class="accordion"> <details class="accordion">
<summary <summary
class="accordion-header misc-name" class="accordion-header misc-name"
:class="{'text-bold': breadcrumbs.schema === database.name && breadcrumbs.procedure}" :class="{'text-bold': breadcrumbs.schema === database.name && breadcrumbs.routine}"
@contextmenu.prevent="showMiscFolderContext($event, 'procedure')" @contextmenu.prevent="showMiscFolderContext($event, 'procedure')"
> >
<i class="misc-icon mdi mdi-18px mdi-folder-sync mr-1" /> <i class="misc-icon mdi mdi-18px mdi-folder-sync mr-1" />
@ -88,8 +88,9 @@
v-for="(procedure, i) of filteredProcedures" v-for="(procedure, i) of filteredProcedures"
:key="`${procedure.name}-${i}`" :key="`${procedure.name}-${i}`"
class="menu-item" class="menu-item"
:class="{'text-bold': breadcrumbs.schema === database.name && breadcrumbs.procedure === procedure.name}" :class="{'text-bold': breadcrumbs.schema === database.name && breadcrumbs.routine === procedure.name}"
@click="setBreadcrumbs({schema: database.name, procedure: procedure.name})" @click="selectMisc({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'})"
> >
<a class="table-name"> <a class="table-name">
@ -154,7 +155,8 @@
:key="`${func.name}-${i}`" :key="`${func.name}-${i}`"
class="menu-item" class="menu-item"
:class="{'text-bold': breadcrumbs.schema === database.name && breadcrumbs.function === func.name}" :class="{'text-bold': breadcrumbs.schema === database.name && breadcrumbs.function === func.name}"
@click="setBreadcrumbs({schema: database.name, function: func.name})" @click="selectMisc({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'})"
> >
<a class="table-name"> <a class="table-name">
@ -186,7 +188,8 @@
:key="scheduler.name" :key="scheduler.name"
class="menu-item" class="menu-item"
:class="{'text-bold': breadcrumbs.schema === database.name && breadcrumbs.scheduler === scheduler.name}" :class="{'text-bold': breadcrumbs.schema === database.name && breadcrumbs.scheduler === scheduler.name}"
@click="setBreadcrumbs({schema: database.name, scheduler: scheduler.name})" @click="selectMisc({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'})"
> >
<a class="table-name"> <a class="table-name">
@ -290,7 +293,10 @@ export default {
selectMisc ({ schema, misc, type }) { selectMisc ({ schema, misc, type }) {
const miscTempTabs = { const miscTempTabs = {
trigger: 'temp-trigger-props', trigger: 'temp-trigger-props',
triggerFunction: 'temp-trigger-function-props' triggerFunction: 'temp-trigger-function-props',
function: 'temp-function-props',
routine: 'temp-routine-props',
scheduler: 'temp-scheduler-props'
}; };
this.newTab({ this.newTab({
@ -310,7 +316,10 @@ export default {
openMiscPermanentTab ({ schema, misc, type }) { openMiscPermanentTab ({ schema, misc, type }) {
const miscTabs = { const miscTabs = {
trigger: 'trigger-props', trigger: 'trigger-props',
triggerFunction: 'trigger-function-props' triggerFunction: 'trigger-function-props',
function: 'function-props',
routine: 'routine-props',
scheduler: 'scheduler-props'
}; };
this.newTab({ this.newTab({
@ -323,19 +332,15 @@ export default {
this.setBreadcrumbs({ schema, [type]: misc.name }); this.setBreadcrumbs({ schema, [type]: misc.name });
}, },
showSchemaContext (event, schema) { showSchemaContext (event, schema) {
this.selectSchema(schema);
this.$emit('show-schema-context', { event, schema }); this.$emit('show-schema-context', { event, schema });
}, },
showTableContext (event, table) { showTableContext (event, table) {
this.$emit('show-table-context', { event, schema: this.database.name, 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.$emit('show-misc-context', { event, schema: this.database.name, misc }); this.$emit('show-misc-context', { event, schema: this.database.name, misc });
}, },
showMiscFolderContext (event, type) { showMiscFolderContext (event, type) {
this.selectSchema(this.database.name);
this.setBreadcrumbs({ schema: this.database.name, type });
this.$emit('show-misc-folder-context', { event, schema: this.database.name, type }); this.$emit('show-misc-folder-context', { event, schema: this.database.name, type });
}, },
piePercentage (val) { piePercentage (val) {

View File

@ -1,5 +1,5 @@
<template> <template>
<div class="workspace-query-tab column col-12 columns col-gapless"> <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 column col-12">
<div class="workspace-query-runner-footer"> <div class="workspace-query-runner-footer">
<div class="workspace-query-buttons"> <div class="workspace-query-buttons">
@ -42,6 +42,11 @@
<span>{{ $t('word.options') }}</span> <span>{{ $t('word.options') }}</span>
</button> </button>
</div> </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> </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">
@ -102,11 +107,12 @@ export default {
}, },
props: { props: {
connection: Object, connection: Object,
function: String function: String,
isSelected: Boolean,
schema: String
}, },
data () { data () {
return { return {
tabUid: 'prop',
isLoading: false, isLoading: false,
isSaving: false, isSaving: false,
isOptionsModal: false, isOptionsModal: false,
@ -127,11 +133,8 @@ export default {
workspace () { workspace () {
return this.getWorkspace(this.connection.uid); return this.getWorkspace(this.connection.uid);
}, },
isSelected () { tabUid () {
return this.workspace.selected_tab === 'prop' && this.selectedWorkspace === this.workspace.uid && this.function; return this.$vnode.key;
},
schema () {
return this.workspace.breadcrumbs.schema;
}, },
isChanged () { isChanged () {
return JSON.stringify(this.originalFunction) !== JSON.stringify(this.localFunction); return JSON.stringify(this.originalFunction) !== JSON.stringify(this.localFunction);
@ -150,6 +153,13 @@ export default {
} }
}, },
watch: { watch: {
async schema () {
if (this.isSelected) {
await this.getFunctionData();
this.$refs.queryEditor.editor.session.setValue(this.localFunction.sql);
this.lastFunction = this.function;
}
},
async function () { async function () {
if (this.isSelected) { if (this.isSelected) {
await this.getFunctionData(); await this.getFunctionData();
@ -158,26 +168,28 @@ export default {
} }
}, },
async isSelected (val) { async isSelected (val) {
if (val && this.lastFunction !== this.function) { if (val) {
await this.getFunctionData(); this.changeBreadcrumbs({ schema: this.schema, function: this.function });
this.$refs.queryEditor.editor.session.setValue(this.localFunction.sql);
this.lastFunction = this.function; if (this.lastFunction !== this.function)
this.getRoutineData();
} }
}, },
isChanged (val) { isChanged (val) {
if (this.isSelected && this.lastFunction === this.function && this.function !== null) this.setUnsavedChanges({ uid: this.connection.uid, tUid: this.tabUid, isChanged: val });
this.setUnsavedChanges(val);
} }
}, },
async created () {
await this.getFunctionData();
this.$refs.queryEditor.editor.session.setValue(this.localFunction.sql);
window.addEventListener('keydown', this.onKey);
},
mounted () { mounted () {
window.addEventListener('resize', this.resizeQueryEditor); window.addEventListener('resize', this.resizeQueryEditor);
}, },
destroyed () { destroyed () {
window.removeEventListener('resize', this.resizeQueryEditor); window.removeEventListener('resize', this.resizeQueryEditor);
}, },
created () {
window.addEventListener('keydown', this.onKey);
},
beforeDestroy () { beforeDestroy () {
window.removeEventListener('keydown', this.onKey); window.removeEventListener('keydown', this.onKey);
}, },
@ -185,20 +197,22 @@ export default {
...mapActions({ ...mapActions({
addNotification: 'notifications/addNotification', addNotification: 'notifications/addNotification',
refreshStructure: 'workspaces/refreshStructure', refreshStructure: 'workspaces/refreshStructure',
setUnsavedChanges: 'workspaces/setUnsavedChanges', renameTabs: 'workspaces/renameTabs',
newTab: 'workspaces/newTab',
changeBreadcrumbs: 'workspaces/changeBreadcrumbs', changeBreadcrumbs: 'workspaces/changeBreadcrumbs',
newTab: 'workspaces/newTab' setUnsavedChanges: 'workspaces/setUnsavedChanges'
}), }),
async getFunctionData () { async getFunctionData () {
if (!this.function) return; if (!this.function) return;
this.isLoading = true; this.isLoading = true;
this.localFunction = { sql: '' }; this.localFunction = { sql: '' };
this.lastFunction = this.function;
const params = { const params = {
uid: this.connection.uid, uid: this.connection.uid,
schema: this.schema, schema: this.schema,
func: this.workspace.breadcrumbs.function func: this.function
}; };
try { try {
@ -245,7 +259,14 @@ export default {
await this.refreshStructure(this.connection.uid); await this.refreshStructure(this.connection.uid);
if (oldName !== this.localFunction.name) { if (oldName !== this.localFunction.name) {
this.setUnsavedChanges(false); this.renameTabs({
uid: this.connection.uid,
schema: this.schema,
elementName: oldName,
elementNewName: this.localFunction.name,
elementType: 'function'
});
this.changeBreadcrumbs({ schema: this.schema, function: this.localFunction.name }); this.changeBreadcrumbs({ schema: this.schema, function: this.localFunction.name });
} }

View File

@ -1,5 +1,5 @@
<template> <template>
<div class="workspace-query-tab column col-12 columns col-gapless"> <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 column col-12">
<div class="workspace-query-runner-footer"> <div class="workspace-query-runner-footer">
<div class="workspace-query-buttons"> <div class="workspace-query-buttons">
@ -42,6 +42,11 @@
<span>{{ $t('word.options') }}</span> <span>{{ $t('word.options') }}</span>
</button> </button>
</div> </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> </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">
@ -103,11 +108,12 @@ export default {
}, },
props: { props: {
connection: Object, connection: Object,
routine: String routine: String,
isSelected: Boolean,
schema: String
}, },
data () { data () {
return { return {
tabUid: 'prop',
isLoading: false, isLoading: false,
isSaving: false, isSaving: false,
isOptionsModal: false, isOptionsModal: false,
@ -128,11 +134,8 @@ export default {
workspace () { workspace () {
return this.getWorkspace(this.connection.uid); return this.getWorkspace(this.connection.uid);
}, },
isSelected () { tabUid () {
return this.workspace.selected_tab === 'prop' && this.selectedWorkspace === this.workspace.uid && this.routine; return this.$vnode.key;
},
schema () {
return this.workspace.breadcrumbs.schema;
}, },
isChanged () { isChanged () {
return JSON.stringify(this.originalRoutine) !== JSON.stringify(this.localRoutine); return JSON.stringify(this.originalRoutine) !== JSON.stringify(this.localRoutine);
@ -149,6 +152,13 @@ export default {
} }
}, },
watch: { watch: {
async schema () {
if (this.isSelected) {
await this.getRoutineData();
this.$refs.queryEditor.editor.session.setValue(this.localRoutine.sql);
this.lastRoutine = this.routine;
}
},
async routine () { async routine () {
if (this.isSelected) { if (this.isSelected) {
await this.getRoutineData(); await this.getRoutineData();
@ -157,26 +167,28 @@ export default {
} }
}, },
async isSelected (val) { async isSelected (val) {
if (val && this.lastRoutine !== this.routine) { if (val) {
await this.getRoutineData(); this.changeBreadcrumbs({ schema: this.schema, routine: this.routine });
this.$refs.queryEditor.editor.session.setValue(this.localRoutine.sql);
this.lastRoutine = this.routine; if (this.lastRoutine !== this.routine)
this.getRoutineData();
} }
}, },
isChanged (val) { isChanged (val) {
if (this.isSelected && this.lastRoutine === this.routine && this.routine !== null) this.setUnsavedChanges({ uid: this.connection.uid, tUid: this.tabUid, isChanged: val });
this.setUnsavedChanges(val);
} }
}, },
async created () {
await this.getRoutineData();
this.$refs.queryEditor.editor.session.setValue(this.localRoutine.sql);
window.addEventListener('keydown', this.onKey);
},
mounted () { mounted () {
window.addEventListener('resize', this.resizeQueryEditor); window.addEventListener('resize', this.resizeQueryEditor);
}, },
destroyed () { destroyed () {
window.removeEventListener('resize', this.resizeQueryEditor); window.removeEventListener('resize', this.resizeQueryEditor);
}, },
created () {
window.addEventListener('keydown', this.onKey);
},
beforeDestroy () { beforeDestroy () {
window.removeEventListener('keydown', this.onKey); window.removeEventListener('keydown', this.onKey);
}, },
@ -184,19 +196,22 @@ export default {
...mapActions({ ...mapActions({
addNotification: 'notifications/addNotification', addNotification: 'notifications/addNotification',
refreshStructure: 'workspaces/refreshStructure', refreshStructure: 'workspaces/refreshStructure',
setUnsavedChanges: 'workspaces/setUnsavedChanges', renameTabs: 'workspaces/renameTabs',
newTab: 'workspaces/newTab',
changeBreadcrumbs: 'workspaces/changeBreadcrumbs', changeBreadcrumbs: 'workspaces/changeBreadcrumbs',
newTab: 'workspaces/newTab' setUnsavedChanges: 'workspaces/setUnsavedChanges'
}), }),
async getRoutineData () { async getRoutineData () {
if (!this.routine) return; if (!this.routine) return;
this.localRoutine = { sql: '' }; this.localRoutine = { sql: '' };
this.isLoading = true; this.isLoading = true;
this.lastRoutine = this.routine;
const params = { const params = {
uid: this.connection.uid, uid: this.connection.uid,
schema: this.schema, schema: this.schema,
routine: this.workspace.breadcrumbs.procedure routine: this.routine
}; };
try { try {
@ -243,7 +258,14 @@ export default {
await this.refreshStructure(this.connection.uid); await this.refreshStructure(this.connection.uid);
if (oldName !== this.localRoutine.name) { if (oldName !== this.localRoutine.name) {
this.setUnsavedChanges(false); this.renameTabs({
uid: this.connection.uid,
schema: this.schema,
elementName: oldName,
elementNewName: this.localRoutine.name,
elementType: 'procedure'
});
this.changeBreadcrumbs({ schema: this.schema, procedure: this.localRoutine.name }); this.changeBreadcrumbs({ schema: this.schema, procedure: this.localRoutine.name });
} }

View File

@ -1,5 +1,5 @@
<template> <template>
<div class="workspace-query-tab column col-12 columns col-gapless"> <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 column col-12">
<div class="workspace-query-runner-footer"> <div class="workspace-query-runner-footer">
<div class="workspace-query-buttons"> <div class="workspace-query-buttons">
@ -29,6 +29,11 @@
<span>{{ $t('word.timing') }}</span> <span>{{ $t('word.timing') }}</span>
</button> </button>
</div> </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> </div>
<div class="container"> <div class="container">
@ -153,11 +158,12 @@ export default {
}, },
props: { props: {
connection: Object, connection: Object,
scheduler: String scheduler: String,
isSelected: Boolean,
schema: String
}, },
data () { data () {
return { return {
tabUid: 'prop',
isLoading: false, isLoading: false,
isSaving: false, isSaving: false,
isTimingModal: false, isTimingModal: false,
@ -176,11 +182,8 @@ export default {
workspace () { workspace () {
return this.getWorkspace(this.connection.uid); return this.getWorkspace(this.connection.uid);
}, },
isSelected () { tabUid () {
return this.workspace.selected_tab === 'prop' && this.selectedWorkspace === this.workspace.uid && this.scheduler; return this.$vnode.key;
},
schema () {
return this.workspace.breadcrumbs.schema;
}, },
isChanged () { isChanged () {
return JSON.stringify(this.originalScheduler) !== JSON.stringify(this.localScheduler); return JSON.stringify(this.originalScheduler) !== JSON.stringify(this.localScheduler);
@ -197,6 +200,13 @@ export default {
} }
}, },
watch: { watch: {
async schema () {
if (this.isSelected) {
await this.getSchedulerData();
this.$refs.queryEditor.editor.session.setValue(this.localScheduler.sql);
this.lastScheduler = this.scheduler;
}
},
async scheduler () { async scheduler () {
if (this.isSelected) { if (this.isSelected) {
await this.getSchedulerData(); await this.getSchedulerData();
@ -205,26 +215,28 @@ export default {
} }
}, },
async isSelected (val) { async isSelected (val) {
if (val && this.lastScheduler !== this.scheduler) { if (val) {
await this.getSchedulerData(); this.changeBreadcrumbs({ schema: this.schema, scheduler: this.scheduler });
this.$refs.queryEditor.editor.session.setValue(this.localScheduler.sql);
this.lastScheduler = this.scheduler; if (this.lastScheduler !== this.scheduler)
this.getSchedulerData();
} }
}, },
isChanged (val) { isChanged (val) {
if (this.isSelected && this.lastScheduler === this.scheduler && this.scheduler !== null) this.setUnsavedChanges({ uid: this.connection.uid, tUid: this.tabUid, isChanged: val });
this.setUnsavedChanges(val);
} }
}, },
async created () {
await this.getSchedulerData();
this.$refs.queryEditor.editor.session.setValue(this.localScheduler.sql);
window.addEventListener('keydown', this.onKey);
},
mounted () { mounted () {
window.addEventListener('resize', this.resizeQueryEditor); window.addEventListener('resize', this.resizeQueryEditor);
}, },
destroyed () { destroyed () {
window.removeEventListener('resize', this.resizeQueryEditor); window.removeEventListener('resize', this.resizeQueryEditor);
}, },
created () {
window.addEventListener('keydown', this.onKey);
},
beforeDestroy () { beforeDestroy () {
window.removeEventListener('keydown', this.onKey); window.removeEventListener('keydown', this.onKey);
}, },
@ -232,17 +244,21 @@ export default {
...mapActions({ ...mapActions({
addNotification: 'notifications/addNotification', addNotification: 'notifications/addNotification',
refreshStructure: 'workspaces/refreshStructure', refreshStructure: 'workspaces/refreshStructure',
setUnsavedChanges: 'workspaces/setUnsavedChanges', renameTabs: 'workspaces/renameTabs',
changeBreadcrumbs: 'workspaces/changeBreadcrumbs' newTab: 'workspaces/newTab',
changeBreadcrumbs: 'workspaces/changeBreadcrumbs',
setUnsavedChanges: 'workspaces/setUnsavedChanges'
}), }),
async getSchedulerData () { async getSchedulerData () {
if (!this.scheduler) return; if (!this.scheduler) return;
this.isLoading = true; this.isLoading = true;
this.lastScheduler = this.scheduler;
const params = { const params = {
uid: this.connection.uid, uid: this.connection.uid,
schema: this.schema, schema: this.schema,
scheduler: this.workspace.breadcrumbs.scheduler scheduler: this.scheduler
}; };
try { try {
@ -283,7 +299,14 @@ export default {
await this.refreshStructure(this.connection.uid); await this.refreshStructure(this.connection.uid);
if (oldName !== this.localScheduler.name) { if (oldName !== this.localScheduler.name) {
this.setUnsavedChanges(false); this.renameTabs({
uid: this.connection.uid,
schema: this.schema,
elementName: oldName,
elementNewName: this.localScheduler.name,
elementType: 'scheduler'
});
this.changeBreadcrumbs({ schema: this.schema, scheduler: this.localScheduler.name }); this.changeBreadcrumbs({ schema: this.schema, scheduler: this.localScheduler.name });
} }

View File

@ -597,7 +597,10 @@ export default {
} }
break; break;
case 'temp-trigger-props': case 'temp-trigger-props':
case 'temp-trigger-function-props': { case 'temp-trigger-function-props':
case 'temp-function-props':
case 'temp-routine-props':
case 'temp-scheduler-props': {
const existentTab = workspaceTabs const existentTab = workspaceTabs
? workspaceTabs.tabs.find(tab => ? workspaceTabs.tabs.find(tab =>
tab.schema === schema && tab.schema === schema &&
@ -640,7 +643,10 @@ export default {
} }
break; break;
case 'trigger-props': case 'trigger-props':
case 'trigger-function-props': { case 'trigger-function-props':
case 'function-props':
case 'routine-props':
case 'scheduler-props': {
const existentTab = workspaceTabs const existentTab = workspaceTabs
? workspaceTabs.tabs.find(tab => ? workspaceTabs.tabs.find(tab =>
tab.schema === schema && tab.schema === schema &&