mirror of
https://framagit.org/les/gancio.git
synced 2025-01-31 16:42:22 +01:00
fix: better test plugin error handling
Signed-off-by: lesion <lesion@autistici.org>
This commit is contained in:
parent
92bb516b33
commit
e91659408b
2 changed files with 14 additions and 7 deletions
|
@ -66,18 +66,22 @@ export default {
|
|||
computed: mapState(['settings']),
|
||||
methods: {
|
||||
...mapActions(['setSetting']),
|
||||
async saveSettings() {
|
||||
async saveSettings(close=true) {
|
||||
this.loading = true
|
||||
await this.setSetting({
|
||||
key: 'plugin_' + this.selectedPlugin.name,
|
||||
value: this.selectedPlugin.settingsValue
|
||||
})
|
||||
this.loading = false
|
||||
this.dialog = false
|
||||
if (close) {
|
||||
this.dialog = false
|
||||
}
|
||||
},
|
||||
async testPlugin() {
|
||||
await this.saveSettings()
|
||||
this.$axios.$post(`/plugin/test/${this.selectedPlugin.name}`)
|
||||
await this.saveSettings(false)
|
||||
this.$axios.$post(`/plugin/test/${this.selectedPlugin.name}`).catch( e => {
|
||||
this.$root.$message(e?.response?.data?.message ?? e, { color: 'warning'})
|
||||
})
|
||||
},
|
||||
toggleEnable(plugin) {
|
||||
this.$axios.$put(`/plugin/${plugin.name}`)
|
||||
|
|
|
@ -62,19 +62,22 @@ const pluginController = {
|
|||
return res.sendStatus(404)
|
||||
}
|
||||
|
||||
await plugin.onTest()
|
||||
try {
|
||||
await plugin.onTest()
|
||||
} catch (response) {
|
||||
return res.status(400).send({ message: String(response) })
|
||||
}
|
||||
res.sendStatus(200)
|
||||
},
|
||||
|
||||
unloadPlugin(pluginName) {
|
||||
const plugin = pluginController.plugins.find(p => p.configuration.name === pluginName)
|
||||
const settings = settingsController.settings['plugin_' + pluginName]
|
||||
if (!plugin) {
|
||||
log.warn(`Plugin ${pluginName} not found`)
|
||||
return
|
||||
}
|
||||
const notifier = require('../../notifier')
|
||||
log.info('Unload plugin ' + plugin)
|
||||
log.info('Unload plugin ' + plugin.configuration.name)
|
||||
if (typeof plugin.onEventCreate === 'function') {
|
||||
notifier.emitter.off('Create', plugin.onEventCreate)
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue