mirror of
https://github.com/the-djmaze/snappymail.git
synced 2026-08-29 12:09:20 +03:00
Add alias support (domains)
This commit is contained in:
parent
a1d829c697
commit
28a125426a
26 changed files with 1014 additions and 92 deletions
|
|
@ -89,6 +89,7 @@
|
|||
this.smtpAuth = ko.observable(true);
|
||||
this.smtpPhpMail = ko.observable(false);
|
||||
this.whiteList = ko.observable('');
|
||||
this.aliasName = ko.observable('');
|
||||
|
||||
this.enableSmartPorts = ko.observable(false);
|
||||
|
||||
|
|
@ -97,10 +98,30 @@
|
|||
}, this);
|
||||
|
||||
this.headerText = ko.computed(function () {
|
||||
var sName = this.name();
|
||||
return this.edit() ? Translator.i18n('POPUPS_DOMAIN/TITLE_EDIT_DOMAIN', {'NAME': sName}) :
|
||||
('' === sName ? Translator.i18n('POPUPS_DOMAIN/TITLE_ADD_DOMAIN') :
|
||||
Translator.i18n('POPUPS_DOMAIN/TITLE_ADD_DOMAIN_WITH_NAME', {'NAME': sName}));
|
||||
|
||||
var
|
||||
sName = this.name(),
|
||||
sAliasName = this.aliasName(),
|
||||
sResult = ''
|
||||
;
|
||||
|
||||
if (this.edit())
|
||||
{
|
||||
sResult = Translator.i18n('POPUPS_DOMAIN/TITLE_EDIT_DOMAIN', {'NAME': sName});
|
||||
if (sAliasName)
|
||||
{
|
||||
sResult += ' ← ' + sAliasName;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
sResult = ('' === sName ? Translator.i18n('POPUPS_DOMAIN/TITLE_ADD_DOMAIN') :
|
||||
Translator.i18n('POPUPS_DOMAIN/TITLE_ADD_DOMAIN_WITH_NAME', {'NAME': sName}))
|
||||
;
|
||||
}
|
||||
|
||||
return sResult;
|
||||
|
||||
}, this);
|
||||
|
||||
this.domainDesc = ko.computed(function () {
|
||||
|
|
@ -418,6 +439,7 @@
|
|||
this.smtpAuth(!!oDomain.OutAuth);
|
||||
this.smtpPhpMail(!!oDomain.OutUsePhpMail);
|
||||
this.whiteList(Utils.trim(oDomain.WhiteList));
|
||||
this.aliasName(Utils.trim(oDomain.AliasName));
|
||||
|
||||
this.enableSmartPorts(true);
|
||||
}
|
||||
|
|
@ -464,6 +486,7 @@
|
|||
this.smtpPhpMail(false);
|
||||
|
||||
this.whiteList('');
|
||||
this.aliasName('');
|
||||
this.enableSmartPorts(true);
|
||||
};
|
||||
|
||||
|
|
|
|||
117
dev/View/Popup/DomainAlias.js
Normal file
117
dev/View/Popup/DomainAlias.js
Normal file
|
|
@ -0,0 +1,117 @@
|
|||
|
||||
(function () {
|
||||
|
||||
'use strict';
|
||||
|
||||
var
|
||||
_ = require('_'),
|
||||
ko = require('ko'),
|
||||
|
||||
Enums = require('Common/Enums'),
|
||||
Globals = require('Common/Globals'),
|
||||
Utils = require('Common/Utils'),
|
||||
|
||||
Translator = require('Common/Translator'),
|
||||
|
||||
DomainStore = require('Stores/Admin/Domain'),
|
||||
|
||||
Remote = require('Remote/Admin/Ajax'),
|
||||
|
||||
kn = require('Knoin/Knoin'),
|
||||
AbstractView = require('Knoin/AbstractView')
|
||||
;
|
||||
|
||||
/**
|
||||
* @constructor
|
||||
* @extends AbstractView
|
||||
*/
|
||||
function DomainAliasPopupView()
|
||||
{
|
||||
AbstractView.call(this, 'Popups', 'PopupsDomainAlias');
|
||||
|
||||
this.saving = ko.observable(false);
|
||||
this.savingError = ko.observable('');
|
||||
|
||||
this.name = ko.observable('');
|
||||
this.name.focused = ko.observable(false);
|
||||
|
||||
this.alias = ko.observable('');
|
||||
|
||||
this.domains = DomainStore.domainsWithoutAliases;
|
||||
|
||||
this.domainsOptions = ko.computed(function () {
|
||||
return _.map(this.domains(), function(item) {
|
||||
return {
|
||||
optValue: item.name,
|
||||
optText: item.name
|
||||
};
|
||||
});
|
||||
}, this);
|
||||
|
||||
this.canBeSaved = ko.computed(function () {
|
||||
return !this.saving() && '' !== this.name() && '' !== this.alias();
|
||||
}, this);
|
||||
|
||||
this.createCommand = Utils.createCommand(this, function () {
|
||||
this.saving(true);
|
||||
Remote.createDomainAlias(
|
||||
_.bind(this.onDomainAliasCreateOrSaveResponse, this),
|
||||
this.name(),
|
||||
this.alias()
|
||||
);
|
||||
}, this.canBeSaved);
|
||||
|
||||
kn.constructorEnd(this);
|
||||
}
|
||||
|
||||
kn.extendAsViewModel(['View/Popup/DomainAlias', 'PopupsDomainAliasViewModel'], DomainAliasPopupView);
|
||||
_.extend(DomainAliasPopupView.prototype, AbstractView.prototype);
|
||||
|
||||
DomainAliasPopupView.prototype.onDomainAliasCreateOrSaveResponse = function (sResult, oData)
|
||||
{
|
||||
this.saving(false);
|
||||
if (Enums.StorageResultType.Success === sResult && oData)
|
||||
{
|
||||
if (oData.Result)
|
||||
{
|
||||
require('App/Admin').default.reloadDomainList();
|
||||
this.closeCommand();
|
||||
}
|
||||
else if (Enums.Notification.DomainAlreadyExists === oData.ErrorCode)
|
||||
{
|
||||
this.savingError(Translator.i18n('ERRORS/DOMAIN_ALREADY_EXISTS'));
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
this.savingError(Translator.i18n('ERRORS/UNKNOWN_ERROR'));
|
||||
}
|
||||
};
|
||||
|
||||
DomainAliasPopupView.prototype.onShow = function ()
|
||||
{
|
||||
this.clearForm();
|
||||
};
|
||||
|
||||
DomainAliasPopupView.prototype.onShowWithDelay = function ()
|
||||
{
|
||||
if ('' === this.name() && !Globals.bMobile)
|
||||
{
|
||||
this.name.focused(true);
|
||||
}
|
||||
};
|
||||
|
||||
DomainAliasPopupView.prototype.clearForm = function ()
|
||||
{
|
||||
this.saving(false);
|
||||
this.savingError('');
|
||||
|
||||
this.name('');
|
||||
this.name.focused(false);
|
||||
|
||||
this.alias('');
|
||||
};
|
||||
|
||||
module.exports = DomainAliasPopupView;
|
||||
|
||||
}());
|
||||
Loading…
Add table
Add a link
Reference in a new issue