adds a way to test plugins settings from admin
This commit is contained in:
parent
d1c48f770e
commit
2f3868354b
3 changed files with 28 additions and 5 deletions
|
@ -22,13 +22,14 @@ v-container
|
||||||
v-select(v-if='setting.type === "LIST"' v-model='selectedPlugin.settingsValue[name]' :items='setting.items' :label='setting.description')
|
v-select(v-if='setting.type === "LIST"' v-model='selectedPlugin.settingsValue[name]' :items='setting.items' :label='setting.description')
|
||||||
v-switch(:label="$t('common.enable')" inset color='primary' v-model='selectedPlugin.settingsValue["enable"]')
|
v-switch(:label="$t('common.enable')" inset color='primary' v-model='selectedPlugin.settingsValue["enable"]')
|
||||||
v-card-actions
|
v-card-actions
|
||||||
|
v-btn(@click='testPlugin' outlined color='primary') {{ $t('common.test') }}
|
||||||
v-spacer
|
v-spacer
|
||||||
v-btn(@click='dialog = false' outlined color='warning') {{ $t('common.cancel') }}
|
v-btn(@click='dialog = false' outlined color='warning') {{ $t('common.close') }}
|
||||||
v-btn(@click='saveSettings' outlined color='primary' :loading='loading'
|
v-btn(@click='saveSettings' outlined color='primary' :loading='loading'
|
||||||
:disable='!valid || loading') {{ $t('common.save') }}
|
:disable='!valid || loading') {{ $t('common.save') }}
|
||||||
|
|
||||||
v-card-text
|
v-card-text
|
||||||
v-card(v-for='plugin in plugins' :key='plugin.name' max-width="400" elevation='10')
|
v-card(v-for='plugin in plugins' :key='plugin.name' max-width="400" outlined)
|
||||||
v-card-title {{ plugin.name }}
|
v-card-title {{ plugin.name }}
|
||||||
v-card-text
|
v-card-text
|
||||||
p {{ plugin.description }}
|
p {{ plugin.description }}
|
||||||
|
@ -67,15 +68,19 @@ export default {
|
||||||
...mapActions(['setSetting']),
|
...mapActions(['setSetting']),
|
||||||
async saveSettings() {
|
async saveSettings() {
|
||||||
this.loading = true
|
this.loading = true
|
||||||
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
|
this.dialog = false
|
||||||
},
|
},
|
||||||
async toggleEnable(plugin) {
|
async testPlugin() {
|
||||||
await this.$axios.$put(`/plugin/${plugin.name}`)
|
await this.saveSettings()
|
||||||
|
this.$axios.$post(`/plugin/test/${this.selectedPlugin.name}`)
|
||||||
|
},
|
||||||
|
toggleEnable(plugin) {
|
||||||
|
this.$axios.$put(`/plugin/${plugin.name}`)
|
||||||
},
|
},
|
||||||
setOptions(plugin) {
|
setOptions(plugin) {
|
||||||
this.selectedPlugin = plugin
|
this.selectedPlugin = plugin
|
||||||
|
|
|
@ -32,6 +32,23 @@ const pluginController = {
|
||||||
res.json()
|
res.json()
|
||||||
},
|
},
|
||||||
|
|
||||||
|
async testPlugin (req, res) {
|
||||||
|
const pluginName = req.params.plugin
|
||||||
|
const plugin = pluginController.plugins.find(p => p.configuration.name === pluginName)
|
||||||
|
if (!plugin) {
|
||||||
|
log.warn(`Plugin ${pluginName} not found`)
|
||||||
|
return res.sendStatus(404)
|
||||||
|
}
|
||||||
|
|
||||||
|
if (typeof plugin.onTest !== 'function') {
|
||||||
|
log.warn(`Plugin ${pluginName} does not expose an 'onTest' function`)
|
||||||
|
return res.sendStatus(404)
|
||||||
|
}
|
||||||
|
|
||||||
|
await plugin.onTest()
|
||||||
|
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]
|
const settings = settingsController.settings['plugin_' + pluginName]
|
||||||
|
|
|
@ -219,6 +219,7 @@ module.exports = () => {
|
||||||
|
|
||||||
// - PLUGINS
|
// - PLUGINS
|
||||||
api.get('/plugins', isAdmin, pluginController.getAll)
|
api.get('/plugins', isAdmin, pluginController.getAll)
|
||||||
|
api.post('/plugin/test/:plugin', isAdmin, pluginController.testPlugin)
|
||||||
api.put('/plugin/:plugin', isAdmin, pluginController.togglePlugin)
|
api.put('/plugin/:plugin', isAdmin, pluginController.togglePlugin)
|
||||||
|
|
||||||
// OAUTH
|
// OAUTH
|
||||||
|
|
Loading…
Reference in a new issue