mirror of https://github.com/nocodb/nocodb
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
287 lines
8.4 KiB
287 lines
8.4 KiB
4 years ago
|
<template>
|
||
|
<v-container class="pa-0 ma-0" fluid>
|
||
|
<v-toolbar flat height="42" class="toolbar-border-bottom">
|
||
|
<v-toolbar-title>
|
||
3 years ago
|
<v-breadcrumbs
|
||
3 years ago
|
:items="[
|
||
|
{
|
||
|
text: nodes.env,
|
||
|
disabled: true,
|
||
|
href: '#',
|
||
|
},
|
||
|
{
|
||
|
text: nodes.dbAlias,
|
||
|
disabled: true,
|
||
|
href: '#',
|
||
|
},
|
||
|
{
|
||
|
text: nodes.procedure_name + ' (function)',
|
||
|
disabled: true,
|
||
|
href: '#',
|
||
|
},
|
||
|
]"
|
||
3 years ago
|
divider=">"
|
||
|
small
|
||
|
>
|
||
|
<template #divider>
|
||
3 years ago
|
<v-icon small color="grey lighten-2"> forward </v-icon>
|
||
4 years ago
|
</template>
|
||
|
</v-breadcrumbs>
|
||
|
</v-toolbar-title>
|
||
3 years ago
|
<v-spacer />
|
||
3 years ago
|
<x-btn outlined :tooltip="$t('tooltip.saveChanges')" small color="primary" icon="save" @click="applyChanges()">
|
||
3 years ago
|
<!-- Save -->
|
||
|
{{ $t('general.save') }}
|
||
3 years ago
|
</x-btn>
|
||
|
<x-btn
|
||
|
outlined
|
||
|
tooltip="Delete Procedure"
|
||
|
small
|
||
|
color="error"
|
||
|
icon="mdi-delete-outline"
|
||
|
@click="deleteProcedure('showDialog')"
|
||
|
>
|
||
4 years ago
|
Delete Procedure
|
||
|
<!-- <v-icon>delete</v-icon>-->
|
||
|
</x-btn>
|
||
|
</v-toolbar>
|
||
|
<monaco-editor
|
||
|
v-if="procedure.create_procedure != undefined"
|
||
|
:code.sync="procedure.create_procedure"
|
||
3 years ago
|
css-style="height:500px"
|
||
|
/>
|
||
4 years ago
|
<dlgLabelSubmitCancel
|
||
|
v-if="dialogShow"
|
||
3 years ago
|
type="error"
|
||
|
:dialog-show="dialogShow"
|
||
|
css-style="border:1px solid grey;height:300px"
|
||
|
:actions-mtd="deleteProcedure"
|
||
4 years ago
|
heading="Click Submit to Delete the Procedure"
|
||
|
/>
|
||
|
</v-container>
|
||
|
</template>
|
||
|
|
||
|
<script>
|
||
3 years ago
|
import { mapGetters, mapActions } from 'vuex';
|
||
4 years ago
|
|
||
3 years ago
|
import MonacoEditor from '../../monaco/Monaco';
|
||
|
import dlgLabelSubmitCancel from '../../utils/DlgLabelSubmitCancel';
|
||
4 years ago
|
|
||
|
export default {
|
||
3 years ago
|
components: { MonacoEditor, dlgLabelSubmitCancel },
|
||
3 years ago
|
data() {
|
||
4 years ago
|
return {
|
||
|
procedure: {},
|
||
3 years ago
|
newProcedure: !!this.nodes.newProcedure,
|
||
|
oldCreateProcedure: '',
|
||
3 years ago
|
dialogShow: false,
|
||
|
};
|
||
4 years ago
|
},
|
||
|
computed: {
|
||
3 years ago
|
...mapGetters({ sqlMgr: 'sqlMgr/sqlMgr' }),
|
||
4 years ago
|
},
|
||
|
methods: {
|
||
|
...mapActions({
|
||
3 years ago
|
loadProceduresFromChildTreeNode: 'project/loadProceduresFromChildTreeNode',
|
||
|
loadProceduresFromParentTreeNode: 'project/loadProceduresFromParentTreeNode',
|
||
|
removeProcedureTab: 'tabs/removeProcedureTab',
|
||
4 years ago
|
}),
|
||
|
|
||
3 years ago
|
async handleKeyDown({ metaKey, key, altKey, shiftKey, ctrlKey }) {
|
||
3 years ago
|
console.log(metaKey, key, altKey, shiftKey, ctrlKey);
|
||
4 years ago
|
// cmd + s -> save
|
||
|
// cmd + l -> reload
|
||
|
// cmd + n -> new
|
||
|
// cmd + d -> delete
|
||
|
// cmd + enter -> send api
|
||
|
|
||
|
switch ([metaKey, key].join('_')) {
|
||
3 years ago
|
case 'true_s':
|
||
|
await this.applyChanges();
|
||
|
break;
|
||
|
case 'true_l':
|
||
|
await this.loadProcedure();
|
||
|
break;
|
||
4 years ago
|
// case 'true_n' :
|
||
|
// this.addColumn();
|
||
|
// break;
|
||
3 years ago
|
case 'true_d':
|
||
|
await this.deleteProcedure('showDialog');
|
||
|
break;
|
||
4 years ago
|
}
|
||
|
},
|
||
|
|
||
3 years ago
|
async loadProcedure() {
|
||
4 years ago
|
try {
|
||
3 years ago
|
this.$store.commit('notification/MutToggleProgressBar', true);
|
||
4 years ago
|
if (this.newProcedure) {
|
||
|
this.procedure = {
|
||
|
procedure_name: this.nodes.procedure_name,
|
||
3 years ago
|
create_procedure: '',
|
||
|
};
|
||
|
this.$store.commit('notification/MutToggleProgressBar', false);
|
||
|
return;
|
||
4 years ago
|
}
|
||
|
|
||
|
// // console.log("env: this.env", this.env, this.dbAlias);
|
||
|
// const client = await this.sqlMgr.projectGetSqlClient({
|
||
|
// env: this.nodes.env,
|
||
|
// dbAlias: this.nodes.dbAlias
|
||
|
// });
|
||
|
// const result = await client.procedureRead({
|
||
|
// procedure_name: this.nodes.procedure_name
|
||
|
// });
|
||
|
//
|
||
|
// const result = await this.sqlMgr.sqlOp({
|
||
|
// env: this.nodes.env,
|
||
|
// dbAlias: this.nodes.dbAlias
|
||
|
// }, 'procedureRead', {procedure_name: this.nodes.procedure_name})
|
||
|
|
||
3 years ago
|
const result = await this.$store.dispatch('sqlMgr/ActSqlOp', [
|
||
|
{
|
||
|
env: this.nodes.env,
|
||
|
dbAlias: this.nodes.dbAlias,
|
||
|
},
|
||
|
'procedureRead',
|
||
|
{ procedure_name: this.nodes.procedure_name },
|
||
|
]);
|
||
4 years ago
|
|
||
|
// console.log("procedure read", result);
|
||
3 years ago
|
this.procedure = result.data.list[0];
|
||
|
this.oldCreateProcedure = this.procedure.create_procedure;
|
||
4 years ago
|
} catch (e) {
|
||
3 years ago
|
console.log(e);
|
||
4 years ago
|
} finally {
|
||
3 years ago
|
this.$store.commit('notification/MutToggleProgressBar', false);
|
||
4 years ago
|
}
|
||
|
},
|
||
3 years ago
|
async applyChanges() {
|
||
4 years ago
|
try {
|
||
|
if (this.newProcedure) {
|
||
3 years ago
|
const result = await this.$store.dispatch('sqlMgr/ActSqlOpPlus', [
|
||
4 years ago
|
{
|
||
|
env: this.nodes.env,
|
||
3 years ago
|
dbAlias: this.nodes.dbAlias,
|
||
4 years ago
|
},
|
||
3 years ago
|
'procedureCreate',
|
||
4 years ago
|
{
|
||
|
procedure_name: this.nodes.procedure_name,
|
||
3 years ago
|
create_procedure: this.procedure.create_procedure,
|
||
|
},
|
||
|
]);
|
||
4 years ago
|
|
||
|
await this.loadProceduresFromChildTreeNode({
|
||
|
_nodes: {
|
||
3 years ago
|
...this.nodes,
|
||
|
},
|
||
|
});
|
||
|
console.log('create procedure result', result);
|
||
|
this.newProcedure = false;
|
||
|
this.oldCreateProcedure = this.procedure.create_procedure;
|
||
|
this.$toast.success('Procedure created successfully').goAway(3000);
|
||
4 years ago
|
} else {
|
||
3 years ago
|
const result = await this.$store.dispatch('sqlMgr/ActSqlOpPlus', [
|
||
4 years ago
|
{
|
||
|
env: this.nodes.env,
|
||
3 years ago
|
dbAlias: this.nodes.dbAlias,
|
||
4 years ago
|
},
|
||
3 years ago
|
'procedureUpdate',
|
||
4 years ago
|
{
|
||
|
procedure_name: this.nodes.procedure_name,
|
||
|
create_procedure: this.procedure.create_procedure,
|
||
3 years ago
|
oldCreateProcedure: this.oldCreateProcedure,
|
||
|
},
|
||
|
]);
|
||
4 years ago
|
|
||
3 years ago
|
this.oldCreateProcedure = this.procedure.create_procedure;
|
||
|
console.log('update procedure result', result);
|
||
|
this.$toast.success('Procedure updated successfully').goAway(3000);
|
||
4 years ago
|
}
|
||
|
} catch (e) {
|
||
3 years ago
|
this.$toast.error('Saving procedure failed').goAway(3000);
|
||
|
throw e;
|
||
4 years ago
|
}
|
||
|
},
|
||
3 years ago
|
async deleteProcedure(action = '') {
|
||
4 years ago
|
try {
|
||
3 years ago
|
if (action === 'showDialog') {
|
||
3 years ago
|
this.dialogShow = true;
|
||
3 years ago
|
} else if (action === 'hideDialog') {
|
||
3 years ago
|
this.dialogShow = false;
|
||
4 years ago
|
} else {
|
||
3 years ago
|
await this.$store.dispatch('sqlMgr/ActSqlOpPlus', [
|
||
4 years ago
|
{
|
||
|
env: this.nodes.env,
|
||
3 years ago
|
dbAlias: this.nodes.dbAlias,
|
||
4 years ago
|
},
|
||
3 years ago
|
'procedureDelete',
|
||
4 years ago
|
{
|
||
|
procedure_name: this.nodes.procedure_name,
|
||
3 years ago
|
create_procedure: this.oldCreateProcedure,
|
||
|
},
|
||
|
]);
|
||
4 years ago
|
|
||
|
this.removeProcedureTab({
|
||
|
env: this.nodes.env,
|
||
|
dbAlias: this.nodes.dbAlias,
|
||
3 years ago
|
procedure_name: this.nodes.procedure_name,
|
||
|
});
|
||
4 years ago
|
await this.loadProceduresFromParentTreeNode({
|
||
|
_nodes: {
|
||
3 years ago
|
...this.nodes,
|
||
|
},
|
||
|
});
|
||
|
this.dialogShow = false;
|
||
|
this.$toast.success('Procedure deleted successfully').goAway(3000);
|
||
4 years ago
|
}
|
||
|
} catch (e) {
|
||
3 years ago
|
this.$toast.error('Deleting procedure failed').goAway(3000);
|
||
|
throw e;
|
||
4 years ago
|
}
|
||
3 years ago
|
},
|
||
4 years ago
|
},
|
||
3 years ago
|
beforeCreated() {},
|
||
3 years ago
|
watch: {},
|
||
3 years ago
|
created() {
|
||
3 years ago
|
this.loadProcedure();
|
||
4 years ago
|
},
|
||
3 years ago
|
mounted() {},
|
||
|
beforeDestroy() {},
|
||
|
destroy() {},
|
||
3 years ago
|
directives: {},
|
||
3 years ago
|
validate({ params }) {
|
||
3 years ago
|
return true;
|
||
4 years ago
|
},
|
||
3 years ago
|
head() {
|
||
3 years ago
|
return {};
|
||
4 years ago
|
},
|
||
3 years ago
|
props: ['nodes'],
|
||
|
};
|
||
4 years ago
|
</script>
|
||
|
|
||
3 years ago
|
<style scoped></style>
|
||
4 years ago
|
<!--
|
||
|
/**
|
||
|
* @copyright Copyright (c) 2021, Xgene Cloud Ltd
|
||
|
*
|
||
|
* @author Naveen MR <oof1lab@gmail.com>
|
||
|
* @author Pranav C Balan <pranavxc@gmail.com>
|
||
|
*
|
||
|
* @license GNU AGPL version 3 or any later version
|
||
|
*
|
||
|
* This program is free software: you can redistribute it and/or modify
|
||
|
* it under the terms of the GNU Affero General Public License as
|
||
|
* published by the Free Software Foundation, either version 3 of the
|
||
|
* License, or (at your option) any later version.
|
||
|
*
|
||
|
* This program is distributed in the hope that it will be useful,
|
||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||
|
* GNU Affero General Public License for more details.
|
||
|
*
|
||
|
* You should have received a copy of the GNU Affero General Public License
|
||
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||
|
*
|
||
|
*/
|
||
|
-->
|