##// END OF EJS Templates
Adds "Check for updates" for installed plugins (#3177)....
Jean-Philippe Lang -
r12767:43d703605123
parent child
Show More
@@ -24,4 +24,12 module AdminHelper
24 [l(:project_status_closed), '5'],
24 [l(:project_status_closed), '5'],
25 [l(:project_status_archived), '9']], selected.to_s)
25 [l(:project_status_archived), '9']], selected.to_s)
26 end
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 end
35 end
@@ -9,11 +9,55
9 <%= content_tag('span', link_to(h(plugin.url), plugin.url), :class => 'url') unless plugin.url.blank? %>
9 <%= content_tag('span', link_to(h(plugin.url), plugin.url), :class => 'url') unless plugin.url.blank? %>
10 </td>
10 </td>
11 <td class="author"><%= plugin.author_url.blank? ? h(plugin.author) : link_to(h(plugin.author), plugin.author_url) %></td>
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 <td class="configure"><%= link_to(l(:button_configure), plugin_settings_path(plugin)) if plugin.configurable? %></td>
13 <td class="configure"><%= link_to(l(:button_configure), plugin_settings_path(plugin)) if plugin.configurable? %></td>
14 </tr>
14 </tr>
15 <% end %>
15 <% end %>
16 </table>
16 </table>
17 <p><a href="#" id="check-for-updates">Check for updates</a>
17 <% else %>
18 <% else %>
18 <p class="nodata"><%= l(:label_no_data) %></p>
19 <p class="nodata"><%= l(:label_no_data) %></p>
19 <% end %>
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