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 { showScreenPopup } from 'Knoin/Knoin';
|
2016-06-30 08:02:45 +08:00
|
|
|
|
2021-02-17 21:40:21 +08:00
|
|
|
import { DomainAdminStore } from 'Stores/Admin/Domain';
|
2020-09-15 01:40:56 +08:00
|
|
|
import Remote from 'Remote/Admin/Fetch';
|
2016-06-30 08:02:45 +08:00
|
|
|
|
2021-01-26 05:00:13 +08:00
|
|
|
import { DomainPopupView } from 'View/Popup/Domain';
|
|
|
|
import { DomainAliasPopupView } from 'View/Popup/DomainAlias';
|
|
|
|
|
2021-01-22 23:32:08 +08:00
|
|
|
export class DomainsAdminSettings {
|
2016-07-16 05:29:42 +08:00
|
|
|
constructor() {
|
2021-02-17 21:40:21 +08:00
|
|
|
this.domains = DomainAdminStore;
|
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() {
|
2021-01-26 05:00:13 +08:00
|
|
|
showScreenPopup(DomainPopupView);
|
2016-07-16 05:29:42 +08:00
|
|
|
}
|
2016-06-30 08:02:45 +08:00
|
|
|
|
2016-07-16 05:29:42 +08:00
|
|
|
createDomainAlias() {
|
2021-01-26 05:00:13 +08:00
|
|
|
showScreenPopup(DomainAliasPopupView);
|
2016-07-16 05:29:42 +08:00
|
|
|
}
|
2016-06-30 08:02:45 +08:00
|
|
|
|
2016-07-16 05:29:42 +08:00
|
|
|
deleteDomain(domain) {
|
2021-02-17 21:40:21 +08:00
|
|
|
DomainAdminStore.remove(domain);
|
2016-07-16 05:29:42 +08:00
|
|
|
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) {
|
2020-08-30 16:30:50 +08:00
|
|
|
oDom.addEventListener('click', event => {
|
|
|
|
let el = event.target.closestWithin('.b-admin-domains-list-table .e-item .e-action', oDom);
|
|
|
|
el && ko.dataFor(el) && Remote.domain(this.onDomainLoadRequest, ko.dataFor(el).name);
|
2019-07-05 03:19:24 +08:00
|
|
|
});
|
2016-07-16 05:29:42 +08:00
|
|
|
|
2021-03-15 05:36:23 +08:00
|
|
|
DomainAdminStore.fetch();
|
2014-08-21 23:08:34 +08:00
|
|
|
}
|
|
|
|
|
2021-03-16 16:46:23 +08:00
|
|
|
onDomainLoadRequest(iError, oData) {
|
2021-03-18 21:48:21 +08:00
|
|
|
if (!iError) {
|
2021-01-26 05:00:13 +08:00
|
|
|
showScreenPopup(DomainPopupView, [oData.Result]);
|
2016-07-16 05:29:42 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
onDomainListChangeRequest() {
|
2021-03-15 05:36:23 +08:00
|
|
|
DomainAdminStore.fetch();
|
2016-07-16 05:29:42 +08:00
|
|
|
}
|
|
|
|
}
|