mirror of
https://github.com/jellyfin/jellyfin-web.git
synced 2024-11-15 18:08:17 -07:00
Migrate add, installed, available plugin pages to ES6
This commit is contained in:
parent
15b0f3ec99
commit
af2fab85d1
@ -209,6 +209,9 @@
|
|||||||
"src/controllers/dashboard/notifications/notification.js",
|
"src/controllers/dashboard/notifications/notification.js",
|
||||||
"src/controllers/dashboard/notifications/notifications.js",
|
"src/controllers/dashboard/notifications/notifications.js",
|
||||||
"src/controllers/dashboard/playback.js",
|
"src/controllers/dashboard/playback.js",
|
||||||
|
"src/controllers/dashboard/plugins/add/index.js",
|
||||||
|
"src/controllers/dashboard/plugins/installed/index.js",
|
||||||
|
"src/controllers/dashboard/plugins/available/index.js",
|
||||||
"src/controllers/dashboard/plugins/repositories/index.js",
|
"src/controllers/dashboard/plugins/repositories/index.js",
|
||||||
"src/controllers/dashboard/scheduledtasks/scheduledtask.js",
|
"src/controllers/dashboard/scheduledtasks/scheduledtask.js",
|
||||||
"src/controllers/dashboard/scheduledtasks/scheduledtasks.js",
|
"src/controllers/dashboard/scheduledtasks/scheduledtasks.js",
|
||||||
|
@ -1,143 +1,148 @@
|
|||||||
define(['jQuery', 'loading', 'libraryMenu', 'globalize', 'connectionManager', 'emby-button'], function ($, loading, libraryMenu, globalize, connectionManager) {
|
import $ from 'jQuery';
|
||||||
'use strict';
|
import loading from 'loading';
|
||||||
|
import globalize from 'globalize';
|
||||||
|
import 'emby-button';
|
||||||
|
|
||||||
loading = loading.default || loading;
|
function populateHistory(packageInfo, page) {
|
||||||
|
let html = '';
|
||||||
|
const length = Math.min(packageInfo.versions.length, 10);
|
||||||
|
|
||||||
function populateHistory(packageInfo, page) {
|
for (let i = 0; i < length; i++) {
|
||||||
var html = '';
|
let version = packageInfo.versions[i];
|
||||||
var length = Math.min(packageInfo.versions.length, 10);
|
html += '<h2 style="margin:.5em 0;">' + version.version + '</h2>';
|
||||||
|
html += '<div style="margin-bottom:1.5em;">' + version.changelog + '</div>';
|
||||||
for (var i = 0; i < length; i++) {
|
|
||||||
var version = packageInfo.versions[i];
|
|
||||||
html += '<h2 style="margin:.5em 0;">' + version.version + '</h2>';
|
|
||||||
html += '<div style="margin-bottom:1.5em;">' + version.changelog + '</div>';
|
|
||||||
}
|
|
||||||
|
|
||||||
$('#revisionHistory', page).html(html);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function populateVersions(packageInfo, page, installedPlugin) {
|
$('#revisionHistory', page).html(html);
|
||||||
var html = '';
|
}
|
||||||
|
|
||||||
for (var i = 0; i < packageInfo.versions.length; i++) {
|
function populateVersions(packageInfo, page, installedPlugin) {
|
||||||
var version = packageInfo.versions[i];
|
let html = '';
|
||||||
html += '<option value="' + version.version + '">' + version.version + '</option>';
|
|
||||||
}
|
|
||||||
|
|
||||||
var selectmenu = $('#selectVersion', page).html(html);
|
for (let i = 0; i < packageInfo.versions.length; i++) {
|
||||||
|
const version = packageInfo.versions[i];
|
||||||
if (!installedPlugin) {
|
html += '<option value="' + version.version + '">' + version.version + '</option>';
|
||||||
$('#pCurrentVersion', page).hide().html('');
|
|
||||||
}
|
|
||||||
|
|
||||||
var packageVersion = packageInfo.versions[0];
|
|
||||||
if (packageVersion) {
|
|
||||||
selectmenu.val(packageVersion.version);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function renderPackage(pkg, installedPlugins, page) {
|
const selectmenu = $('#selectVersion', page).html(html);
|
||||||
var installedPlugin = installedPlugins.filter(function (ip) {
|
|
||||||
return ip.Name == pkg.name;
|
|
||||||
})[0];
|
|
||||||
|
|
||||||
populateVersions(pkg, page, installedPlugin);
|
if (!installedPlugin) {
|
||||||
populateHistory(pkg, page);
|
$('#pCurrentVersion', page).hide().html('');
|
||||||
|
|
||||||
$('.pluginName', page).html(pkg.name);
|
|
||||||
$('#btnInstallDiv', page).removeClass('hide');
|
|
||||||
$('#pSelectVersion', page).removeClass('hide');
|
|
||||||
|
|
||||||
if (pkg.overview) {
|
|
||||||
$('#overview', page).show().html(pkg.overview);
|
|
||||||
} else {
|
|
||||||
$('#overview', page).hide();
|
|
||||||
}
|
|
||||||
|
|
||||||
$('#description', page).html(pkg.description);
|
|
||||||
$('#developer', page).html(pkg.owner);
|
|
||||||
|
|
||||||
if (installedPlugin) {
|
|
||||||
var currentVersionText = globalize.translate('MessageYouHaveVersionInstalled', '<strong>' + installedPlugin.Version + '</strong>');
|
|
||||||
$('#pCurrentVersion', page).show().html(currentVersionText);
|
|
||||||
} else {
|
|
||||||
$('#pCurrentVersion', page).hide().html('');
|
|
||||||
}
|
|
||||||
|
|
||||||
loading.hide();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function alertText(options) {
|
const packageVersion = packageInfo.versions[0];
|
||||||
require(['alert'], function ({default: alert}) {
|
if (packageVersion) {
|
||||||
alert(options);
|
selectmenu.val(packageVersion.version);
|
||||||
});
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function renderPackage(pkg, installedPlugins, page) {
|
||||||
|
const installedPlugin = installedPlugins.filter(function (ip) {
|
||||||
|
return ip.Name == pkg.name;
|
||||||
|
})[0];
|
||||||
|
|
||||||
|
populateVersions(pkg, page, installedPlugin);
|
||||||
|
populateHistory(pkg, page);
|
||||||
|
|
||||||
|
$('.pluginName', page).html(pkg.name);
|
||||||
|
$('#btnInstallDiv', page).removeClass('hide');
|
||||||
|
$('#pSelectVersion', page).removeClass('hide');
|
||||||
|
|
||||||
|
if (pkg.overview) {
|
||||||
|
$('#overview', page).show().html(pkg.overview);
|
||||||
|
} else {
|
||||||
|
$('#overview', page).hide();
|
||||||
}
|
}
|
||||||
|
|
||||||
function performInstallation(page, name, guid, version) {
|
$('#description', page).html(pkg.description);
|
||||||
var developer = $('#developer', page).html().toLowerCase();
|
$('#developer', page).html(pkg.owner);
|
||||||
|
|
||||||
var alertCallback = function () {
|
if (installedPlugin) {
|
||||||
loading.show();
|
const currentVersionText = globalize.translate('MessageYouHaveVersionInstalled', '<strong>' + installedPlugin.Version + '</strong>');
|
||||||
page.querySelector('#btnInstall').disabled = true;
|
$('#pCurrentVersion', page).show().html(currentVersionText);
|
||||||
ApiClient.installPlugin(name, guid, version).then(function () {
|
} else {
|
||||||
loading.hide();
|
$('#pCurrentVersion', page).hide().html('');
|
||||||
alertText(globalize.translate('MessagePluginInstalled'));
|
}
|
||||||
});
|
|
||||||
};
|
|
||||||
|
|
||||||
if (developer !== 'jellyfin') {
|
loading.hide();
|
||||||
|
}
|
||||||
|
|
||||||
|
function alertText(options) {
|
||||||
|
import('alert').then(({default: alert}) => {
|
||||||
|
alert(options);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
function performInstallation(page, name, guid, version) {
|
||||||
|
const developer = $('#developer', page).html().toLowerCase();
|
||||||
|
|
||||||
|
const alertCallback = function () {
|
||||||
|
loading.show();
|
||||||
|
page.querySelector('#btnInstall').disabled = true;
|
||||||
|
ApiClient.installPlugin(name, guid, version).then(() => {
|
||||||
loading.hide();
|
loading.hide();
|
||||||
var msg = globalize.translate('MessagePluginInstallDisclaimer');
|
alertText(globalize.translate('MessagePluginInstalled'));
|
||||||
msg += '<br/>';
|
}).catch(() => {
|
||||||
msg += '<br/>';
|
alertText(globalize.translate('MessagePluginIntallError'));
|
||||||
msg += globalize.translate('PleaseConfirmPluginInstallation');
|
});
|
||||||
|
};
|
||||||
|
|
||||||
require(['confirm'], function (confirm) {
|
if (developer !== 'jellyfin') {
|
||||||
confirm.default(msg, globalize.translate('HeaderConfirmPluginInstallation')).then(function () {
|
loading.hide();
|
||||||
alertCallback();
|
let msg = globalize.translate('MessagePluginInstallDisclaimer');
|
||||||
}, function () {
|
msg += '<br/>';
|
||||||
console.debug('plugin not installed');
|
msg += '<br/>';
|
||||||
});
|
msg += globalize.translate('PleaseConfirmPluginInstallation');
|
||||||
|
|
||||||
|
import('confirm').then(({default: confirm}) => {
|
||||||
|
confirm.default(msg, globalize.translate('HeaderConfirmPluginInstallation')).then(function () {
|
||||||
|
alertCallback();
|
||||||
|
}).catch(() => {
|
||||||
|
console.debug('plugin not installed');
|
||||||
});
|
});
|
||||||
} else {
|
});
|
||||||
alertCallback();
|
} else {
|
||||||
}
|
alertCallback();
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return function (view, params) {
|
export default function(view, params) {
|
||||||
$('.addPluginForm', view).on('submit', function () {
|
$('.addPluginForm', view).on('submit', function () {
|
||||||
loading.show();
|
loading.show();
|
||||||
var page = $(this).parents('#addPluginPage')[0];
|
const page = $(this).parents('#addPluginPage')[0];
|
||||||
var name = params.name;
|
const name = params.name;
|
||||||
var guid = params.guid;
|
const guid = params.guid;
|
||||||
ApiClient.getInstalledPlugins().then(function (plugins) {
|
ApiClient.getInstalledPlugins().then(function (plugins) {
|
||||||
var installedPlugin = plugins.filter(function (plugin) {
|
const installedPlugin = plugins.filter(function (plugin) {
|
||||||
return plugin.Name == name;
|
return plugin.Name == name;
|
||||||
})[0];
|
})[0];
|
||||||
|
|
||||||
var version = $('#selectVersion', page).val();
|
const version = $('#selectVersion', page).val();
|
||||||
if (installedPlugin && installedPlugin.Version === version) {
|
if (installedPlugin) {
|
||||||
|
if (installedPlugin.Version === version) {
|
||||||
loading.hide();
|
loading.hide();
|
||||||
Dashboard.alert({
|
Dashboard.alert({
|
||||||
message: globalize.translate('MessageAlreadyInstalled'),
|
message: globalize.translate('MessageAlreadyInstalled'),
|
||||||
title: globalize.translate('HeaderPluginInstallation')
|
title: globalize.translate('HeaderPluginInstallation')
|
||||||
});
|
});
|
||||||
} else {
|
|
||||||
performInstallation(page, name, guid, version);
|
|
||||||
}
|
}
|
||||||
});
|
} else {
|
||||||
return false;
|
performInstallation(page, name, guid, version);
|
||||||
|
}
|
||||||
|
}).catch(() => {
|
||||||
|
alertText(globalize.translate('MessageGetInstalledPluginsError'));
|
||||||
});
|
});
|
||||||
view.addEventListener('viewshow', function () {
|
return false;
|
||||||
var page = this;
|
});
|
||||||
loading.show();
|
view.addEventListener('viewshow', function () {
|
||||||
var name = params.name;
|
const page = this;
|
||||||
var guid = params.guid;
|
loading.show();
|
||||||
var promise1 = ApiClient.getPackageInfo(name, guid);
|
const name = params.name;
|
||||||
var promise2 = ApiClient.getInstalledPlugins();
|
const guid = params.guid;
|
||||||
Promise.all([promise1, promise2]).then(function (responses) {
|
const promise1 = ApiClient.getPackageInfo(name, guid);
|
||||||
renderPackage(responses[0], responses[1], page);
|
const promise2 = ApiClient.getInstalledPlugins();
|
||||||
});
|
Promise.all([promise1, promise2]).then(function (responses) {
|
||||||
|
renderPackage(responses[0], responses[1], page);
|
||||||
});
|
});
|
||||||
};
|
});
|
||||||
});
|
}
|
||||||
|
@ -1,143 +1,141 @@
|
|||||||
define(['loading', 'libraryMenu', 'globalize', 'cardStyle', 'emby-button', 'emby-checkbox', 'emby-select'], function (loading, libraryMenu, globalize) {
|
import loading from 'loading';
|
||||||
'use strict';
|
import libraryMenu from 'libraryMenu';
|
||||||
|
import globalize from 'globalize';
|
||||||
|
import 'cardStyle';
|
||||||
|
import 'emby-button';
|
||||||
|
import 'emby-checkbox';
|
||||||
|
import 'emby-select';
|
||||||
|
|
||||||
loading = loading.default || loading;
|
function reloadList(page) {
|
||||||
|
loading.show();
|
||||||
function reloadList(page) {
|
const promise1 = ApiClient.getAvailablePlugins();
|
||||||
loading.show();
|
const promise2 = ApiClient.getInstalledPlugins();
|
||||||
var promise1 = ApiClient.getAvailablePlugins();
|
Promise.all([promise1, promise2]).then(function (responses) {
|
||||||
var promise2 = ApiClient.getInstalledPlugins();
|
populateList({
|
||||||
Promise.all([promise1, promise2]).then(function (responses) {
|
catalogElement: page.querySelector('#pluginTiles'),
|
||||||
populateList({
|
noItemsElement: page.querySelector('#noPlugins'),
|
||||||
catalogElement: page.querySelector('#pluginTiles'),
|
availablePlugins: responses[0],
|
||||||
noItemsElement: page.querySelector('#noPlugins'),
|
installedPlugins: responses[1]
|
||||||
availablePlugins: responses[0],
|
|
||||||
installedPlugins: responses[1]
|
|
||||||
});
|
|
||||||
});
|
});
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
function getHeaderText(category) {
|
||||||
|
category = category.replace(' ', '');
|
||||||
|
if ('Channel' === category) {
|
||||||
|
category = 'Channels';
|
||||||
|
} else if ('Theme' === category) {
|
||||||
|
category = 'Themes';
|
||||||
|
} else if ('LiveTV' === category) {
|
||||||
|
category = 'HeaderLiveTV';
|
||||||
|
} else if ('ScreenSaver' === category) {
|
||||||
|
category = 'HeaderScreenSavers';
|
||||||
}
|
}
|
||||||
|
|
||||||
function getHeaderText(category) {
|
return globalize.translate(category);
|
||||||
category = category.replace(' ', '');
|
}
|
||||||
if (category === 'Channel') {
|
|
||||||
category = 'Channels';
|
function populateList(options) {
|
||||||
} else if (category === 'Theme') {
|
const availablePlugins = options.availablePlugins;
|
||||||
category = 'Themes';
|
const installedPlugins = options.installedPlugins;
|
||||||
} else if (category === 'LiveTV') {
|
|
||||||
category = 'HeaderLiveTV';
|
availablePlugins.forEach(function (plugin, index, array) {
|
||||||
} else if (category === 'ScreenSaver') {
|
plugin.category = plugin.category || 'General';
|
||||||
category = 'HeaderScreenSavers';
|
plugin.categoryDisplayName = getHeaderText(plugin.category);
|
||||||
|
array[index] = plugin;
|
||||||
|
});
|
||||||
|
|
||||||
|
availablePlugins.sort(function (a, b) {
|
||||||
|
if (a.category > b.category) {
|
||||||
|
return 1;
|
||||||
|
} else if (b.category > a.category) {
|
||||||
|
return -1;
|
||||||
}
|
}
|
||||||
|
if (a.name > b.name) {
|
||||||
|
return 1;
|
||||||
|
} else if (b.name > a.name) {
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
});
|
||||||
|
|
||||||
return globalize.translate(category);
|
let currentCategory = null;
|
||||||
}
|
let html = '';
|
||||||
|
|
||||||
function populateList(options) {
|
for (let i = 0; i < availablePlugins.length; i++) {
|
||||||
var availablePlugins = options.availablePlugins;
|
const plugin = availablePlugins[i];
|
||||||
var installedPlugins = options.installedPlugins;
|
const category = plugin.categoryDisplayName;
|
||||||
|
if (category != currentCategory) {
|
||||||
availablePlugins.forEach(function (plugin, index, array) {
|
if (currentCategory) {
|
||||||
plugin.category = plugin.category || 'General';
|
html += '</div>';
|
||||||
plugin.categoryDisplayName = getHeaderText(plugin.category);
|
html += '</div>';
|
||||||
array[index] = plugin;
|
|
||||||
});
|
|
||||||
|
|
||||||
availablePlugins.sort(function (a, b) {
|
|
||||||
if (a.category > b.category) {
|
|
||||||
return 1;
|
|
||||||
} else if (b.category > a.category) {
|
|
||||||
return -1;
|
|
||||||
}
|
}
|
||||||
if (a.name > b.name) {
|
html += '<div class="verticalSection">';
|
||||||
return 1;
|
html += '<h2 class="sectionTitle sectionTitle-cards">' + category + '</h2>';
|
||||||
} else if (b.name > a.name) {
|
html += '<div class="itemsContainer vertical-wrap">';
|
||||||
return -1;
|
currentCategory = category;
|
||||||
}
|
|
||||||
return 0;
|
|
||||||
});
|
|
||||||
|
|
||||||
var currentCategory = null;
|
|
||||||
var html = '';
|
|
||||||
|
|
||||||
for (var i = 0; i < availablePlugins.length; i++) {
|
|
||||||
var plugin = availablePlugins[i];
|
|
||||||
var category = plugin.categoryDisplayName;
|
|
||||||
if (category != currentCategory) {
|
|
||||||
if (currentCategory) {
|
|
||||||
html += '</div>';
|
|
||||||
html += '</div>';
|
|
||||||
}
|
|
||||||
html += '<div class="verticalSection">';
|
|
||||||
html += '<h2 class="sectionTitle sectionTitle-cards">' + category + '</h2>';
|
|
||||||
html += '<div class="itemsContainer vertical-wrap">';
|
|
||||||
currentCategory = category;
|
|
||||||
}
|
|
||||||
html += getPluginHtml(plugin, options, installedPlugins);
|
|
||||||
}
|
}
|
||||||
html += '</div>';
|
html += getPluginHtml(plugin, options, installedPlugins);
|
||||||
html += '</div>';
|
}
|
||||||
|
html += '</div>';
|
||||||
|
html += '</div>';
|
||||||
|
|
||||||
if (!availablePlugins.length && options.noItemsElement) {
|
if (!availablePlugins.length && options.noItemsElement) {
|
||||||
options.noItemsElement.classList.remove('hide');
|
options.noItemsElement.classList.remove('hide');
|
||||||
}
|
|
||||||
|
|
||||||
options.catalogElement.innerHTML = html;
|
|
||||||
loading.hide();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function getPluginHtml(plugin, options, installedPlugins) {
|
options.catalogElement.innerHTML = html;
|
||||||
var html = '';
|
loading.hide();
|
||||||
var href = plugin.externalUrl ? plugin.externalUrl : 'addplugin.html?name=' + encodeURIComponent(plugin.name) + '&guid=' + plugin.guid;
|
}
|
||||||
|
|
||||||
if (options.context) {
|
function getPluginHtml(plugin, options, installedPlugins) {
|
||||||
href += '&context=' + options.context;
|
let html = '';
|
||||||
}
|
let href = plugin.externalUrl ? plugin.externalUrl : 'addplugin.html?name=' + encodeURIComponent(plugin.name) + '&guid=' + plugin.guid;
|
||||||
|
|
||||||
var target = plugin.externalUrl ? ' target="_blank"' : '';
|
if (options.context) {
|
||||||
html += "<div class='card backdropCard'>";
|
href += '&context=' + options.context;
|
||||||
html += '<div class="cardBox visualCardBox">';
|
|
||||||
html += '<div class="cardScalable visualCardBox-cardScalable">';
|
|
||||||
html += '<div class="cardPadder cardPadder-backdrop"></div>';
|
|
||||||
html += '<a class="cardContent cardImageContainer" is="emby-linkbutton" href="' + href + '"' + target + '>';
|
|
||||||
html += '<span class="cardImageIcon material-icons folder"></span>';
|
|
||||||
html += '</a>';
|
|
||||||
html += '</div>';
|
|
||||||
html += '<div class="cardFooter">';
|
|
||||||
html += "<div class='cardText'>";
|
|
||||||
html += plugin.name;
|
|
||||||
html += '</div>';
|
|
||||||
var installedPlugin = installedPlugins.filter(function (ip) {
|
|
||||||
return ip.Id == plugin.guid;
|
|
||||||
})[0];
|
|
||||||
html += "<div class='cardText cardText-secondary'>";
|
|
||||||
html += installedPlugin ? globalize.translate('LabelVersionInstalled', installedPlugin.Version) : ' ';
|
|
||||||
html += '</div>';
|
|
||||||
html += '</div>';
|
|
||||||
html += '</div>';
|
|
||||||
return html += '</div>';
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function getTabs() {
|
const target = plugin.externalUrl ? ' target="_blank"' : '';
|
||||||
return [{
|
html += "<div class='card backdropCard'>";
|
||||||
href: 'installedplugins.html',
|
html += '<div class="cardBox visualCardBox">';
|
||||||
name: globalize.translate('TabMyPlugins')
|
html += '<div class="cardScalable visualCardBox-cardScalable">';
|
||||||
}, {
|
html += '<div class="cardPadder cardPadder-backdrop"></div>';
|
||||||
href: 'availableplugins.html',
|
html += '<a class="cardContent cardImageContainer" is="emby-linkbutton" href="' + href + '"' + target + '>';
|
||||||
name: globalize.translate('TabCatalog')
|
html += '<span class="cardImageIcon material-icons folder"></span>';
|
||||||
}, {
|
html += '</a>';
|
||||||
href: 'repositories.html',
|
html += '</div>';
|
||||||
name: globalize.translate('TabRepositories')
|
html += '<div class="cardFooter">';
|
||||||
}];
|
html += "<div class='cardText'>";
|
||||||
}
|
html += plugin.name;
|
||||||
|
html += '</div>';
|
||||||
|
const installedPlugin = installedPlugins.filter(function (ip) {
|
||||||
|
return ip.Id == plugin.guid;
|
||||||
|
})[0];
|
||||||
|
html += "<div class='cardText cardText-secondary'>";
|
||||||
|
html += installedPlugin ? globalize.translate('LabelVersionInstalled', installedPlugin.Version) : ' ';
|
||||||
|
html += '</div>';
|
||||||
|
html += '</div>';
|
||||||
|
html += '</div>';
|
||||||
|
return html += '</div>';
|
||||||
|
}
|
||||||
|
|
||||||
window.PluginCatalog = {
|
function getTabs() {
|
||||||
renderCatalog: populateList
|
return [{
|
||||||
};
|
href: 'installedplugins.html',
|
||||||
|
name: globalize.translate('TabMyPlugins')
|
||||||
|
}, {
|
||||||
|
href: 'availableplugins.html',
|
||||||
|
name: globalize.translate('TabCatalog')
|
||||||
|
}, {
|
||||||
|
href: 'repositories.html',
|
||||||
|
name: globalize.translate('TabRepositories')
|
||||||
|
}];
|
||||||
|
}
|
||||||
|
|
||||||
return function (view, params) {
|
export default function (view) {
|
||||||
view.addEventListener('viewshow', function () {
|
view.addEventListener('viewshow', function () {
|
||||||
libraryMenu.setTabs('plugins', 1, getTabs);
|
libraryMenu.setTabs('plugins', 1, getTabs);
|
||||||
reloadList(this);
|
reloadList(this);
|
||||||
});
|
});
|
||||||
};
|
}
|
||||||
});
|
|
||||||
|
@ -1,192 +1,193 @@
|
|||||||
define(['loading', 'libraryMenu', 'dom', 'globalize', 'cardStyle', 'emby-button'], function (loading, libraryMenu, dom, globalize) {
|
import loading from 'loading';
|
||||||
'use strict';
|
import libraryMenu from 'libraryMenu';
|
||||||
|
import dom from 'dom';
|
||||||
|
import globalize from 'globalize';
|
||||||
|
import 'cardStyle';
|
||||||
|
import 'emby-button';
|
||||||
|
|
||||||
loading = loading.default || loading;
|
function deletePlugin(page, uniqueid, name) {
|
||||||
|
const msg = globalize.translate('UninstallPluginConfirmation', name);
|
||||||
|
|
||||||
function deletePlugin(page, uniqueid, name) {
|
import('confirm').then(({default: confirm}) => {
|
||||||
var msg = globalize.translate('UninstallPluginConfirmation', name);
|
confirm.default({
|
||||||
|
title: globalize.translate('UninstallPluginHeader'),
|
||||||
require(['confirm'], function (confirm) {
|
text: msg,
|
||||||
confirm.default({
|
primary: 'delete',
|
||||||
title: globalize.translate('HeaderUninstallPlugin'),
|
confirmText: globalize.translate('UninstallPluginHeader')
|
||||||
text: msg,
|
}).then(function () {
|
||||||
primary: 'delete',
|
loading.show();
|
||||||
confirmText: globalize.translate('HeaderUninstallPlugin')
|
ApiClient.uninstallPlugin(uniqueid).then(function () {
|
||||||
}).then(function () {
|
reloadList(page);
|
||||||
loading.show();
|
|
||||||
ApiClient.uninstallPlugin(uniqueid).then(function () {
|
|
||||||
reloadList(page);
|
|
||||||
});
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
}
|
});
|
||||||
|
}
|
||||||
|
|
||||||
function showNoConfigurationMessage() {
|
function showNoConfigurationMessage() {
|
||||||
Dashboard.alert({
|
Dashboard.alert({
|
||||||
message: globalize.translate('MessageNoPluginConfiguration')
|
message: globalize.translate('NoPluginConfigurationMessage')
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
function showConnectMessage() {
|
function showConnectMessage() {
|
||||||
Dashboard.alert({
|
Dashboard.alert({
|
||||||
message: globalize.translate('MessagePluginConfigurationRequiresLocalAccess')
|
message: globalize.translate('MessagePluginConfigurationRequiresLocalAccess')
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
function getPluginCardHtml(plugin, pluginConfigurationPages) {
|
function getPluginCardHtml(plugin, pluginConfigurationPages) {
|
||||||
var configPage = pluginConfigurationPages.filter(function (pluginConfigurationPage) {
|
const configPage = pluginConfigurationPages.filter(function (pluginConfigurationPage) {
|
||||||
return pluginConfigurationPage.PluginId == plugin.Id;
|
return pluginConfigurationPage.PluginId == plugin.Id;
|
||||||
})[0];
|
})[0];
|
||||||
var configPageUrl = configPage ? Dashboard.getConfigurationPageUrl(configPage.Name) : null;
|
const configPageUrl = configPage ? Dashboard.getConfigurationPageUrl(configPage.Name) : null;
|
||||||
var html = '';
|
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-name='" + plugin.Name + "' data-removable='" + plugin.CanUninstall + "' class='card backdropCard'>";
|
||||||
html += '<div class="cardBox visualCardBox">';
|
html += '<div class="cardBox visualCardBox">';
|
||||||
html += '<div class="cardScalable">';
|
html += '<div class="cardScalable">';
|
||||||
html += '<div class="cardPadder cardPadder-backdrop"></div>';
|
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 += 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 += '<span class="cardImageIcon material-icons folder"></span>';
|
||||||
html += configPageUrl ? '</a>' : '</div>';
|
html += configPageUrl ? '</a>' : '</div>';
|
||||||
|
html += '</div>';
|
||||||
|
html += '<div class="cardFooter">';
|
||||||
|
|
||||||
|
if (configPage || plugin.CanUninstall) {
|
||||||
|
html += '<div style="text-align:right; float:right;padding-top:5px;">';
|
||||||
|
html += '<button type="button" is="paper-icon-button-light" class="btnCardMenu autoSize"><span class="material-icons more_vert"></span></button>';
|
||||||
html += '</div>';
|
html += '</div>';
|
||||||
html += '<div class="cardFooter">';
|
}
|
||||||
|
|
||||||
if (configPage || plugin.CanUninstall) {
|
html += "<div class='cardText'>";
|
||||||
html += '<div style="text-align:right; float:right;padding-top:5px;">';
|
html += configPage && configPage.DisplayName ? configPage.DisplayName : plugin.Name;
|
||||||
html += '<button type="button" is="paper-icon-button-light" class="btnCardMenu autoSize"><span class="material-icons more_vert"></span></button>';
|
html += '</div>';
|
||||||
html += '</div>';
|
html += "<div class='cardText cardText-secondary'>";
|
||||||
|
html += plugin.Version;
|
||||||
|
html += '</div>';
|
||||||
|
html += '</div>';
|
||||||
|
html += '</div>';
|
||||||
|
html += '</div>';
|
||||||
|
return html;
|
||||||
|
}
|
||||||
|
|
||||||
|
function renderPlugins(page, plugins) {
|
||||||
|
ApiClient.getJSON(ApiClient.getUrl('web/configurationpages') + '?pageType=PluginConfiguration').then(function (configPages) {
|
||||||
|
populateList(page, plugins, configPages);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
function populateList(page, plugins, pluginConfigurationPages) {
|
||||||
|
plugins = plugins.sort(function (plugin1, plugin2) {
|
||||||
|
if (plugin1.Name > plugin2.Name) {
|
||||||
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
html += "<div class='cardText'>";
|
return -1;
|
||||||
html += configPage && configPage.DisplayName ? configPage.DisplayName : plugin.Name;
|
|
||||||
html += '</div>';
|
|
||||||
html += "<div class='cardText cardText-secondary'>";
|
|
||||||
html += plugin.Version;
|
|
||||||
html += '</div>';
|
|
||||||
html += '</div>';
|
|
||||||
html += '</div>';
|
|
||||||
html += '</div>';
|
|
||||||
return html;
|
|
||||||
}
|
|
||||||
|
|
||||||
function renderPlugins(page, plugins) {
|
|
||||||
ApiClient.getJSON(ApiClient.getUrl('web/configurationpages') + '?pageType=PluginConfiguration').then(function (configPages) {
|
|
||||||
populateList(page, plugins, configPages);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
function populateList(page, plugins, pluginConfigurationPages) {
|
|
||||||
plugins = plugins.sort(function (plugin1, plugin2) {
|
|
||||||
if (plugin1.Name > plugin2.Name) {
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
return -1;
|
|
||||||
});
|
|
||||||
|
|
||||||
var html = plugins.map(function (p) {
|
|
||||||
return getPluginCardHtml(p, pluginConfigurationPages);
|
|
||||||
}).join('');
|
|
||||||
|
|
||||||
var installedPluginsElement = page.querySelector('.installedPlugins');
|
|
||||||
installedPluginsElement.removeEventListener('click', onInstalledPluginsClick);
|
|
||||||
installedPluginsElement.addEventListener('click', onInstalledPluginsClick);
|
|
||||||
|
|
||||||
if (plugins.length) {
|
|
||||||
installedPluginsElement.classList.add('itemsContainer');
|
|
||||||
installedPluginsElement.classList.add('vertical-wrap');
|
|
||||||
} else {
|
|
||||||
html += '<div class="centerMessage">';
|
|
||||||
html += '<h1>' + globalize.translate('MessageNoPluginsInstalled') + '</h1>';
|
|
||||||
html += '<p><a is="emby-linkbutton" class="button-link" href="availableplugins.html">';
|
|
||||||
html += globalize.translate('MessageBrowsePluginCatalog');
|
|
||||||
html += '</a></p>';
|
|
||||||
html += '</div>';
|
|
||||||
}
|
|
||||||
|
|
||||||
installedPluginsElement.innerHTML = html;
|
|
||||||
loading.hide();
|
|
||||||
}
|
|
||||||
|
|
||||||
function showPluginMenu(page, elem) {
|
|
||||||
var card = dom.parentWithClass(elem, 'card');
|
|
||||||
var id = card.getAttribute('data-id');
|
|
||||||
var name = card.getAttribute('data-name');
|
|
||||||
var removable = card.getAttribute('data-removable');
|
|
||||||
var configHref = card.querySelector('.cardContent').getAttribute('href');
|
|
||||||
var menuItems = [];
|
|
||||||
|
|
||||||
if (configHref) {
|
|
||||||
menuItems.push({
|
|
||||||
name: globalize.translate('ButtonSettings'),
|
|
||||||
id: 'open',
|
|
||||||
icon: 'mode_edit'
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
if (removable === 'true') {
|
|
||||||
menuItems.push({
|
|
||||||
name: globalize.translate('ButtonUninstall'),
|
|
||||||
id: 'delete',
|
|
||||||
icon: 'delete'
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
require(['actionsheet'], function (actionsheet) {
|
|
||||||
actionsheet.show({
|
|
||||||
items: menuItems,
|
|
||||||
positionTo: elem,
|
|
||||||
callback: function (resultId) {
|
|
||||||
switch (resultId) {
|
|
||||||
case 'open':
|
|
||||||
Dashboard.navigate(configHref);
|
|
||||||
break;
|
|
||||||
case 'delete':
|
|
||||||
deletePlugin(page, id, name);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
function reloadList(page) {
|
|
||||||
loading.show();
|
|
||||||
ApiClient.getInstalledPlugins().then(function (plugins) {
|
|
||||||
renderPlugins(page, plugins);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
function getTabs() {
|
|
||||||
return [{
|
|
||||||
href: 'installedplugins.html',
|
|
||||||
name: globalize.translate('TabMyPlugins')
|
|
||||||
}, {
|
|
||||||
href: 'availableplugins.html',
|
|
||||||
name: globalize.translate('TabCatalog')
|
|
||||||
}, {
|
|
||||||
href: 'repositories.html',
|
|
||||||
name: globalize.translate('TabRepositories')
|
|
||||||
}];
|
|
||||||
}
|
|
||||||
|
|
||||||
function onInstalledPluginsClick(e) {
|
|
||||||
if (dom.parentWithClass(e.target, 'noConfigPluginCard')) {
|
|
||||||
showNoConfigurationMessage();
|
|
||||||
} else if (dom.parentWithClass(e.target, 'connectModePluginCard')) {
|
|
||||||
showConnectMessage();
|
|
||||||
} else {
|
|
||||||
var btnCardMenu = dom.parentWithClass(e.target, 'btnCardMenu');
|
|
||||||
if (btnCardMenu) {
|
|
||||||
showPluginMenu(dom.parentWithClass(btnCardMenu, 'page'), btnCardMenu);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
pageIdOn('pageshow', 'pluginsPage', function () {
|
|
||||||
libraryMenu.setTabs('plugins', 0, getTabs);
|
|
||||||
reloadList(this);
|
|
||||||
});
|
});
|
||||||
|
|
||||||
window.PluginsPage = {
|
let html = plugins.map(function (p) {
|
||||||
renderPlugins: renderPlugins
|
return getPluginCardHtml(p, pluginConfigurationPages);
|
||||||
};
|
}).join('');
|
||||||
|
|
||||||
|
const installedPluginsElement = page.querySelector('.installedPlugins');
|
||||||
|
installedPluginsElement.removeEventListener('click', onInstalledPluginsClick);
|
||||||
|
installedPluginsElement.addEventListener('click', onInstalledPluginsClick);
|
||||||
|
|
||||||
|
if (plugins.length) {
|
||||||
|
installedPluginsElement.classList.add('itemsContainer');
|
||||||
|
installedPluginsElement.classList.add('vertical-wrap');
|
||||||
|
} else {
|
||||||
|
html += '<div class="centerMessage">';
|
||||||
|
html += '<h1>' + globalize.translate('MessageNoPluginsInstalled') + '</h1>';
|
||||||
|
html += '<p><a is="emby-linkbutton" class="button-link" href="availableplugins.html">';
|
||||||
|
html += globalize.translate('BrowsePluginCatalogMessage');
|
||||||
|
html += '</a></p>';
|
||||||
|
html += '</div>';
|
||||||
|
}
|
||||||
|
|
||||||
|
installedPluginsElement.innerHTML = html;
|
||||||
|
loading.hide();
|
||||||
|
}
|
||||||
|
|
||||||
|
function showPluginMenu(page, elem) {
|
||||||
|
const card = dom.parentWithClass(elem, 'card');
|
||||||
|
const id = card.getAttribute('data-id');
|
||||||
|
const name = card.getAttribute('data-name');
|
||||||
|
const removable = card.getAttribute('data-removable');
|
||||||
|
const configHref = card.querySelector('.cardContent').getAttribute('href');
|
||||||
|
const menuItems = [];
|
||||||
|
|
||||||
|
if (configHref) {
|
||||||
|
menuItems.push({
|
||||||
|
name: globalize.translate('ButtonSettings'),
|
||||||
|
id: 'open',
|
||||||
|
icon: 'mode_edit'
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
if (removable === 'true') {
|
||||||
|
menuItems.push({
|
||||||
|
name: globalize.translate('ButtonUninstall'),
|
||||||
|
id: 'delete',
|
||||||
|
icon: 'delete'
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
import('actionsheet').then(({default: actionsheet}) => {
|
||||||
|
actionsheet.show({
|
||||||
|
items: menuItems,
|
||||||
|
positionTo: elem,
|
||||||
|
callback: function (resultId) {
|
||||||
|
switch (resultId) {
|
||||||
|
case 'open':
|
||||||
|
Dashboard.navigate(configHref);
|
||||||
|
break;
|
||||||
|
case 'delete':
|
||||||
|
deletePlugin(page, id, name);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
function reloadList(page) {
|
||||||
|
loading.show();
|
||||||
|
ApiClient.getInstalledPlugins().then(function (plugins) {
|
||||||
|
renderPlugins(page, plugins);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
function getTabs() {
|
||||||
|
return [{
|
||||||
|
href: 'installedplugins.html',
|
||||||
|
name: globalize.translate('TabMyPlugins')
|
||||||
|
}, {
|
||||||
|
href: 'availableplugins.html',
|
||||||
|
name: globalize.translate('TabCatalog')
|
||||||
|
}, {
|
||||||
|
href: 'repositories.html',
|
||||||
|
name: globalize.translate('TabRepositories')
|
||||||
|
}];
|
||||||
|
}
|
||||||
|
|
||||||
|
function onInstalledPluginsClick(e) {
|
||||||
|
if (dom.parentWithClass(e.target, 'noConfigPluginCard')) {
|
||||||
|
showNoConfigurationMessage();
|
||||||
|
} else if (dom.parentWithClass(e.target, 'connectModePluginCard')) {
|
||||||
|
showConnectMessage();
|
||||||
|
} else {
|
||||||
|
const btnCardMenu = dom.parentWithClass(e.target, 'btnCardMenu');
|
||||||
|
if (btnCardMenu) {
|
||||||
|
showPluginMenu(dom.parentWithClass(btnCardMenu, 'page'), btnCardMenu);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
pageIdOn('pageshow', 'pluginsPage', function () {
|
||||||
|
libraryMenu.setTabs('plugins', 0, getTabs);
|
||||||
|
reloadList(this);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
window.PluginsPage = {
|
||||||
|
renderPlugins: renderPlugins
|
||||||
|
};
|
||||||
|
@ -1282,6 +1282,8 @@
|
|||||||
"PleaseRestartServerName": "Please restart Jellyfin Server - {0}.",
|
"PleaseRestartServerName": "Please restart Jellyfin Server - {0}.",
|
||||||
"PleaseSelectTwoItems": "Please select at least two items.",
|
"PleaseSelectTwoItems": "Please select at least two items.",
|
||||||
"MessagePluginInstalled": "The plugin has been successfully installed. Jellyfin Server will need to be restarted for changes to take effect.",
|
"MessagePluginInstalled": "The plugin has been successfully installed. Jellyfin Server will need to be restarted for changes to take effect.",
|
||||||
|
"MessagePluginIntallError": "An error occured while installing the plugin.",
|
||||||
|
"MessageGetInstalledPluginsError": "An error occured while getting the list of currently installed plugins.",
|
||||||
"PreferEmbeddedTitlesOverFileNames": "Prefer embedded titles over filenames",
|
"PreferEmbeddedTitlesOverFileNames": "Prefer embedded titles over filenames",
|
||||||
"PreferEmbeddedTitlesOverFileNamesHelp": "This determines the default display title when no internet metadata or local metadata is available.",
|
"PreferEmbeddedTitlesOverFileNamesHelp": "This determines the default display title when no internet metadata or local metadata is available.",
|
||||||
"PreferEmbeddedEpisodeInfosOverFileNamesHelp": "This uses the episode information from the embedded metadata if available.",
|
"PreferEmbeddedEpisodeInfosOverFileNamesHelp": "This uses the episode information from the embedded metadata if available.",
|
||||||
|
Loading…
Reference in New Issue
Block a user