show.html.erb 7.6KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187
  1. <div class='container agent-show'>
  2. <div class='row'>
  3. <div class='col-md-2'>
  4. <ul class="nav nav-pills nav-stacked" id="show-tabs">
  5. <li><%= link_to '<span class="glyphicon glyphicon-chevron-left"></span> Back'.html_safe, agents_path %></li>
  6. <% if agent_show_view(@agent).present? %>
  7. <li class='active'><a href="#summary" data-toggle="tab"><span class='glyphicon glyphicon-picture'></span> Summary</a></li>
  8. <li><a href="#details" data-toggle="tab"><span class='glyphicon glyphicon-indent-left'></span> Details</a></li>
  9. <% else %>
  10. <li class='disabled'><a><span class='glyphicon glyphicon-picture'></span> Summary</a></li>
  11. <li class='active'><a href="#details" data-toggle="tab"><span class='glyphicon glyphicon-indent-left'></span> Details</a></li>
  12. <% end %>
  13. <li><a href="#logs" data-toggle="tab" data-agent-id="<%= @agent.id %>" class='<%= @agent.recent_error_logs? ? 'recent-errors' : '' %>'><span class='glyphicon glyphicon-list-alt'></span> Logs</a></li>
  14. <% if @agent.can_create_events? && @agent.events.count > 0 %>
  15. <li><%= link_to '<span class="glyphicon glyphicon-random"></span> Events'.html_safe, events_path(:agent => @agent.to_param) %></li>
  16. <% else %>
  17. <li class='disabled'><a><span class='glyphicon glyphicon-random'></span> Events</a></li>
  18. <% end %>
  19. <li class="dropdown">
  20. <a class="dropdown-toggle" data-toggle="dropdown" href="#">Actions <b class="caret"></b></a>
  21. <ul class="dropdown-menu" role="menu" aria-labelledby="dLabel">
  22. <% if @agent.can_be_scheduled? %>
  23. <li>
  24. <%= link_to '<span class="color-success glyphicon glyphicon-refresh"></span> Run'.html_safe, run_agent_path(@agent, :return => "show"), method: :post, :tabindex => "-1" %>
  25. </li>
  26. <% end %>
  27. <li>
  28. <%= link_to '<span class="glyphicon glyphicon-pencil"></span> Edit'.html_safe, edit_agent_path(@agent) %>
  29. </li>
  30. <li class="divider"></li>
  31. <li>
  32. <%= link_to '<span class="glyphicon glyphicon-plus"></span> Clone agent'.html_safe, new_agent_path(id: @agent), :tabindex => "-1" %>
  33. </li>
  34. <li>
  35. <% if @agent.disabled? %>
  36. <%= link_to '<i class="glyphicon glyphicon-play"></i> Enable agent'.html_safe, agent_path(@agent, :agent => { :disabled => false }, :return => "show"), :method => :put %>
  37. <% else %>
  38. <%= link_to '<i class="glyphicon glyphicon-pause"></i> Disable agent'.html_safe, agent_path(@agent, :agent => { :disabled => true }, :return => "show"), :method => :put %>
  39. <% end %>
  40. </li>
  41. <li class="divider"></li>
  42. <% if @agent.can_create_events? && @agent.events.count > 0 %>
  43. <li>
  44. <%= link_to '<span class="color-danger glyphicon glyphicon-trash"></span> Delete all events'.html_safe, remove_events_agent_path(@agent), method: :delete, data: {confirm: 'Are you sure you want to delete ALL events for this Agent?'}, :tabindex => "-1" %>
  45. </li>
  46. <% end %>
  47. <li>
  48. <%= link_to '<span class="color-danger glyphicon glyphicon-remove"></span> Delete agent'.html_safe, agent_path(@agent), method: :delete, data: { confirm: 'Are you sure?' }, :tabindex => "-1" %>
  49. </li>
  50. </ul>
  51. </li>
  52. </ul>
  53. </div>
  54. <div class='col-md-10'>
  55. <div class="tab-content">
  56. <div class="tab-pane <%= agent_show_view(@agent).present? ? "active" : "disabled" %>" id="summary">
  57. <h2><%= @agent.name %> Summary</h2>
  58. <% if agent_show_view(@agent).present? %>
  59. <div class="show-view <%= agent_show_class(@agent) %>">
  60. <%= render agent_show_view(@agent) %>
  61. </div>
  62. <% end %>
  63. </div>
  64. <div class="tab-pane" id="logs" data-agent-id="<%= @agent.id %>">
  65. <div class='row'>
  66. <div class='col-md-12'>
  67. <h2>
  68. <%= @agent.name %> Logs
  69. <small>
  70. <%= image_tag "spinner-arrows.gif", :class => "spinner" %>
  71. <span class="glyphicon glyphicon-refresh action-icon refresh"></span>
  72. <span class="glyphicon glyphicon-trash action-icon clear"></span>
  73. </small>
  74. </h2>
  75. </div>
  76. </div>
  77. <div class='row'>
  78. <div class='col-md-12'>
  79. <div class='logs'>
  80. Just a moment...
  81. </div>
  82. </div>
  83. </div>
  84. </div>
  85. <div class="tab-pane <%= agent_show_view(@agent).present? ? "" : "active" %>" id="details">
  86. <h2><%= @agent.name %> Details</h2>
  87. <p>
  88. <b>Type:</b>
  89. <%= @agent.short_type.titleize %>
  90. </p>
  91. <% if @agent.can_be_scheduled? %>
  92. <p>
  93. <b>Schedule:</b>
  94. <%= (@agent.schedule || "n/a").humanize.titleize %>
  95. </p>
  96. <p>
  97. <b>Last checked:</b>
  98. <%= @agent.last_check_at ? time_ago_in_words(@agent.last_check_at) + " ago" : "never" %>
  99. </p>
  100. <% end %>
  101. <% if @agent.can_create_events? %>
  102. <p>
  103. <b>Keep events:</b>
  104. <%= (Agent::EVENT_RETENTION_SCHEDULES.detect {|s| s.last == @agent.keep_events_for } || [@agent.keep_events_for]).first %>
  105. </p>
  106. <p>
  107. <b>Last event created:</b>
  108. <%= @agent.last_event_at ? time_ago_in_words(@agent.last_event_at) + " ago" : "never" %>
  109. </p>
  110. <% end %>
  111. <% if @agent.can_receive_events? %>
  112. <p>
  113. <b>Last received event:</b>
  114. <%= @agent.last_receive_at ? time_ago_in_words(@agent.last_receive_at) + " ago" : "never" %>
  115. </p>
  116. <% end %>
  117. <% if @agent.can_create_events? %>
  118. <p>
  119. <b>Events created:</b>
  120. <%= link_to @agent.events.count, events_path(:agent => @agent.to_param) %>
  121. </p>
  122. <% end %>
  123. <% if @agent.can_receive_events? %>
  124. <p>
  125. <b>Event sources:</b>
  126. <% if @agent.sources.length %>
  127. <%= @agent.sources.map { |source_agent| link_to(source_agent.name, agent_path(source_agent)) }.to_sentence.html_safe %>
  128. <% else %>
  129. None
  130. <% end %>
  131. </p>
  132. <% end %>
  133. <% if @agent.can_create_events? %>
  134. <p>
  135. <b>Event receivers:</b>
  136. <% if @agent.receivers.length %>
  137. <%= @agent.receivers.map { |receiver_agent| link_to(receiver_agent.name, agent_path(receiver_agent)) }.to_sentence.html_safe %>
  138. <% else %>
  139. None
  140. <% end %>
  141. </p>
  142. <% end %>
  143. <p>
  144. <b>Working:</b>
  145. <%= working @agent %>
  146. </p>
  147. <p>
  148. <b>Options:</b>
  149. <pre><%= Utils.pretty_jsonify @agent.options || {} %></pre>
  150. </p>
  151. <p>
  152. <b>Memory:</b>
  153. <pre><%= Utils.pretty_jsonify @agent.memory || {} %></pre>
  154. </p>
  155. </div>
  156. </div>
  157. </div>
  158. </div>
  159. </div>