mirror of
https://github.com/the-djmaze/snappymail.git
synced 2026-07-08 22:18:28 +03:00
Cleanup admin code
This commit is contained in:
parent
75c879836c
commit
3572d00a10
16 changed files with 178 additions and 244 deletions
|
|
@ -105,8 +105,6 @@ export class ContactsAdminSettings {
|
|||
})
|
||||
})
|
||||
|
||||
this.onTestContactsResponse = this.onTestContactsResponse.bind(this);
|
||||
|
||||
decorateKoCommands(this, {
|
||||
testContactsCommand: self => self.pdoDsn() && self.pdoUser()
|
||||
});
|
||||
|
|
@ -118,7 +116,24 @@ export class ContactsAdminSettings {
|
|||
this.testContactsErrorMessage('');
|
||||
this.testing(true);
|
||||
|
||||
Remote.testContacts(this.onTestContactsResponse, {
|
||||
Remote.testContacts((iError, data) => {
|
||||
this.testContactsSuccess(false);
|
||||
this.testContactsError(false);
|
||||
this.testContactsErrorMessage('');
|
||||
|
||||
if (!iError && data.Result.Result) {
|
||||
this.testContactsSuccess(true);
|
||||
} else {
|
||||
this.testContactsError(true);
|
||||
if (data && data.Result) {
|
||||
this.testContactsErrorMessage(data.Result.Message || '');
|
||||
} else {
|
||||
this.testContactsErrorMessage('');
|
||||
}
|
||||
}
|
||||
|
||||
this.testing(false);
|
||||
}, {
|
||||
ContactsPdoType: this.contactsType(),
|
||||
ContactsPdoDsn: this.pdoDsn(),
|
||||
ContactsPdoUser: this.pdoUser(),
|
||||
|
|
@ -126,25 +141,6 @@ export class ContactsAdminSettings {
|
|||
});
|
||||
}
|
||||
|
||||
onTestContactsResponse(iError, data) {
|
||||
this.testContactsSuccess(false);
|
||||
this.testContactsError(false);
|
||||
this.testContactsErrorMessage('');
|
||||
|
||||
if (!iError && data.Result.Result) {
|
||||
this.testContactsSuccess(true);
|
||||
} else {
|
||||
this.testContactsError(true);
|
||||
if (data && data.Result) {
|
||||
this.testContactsErrorMessage(data.Result.Message || '');
|
||||
} else {
|
||||
this.testContactsErrorMessage('');
|
||||
}
|
||||
}
|
||||
|
||||
this.testing(false);
|
||||
}
|
||||
|
||||
onShow() {
|
||||
this.testContactsSuccess(false);
|
||||
this.testContactsError(false);
|
||||
|
|
|
|||
|
|
@ -13,9 +13,6 @@ export class DomainsAdminSettings {
|
|||
this.domains = DomainAdminStore;
|
||||
|
||||
this.domainForDeletion = ko.observable(null).deleteAccessHelper();
|
||||
|
||||
this.onDomainListChangeRequest = this.onDomainListChangeRequest.bind(this);
|
||||
this.onDomainLoadRequest = this.onDomainLoadRequest.bind(this);
|
||||
}
|
||||
|
||||
createDomain() {
|
||||
|
|
@ -28,30 +25,22 @@ export class DomainsAdminSettings {
|
|||
|
||||
deleteDomain(domain) {
|
||||
DomainAdminStore.remove(domain);
|
||||
Remote.domainDelete(this.onDomainListChangeRequest, domain.name);
|
||||
Remote.domainDelete(DomainAdminStore.fetch, domain.name);
|
||||
}
|
||||
|
||||
disableDomain(domain) {
|
||||
domain.disabled(!domain.disabled());
|
||||
Remote.domainDisable(this.onDomainListChangeRequest, domain.name, domain.disabled());
|
||||
Remote.domainDisable(DomainAdminStore.fetch, domain.name, domain.disabled());
|
||||
}
|
||||
|
||||
onBuild(oDom) {
|
||||
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);
|
||||
let el = event.target.closestWithin('.b-admin-domains-list-table .e-action', oDom);
|
||||
el && ko.dataFor(el) && Remote.domain(
|
||||
(iError, oData) => iError || showScreenPopup(DomainPopupView, [oData.Result]), ko.dataFor(el).name
|
||||
);
|
||||
});
|
||||
|
||||
DomainAdminStore.fetch();
|
||||
}
|
||||
|
||||
onDomainLoadRequest(iError, oData) {
|
||||
if (!iError) {
|
||||
showScreenPopup(DomainPopupView, [oData.Result]);
|
||||
}
|
||||
}
|
||||
|
||||
onDomainListChangeRequest() {
|
||||
DomainAdminStore.fetch();
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -12,16 +12,14 @@ import Remote from 'Remote/Admin/Fetch';
|
|||
|
||||
import { PluginPopupView } from 'View/Popup/Plugin';
|
||||
|
||||
export class PluginsAdminSettings {
|
||||
export class PluginsAdminSettings
|
||||
{
|
||||
constructor() {
|
||||
this.enabledPlugins = ko.observable(!!SettingsGet('EnabledPlugins'));
|
||||
|
||||
this.plugins = PluginAdminStore;
|
||||
this.pluginsError = PluginAdminStore.error;
|
||||
|
||||
this.onPluginLoadRequest = this.onPluginLoadRequest.bind(this);
|
||||
this.onPluginDisableRequest = this.onPluginDisableRequest.bind(this);
|
||||
|
||||
this.enabledPlugins.subscribe(value =>
|
||||
Remote.saveAdminConfig(null, {
|
||||
EnabledPlugins: value ? 1 : 0
|
||||
|
|
@ -30,20 +28,30 @@ export class PluginsAdminSettings {
|
|||
}
|
||||
|
||||
disablePlugin(plugin) {
|
||||
plugin.disabled(!plugin.disabled());
|
||||
Remote.pluginDisable(this.onPluginDisableRequest, plugin.name, plugin.disabled());
|
||||
let b = !plugin.disabled();
|
||||
plugin.disabled(b);
|
||||
Remote.pluginDisable((iError, data) => {
|
||||
if (iError) {
|
||||
PluginAdminStore.error(
|
||||
(Notification.UnsupportedPluginPackage === iError && data && data.ErrorMessage)
|
||||
? data.ErrorMessage
|
||||
: getNotification(iError)
|
||||
);
|
||||
}
|
||||
PluginAdminStore.fetch();
|
||||
}, plugin.name, b);
|
||||
}
|
||||
|
||||
configurePlugin(plugin) {
|
||||
Remote.plugin(this.onPluginLoadRequest, plugin.name);
|
||||
Remote.plugin((iError, data) => iError || showScreenPopup(PluginPopupView, [data.Result]), plugin.name);
|
||||
}
|
||||
|
||||
onBuild(oDom) {
|
||||
oDom.addEventListener('click', event => {
|
||||
let el = event.target.closestWithin('.e-item .configure-plugin-action', oDom);
|
||||
let el = event.target.closestWithin('.configure-plugin-action', oDom);
|
||||
el && ko.dataFor(el) && this.configurePlugin(ko.dataFor(el));
|
||||
|
||||
el = event.target.closestWithin('.e-item .disabled-plugin', oDom);
|
||||
el = event.target.closestWithin('.disabled-plugin', oDom);
|
||||
el && ko.dataFor(el) && this.disablePlugin(ko.dataFor(el));
|
||||
});
|
||||
}
|
||||
|
|
@ -52,22 +60,4 @@ export class PluginsAdminSettings {
|
|||
PluginAdminStore.error('');
|
||||
PluginAdminStore.fetch();
|
||||
}
|
||||
|
||||
onPluginLoadRequest(iError, data) {
|
||||
if (!iError) {
|
||||
showScreenPopup(PluginPopupView, [data.Result]);
|
||||
}
|
||||
}
|
||||
|
||||
onPluginDisableRequest(iError, data) {
|
||||
if (iError) {
|
||||
if (Notification.UnsupportedPluginPackage === iError && data && data.ErrorMessage) {
|
||||
PluginAdminStore.error(data.ErrorMessage);
|
||||
} else {
|
||||
PluginAdminStore.error(getNotification(iError));
|
||||
}
|
||||
}
|
||||
|
||||
PluginAdminStore.fetch();
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -72,8 +72,6 @@ export class SecurityAdminSettings {
|
|||
})
|
||||
});
|
||||
|
||||
this.onNewAdminPasswordResponse = this.onNewAdminPasswordResponse.bind(this);
|
||||
|
||||
decorateKoCommands(this, {
|
||||
saveNewAdminPasswordCommand: self => self.adminLogin().trim() && self.adminPassword()
|
||||
});
|
||||
|
|
@ -93,7 +91,19 @@ export class SecurityAdminSettings {
|
|||
this.adminPasswordUpdateError(false);
|
||||
this.adminPasswordUpdateSuccess(false);
|
||||
|
||||
Remote.saveNewAdminPassword(this.onNewAdminPasswordResponse, {
|
||||
Remote.saveNewAdminPassword((iError, data) => {
|
||||
if (iError) {
|
||||
this.adminPasswordUpdateError(true);
|
||||
} else {
|
||||
this.adminPassword('');
|
||||
this.adminPasswordNew('');
|
||||
this.adminPasswordNew2('');
|
||||
|
||||
this.adminPasswordUpdateSuccess(true);
|
||||
|
||||
this.weakPassword(!!data.Result.Weak);
|
||||
}
|
||||
}, {
|
||||
'Login': this.adminLogin(),
|
||||
'Password': this.adminPassword(),
|
||||
'NewPassword': this.adminPasswordNew()
|
||||
|
|
@ -102,20 +112,6 @@ export class SecurityAdminSettings {
|
|||
return true;
|
||||
}
|
||||
|
||||
onNewAdminPasswordResponse(iError, data) {
|
||||
if (iError) {
|
||||
this.adminPasswordUpdateError(true);
|
||||
} else {
|
||||
this.adminPassword('');
|
||||
this.adminPasswordNew('');
|
||||
this.adminPasswordNew2('');
|
||||
|
||||
this.adminPasswordUpdateSuccess(true);
|
||||
|
||||
this.weakPassword(!!data.Result.Weak);
|
||||
}
|
||||
}
|
||||
|
||||
onHide() {
|
||||
this.adminPassword('');
|
||||
this.adminPasswordNew('');
|
||||
|
|
|
|||
|
|
@ -3,54 +3,49 @@
|
|||
|
||||
width: 600px;
|
||||
|
||||
.e-item {
|
||||
.domain-name {
|
||||
display: inline-block;
|
||||
word-break: break-all;
|
||||
box-sizing: border-box;
|
||||
}
|
||||
|
||||
.domain-name {
|
||||
display: inline-block;
|
||||
word-break: break-all;
|
||||
box-sizing: border-box;
|
||||
.domain-alias {
|
||||
display: inline-block;
|
||||
box-sizing: border-box;
|
||||
color: #bbb;
|
||||
padding-left: 5px;
|
||||
}
|
||||
|
||||
.button-delete {
|
||||
position: relative;
|
||||
right: 0;
|
||||
visibility: hidden;
|
||||
opacity: 0;
|
||||
white-space: nowrap;
|
||||
|
||||
&.delete-access {
|
||||
visibility: visible;
|
||||
right: -15px;
|
||||
opacity: 1;
|
||||
}
|
||||
}
|
||||
|
||||
.domain-alias {
|
||||
display: inline-block;
|
||||
box-sizing: border-box;
|
||||
.delete-domain, .disabled-domain {
|
||||
cursor: pointer;
|
||||
opacity: 0.5;
|
||||
|
||||
&:hover {
|
||||
opacity: 1;
|
||||
}
|
||||
}
|
||||
|
||||
&.disabled {
|
||||
.domain-name, .domain-alias {
|
||||
color: #bbb;
|
||||
padding-left: 5px;
|
||||
}
|
||||
|
||||
&.disabled {
|
||||
.domain-name, .domain-alias {
|
||||
color: #bbb;
|
||||
}
|
||||
}
|
||||
|
||||
.button-delete {
|
||||
margin-right: 15px;
|
||||
visibility: hidden;
|
||||
opacity: 0;
|
||||
}
|
||||
|
||||
.delete-access {
|
||||
&.button-delete {
|
||||
visibility: visible;
|
||||
margin-right: 0;
|
||||
opacity: 1;
|
||||
}
|
||||
}
|
||||
|
||||
.delete-domain, .disabled-domain {
|
||||
cursor: pointer;
|
||||
.disabled-domain {
|
||||
opacity: 0.5;
|
||||
}
|
||||
|
||||
&.disabled .disabled-domain {
|
||||
opacity: 0.5;
|
||||
}
|
||||
|
||||
.delete-domain, .disabled-domain {
|
||||
&:hover {
|
||||
opacity: 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -11,26 +11,23 @@
|
|||
|
||||
width: 700px;
|
||||
|
||||
.e-item {
|
||||
.package-img {
|
||||
font-size: 12px;
|
||||
margin-right: 2px;
|
||||
}
|
||||
|
||||
.package-img {
|
||||
font-size: 12px;
|
||||
margin-right: 2px;
|
||||
}
|
||||
.package-name.core {
|
||||
font-weight: bold;
|
||||
}
|
||||
.package-desc {
|
||||
color: #999;
|
||||
font-size: 12px;
|
||||
}
|
||||
|
||||
.package-name.core {
|
||||
font-weight: bold;
|
||||
}
|
||||
.package-desc {
|
||||
color: #999;
|
||||
font-size: 12px;
|
||||
}
|
||||
|
||||
.package-release, .package-actions {
|
||||
text-align: center;
|
||||
}
|
||||
.package-actions {
|
||||
vertical-align: middle;
|
||||
}
|
||||
.package-release, .package-actions {
|
||||
text-align: center;
|
||||
}
|
||||
.package-actions {
|
||||
vertical-align: middle;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,25 +1,13 @@
|
|||
|
||||
.b-admin-plugins-list-table {
|
||||
max-width: 620px; /* span8 */
|
||||
|
||||
&.disabled {
|
||||
opacity: 0.5;
|
||||
background-color: #eee;
|
||||
}
|
||||
|
||||
.e-item {
|
||||
.plugin-img {
|
||||
font-size: 12px;
|
||||
margin-right: 2px;
|
||||
}
|
||||
|
||||
&.disabled {
|
||||
.plugin-img, .plugin-name {
|
||||
color: #bbb;
|
||||
}
|
||||
.disabled-plugin {
|
||||
opacity: 0.5;
|
||||
}
|
||||
}
|
||||
.disabled {
|
||||
opacity: 0.5;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -21,7 +21,7 @@ export class MenuSettingsUserView extends AbstractViewLeft {
|
|||
onBuild(dom) {
|
||||
dom.addEventListener('click', event =>
|
||||
ThemeStore.isMobile()
|
||||
&& event.target.closest('.b-settings-menu a', dom)
|
||||
&& event.target.closestWithin('.b-settings-menu a', dom)
|
||||
&& leftPanelDisabled(true)
|
||||
);
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue