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

103 lines
3.0 KiB
JavaScript
Raw Normal View History

2016-03-16 14:30:49 -07:00
define(['jQuery'], function ($) {
function reloadList(page) {
Dashboard.showLoadingMsg();
var promise1 = ApiClient.getAvailablePlugins({
TargetSystems: 'Server'
});
var promise2 = ApiClient.getInstalledPlugins();
2015-12-14 08:43:03 -07:00
Promise.all([promise1, promise2]).then(function (responses) {
renderInstalled(page, responses[0], responses[1]);
renderCatalog(page, responses[0], responses[1]);
});
}
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-09-02 18:40:47 -07:00
$(document).on('pagebeforeshow pageshow', "#appServicesPage", function () {
// This needs both events for the helpurl to get done at the right time
var page = this;
var context = getParameterByName('context');
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-09-24 10:08:10 -07:00
}).on('pageshow', "#appServicesPage", function () {
var page = this;
reloadList(page);
});
2016-03-16 14:30:49 -07:00
});