snappymail/dev/Settings/Admin/Domains.js

69 lines
1.7 KiB
JavaScript
Raw Normal View History

2014-08-21 23:08:34 +08:00
2016-07-16 05:29:42 +08:00
import _ from '_';
import ko from 'ko';
2016-06-30 08:02:45 +08:00
2016-07-16 05:29:42 +08:00
import {StorageResultType} from 'Common/Enums';
import {showScreenPopup} from 'Knoin/Knoin';
2016-06-30 08:02:45 +08:00
2016-07-16 05:29:42 +08:00
import DomainStore from 'Stores/Admin/Domain';
import Remote from 'Remote/Admin/Ajax';
2016-06-30 08:02:45 +08:00
2016-07-16 05:29:42 +08:00
class DomainsAdminSettings
2016-06-30 08:02:45 +08:00
{
2016-07-16 05:29:42 +08:00
constructor() {
this.domains = DomainStore.domains;
2016-06-30 08:02:45 +08:00
2016-07-16 05:29:42 +08:00
this.visibility = ko.computed(() => (this.domains.loading() ? 'visible' : 'hidden'));
2016-06-30 08:02:45 +08:00
2016-07-16 05:29:42 +08:00
this.domainForDeletion = ko.observable(null).deleteAccessHelper();
2016-06-30 08:02:45 +08:00
2016-07-16 05:29:42 +08:00
this.onDomainListChangeRequest = _.bind(this.onDomainListChangeRequest, this);
this.onDomainLoadRequest = _.bind(this.onDomainLoadRequest, this);
}
2016-06-30 08:02:45 +08:00
2016-07-16 05:29:42 +08:00
createDomain() {
showScreenPopup(require('View/Popup/Domain'));
}
2016-06-30 08:02:45 +08:00
2016-07-16 05:29:42 +08:00
createDomainAlias() {
showScreenPopup(require('View/Popup/DomainAlias'));
}
2016-06-30 08:02:45 +08:00
2016-07-16 05:29:42 +08:00
deleteDomain(domain) {
this.domains.remove(domain);
Remote.domainDelete(this.onDomainListChangeRequest, domain.name);
}
2016-06-30 08:02:45 +08:00
2016-07-16 05:29:42 +08:00
disableDomain(domain) {
domain.disabled(!domain.disabled());
Remote.domainDisable(this.onDomainListChangeRequest, domain.name, domain.disabled());
}
2016-06-30 08:02:45 +08:00
2016-07-16 05:29:42 +08:00
onBuild(oDom) {
const self = this;
oDom
.on('click', '.b-admin-domains-list-table .e-item .e-action', function() {
const domainItem = ko.dataFor(this);
if (domainItem)
{
Remote.domain(self.onDomainLoadRequest, domainItem.name);
}
});
require('App/Admin').default.reloadDomainList();
2014-08-21 23:08:34 +08:00
}
2016-07-16 05:29:42 +08:00
onDomainLoadRequest(sResult, oData) {
if (StorageResultType.Success === sResult && oData && oData.Result)
{
showScreenPopup(require('View/Popup/Domain'), [oData.Result]);
}
}
onDomainListChangeRequest() {
require('App/Admin').default.reloadDomainList();
}
}
2014-08-21 23:08:34 +08:00
2016-07-16 03:54:37 +08:00
export {DomainsAdminSettings, DomainsAdminSettings as default};