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']),
|
computed: mapState(['settings']),
|
||||||
methods: {
|
methods: {
|
||||||
...mapActions(['setSetting']),
|
...mapActions(['setSetting']),
|
||||||
async saveSettings() {
|
async saveSettings(close=true) {
|
||||||
this.loading = true
|
this.loading = true
|
||||||
await this.setSetting({
|
await this.setSetting({
|
||||||
key: 'plugin_' + this.selectedPlugin.name,
|
key: 'plugin_' + this.selectedPlugin.name,
|
||||||
value: this.selectedPlugin.settingsValue
|
value: this.selectedPlugin.settingsValue
|
||||||
})
|
})
|
||||||
this.loading = false
|
this.loading = false
|
||||||
this.dialog = false
|
if (close) {
|
||||||
|
this.dialog = false
|
||||||
|
}
|
||||||
},
|
},
|
||||||
async testPlugin() {
|
async testPlugin() {
|
||||||
await this.saveSettings()
|
await this.saveSettings(false)
|
||||||
this.$axios.$post(`/plugin/test/${this.selectedPlugin.name}`)
|
this.$axios.$post(`/plugin/test/${this.selectedPlugin.name}`).catch( e => {
|
||||||
|
this.$root.$message(e?.response?.data?.message ?? e, { color: 'warning'})
|
||||||
|
})
|
||||||
},
|
},
|
||||||
toggleEnable(plugin) {
|
toggleEnable(plugin) {
|
||||||
this.$axios.$put(`/plugin/${plugin.name}`)
|
this.$axios.$put(`/plugin/${plugin.name}`)
|
||||||
|
|
|
@ -62,19 +62,22 @@ const pluginController = {
|
||||||
return res.sendStatus(404)
|
return res.sendStatus(404)
|
||||||
}
|
}
|
||||||
|
|
||||||
await plugin.onTest()
|
try {
|
||||||
|
await plugin.onTest()
|
||||||
|
} catch (response) {
|
||||||
|
return res.status(400).send({ message: String(response) })
|
||||||
|
}
|
||||||
res.sendStatus(200)
|
res.sendStatus(200)
|
||||||
},
|
},
|
||||||
|
|
||||||
unloadPlugin(pluginName) {
|
unloadPlugin(pluginName) {
|
||||||
const plugin = pluginController.plugins.find(p => p.configuration.name === pluginName)
|
const plugin = pluginController.plugins.find(p => p.configuration.name === pluginName)
|
||||||
const settings = settingsController.settings['plugin_' + pluginName]
|
|
||||||
if (!plugin) {
|
if (!plugin) {
|
||||||
log.warn(`Plugin ${pluginName} not found`)
|
log.warn(`Plugin ${pluginName} not found`)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
const notifier = require('../../notifier')
|
const notifier = require('../../notifier')
|
||||||
log.info('Unload plugin ' + plugin)
|
log.info('Unload plugin ' + plugin.configuration.name)
|
||||||
if (typeof plugin.onEventCreate === 'function') {
|
if (typeof plugin.onEventCreate === 'function') {
|
||||||
notifier.emitter.off('Create', plugin.onEventCreate)
|
notifier.emitter.off('Create', plugin.onEventCreate)
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue