Browse Source

When an Agent isn't working, the "No" links to either the Agent's details tab, or its Logs tab, depending on if the most recent log is an error.

Andrew Cantino 11 years ago
parent
commit
700209155a

+ 6 - 3
app/assets/javascripts/application.js.coffee.erb

@@ -76,9 +76,12 @@ $(document).ready ->
         $("#logs .spinner").stop(true, true).fadeOut ->
           $("#logs .refresh, #logs .clear").show()
 
-  $(".agent-show #show-tabs a[href='#logs']").on "click", fetchLogs
-  $("#logs .refresh").on "click", fetchLogs
-  $("#logs .clear").on "click", clearLogs
+  $(".agent-show #show-tabs a[href='#logs'], #logs .refresh").on "click", fetchLogs
+  $(".agent-show #logs .clear").on "click", clearLogs
+
+  if tab = window.location.href.match(/tab=(\w+)\b/i)?[1]
+    if tab in ["details", "logs"]
+      $(".agent-show .nav-tabs li a[href='##{tab}']").click()
 
   # Editing Agents
   $("#agent_source_ids").on "change", showEventDescriptions

+ 1 - 1
app/helpers/application_helper.rb

@@ -11,7 +11,7 @@ module ApplicationHelper
     if agent.working?
       '<span class="label label-success">Yes</span>'.html_safe
     else
-      '<span class="label label-warning">No</span>'.html_safe
+      link_to '<span class="label label-warning">No</span>'.html_safe, agent_path(agent, :tab => (agent.recent_error_logs? ? 'logs' : 'details'))
     end
   end
 end