Render Gopher settings from API description

This commit is contained in:
Angelina Filippova 2019-11-16 11:28:59 +09:00
parent c18172f23e
commit 7811827cdc

View file

@ -1,21 +1,6 @@
<template> <template>
<el-form v-if="!loading" ref="gopher" :model="gopher" :label-width="labelWidth"> <el-form v-if="!loading" ref="gopher" :model="gopherData" :label-width="labelWidth">
<el-form-item label="Enabled"> <setting :setting-group="gopher" :data="gopherData"/>
<el-switch :value="gopher.enabled" @change="updateSetting($event, 'gopher', 'enabled')"/>
<p class="expl">Enables the gopher interface</p>
</el-form-item>
<el-form-item label="IP address">
<el-input :value="gopher.ip" placeholder="xxx.xxx.xxx.xx" @input="updateSetting($event, 'gopher', 'ip')"/>
<p class="expl">Enables the gopher interface</p>
</el-form-item>
<el-form-item label="Port">
<el-input :value="gopher.port" @input="updateSetting($event, 'gopher', 'port')"/>
<p class="expl">Port to bind to</p>
</el-form-item>
<el-form-item label="Dst port">
<el-input :value="gopher.dstport" @input="updateSetting($event, 'gopher', 'dstport')"/>
<p class="expl">Port advertised in urls (optional, defaults to port)</p>
</el-form-item>
<el-form-item> <el-form-item>
<el-button type="primary" @click="onSubmit">Submit</el-button> <el-button type="primary" @click="onSubmit">Submit</el-button>
</el-form-item> </el-form-item>
@ -25,13 +10,21 @@
<script> <script>
import i18n from '@/lang' import i18n from '@/lang'
import { mapGetters } from 'vuex' import { mapGetters } from 'vuex'
import Setting from './Setting'
export default { export default {
name: 'Gopher', name: 'Gopher',
components: { Setting },
computed: { computed: {
...mapGetters([ ...mapGetters([
'gopher' 'settings'
]), ]),
gopher() {
return this.settings.description.find(setting => setting.key === ':gopher')
},
gopherData() {
return this.settings.settings[':gopher']
},
isMobile() { isMobile() {
return this.$store.state.app.device === 'mobile' return this.$store.state.app.device === 'mobile'
}, },
@ -43,9 +36,6 @@ export default {
} }
}, },
methods: { methods: {
updateSetting(value, tab, input) {
this.$store.dispatch('UpdateSettings', { tab, data: { [input]: value }})
},
async onSubmit() { async onSubmit() {
try { try {
await this.$store.dispatch('SubmitChanges') await this.$store.dispatch('SubmitChanges')