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.
350 lines
10 KiB
350 lines
10 KiB
4 years ago
|
<template>
|
||
|
<v-row class="pa-0 ma-0">
|
||
3 years ago
|
<v-overlay v-if="isMetaTable" absolute>
|
||
3 years ago
|
<v-alert type="info"> Meta tables are not editable </v-alert>
|
||
4 years ago
|
</v-overlay>
|
||
|
|
||
|
<v-col cols="12 pa-0">
|
||
|
<v-card class="elevation-0">
|
||
|
<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.title + ' (table)',
|
||
|
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 />
|
||
|
<x-btn
|
||
3 years ago
|
v-ge="['triggers', 'load']"
|
||
3 years ago
|
outlined
|
||
|
tooltip="Load Triggers"
|
||
|
small
|
||
|
class="primary"
|
||
|
color="primary"
|
||
|
@click="loadTriggerList"
|
||
4 years ago
|
>
|
||
3 years ago
|
<v-icon small left> refresh </v-icon>
|
||
3 years ago
|
<!-- Reload -->
|
||
|
{{ $t('general.reload') }}
|
||
4 years ago
|
</x-btn>
|
||
3 years ago
|
<x-btn
|
||
3 years ago
|
v-ge="['triggers', 'new']"
|
||
3 years ago
|
outlined
|
||
|
tooltip="Create New Trigger"
|
||
|
small
|
||
|
class="primary"
|
||
|
color="primary"
|
||
|
icon="mdi-plus"
|
||
|
@click="showTriggerDlg()"
|
||
|
>
|
||
|
New Trigger
|
||
4 years ago
|
</x-btn>
|
||
3 years ago
|
<x-btn
|
||
3 years ago
|
v-ge="['triggers', 'delete']"
|
||
3 years ago
|
outlined
|
||
3 years ago
|
:tooltip="$t('activity.deleteTable')"
|
||
3 years ago
|
small
|
||
|
icon="mdi-delete-outline"
|
||
|
class="error text-right"
|
||
|
color="error "
|
||
|
@click="deleteTable('showDialog')"
|
||
4 years ago
|
>
|
||
3 years ago
|
{{ $t('activity.deleteTable') }}
|
||
3 years ago
|
</x-btn>
|
||
|
</v-toolbar>
|
||
|
<v-skeleton-loader v-if="loading" type="table" />
|
||
3 years ago
|
<v-data-table v-else dense :headers="headers" :items="triggers" footer-props.items-per-page-options="30">
|
||
3 years ago
|
<template #item="props">
|
||
4 years ago
|
<tr>
|
||
|
<td>{{ props.item.trigger }}</td>
|
||
|
<td>{{ props.item.event }}</td>
|
||
|
<td>{{ props.item.timing }}</td>
|
||
|
<td>{{ props.item.statement }}</td>
|
||
|
<td>
|
||
|
<div>
|
||
3 years ago
|
<x-icon v-ge="['triggers', 'edit']" color="primary" small @click="showTriggerDlg(props.item)">
|
||
3 years ago
|
mdi-square-edit-outline
|
||
4 years ago
|
</x-icon>
|
||
|
<x-icon
|
||
3 years ago
|
v-ge="['triggers', 'delete']"
|
||
4 years ago
|
small
|
||
|
color="error"
|
||
|
@click="deleteTrigger('showDialog', props.item)"
|
||
3 years ago
|
>
|
||
|
mdi-delete-forever
|
||
4 years ago
|
</x-icon>
|
||
|
</div>
|
||
|
</td>
|
||
|
</tr>
|
||
|
</template>
|
||
|
</v-data-table>
|
||
|
</v-card>
|
||
|
<triggerAddEditDlg
|
||
|
v-if="dialogShow"
|
||
|
:nodes="nodes"
|
||
3 years ago
|
:trigger-object="selectedTrigger"
|
||
|
:new-trigger="!selectedTrigger.trigger"
|
||
|
:dialog-show="dialogShow"
|
||
|
:mtd-dialog-submit="mtdTriggerDlgSubmit"
|
||
|
:mtd-dialog-cancel="mtdTriggerDlgCancel"
|
||
4 years ago
|
/>
|
||
|
<dlgLabelSubmitCancel
|
||
|
v-if="showTriggerDeleteDialog"
|
||
3 years ago
|
type="error"
|
||
|
:dialog-show="showTriggerDeleteDialog"
|
||
|
:actions-mtd="deleteTrigger"
|
||
4 years ago
|
heading="Click Submit to Delete the Trigger"
|
||
|
/>
|
||
|
</v-col>
|
||
|
</v-row>
|
||
|
</template>
|
||
|
|
||
|
<script>
|
||
3 years ago
|
import { mapGetters } from 'vuex';
|
||
4 years ago
|
|
||
3 years ago
|
import triggerAddEditDlg from '../dlgs/DlgTriggerAddEdit';
|
||
|
import dlgLabelSubmitCancel from '../../utils/DlgLabelSubmitCancel';
|
||
4 years ago
|
|
||
|
export default {
|
||
3 years ago
|
components: { triggerAddEditDlg, dlgLabelSubmitCancel },
|
||
3 years ago
|
data() {
|
||
4 years ago
|
return {
|
||
|
loading: false,
|
||
|
showTriggerDeleteDialog: false,
|
||
|
triggers: [],
|
||
|
headers: [
|
||
|
{
|
||
3 years ago
|
text: 'Trigger Name',
|
||
3 years ago
|
sortable: false,
|
||
4 years ago
|
},
|
||
3 years ago
|
{ text: 'Event', sortable: false },
|
||
|
{ text: 'Timing', sortable: false },
|
||
|
{ text: 'Statement', sortable: false },
|
||
3 years ago
|
{ text: '', sortable: false },
|
||
4 years ago
|
],
|
||
|
dialogShow: false,
|
||
3 years ago
|
selectedTrigger: null,
|
||
|
};
|
||
4 years ago
|
},
|
||
|
methods: {
|
||
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('_')) {
|
||
|
// case 'true_s' :
|
||
|
// await this.applyChanges();
|
||
|
// break;
|
||
3 years ago
|
case 'true_l':
|
||
|
await this.loadTriggerList();
|
||
|
break;
|
||
|
case 'true_n':
|
||
|
this.showTriggerDlg();
|
||
|
break;
|
||
|
case 'true_d':
|
||
|
await this.deleteTable('showDialog');
|
||
|
break;
|
||
4 years ago
|
}
|
||
|
},
|
||
|
|
||
3 years ago
|
async loadTriggerList() {
|
||
3 years ago
|
this.loading = true;
|
||
4 years ago
|
try {
|
||
3 years ago
|
this.$store.commit('notification/MutToggleProgressBar', true);
|
||
4 years ago
|
if (this.newTable) {
|
||
3 years ago
|
this.$store.commit('notification/MutToggleProgressBar', false);
|
||
|
return;
|
||
4 years ago
|
}
|
||
|
// const client = await this.sqlMgr.projectGetSqlClient({
|
||
|
// env: this.nodes.env,
|
||
|
// dbAlias: this.nodes.dbAlias
|
||
|
// });
|
||
|
// const result = await client.triggerList({
|
||
3 years ago
|
// table_name: this.nodes.table_name
|
||
4 years ago
|
// });
|
||
|
|
||
|
//
|
||
|
// const result = await this.sqlMgr.sqlOp({
|
||
|
// env: this.nodes.env,
|
||
|
// dbAlias: this.nodes.dbAlias
|
||
|
// }, 'triggerList', {
|
||
3 years ago
|
// table_name: this.nodes.table_name
|
||
4 years ago
|
// })
|
||
|
|
||
3 years ago
|
const result = await this.$store.dispatch('sqlMgr/ActSqlOp', [
|
||
|
{
|
||
|
env: this.nodes.env,
|
||
|
dbAlias: this.nodes.dbAlias,
|
||
|
},
|
||
|
'triggerList',
|
||
|
{
|
||
|
table_name: this.nodes.table_name,
|
||
|
},
|
||
|
]);
|
||
4 years ago
|
|
||
3 years ago
|
console.log('triggers', result.data.list);
|
||
|
this.triggers = result.data.list;
|
||
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
|
this.loading = false;
|
||
4 years ago
|
},
|
||
3 years ago
|
showTriggerDlg(trigger) {
|
||
3 years ago
|
if (trigger) {
|
||
|
this.selectedTrigger = trigger;
|
||
|
} else {
|
||
|
this.selectedTrigger = {};
|
||
|
}
|
||
|
this.dialogShow = true;
|
||
4 years ago
|
},
|
||
3 years ago
|
async mtdTriggerDlgSubmit(triggerObject, newTrigger) {
|
||
4 years ago
|
try {
|
||
|
// const client = await this.sqlMgr.projectGetSqlClient({
|
||
|
// env: this.nodes.env,
|
||
|
// dbAlias: this.nodes.dbAlias
|
||
|
// });
|
||
|
if (newTrigger) {
|
||
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
|
'triggerCreate',
|
||
3 years ago
|
triggerObject,
|
||
|
]);
|
||
|
console.log('triggerCreate result: ', result);
|
||
|
this.$toast.success('Trigger 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
|
'triggerUpdate',
|
||
4 years ago
|
{
|
||
|
...triggerObject,
|
||
3 years ago
|
oldStatement: this.selectedTrigger.statement,
|
||
|
},
|
||
|
]);
|
||
4 years ago
|
|
||
3 years ago
|
console.log('triggerUpdate result: ', result);
|
||
|
this.$toast.success('Trigger updated successfully').goAway(3000);
|
||
4 years ago
|
}
|
||
|
|
||
3 years ago
|
await this.loadTriggerList();
|
||
|
this.selectedTrigger = null;
|
||
|
this.dialogShow = false;
|
||
4 years ago
|
} catch (error) {
|
||
3 years ago
|
console.error('triggerCreate error: ', error);
|
||
4 years ago
|
}
|
||
|
},
|
||
3 years ago
|
mtdTriggerDlgCancel() {
|
||
3 years ago
|
this.dialogShow = false;
|
||
|
this.selectedTrigger = null;
|
||
4 years ago
|
},
|
||
3 years ago
|
async deleteTrigger(action = '', trigger) {
|
||
3 years ago
|
if (action === 'showDialog') {
|
||
3 years ago
|
this.showTriggerDeleteDialog = true;
|
||
|
this.selectedTriggerForDelete = trigger;
|
||
3 years ago
|
} else if (action === 'hideDialog') {
|
||
3 years ago
|
this.showTriggerDeleteDialog = false;
|
||
|
this.selectedTriggerForDelete = null;
|
||
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
|
'triggerDelete',
|
||
4 years ago
|
{
|
||
|
...this.selectedTriggerForDelete,
|
||
3 years ago
|
table_name: this.nodes.table_name,
|
||
3 years ago
|
oldStatement: this.selectedTriggerForDelete.statement,
|
||
|
},
|
||
|
]);
|
||
4 years ago
|
|
||
3 years ago
|
console.log('triggerDelete result ', result);
|
||
|
await this.loadTriggerList();
|
||
|
this.showTriggerDeleteDialog = false;
|
||
|
this.selectedTriggerForDelete = null;
|
||
4 years ago
|
|
||
3 years ago
|
this.$toast.success('Trigger deleted successfully').goAway(3000);
|
||
4 years ago
|
}
|
||
3 years ago
|
},
|
||
4 years ago
|
},
|
||
3 years ago
|
computed: { ...mapGetters({ sqlMgr: 'sqlMgr/sqlMgr' }) },
|
||
4 years ago
|
|
||
3 years ago
|
beforeCreated() {},
|
||
3 years ago
|
watch: {},
|
||
3 years ago
|
created() {
|
||
3 years ago
|
this.loadTriggerList();
|
||
4 years ago
|
},
|
||
3 years ago
|
mounted() {},
|
||
3 years ago
|
beforeDestroy() {
|
||
3 years ago
|
console.log('triggerlist before destroy');
|
||
4 years ago
|
},
|
||
3 years ago
|
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', 'newTable', 'deleteTable', 'isMetaTable'],
|
||
|
};
|
||
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/>.
|
||
|
*
|
||
|
*/
|
||
|
-->
|