toggle plugins / save dynamic plugin settings
This commit is contained in:
@@ -10,7 +10,10 @@ v-container
|
||||
v-card-text
|
||||
v-form(v-model='valid' ref='form' lazy-validation)
|
||||
div(v-for='(setting, name) in selectedPlugin.settings')
|
||||
v-text-field(v-model='pluginSettings[name]' type='text' :label='setting.description')
|
||||
v-text-field(v-if='setting.type === "TEXT"' v-model='selectedPlugin.settingsValue[name]' type='text' :label='setting.description')
|
||||
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-card-actions
|
||||
v-spacer
|
||||
@@ -19,9 +22,9 @@ v-container
|
||||
:disable='!valid || loading') {{ $t('common.save') }}
|
||||
|
||||
v-card-text
|
||||
v-card(v-for='plugin in plugins' :key='plugin.name' max-width="400" elevation='10' color='secondary')
|
||||
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-switch.float-right(:label="$t('common.enable')" @change='toggleEnable(plugin)')
|
||||
v-switch.float-right(:label="$t('common.enable')" v-model='plugin.settingsValue.enable' @change='toggleEnable(plugin)')
|
||||
v-card-text
|
||||
p {{ plugin.description }}
|
||||
blockquote author: {{ plugin.author }}
|
||||
@@ -33,6 +36,7 @@ v-container
|
||||
</template>
|
||||
<script>
|
||||
import { mdiPencil, mdiChevronLeft, mdiChevronRight, mdiMagnify, mdiEye } from '@mdi/js'
|
||||
import { mapActions, mapState } from 'vuex'
|
||||
|
||||
export default {
|
||||
data() {
|
||||
@@ -42,7 +46,6 @@ export default {
|
||||
dialog: false,
|
||||
valid: false,
|
||||
selectedPlugin: {},
|
||||
pluginSettings: {},
|
||||
plugins: [],
|
||||
headers: [
|
||||
{ value: 'name', text: 'Name' },
|
||||
@@ -51,22 +54,26 @@ export default {
|
||||
]
|
||||
}
|
||||
},
|
||||
async fetch() {
|
||||
async mounted() {
|
||||
this.plugins = await this.$axios.$get('/plugins')
|
||||
},
|
||||
computed: mapState(['settings']),
|
||||
methods: {
|
||||
saveSettings() {
|
||||
console.error(this.pluginSettings)
|
||||
this.setSetting({ key: 'plugin_' + this.selectedPlugin.name, value: this.pluginSettings })
|
||||
...mapActions(['setSetting']),
|
||||
async saveSettings() {
|
||||
this.loading = true
|
||||
this.setSetting({
|
||||
key: 'plugin_' + this.selectedPlugin.name,
|
||||
value: this.selectedPlugin.settingsValue
|
||||
})
|
||||
this.loading = false
|
||||
this.dialog = false
|
||||
},
|
||||
toggleEnable(plugin) {
|
||||
this.pluginSettings.enable = !this.pluginSettings.enable
|
||||
this.setSetting({ key: 'plugin_' + this.selectedPlugin.name, value: this.pluginSettings })
|
||||
async toggleEnable(plugin) {
|
||||
await this.$axios.$put(`/plugin/${plugin.name}`)
|
||||
},
|
||||
setOptions(plugin) {
|
||||
console.error(plugin)
|
||||
this.selectedPlugin = plugin
|
||||
console.error(plugin)
|
||||
this.dialog = true
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user