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
3 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
|
||
2 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>
|
||
2 years ago
|
<v-icon small color="grey lighten-2"> forward </v-icon>
|
||
3 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') }}
|
||
3 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') }}
|
||
3 years ago
|
</x-btn>
|
||
3 years ago
|
<x-btn
|
||
|
outlined
|
||
|
tooltip="Delete Sequence"
|
||
|
small
|
||
|
color="error"
|
||
|
icon="mdi-delete-outline"
|
||
|
@click="deleteSequence('showDialog')"
|
||
|
>
|
||
3 years ago
|
Delete Sequence
|
||
|
</x-btn>
|
||
|
</v-toolbar>
|
||
2 years ago
|
<br />
|
||
3 years ago
|
<v-row>
|
||
|
<v-col cols="8" offset="2">
|
||
|
<v-simple-table v-if="newSequence">
|
||
3 years ago
|
<template #default>
|
||
3 years ago
|
<thead>
|
||
3 years ago
|
<tr>
|
||
2 years ago
|
<th class="text-left">Name</th>
|
||
|
<th class="text-left">Value</th>
|
||
3 years ago
|
</tr>
|
||
3 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"
|
||
2 years ago
|
:rules="[v => !!v || 'Value required']"
|
||
3 years ago
|
@input="sequenceNameChanged()"
|
||
|
/>
|
||
|
</td>
|
||
|
</tr>
|
||
3 years ago
|
</tbody>
|
||
|
</template>
|
||
|
</v-simple-table>
|
||
|
|
||
|
<v-simple-table v-else>
|
||
3 years ago
|
<template #default>
|
||
3 years ago
|
<thead>
|
||
3 years ago
|
<tr>
|
||
2 years ago
|
<th class="text-left">Name</th>
|
||
|
<th class="text-left">Value</th>
|
||
3 years ago
|
</tr>
|
||
3 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'"
|
||
2 years ago
|
:rules="[v => !!v || 'Value required']"
|
||
3 years ago
|
@input="sequenceNameChanged()"
|
||
|
/>
|
||
|
</td>
|
||
|
</tr>
|
||
|
<tr
|
||
2 years ago
|
v-for="(item, key, i) in sequence"
|
||
3 years ago
|
:key="i"
|
||
2 years ago
|
:style="key === 'sequence_name' ? 'display:none' : ''"
|
||
3 years ago
|
class="grey--text"
|
||
|
>
|
||
|
<td>{{ key }}</td>
|
||
|
<td>
|
||
|
{{ item }}
|
||
|
</td>
|
||
|
</tr>
|
||
3 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"
|
||
3 years ago
|
heading="Click Submit to Delete the Sequence"
|
||
|
/>
|
||
|
</v-container>
|
||
|
</template>
|
||
|
|
||
|
<script>
|
||
2 years ago
|
import { mapGetters, mapActions } from 'vuex';
|
||
3 years ago
|
|
||
2 years ago
|
import dlgLabelSubmitCancel from '../utils/DlgLabelSubmitCancel';
|
||
3 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: '',
|
||
2 years ago
|
dialogShow: false,
|
||
|
};
|
||
3 years ago
|
},
|
||
|
computed: {
|
||
2 years ago
|
...mapGetters({ sqlMgr: 'sqlMgr/sqlMgr' }),
|
||
3 years ago
|
},
|
||
|
methods: {
|
||
|
...mapActions({
|
||
2 years ago
|
loadSequencesFromChildTreeNode: 'project/loadSequencesFromChildTreeNode',
|
||
|
loadSequencesFromParentTreeNode: 'project/loadSequencesFromParentTreeNode',
|
||
|
removeSequenceTab: 'tabs/removeSequenceTab',
|
||
3 years ago
|
}),
|
||
3 years ago
|
async loadSequences() {
|
||
3 years ago
|
try {
|
||
2 years ago
|
this.$store.commit('notification/MutToggleProgressBar', true);
|
||
3 years ago
|
if (this.newSequence) {
|
||
|
this.sequence = {
|
||
2 years ago
|
sequence_name: this.originalNodes.sequence_name,
|
||
|
};
|
||
|
this.$store.commit('notification/MutToggleProgressBar', false);
|
||
|
return;
|
||
3 years ago
|
}
|
||
|
|
||
2 years ago
|
const result = await this.sqlMgr.sqlOp(
|
||
|
{
|
||
|
env: this.nodes.env,
|
||
|
dbAlias: this.nodes.dbAlias,
|
||
|
},
|
||
|
'sequenceList',
|
||
|
{ sequence_name: this.originalNodes.sequence_name }
|
||
|
);
|
||
3 years ago
|
|
||
2 years ago
|
this.sequence = { ...result.data.list.find(seq => seq.sequence_name === this.originalNodes.sequence_name) };
|
||
3 years ago
|
} catch (e) {
|
||
2 years ago
|
console.log(e);
|
||
|
this.$toast.error('Loading sequence failed');
|
||
3 years ago
|
} finally {
|
||
2 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,
|
||
2 years ago
|
dbAlias: this.nodes.dbAlias,
|
||
3 years ago
|
},
|
||
|
'sequenceCreate',
|
||
2 years ago
|
this.sequence,
|
||
|
]);
|
||
3 years ago
|
|
||
3 years ago
|
await this.loadSequencesFromChildTreeNode({
|
||
|
_nodes: {
|
||
2 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,
|
||
2 years ago
|
dbAlias: this.nodes.dbAlias,
|
||
3 years ago
|
},
|
||
|
'sequenceUpdate',
|
||
2 years ago
|
this.sequence,
|
||
|
]);
|
||
3 years ago
|
|
||
2 years ago
|
this.$toast.success('Sequence updated successfully').goAway(3000);
|
||
3 years ago
|
}
|
||
3 years ago
|
} catch (e) {
|
||
2 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') {
|
||
2 years ago
|
this.dialogShow = true;
|
||
3 years ago
|
} else if (action === 'hideDialog') {
|
||
2 years ago
|
this.dialogShow = false;
|
||
3 years ago
|
} else {
|
||
|
await this.$store.dispatch('sqlMgr/ActSqlOpPlus', [
|
||
|
{
|
||
3 years ago
|
env: this.nodes.env,
|
||
2 years ago
|
dbAlias: this.nodes.dbAlias,
|
||
3 years ago
|
},
|
||
|
'sequenceDelete',
|
||
|
{
|
||
2 years ago
|
sequence_name: this.originalNodes.sequence_name,
|
||
|
},
|
||
|
]);
|
||
3 years ago
|
|
||
3 years ago
|
this.removeSequenceTab({
|
||
|
env: this.nodes.env,
|
||
|
dbAlias: this.nodes.dbAlias,
|
||
2 years ago
|
sequence_name: this.originalNodes.sequence_name,
|
||
|
});
|
||
3 years ago
|
await this.loadSequencesFromParentTreeNode({
|
||
|
_nodes: {
|
||
2 years ago
|
...this.nodes,
|
||
|
},
|
||
|
});
|
||
|
this.dialogShow = false;
|
||
|
this.$toast.success('Sequence deleted successfully').goAway(3000);
|
||
3 years ago
|
}
|
||
|
} catch (e) {
|
||
2 years ago
|
this.$toast.error('Deleting sequence failed').goAway(3000);
|
||
|
throw e;
|
||
3 years ago
|
}
|
||
|
},
|
||
3 years ago
|
sequenceNameChanged() {
|
||
2 years ago
|
this.edited = this.sequence.sequence_name.trim() !== '';
|
||
|
},
|
||
3 years ago
|
},
|
||
2 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() {
|
||
2 years ago
|
this.originalNodes = { ...this.nodes };
|
||
|
await this.loadSequences();
|
||
3 years ago
|
},
|
||
2 years ago
|
mounted() {},
|
||
|
beforeDestroy() {},
|
||
|
destroy() {},
|
||
3 years ago
|
directives: {},
|
||
3 years ago
|
validate({ params }) {
|
||
2 years ago
|
return true;
|
||
3 years ago
|
},
|
||
3 years ago
|
head() {
|
||
2 years ago
|
return {};
|
||
3 years ago
|
},
|
||
2 years ago
|
props: ['nodes'],
|
||
|
};
|
||
3 years ago
|
</script>
|
||
|
|
||
2 years ago
|
<style scoped></style>
|
||
3 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/>.
|
||
|
*
|
||
|
*/
|
||
|
-->
|