mirror of
https://github.com/YunoHost/yunohost-admin.git
synced 2024-09-03 20:06:15 +02:00
update DomainConfig & AppConfigPanel with new API calls for apply and action
This commit is contained in:
parent
fd60748301
commit
368f890ff1
3 changed files with 37 additions and 29 deletions
|
@ -378,13 +378,14 @@
|
||||||
"human_routes": {
|
"human_routes": {
|
||||||
"adminpw": "Change admin password",
|
"adminpw": "Change admin password",
|
||||||
"apps": {
|
"apps": {
|
||||||
|
"action_config": "Run action '{action}' of app '{name}' configuration",
|
||||||
"change_label": "Change label of '{prevName}' for '{nextName}'",
|
"change_label": "Change label of '{prevName}' for '{nextName}'",
|
||||||
"change_url": "Change access URL of '{name}'",
|
"change_url": "Change access URL of '{name}'",
|
||||||
"install": "Install app '{name}'",
|
"install": "Install app '{name}'",
|
||||||
"set_default": "Redirect '{domain}' domain root to '{name}'",
|
"set_default": "Redirect '{domain}' domain root to '{name}'",
|
||||||
"perform_action": "Perform action '{action}' of app '{name}'",
|
"perform_action": "Perform action '{action}' of app '{name}'",
|
||||||
"uninstall": "Uninstall app '{name}'",
|
"uninstall": "Uninstall app '{name}'",
|
||||||
"update_config": "Update app '{name}' configuration"
|
"update_config": "Update panel '{id}' of app '{name}' configuration"
|
||||||
},
|
},
|
||||||
"backups": {
|
"backups": {
|
||||||
"create": "Create a backup",
|
"create": "Create a backup",
|
||||||
|
@ -406,13 +407,11 @@
|
||||||
"domains": {
|
"domains": {
|
||||||
"add": "Add domain '{name}'",
|
"add": "Add domain '{name}'",
|
||||||
"delete": "Delete domain '{name}'",
|
"delete": "Delete domain '{name}'",
|
||||||
"install_LE": "Install certificate for '{name}'",
|
"cert_install": "Install certificate for '{name}'",
|
||||||
"manual_renew_LE": "Renew certificate for '{name}'",
|
"cert_renew": "Renew certificate for '{name}'",
|
||||||
"push_dns_changes": "Push DNS records to registrar for '{name}'",
|
"push_dns_changes": "Push DNS records to registrar for '{name}'",
|
||||||
"regen_selfsigned": "Renew self-signed certificate for '{name}'",
|
|
||||||
"revert_to_selfsigned": "Revert to self-signed certificate for '{name}'",
|
|
||||||
"set_default": "Set '{name}' as default domain",
|
"set_default": "Set '{name}' as default domain",
|
||||||
"update_config": "Update '{name}' configuration"
|
"update_config": "Update panel '{id}' of domain '{name}' configuration"
|
||||||
},
|
},
|
||||||
"firewall": {
|
"firewall": {
|
||||||
"ports": "{action} port {port} ({protocol}, {connection})",
|
"ports": "{action} port {port} ({protocol}, {connection})",
|
||||||
|
|
|
@ -3,7 +3,10 @@
|
||||||
:queries="queries" @queries-response="onQueriesResponse"
|
:queries="queries" @queries-response="onQueriesResponse"
|
||||||
ref="view" skeleton="card-form-skeleton"
|
ref="view" skeleton="card-form-skeleton"
|
||||||
>
|
>
|
||||||
<config-panels v-if="config.panels" v-bind="config" @submit="applyConfig" />
|
<config-panels
|
||||||
|
v-if="config.panels" v-bind="config"
|
||||||
|
@submit="onConfigSubmit"
|
||||||
|
/>
|
||||||
|
|
||||||
<b-alert v-else-if="config.panels === null" variant="warning">
|
<b-alert v-else-if="config.panels === null" variant="warning">
|
||||||
<icon iname="exclamation-triangle" /> {{ $t('app_config_panel_no_panel') }}
|
<icon iname="exclamation-triangle" /> {{ $t('app_config_panel_no_panel') }}
|
||||||
|
@ -34,7 +37,7 @@ export default {
|
||||||
data () {
|
data () {
|
||||||
return {
|
return {
|
||||||
queries: [
|
queries: [
|
||||||
['GET', `apps/${this.id}/config-panel?full`]
|
['GET', `apps/${this.id}/config?full`]
|
||||||
],
|
],
|
||||||
config: {}
|
config: {}
|
||||||
}
|
}
|
||||||
|
@ -49,23 +52,22 @@ export default {
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
async applyConfig (id_) {
|
async onConfigSubmit ({ id, form, action, name }) {
|
||||||
const args = await formatFormData(
|
const args = await formatFormData(form, { removeEmpty: false, removeNull: true })
|
||||||
this.config.forms[id_],
|
|
||||||
{ removeEmpty: false, removeNull: true }
|
|
||||||
)
|
|
||||||
|
|
||||||
api.put(
|
api.put(
|
||||||
`apps/${this.id}/config`,
|
action
|
||||||
{ key: id_, args: objectToParams(args) },
|
? `apps/${this.id}/actions/${action}`
|
||||||
{ key: 'apps.update_config', name: this.id }
|
: `apps/${this.id}/config/${id}`,
|
||||||
|
{ args: objectToParams(args) },
|
||||||
|
{ key: `apps.${action ? 'action' : 'update'}_config`, id, name: this.id }
|
||||||
).then(() => {
|
).then(() => {
|
||||||
this.$refs.view.fetchQueries({ triggerLoading: true })
|
this.$refs.view.fetchQueries({ triggerLoading: true })
|
||||||
}).catch(err => {
|
}).catch(err => {
|
||||||
if (err.name !== 'APIBadRequestError') throw err
|
if (err.name !== 'APIBadRequestError') throw err
|
||||||
const panel = this.config.panels.find(({ id }) => id_ === id)
|
const panel = this.config.panels.find(panel => panel.id === id)
|
||||||
if (err.data.name) {
|
if (err.data.name) {
|
||||||
this.config.errors[id_][err.data.name].message = err.message
|
this.config.errors[id][err.data.name].message = err.message
|
||||||
} else this.$set(panel, 'serverError', err.message)
|
} else this.$set(panel, 'serverError', err.message)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,7 +3,10 @@
|
||||||
:queries="queries" @queries-response="onQueriesResponse"
|
:queries="queries" @queries-response="onQueriesResponse"
|
||||||
ref="view" skeleton="card-form-skeleton"
|
ref="view" skeleton="card-form-skeleton"
|
||||||
>
|
>
|
||||||
<config-panels v-if="config.panels" v-bind="config" @submit="applyConfig" />
|
<config-panels
|
||||||
|
v-if="config.panels" v-bind="config"
|
||||||
|
@submit="onConfigSubmit"
|
||||||
|
/>
|
||||||
</view-base>
|
</view-base>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
|
@ -41,17 +44,21 @@ export default {
|
||||||
this.config = formatYunoHostConfigPanels(config)
|
this.config = formatYunoHostConfigPanels(config)
|
||||||
},
|
},
|
||||||
|
|
||||||
async applyConfig (id) {
|
async onConfigSubmit ({ id, form, action, name }) {
|
||||||
const args = await formatFormData(
|
const args = await formatFormData(form, { removeEmpty: false, removeNull: true })
|
||||||
this.config.forms[id],
|
const call = action
|
||||||
{ removeEmpty: false, removeNull: true }
|
? api.put(
|
||||||
)
|
`domain/${this.name}/actions/${action}`,
|
||||||
|
{ args: objectToParams(args) },
|
||||||
|
{ key: 'domains.' + name, name: this.name }
|
||||||
|
)
|
||||||
|
: api.put(
|
||||||
|
`domains/${this.name}/config/${id}`,
|
||||||
|
{ args: objectToParams(args) },
|
||||||
|
{ key: 'domains.update_config', id, name: this.name }
|
||||||
|
)
|
||||||
|
|
||||||
api.put(
|
call.then(() => {
|
||||||
`domains/${this.name}/config`,
|
|
||||||
{ key: id, args: objectToParams(args) },
|
|
||||||
{ key: 'domains.update_config', name: this.name }
|
|
||||||
).then(() => {
|
|
||||||
this.$refs.view.fetchQueries({ triggerLoading: true })
|
this.$refs.view.fetchQueries({ triggerLoading: true })
|
||||||
}).catch(err => {
|
}).catch(err => {
|
||||||
if (err.name !== 'APIBadRequestError') throw err
|
if (err.name !== 'APIBadRequestError') throw err
|
||||||
|
|
Loading…
Add table
Reference in a new issue