mirror of
https://github.com/the-djmaze/snappymail.git
synced 2026-07-10 15:08:28 +03:00
Simplify admin domain management
This commit is contained in:
parent
962ddde1f3
commit
b5114fa73a
2 changed files with 40 additions and 89 deletions
|
|
@ -1,4 +1,4 @@
|
|||
import { pInt, pString, forEachObjectEntry } from 'Common/Utils';
|
||||
import { pInt, forEachObjectEntry } from 'Common/Utils';
|
||||
import { i18n, getNotification } from 'Common/Translator';
|
||||
|
||||
import Remote from 'Remote/Admin/Fetch';
|
||||
|
|
@ -112,16 +112,16 @@ class DomainPopupView extends AbstractViewPopup {
|
|||
imapSecure: value => {
|
||||
if (this.enableSmartPorts()) {
|
||||
const port = pInt(this.imapPort());
|
||||
switch (pString(value)) {
|
||||
case '0':
|
||||
case '2':
|
||||
switch (pInt(value)) {
|
||||
case 0:
|
||||
case 2:
|
||||
if (993 === port) {
|
||||
this.imapPort('143');
|
||||
this.imapPort(143);
|
||||
}
|
||||
break;
|
||||
case '1':
|
||||
case 1:
|
||||
if (143 === port) {
|
||||
this.imapPort('993');
|
||||
this.imapPort(993);
|
||||
}
|
||||
break;
|
||||
// no default
|
||||
|
|
@ -132,20 +132,20 @@ class DomainPopupView extends AbstractViewPopup {
|
|||
smtpSecure: value => {
|
||||
if (this.enableSmartPorts()) {
|
||||
const port = pInt(this.smtpPort());
|
||||
switch (pString(value)) {
|
||||
case '0':
|
||||
switch (pInt(value)) {
|
||||
case 0:
|
||||
if (465 === port || 587 === port) {
|
||||
this.smtpPort('25');
|
||||
this.smtpPort(25);
|
||||
}
|
||||
break;
|
||||
case '1':
|
||||
case 1:
|
||||
if (25 === port || 587 === port) {
|
||||
this.smtpPort('465');
|
||||
this.smtpPort(465);
|
||||
}
|
||||
break;
|
||||
case '2':
|
||||
case 2:
|
||||
if (25 === port || 465 === port) {
|
||||
this.smtpPort('587');
|
||||
this.smtpPort(587);
|
||||
}
|
||||
break;
|
||||
// no default
|
||||
|
|
@ -178,10 +178,7 @@ class DomainPopupView extends AbstractViewPopup {
|
|||
}
|
||||
|
||||
testConnectionCommand() {
|
||||
this.testingDone(false);
|
||||
this.testingImapError(false);
|
||||
this.testingSieveError(false);
|
||||
this.testingSmtpError(false);
|
||||
this.clearTesting(false);
|
||||
this.testing(true);
|
||||
|
||||
Remote.request('AdminDomainTest',
|
||||
|
|
@ -237,56 +234,36 @@ class DomainPopupView extends AbstractViewPopup {
|
|||
|
||||
onShow(oDomain) {
|
||||
this.saving(false);
|
||||
|
||||
this.clearTesting();
|
||||
|
||||
this.clearForm();
|
||||
if (oDomain) {
|
||||
this.enableSmartPorts(false);
|
||||
|
||||
this.edit(true);
|
||||
|
||||
this.name(oDomain.Name);
|
||||
this.imapHost(oDomain.IncHost);
|
||||
this.imapPort('' + pInt(oDomain.IncPort));
|
||||
this.imapSecure(oDomain.IncSecure);
|
||||
this.imapShortLogin(!!oDomain.IncShortLogin);
|
||||
this.useSieve(!!oDomain.UseSieve);
|
||||
this.sieveHost(oDomain.SieveHost);
|
||||
this.sievePort('' + pInt(oDomain.SievePort));
|
||||
this.sieveSecure(oDomain.SieveSecure);
|
||||
this.smtpHost(oDomain.OutHost);
|
||||
this.smtpPort('' + pInt(oDomain.OutPort));
|
||||
this.smtpSecure(oDomain.OutSecure);
|
||||
this.smtpShortLogin(!!oDomain.OutShortLogin);
|
||||
this.smtpAuth(!!oDomain.OutAuth);
|
||||
this.smtpSetSender(!!oDomain.OutSetSender);
|
||||
this.smtpPhpMail(!!oDomain.OutUsePhpMail);
|
||||
this.whiteList(oDomain.WhiteList);
|
||||
this.aliasName(oDomain.AliasName);
|
||||
|
||||
forEachObjectEntry(oDomain, (key, value) => this[key] && this[key](value));
|
||||
this.enableSmartPorts(true);
|
||||
}
|
||||
}
|
||||
|
||||
getDefaults() {
|
||||
return {
|
||||
enableSmartPorts: false,
|
||||
|
||||
savingError: '',
|
||||
|
||||
name: '',
|
||||
|
||||
imapHost: '',
|
||||
imapPort: '143',
|
||||
imapPort: 143,
|
||||
imapSecure: 0,
|
||||
imapShortLogin: false,
|
||||
|
||||
useSieve: false,
|
||||
sieveHost: '',
|
||||
sievePort: '4190',
|
||||
sievePort: 4190,
|
||||
sieveSecure: 0,
|
||||
|
||||
smtpHost: '',
|
||||
smtpPort: '25',
|
||||
smtpPort: 25,
|
||||
smtpSecure: 0,
|
||||
smtpShortLogin: false,
|
||||
smtpAuth: true,
|
||||
|
|
@ -294,9 +271,7 @@ class DomainPopupView extends AbstractViewPopup {
|
|||
smtpPhpMail: false,
|
||||
|
||||
whiteList: '',
|
||||
aliasName: '',
|
||||
|
||||
enableSmartPorts: false
|
||||
aliasName: ''
|
||||
};
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -400,52 +400,28 @@ class Domain implements \JsonSerializable
|
|||
);
|
||||
}
|
||||
|
||||
public function ToSimpleJSON() : array
|
||||
{
|
||||
return array(
|
||||
'Name' => $this->sName,
|
||||
'IncHost' => $this->sIncHost,
|
||||
'IncPort' => $this->iIncPort,
|
||||
'IncSecure' => $this->iIncSecure,
|
||||
'IncShortLogin' => $this->bIncShortLogin,
|
||||
'UseSieve' => $this->bUseSieve,
|
||||
'SieveHost' => $this->sSieveHost,
|
||||
'SievePort' => $this->iSievePort,
|
||||
'SieveSecure' => $this->iSieveSecure,
|
||||
'OutHost' => $this->sOutHost,
|
||||
'OutPort' => $this->iOutPort,
|
||||
'OutSecure' => $this->iOutSecure,
|
||||
'OutShortLogin' => $this->bOutShortLogin,
|
||||
'OutAuth' => $this->bOutAuth,
|
||||
'OutSetSender' => $this->bOutSetSender,
|
||||
'OutUsePhpMail' => $this->bOutUsePhpMail,
|
||||
'WhiteList' => $this->sWhiteList,
|
||||
'AliasName' => $this->sAliasName
|
||||
);
|
||||
}
|
||||
|
||||
public function jsonSerialize()
|
||||
{
|
||||
return array(
|
||||
// '@Object' => 'Object/Domain',
|
||||
'Name' => \MailSo\Base\Utils::IdnToUtf8($this->sName),
|
||||
'IncHost' => \MailSo\Base\Utils::IdnToUtf8($this->sIncHost),
|
||||
'IncPort' => $this->iIncPort,
|
||||
'IncSecure' => $this->iIncSecure,
|
||||
'IncShortLogin' => $this->bIncShortLogin,
|
||||
'UseSieve' => $this->bUseSieve,
|
||||
'SieveHost' => \MailSo\Base\Utils::IdnToUtf8($this->sSieveHost),
|
||||
'SievePort' => $this->iSievePort,
|
||||
'SieveSecure' => $this->iSieveSecure,
|
||||
'OutHost' => \MailSo\Base\Utils::IdnToUtf8($this->sOutHost),
|
||||
'OutPort' => $this->iOutPort,
|
||||
'OutSecure' => $this->iOutSecure,
|
||||
'OutShortLogin' => $this->bOutShortLogin,
|
||||
'OutAuth' => $this->bOutAuth,
|
||||
'OutSetSender' => $this->bOutSetSender,
|
||||
'OutUsePhpMail' => $this->bOutUsePhpMail,
|
||||
'WhiteList' => $this->sWhiteList,
|
||||
'AliasName' => $this->sAliasName
|
||||
'name' => \MailSo\Base\Utils::IdnToUtf8($this->sName),
|
||||
'imapHost' => \MailSo\Base\Utils::IdnToUtf8($this->sIncHost),
|
||||
'imapPort' => $this->iIncPort,
|
||||
'imapSecure' => $this->iIncSecure,
|
||||
'imapShortLogin' => $this->bIncShortLogin,
|
||||
'useSieve' => $this->bUseSieve,
|
||||
'sieveHost' => \MailSo\Base\Utils::IdnToUtf8($this->sSieveHost),
|
||||
'sievePort' => $this->iSievePort,
|
||||
'sieveSecure' => $this->iSieveSecure,
|
||||
'smtpHost' => \MailSo\Base\Utils::IdnToUtf8($this->sOutHost),
|
||||
'smtpPort' => $this->iOutPort,
|
||||
'smtpSecure' => $this->iOutSecure,
|
||||
'smtpShortLogin' => $this->bOutShortLogin,
|
||||
'smtpAuth' => $this->bOutAuth,
|
||||
'smtpSetSender' => $this->bOutSetSender,
|
||||
'smtpPhpMail' => $this->bOutUsePhpMail,
|
||||
'whiteList' => $this->sWhiteList,
|
||||
'aliasName' => $this->sAliasName
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue