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.
175 lines
4.6 KiB
175 lines
4.6 KiB
4 years ago
|
<template>
|
||
|
<v-container>
|
||
|
<h1>Relation List</h1>
|
||
2 years ago
|
<v-btn color="primary" @click="loadRelationList">
|
||
|
<v-icon left> refresh </v-icon>
|
||
3 years ago
|
<!-- Reload -->
|
||
|
{{ $t('general.reload') }}
|
||
3 years ago
|
</v-btn>
|
||
2 years ago
|
<v-btn small class="text-right" @click="deleteTable('showDialog')">
|
||
3 years ago
|
{{ $t('activity.deleteTable') }}
|
||
3 years ago
|
</v-btn>
|
||
2 years ago
|
<v-btn @click="throwError()"> error </v-btn>
|
||
4 years ago
|
<v-row>
|
||
|
<v-col cols="6">
|
||
2 years ago
|
<v-data-table :headers="relationHeaders" :items="relations" footer-props.items-per-page-options="30">
|
||
3 years ago
|
<template #item="props">
|
||
4 years ago
|
<td>{{ props.item.cstn }}</td>
|
||
|
<td>{{ props.item.rtn }}</td>
|
||
|
</template>
|
||
|
</v-data-table>
|
||
|
</v-col>
|
||
|
<v-col cols="6">
|
||
2 years ago
|
<v-data-table :headers="columnHeaders" :items="columns" footer-props.items-per-page-options="30">
|
||
3 years ago
|
<template #items="props">
|
||
3 years ago
|
<td>{{ props.item.column_name }}</td>
|
||
4 years ago
|
</template>
|
||
|
</v-data-table>
|
||
|
</v-col>
|
||
|
</v-row>
|
||
3 years ago
|
</v-container>
|
||
4 years ago
|
</template>
|
||
|
|
||
|
<script>
|
||
2 years ago
|
import { mapGetters } from 'vuex';
|
||
4 years ago
|
|
||
3 years ago
|
export default {
|
||
3 years ago
|
data() {
|
||
3 years ago
|
return {
|
||
|
relations: [],
|
||
|
columns: [],
|
||
|
relationHeaders: [
|
||
|
{
|
||
|
text: 'Relation',
|
||
2 years ago
|
sortable: false,
|
||
3 years ago
|
},
|
||
|
{
|
||
|
text: 'Referenced Table',
|
||
2 years ago
|
sortable: false,
|
||
|
},
|
||
3 years ago
|
],
|
||
|
columnHeaders: [
|
||
|
{
|
||
|
text: 'Column',
|
||
2 years ago
|
sortable: false,
|
||
|
},
|
||
3 years ago
|
],
|
||
2 years ago
|
max25chars: v => v.length <= 25 || 'Input too long!',
|
||
|
};
|
||
3 years ago
|
},
|
||
|
methods: {
|
||
3 years ago
|
throwError() {
|
||
2 years ago
|
throw new Error('new erroror ');
|
||
4 years ago
|
},
|
||
3 years ago
|
async loadRelationList() {
|
||
2 years ago
|
if (this.newTable) {
|
||
|
return;
|
||
|
}
|
||
4 years ago
|
|
||
3 years ago
|
// console.log("env: this.nodes.env", this.nodes.env, this.nodes.dbAlias);
|
||
|
// const client = await this.sqlMgr.projectGetSqlClient({
|
||
|
// env: this.nodes.env,
|
||
|
// dbAlias: this.nodes.dbAlias
|
||
|
// });
|
||
|
// const result = await client.relationList({
|
||
3 years ago
|
// table_name: this.nodes.table_name
|
||
3 years ago
|
// });
|
||
|
//
|
||
4 years ago
|
|
||
3 years ago
|
// const result = await this.sqlMgr.sqlOp({
|
||
|
// env: this.nodes.env,
|
||
|
// dbAlias: this.nodes.dbAlias
|
||
3 years ago
|
// }, 'relationList', { table_name: this.nodes.table_name})
|
||
4 years ago
|
|
||
2 years ago
|
const result = await this.$store.dispatch('sqlMgr/ActSqlOp', [
|
||
|
{
|
||
|
env: this.nodes.env,
|
||
|
dbAlias: this.nodes.dbAlias,
|
||
|
},
|
||
|
'relationList',
|
||
|
{ table_name: this.nodes.table_name },
|
||
|
]);
|
||
4 years ago
|
|
||
3 years ago
|
// console.log(result, "relations");
|
||
2 years ago
|
this.relations = result.data.list;
|
||
3 years ago
|
// this.loadColumnList(result.data.list[0].rtn);
|
||
|
},
|
||
3 years ago
|
async loadColumnList(table_name = '') {
|
||
3 years ago
|
// console.log("env: this.nodes.env", this.nodes.env, this.nodes.dbAlias);
|
||
|
// const client = await this.sqlMgr.projectGetSqlClient({
|
||
|
// env: this.nodes.env,
|
||
|
// dbAlias: this.nodes.dbAlias
|
||
|
// });
|
||
|
// const result = await client.columnList({
|
||
3 years ago
|
// table_name
|
||
3 years ago
|
// });
|
||
4 years ago
|
|
||
3 years ago
|
// const result = await this.sqlMgr.sqlOp({
|
||
|
// env: this.nodes.env,
|
||
|
// dbAlias: this.nodes.dbAlias
|
||
|
// }, 'columnList', {
|
||
3 years ago
|
// table_name
|
||
3 years ago
|
// });
|
||
4 years ago
|
|
||
2 years ago
|
const result = await this.$store.dispatch('sqlMgr/ActSqlOp', [
|
||
|
{
|
||
|
env: this.nodes.env,
|
||
|
dbAlias: this.nodes.dbAlias,
|
||
|
},
|
||
|
'columnList',
|
||
|
{
|
||
|
table_name,
|
||
|
},
|
||
|
]);
|
||
4 years ago
|
|
||
2 years ago
|
this.columns = result.data.list;
|
||
|
},
|
||
3 years ago
|
},
|
||
|
computed: { ...mapGetters({ sqlMgr: 'sqlMgr/sqlMgr' }) },
|
||
4 years ago
|
|
||
2 years ago
|
beforeCreated() {},
|
||
3 years ago
|
watch: {},
|
||
3 years ago
|
created() {
|
||
2 years ago
|
this.loadRelationList();
|
||
3 years ago
|
},
|
||
2 years ago
|
mounted() {},
|
||
|
beforeDestroy() {},
|
||
|
destroy() {},
|
||
3 years ago
|
directives: {},
|
||
|
components: {},
|
||
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', 'newTable', 'deleteTable'],
|
||
|
};
|
||
4 years ago
|
</script>
|
||
|
|
||
2 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/>.
|
||
|
*
|
||
|
*/
|
||
|
-->
|