From 368f890ff1f7c43266dfa4f48de625d14f2ea752 Mon Sep 17 00:00:00 2001 From: axolotle Date: Wed, 2 Mar 2022 20:28:13 +0100 Subject: [PATCH] update DomainConfig & AppConfigPanel with new API calls for apply and action --- app/src/i18n/locales/en.json | 11 +++++----- app/src/views/app/AppConfigPanel.vue | 26 +++++++++++++----------- app/src/views/domain/DomainConfig.vue | 29 +++++++++++++++++---------- 3 files changed, 37 insertions(+), 29 deletions(-) diff --git a/app/src/i18n/locales/en.json b/app/src/i18n/locales/en.json index e66541aa..18b240a8 100644 --- a/app/src/i18n/locales/en.json +++ b/app/src/i18n/locales/en.json @@ -378,13 +378,14 @@ "human_routes": { "adminpw": "Change admin password", "apps": { + "action_config": "Run action '{action}' of app '{name}' configuration", "change_label": "Change label of '{prevName}' for '{nextName}'", "change_url": "Change access URL of '{name}'", "install": "Install app '{name}'", "set_default": "Redirect '{domain}' domain root to '{name}'", "perform_action": "Perform action '{action}' of app '{name}'", "uninstall": "Uninstall app '{name}'", - "update_config": "Update app '{name}' configuration" + "update_config": "Update panel '{id}' of app '{name}' configuration" }, "backups": { "create": "Create a backup", @@ -406,13 +407,11 @@ "domains": { "add": "Add domain '{name}'", "delete": "Delete domain '{name}'", - "install_LE": "Install certificate for '{name}'", - "manual_renew_LE": "Renew certificate for '{name}'", + "cert_install": "Install certificate for '{name}'", + "cert_renew": "Renew certificate 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", - "update_config": "Update '{name}' configuration" + "update_config": "Update panel '{id}' of domain '{name}' configuration" }, "firewall": { "ports": "{action} port {port} ({protocol}, {connection})", diff --git a/app/src/views/app/AppConfigPanel.vue b/app/src/views/app/AppConfigPanel.vue index dc36aa72..ed9f1562 100644 --- a/app/src/views/app/AppConfigPanel.vue +++ b/app/src/views/app/AppConfigPanel.vue @@ -3,7 +3,10 @@ :queries="queries" @queries-response="onQueriesResponse" ref="view" skeleton="card-form-skeleton" > - + {{ $t('app_config_panel_no_panel') }} @@ -34,7 +37,7 @@ export default { data () { return { queries: [ - ['GET', `apps/${this.id}/config-panel?full`] + ['GET', `apps/${this.id}/config?full`] ], config: {} } @@ -49,23 +52,22 @@ export default { } }, - async applyConfig (id_) { - const args = await formatFormData( - this.config.forms[id_], - { removeEmpty: false, removeNull: true } - ) + async onConfigSubmit ({ id, form, action, name }) { + const args = await formatFormData(form, { removeEmpty: false, removeNull: true }) api.put( - `apps/${this.id}/config`, - { key: id_, args: objectToParams(args) }, - { key: 'apps.update_config', name: this.id } + action + ? `apps/${this.id}/actions/${action}` + : `apps/${this.id}/config/${id}`, + { args: objectToParams(args) }, + { key: `apps.${action ? 'action' : 'update'}_config`, id, name: this.id } ).then(() => { this.$refs.view.fetchQueries({ triggerLoading: true }) }).catch(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) { - 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) }) } diff --git a/app/src/views/domain/DomainConfig.vue b/app/src/views/domain/DomainConfig.vue index 8e31c593..83b1da98 100644 --- a/app/src/views/domain/DomainConfig.vue +++ b/app/src/views/domain/DomainConfig.vue @@ -3,7 +3,10 @@ :queries="queries" @queries-response="onQueriesResponse" ref="view" skeleton="card-form-skeleton" > - + @@ -41,17 +44,21 @@ export default { this.config = formatYunoHostConfigPanels(config) }, - async applyConfig (id) { - const args = await formatFormData( - this.config.forms[id], - { removeEmpty: false, removeNull: true } - ) + async onConfigSubmit ({ id, form, action, name }) { + const args = await formatFormData(form, { removeEmpty: false, removeNull: true }) + const call = action + ? 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( - `domains/${this.name}/config`, - { key: id, args: objectToParams(args) }, - { key: 'domains.update_config', name: this.name } - ).then(() => { + call.then(() => { this.$refs.view.fetchQueries({ triggerLoading: true }) }).catch(err => { if (err.name !== 'APIBadRequestError') throw err