2016-07-16 05:29:42 +08:00
|
|
|
import ko from 'ko';
|
2016-06-30 08:02:45 +08:00
|
|
|
|
2019-07-05 03:19:24 +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
|
|
|
|
2019-07-05 03:19:24 +08:00
|
|
|
import { getApp } from 'Helper/Apps/Admin';
|
2016-08-17 06:01:20 +08:00
|
|
|
|
2019-07-05 03:19:24 +08:00
|
|
|
class DomainsAdminSettings {
|
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
|
|
|
|
2020-07-20 21:47:33 +08:00
|
|
|
this.onDomainListChangeRequest = this.onDomainListChangeRequest.bind(this);
|
|
|
|
this.onDomainLoadRequest = this.onDomainLoadRequest.bind(this);
|
2016-07-16 05:29:42 +08:00
|
|
|
}
|
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;
|
2019-07-05 03:19:24 +08:00
|
|
|
oDom.on('click', '.b-admin-domains-list-table .e-item .e-action', function() {
|
|
|
|
// eslint-disable-line prefer-arrow-callback
|
|
|
|
const domainItem = ko.dataFor(this); // eslint-disable-line no-invalid-this
|
|
|
|
if (domainItem) {
|
|
|
|
Remote.domain(self.onDomainLoadRequest, domainItem.name);
|
|
|
|
}
|
|
|
|
});
|
2016-07-16 05:29:42 +08:00
|
|
|
|
2016-08-17 06:01:20 +08:00
|
|
|
getApp().reloadDomainList();
|
2014-08-21 23:08:34 +08:00
|
|
|
}
|
|
|
|
|
2016-07-16 05:29:42 +08:00
|
|
|
onDomainLoadRequest(sResult, oData) {
|
2019-07-05 03:19:24 +08:00
|
|
|
if (StorageResultType.Success === sResult && oData && oData.Result) {
|
2016-07-16 05:29:42 +08:00
|
|
|
showScreenPopup(require('View/Popup/Domain'), [oData.Result]);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
onDomainListChangeRequest() {
|
2016-08-17 06:01:20 +08:00
|
|
|
getApp().reloadDomainList();
|
2016-07-16 05:29:42 +08:00
|
|
|
}
|
|
|
|
}
|
2014-08-21 23:08:34 +08:00
|
|
|
|
2019-07-05 03:19:24 +08:00
|
|
|
export { DomainsAdminSettings, DomainsAdminSettings as default };
|