jellyfin-web/dashboard-ui/scripts/appservices.js

120 lines
3.6 KiB
JavaScript
Raw Normal View History

(function ($, document) {
function reloadList(page) {
Dashboard.showLoadingMsg();
var promise1 = ApiClient.getAvailablePlugins({
TargetSystems: 'Server'
});
var promise2 = ApiClient.getInstalledPlugins();
$.when(promise1, promise2).done(function (response1, response2) {
renderInstalled(page, response1[0], response2[0]);
renderCatalog(page, response1[0], response2[0]);
});
}
function getCategories() {
var context = getParameterByName('context');
var categories = [];
if (context == 'sync') {
categories.push('Sync');
}
else if (context == 'livetv') {
categories.push('Live TV');
}
2015-04-05 20:47:01 -07:00
else if (context == 'notifications') {
categories.push('Notifications');
}
return categories;
}
function renderInstalled(page, availablePlugins, installedPlugins) {
2015-06-09 21:01:14 -07:00
requirejs(['scripts/pluginspage'], function() {
var category = getCategories()[0];
2015-06-09 21:01:14 -07:00
installedPlugins = installedPlugins.filter(function (i) {
2015-06-09 21:01:14 -07:00
var catalogEntry = availablePlugins.filter(function (a) {
return a.guid == i.Id;
})[0];
2015-06-09 21:01:14 -07:00
return catalogEntry && catalogEntry.category == category;
2015-06-09 21:01:14 -07:00
});
2015-06-09 21:01:14 -07:00
PluginsPage.renderPlugins(page, installedPlugins);
});
}
function renderCatalog(page, availablePlugins, installedPlugins) {
2015-06-09 21:01:14 -07:00
requirejs(['scripts/plugincatalogpage'], function () {
var categories = getCategories();
2015-06-09 21:01:14 -07:00
PluginCatalog.renderCatalog({
2015-06-09 21:01:14 -07:00
catalogElement: $('.catalog', page),
availablePlugins: availablePlugins,
installedPlugins: installedPlugins,
categories: categories,
showCategory: false,
context: getParameterByName('context'),
targetSystem: 'Server'
});
});
}
2015-03-30 12:57:37 -07:00
$(document).on('pagebeforeshow pageinit pageshow', "#appServicesPage", function () {
// This needs both events for the helpurl to get done at the right time
var page = this;
var context = getParameterByName('context');
$('.sectionTabs', page).hide();
$('.' + context + 'SectionTabs', page).show();
if (context == 'sync') {
Dashboard.setPageTitle(Globalize.translate('TitleSync'));
page.setAttribute('data-helpurl', 'https://github.com/MediaBrowser/Wiki/wiki/Sync');
}
else if (context == 'livetv') {
Dashboard.setPageTitle(Globalize.translate('TitleLiveTV'));
page.setAttribute('data-helpurl', 'https://github.com/MediaBrowser/Wiki/wiki/Live%20TV');
}
2015-04-05 20:47:01 -07:00
else if (context == 'notifications') {
Dashboard.setPageTitle(Globalize.translate('TitleNotifications'));
page.setAttribute('data-helpurl', 'https://github.com/MediaBrowser/Wiki/wiki/Notifications');
}
2015-06-09 21:01:14 -07:00
}).on('pageshowready', "#appServicesPage", function () {
// This needs both events for the helpurl to get done at the right time
var page = this;
reloadList(page);
var context = getParameterByName('context');
Dashboard.getPluginSecurityInfo().done(function (pluginSecurityInfo) {
2015-05-21 13:53:14 -07:00
if (pluginSecurityInfo.IsMBSupporter || context != 'sync' || !AppInfo.enableSupporterMembership) {
$('.syncPromotion', page).hide();
} else {
$('.syncPromotion', page).show();
}
});
});
})(jQuery, document);