2016-03-16 14:30:49 -07:00
|
|
|
|
define(['jQuery'], function ($) {
|
2015-03-30 09:16:34 -07:00
|
|
|
|
|
|
|
|
|
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]);
|
2015-03-30 09:16:34 -07:00
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
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');
|
|
|
|
|
}
|
2015-03-30 09:16:34 -07:00
|
|
|
|
|
|
|
|
|
return categories;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function renderInstalled(page, availablePlugins, installedPlugins) {
|
|
|
|
|
|
2015-06-09 21:01:14 -07:00
|
|
|
|
requirejs(['scripts/pluginspage'], function() {
|
|
|
|
|
var category = getCategories()[0];
|
2015-03-30 09:16:34 -07:00
|
|
|
|
|
2015-06-09 21:01:14 -07:00
|
|
|
|
installedPlugins = installedPlugins.filter(function (i) {
|
2015-03-30 09:16:34 -07:00
|
|
|
|
|
2015-06-09 21:01:14 -07:00
|
|
|
|
var catalogEntry = availablePlugins.filter(function (a) {
|
|
|
|
|
return a.guid == i.Id;
|
|
|
|
|
})[0];
|
2015-03-30 09:16:34 -07:00
|
|
|
|
|
2015-06-09 21:01:14 -07:00
|
|
|
|
return catalogEntry && catalogEntry.category == category;
|
2015-03-30 09:16:34 -07:00
|
|
|
|
|
2015-06-09 21:01:14 -07:00
|
|
|
|
});
|
2015-03-30 09:16:34 -07:00
|
|
|
|
|
2015-06-09 21:01:14 -07:00
|
|
|
|
PluginsPage.renderPlugins(page, installedPlugins);
|
|
|
|
|
});
|
2015-03-30 09:16:34 -07:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function renderCatalog(page, availablePlugins, installedPlugins) {
|
|
|
|
|
|
2015-06-09 21:01:14 -07:00
|
|
|
|
requirejs(['scripts/plugincatalogpage'], function () {
|
|
|
|
|
var categories = getCategories();
|
2015-03-30 09:16:34 -07:00
|
|
|
|
|
2015-06-09 21:01:14 -07:00
|
|
|
|
PluginCatalog.renderCatalog({
|
2015-03-30 09:16:34 -07:00
|
|
|
|
|
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 09:16:34 -07:00
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
2015-09-02 18:40:47 -07:00
|
|
|
|
$(document).on('pagebeforeshow pageshow', "#appServicesPage", function () {
|
2015-03-30 09:16:34 -07:00
|
|
|
|
|
|
|
|
|
// This needs both events for the helpurl to get done at the right time
|
|
|
|
|
|
|
|
|
|
var page = this;
|
|
|
|
|
|
|
|
|
|
var context = getParameterByName('context');
|
|
|
|
|
|
|
|
|
|
$('.sectionTabs', page).hide();
|
|
|
|
|
|
|
|
|
|
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-03-30 09:16:34 -07:00
|
|
|
|
|
2015-07-20 21:22:46 -07:00
|
|
|
|
$('.sectionTabs', page).hide();
|
|
|
|
|
$('.' + context + 'SectionTabs', page).show();
|
|
|
|
|
|
2015-09-24 10:08:10 -07:00
|
|
|
|
}).on('pageshow', "#appServicesPage", function () {
|
2015-03-30 09:16:34 -07:00
|
|
|
|
|
|
|
|
|
var page = this;
|
|
|
|
|
|
|
|
|
|
reloadList(page);
|
|
|
|
|
});
|
|
|
|
|
|
2016-03-16 14:30:49 -07:00
|
|
|
|
});
|