diff options
| author | LukePulverenti <luke.pulverenti@gmail.com> | 2013-02-20 20:33:05 -0500 |
|---|---|---|
| committer | LukePulverenti <luke.pulverenti@gmail.com> | 2013-02-20 20:33:05 -0500 |
| commit | 767cdc1f6f6a63ce997fc9476911e2c361f9d402 (patch) | |
| tree | 49add55976f895441167c66cfa95e5c7688d18ce /MediaBrowser.WebDashboard/Html/scripts/PluginsPage.js | |
| parent | 845554722efaed872948a9e0f7202e3ef52f1b6e (diff) | |
Pushing missing changes
Diffstat (limited to 'MediaBrowser.WebDashboard/Html/scripts/PluginsPage.js')
| -rw-r--r-- | MediaBrowser.WebDashboard/Html/scripts/PluginsPage.js | 92 |
1 files changed, 92 insertions, 0 deletions
diff --git a/MediaBrowser.WebDashboard/Html/scripts/PluginsPage.js b/MediaBrowser.WebDashboard/Html/scripts/PluginsPage.js new file mode 100644 index 000000000..f7e05e4ba --- /dev/null +++ b/MediaBrowser.WebDashboard/Html/scripts/PluginsPage.js @@ -0,0 +1,92 @@ +var PluginsPage = { + + onPageShow: function () { + PluginsPage.reloadList(); + }, + + reloadList: function () { + + Dashboard.showLoadingMsg(); + + var promise1 = ApiClient.getInstalledPlugins(); + + var promise2 = $.getJSON("configurationpages?pageType=PluginConfiguration"); + + $.when(promise1, promise2).done(function(response1, response2) { + + PluginsPage.populateList(response1[0], response2[0]); + + }); + }, + + populateList: function (plugins, pluginConfigurationPages) { + + var page = $($.mobile.activePage); + + plugins = plugins.sort(function (plugin1, plugin2) { + + return (plugin1.IsCorePlugin.toString() + plugin1.Name) > (plugin2.IsCorePlugin.toString() + plugin2.Name) ? 1 : -1; + + }); + + var html = ""; + + for (var i = 0, length = plugins.length; i < length; i++) { + + var plugin = plugins[i]; + + if (plugin.IsCorePlugin) { + continue; + } + + var configPage = $.grep(pluginConfigurationPages, function (pluginConfigurationPage) { + return pluginConfigurationPage.OwnerPluginName == plugin.Name; + })[0]; + + html += "<li>"; + + var href = configPage ? Dashboard.getConfigurationPageUrl(configPage.Name) : "#"; + + html += "<a href='" + href + "'>"; + + html += "<h3>" + plugin.Name + "</h3>"; + + html += "<p><strong>" + plugin.Version + "</strong></p>"; + + html += "</a>"; + + if (!plugin.IsCorePlugin) { + html += "<a data-uniqueid='" + plugin.UniqueId + "' data-pluginname='" + plugin.Name + "' onclick='PluginsPage.deletePlugin(this);' href='#'>Delete</a>"; + } + + html += "</li>"; + } + + $('#ulInstalledPlugins', page).html(html).listview('refresh'); + + Dashboard.hideLoadingMsg(); + }, + + deletePlugin: function (link) { + + var name = link.getAttribute('data-pluginname'); + var uniqueid = link.getAttribute('data-uniqueid'); + + var msg = "Are you sure you wish to uninstall " + name + "?"; + + Dashboard.confirm(msg, "Uninstall Plugin", function (result) { + + if (result) { + Dashboard.showLoadingMsg(); + + ApiClient.uninstallPlugin(uniqueid).done(function () { + + PluginsPage.reloadList(); + }); + } + }); + + } +}; + +$(document).on('pageshow', "#pluginsPage", PluginsPage.onPageShow);
\ No newline at end of file |
