mirror of
https://github.com/the-djmaze/snappymail.git
synced 2026-08-28 19:49: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
|
|
@ -39,10 +39,11 @@ class AdminApp extends AbstractApp
|
|||
DomainStore.domains.loading(false);
|
||||
if (StorageResultType.Success === result && data && data.Result)
|
||||
{
|
||||
DomainStore.domains(_.map(data.Result, (enabled, name) => {
|
||||
DomainStore.domains(_.map(data.Result, ([enabled, alias], name) => {
|
||||
return {
|
||||
name: name,
|
||||
disabled: ko.observable(!enabled),
|
||||
alias: alias,
|
||||
deleteAccess: ko.observable(false)
|
||||
};
|
||||
}));
|
||||
|
|
|
|||
|
|
@ -6,6 +6,8 @@
|
|||
var
|
||||
_ = require('_'),
|
||||
|
||||
Utils = require('Common/Utils'),
|
||||
|
||||
AbstractAjaxRemote = require('Remote/AbstractAjax')
|
||||
;
|
||||
|
||||
|
|
@ -54,10 +56,14 @@
|
|||
|
||||
/**
|
||||
* @param {?Function} fCallback
|
||||
* @param {boolean=} bIncludeAliases = true
|
||||
*/
|
||||
RemoteAdminStorage.prototype.domainList = function (fCallback)
|
||||
RemoteAdminStorage.prototype.domainList = function (fCallback, bIncludeAliases)
|
||||
{
|
||||
this.defaultRequest(fCallback, 'AdminDomainList');
|
||||
bIncludeAliases = Utils.isUnd(bIncludeAliases) ? true : bIncludeAliases;
|
||||
this.defaultRequest(fCallback, 'AdminDomainList', {
|
||||
'IncludeAliases': bIncludeAliases ? '1' : '0'
|
||||
});
|
||||
};
|
||||
|
||||
/**
|
||||
|
|
@ -208,6 +214,14 @@
|
|||
});
|
||||
};
|
||||
|
||||
RemoteAdminStorage.prototype.createDomainAlias = function (fCallback, sName, sAlias)
|
||||
{
|
||||
this.defaultRequest(fCallback, 'AdminDomainAliasSave', {
|
||||
'Name': sName,
|
||||
'Alias': sAlias
|
||||
});
|
||||
};
|
||||
|
||||
RemoteAdminStorage.prototype.createOrUpdateDomain = function (fCallback,
|
||||
bCreate, sName,
|
||||
sIncHost, iIncPort, sIncSecure, bIncShortLogin,
|
||||
|
|
|
|||
|
|
@ -35,6 +35,11 @@
|
|||
require('Knoin/Knoin').showScreenPopup(require('View/Popup/Domain'));
|
||||
};
|
||||
|
||||
DomainsAdminSettings.prototype.createDomainAlias = function ()
|
||||
{
|
||||
require('Knoin/Knoin').showScreenPopup(require('View/Popup/DomainAlias'));
|
||||
};
|
||||
|
||||
DomainsAdminSettings.prototype.deleteDomain = function (oDomain)
|
||||
{
|
||||
this.domains.remove(oDomain);
|
||||
|
|
|
|||
|
|
@ -14,6 +14,10 @@
|
|||
{
|
||||
this.domains = ko.observableArray([]);
|
||||
this.domains.loading = ko.observable(false).extend({'throttle': 100});
|
||||
|
||||
this.domainsWithoutAliases = this.domains.filter(function (oItem) {
|
||||
return oItem && !oItem.alias;
|
||||
});
|
||||
}
|
||||
|
||||
module.exports = new DomainAdminStore();
|
||||
|
|
|
|||
|
|
@ -1,3 +1,16 @@
|
|||
.b-domain-alias-content {
|
||||
&.modal {
|
||||
width: 330px;
|
||||
}
|
||||
.modal-header {
|
||||
background-color: #fff;
|
||||
}
|
||||
|
||||
.error-desc {
|
||||
color: red;
|
||||
}
|
||||
}
|
||||
|
||||
.b-domain-content {
|
||||
|
||||
&.modal {
|
||||
|
|
@ -40,7 +53,6 @@
|
|||
|
||||
.error-desc {
|
||||
color: red;
|
||||
margin-left: 10px;
|
||||
}
|
||||
|
||||
.testing-done {
|
||||
|
|
|
|||
|
|
@ -24,8 +24,17 @@
|
|||
box-sizing: border-box;
|
||||
}
|
||||
|
||||
&.disabled .domain-name {
|
||||
.domain-alias {
|
||||
display: inline-block;
|
||||
box-sizing: border-box;
|
||||
color: #bbb;
|
||||
padding-left: 5px;
|
||||
}
|
||||
|
||||
&.disabled {
|
||||
.domain-name, .domain-alias {
|
||||
color: #bbb;
|
||||
}
|
||||
}
|
||||
|
||||
.button-delete {
|
||||
|
|
|
|||
|
|
@ -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