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

115 lines
3.4 KiB
JavaScript
Raw Normal View History

2013-02-20 18:33:05 -07:00
var PluginUpdatesPage = {
onPageShow: function () {
Dashboard.showLoadingMsg();
$('.liPluginUpdate', this).remove();
ApiClient.getInstalledPlugins().done(PluginUpdatesPage.loadPlugins);
},
loadPlugins: function (plugins) {
var elem = $('#tbodyPluginUpdates', $.mobile.activePage).html('');
for (var i = 0, length = plugins.length; i < length; i++) {
PluginUpdatesPage.addPlugin(plugins[i], i, elem);
}
Dashboard.hideLoadingMsg();
},
addPlugin: function (plugin, fieldIndex, elem) {
var html = "";
html += "<tr>";
html += "<td><h3>" + plugin.Name + "</h3></td>";
var fieldId = "liPluginUpdateFielda" + fieldIndex;
2014-03-31 14:04:22 -07:00
var enabledOptions = [
{ name: Globalize.translate('OptionOff'), value: 'Off' },
{ name: Globalize.translate('OptionOn'), value: 'On' }
2014-03-31 14:04:22 -07:00
];
var options = PluginUpdatesPage.getHtmlOptions(enabledOptions, (plugin.EnableAutoUpdate ? "On" : "Off"));
2013-02-20 18:33:05 -07:00
2013-12-19 14:51:32 -07:00
html += "<td style='vertical-align:middle;text-align:left;'>";
html += "<select data-mini='true' data-id='" + plugin.Id + "' onchange='PluginUpdatesPage.setAutoUpdate(this);' data-role='slider' id='" + fieldId + "' name='" + fieldId + "'>" + options + "</select>";
2013-02-20 18:33:05 -07:00
html += "</td>";
fieldId = "liPluginUpdateFieldb" + fieldIndex;
2014-03-31 14:04:22 -07:00
var updateOptions = [
{ name: Globalize.translate('OptionRelease'), value: 'Release' },
{ name: Globalize.translate('OptionBeta'), value: 'Beta' },
{ name: Globalize.translate('OptionDev'), value: 'Dev' }
2014-03-31 14:04:22 -07:00
];
options = PluginUpdatesPage.getHtmlOptions(updateOptions, plugin.UpdateClass);
2013-02-20 18:33:05 -07:00
2013-12-19 14:51:32 -07:00
html += "<td style='vertical-align:middle;text-align:left;'>";
html += "<select data-mini='true' data-id='" + plugin.Id + "' onchange='PluginUpdatesPage.setUpdateClass(this);' data-inline='true' id='" + fieldId + "' name='" + fieldId + "'>" + options + "</select>";
2013-02-20 18:33:05 -07:00
html += "</td>";
html += "</tr>";
elem.append(html).trigger('create');
},
getHtmlOptions: function (options, selectedValue) {
2013-02-20 18:33:05 -07:00
var html = "";
for (var i = 0, length = options.length; i < length; i++) {
2013-02-20 18:33:05 -07:00
var option = options[i];
var name = option.name;
var value = option.value;
2013-02-20 18:33:05 -07:00
if (value == selectedValue) {
html += '<option value="' + value + '" selected="selected">' + name + '</option>';
2013-02-20 18:33:05 -07:00
} else {
html += '<option value="' + value + '">' + name + '</option>';
2013-02-20 18:33:05 -07:00
}
}
return html;
},
setAutoUpdate: function (select) {
2013-02-21 23:28:57 -07:00
var id = $(select).attr('data-id');
2013-02-20 18:33:05 -07:00
Dashboard.showLoadingMsg();
ApiClient.getPluginConfiguration(id).done(function (config) {
config.EnableAutoUpdate = select.selectedIndex === 1;
ApiClient.updatePluginConfiguration(id, config).done(Dashboard.hideLoadingMsg);
});
},
setUpdateClass: function (select) {
2013-02-21 23:28:57 -07:00
var id = $(select).attr('data-id');
2013-02-20 18:33:05 -07:00
Dashboard.showLoadingMsg();
ApiClient.getPluginConfiguration(id).done(function (config) {
config.UpdateClass = select.value;
ApiClient.updatePluginConfiguration(id, config).done(Dashboard.hideLoadingMsg);
});
}
};
$(document).on('pageshow', "#pluginUpdatesPage", PluginUpdatesPage.onPageShow);