Fixed transport update

This commit is contained in:
Antoine Nguyen
2022-03-25 09:55:06 +01:00
parent 15d9afc4a5
commit 4f2cbffd0b
6 changed files with 106 additions and 6 deletions
@@ -215,6 +215,9 @@ export default {
if (!this.createAdmin) {
delete data.domain_admin
}
if (data.type === 'relaydomain') {
this.$refs.form_4.checkSettingTypes(data)
}
this.$store.dispatch('domains/createDomain', data).then(resp => {
this.$router.push({ name: 'DomainDetail', params: { id: resp.data.pk } })
bus.$emit('notification', { msg: this.$gettext('Domain created') })
+40 -1
View File
@@ -104,6 +104,35 @@
<domain-limitations-form :domain="editedDomain" />
</v-expansion-panel-content>
</v-expansion-panel>
<v-expansion-panel v-if="editedDomain.type === 'relaydomain'">
<v-expansion-panel-header v-slot="{ open }">
<v-row no-gutters>
<v-col cols="4">
<translate>Transport</translate>
</v-col>
<v-col
cols="8"
class="text--secondary"
>
<v-fade-transition leave-absolute>
<span v-if="open"></span>
<v-row
v-else
no-gutters
style="width: 100%"
>
<v-col cols="6">
<translate class="mr-2">Service: </translate> {{ editedDomain.transport.service }}
</v-col>
</v-row>
</v-fade-transition>
</v-col>
</v-row>
</v-expansion-panel-header>
<v-expansion-panel-content>
<domain-transport-form ref="transportForm" :domain="editedDomain" />
</v-expansion-panel-content>
</v-expansion-panel>
</v-expansion-panels>
<div class="mt-4 d-flex justify-end">
<v-btn color="grey lighten-1" @click="$router.go(-1)">
@@ -121,12 +150,14 @@ import { bus } from '@/main'
import DomainDNSForm from './DomainDNSForm'
import DomainGeneralForm from './DomainGeneralForm'
import DomainLimitationsForm from './DomainLimitationsForm'
import DomainTransportForm from './DomainTransportForm'
export default {
components: {
'domain-dns-form': DomainDNSForm,
DomainGeneralForm,
DomainLimitationsForm
DomainLimitationsForm,
DomainTransportForm
},
props: ['domain'],
data () {
@@ -143,6 +174,9 @@ export default {
return
}
}
if (this.editedDomain.type === 'relaydomain') {
this.$refs.transportForm.checkSettingTypes(this.editedDomain)
}
this.$store.dispatch('domains/updateDomain', this.editedDomain).then(resp => {
bus.$emit('notification', { msg: this.$gettext('Domain updated') })
})
@@ -156,6 +190,11 @@ export default {
}
},
immediate: true
},
'editedDomain.type' (val) {
if (val === 'relaydomain' && this.editedDomain.transport === null) {
this.$set(this.editedDomain, 'transport', {})
}
}
}
}
@@ -79,11 +79,22 @@ export default {
this.$set(this.domain.transport.settings, `${value.name}_${setting.name}`, defaultValue)
}
}
},
checkSettingTypes (data) {
for (const setting of this.service.settings) {
if (setting.type === 'int') {
const fullName = `${this.service.name}_${setting.name}`
data.transport.settings[fullName] = parseInt(data.transport.settings[fullName])
}
}
}
},
mounted () {
transports.getAll().then(resp => {
this.backends = resp.data
if (this.domain) {
this.service = this.backends.find(backend => backend.name === this.domain.transport.service)
}
})
},
watch: {