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.
270 lines
6.7 KiB
270 lines
6.7 KiB
3 years ago
|
<template>
|
||
|
<v-container class="ma-0 pa-0" fluid>
|
||
|
<v-toolbar height="42" class="toolbar-border-bottom elevation-0">
|
||
3 years ago
|
<v-breadcrumbs
|
||
2 years ago
|
:items="[
|
||
|
{
|
||
|
text: nodes.env,
|
||
|
disabled: true,
|
||
|
href: '#',
|
||
|
},
|
||
|
{
|
||
|
text: nodes.dbAlias,
|
||
|
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>
|
||
|
|
||
2 years ago
|
<p class="pt-3">Seed Database</p>
|
||
3 years ago
|
|
||
3 years ago
|
<v-spacer />
|
||
3 years ago
|
|
||
3 years ago
|
<x-btn small icon="mdi-numeric-1-circle" outlined color="primary" @click="dialogShow = true">
|
||
|
Seed Initialise
|
||
|
</x-btn>
|
||
3 years ago
|
<!-- <x-btn outlined @click="seedTerm" color="red"> Clear all tables</x-btn>-->
|
||
2 years ago
|
<x-btn small outlined icon="mdi-play" color="primary" @click="seedStart"> Start Seeding </x-btn>
|
||
|
<x-btn small outlined icon="mdi-stop" @click="seedStop"> Stop Seeding </x-btn>
|
||
3 years ago
|
<x-btn small outlined :disabled="disableSaveButton" icon="save" @click="seedSettingsUpdate">
|
||
|
Save Settings
|
||
|
</x-btn>
|
||
3 years ago
|
</v-toolbar>
|
||
|
|
||
|
<v-row class="mx-0">
|
||
|
<v-col cols="8" offset="2">
|
||
|
<v-simple-table class="ma-0 pa-0">
|
||
|
<thead>
|
||
3 years ago
|
<tr>
|
||
2 years ago
|
<th class="text-left" width="20%">Key</th>
|
||
|
<th class="text-left">Value</th>
|
||
3 years ago
|
</tr>
|
||
3 years ago
|
</thead>
|
||
|
<tbody>
|
||
2 years ago
|
<tr v-for="(value, key) in settings" :key="key">
|
||
3 years ago
|
<td>{{ key }}</td>
|
||
|
<td>
|
||
|
<v-text-field
|
||
|
v-model="settings[key].value"
|
||
|
:label="settings[key].description"
|
||
|
hide-details
|
||
|
type="number"
|
||
|
step="1"
|
||
|
@input="disableSaveButton = false"
|
||
|
/>
|
||
|
<!-- <p class="caption">{{settings[key].description}}</p>-->
|
||
|
</td>
|
||
|
</tr>
|
||
3 years ago
|
</tbody>
|
||
|
</v-simple-table>
|
||
|
</v-col>
|
||
|
</v-row>
|
||
|
|
||
|
<dlgLabelSubmitCancel
|
||
|
v-if="dialogShow"
|
||
3 years ago
|
:dialog-show="dialogShow"
|
||
|
:actions-mtd="dlgAction"
|
||
|
css-style="border:1px solid grey;height:300px"
|
||
3 years ago
|
heading="This will recreate all the faker function mapping!"
|
||
|
type="info"
|
||
|
/>
|
||
|
</v-container>
|
||
|
</template>
|
||
|
|
||
|
<script>
|
||
2 years ago
|
import { mapGetters } from 'vuex';
|
||
|
import dlgLabelSubmitCancel from '../utils/DlgLabelSubmitCancel';
|
||
3 years ago
|
|
||
|
export default {
|
||
|
components: {
|
||
2 years ago
|
dlgLabelSubmitCancel,
|
||
3 years ago
|
},
|
||
3 years ago
|
data() {
|
||
3 years ago
|
return {
|
||
|
settings: {},
|
||
|
dialogShow: false,
|
||
2 years ago
|
disableSaveButton: true,
|
||
|
};
|
||
3 years ago
|
},
|
||
|
computed: {
|
||
2 years ago
|
...mapGetters({ sqlMgr: 'sqlMgr/sqlMgr' }),
|
||
3 years ago
|
},
|
||
|
watch: {},
|
||
3 years ago
|
async created() {
|
||
3 years ago
|
this.seedsFolder = this.sqlMgr.projectGetFolder({
|
||
|
env: this.nodes.env,
|
||
2 years ago
|
dbAlias: this.nodes.dbAlias,
|
||
|
});
|
||
3 years ago
|
const result = await this.$store.dispatch('sqlMgr/ActSqlOpPlus', [
|
||
|
{
|
||
|
env: this.nodes.env,
|
||
2 years ago
|
dbAlias: this.nodes.dbAlias,
|
||
3 years ago
|
},
|
||
|
'seedSettingsRead',
|
||
|
{
|
||
2 years ago
|
seedsFolder: this.seedsFolder,
|
||
|
},
|
||
|
]);
|
||
3 years ago
|
|
||
|
if (!Object.keys(result.data).length) {
|
||
2 years ago
|
await this.seedInit();
|
||
3 years ago
|
} else {
|
||
2 years ago
|
this.settings = result.data;
|
||
3 years ago
|
}
|
||
|
},
|
||
2 years ago
|
mounted() {},
|
||
|
beforeDestroy() {},
|
||
3 years ago
|
methods: {
|
||
3 years ago
|
async dlgAction(action = '') {
|
||
2 years ago
|
console.log('dlgAction', action);
|
||
3 years ago
|
if (action === 'hideDialog') {
|
||
2 years ago
|
this.dialogShow = false;
|
||
3 years ago
|
} else {
|
||
2 years ago
|
this.dialogShow = false;
|
||
|
await this.seedInit();
|
||
3 years ago
|
}
|
||
3 years ago
|
},
|
||
3 years ago
|
async seedInit() {
|
||
3 years ago
|
try {
|
||
|
const result = await this.$store.dispatch('sqlMgr/ActSqlOpPlus', [
|
||
|
{
|
||
|
env: this.nodes.env,
|
||
2 years ago
|
dbAlias: this.nodes.dbAlias,
|
||
3 years ago
|
},
|
||
|
'seedInit',
|
||
|
{
|
||
2 years ago
|
seedsFolder: this.seedsFolder,
|
||
|
},
|
||
|
]);
|
||
3 years ago
|
|
||
2 years ago
|
this.settings = result.data;
|
||
3 years ago
|
} catch (e) {
|
||
2 years ago
|
console.log(e);
|
||
|
throw e;
|
||
3 years ago
|
}
|
||
3 years ago
|
},
|
||
|
|
||
3 years ago
|
async seedTerm() {
|
||
3 years ago
|
try {
|
||
|
await this.$store.dispatch('sqlMgr/ActSqlOpPlus', [
|
||
|
{
|
||
|
env: this.nodes.env,
|
||
2 years ago
|
dbAlias: this.nodes.dbAlias,
|
||
3 years ago
|
},
|
||
|
'seedTerm',
|
||
|
{
|
||
2 years ago
|
seedsFolder: this.seedsFolder,
|
||
|
},
|
||
|
]);
|
||
3 years ago
|
} catch (e) {
|
||
2 years ago
|
console.log(e);
|
||
|
throw e;
|
||
3 years ago
|
}
|
||
|
},
|
||
3 years ago
|
|
||
3 years ago
|
async seedStart() {
|
||
3 years ago
|
try {
|
||
2 years ago
|
setTimeout(async () => {
|
||
3 years ago
|
await this.$store.dispatch('sqlMgr/ActSqlOpPlus', [
|
||
3 years ago
|
{
|
||
|
env: this.nodes.env,
|
||
2 years ago
|
dbAlias: this.nodes.dbAlias,
|
||
3 years ago
|
},
|
||
3 years ago
|
'seedStart',
|
||
3 years ago
|
{
|
||
2 years ago
|
seedsFolder: this.seedsFolder,
|
||
|
},
|
||
|
]);
|
||
|
});
|
||
3 years ago
|
} catch (e) {
|
||
2 years ago
|
console.log(e);
|
||
|
throw e;
|
||
3 years ago
|
}
|
||
|
},
|
||
3 years ago
|
|
||
3 years ago
|
async seedStop() {
|
||
3 years ago
|
try {
|
||
|
await this.$store.dispatch('sqlMgr/ActSqlOpPlus', [
|
||
|
{
|
||
3 years ago
|
env: this.nodes.env,
|
||
2 years ago
|
dbAlias: this.nodes.dbAlias,
|
||
3 years ago
|
},
|
||
|
'seedStop',
|
||
|
{
|
||
2 years ago
|
seedsFolder: this.seedsFolder,
|
||
|
},
|
||
|
]);
|
||
3 years ago
|
} catch (e) {
|
||
2 years ago
|
console.log(e);
|
||
|
throw e;
|
||
3 years ago
|
}
|
||
|
},
|
||
|
|
||
3 years ago
|
async seedSettingsUpdate() {
|
||
3 years ago
|
try {
|
||
2 years ago
|
this.settings.rows.value = +this.settings.rows.value > 100 ? 100 : this.settings.rows.value;
|
||
3 years ago
|
|
||
2 years ago
|
await this.$store.dispatch('sqlMgr/ActSqlOpPlus', [
|
||
|
{
|
||
|
env: this.nodes.env,
|
||
|
dbAlias: this.nodes.dbAlias,
|
||
|
},
|
||
|
'seedSettingsCreate',
|
||
|
{
|
||
|
seedsFolder: this.seedsFolder,
|
||
|
settings: this.settings,
|
||
|
},
|
||
|
]);
|
||
|
this.disableSaveButton = true;
|
||
3 years ago
|
} catch (e) {
|
||
2 years ago
|
console.log(e);
|
||
|
throw e;
|
||
3 years ago
|
}
|
||
2 years ago
|
},
|
||
3 years ago
|
},
|
||
|
|
||
2 years ago
|
beforeCreated() {},
|
||
|
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/>.
|
||
|
*
|
||
|
*/
|
||
|
-->
|