|
<div class="page-header">
<h1>
Mission Control
<%= link_to 'Edit', edit_mission_path(@mission), :class => 'btn btn-mini btn-default' %>
<%= link_to 'Launch', mission_launch_path, :class => 'btn btn-mini btn-danger' %>
<%= render 'mission_status', :mission => @mission, :big => true %>
</h1>
<small>Director: <%= link_to @mission.owner.username, agent_profile_path(@mission.owner.id) %></small>
</div>
<p class="lead"><strong>Mission: </strong><%= @mission.title %></p>
<p class="lead"><strong>Details: </strong><%= @mission.description %></p>
<hr>
<h2>Agent List</h2>
<% if @mission.mission_agents.length > 0 %>
<div class="accordion" id="accordion_agents">
<% @agent_number = 1 %>
<% @mission.mission_agents.order(:created_at => :asc).each do |agent| %>
<% if agent.mission_agent_invites.last != nil %>
<% if agent.mission_agent_invites.last.status == 'accepted' %>
<% @status_label = 'label-success'%>
<% elsif agent.mission_agent_invites.last.status == 'denied' %>
<% @status_label = 'label-important'%>
<% elsif agent.mission_agent_invites.last.status == 'Completed' %>
<% @status_label = 'label-success'%>
<% @agent_status = 'closed'%>
<% else%>
<% @status_label = 'label-default'%>
<% end %>
<% if agent.mission_agent_steps.length == 0 %>
<% @agent_status = 'empty'%>
<% end %>
<% else %>
<% @status_label = 'label-important'%>
<% @agent_status = 'missing'%>
<% end %>
<div class="accordion-group" style="margin-bottom: 10px;">
<div class="accordion-heading">
<a class="accordion-toggle pull-left" data-toggle="collapse" href="#collapse_<%= agent.id %>" >
Agent <%= @agent_number %>
<% if agent.user != nil %>
<% if agent.user.username != nil %>
- <%= agent.user.username %>
<% else %>
- <%= agent.user.email %>
<% end %>
<% agent.mission_agent_invites.each do |invite| %>
<% if invite.user = agent.user %>
<% end %>
<% end %>
<% end %>
</a>
<span class="label <%= @status_label %> pull-right" style="margin-top: 8px; margin-right: 10px">
<% if @agent_status != 'missing'%>
<%= agent.mission_agent_invites.last.status %>
<% else %>
Agent not found!
<% end %>
</span>
<div class="clearfix"></div>
</div>
<div id="collapse_<%= agent.id %>" class="accordion-body collapse <% if @agent_status == 'missing' || @agent_status == 'empty' || @agent_status == 'closed' %> out <% else %> in <% end %>">
<div class="accordion-inner">
<% @step = 1 %>
<% @line_step = 0%>
<% agent.mission_agent_steps.order(:created_at => :asc).each do |step| %>
<% if @line_step == 0 %>
<div class="row-fluid"><ul class="thumbnails">
<% end %>
<li class="span4">
<div class="thumbnail" style= "padding: 5px;">
<h3 style= "padding: 5px; margin-top: 0px;">Step <%= @step %> <%= render 'mission_agent_step_status', :step => step %></h3>
<p style= "padding: 5px; height: 50px;"><%= step.description %></p>
<% if step.status == 'Waiting Validation'%>
<div class="well well-small" style="margin-bottom: 0px; text-align: center; height: 90px;">
<p style="height: 60px"><strong>Response:</strong> <%= step.proof %></p>
<div style=" margin-top: 10px">
<%= link_to 'Invalidade', step_invalidate_check_path(step.id), :class => 'btn btn-danger btn-mini' %>
<%= link_to 'Validade', step_validate_check_path(step.id), :class => 'btn btn-success btn-mini', :style => 'margin-right: 5px;' %>
</div>
</div>
<% end %>
</li>
<% @step = @step + 1 %>
<% @line_step = @line_step + 1%>
<% if @line_step == 3 %>
<% @line_step = 0%>
</div></ul>
<% end %>
<% end %>
</div>
</div>
</div>
</div>
<% @agent_number = @agent_number + 1 %>
<% end %>
</div>
<% else %>
<br>
<em>No agents were assigned for this mission! Please edit mission settings and add agents in the form.</em>
<% end %>
|