mirror of
https://github.com/the-djmaze/snappymail.git
synced 2026-09-01 05:29:20 +03:00
Merge Admin Plugins and Packages into single management page
This commit is contained in:
parent
d69743cee5
commit
79945d45b4
20 changed files with 142 additions and 322 deletions
|
|
@ -6,6 +6,10 @@ import { getNotification } from 'Common/Translator';
|
|||
import { PackageAdminStore } from 'Stores/Admin/Package';
|
||||
import Remote from 'Remote/Admin/Fetch';
|
||||
|
||||
import { showScreenPopup } from 'Knoin/Knoin';
|
||||
import { PluginPopupView } from 'View/Popup/Plugin';
|
||||
import { SettingsGet } from 'Common/Globals';
|
||||
|
||||
export class PackagesAdminSettings {
|
||||
constructor() {
|
||||
this.packagesError = ko.observable('');
|
||||
|
|
@ -13,24 +17,42 @@ export class PackagesAdminSettings {
|
|||
this.packages = PackageAdminStore;
|
||||
|
||||
this.packagesCurrent = ko.computed(() =>
|
||||
PackageAdminStore.filter(item => item && item.installed && !item.compare)
|
||||
PackageAdminStore.filter(item => item && item.installed && !item.canBeUpdated)
|
||||
);
|
||||
this.packagesAvailableForUpdate = ko.computed(() =>
|
||||
PackageAdminStore.filter(item => item && item.installed && !!item.compare)
|
||||
PackageAdminStore.filter(item => item && item.installed && !!item.canBeUpdated)
|
||||
);
|
||||
this.packagesAvailableForInstallation = ko.computed(() =>
|
||||
PackageAdminStore.filter(item => item && !item.installed)
|
||||
);
|
||||
|
||||
this.visibility = ko.computed(() => (PackageAdminStore.loading() ? 'visible' : 'hidden'));
|
||||
|
||||
this.enabledPlugins = ko.observable(!!SettingsGet('EnabledPlugins'));
|
||||
this.enabledPlugins.subscribe(value =>
|
||||
Remote.saveAdminConfig(null, {
|
||||
EnabledPlugins: value ? 1 : 0
|
||||
})
|
||||
);
|
||||
}
|
||||
|
||||
onShow() {
|
||||
this.packagesError('');
|
||||
}
|
||||
|
||||
onBuild() {
|
||||
onBuild(oDom) {
|
||||
PackageAdminStore.fetch();
|
||||
|
||||
oDom.addEventListener('click', event => {
|
||||
// configurePlugin
|
||||
let el = event.target.closestWithin('.package-configure', oDom),
|
||||
data = el ? ko.dataFor(el) : 0;
|
||||
data && Remote.plugin((iError, data) => iError || showScreenPopup(PluginPopupView, [data.Result]), data.name)
|
||||
// disablePlugin
|
||||
el = event.target.closestWithin('.package-active', oDom);
|
||||
data = el ? ko.dataFor(el) : 0;
|
||||
data && this.disablePlugin(data);
|
||||
});
|
||||
}
|
||||
|
||||
requestHelper(packageToRequest, install) {
|
||||
|
|
@ -70,4 +92,20 @@ export class PackagesAdminSettings {
|
|||
Remote.packageInstall(this.requestHelper(packageToInstall, true), packageToInstall);
|
||||
}
|
||||
}
|
||||
|
||||
disablePlugin(plugin) {
|
||||
let b = !plugin.enabled();
|
||||
plugin.enabled(b);
|
||||
Remote.pluginDisable((iError, data) => {
|
||||
if (iError) {
|
||||
this.packagesError(
|
||||
(Notification.UnsupportedPluginPackage === iError && data && data.ErrorMessage)
|
||||
? data.ErrorMessage
|
||||
: getNotification(iError)
|
||||
);
|
||||
}
|
||||
// PackageAdminStore.fetch();
|
||||
}, plugin.name, !b);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,63 +0,0 @@
|
|||
import ko from 'ko';
|
||||
|
||||
import { Notification } from 'Common/Enums';
|
||||
import { SettingsGet } from 'Common/Globals';
|
||||
import { getNotification } from 'Common/Translator';
|
||||
|
||||
import { showScreenPopup } from 'Knoin/Knoin';
|
||||
|
||||
import { PluginAdminStore } from 'Stores/Admin/Plugin';
|
||||
|
||||
import Remote from 'Remote/Admin/Fetch';
|
||||
|
||||
import { PluginPopupView } from 'View/Popup/Plugin';
|
||||
|
||||
export class PluginsAdminSettings
|
||||
{
|
||||
constructor() {
|
||||
this.enabledPlugins = ko.observable(!!SettingsGet('EnabledPlugins'));
|
||||
|
||||
this.plugins = PluginAdminStore;
|
||||
this.pluginsError = PluginAdminStore.error;
|
||||
|
||||
this.enabledPlugins.subscribe(value =>
|
||||
Remote.saveAdminConfig(null, {
|
||||
EnabledPlugins: value ? 1 : 0
|
||||
})
|
||||
);
|
||||
}
|
||||
|
||||
disablePlugin(plugin) {
|
||||
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((iError, data) => iError || showScreenPopup(PluginPopupView, [data.Result]), plugin.name);
|
||||
}
|
||||
|
||||
onBuild(oDom) {
|
||||
oDom.addEventListener('click', event => {
|
||||
let el = event.target.closestWithin('.configure-plugin-action', oDom);
|
||||
el && ko.dataFor(el) && this.configurePlugin(ko.dataFor(el));
|
||||
|
||||
el = event.target.closestWithin('.disabled-plugin', oDom);
|
||||
el && ko.dataFor(el) && this.disablePlugin(ko.dataFor(el));
|
||||
});
|
||||
}
|
||||
|
||||
onShow() {
|
||||
PluginAdminStore.error('');
|
||||
PluginAdminStore.fetch();
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue