globalsettings: update apply call to actions changes

This commit is contained in:
axolotle 2022-10-07 21:04:47 +02:00
parent 2708b98d20
commit 8a91045f0d
2 changed files with 10 additions and 12 deletions

View file

@ -455,7 +455,7 @@
"update": "Update user '{name}'"
},
"settings": {
"update": "Update global settings"
"update": "Update '{panel}' global settings panel"
}
},
"run": "Run",

View file

@ -3,7 +3,7 @@
:queries="queries" @queries-response="onQueriesResponse"
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>
</template>
@ -39,23 +39,21 @@ export default {
this.config = formatYunoHostConfigPanels(config)
},
async applyConfig (id_) {
const formatedData = await formatFormData(
this.config.forms[id_],
{ removeEmpty: false, removeNull: true, multipart: false }
)
async onConfigSubmit ({ id, form }) {
const args = await formatFormData(form, { removeEmpty: false, removeNull: true })
// FIXME no route for potential action
api.put(
'settings',
{ key: id_, args: objectToParams(formatedData) },
{ key: 'settings.update', name: this.name }
`settings/${id}`,
{ args: objectToParams(args) },
{ key: 'settings.update', panel: 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)
})
}