##// END OF EJS Templates
Adds "Check for updates" for installed plugins (#3177)....
Jean-Philippe Lang -
r12767:43d703605123
parent child
Show More
@@ -1,27 +1,35
1 1 # encoding: utf-8
2 2 #
3 3 # Redmine - project management software
4 4 # Copyright (C) 2006-2014 Jean-Philippe Lang
5 5 #
6 6 # This program is free software; you can redistribute it and/or
7 7 # modify it under the terms of the GNU General Public License
8 8 # as published by the Free Software Foundation; either version 2
9 9 # of the License, or (at your option) any later version.
10 10 #
11 11 # This program is distributed in the hope that it will be useful,
12 12 # but WITHOUT ANY WARRANTY; without even the implied warranty of
13 13 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 14 # GNU General Public License for more details.
15 15 #
16 16 # You should have received a copy of the GNU General Public License
17 17 # along with this program; if not, write to the Free Software
18 18 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
19 19
20 20 module AdminHelper
21 21 def project_status_options_for_select(selected)
22 22 options_for_select([[l(:label_all), ''],
23 23 [l(:project_status_active), '1'],
24 24 [l(:project_status_closed), '5'],
25 25 [l(:project_status_archived), '9']], selected.to_s)
26 26 end
27
28 def plugin_data_for_updates(plugins)
29 data = {"v" => Redmine::VERSION.to_s, "p" => {}}
30 plugins.each do |plugin|
31 data["p"].merge! plugin.id => {"v" => plugin.version, "n" => plugin.name, "a" => plugin.author}
32 end
33 data
34 end
27 35 end
@@ -1,19 +1,63
1 1 <%= title l(:label_plugins) %>
2 2
3 3 <% if @plugins.any? %>
4 4 <table class="list plugins">
5 5 <% @plugins.each do |plugin| %>
6 6 <tr id="plugin-<%= plugin.id %>" class="<%= cycle('odd', 'even') %>">
7 7 <td class="name"><span class="name"><%=h plugin.name %></span>
8 8 <%= content_tag('span', h(plugin.description), :class => 'description') unless plugin.description.blank? %>
9 9 <%= content_tag('span', link_to(h(plugin.url), plugin.url), :class => 'url') unless plugin.url.blank? %>
10 10 </td>
11 11 <td class="author"><%= plugin.author_url.blank? ? h(plugin.author) : link_to(h(plugin.author), plugin.author_url) %></td>
12 <td class="version"><%=h plugin.version %></td>
12 <td class="version"><span class="icon"><%= plugin.version %></span></td>
13 13 <td class="configure"><%= link_to(l(:button_configure), plugin_settings_path(plugin)) if plugin.configurable? %></td>
14 14 </tr>
15 15 <% end %>
16 16 </table>
17 <p><a href="#" id="check-for-updates">Check for updates</a>
17 18 <% else %>
18 19 <p class="nodata"><%= l(:label_no_data) %></p>
19 20 <% end %>
21
22 <%= javascript_tag do %>
23 $(document).ready(function(){
24 $("#check-for-updates").click(function(e){
25 e.preventDefault();
26 $.ajax({
27 dataType: "jsonp",
28 url: "http://www.redmine.org/plugins/check_updates",
29 data: <%= raw_json plugin_data_for_updates(@plugins) %>,
30 timeout: 3000,
31 beforeSend: function(){
32 $('#ajax-indicator').show();
33 },
34 success: function(data){
35 $('#ajax-indicator').hide();
36 $("table.plugins td.version span").addClass("unknown");
37 $.each(data, function(plugin_id, plugin_data){
38 var s = $("tr#plugin-"+plugin_id+" td.version span");
39 s.removeClass("icon-checked icon-warning unknown");
40 if (plugin_data.url) {
41 if (s.parent("a").length>0) {
42 s.unwrap();
43 }
44 s.addClass("found");
45 s.wrap($("<a></a>").attr("href", plugin_data.url).attr("target", "_blank"));
46 }
47 if (plugin_data.c == s.text()) {
48 s.addClass("icon-checked");
49 } else if (plugin_data.c) {
50 s.addClass("icon-warning");
51 s.attr("title", "Latest compatible version: "+plugin_data.c);
52 }
53 });
54 $("table.plugins td.version span.unknown").addClass("icon-help").attr("title", "Unknown plugin");
55 },
56 error: function(){
57 $('#ajax-indicator').hide();
58 alert("Unable to retrieve plugin informations from www.redmine.org");
59 }
60 });
61 });
62 });
63 <% end if @plugins.any? %>
General Comments 0
You need to be logged in to leave comments. Login now