Skip to content
Snippets Groups Projects
Verified Commit 57d89d41 authored by Kirill Stytsenko's avatar Kirill Stytsenko
Browse files

WiP on QueryResults table on query details page

For now there is not information needed for displaying the header of the table.
i.e. user-friendly titles, etc.
parent 3bc119fe
No related branches found
No related tags found
3 merge requests!81New stable release,!43Merge dev to master,!41UI March
...@@ -140,7 +140,7 @@ export default { ...@@ -140,7 +140,7 @@ export default {
} }
}, },
execute () { execute () {
this.$refs.queryResults.execute(this) this.$refs.queryResults.executeFirstTime(this)
}, },
async buildQuery () { async buildQuery () {
if (!this.table) { if (!this.table) {
......
...@@ -12,6 +12,9 @@ ...@@ -12,6 +12,9 @@
import _ from 'lodash' import _ from 'lodash'
export default { export default {
props: {
value: { type: Number, default: () => 0 }
},
data () { data () {
return { return {
parent: null, parent: null,
...@@ -40,7 +43,9 @@ export default { ...@@ -40,7 +43,9 @@ export default {
}, },
watch: { watch: {
value () { value () {
this.execute() if (this.value) {
this.execute()
}
}, },
options (newVal, oldVal) { options (newVal, oldVal) {
if (typeof oldVal.groupBy === 'undefined') { if (typeof oldVal.groupBy === 'undefined') {
...@@ -48,17 +53,18 @@ export default { ...@@ -48,17 +53,18 @@ export default {
// don't run the execute method twice, when a new query is created // don't run the execute method twice, when a new query is created
return return
} }
if (!this.value) {
this.$toast.error('Cannot paginate invalidated Query: press Execute')
return
}
this.execute() this.execute()
} }
}, },
mounted () { mounted () {
}, },
methods: { methods: {
async execute (parent) { async executeFirstTime (parent) {
if (parent) { this.parent = parent
this.parent = parent
}
this.loading = true this.loading = true
try { try {
const data = { const data = {
...@@ -69,10 +75,7 @@ export default { ...@@ -69,10 +75,7 @@ export default {
})] })]
} }
console.debug('send data', data) console.debug('send data', data)
let page = this.options.page - 1 const page = 0
if (!this.parent.queryId) {
page = 0
}
const urlParams = `page=${page}&size=${this.options.itemsPerPage}` const urlParams = `page=${page}&size=${this.options.itemsPerPage}`
const res = await this.$axios.put(`/api/container/ const res = await this.$axios.put(`/api/container/
${this.$route.params.container_id}/database/${this.$route.params.database_id}/query ${this.$route.params.container_id}/database/${this.$route.params.database_id}/query
...@@ -94,6 +97,30 @@ ${this.parent.queryId ? `/${this.parent.queryId}` : ''} ...@@ -94,6 +97,30 @@ ${this.parent.queryId ? `/${this.parent.queryId}` : ''}
this.$toast.error('Could not execute query') this.$toast.error('Could not execute query')
this.loading = false this.loading = false
} }
},
async execute () {
this.loading = true
try {
const page = this.options.page - 1
const urlParams = `page=${page}&size=${this.options.itemsPerPage}`
const res = await this.$axios.put(`/api/container/
${this.$route.params.container_id}/database/${this.$route.params.database_id}/query
/${this.value}
?${urlParams}`, {}, {
headers: this.headers
})
this.loading = false
// Can't display headers yet
// this.result.headers = this.parent.select.map((s) => {
// return { text: s.name, value: s.name, sortable: false }
// })
this.result.rows = res.data.result
this.total = res.data.resultNumber
} catch (err) {
console.error('query execute', err)
this.$toast.error('Could not execute query')
this.loading = false
}
} }
} }
} }
......
...@@ -70,6 +70,7 @@ ...@@ -70,6 +70,7 @@
Username: <code v-if="query.username">{{ query.username }}</code><span v-if="!query.username">(empty)</span> Username: <code v-if="query.username">{{ query.username }}</code><span v-if="!query.username">(empty)</span>
</p> </p>
</v-card-text> </v-card-text>
<QueryResults v-if="false" ref="queryResults" v-model="query.id" />
</v-card> </v-card>
<v-breadcrumbs :items="items" class="pa-0 mt-2" /> <v-breadcrumbs :items="items" class="pa-0 mt-2" />
<v-dialog <v-dialog
...@@ -164,6 +165,11 @@ export default { ...@@ -164,6 +165,11 @@ export default {
this.loading = false this.loading = false
} }
this.loading = false this.loading = false
// refresh QueryResults table
setTimeout(() => {
// this.$refs.queryResults.execute()
}, 200)
}, },
async reExecute () { async reExecute () {
try { try {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment