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.
259 lines
7.0 KiB
259 lines
7.0 KiB
4 years ago
|
<template>
|
||
|
<div class="">
|
||
3 years ago
|
<v-overlay v-if="isMetaTable" absolute>
|
||
2 years ago
|
<v-alert type="info"> Meta tables are not editable </v-alert>
|
||
4 years ago
|
</v-overlay>
|
||
|
<v-card class="elevation-0">
|
||
|
<v-toolbar height="42" flat 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: nodes.view_name + ' (view)',
|
||
|
disabled: true,
|
||
|
href: '#',
|
||
|
},
|
||
|
]"
|
||
3 years ago
|
divider=">"
|
||
|
small
|
||
|
class="title"
|
||
|
>
|
||
|
<template #divider>
|
||
2 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
|
||
2 years ago
|
v-ge="['columns', 'reload']"
|
||
3 years ago
|
tooltip="Reload Columns from database"
|
||
|
outlined
|
||
|
color="primary"
|
||
|
small
|
||
|
@click="loadColumnList"
|
||
4 years ago
|
>
|
||
2 years ago
|
<v-icon small left> refresh </v-icon>
|
||
4 years ago
|
Re<u>l</u>oad
|
||
|
</x-btn>
|
||
|
</v-toolbar>
|
||
|
<div class="d-flex justify-center">
|
||
|
<v-data-table
|
||
|
dense
|
||
|
:headers="headers"
|
||
|
:items="columns"
|
||
|
hide-default-header
|
||
2 years ago
|
class="column-table flex-shrink-1"
|
||
|
style="min-width: 60%"
|
||
4 years ago
|
>
|
||
2 years ago
|
<template #header="{ props: { headers } }">
|
||
4 years ago
|
<tr>
|
||
3 years ago
|
<th
|
||
|
v-for="header in headers"
|
||
|
:key="header.title"
|
||
|
class="pt-2 pb-0 text-center"
|
||
2 years ago
|
style="white-space: nowrap"
|
||
|
:style="{ minWidth: header.width, width: header.width }"
|
||
4 years ago
|
>
|
||
|
<v-tooltip bottom>
|
||
3 years ago
|
<template #activator="{ on }">
|
||
4 years ago
|
<span v-on="on">{{ header.text }}</span>
|
||
|
</template>
|
||
|
<span>{{ header.title }}</span>
|
||
|
</v-tooltip>
|
||
|
</th>
|
||
|
</tr>
|
||
|
</template>
|
||
|
|
||
3 years ago
|
<template #item="props">
|
||
2 years ago
|
<tr :disabled="nodes.view_name === '_evolutions' || nodes.view_name === 'nc_evolutions'">
|
||
|
<td ref="column" :title="props.item.column_name" style="width: 200px">
|
||
4 years ago
|
<div class="d-flex">
|
||
|
|
||
3 years ago
|
<v-icon
|
||
|
small
|
||
|
:class="{
|
||
2 years ago
|
'green--text': props.item.pk,
|
||
3 years ago
|
}"
|
||
|
>
|
||
2 years ago
|
{{ getColumnIcon(props.item) }} </v-icon
|
||
|
>
|
||
3 years ago
|
{{ props.item.column_name }}
|
||
4 years ago
|
</div>
|
||
|
</td>
|
||
|
<td class="pa-0 text-center">
|
||
|
{{ props.item.dt }}
|
||
|
</td>
|
||
|
<td class="pa-0 text-center">
|
||
|
{{ props.item.dtxp }}
|
||
|
</td>
|
||
|
</tr>
|
||
|
</template>
|
||
|
</v-data-table>
|
||
|
</div>
|
||
|
</v-card>
|
||
|
</div>
|
||
|
</template>
|
||
|
|
||
|
<script>
|
||
2 years ago
|
import { mapGetters } from 'vuex';
|
||
4 years ago
|
|
||
|
export default {
|
||
|
components: {},
|
||
3 years ago
|
data() {
|
||
4 years ago
|
return {
|
||
|
columns: [],
|
||
|
dataTypes: [],
|
||
|
headers: [
|
||
|
{
|
||
3 years ago
|
text: 'Column',
|
||
|
title: 'Column name',
|
||
|
value: 'cn',
|
||
4 years ago
|
sortable: false,
|
||
2 years ago
|
width: '1%',
|
||
4 years ago
|
},
|
||
3 years ago
|
{ text: 'Data Type', title: 'Data Type', value: 'dt', sortable: false, width: '10%' },
|
||
2 years ago
|
{ text: 'Length/Values', title: 'Length/Values', value: 'dt', sortable: false, width: '5%' },
|
||
|
],
|
||
|
};
|
||
4 years ago
|
},
|
||
|
methods: {
|
||
3 years ago
|
getColumnIcon(column) {
|
||
4 years ago
|
if (column.pk) {
|
||
2 years ago
|
return 'mdi-key';
|
||
4 years ago
|
} else if (column.rcn) {
|
||
2 years ago
|
return 'mdi-link-variant';
|
||
4 years ago
|
} else {
|
||
2 years ago
|
return 'mdi-gate-or';
|
||
4 years ago
|
}
|
||
|
},
|
||
|
|
||
3 years ago
|
async loadColumnList() {
|
||
2 years ago
|
this.$store.commit('notification/MutToggleProgressBar', true);
|
||
4 years ago
|
try {
|
||
2 years ago
|
this.edited = false;
|
||
4 years ago
|
if (this.newTable) {
|
||
2 years ago
|
this.columns = this.sqlUi.getNewTableColumns();
|
||
|
return;
|
||
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: this.nodes.view_name,
|
||
|
},
|
||
|
]);
|
||
|
console.log('table ', result.data.list);
|
||
|
const columns = result.data.list;
|
||
4 years ago
|
|
||
2 years ago
|
this.columns = JSON.parse(JSON.stringify(columns));
|
||
|
this.originalColumns = [...columns];
|
||
|
console.log(this.columns);
|
||
4 years ago
|
} catch (e) {
|
||
2 years ago
|
console.log(e);
|
||
|
this.$toast.error('Error loading columns :' + e).goAway(4000);
|
||
|
throw e;
|
||
4 years ago
|
} finally {
|
||
2 years ago
|
this.$store.commit('notification/MutToggleProgressBar', false);
|
||
4 years ago
|
}
|
||
|
},
|
||
3 years ago
|
async loadDataTypes() {
|
||
4 years ago
|
try {
|
||
2 years ago
|
const result = await this.$store.dispatch('sqlMgr/ActSqlOp', [
|
||
|
{
|
||
|
env: this.nodes.env,
|
||
|
dbAlias: this.nodes.dbAlias,
|
||
|
},
|
||
|
'getKnexDataTypes',
|
||
|
{},
|
||
|
]);
|
||
4 years ago
|
|
||
2 years ago
|
this.dataTypes = result.data.list;
|
||
4 years ago
|
} catch (e) {
|
||
2 years ago
|
this.$toast.error('Error loading datatypes :' + e).goAway(4000);
|
||
|
throw e;
|
||
4 years ago
|
}
|
||
2 years ago
|
},
|
||
4 years ago
|
},
|
||
|
computed: {
|
||
|
...mapGetters({
|
||
3 years ago
|
sqlMgr: 'sqlMgr/sqlMgr',
|
||
|
currentProjectFolder: 'project/currentProjectFolder',
|
||
|
projectIsGraphql: 'project/GtrProjectIsGraphql',
|
||
|
isNoApis: 'project/GtrProjectIsNoApis',
|
||
2 years ago
|
isMvc: 'project/GtrIsMvc',
|
||
|
}),
|
||
4 years ago
|
},
|
||
|
|
||
2 years ago
|
beforeCreated() {},
|
||
3 years ago
|
watch: {},
|
||
3 years ago
|
async created() {
|
||
3 years ago
|
// try {
|
||
2 years ago
|
await this.loadColumnList();
|
||
3 years ago
|
// } catch (e) {
|
||
|
// throw e
|
||
|
// } finally {
|
||
|
//
|
||
|
// }
|
||
4 years ago
|
},
|
||
2 years ago
|
mounted() {},
|
||
|
beforeDestroy() {},
|
||
|
destroy() {},
|
||
3 years ago
|
directives: {},
|
||
3 years ago
|
validate({ params }) {
|
||
2 years ago
|
return true;
|
||
4 years ago
|
},
|
||
3 years ago
|
head() {
|
||
2 years ago
|
return {};
|
||
4 years ago
|
},
|
||
2 years ago
|
props: ['nodes', 'newTable', 'mtdNewTableUpdate', 'deleteTable', 'isMetaTable'],
|
||
|
};
|
||
4 years ago
|
</script>
|
||
|
|
||
|
<style scoped>
|
||
|
/* to apply 6-9 columns */
|
||
2 years ago
|
/deep/ .column-table td:nth-child(n + 5):not(:nth-child(n + 10)),
|
||
|
/deep/ .column-table th:nth-child(n + 5):not(:nth-child(n + 10)) {
|
||
4 years ago
|
width: 30px;
|
||
|
padding: 0;
|
||
|
}
|
||
|
</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/>.
|
||
|
*
|
||
|
*/
|
||
|
-->
|