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

Handle whitespace in CreateDB #131

Former-commit-id: f4f117af
parent 310bce2d
No related branches found
No related tags found
No related merge requests found
...@@ -18,7 +18,7 @@ ...@@ -18,7 +18,7 @@
name="database" name="database"
label="Name *" label="Name *"
autofocus autofocus
:rules="[v => !!v || $t('Required')]" :rules="[v => notEmpty(v) || $t('Required')]"
required /> required />
<v-textarea <v-textarea
id="description" id="description"
...@@ -26,7 +26,7 @@ ...@@ -26,7 +26,7 @@
name="description" name="description"
rows="2" rows="2"
label="Description *" label="Description *"
:rules="[v => !!v || $t('Required')]" :rules="[v => notEmpty(v) || $t('Required')]"
required /> required />
<v-select <v-select
id="engine" id="engine"
...@@ -120,6 +120,9 @@ export default { ...@@ -120,6 +120,9 @@ export default {
setTimeout(resolve, ms) setTimeout(resolve, ms)
}) })
}, },
notEmpty (str) {
return typeof str === 'string' && str.trim().length > 0
},
async createDB () { async createDB () {
let res let res
// create a container // create a container
...@@ -129,8 +132,8 @@ export default { ...@@ -129,8 +132,8 @@ export default {
this.loading = true this.loading = true
this.error = false this.error = false
res = await this.$axios.post('/api/container', { res = await this.$axios.post('/api/container', {
name: this.database, name: this.database.trim(),
description: this.description, description: this.description.trim(),
repository: this.engine.repository, repository: this.engine.repository,
tag: this.engine.tag tag: this.engine.tag
}, { }, {
...@@ -156,9 +159,10 @@ export default { ...@@ -156,9 +159,10 @@ export default {
try { try {
this.loading = true this.loading = true
this.error = false this.error = false
res = await this.$axios.put(`/api/container/${containerId}`, { action: 'START' }, { res = await this.$axios.put(`/api/container/${containerId}`,
headers: { Authorization: `Bearer ${this.token}` } { action: 'START' }, {
}) headers: { Authorization: `Bearer ${this.token}` }
})
console.debug('started container', res.data) console.debug('started container', res.data)
} catch (err) { } catch (err) {
this.error = true this.error = true
...@@ -176,8 +180,8 @@ export default { ...@@ -176,8 +180,8 @@ export default {
for (let i = 0; i < 5; i++) { for (let i = 0; i < 5; i++) {
try { try {
res = await this.$axios.post(`/api/container/${containerId}/database`, { res = await this.$axios.post(`/api/container/${containerId}/database`, {
name: this.database, name: this.database.trim(),
description: this.description, description: this.description.trim(),
is_public: this.isPublic is_public: this.isPublic
}, { }, {
headers: { Authorization: `Bearer ${this.token}` } headers: { Authorization: `Bearer ${this.token}` }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment