<!-- Modal -->
<div class="modal fade" id="myModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
  <div class="modal-dialog">
    <div class="modal-content">
      <div class="modal-header">
        <button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
        <h4 class="modal-title" id="myModalLabel"></h4>
      </div>
      <div class="modal-body"></div>
    </div>
  </div>
</div>
<!-- Modal end -->

<div class="row">
	<div class="col-md-12 col-xs-12">
		<div class="panel panel-default">
			<div class="panel-heading clearfix">
				<i class="icon-dashboard"></i>
				<h3 class="panel-title">Previous Payload List</h3>
			</div>
			<div class="panel-body">
				<table id="example" class="table table-striped table-bordered" cellspacing="0" width="100%">
	        <thead>
            <tr>
				       <th>Device</th>
    					<th>Commands</th>
    					<th>Status</th>
              <th>Action</th>
            </tr>
	        </thead>
	        <tbody>
	        	<%(router_inventories || []).each do |router|%>
	            <% router.commands.each do |command| %>
	            	<tr>
					        <td><%= command.aps %></td>
					        <td><%= command.commands %></td>
					        <td><%= command.status %></td>
	                <td>
	                	<% if "pending".eql?(command.status) %>
	  	                <%= link_to 'Edit', {:controller=>:commands, :action=>:index, :id=>command.id},:class=>"label label-info"  %>
	                	<% elsif "success".eql?(command.status) %>
		                  <%= link_to 'Result', "javascript:void(0);", :id=>"modal", :data=> command.result, :command=>command.commands,:class=>"text-success" %>
                	 	<% end %>
	                </td>
	            	</tr>
	          	<%end%>
	          <%end%>
	        </tbody>
			  </table>
			</div>
		</div>
	</div>
</div>
<script type="text/javascript">
jQuery(document).on('click', '#modal',function(){ 
	$(".modal-body").html(jQuery(this).attr("data"))
	$("#myModalLabel").html(jQuery(this).attr("command")+" "+" Result")
  $('#myModal').modal('show')
})
</script>
