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';
|
|
|
|
|
2022-03-08 07:51:32 +08:00
|
|
|
export class AdminSettingsDomains /*extends AbstractViewSettings*/ {
|
2016-07-16 05:29:42 +08:00
|
|
|
constructor() {
|
2021-02-17 21:40:21 +08:00
|
|
|
this.domains = DomainAdminStore;
|
2022-11-22 00:18:11 +08:00
|
|
|
this.username = ko.observable('');
|
2022-01-28 06:07:34 +08:00
|
|
|
this.domainForDeletion = ko.observable(null).askDeleteHelper();
|
2016-07-16 05:29:42 +08:00
|
|
|
}
|
2016-06-30 08:02:45 +08:00
|
|
|
|
2022-11-22 00:18:11 +08:00
|
|
|
testUsername() {
|
|
|
|
Remote.request('AdminDomainMatch',
|
|
|
|
(iError, oData) => {
|
|
|
|
if (oData?.Result?.domain) {
|
2022-12-06 17:50:55 +08:00
|
|
|
alert(`${oData.Result.email} matched domain: ${oData.Result.domain.name}`);
|
2022-11-22 00:18:11 +08:00
|
|
|
} else {
|
|
|
|
alert('No domain match');
|
|
|
|
}
|
|
|
|
},
|
|
|
|
{
|
2023-01-26 17:41:55 +08:00
|
|
|
username: this.username
|
2022-11-22 00:18:11 +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);
|
2021-12-03 07:11:19 +08:00
|
|
|
Remote.request('AdminDomainDelete', DomainAdminStore.fetch, {
|
2023-01-26 17:41:55 +08:00
|
|
|
name: domain.name
|
2021-12-03 07:11:19 +08:00
|
|
|
});
|
2016-07-16 05:29:42 +08:00
|
|
|
}
|
2016-06-30 08:02:45 +08:00
|
|
|
|
2016-07-16 05:29:42 +08:00
|
|
|
disableDomain(domain) {
|
|
|
|
domain.disabled(!domain.disabled());
|
2021-12-03 07:11:19 +08:00
|
|
|
Remote.request('AdminDomainDisable', DomainAdminStore.fetch, {
|
2023-01-26 17:41:55 +08:00
|
|
|
name: domain.name,
|
|
|
|
disabled: domain.disabled() ? 1 : 0
|
2021-12-03 07:11:19 +08:00
|
|
|
});
|
2016-07-16 05:29:42 +08:00
|
|
|
}
|
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 => {
|
2021-04-23 03:56:01 +08:00
|
|
|
let el = event.target.closestWithin('.b-admin-domains-list-table .e-action', oDom);
|
2021-12-03 07:11:19 +08:00
|
|
|
el && ko.dataFor(el) && Remote.request('AdminDomainLoad',
|
|
|
|
(iError, oData) => iError || showScreenPopup(DomainPopupView, [oData.Result]),
|
|
|
|
{
|
2023-01-26 17:41:55 +08:00
|
|
|
name: ko.dataFor(el).name
|
2021-12-03 07:11:19 +08:00
|
|
|
}
|
2021-04-23 03:56:01 +08:00
|
|
|
);
|
2021-12-03 07:11:19 +08:00
|
|
|
|
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
|
|
|
}
|
2016-07-16 05:29:42 +08:00
|
|
|
}
|