gancio-upstream/components/DbStep.vue

52 lines
1.7 KiB
Vue
Raw Normal View History

2021-09-27 11:12:14 +02:00
<template lang="pug">
2022-07-01 15:55:09 +02:00
v-container
v-card-title.text-h5 Database
v-card-text
v-form
v-btn-toggle(text color='primary' v-model='db.dialect')
v-btn(value='sqlite' text) sqlite
v-btn(value='postgres' text) postgres
v-btn(value='mariadb' text) mariadb
template(v-if='db.dialect === "sqlite"')
v-text-field(v-model='db.storage' label='Path')
template(v-if='db.dialect !== "sqlite"')
v-text-field(v-model='db.host' label='Hostname' :rules="[$validators.required('hostname')]")
v-text-field(v-model='db.database' label='Database' :rules="[$validators.required('database')]")
v-text-field(v-model='db.username' label='Username' :rules="[$validators.required('username')]")
v-text-field(type='password' v-model='db.password' label='Password' :rules="[$validators.required('password')]")
2021-09-27 11:12:14 +02:00
2022-07-01 15:55:09 +02:00
v-card-actions
v-btn(text @click='checkDb' color='primary' :loading='loading' :disabled='loading') {{$t('common.next')}}
v-icon(v-text='mdiArrowRight')
2021-09-27 11:12:14 +02:00
</template>
<script>
import { mdiArrowRight } from '@mdi/js'
2021-09-27 11:12:14 +02:00
export default {
data () {
return {
mdiArrowRight,
2021-09-27 11:12:14 +02:00
db: {
2022-01-26 09:51:42 +01:00
dialect: 'sqlite',
2021-09-27 11:12:14 +02:00
storage: './gancio.sqlite',
2021-12-09 09:29:39 +01:00
host: 'localhost',
2021-09-27 11:12:14 +02:00
database: 'gancio'
},
2021-10-19 17:59:09 +02:00
loading: false
2021-09-27 11:12:14 +02:00
}
},
methods: {
async checkDb () {
this.loading = true
try {
await this.$axios.$post('/setup/db', { db: this.db })
this.$root.$message('DB Connection OK!', { color: 'success' })
this.$emit('complete', this.db)
} catch (e) {
this.$root.$message(e.response.data, { color: 'error' })
}
this.loading = false
}
}
}
</script>