Skip to content
Snippets Groups Projects
Commit 6615183f authored by Kirill Stytsenko's avatar Kirill Stytsenko
Browse files

Add table column list component

parent 29d1b44d
No related branches found
No related tags found
No related merge requests found
...@@ -206,4 +206,4 @@ services: ...@@ -206,4 +206,4 @@ services:
- fda-database-service - fda-database-service
environment: environment:
HOST: 0.0.0.0 HOST: 0.0.0.0
API_URL: //fda-database-managing-service:9092/api API_URL: //fda-gateway-service:9095/api
# .env SAMPLE
# DB Service API url # DB Service API url
# API_URL="//localhost:9092/api" API_URL="//localhost:9095/api"
# API_URL="//localhost:9092/api"
<template> <template>
<div> <v-expansion-panels v-model="panelIndex" accordion>
List of Tables <v-expansion-panel v-for="(item,i) in tables" :key="i">
<v-expansion-panel-header>{{ item.name }}</v-expansion-panel-header>
<v-expansion-panel-content>
ID: {{ item.id }}<br>
Internal Name: {{ item.internalName }}<br>
<div v-if="tableDetails">
Description: {{ tableDetails.description }}<br>
<v-simple-table class="colTable">
<thead>
<th>Column Name</th>
<th>Type</th>
<th>Primary Key</th>
<th>Null Allowed</th>
</thead>
<tbody>
<tr v-for="(col, idx) in tableDetails.columns" :key="idx">
<td class="pl-0">{{ col.name }}</td>
<td class="pl-0">{{ col.columnType }}</td>
<td class="pl-0"><v-simple-checkbox v-model="col.isPrimaryKey" disabled /></td>
<td class="pl-0"><v-simple-checkbox v-model="col.isNullAllowed" disabled /></td>
</tr>
</tbody>
</v-simple-table>
</div> </div>
</v-expansion-panel-content>
</v-expansion-panel>
</v-expansion-panels>
</template> </template>
<script> <script>
export default {
data () {
return {
tables: [],
panelIndex: undefined,
tableDetails: null
}
},
watch: {
async panelIndex () {
if (typeof this.panelIndex !== 'undefined') {
console.log('watch panelIndex id: ' + this.panelIndex)
const tableId = this.tables[this.panelIndex].id
try {
const res = await this.$axios.get(`http://localhost:9094/api/database/${this.$route.params.db_id}/table/${tableId}`)
this.tableDetails = res.data[0] // It's a list with one element
console.log(this.tableDetails)
} catch (err) {
this.$toast.error('Could not get table details.')
}
} else {
this.tableDetails = null
}
}
},
async mounted () {
let res
try {
res = await this.$axios.get(`http://localhost:9094/api/database/${this.$route.params.db_id}/table`)
this.tables = res.data
console.log(this.tables)
} catch (err) {
this.$toast.error('Could not list tables.')
}
}
// methods: {
// onTableExpand () {
// debugger
// }
// }
}
</script> </script>
<style> <style>
.colTable thead th {
text-align: initial;
}
</style> </style>
...@@ -42,7 +42,7 @@ export default { ...@@ -42,7 +42,7 @@ export default {
return { return {
formValid: false, formValid: false,
loading: false, loading: false,
database: 'Foo Bar', database: '',
engine: { engine: {
label: 'PostgreSQL, latest', label: 'PostgreSQL, latest',
repo: 'postgres', repo: 'postgres',
......
...@@ -69,7 +69,7 @@ export default { ...@@ -69,7 +69,7 @@ export default {
// Axios module configuration (https://go.nuxtjs.dev/config-axios) // Axios module configuration (https://go.nuxtjs.dev/config-axios)
axios: { axios: {
// baseURL: process.env.API_URL.startsWith('//') ? `http:${process.env.API_URL}` : process.env.API_URL baseURL: process.env.API_URL.startsWith('//') ? `http:${process.env.API_URL}` : process.env.API_URL
}, },
// Vuetify module configuration (https://go.nuxtjs.dev/config-vuetify) // Vuetify module configuration (https://go.nuxtjs.dev/config-vuetify)
......
...@@ -4,7 +4,7 @@ ...@@ -4,7 +4,7 @@
<h2> <h2>
{{ db.name }} {{ db.name }}
</h2> </h2>
<v-btn :to="`/db/${$route.params.id}/tables`">Tables</v-btn> <v-btn :to="`/db/${$route.params.db_id}/tables`">Tables</v-btn>
</v-col> </v-col>
</v-row> </v-row>
</template> </template>
...@@ -19,7 +19,7 @@ export default { ...@@ -19,7 +19,7 @@ export default {
}, },
async mounted () { async mounted () {
try { try {
const res = await this.$axios.get(`http://localhost:9092/api/database/${this.$route.params.id}`) const res = await this.$axios.get(`http://localhost:9092/api/database/${this.$route.params.db_id}`)
this.db = res.data this.db = res.data
} catch (err) { } catch (err) {
this.$toast.error('Could not load database.') this.$toast.error('Could not load database.')
......
File moved
File moved
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment