mirror of
https://github.com/Fishwaldo/huginn.git
synced 2025-03-15 19:31:26 +00:00
Add agent role icons in agent tables
This commit is contained in:
parent
9202c84406
commit
96537fcd3a
5 changed files with 39 additions and 2 deletions
|
@ -318,3 +318,12 @@ $service-colors: (
|
|||
color: yellow;
|
||||
text-decoration: underline;
|
||||
}
|
||||
|
||||
.glyphicon-flipped {
|
||||
-ms-transform: translateZ(0);
|
||||
-webkit-transform: translateZ(0);
|
||||
transform: translateZ(0);
|
||||
-ms-transform: scaleX(-1);
|
||||
-webkit-transform: scaleX(-1);
|
||||
transform: scaleX(-1);
|
||||
}
|
||||
|
|
|
@ -6,7 +6,7 @@ class AgentsController < ApplicationController
|
|||
def index
|
||||
set_table_sort sorts: %w[name created_at last_check_at last_event_at last_receive_at], default: { created_at: :desc }
|
||||
|
||||
@agents = current_user.agents.preload(:scenarios, :controllers).reorder(table_sort).page(params[:page])
|
||||
@agents = current_user.agents.preload(:scenarios, :controllers, :links_as_receiver, :links_as_source, :control_links_as_controller).reorder(table_sort).page(params[:page])
|
||||
|
||||
if show_only_enabled_agents?
|
||||
@agents = @agents.where(disabled: false)
|
||||
|
|
|
@ -26,7 +26,7 @@ class ScenariosController < ApplicationController
|
|||
@scenario = current_user.scenarios.find(params[:id])
|
||||
|
||||
set_table_sort sorts: %w[name last_check_at last_event_at last_receive_at], default: { name: :asc }
|
||||
@agents = @scenario.agents.preload(:scenarios, :controllers).reorder(table_sort).page(params[:page])
|
||||
@agents = @scenario.agents.preload(:scenarios, :controllers, :links_as_receiver, :links_as_source, :control_links_as_controller).reorder(table_sort).page(params[:page])
|
||||
|
||||
respond_to do |format|
|
||||
format.html
|
||||
|
|
|
@ -57,4 +57,28 @@ module AgentHelper
|
|||
'maybe'.freeze
|
||||
end
|
||||
end
|
||||
|
||||
def agent_type_icon(agent)
|
||||
receiver_count = agent.links_as_receiver.length
|
||||
control_count = agent.control_links_as_controller.length
|
||||
source_count = agent.links_as_source.length
|
||||
|
||||
if control_count > 0 && receiver_count > 0
|
||||
content_tag('span') do
|
||||
concat icon_tag('glyphicon-arrow-right')
|
||||
concat tag('br')
|
||||
concat icon_tag('glyphicon-new-window', class: 'glyphicon-flipped')
|
||||
end
|
||||
elsif control_count > 0 && receiver_count == 0
|
||||
icon_tag('glyphicon-new-window', class: 'glyphicon-flipped')
|
||||
elsif receiver_count > 0 && source_count == 0
|
||||
icon_tag('glyphicon-arrow-right')
|
||||
elsif receiver_count == 0 && source_count > 0
|
||||
icon_tag('glyphicon-arrow-left')
|
||||
elsif receiver_count > 0 && source_count > 0
|
||||
icon_tag('glyphicon-transfer')
|
||||
else
|
||||
icon_tag('glyphicon-unchecked')
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
<div class='table-responsive'>
|
||||
<table class='table table-striped'>
|
||||
<tr>
|
||||
<th></th>
|
||||
<th><%= sortable_column 'name', 'asc' %></th>
|
||||
<th><%= sortable_column 'created_at', 'desc', name: 'Age' %></th>
|
||||
<th>Schedule</th>
|
||||
|
@ -14,6 +15,9 @@
|
|||
|
||||
<% @agents.each do |agent| %>
|
||||
<tr>
|
||||
<td class='<%= "agent-unavailable" if agent.unavailable? %>'>
|
||||
<%= agent_type_icon(agent) %>
|
||||
</td>
|
||||
<td class='<%= "agent-unavailable" if agent.unavailable? %>'>
|
||||
<%= link_to agent.name, agent_path(agent, return: (defined?(return_to) && return_to) || request.path) %>
|
||||
<br/>
|
||||
|
|
Loading…
Add table
Reference in a new issue