From aba1d8655b2d7db9b750d11fab273bd7c6619a8b Mon Sep 17 00:00:00 2001 From: "Joshua M. Boniface" Date: Thu, 31 Dec 2020 18:47:14 -0500 Subject: [PATCH] Merge pull request #2225 from BaronGreenback/NewPluginController (cherry picked from commit 9f175ee4835991bc054b1991e61454555aae504c) Signed-off-by: Joshua M. Boniface --- .../dashboard/plugins/installed/index.js | 58 ++++++++++++++++--- src/strings/en-gb.json | 4 +- src/strings/en-us.json | 2 + 3 files changed, 56 insertions(+), 8 deletions(-) diff --git a/src/controllers/dashboard/plugins/installed/index.js b/src/controllers/dashboard/plugins/installed/index.js index 33f9b44ea2..76249abf64 100644 --- a/src/controllers/dashboard/plugins/installed/index.js +++ b/src/controllers/dashboard/plugins/installed/index.js @@ -7,7 +7,7 @@ import '../../../../elements/emby-button/emby-button'; import Dashboard, { pageIdOn } from '../../../../scripts/clientUtils'; import confirm from '../../../../components/confirm/confirm'; -function deletePlugin(page, uniqueid, name) { +function deletePlugin(page, uniqueid, version, name) { const msg = globalize.translate('UninstallPluginConfirmation', name); confirm({ @@ -17,12 +17,26 @@ function deletePlugin(page, uniqueid, name) { confirmText: globalize.translate('HeaderUninstallPlugin') }).then(function () { loading.show(); - ApiClient.uninstallPlugin(uniqueid).then(function () { + ApiClient.uninstallPluginByVersion(uniqueid, version).then(function () { reloadList(page); }); }); } +function enablePlugin(page, uniqueid, version) { + loading.show(); + ApiClient.enablePlugin(uniqueid, version).then(function () { + reloadList(page); + }); +} + +function disablePlugin(page, uniqueid, version) { + loading.show(); + ApiClient.disablePlugin(uniqueid, version).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 += '
'; - html += configPageUrl ? '' : ''; html += '
'; @@ -59,7 +79,7 @@ function getPluginCardHtml(plugin, pluginConfigurationPages) { html += "
"; html += configPage && configPage.DisplayName ? configPage.DisplayName : plugin.Name; - html += '
'; + html += `
${globalize.translate('LabelStatus')} ${plugin.Status}
`; html += "
"; html += plugin.Version; html += '
'; @@ -114,6 +134,8 @@ 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 version = card.getAttribute('data-version'); const menuItems = []; if (configHref) { @@ -125,6 +147,22 @@ function showPluginMenu(page, elem) { } if (removable === 'true') { + if (status === 'Disabled') { + menuItems.push({ + name: globalize.translate('EnablePlugin'), + id: 'enable', + icon: 'mode_enable' + }); + } + + if (status === 'Active') { + menuItems.push({ + name: globalize.translate('DisablePlugin'), + id: 'disable', + icon: 'mode_disable' + }); + } + menuItems.push({ name: globalize.translate('ButtonUninstall'), id: 'delete', @@ -142,7 +180,13 @@ function showPluginMenu(page, elem) { Dashboard.navigate(configHref); break; case 'delete': - deletePlugin(page, id, name); + deletePlugin(page, id, version, name); + break; + case 'enable': + enablePlugin(page, id, version); + break; + case 'disable': + disablePlugin(page, id, version); break; } } diff --git a/src/strings/en-gb.json b/src/strings/en-gb.json index 63ac2f57b4..83e1219d38 100644 --- a/src/strings/en-gb.json +++ b/src/strings/en-gb.json @@ -1456,5 +1456,7 @@ "LabelEnableIP6": "Enable IPv6:", "LabelEnableIP4Help": "Enables IPv4 functionality.", "LabelEnableIP4": "Enable IPv4:", - "HeaderNetworking": "IP Protocols" + "HeaderNetworking": "IP Protocols", + "EnablePlugin": "Enable Plugin", + "DisablePlugin": "Disable Plugin" } diff --git a/src/strings/en-us.json b/src/strings/en-us.json index 84691e9b4e..a7a376a552 100644 --- a/src/strings/en-us.json +++ b/src/strings/en-us.json @@ -179,6 +179,7 @@ "DirectStreamHelp1": "The video stream is compatible with the device, but has an incompatible audio format (DTS, TRUEHD, etc) or number of audio channels. The video stream will be repackaged losslessly on the fly before being sent to the device. Only the audio stream will be transcoded.", "DirectStreamHelp2": "Power consumed by direct streaming usually depends on the audio profile. Only the video stream is lossless.", "DirectStreaming": "Direct streaming", + "DisablePlugin": "Disable Plugin", "Disc": "Disc", "Disconnect": "Disconnect", "Display": "Display", @@ -218,6 +219,7 @@ "EnableNextVideoInfoOverlayHelp": "At the end of a video, display info about the next video coming up in the current playlist.", "EnablePhotos": "Display photos", "EnablePhotosHelp": "Images will be detected and displayed alongside other media files.", + "EnablePlugin": "Enable Plugin", "EnableQuickConnect": "Enable quick connect on this server", "EnableStreamLooping": "Auto-loop live streams", "EnableStreamLoopingHelp": "Enable this if live streams only contain a few seconds of data and need to be continuously requested. Enabling this when not needed may cause problems.",