From 4cc61594799235376ad9c738058ae90fe7b40945 Mon Sep 17 00:00:00 2001
From: axolotle
Date: Sat, 10 Apr 2021 17:33:47 +0200
Subject: [PATCH 1/3] add ability to not query /installed in login component
---
app/src/views/Login.vue | 7 ++++++-
app/src/views/PostInstall.vue | 2 +-
2 files changed, 7 insertions(+), 2 deletions(-)
diff --git a/app/src/views/Login.vue b/app/src/views/Login.vue
index 63d61815..190447d6 100644
--- a/app/src/views/Login.vue
+++ b/app/src/views/Login.vue
@@ -32,9 +32,13 @@
export default {
name: 'Login',
+ props: {
+ skipInstallCheck: { type: Boolean, default: false }
+ },
+
data () {
return {
- disabled: true,
+ disabled: !this.skipInstallCheck,
password: '',
isValid: null,
apiError: undefined
@@ -51,6 +55,7 @@ export default {
},
created () {
+ if (this.skipInstallCheck) return
this.$store.dispatch('CHECK_INSTALL').then(installed => {
if (installed) {
this.disabled = false
diff --git a/app/src/views/PostInstall.vue b/app/src/views/PostInstall.vue
index 8edcae6a..4682e30a 100644
--- a/app/src/views/PostInstall.vue
+++ b/app/src/views/PostInstall.vue
@@ -48,7 +48,7 @@
{{ $t('installation_complete') }}
-
+
From 146c51502cf4fbcdadb5aba5c1f16387fdbf87ca Mon Sep 17 00:00:00 2001
From: axolotle
Date: Sat, 10 Apr 2021 17:34:32 +0200
Subject: [PATCH 2/3] removed unused prop in DomainForm
---
app/src/views/_partials/DomainForm.vue | 4 +---
1 file changed, 1 insertion(+), 3 deletions(-)
diff --git a/app/src/views/_partials/DomainForm.vue b/app/src/views/_partials/DomainForm.vue
index 9586928a..b7a6dfe6 100644
--- a/app/src/views/_partials/DomainForm.vue
+++ b/app/src/views/_partials/DomainForm.vue
@@ -61,9 +61,7 @@ export default {
props: {
title: { type: String, required: true },
submitText: { type: String, default: null },
- serverError: { type: String, default: '' },
- // Do not query the api (used by postinstall)
- noStore: { type: Boolean, default: false }
+ serverError: { type: String, default: '' }
},
data () {
From 1a1da4c0d0e2de536e86bc037b01945ade2b0034 Mon Sep 17 00:00:00 2001
From: axolotle
Date: Sat, 10 Apr 2021 17:39:20 +0200
Subject: [PATCH 3/3] handle validation errors & --force-diskspace
---
app/src/api/errors.js | 1 +
app/src/components/globals/CardForm.vue | 5 ++-
app/src/i18n/locales/en.json | 3 ++
app/src/views/PostInstall.vue | 58 ++++++++++++++++++++-----
4 files changed, 56 insertions(+), 11 deletions(-)
diff --git a/app/src/api/errors.js b/app/src/api/errors.js
index cbca7c12..f120ac02 100644
--- a/app/src/api/errors.js
+++ b/app/src/api/errors.js
@@ -47,6 +47,7 @@ class APIBadRequestError extends APIError {
constructor (method, response, errorData) {
super(method, response, errorData)
this.name = 'APIBadRequestError'
+ this.key = errorData.error_key
}
}
diff --git a/app/src/components/globals/CardForm.vue b/app/src/components/globals/CardForm.vue
index 1867f4bd..8debb8a3 100644
--- a/app/src/components/globals/CardForm.vue
+++ b/app/src/components/globals/CardForm.vue
@@ -10,7 +10,10 @@
-
+
diff --git a/app/src/i18n/locales/en.json b/app/src/i18n/locales/en.json
index 71f20d8a..4e192826 100644
--- a/app/src/i18n/locales/en.json
+++ b/app/src/i18n/locales/en.json
@@ -314,6 +314,9 @@
"permission_show_tile_enabled": "Visible as tile in user portal",
"port": "Port",
"ports": "Ports",
+ "postinstall": {
+ "force": "Force the post-install"
+ },
"postinstall_domain": "This is the first domain name linked to your YunoHost server, but also the one which will be used by your server's users to access the authentication portal. Accordingly, it will be visible by everyone, so choose it carefully.",
"postinstall_intro_1": "Congratulations! YunoHost has been successfully installed.",
"postinstall_intro_2": "Two more configuration steps are required to activate you server's services.",
diff --git a/app/src/views/PostInstall.vue b/app/src/views/PostInstall.vue
index 4682e30a..4a55c906 100644
--- a/app/src/views/PostInstall.vue
+++ b/app/src/views/PostInstall.vue
@@ -12,37 +12,57 @@
-
+
{{ $t('begin') }}
-
+
-
+
{{ $t('previous') }}
-
+
-
+
{{ $t('previous') }}
+
+
+
+ {{ serverError }}
+
+
+
+
+ {{ $t('postinstall.force') }}
+
+
+
+
+
@@ -71,14 +91,20 @@ export default {
return {
step: 'start',
domain: undefined,
- password: undefined
+ password: undefined,
+ serverError: ''
}
},
methods: {
+ goToStep (step) {
+ this.serverError = ''
+ this.step = step
+ },
+
setDomain ({ domain }) {
this.domain = domain
- this.step = 'password'
+ this.goToStep('password')
},
async setPassword ({ password }) {
@@ -90,11 +116,23 @@ export default {
this.performPostInstall()
},
- performPostInstall () {
+ performPostInstall (force = false) {
// FIXME does the api will throw an error for bad passwords ?
- api.post('postinstall', { domain: this.domain, password: this.password }).then(data => {
+ api.post('postinstall' + (force ? '?force_diskspace' : ''), { domain: this.domain, password: this.password }).then(data => {
// Display success message and allow the user to login
- this.step = 'login'
+ this.goToStep('login')
+ }).catch(err => {
+ if (err.name !== 'APIBadRequestError') throw err
+ if (err.key === 'postinstall_low_rootfsspace') {
+ this.step = 'rootfsspace-error'
+ } else if (err.key.includes('password')) {
+ this.step = 'password'
+ } else if (['domain', 'dyndns'].some(word => err.key.includes(word))) {
+ this.step = 'domain'
+ } else {
+ throw err
+ }
+ this.serverError = err.message
})
}
},