diff --git a/fda-ui/components/QueryList.vue b/fda-ui/components/QueryList.vue index 4e2c5a6eb8e3a4b328634b21261794dab3356637..1b1cad9609d22096c1b3049db3acf4f24c0f41cc 100644 --- a/fda-ui/components/QueryList.vue +++ b/fda-ui/components/QueryList.vue @@ -70,7 +70,7 @@ </v-row> <v-row dense> <v-col> - <v-btn color="primary" :to="`/databases/${$route.params.database_id}/tables/${item.id}`" disabled> + <v-btn color="primary" :to="`/databases/${$route.params.database_id}/queries/${item.id}`"> <v-icon left>mdi-run</v-icon> Execute Again </v-btn> </v-col> diff --git a/fda-ui/components/dialogs/CreateDB.vue b/fda-ui/components/dialogs/CreateDB.vue index ed5e242be0ff669b98734d4e3b103e42638978d8..44dc2864750d752e9609420c92713d59b1c40b44 100644 --- a/fda-ui/components/dialogs/CreateDB.vue +++ b/fda-ui/components/dialogs/CreateDB.vue @@ -89,7 +89,10 @@ export default { let res try { res = await this.$axios.get('/api/image/') - this.engines = res.data + this.engines = res.data.map((e) => { + e.disabled = (e.id !== 3) + return e + }) console.debug('engines', this.engines) } catch (err) { this.$toast.error('Failed to fetch supported engines. Try reload the page.') diff --git a/fda-ui/components/query/Builder.vue b/fda-ui/components/query/Builder.vue index aa2a9f7c60206e620e0bb20e4725867818eef213..e6d01bf97093b84dc442b6014104d1e698ec1dff 100644 --- a/fda-ui/components/query/Builder.vue +++ b/fda-ui/components/query/Builder.vue @@ -97,7 +97,7 @@ export default { }, methods: { async execute () { - const query = this.query.sql.replaceAll('"', '') + const query = this.query.sql.replaceAll('`', '') this.loading = true try { const res = await this.$axios.put(`/api/database/${this.$route.params.database_id}/query`, { diff --git a/fda-ui/pages/databases/_database_id/queries/_query_id/index.vue b/fda-ui/pages/databases/_database_id/queries/_query_id/index.vue new file mode 100644 index 0000000000000000000000000000000000000000..3cd6e8e5cd9ffa34d1535d0a42e11333e005fa58 --- /dev/null +++ b/fda-ui/pages/databases/_database_id/queries/_query_id/index.vue @@ -0,0 +1,56 @@ +<template> + <div> + <v-card> + <v-card-title v-if="!loading"> + Result of Query #{{ id }} + </v-card-title> + <v-card-subtitle v-if="!loading"> + <code v-if="hash">{{ hash }}</code> + </v-card-subtitle> + <v-data-table + :headers="headers" + :items="rows" + :loading="loading" + :items-per-page="30" + class="elevation-1" /> + </v-card> + </div> +</template> +<script> +export default { + name: 'QueryShow', + components: { + }, + data () { + return { + id: this.$route.params.query_id, + hash: null, + loading: true, + table: null, + headers: [], + rows: [] + } + }, + mounted () { + this.loadData() + }, + methods: { + async loadData () { + try { + const res = await this.$axios.get(`/api/database/${this.$route.params.database_id}/query/${this.$route.params.query_id}`) + this.headers = Object.keys(res.data.result[0]).map((c) => { + return { text: c, value: c } + }) + this.rows = res.data.result + console.debug('query data', res.data) + } catch (err) { + this.$toast.error('Could not load table data.') + } + this.loading = false + } + } +} +</script> + +<style> +</style> diff --git a/fda-ui/server-middleware/query/index.js b/fda-ui/server-middleware/query/index.js index 9cf322c330cb0b762650be1d3f6171d26098a39b..bb688815c9e00a0f95d8adbb4b914597f4258994 100644 --- a/fda-ui/server-middleware/query/index.js +++ b/fda-ui/server-middleware/query/index.js @@ -1,5 +1,5 @@ const { format } = require('sql-formatter') -const knex = require('knex')({ client: 'pg' }) +const knex = require('knex')({ client: 'mysql' }) export function buildQuery ({ table, select, clauses }) { const builder = knex(table)