1
0
Fork 0
mirror of https://github.com/jellyfin/jellyfin-web synced 2025-03-30 19:56:21 +00:00

Merge pull request #2225 from BaronGreenback/NewPluginController

(cherry picked from commit 9f175ee483)
Signed-off-by: Joshua M. Boniface <joshua@boniface.me>
This commit is contained in:
Joshua M. Boniface 2020-12-31 18:47:14 -05:00
parent 7582206eb3
commit aba1d8655b
3 changed files with 56 additions and 8 deletions

View file

@ -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 += "<div data-id='" + plugin.Id + "' data-name='" + plugin.Name + "' data-removable='" + plugin.CanUninstall + "' class='card backdropCard'>";
html += `<div data-id='${plugin.Id}' data-version='${plugin.Version}' data-name='${plugin.Name}' data-removable='${plugin.CanUninstall}' data-status='${plugin.Status}' class='card backdropCard'>`;
html += '<div class="cardBox visualCardBox">';
html += '<div class="cardScalable">';
html += '<div class="cardPadder cardPadder-backdrop"></div>';
html += configPageUrl ? '<a class="cardContent cardImageContainer" is="emby-linkbutton" href="' + configPageUrl + '">' : '<div class="cardContent noConfigPluginCard noHoverEffect cardImageContainer emby-button">';
html += '<span class="cardImageIcon material-icons folder"></span>';
html += configPageUrl ? `<a class="cardContent cardImageContainer" is="emby-linkbutton" href="${configPageUrl}">` : '<div class="cardContent noConfigPluginCard noHoverEffect cardImageContainer emby-button">';
html += '<span class="cardImageIcon';
if (plugin.HasImage) {
html += `"><img src="/Plugins/${plugin.Id}/${plugin.Version}/Image" style="width:100%;height:auto"/>`;
} else {
html += ' material-icons folder">';
}
html += '</span> ';
html += configPageUrl ? '</a>' : '</div>';
html += '</div>';
html += '<div class="cardFooter">';
@ -59,7 +79,7 @@ function getPluginCardHtml(plugin, pluginConfigurationPages) {
html += "<div class='cardText'>";
html += configPage && configPage.DisplayName ? configPage.DisplayName : plugin.Name;
html += '</div>';
html += `<br/>${globalize.translate('LabelStatus')} ${plugin.Status}</div>`;
html += "<div class='cardText cardText-secondary'>";
html += plugin.Version;
html += '</div>';
@ -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;
}
}

View file

@ -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"
}

View file

@ -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.",