snappymail/dev/Settings/Admin/Domains.js

87 lines
2.1 KiB
JavaScript
Raw Normal View History

2014-08-21 23:08:34 +08:00
2014-09-05 06:49:03 +08:00
(function () {
2014-08-25 23:49:01 +08:00
'use strict';
2014-08-21 23:08:34 +08:00
var
2014-08-25 23:49:01 +08:00
_ = require('_'),
ko = require('ko'),
2014-08-21 23:08:34 +08:00
2014-09-05 06:49:03 +08:00
Enums = require('Common/Enums'),
2014-08-21 23:08:34 +08:00
DomainStore = require('Stores/Admin/Domain'),
2015-02-23 00:35:17 +08:00
Remote = require('Remote/Admin/Ajax')
2014-08-21 23:08:34 +08:00
;
/**
* @constructor
*/
function DomainsAdminSettings()
2014-08-21 23:08:34 +08:00
{
2015-02-03 07:58:58 +08:00
this.domains = DomainStore.domains;
2014-08-21 23:08:34 +08:00
this.visibility = ko.computed(function () {
return this.domains.loading() ? 'visible' : 'hidden';
2014-08-21 23:08:34 +08:00
}, this);
this.domainForDeletion = ko.observable(null).deleteAccessHelper();
2016-06-05 02:06:14 +08:00
this.onDomainListChangeRequest = _.bind(this.onDomainListChangeRequest, this);
this.onDomainLoadRequest = _.bind(this.onDomainLoadRequest, this);
2014-08-21 23:08:34 +08:00
}
DomainsAdminSettings.prototype.createDomain = function ()
2014-08-21 23:08:34 +08:00
{
require('Knoin/Knoin').showScreenPopup(require('View/Popup/Domain'));
2014-08-21 23:08:34 +08:00
};
2016-06-11 06:20:09 +08:00
DomainsAdminSettings.prototype.createDomainAlias = function ()
{
require('Knoin/Knoin').showScreenPopup(require('View/Popup/DomainAlias'));
};
DomainsAdminSettings.prototype.deleteDomain = function (oDomain)
2014-08-21 23:08:34 +08:00
{
this.domains.remove(oDomain);
2016-06-05 02:06:14 +08:00
Remote.domainDelete(this.onDomainListChangeRequest, oDomain.name);
2014-08-21 23:08:34 +08:00
};
DomainsAdminSettings.prototype.disableDomain = function (oDomain)
2014-08-21 23:08:34 +08:00
{
oDomain.disabled(!oDomain.disabled());
2016-06-05 02:06:14 +08:00
Remote.domainDisable(this.onDomainListChangeRequest, oDomain.name, oDomain.disabled());
2014-08-21 23:08:34 +08:00
};
DomainsAdminSettings.prototype.onBuild = function (oDom)
2014-08-21 23:08:34 +08:00
{
var self = this;
oDom
.on('click', '.b-admin-domains-list-table .e-item .e-action', function () {
var oDomainItem = ko.dataFor(this);
if (oDomainItem)
{
2016-06-05 02:06:14 +08:00
Remote.domain(self.onDomainLoadRequest, oDomainItem.name);
2014-08-21 23:08:34 +08:00
}
})
;
2015-11-19 01:32:29 +08:00
require('App/Admin').default.reloadDomainList();
2014-08-21 23:08:34 +08:00
};
DomainsAdminSettings.prototype.onDomainLoadRequest = function (sResult, oData)
2014-08-21 23:08:34 +08:00
{
if (Enums.StorageResultType.Success === sResult && oData && oData.Result)
{
require('Knoin/Knoin').showScreenPopup(require('View/Popup/Domain'), [oData.Result]);
2014-08-21 23:08:34 +08:00
}
};
DomainsAdminSettings.prototype.onDomainListChangeRequest = function ()
2014-08-21 23:08:34 +08:00
{
2015-11-19 01:32:29 +08:00
require('App/Admin').default.reloadDomainList();
2014-08-21 23:08:34 +08:00
};
module.exports = DomainsAdminSettings;
2014-08-21 23:08:34 +08:00
2016-06-28 04:54:38 +08:00
}());