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.
327 lines
9.0 KiB
327 lines
9.0 KiB
4 years ago
|
<template>
|
||
|
<v-container fluid class="pa-0 ma-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: originalNodes.sequence_name + ' (sequence)',
|
||
|
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
|
||
|
outlined
|
||
|
tooltip="Reload Sequences"
|
||
|
small
|
||
|
color="primary"
|
||
|
icon="refresh"
|
||
|
:disabled="newSequence"
|
||
|
@click="loadSequences()"
|
||
|
>
|
||
3 years ago
|
<!-- Reload -->
|
||
|
{{ $t('general.reload') }}
|
||
4 years ago
|
</x-btn>
|
||
3 years ago
|
<x-btn
|
||
|
outlined
|
||
3 years ago
|
:tooltip="$t('tooltip.saveChanges')"
|
||
3 years ago
|
small
|
||
|
color="primary"
|
||
|
icon="save"
|
||
|
:disabled="!(newSequence || edited)"
|
||
|
@click="applyChanges()"
|
||
|
>
|
||
3 years ago
|
<!-- Save -->
|
||
|
{{ $t('general.save') }}
|
||
4 years ago
|
</x-btn>
|
||
3 years ago
|
<x-btn
|
||
|
outlined
|
||
|
tooltip="Delete Sequence"
|
||
|
small
|
||
|
color="error"
|
||
|
icon="mdi-delete-outline"
|
||
|
@click="deleteSequence('showDialog')"
|
||
|
>
|
||
4 years ago
|
Delete Sequence
|
||
|
</x-btn>
|
||
|
</v-toolbar>
|
||
3 years ago
|
<br />
|
||
4 years ago
|
<v-row>
|
||
|
<v-col cols="8" offset="2">
|
||
|
<v-simple-table v-if="newSequence">
|
||
3 years ago
|
<template #default>
|
||
4 years ago
|
<thead>
|
||
3 years ago
|
<tr>
|
||
3 years ago
|
<th class="text-left">Name</th>
|
||
|
<th class="text-left">Value</th>
|
||
3 years ago
|
</tr>
|
||
4 years ago
|
</thead>
|
||
|
<tbody>
|
||
3 years ago
|
<tr class="pa-1">
|
||
|
<td>sequence_name</td>
|
||
|
<td class="pb-2 pt-1 pr-1">
|
||
|
<v-row />
|
||
|
<v-text-field
|
||
|
v-model="sequence.sequence_name"
|
||
3 years ago
|
:rules="[v => !!v || 'Value required']"
|
||
3 years ago
|
@input="sequenceNameChanged()"
|
||
|
/>
|
||
|
</td>
|
||
|
</tr>
|
||
4 years ago
|
</tbody>
|
||
|
</template>
|
||
|
</v-simple-table>
|
||
|
|
||
|
<v-simple-table v-else>
|
||
3 years ago
|
<template #default>
|
||
4 years ago
|
<thead>
|
||
3 years ago
|
<tr>
|
||
3 years ago
|
<th class="text-left">Name</th>
|
||
|
<th class="text-left">Value</th>
|
||
3 years ago
|
</tr>
|
||
4 years ago
|
</thead>
|
||
|
<tbody>
|
||
3 years ago
|
<tr>
|
||
|
<td>sequence_name</td>
|
||
|
<td class="pb-2 pt-1 pr-1">
|
||
|
<v-text-field
|
||
|
v-model="sequence.sequence_name"
|
||
|
:disabled="nodes.dbConnection.client === 'mssql'"
|
||
3 years ago
|
:rules="[v => !!v || 'Value required']"
|
||
3 years ago
|
@input="sequenceNameChanged()"
|
||
|
/>
|
||
|
</td>
|
||
|
</tr>
|
||
|
<tr
|
||
3 years ago
|
v-for="(item, key, i) in sequence"
|
||
3 years ago
|
:key="i"
|
||
3 years ago
|
:style="key === 'sequence_name' ? 'display:none' : ''"
|
||
3 years ago
|
class="grey--text"
|
||
|
>
|
||
|
<td>{{ key }}</td>
|
||
|
<td>
|
||
|
{{ item }}
|
||
|
</td>
|
||
|
</tr>
|
||
4 years ago
|
</tbody>
|
||
|
</template>
|
||
|
</v-simple-table>
|
||
|
</v-col>
|
||
|
</v-row>
|
||
|
<dlgLabelSubmitCancel
|
||
|
v-if="dialogShow"
|
||
3 years ago
|
type="error"
|
||
|
:dialog-show="dialogShow"
|
||
|
css-style="border:1px solid grey;height:300px"
|
||
|
:actions-mtd="deleteSequence"
|
||
4 years ago
|
heading="Click Submit to Delete the Sequence"
|
||
|
/>
|
||
|
</v-container>
|
||
|
</template>
|
||
|
|
||
|
<script>
|
||
3 years ago
|
import { mapGetters, mapActions } from 'vuex';
|
||
4 years ago
|
|
||
3 years ago
|
import dlgLabelSubmitCancel from '../utils/DlgLabelSubmitCancel';
|
||
4 years ago
|
|
||
3 years ago
|
export default {
|
||
|
components: { dlgLabelSubmitCancel },
|
||
3 years ago
|
data() {
|
||
3 years ago
|
return {
|
||
|
edited: false,
|
||
|
originalNodes: {},
|
||
|
sequence: {},
|
||
|
newSequence: !!this.nodes.newSequence,
|
||
|
oldCreateSequence: '',
|
||
3 years ago
|
dialogShow: false,
|
||
|
};
|
||
3 years ago
|
},
|
||
|
computed: {
|
||
3 years ago
|
...mapGetters({ sqlMgr: 'sqlMgr/sqlMgr' }),
|
||
3 years ago
|
},
|
||
|
methods: {
|
||
|
...mapActions({
|
||
3 years ago
|
loadSequencesFromChildTreeNode: 'project/loadSequencesFromChildTreeNode',
|
||
|
loadSequencesFromParentTreeNode: 'project/loadSequencesFromParentTreeNode',
|
||
|
removeSequenceTab: 'tabs/removeSequenceTab',
|
||
3 years ago
|
}),
|
||
3 years ago
|
async loadSequences() {
|
||
3 years ago
|
try {
|
||
3 years ago
|
this.$store.commit('notification/MutToggleProgressBar', true);
|
||
3 years ago
|
if (this.newSequence) {
|
||
|
this.sequence = {
|
||
3 years ago
|
sequence_name: this.originalNodes.sequence_name,
|
||
|
};
|
||
|
this.$store.commit('notification/MutToggleProgressBar', false);
|
||
|
return;
|
||
4 years ago
|
}
|
||
|
|
||
3 years ago
|
const result = await this.sqlMgr.sqlOp(
|
||
|
{
|
||
|
env: this.nodes.env,
|
||
|
dbAlias: this.nodes.dbAlias,
|
||
|
},
|
||
|
'sequenceList',
|
||
|
{ sequence_name: this.originalNodes.sequence_name }
|
||
|
);
|
||
4 years ago
|
|
||
3 years ago
|
this.sequence = { ...result.data.list.find(seq => seq.sequence_name === this.originalNodes.sequence_name) };
|
||
3 years ago
|
} catch (e) {
|
||
3 years ago
|
console.log(e);
|
||
|
this.$toast.error('Loading sequence failed');
|
||
3 years ago
|
} finally {
|
||
3 years ago
|
this.$store.commit('notification/MutToggleProgressBar', false);
|
||
3 years ago
|
}
|
||
|
},
|
||
3 years ago
|
async applyChanges() {
|
||
3 years ago
|
try {
|
||
|
if (this.newSequence) {
|
||
|
const result = await this.$store.dispatch('sqlMgr/ActSqlOpPlus', [
|
||
|
{
|
||
|
env: this.nodes.env,
|
||
3 years ago
|
dbAlias: this.nodes.dbAlias,
|
||
3 years ago
|
},
|
||
|
'sequenceCreate',
|
||
3 years ago
|
this.sequence,
|
||
|
]);
|
||
4 years ago
|
|
||
3 years ago
|
await this.loadSequencesFromChildTreeNode({
|
||
|
_nodes: {
|
||
3 years ago
|
...this.nodes,
|
||
|
},
|
||
|
});
|
||
|
this.originalNodes.sequence_name = this.sequence.sequence_name;
|
||
|
this.newSequence = false;
|
||
|
await this.loadSequences();
|
||
|
this.$toast.success('Sequence created successfully').goAway(3000);
|
||
3 years ago
|
} else {
|
||
|
const result = await this.$store.dispatch('sqlMgr/ActSqlOpPlus', [
|
||
|
{
|
||
|
env: this.nodes.env,
|
||
3 years ago
|
dbAlias: this.nodes.dbAlias,
|
||
3 years ago
|
},
|
||
|
'sequenceUpdate',
|
||
3 years ago
|
this.sequence,
|
||
|
]);
|
||
4 years ago
|
|
||
3 years ago
|
this.$toast.success('Sequence updated successfully').goAway(3000);
|
||
4 years ago
|
}
|
||
3 years ago
|
} catch (e) {
|
||
3 years ago
|
this.$toast.error('Saving sequence failed').goAway(3000);
|
||
|
throw e;
|
||
3 years ago
|
}
|
||
|
},
|
||
3 years ago
|
async deleteSequence(action = '') {
|
||
3 years ago
|
try {
|
||
|
if (action === 'showDialog') {
|
||
3 years ago
|
this.dialogShow = true;
|
||
3 years ago
|
} else if (action === 'hideDialog') {
|
||
3 years ago
|
this.dialogShow = false;
|
||
3 years ago
|
} else {
|
||
|
await this.$store.dispatch('sqlMgr/ActSqlOpPlus', [
|
||
|
{
|
||
4 years ago
|
env: this.nodes.env,
|
||
3 years ago
|
dbAlias: this.nodes.dbAlias,
|
||
3 years ago
|
},
|
||
|
'sequenceDelete',
|
||
|
{
|
||
3 years ago
|
sequence_name: this.originalNodes.sequence_name,
|
||
|
},
|
||
|
]);
|
||
4 years ago
|
|
||
3 years ago
|
this.removeSequenceTab({
|
||
|
env: this.nodes.env,
|
||
|
dbAlias: this.nodes.dbAlias,
|
||
3 years ago
|
sequence_name: this.originalNodes.sequence_name,
|
||
|
});
|
||
3 years ago
|
await this.loadSequencesFromParentTreeNode({
|
||
|
_nodes: {
|
||
3 years ago
|
...this.nodes,
|
||
|
},
|
||
|
});
|
||
|
this.dialogShow = false;
|
||
|
this.$toast.success('Sequence deleted successfully').goAway(3000);
|
||
3 years ago
|
}
|
||
|
} catch (e) {
|
||
3 years ago
|
this.$toast.error('Deleting sequence failed').goAway(3000);
|
||
|
throw e;
|
||
4 years ago
|
}
|
||
|
},
|
||
3 years ago
|
sequenceNameChanged() {
|
||
3 years ago
|
this.edited = this.sequence.sequence_name.trim() !== '';
|
||
|
},
|
||
3 years ago
|
},
|
||
3 years ago
|
beforeCreated() {},
|
||
3 years ago
|
watch: {
|
||
|
// 'sequence' : {
|
||
|
// deep:true,
|
||
|
// handler(n,o) {
|
||
|
// console.log('watch sequence',n,o);
|
||
|
// if(o.sequence_name)
|
||
|
// this.edited = true;
|
||
|
// }
|
||
|
// }
|
||
|
},
|
||
3 years ago
|
async created() {
|
||
3 years ago
|
this.originalNodes = { ...this.nodes };
|
||
|
await this.loadSequences();
|
||
3 years ago
|
},
|
||
3 years ago
|
mounted() {},
|
||
|
beforeDestroy() {},
|
||
|
destroy() {},
|
||
3 years ago
|
directives: {},
|
||
3 years ago
|
validate({ params }) {
|
||
3 years ago
|
return true;
|
||
3 years ago
|
},
|
||
3 years ago
|
head() {
|
||
3 years ago
|
return {};
|
||
3 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/>.
|
||
|
*
|
||
|
*/
|
||
|
-->
|