finish plugins setup
This commit is contained in:
@@ -3,18 +3,24 @@ v-container
|
|||||||
v-card-title {{ $t('common.plugins') }}
|
v-card-title {{ $t('common.plugins') }}
|
||||||
v-spacer
|
v-spacer
|
||||||
v-card-subtitle(v-html="$t('admin.plugins_description')")
|
v-card-subtitle(v-html="$t('admin.plugins_description')")
|
||||||
|
v-dialog(v-if='selectedPlugin.settingsValue' v-model='dialog' width='600' :fullscreen='$vuetify.breakpoint.xsOnly')
|
||||||
v-dialog(v-model='dialog' width='600' :fullscreen='$vuetify.breakpoint.xsOnly')
|
|
||||||
v-card
|
v-card
|
||||||
v-card-title {{ $t('admin.config_plugin') }} - {{ selectedPlugin.name }}
|
v-card-title {{ $t('admin.config_plugin') }} - {{ selectedPlugin.name }}
|
||||||
v-card-text
|
v-card-text
|
||||||
v-form(v-model='valid' ref='form' lazy-validation)
|
v-form(v-model='valid' ref='form' lazy-validation)
|
||||||
div(v-for='(setting, name) in selectedPlugin.settings')
|
v-row(v-for='(setting, name) in selectedPlugin.settings' :key='name' mt-2)
|
||||||
v-text-field(v-if='setting.type === "TEXT"' v-model='selectedPlugin.settingsValue[name]' type='text' :label='setting.description')
|
v-col.col-4
|
||||||
v-text-field(v-if='setting.type === "NUMBER"' v-model='selectedPlugin.settingsValue[name]' type='number' :label='setting.description')
|
small(v-html='setting.hint')
|
||||||
v-switch(v-if='setting.type === "CHECK"' v-model='selectedPlugin.settingsValue[name]' :label='setting.description')
|
v-col.col-8
|
||||||
v-select(v-if='setting.type === "LIST"' v-model='selectedPlugin.settingsValue[name]' :items='setting.items' :label='setting.description')
|
v-text-field(v-if='setting.type === "TEXT"' v-model='selectedPlugin.settingsValue[name]'
|
||||||
|
type='text' :label='setting.description'
|
||||||
|
persistent-hint
|
||||||
|
:rules="[setting.required ? $validators.required(setting.description) : false]")
|
||||||
|
|
||||||
|
v-text-field(v-if='setting.type === "NUMBER"' v-model='selectedPlugin.settingsValue[name]' type='number' :label='setting.description')
|
||||||
|
v-switch(v-if='setting.type === "CHECK"' v-model='selectedPlugin.settingsValue[name]' :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-card-actions
|
v-card-actions
|
||||||
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.cancel') }}
|
||||||
@@ -23,8 +29,7 @@ v-container
|
|||||||
|
|
||||||
v-card-text
|
v-card-text
|
||||||
v-card(v-for='plugin in plugins' :key='plugin.name' max-width="400" elevation='10' color='secondary' dark)
|
v-card(v-for='plugin in plugins' :key='plugin.name' max-width="400" elevation='10' color='secondary' dark)
|
||||||
v-card-title.d-block {{ plugin.name }}
|
v-card-title {{ plugin.name }}
|
||||||
v-switch.float-right(:label="$t('common.enable')" v-model='plugin.settingsValue.enable' @change='toggleEnable(plugin)')
|
|
||||||
v-card-text
|
v-card-text
|
||||||
p {{ plugin.description }}
|
p {{ plugin.description }}
|
||||||
blockquote author: {{ plugin.author }}
|
blockquote author: {{ plugin.author }}
|
||||||
|
|||||||
@@ -8,11 +8,11 @@ const pluginController = {
|
|||||||
getAll(_req, res) {
|
getAll(_req, res) {
|
||||||
const settingsController = require('./settings')
|
const settingsController = require('./settings')
|
||||||
// return plugins and inner settings
|
// return plugins and inner settings
|
||||||
const plugins = pluginController.plugins.map(p => {
|
const plugins = pluginController.plugins.map( ({ configuration }) => {
|
||||||
if (settingsController.settings['plugin_' + p.name]) {
|
if (settingsController.settings['plugin_' + configuration.name]) {
|
||||||
p.settingsValue = settingsController.settings['plugin_' + p.name]
|
configuration.settingsValue = settingsController.settings['plugin_' + configuration.name]
|
||||||
}
|
}
|
||||||
return p
|
return configuration
|
||||||
})
|
})
|
||||||
return res.json(plugins)
|
return res.json(plugins)
|
||||||
},
|
},
|
||||||
@@ -34,7 +34,7 @@ const pluginController = {
|
|||||||
|
|
||||||
unloadPlugin(pluginName) {
|
unloadPlugin(pluginName) {
|
||||||
const settingsController = require('./settings')
|
const settingsController = require('./settings')
|
||||||
const plugin = pluginController.plugins.find(p => p.name === pluginName)
|
const plugin = pluginController.plugins.find(p => p.configuration.name === pluginName)
|
||||||
const settings = settingsController.settings['plugin_' + pluginName]
|
const settings = settingsController.settings['plugin_' + pluginName]
|
||||||
if (!plugin) {
|
if (!plugin) {
|
||||||
log.warn(`Plugin ${pluginName} not found`)
|
log.warn(`Plugin ${pluginName} not found`)
|
||||||
@@ -60,7 +60,7 @@ const pluginController = {
|
|||||||
|
|
||||||
loadPlugin(pluginName) {
|
loadPlugin(pluginName) {
|
||||||
const settingsController = require('./settings')
|
const settingsController = require('./settings')
|
||||||
const plugin = pluginController.plugins.find(p => p.name === pluginName)
|
const plugin = pluginController.plugins.find(p => p.configuration.name === pluginName)
|
||||||
const settings = settingsController.settings['plugin_' + pluginName]
|
const settings = settingsController.settings['plugin_' + pluginName]
|
||||||
if (!plugin) {
|
if (!plugin) {
|
||||||
log.warn(`Plugin ${pluginName} not found`)
|
log.warn(`Plugin ${pluginName} not found`)
|
||||||
@@ -78,7 +78,7 @@ const pluginController = {
|
|||||||
notifier.emitter.on('Update', plugin.onEventUpdate)
|
notifier.emitter.on('Update', plugin.onEventUpdate)
|
||||||
}
|
}
|
||||||
|
|
||||||
if (plugin.unload && typeof plugin.unload === 'function') {
|
if (plugin.load && typeof plugin.load === 'function') {
|
||||||
plugin.load({ settings: settingsController.settings }, settings)
|
plugin.load({ settings: settingsController.settings }, settings)
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
@@ -95,10 +95,9 @@ const pluginController = {
|
|||||||
plugins.forEach(pluginFile => {
|
plugins.forEach(pluginFile => {
|
||||||
try {
|
try {
|
||||||
const plugin = require(pluginFile)
|
const plugin = require(pluginFile)
|
||||||
if (typeof plugin.load !== 'function') return
|
|
||||||
const name = plugin.configuration.name
|
const name = plugin.configuration.name
|
||||||
console.log(`Found plugin '${name}'`)
|
console.log(`Found plugin '${name}'`)
|
||||||
pluginController.plugins.push(plugin.configuration)
|
pluginController.plugins.push(plugin)
|
||||||
console.error(settingsController.settings['plugin_' + name])
|
console.error(settingsController.settings['plugin_' + name])
|
||||||
if (settingsController.settings['plugin_' + name]) {
|
if (settingsController.settings['plugin_' + name]) {
|
||||||
const pluginSetting = settingsController.settings['plugin_' + name]
|
const pluginSetting = settingsController.settings['plugin_' + name]
|
||||||
|
|||||||
Reference in New Issue
Block a user