mirror of
https://github.com/YunoHost/yunohost-admin.git
synced 2024-09-03 20:06:15 +02:00
handle validation errors & --force-diskspace
This commit is contained in:
parent
146c51502c
commit
1a1da4c0d0
4 changed files with 56 additions and 11 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.",
|
||||
|
|
|
@ -12,37 +12,57 @@
|
|||
<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">
|
||||
|
@ -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
|
||||
})
|
||||
}
|
||||
},
|
||||
|
|
Loading…
Add table
Reference in a new issue