Updated frontend dependencies.

Also fixed errors with mutated props.
This commit is contained in:
Antoine Nguyen
2022-09-24 10:39:51 +02:00
parent 335dbafe2c
commit 680bcdc329
31 changed files with 4348 additions and 6327 deletions
+6 -2
View File
@@ -8,11 +8,15 @@ module.exports = {
'@vue/standard'
],
parserOptions: {
parser: 'babel-eslint'
parser: '@babel/eslint-parser'
},
rules: {
'no-console': process.env.NODE_ENV === 'production' ? 'warn' : 'off',
'no-debugger': process.env.NODE_ENV === 'production' ? 'warn' : 'off'
'no-debugger': process.env.NODE_ENV === 'production' ? 'warn' : 'off',
'vue/valid-v-slot': ['error', {
allowModifiers: true
}],
'vue/multi-word-component-names': 'off'
},
overrides: [
{
+37
View File
@@ -0,0 +1,37 @@
#!/usr/bin/env python
import polib
LOCALES = [
"fr",
]
OLD_TRANSLATION_MODULES = [
"",
"admin",
"dnstools",
"ldapsync",
"limits",
"maillog",
"policyd",
"relaydomains",
"transport"
]
def merge_translations():
for locale in LOCALES:
new_po = polib.pofile(f"locale/{locale}/LC_MESSAGES/app.po")
for module in OLD_TRANSLATION_MODULES:
prefix = f"../modoboa/{module}" if module else "../modoboa"
old_po = polib.pofile(f"{prefix}/locale/{locale}/LC_MESSAGES/django.po")
for entry in new_po:
old_entry = old_po.find(entry.msgid)
if old_entry:
entry.msgstr = old_entry.msgstr
new_po.save()
if __name__ == "__main__":
merge_translations()
+14 -13
View File
@@ -25,28 +25,29 @@
"vuex": "^3.4.0"
},
"devDependencies": {
"@vue/cli-plugin-babel": "~4.5.0",
"@vue/cli-plugin-eslint": "~4.5.0",
"@vue/cli-plugin-router": "~4.5.0",
"@vue/cli-plugin-unit-mocha": "~4.5.0",
"@vue/cli-plugin-vuex": "~4.5.0",
"@vue/cli-service": "~4.5.0",
"@vue/eslint-config-standard": "^5.1.2",
"@babel/core": "^7.12.16",
"@babel/eslint-parser": "^7.12.16",
"@vue/cli-plugin-babel": "~5.0.8",
"@vue/cli-plugin-eslint": "~5.0.8",
"@vue/cli-plugin-router": "~5.0.8",
"@vue/cli-plugin-unit-mocha": "~5.0.8",
"@vue/cli-plugin-vuex": "~5.0.8",
"@vue/cli-service": "~5.0.8",
"@vue/eslint-config-standard": "^6.1.0",
"@vue/test-utils": "^1.0.3",
"axios": "^0.21.2",
"babel-eslint": "^10.1.0",
"chai": "^4.1.2",
"easygettext": "^2.15.0",
"eslint": "^6.7.2",
"eslint-plugin-import": "^2.20.2",
"eslint": "^7.32.0",
"eslint-plugin-import": "^2.25.3",
"eslint-plugin-node": "^11.1.0",
"eslint-plugin-promise": "^4.2.1",
"eslint-plugin-promise": "^5.1.0",
"eslint-plugin-standard": "^4.0.0",
"eslint-plugin-vue": "^6.2.2",
"eslint-plugin-vue": "^8.0.3",
"sass": "~1.32.12",
"sass-loader": "^8.0.2",
"vue-cli-plugin-axios": "~0.0.4",
"vue-cli-plugin-vuetify": "~2.4.1",
"vue-cli-plugin-vuetify": "~2.5.8",
"vue-template-compiler": "^2.6.11",
"vuetify-loader": "^1.3.0"
}
+16 -12
View File
@@ -1,5 +1,5 @@
<template>
<v-card>
<v-card v-if="value">
<v-card-title>
<span class="headline">DNS</span>
<v-btn icon :title="'DNS configuration help'|translate" @click="showConfigHelp = true">
@@ -101,10 +101,10 @@
</v-chip>
</v-col>
</v-row>
<v-row v-if="domain.enable_dkim">
<v-row v-if="value.enable_dkim">
<v-col cols="3"><translate>DKIM key</translate></v-col>
<v-col cols="9">
<div v-if="domain.dkim_private_key_path && domain.dkim_public_key">
<div v-if="value.dkim_private_key_path && value.dkim_public_key">
<v-btn color="primary" small @click="showDKIMKey = true">
<translate>Show key</translate>
</v-btn>
@@ -120,13 +120,13 @@
max-width="800px"
persistent
>
<domain-dns-config :domain="domain" @close="showConfigHelp = false" />
<domain-dns-config :domain="value" @close="showConfigHelp = false" />
</v-dialog>
<v-dialog v-model="showDKIMKey"
max-width="800px"
persistent
>
<domain-dkim-key :domain="domain" @close="showDKIMKey = false" />
<domain-dkim-key :domain="value" @close="showDKIMKey = false" />
</v-dialog>
</v-card>
</template>
@@ -138,7 +138,7 @@ import DomainDKIMKey from './DomainDKIMKey'
import DomainDNSConfig from './DomainDNSConfig'
export default {
props: ['domain'],
props: ['value'],
components: {
'domain-dkim-key': DomainDKIMKey,
'domain-dns-config': DomainDNSConfig
@@ -160,21 +160,25 @@ export default {
const payload = {
dkim_private_key_path: ''
}
domains.patchDomain(this.domain.pk, payload).then(resp => {
domains.patchDomain(this.value.pk, payload).then(resp => {
bus.$emit('notification', {
msg: this.$gettext('A new key will be generated soon. Refresh the page in a moment to see it.'),
type: 'success'
})
this.domain.dkim_private_key_path = ''
const domain = { ...this.value }
domain.dkim_private_key_path = ''
this.$emit('input', domain)
})
}
},
watch: {
domain: {
value: {
handler: function (val) {
domains.getDomainDNSDetail(val.pk).then(resp => {
this.detail = resp.data
})
if (val) {
domains.getDomainDNSDetail(val.pk).then(resp => {
this.detail = resp.data
})
}
},
immediate: true
}
@@ -9,19 +9,19 @@
@create="submit"
>
<template v-slot:form.general="{ step }">
<domain-general-form :ref="`form_${step}`" :domain="domain" />
<domain-general-form :ref="`form_${step}`" v-model="domain" />
</template>
<template v-slot:form.dns="{ step }">
<domain-dns-form :ref="`form_${step}`" :domain="domain" />
<domain-dns-form :ref="`form_${step}`" v-model="domain" />
</template>
<template v-slot:form.limitations="{ step }">
<domain-limitations-form :ref="`form_${step}`" :domain="domain" />
<domain-limitations-form :ref="`form_${step}`" v-model="domain" />
</template>
<template v-slot:form.options="{ step }">
<domain-options-form :ref="`form_${step}`" :domain="domain" @createAdmin="updateCreateAdmin" />
<domain-options-form :ref="`form_${step}`" v-model="domain" @createAdmin="updateCreateAdmin" />
</template>
<template v-slot:form.transport="{ step }">
<domain-transport-form :ref="`form_${step}`" :domain="domain" />
<domain-transport-form :ref="`form_${step}`" v-model="domain.transport" />
</template>
<template v-slot:item.with_random_password="{ item }">
<template v-if="item.value">
@@ -2,23 +2,27 @@
<div>
<v-switch
:label="'Enable DNS checks' | translate"
v-model="domain.enable_dns_checks"
v-model="form.enable_dns_checks"
@input="update"
/>
<v-switch
:label="'Enable DKIM signing' | translate"
v-model="domain.enable_dkim"
v-model="form.enable_dkim"
@input="update"
/>
<v-text-field
:label="'DKIM key selector' | translate"
v-model="domain.dkim_key_selector"
:disabled="!domain.enable_dkim"
v-model="form.dkim_key_selector"
:disabled="!form.enable_dkim"
outlined
@input="update"
/>
<choice-field
v-model="domain.dkim_key_length"
v-model="form.dkim_key_length"
:label="'DKIM key length' | translate"
:choices="dkimKeyLengths"
:disabled="!domain.enable_dkim"
:disabled="!form.enable_dkim"
@input="update"
/>
</div>
</template>
@@ -46,8 +50,17 @@ export default {
label: '4096',
value: 4096
}
]
],
form: {}
}
},
methods: {
update () {
this.$emit('input', this.form)
}
},
mounted () {
this.form = { ...this.value }
}
}
</script>
@@ -30,7 +30,7 @@
</v-row>
</v-expansion-panel-header>
<v-expansion-panel-content>
<domain-general-form ref="generalForm" :domain="editedDomain" />
<domain-general-form ref="generalForm" v-model="editedDomain" />
</v-expansion-panel-content>
</v-expansion-panel>
<v-expansion-panel>
@@ -66,7 +66,7 @@
</v-row>
</v-expansion-panel-header>
<v-expansion-panel-content>
<domain-dns-form ref="dnsForm" :domain="editedDomain" />
<domain-dns-form ref="dnsForm" v-model="editedDomain" />
</v-expansion-panel-content>
</v-expansion-panel>
<v-expansion-panel>
@@ -101,7 +101,7 @@
</v-row>
</v-expansion-panel-header>
<v-expansion-panel-content>
<domain-limitations-form :domain="editedDomain" />
<domain-limitations-form v-model="editedDomain" />
</v-expansion-panel-content>
</v-expansion-panel>
<v-expansion-panel v-if="editedDomain.type === 'relaydomain'">
@@ -130,10 +130,12 @@
</v-row>
</v-expansion-panel-header>
<v-expansion-panel-content>
<domain-transport-form ref="transportForm" :domain="editedDomain" />
<domain-transport-form ref="transportForm" v-model="editedDomain" />
</v-expansion-panel-content>
</v-expansion-panel>
<v-expansion-panel v-if="limitsConfig.enable_domain_limits && (authUser.role === 'SuperAdmins' || authUser.role === 'Resellers')">
<v-expansion-panel
v-if="limitsConfig.params && limitsConfig.params.enable_domain_limits && (authUser.role === 'SuperAdmins' || authUser.role === 'Resellers')"
>
<v-expansion-panel-header>
<v-row no-gutters>
<v-col cols="4">
@@ -142,7 +144,7 @@
</v-row>
</v-expansion-panel-header>
<v-expansion-panel-content>
<resources-form ref="resourcesForm" :resources="domain.resources" />
<resources-form ref="resourcesForm" v-model="editedDomain.resources" />
</v-expansion-panel-content>
</v-expansion-panel>
</v-expansion-panels>
@@ -224,6 +226,7 @@ export default {
handler: function (val) {
if (val) {
this.editedDomain = JSON.parse(JSON.stringify(val))
console.log(this.editedDomain)
}
},
immediate: true
@@ -6,26 +6,29 @@
>
<v-text-field
:label="'Domain name (ex: domain.tld)' | translate"
v-model="domain.name"
v-model="form.name"
:error-messages="errors"
outlined
@input="update"
/>
</validation-provider>
<validation-provider
v-slot="{ errors }"
rules="required"
>
<choice-field v-model="domain.type"
<choice-field v-model="form.type"
:label="'Type' | translate"
:choices="domainTypes"
:error-messages="errors"
@input="update"
/>
</validation-provider>
<v-switch
:label="'Enabled' | translate"
v-model="domain.enabled"
v-model="form.enabled"
:hint="'Control if this domain will be allowed to send and receive messages' | translate"
persistent-hint
@change="update"
/>
</validation-observer>
</template>
@@ -37,7 +40,7 @@ export default {
components: {
ChoiceField
},
props: ['domain'],
props: ['value'],
data () {
return {
domainTypes: [
@@ -51,7 +54,21 @@ export default {
icon: 'mdi-earth',
value: 'relaydomain'
}
]
],
form: {}
}
},
methods: {
update () {
this.$emit('input', this.form)
}
},
watch: {
value: {
handler: function (newValue) {
this.form = { ...newValue }
},
immediate: true
}
}
}
@@ -8,10 +8,11 @@
:label="'Quota' | translate"
:hint="'Quota shared between mailboxes. Can be expressed in KB, MB (default) or GB. A value of 0 means no quota.' | translate"
persistent-hint
v-model="domain.quota"
v-model="form.quota"
:error-messages="errors"
class="mb-4"
outlined
@input="update"
/>
</validation-provider>
<validation-provider
@@ -22,10 +23,11 @@
:label="'Default mailbox quota' | translate"
:hint="'Default quota applied to mailboxes. Can be expressed in KB, MB (default) or GB. A value of 0 means no quota.' | translate"
persistent-hint
v-model="domain.default_mailbox_quota"
v-model="form.default_mailbox_quota"
:error-messages="errors"
class="mb-4"
outlined
@input="update"
/>
</validation-provider>
<validation-provider
@@ -36,9 +38,10 @@
:label="'Message sending limit' | translate"
:hint="'Number of messages this domain can send per day. Leave empty for no limit.' | translate"
persistent-hint
v-model="domain.message_sending_limit"
v-model="form.message_sending_limit"
:error-messages="errors"
outlined
@input="update"
/>
</validation-provider>
</validation-observer>
@@ -46,6 +49,21 @@
<script>
export default {
props: ['domain']
props: {
value: Object
},
data () {
return {
form: {}
}
},
methods: {
update () {
this.$emit('input', this.form)
}
},
mounted () {
this.form = { ...this.value }
}
}
</script>
@@ -2,7 +2,7 @@
<validation-observer ref="observer">
<v-switch v-model="createAdmin"
:label="'Create a domain administrator' | translate"
@change="update"
@change="updateCreateAdmin"
/>
<validation-provider
v-slot="{ errors }"
@@ -12,31 +12,35 @@
:label="'Name' | translate"
:hint="'Name of the administrator' | translate"
persistent-hint
v-model="domain.domain_admin.username"
v-model="form.domain_admin.username"
:error-messages="errors"
outlined
:disabled="!createAdmin"
:suffix="`@${domain.name}`"
:suffix="`@${value.name}`"
@input="update"
/>
</validation-provider>
<v-switch v-model="domain.domain_admin.with_random_password"
<v-switch v-model="form.domain_admin.with_random_password"
:label="'Random password' | translate"
:disabled="!createAdmin"
:hint="'Generate a random password for the administrator.' | translate"
@change="updatePassword"
persistent-hint
@input="update"
/>
<v-switch v-model="domain.domain_admin.with_mailbox"
<v-switch v-model="form.domain_admin.with_mailbox"
:label="'With a mailbox' | translate"
:disabled="!createAdmin"
:hint="'Create a mailbox for the administrator.' | translate"
persistent-hint
@input="update"
/>
<v-switch v-model="domain.domain_admin.with_aliases"
<v-switch v-model="form.domain_admin.with_aliases"
:label="'Create aliases' | translate"
:disabled="!createAdmin"
:hint="'Create standard aliases for the domain.' | translate"
persistent-hint
@input="update"
/>
</validation-observer>
</template>
@@ -45,26 +49,34 @@
import accounts from '@/api/accounts'
export default {
props: ['domain'],
props: ['value'],
data () {
return {
createAdmin: false
createAdmin: false,
form: {}
}
},
methods: {
updatePassword (value) {
if (value) {
accounts.getRandomPassword().then(resp => {
this.$set(this.domain.domain_admin, 'password', resp.data.password)
this.$set(this.form.domain_admin, 'password', resp.data.password)
this.update()
})
} else {
delete this.domain.domain_admin.password
delete this.form.domain_admin.password
this.update()
}
},
update (val) {
updateCreateAdmin (val) {
this.$emit('createAdmin', val)
},
update () {
this.$emit('input', this.form)
}
},
mounted () {
this.form = { ...this.value }
}
}
</script>
@@ -1,5 +1,5 @@
<template>
<v-card>
<v-card v-if="domain">
<v-card-title>
<translate class="headline">General information</translate>
</v-card-title>
@@ -28,17 +28,19 @@
>
<label class="m-label">{{ setting.label }}</label>
<v-text-field
v-model="domain.transport.settings[`${service.name}_${setting.name}`]"
v-model="form.transport.settings[`${service.name}_${setting.name}`]"
outlined
:error-messages="errors"
:type="setting.type === 'int' ? 'number' : 'text'"
@input="update"
/>
</template>
<v-checkbox
v-else-if="setting.type === 'boolean'"
v-model="domain.transport.settings[`${service.name}_${setting.name}`]"
v-model="form.transport.settings[`${service.name}_${setting.name}`]"
:label="setting.label"
:error-messages="errors"
@change="update"
/>
</validation-provider>
</div>
@@ -53,17 +55,18 @@ import transports from '@/api/transports'
export default {
props: {
domain: Object
value: Object
},
data () {
return {
backends: [],
form: {},
service: null
}
},
methods: {
resetForm (value) {
this.$set(this.domain, 'transport', { service: value.name, settings: {} })
this.$set(this.form, 'transport', { service: value.name, settings: {} })
for (const setting of value.settings) {
if (setting.default) {
let defaultValue = setting.default
@@ -76,7 +79,8 @@ export default {
defaultValue = true
}
}
this.$set(this.domain.transport.settings, `${value.name}_${setting.name}`, defaultValue)
this.$set(this.form.transport.settings, `${value.name}_${setting.name}`, defaultValue)
this.update()
}
}
},
@@ -87,13 +91,17 @@ export default {
data.transport.settings[fullName] = parseInt(data.transport.settings[fullName])
}
}
},
update () {
this.$emit('input', this.form)
}
},
mounted () {
this.form = { ...this.value }
transports.getAll().then(resp => {
this.backends = resp.data
if (this.domain) {
this.service = this.backends.find(backend => backend.name === this.domain.transport.service)
if (this.value) {
this.service = this.backends.find(backend => backend.name === this.form.transport.service)
}
})
},
@@ -15,11 +15,11 @@
/>
</validation-provider>
<v-chip
v-for="(alias, index) in account.aliases"
v-for="(alias, index) in aliases"
:key="index"
class="mr-2 mt-2"
close
@click:close="account.aliases.splice(index, 1)"
@click:close="removeAlias(index)"
>
{{ alias }}
</v-chip>
@@ -31,20 +31,21 @@ import accounts from '@/api/accounts'
import EmailField from '@/components/tools/EmailField'
export default {
props: ['account'],
props: ['value'],
components: {
EmailField
},
data () {
return {
currentAlias: ''
currentAlias: '',
aliases: []
}
},
methods: {
async addAlias () {
try {
await accounts.validate({ aliases: [this.currentAlias] })
this.account.aliases.push(this.currentAlias)
this.aliases.push(this.currentAlias)
this.$refs.aliasField.reset()
} catch (error) {
let errorMsg = null
@@ -55,7 +56,17 @@ export default {
}
this.$refs.observer.setErrors({ alias: errorMsg })
}
},
removeAlias (index) {
this.aliases.splice(index, 1)
this.update()
},
update () {
this.$emit('input', this.aliases)
}
},
mounted () {
this.aliases = [...this.value]
}
}
</script>
@@ -9,16 +9,16 @@
@create="submit"
>
<template v-slot:form.role="{ step }">
<account-role-form :ref="`form_${step}`" :account="account" />
<account-role-form :ref="`form_${step}`" v-model="account.role" :account="account" />
</template>
<template v-slot:form.identification="{ step }">
<account-general-form v-if="step >= 2" :ref="`form_${step}`" :account="account" />
<account-general-form v-if="step >= 2" :ref="`form_${step}`" v-model="account" />
</template>
<template v-slot:form.mailbox="{ step }">
<account-mailbox-form :ref="`form_${step}`" :account="account" />
<account-mailbox-form :ref="`form_${step}`" v-model="account" />
</template>
<template v-slot:form.aliases="{ step }">
<account-alias-form v-if="step >= 4" :ref="`form_${step}`" :account="account" />
<account-alias-form v-if="step >= 4" :ref="`form_${step}`" v-model="account.aliases" />
</template>
<template v-slot:item.random_password="{ item }">
<template v-if="item.value">
@@ -27,7 +27,7 @@
</v-row>
</v-expansion-panel-header>
<v-expansion-panel-content>
<account-role-form ref="roleForm" :account="editedAccount" />
<account-role-form ref="roleForm" v-model="editedAccount.role" :account="editedAccount" />
</v-expansion-panel-content>
</v-expansion-panel>
<v-expansion-panel>
@@ -61,7 +61,7 @@
</v-row>
</v-expansion-panel-header>
<v-expansion-panel-content>
<account-general-form ref="generalForm" :account="editedAccount" />
<account-general-form ref="generalForm" v-model="editedAccount" />
</v-expansion-panel-content>
</v-expansion-panel>
<v-expansion-panel v-if="usernameIsEmail">
@@ -95,11 +95,11 @@
</v-row>
</v-expansion-panel-header>
<v-expansion-panel-content>
<account-mailbox-form ref="mailboxForm" :account="editedAccount" />
<account-mailbox-form ref="mailboxForm" v-model="editedAccount" />
</v-expansion-panel-content>
</v-expansion-panel>
<v-expansion-panel
v-if="limitsConfig.enable_admin_limits && account.role !== 'SimpleUsers' && account.role !== 'SuperAdmins'"
v-if="limitsConfig.params.enable_admin_limits && account.role !== 'SimpleUsers' && account.role !== 'SuperAdmins'"
>
<v-expansion-panel-header>
<v-row no-gutters>
@@ -144,7 +144,7 @@ export default {
props: ['account'],
computed: {
usernameIsEmail () {
return this.editedAccount.username.indexOf('@') !== -1
return this.editedAccount.username && this.editedAccount.username.indexOf('@') !== -1
}
},
data () {
@@ -7,37 +7,42 @@
<label class="m-label">{{ $gettext('Username') }}</label>
<email-field
ref="username"
v-model="account.username"
v-model="form.username"
:error-messages="errors"
:placeholder="usernamePlaceholder"
:type="usernameInputType"
@input="update"
/>
</validation-provider>
<label class="m-label">{{ $gettext('First name') }}</label>
<v-text-field
v-model="account.first_name"
v-model="form.first_name"
autocomplete="new-password"
outlined
dense
@input="update"
/>
<label class="m-label">{{ $gettext('Last name') }}</label>
<v-text-field
v-model="account.last_name"
v-model="form.last_name"
autocomplete="new-password"
outlined
dense
@input="update"
/>
<account-password-form
ref="passwordForm"
v-model="account.password"
:account="account"
v-model="form.password"
:account="form"
@input="update"
/>
<v-switch
v-model="account.is_active"
v-model="form.is_active"
:label="'Enabled' | translate"
dense
@input="update"
/>
</validation-observer>
</template>
@@ -51,22 +56,34 @@ export default {
AccountPasswordForm,
EmailField
},
props: ['account'],
props: ['value', 'account'],
data () {
return {
form: {}
}
},
computed: {
usernamePlaceholder () {
if (this.account.role === 'SimpleUsers') {
if (this.form.role === 'SimpleUsers') {
return this.$gettext('Enter an email address')
}
return this.$gettext('Enter a simple username or an email address')
},
usernameInputType () {
return (this.account.role === 'SimpleUsers') ? 'email' : 'text'
return (this.form.role === 'SimpleUsers') ? 'email' : 'text'
}
},
methods: {
async validateForm () {
return await this.$refs.observer.validate() && await this.$refs.passwordForm.validate()
},
update () {
console.log(this.form)
this.$emit('input', this.form)
}
},
mounted () {
this.form = { ...this.value }
}
}
</script>
@@ -2,33 +2,36 @@
<validation-observer ref="observer">
<label class="m-label">{{ $gettext('Quota') }}</label>
<v-switch
v-model="account.mailbox.use_domain_quota"
v-model="form.mailbox.use_domain_quota"
:label="useDomainQuotaLabel"
@change="update"
/>
<validation-provider
v-if="!account.mailbox.use_domain_quota"
v-if="!form.mailbox.use_domain_quota"
v-slot="{ errors }"
rules=""
vid="quota"
>
<v-text-field
v-model="account.mailbox.quota"
v-model="form.mailbox.quota"
:placeholder="'Ex: 10MB. Leave empty for no limit'|translate"
:hint="'Quota for this mailbox, can be expressed in KB, MB (default) or GB. Define a custom value or use domain\'s default one. Leave empty to define an unlimited value (not allowed for domain administrators).' | translate"
persistent-hint
outlined
:error-messages="errors"
dense
@input="update"
/>
</validation-provider>
<label class="m-label">{{ $gettext('Daily message sending limit') }}</label>
<v-text-field
v-model="account.mailbox.message_limit"
v-model="form.mailbox.message_limit"
:placeholder="'Leave empty for no limit' | translate"
:hint="'Number of messages this mailbox can send per day. Leave empty for no limit.' | translate"
persistent-hint
outlined
dense
@input="update"
/>
</validation-observer>
</template>
@@ -37,13 +40,20 @@
import { mapGetters } from 'vuex'
export default {
props: ['account'],
props: ['value'],
data () {
return {
form: {
mailbox: {}
}
}
},
computed: {
...mapGetters({
getDomainByName: 'identities/getDomainByName'
}),
domainQuota () {
const email = this.account.mailbox.full_address
const email = this.form.mailbox.full_address
if (email && email.indexOf('@') !== -1) {
const domain = this.getDomainByName(email.split('@')[1])
if (domain) {
@@ -64,11 +74,20 @@ export default {
return result
}
},
methods: {
update () {
this.$emit('input', this.form)
}
},
mounted () {
this.form = { ...this.value }
},
watch: {
account: {
handler (val) {
if (val.role === 'SimpleUsers') {
this.$set(val.mailbox, 'full_address', val.username)
value: {
handler (newValue) {
this.form = { ...newValue }
if (this.form.role === 'SimpleUsers') {
this.$set(this.form.mailbox, 'full_address', this.form.username)
}
},
deep: true
@@ -6,12 +6,14 @@
>
<v-row>
<v-col cols="7">
<choice-field v-model="account.role"
:label="'Choose a role' | translate"
:choices="accountRoles"
:error-messages="errors"
:choices-per-line="2"
/>
<choice-field
:value="account.role"
:label="'Choose a role' | translate"
:choices="accountRoles"
:error-messages="errors"
:choices-per-line="2"
@input="value => $emit('input', value)"
/>
</v-col>
<v-col cols="5">
<v-alert text color="primary" class="mt-11 ml-4 rounded-lg">
@@ -32,7 +34,7 @@ export default {
components: {
ChoiceField
},
props: ['account'],
props: ['value', 'account'],
computed: {
roleLabel () {
const role = this.accountRoles.find(role => role.value === this.account.role)
@@ -9,10 +9,10 @@
@create="submit"
>
<template v-slot:form.general="{ step }">
<alias-general-form :ref="`form_${step}`" :alias="alias" />
<alias-general-form :ref="`form_${step}`" v-model="alias" />
</template>
<template v-slot:form.recipients="{ step }">
<alias-recipient-form :ref="`form_${step}`" :alias="alias" />
<alias-recipient-form :ref="`form_${step}`" v-model="alias.recipients" />
</template>
</creation-form>
</template>
@@ -32,7 +32,7 @@
</v-row>
</v-expansion-panel-header>
<v-expansion-panel-content>
<alias-general-form ref="generalForm" :alias="editedAlias" />
<alias-general-form ref="generalForm" v-model="editedAlias" />
</v-expansion-panel-content>
</v-expansion-panel>
<v-expansion-panel>
@@ -65,7 +65,7 @@
</v-row>
</v-expansion-panel-header>
<v-expansion-panel-content>
<alias-recipient-form ref="recipientForm" :alias="editedAlias" />
<alias-recipient-form ref="recipientForm" v-model="editedAlias.recipients" />
</v-expansion-panel-content>
</v-expansion-panel>
</v-expansion-panels>
@@ -1,12 +1,13 @@
<template>
<validation-observer ref="observer">
<v-switch
v-if="!alias.pk"
v-model="alias.random"
v-if="!form.pk"
v-model="form.random"
:label="'Random address'|translate"
@input="update"
/>
<validation-provider
v-if="!alias.random"
v-if="!form.random"
v-slot="{ errors }"
name="address"
rules="required"
@@ -14,21 +15,22 @@
<label class="m-label">{{ $gettext('Email address') }}</label>
<email-field
ref="address"
v-model="alias.address"
v-model="form.address"
:error-messages="errors"
type="email"
outlined
dense
@input="update"
/>
</validation-provider>
<validation-provider
v-if="alias.random"
v-if="form.random"
v-slot="{ errors }"
rules="required"
>
<label class="m-label">{{ $gettext('Domain') }}</label>
<v-select
v-model="alias.domain"
v-model="form.domain"
:items="domains"
:error-messages="errors"
item-text="name"
@@ -36,24 +38,28 @@
outlined
dense
@change="updateAddress"
@input="update"
/>
</validation-provider>
<v-switch
v-model="alias.enabled"
v-model="form.enabled"
:label="'Enabled'|translate"
@input="update"
/>
<label class="m-label">{{ $gettext('Expire at') }}</label>
<v-text-field
v-model="alias.expire"
v-model="form.expire"
outlined
dense
@input="update"
/>
<label class="m-label">{{ $gettext('Description') }}</label>
<v-textarea
v-model="alias.description"
v-model="form.description"
rows="2"
outlined
dense
@input="update"
/>
</validation-observer>
@@ -68,23 +74,30 @@ export default {
components: {
EmailField
},
props: ['alias'],
props: ['value'],
computed: {
...mapGetters({
domains: 'identities/domains'
})
},
data () {
return {
form: {}
}
},
methods: {
updateAddress (value) {
aliases.getRandomAddress().then(resp => {
this.$set(this.alias, 'address', `${resp.data.address}@${value.name}`)
this.$set(this.form, 'address', `${resp.data.address}@${value.name}`)
this.update()
})
},
update () {
this.$emit('input', this.form)
}
},
watch: {
alias (val) {
console.log(val)
}
mounted () {
this.form = { ...this.value }
}
}
</script>
@@ -16,11 +16,11 @@
/>
</validation-provider>
<v-chip
v-for="(recipient, index) in alias.recipients"
v-for="(recipient, index) in recipients"
:key="index"
class="mr-2 mt-2"
close
@click:close="alias.recipients.splice(index, 1)"
@click:close="removeRecipient(index)"
>
{{ recipient }}
</v-chip>
@@ -31,19 +31,37 @@
import EmailField from '@/components/tools/EmailField'
export default {
props: ['alias'],
props: ['value'],
components: {
EmailField
},
data () {
return {
recipient: ''
recipient: '',
recipients: []
}
},
methods: {
async addRecipient () {
this.alias.recipients.push(this.recipient)
this.recipients.push(this.recipient)
this.$emit('input', this.recipients)
this.$refs.recipientField.reset()
},
removeRecipient (index) {
this.recipients.splice(index, 1)
this.$emit('input', this.recipients)
}
},
watch: {
value: {
handler: function (newValue) {
if (newValue) {
this.recipients = [...newValue]
} else {
this.recipients = []
}
},
immediate: true
}
}
}
@@ -121,7 +121,7 @@ export default {
}
let result = true
element.display.split('&').forEach(rule => {
var [field, value] = rule.split('=')
let [field, value] = rule.split('=')
if (value === 'true' || value === 'false') {
value = Boolean(value)
}
@@ -151,7 +151,6 @@ export default {
},
watch: {
value (newValue) {
console.log(newValue)
this.input = newValue
}
}
@@ -13,6 +13,7 @@
outlined
dense
:error-messages="errors"
@input="$emit('input', resources)"
/>
</validation-provider>
</validation-observer>
@@ -21,7 +22,12 @@
<script>
export default {
props: {
resources: Array
value: Array
},
data () {
return {
resources: []
}
},
methods: {
async validateForm () {
@@ -32,6 +38,14 @@ export default {
return { name: r.name, max_value: r.max_value }
})
}
},
watch: {
value: {
handler: function (newValue) {
this.resources = [...newValue]
},
immediate: true
}
}
}
</script>
@@ -72,12 +72,6 @@ export default {
return this.statistics.title
}
return ''
},
colors () {
if (this.graphicName === 'averagetraffic') {
return ['#ff6347', '#ffff00', '#4682B4', '#7cfc00', '#ffa500', '#d3d3d3']
}
return ['#ffa500', '#41d1cc']
}
},
data () {
@@ -85,7 +79,7 @@ export default {
dateMenu: false,
menu: false,
options: {
colors: this.colors,
colors: [],
chart: {
type: 'area',
stacked: false,
@@ -120,6 +114,12 @@ export default {
}
},
methods: {
getColors () {
if (this.graphicName === 'averagetraffic') {
return ['#ff6347', '#ffff00', '#4682B4', '#7cfc00', '#ffa500', '#d3d3d3']
}
return ['#ffa500', '#41d1cc']
},
setCustomPeriod () {
this.period = 'custom'
this.fetchStatistics()
@@ -148,6 +148,11 @@ export default {
},
mounted () {
this.fetchStatistics()
},
watch: {
graphicName (newValue) {
this.$set(this.options, 'colors', this.getColors())
}
}
}
</script>
+2 -2
View File
@@ -17,7 +17,7 @@ const state = {
const getters = {
domains: state => state.domains,
getDomainByPk: state => pk => {
for (var domain of state.domains) {
for (const domain of state.domains) {
if (domain.pk === parseInt(pk, 10)) {
return domain
}
@@ -65,7 +65,7 @@ const mutations = {
state.domains.push(domain)
},
[UPDATE_DOMAIN] (state, { domain }) {
state.domains.filter(function (item, pos) {
state.domains.forEach(function (item, pos) {
if (item.pk === domain.pk) {
Vue.set(state.domains, pos, domain)
}
+5 -2
View File
@@ -16,9 +16,12 @@
/>
</v-col>
<v-col cols="6">
<dns-detail :domain="domain" />
<dns-detail v-model="domain" />
<div class="mt-4" />
<resources v-if="limitsConfig.enable_domain_limits && domain.resources && domain.resources.length" :resources="domain.resources" />
<resources
v-if="limitsConfig.params && limitsConfig.params.enable_domain_limits && domain.resources && domain.resources.length"
:resources="domain.resources"
/>
</v-col>
</v-row>
</v-layout>
+1 -1
View File
@@ -12,7 +12,7 @@
</v-col>
<v-col cols="6">
<resources
v-if="limitsConfig.enable_admin_limits && account.role !== 'SimpleUsers' && account.role !== 'SuperAdmins'"
v-if="limitsConfig.params.enable_admin_limits && account.role !== 'SimpleUsers' && account.role !== 'SuperAdmins'"
:resources="account.resources"
/>
<account-aliases v-if="account.aliases" class="mt-2" :account="account" />
+3977 -6174
View File
File diff suppressed because it is too large Load Diff