mirror of
https://github.com/YunoHost/yunohost-admin.git
synced 2024-09-03 20:06:15 +02:00
Merge pull request #349 from YunoHost/fix-postinstall-diskspace
Fix postinstall validation errors and add --force-diskspace admin equivalent
This commit is contained in:
commit
1d67aaf141
6 changed files with 64 additions and 16 deletions
|
@ -47,6 +47,7 @@ class APIBadRequestError extends APIError {
|
|||
constructor (method, response, errorData) {
|
||||
super(method, response, errorData)
|
||||
this.name = 'APIBadRequestError'
|
||||
this.key = errorData.error_key
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -10,7 +10,10 @@
|
|||
<slot name="default" />
|
||||
|
||||
<slot name="server-error">
|
||||
<b-alert variant="danger" :show="serverError !== ''" v-html="serverError" />
|
||||
<b-alert
|
||||
variant="danger" class="my-3"
|
||||
:show="serverError !== ''" v-html="serverError"
|
||||
/>
|
||||
</slot>
|
||||
</b-form>
|
||||
</template>
|
||||
|
|
|
@ -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.",
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -12,43 +12,63 @@
|
|||
<span v-html="$t('postinstall_intro_3')" />
|
||||
</p>
|
||||
|
||||
<b-button size="lg" variant="primary" @click="step = 'domain'">
|
||||
<b-button size="lg" variant="primary" @click="goToStep('domain')">
|
||||
{{ $t('begin') }}
|
||||
</b-button>
|
||||
</template>
|
||||
|
||||
<!-- DOMAIN SETUP STEP -->
|
||||
<template v-else-if="step === 'domain'">
|
||||
<domain-form @submit="setDomain" :title="$t('postinstall_set_domain')" :submit-text="$t('next')">
|
||||
<domain-form
|
||||
:title="$t('postinstall_set_domain')" :submit-text="$t('next')" :server-error="serverError"
|
||||
@submit="setDomain"
|
||||
>
|
||||
<template #disclaimer>
|
||||
<p class="alert alert-info" v-t="'postinstall_domain'" />
|
||||
</template>
|
||||
</domain-form>
|
||||
|
||||
<b-button variant="primary" @click="step = 'start'" class="mt-3">
|
||||
<b-button variant="primary" @click="goToStep('start')" class="mt-3">
|
||||
<icon iname="chevron-left" /> {{ $t('previous') }}
|
||||
</b-button>
|
||||
</template>
|
||||
|
||||
<!-- PASSWORD SETUP STEP -->
|
||||
<template v-else-if="step === 'password'">
|
||||
<password-form :title="$t('postinstall_set_password')" :submit-text="$t('next')" @submit="setPassword">
|
||||
<password-form
|
||||
:title="$t('postinstall_set_password')" :submit-text="$t('next')" :server-error="serverError"
|
||||
@submit="setPassword"
|
||||
>
|
||||
<template #disclaimer>
|
||||
<p class="alert alert-warning" v-t="'postinstall_password'" />
|
||||
</template>
|
||||
</password-form>
|
||||
|
||||
<b-button variant="primary" @click="step = 'domain'" class="mt-3">
|
||||
<b-button variant="primary" @click="goToStep('domain')" class="mt-3">
|
||||
<icon iname="chevron-left" /> {{ $t('previous') }}
|
||||
</b-button>
|
||||
</template>
|
||||
|
||||
<template v-else-if="step === 'rootfsspace-error'">
|
||||
<card no-body header-class="d-none" footer-bg-variant="danger">
|
||||
<b-card-body class="alert alert-danger m-0">
|
||||
{{ serverError }}
|
||||
</b-card-body>
|
||||
|
||||
<template #buttons>
|
||||
<b-button variant="light" size="sm" @click="performPostInstall(true)">
|
||||
<icon iname="warning" /> {{ $t('postinstall.force') }}
|
||||
</b-button>
|
||||
</template>
|
||||
</card>
|
||||
</template>
|
||||
|
||||
<!-- POST-INSTALL SUCCESS STEP -->
|
||||
<template v-else-if="step === 'login'">
|
||||
<p class="alert alert-success">
|
||||
<icon iname="thumbs-up" /> {{ $t('installation_complete') }}
|
||||
</p>
|
||||
<login />
|
||||
<login skip-install-check />
|
||||
</template>
|
||||
</div>
|
||||
</template>
|
||||
|
@ -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
|
||||
})
|
||||
}
|
||||
},
|
||||
|
|
|
@ -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 () {
|
||||
|
|
Loading…
Reference in a new issue