mirror of
https://github.com/the-djmaze/snappymail.git
synced 2026-10-29 08:33:32 +03:00
Cleanup admin code
This commit is contained in:
parent
75c879836c
commit
3572d00a10
16 changed files with 178 additions and 244 deletions
|
|
@ -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();
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue