Skip to content
Snippets Groups Projects
Verified Commit 0c4c35ce authored by Martin Weise's avatar Martin Weise
Browse files

Fixed the view create bug

parent da765ef7
No related branches found
No related tags found
1 merge request!374Bumped version of DBRepo
No preview for this file type
<template>
<v-alert
v-cloak
v-if="timestamp && offSeconds > 3"
class="banner"
border="start"
type="warning">
{{ $t('error.data.drift') + ' ' + offSeconds + 's' }}
</v-alert>
</template>
<script>
import { formatTimestamp, timestampsToHumanDifference } from '@/utils'
export default {
data () {
return {
timestamp: null
}
},
computed: {
drift () {
return this.timestampsToHumanDifference(Date.now(), this.timestamp)
},
offSeconds () {
if (!this.timestamp) {
return null
}
return (Date.now().valueOf() - Date.parse(this.timestamp)) / 1000
}
},
mounted() {
const databaseService = useDatabaseService()
databaseService.getServerTime()
.then((timestamp) => {
this.timestamp = timestamp
})
},
methods: {
formatTimestamp,
timestampsToHumanDifference
}
}
</script>
......@@ -31,14 +31,12 @@
:text="$t('pages.subset.subpages.create.expert.text')" />
</v-tabs>
</v-toolbar>
<TimeDrift />
<v-card
rounded="0"
variant="flat">
<v-card-text>
<v-form
ref="form"
v-model="valid"
@submit.prevent>
<v-row
v-if="isView"
......@@ -304,7 +302,6 @@
</template>
<script>
import TimeDrift from '@/components/TimeDrift.vue'
import Raw from '@/components/subset/Raw.vue'
import Results from '@/components/subset/Results.vue'
import { useCacheStore } from '@/stores/cache.js'
......@@ -314,7 +311,6 @@ export default {
components: {
Raw,
Results,
TimeDrift
},
props: {
mode: {
......@@ -468,7 +464,7 @@ export default {
if (!this.table) {
return
}
this.fetchTableColumns(this.table.id)
this.fetchTableColumns(this.table?.id)
}
},
mounted () {
......@@ -545,9 +541,11 @@ export default {
this.view.query = this.sql
const viewService = useViewService()
viewService.create(this.$route.params.database_id, this.view)
.then((simpleView) => {
this.resultId = simpleView.id
viewService.findOne(this.$route.params.database_id, simpleView.id)
.then(async (view) => {
this.resultId = view.id
this.cacheStore.reloadDatabase()
this.cacheStore.setView(view)
const toast = useToastInstance()
toast.success(this.$t('success.view.create'))
await this.$router.push(`/database/${this.$route.params.database_id}/view/${view.id}/data`)
......@@ -561,6 +559,15 @@ export default {
}
toast.error(this.$t(code))
})
})
.catch(({code}) => {
this.loadingQuery = false
const toast = useToastInstance()
if (typeof code !== 'string') {
return
}
toast.error(this.$t(code))
})
},
buildQuery () {
if (!this.table) {
......
......@@ -80,23 +80,6 @@ export default {
}
},
methods: {
executeFirstTime (parent, sql, timestamp) {
this.loading++
const payload = {
statement: sql,
timestamp
}
const queryService = useQueryService()
queryService.execute(this.$route.params.database_id, payload, this.options.page - 1, this.options.itemsPerPage)
.then((result) => {
this.mapResults(result)
parent.resultId = result.id
this.id = result.id
})
.finally(() => {
this.loading--
})
},
reExecute (id) {
if (id === null) {
return
......
......@@ -66,23 +66,6 @@ export const useDatabaseService = (): any => {
});
}
async function getServerTime(): Promise<Date> {
const axios = useAxiosInstance();
console.debug('find server time');
return new Promise<Date>((resolve, reject) => {
axios.head<Date>('/api/database')
.then((response) => {
const date: Date = new Date(response.headers['Date'])
console.info(`Found ${date} server time`);
resolve(date);
})
.catch((error) => {
console.error('Failed to find server time', error);
reject(axiosErrorToApiError(error));
});
});
}
async function findOne(id: number, rawError: boolean = false): Promise<DatabaseDto | null> {
const axios = useAxiosInstance();
console.debug('find database with id', id);
......@@ -239,16 +222,12 @@ export const useDatabaseService = (): any => {
refreshTablesMetadata,
refreshViewsMetadata,
findOne,
findPreviewImage,
findCount,
getServerTime,
updateVisibility,
updateImage,
updateOwner,
create,
databaseToOwner,
databaseToContact,
databaseToJsonLd,
isOwner
}
}
......@@ -161,12 +161,12 @@ export const useQueryService = (): any => {
}
}
sql += ` \`${clause.params[0]}\` ${clause.params[1]} `
const filteredType = types.filter(t => t.value === filteredColumn[0].column_type)
const filteredType = types.filter(t => t.value === filteredColumn[0].type)
if (filteredType.length === 0) {
return {
error: true,
reason: 'exists',
column: filteredColumn[0].column_type,
column: filteredColumn[0].type,
raw: null,
formatted: null
}
......@@ -175,7 +175,7 @@ export const useQueryService = (): any => {
return {
error: true,
reason: 'build',
column: filteredColumn[0].column_type,
column: filteredColumn[0].type,
raw: null,
formatted: null
}
......
......@@ -16,6 +16,12 @@ if (process.env.NODE_ENV === 'development') {
}
process.env.VERSION = 'bun-dev'
process.env.NUXT_PUBLIC_API_SERVER = api
process.env.NUXT_OIDC_PROVIDERS_KEYCLOAK_AUTHORIZATION_URL = api + '/realms/dbrepo/protocol/openid-connect/auth'
process.env.NUXT_OIDC_PROVIDERS_KEYCLOAK_LOGOUT_REDIRECT_URI = api + ':3001'
process.env.NUXT_OIDC_PROVIDERS_KEYCLOAK_LOGOUT_URL = api + '/realms/dbrepo/protocol/openid-connect/logout'
process.env.NUXT_OIDC_PROVIDERS_KEYCLOAK_REDIRECT_URI = api + ':3001/auth/keycloak/callback'
process.env.NUXT_OIDC_PROVIDERS_KEYCLOAK_TOKEN_URL = api + '/realms/dbrepo/protocol/openid-connect/token'
process.env.NUXT_OIDC_PROVIDERS_KEYCLOAK_USER_INFO_URL = api + '/realms/dbrepo/protocol/openid-connect/userinfo'
}
/**
......
......@@ -22,7 +22,6 @@
:loading="loadingData"
@click="reload" />
</v-toolbar>
<TimeDrift />
<v-card tile>
<QueryResults
id="query-results"
......@@ -35,13 +34,11 @@
</template>
<script>
import TimeDrift from '@/components/TimeDrift.vue'
import QueryResults from '@/components/subset/Results.vue'
export default {
components: {
QueryResults,
TimeDrift
QueryResults
},
data () {
return {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment