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.
335 lines
9.1 KiB
335 lines
9.1 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
|
||
|
:items="[{
|
||
|
text: nodes.env,
|
||
|
disabled: true,
|
||
|
href: '#'
|
||
|
},{
|
||
|
text: nodes.dbAlias,
|
||
|
disabled: true,
|
||
|
href: '#'
|
||
|
},
|
||
|
{
|
||
|
text: originalNodes.sequence_name + ' (sequence)',
|
||
|
disabled: true,
|
||
|
href: '#'
|
||
|
}]"
|
||
|
divider=">"
|
||
|
small
|
||
|
>
|
||
|
<template #divider>
|
||
|
<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>
|
||
|
<br>
|
||
|
<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>
|
||
|
<th class="text-left">
|
||
|
Name
|
||
|
</th>
|
||
|
<th class="text-left">
|
||
|
Value
|
||
|
</th>
|
||
|
</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"
|
||
|
:rules="[v=> !!v || 'Value required']"
|
||
|
@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>
|
||
|
<th class="text-left">
|
||
|
Name
|
||
|
</th>
|
||
|
<th class="text-left">
|
||
|
Value
|
||
|
</th>
|
||
|
</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'"
|
||
|
:rules="[v=> !!v || 'Value required']"
|
||
|
@input="sequenceNameChanged()"
|
||
|
/>
|
||
|
</td>
|
||
|
</tr>
|
||
|
<tr
|
||
|
v-for="(item,key,i) in sequence"
|
||
|
:key="i"
|
||
|
:style="key ==='sequence_name' ? 'display:none' : ''"
|
||
|
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: '',
|
||
|
dialogShow: false
|
||
|
}
|
||
|
},
|
||
|
computed: {
|
||
|
...mapGetters({ sqlMgr: 'sqlMgr/sqlMgr' })
|
||
|
},
|
||
|
methods: {
|
||
|
...mapActions({
|
||
|
loadSequencesFromChildTreeNode:
|
||
|
'project/loadSequencesFromChildTreeNode',
|
||
|
loadSequencesFromParentTreeNode:
|
||
|
'project/loadSequencesFromParentTreeNode',
|
||
|
removeSequenceTab: 'tabs/removeSequenceTab'
|
||
|
}),
|
||
3 years ago
|
async loadSequences() {
|
||
3 years ago
|
try {
|
||
|
this.$store.commit('notification/MutToggleProgressBar', true)
|
||
|
if (this.newSequence) {
|
||
|
this.sequence = {
|
||
|
sequence_name: this.originalNodes.sequence_name
|
||
4 years ago
|
}
|
||
3 years ago
|
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) }
|
||
|
} catch (e) {
|
||
|
console.log(e)
|
||
|
this.$toast.error('Loading sequence failed')
|
||
|
} finally {
|
||
|
this.$store.commit('notification/MutToggleProgressBar', false)
|
||
|
}
|
||
|
},
|
||
3 years ago
|
async applyChanges() {
|
||
3 years ago
|
try {
|
||
|
if (this.newSequence) {
|
||
|
const result = await this.$store.dispatch('sqlMgr/ActSqlOpPlus', [
|
||
|
{
|
||
|
env: this.nodes.env,
|
||
|
dbAlias: this.nodes.dbAlias
|
||
|
},
|
||
|
'sequenceCreate',
|
||
|
this.sequence])
|
||
4 years ago
|
|
||
3 years ago
|
await this.loadSequencesFromChildTreeNode({
|
||
|
_nodes: {
|
||
|
...this.nodes
|
||
|
}
|
||
|
})
|
||
|
this.originalNodes.sequence_name = this.sequence.sequence_name
|
||
|
this.newSequence = false
|
||
|
await this.loadSequences()
|
||
|
this.$toast.success('Sequence created successfully').goAway(3000)
|
||
|
} else {
|
||
|
const result = await this.$store.dispatch('sqlMgr/ActSqlOpPlus', [
|
||
|
{
|
||
|
env: this.nodes.env,
|
||
|
dbAlias: this.nodes.dbAlias
|
||
|
},
|
||
|
'sequenceUpdate',
|
||
|
this.sequence
|
||
|
])
|
||
4 years ago
|
|
||
3 years ago
|
this.$toast.success('Sequence updated successfully').goAway(3000)
|
||
4 years ago
|
}
|
||
3 years ago
|
} catch (e) {
|
||
|
this.$toast.error('Saving sequence failed').goAway(3000)
|
||
|
throw e
|
||
|
}
|
||
|
},
|
||
3 years ago
|
async deleteSequence(action = '') {
|
||
3 years ago
|
try {
|
||
|
if (action === 'showDialog') {
|
||
|
this.dialogShow = true
|
||
|
} else if (action === 'hideDialog') {
|
||
|
this.dialogShow = false
|
||
|
} else {
|
||
|
await this.$store.dispatch('sqlMgr/ActSqlOpPlus', [
|
||
|
{
|
||
4 years ago
|
env: this.nodes.env,
|
||
3 years ago
|
dbAlias: this.nodes.dbAlias
|
||
|
},
|
||
|
'sequenceDelete',
|
||
|
{
|
||
4 years ago
|
sequence_name: this.originalNodes.sequence_name
|
||
3 years ago
|
}])
|
||
4 years ago
|
|
||
3 years ago
|
this.removeSequenceTab({
|
||
|
env: this.nodes.env,
|
||
|
dbAlias: this.nodes.dbAlias,
|
||
|
sequence_name: this.originalNodes.sequence_name
|
||
|
})
|
||
|
await this.loadSequencesFromParentTreeNode({
|
||
|
_nodes: {
|
||
|
...this.nodes
|
||
|
}
|
||
|
})
|
||
|
this.dialogShow = false
|
||
|
this.$toast.success('Sequence deleted successfully').goAway(3000)
|
||
|
}
|
||
|
} catch (e) {
|
||
|
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
|
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
|
mounted() {
|
||
3 years ago
|
},
|
||
3 years ago
|
beforeDestroy() {
|
||
3 years ago
|
},
|
||
3 years ago
|
destroy() {
|
||
3 years ago
|
},
|
||
|
directives: {},
|
||
3 years ago
|
validate({ params }) {
|
||
3 years ago
|
return true
|
||
|
},
|
||
3 years ago
|
head() {
|
||
3 years ago
|
return {}
|
||
|
},
|
||
|
props: ['nodes']
|
||
|
}
|
||
4 years ago
|
</script>
|
||
|
|
||
|
<style scoped>
|
||
|
</style>
|
||
|
<!--
|
||
|
/**
|
||
|
* @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/>.
|
||
|
*
|
||
|
*/
|
||
|
-->
|