Skip to content

Commit

Permalink
Merge pull request huginn#1348 from cantino/add_agent_age_column
Browse files Browse the repository at this point in the history
Add column with default sort to prioritize new Agents in the index view
  • Loading branch information
cantino committed Mar 16, 2016
2 parents c1b2496 + 7476d7d commit 0e32f40
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
2 changes: 1 addition & 1 deletion app/controllers/agents_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ class AgentsController < ApplicationController
include SortableTable

def index
set_table_sort sorts: %w[name last_check_at last_event_at last_receive_at], default: { name: :asc }
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])

Expand Down
4 changes: 4 additions & 0 deletions app/views/agents/_table.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
<table class='table table-striped'>
<tr>
<th><%= sortable_column 'name', 'asc' %></th>
<th><%= sortable_column 'created_at', 'desc', name: 'Age' %></th>
<th>Schedule</th>
<th><%= sortable_column 'last_check_at', name: 'Last Check' %></th>
<th><%= sortable_column 'last_event_at', name: 'Last Event Out' %></th>
Expand All @@ -23,6 +24,9 @@
</span>
<% end %>
</td>
<td class='<%= "agent-unavailable" if agent.unavailable? %>'>
<%= time_ago_in_words agent.created_at %>
</td>
<td class='<%= "agent-unavailable" if agent.unavailable? %>'>
<% if agent.can_be_scheduled? %>
<%= agent_schedule(agent, ',<br/>') %>
Expand Down

0 comments on commit 0e32f40

Please sign in to comment.