From 856c7b116648a223680f6185757e201de9b61a95 Mon Sep 17 00:00:00 2001 From: BaronGreenback Date: Sun, 13 Dec 2020 22:12:41 +0000 Subject: [PATCH] Update index.js Added plugin status --- .../dashboard/plugins/installed/index.js | 47 ++++++++++++++++++- 1 file changed, 45 insertions(+), 2 deletions(-) diff --git a/src/controllers/dashboard/plugins/installed/index.js b/src/controllers/dashboard/plugins/installed/index.js index 33f9b44ea..186aafd1b 100644 --- a/src/controllers/dashboard/plugins/installed/index.js +++ b/src/controllers/dashboard/plugins/installed/index.js @@ -23,6 +23,20 @@ function deletePlugin(page, uniqueid, name) { }); } +function enablePlugin(page, uniqueid, name) { + loading.show(); + ApiClient.enablePlugin(uniqueid).then(function () { + reloadList(page); + }); +} + +function disablePlugin(page, uniqueid, name) { + loading.show(); + ApiClient.disablePlugin(uniqueid).then(function () { + reloadList(page); + }); +} + function showNoConfigurationMessage() { Dashboard.alert({ message: globalize.translate('MessageNoPluginConfiguration') @@ -41,12 +55,18 @@ function getPluginCardHtml(plugin, pluginConfigurationPages) { })[0]; const configPageUrl = configPage ? Dashboard.getPluginUrl(configPage.Name) : null; let html = ''; - html += "
"; + html += "
"; html += '
'; html += ''; html += '
'; @@ -114,6 +134,7 @@ function showPluginMenu(page, elem) { const name = card.getAttribute('data-name'); const removable = card.getAttribute('data-removable'); const configHref = card.querySelector('.cardContent').getAttribute('href'); + const status = card.getAttribute('data-status'); const menuItems = []; if (configHref) { @@ -125,6 +146,22 @@ function showPluginMenu(page, elem) { } if (removable === 'true') { + if (status === 'Disabled') { + menuItems.push({ + name: globalize.translate('EnablePlugin'), + id: 'enable', + icon: 'enable' + }); + } + + if (status === 'Active') { + menuItems.push({ + name: globalize.translate('DisablePlugin'), + id: 'disable', + icon: 'disable' + }); + } + menuItems.push({ name: globalize.translate('ButtonUninstall'), id: 'delete', @@ -144,6 +181,12 @@ function showPluginMenu(page, elem) { case 'delete': deletePlugin(page, id, name); break; + case 'enable': + enablePlugin(page, id.name); + break; + case 'disable': + disablePlugin(page, id, name); + break; } } });