snappymail/dev/Settings/Admin/Domains.js

71 lines
1.6 KiB
JavaScript
Raw Normal View History

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
import { DomainAdminStore } from 'Stores/Admin/Domain';
import Remote from 'Remote/Admin/Fetch';
2016-06-30 08:02:45 +08:00
import { DomainPopupView } from 'View/Popup/Domain';
import { DomainAliasPopupView } from 'View/Popup/DomainAlias';
export class AdminSettingsDomains /*extends AbstractViewSettings*/ {
2016-07-16 05:29:42 +08:00
constructor() {
this.domains = DomainAdminStore;
2022-11-22 00:18:11 +08:00
this.username = ko.observable('');
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) {
alert(`${oData.Result.email} matched domain: ${oData.Result.domain.name}`);
2022-11-22 00:18:11 +08:00
} else {
alert('No domain match');
}
},
{
username: this.username
2022-11-22 00:18:11 +08:00
}
);
}
2016-07-16 05:29:42 +08:00
createDomain() {
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() {
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) {
DomainAdminStore.remove(domain);
2021-12-03 07:11:19 +08:00
Remote.request('AdminDomainDelete', DomainAdminStore.fetch, {
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, {
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) {
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]),
{
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
DomainAdminStore.fetch();
2014-08-21 23:08:34 +08:00
}
2016-07-16 05:29:42 +08:00
}