{% load bootstrap3 %}

{% if formset.total_form_count > 0 %}

	<form id='instancesform' action="/instances/" method="post" class="form">
	{{ formset.management_form }}
	<table class="table table-striped">
    	<thead>
    		<tr>
    		{% for column_name in columns %}
    		<th>{{ column_name }}</th>
    		{% endfor %}
    		<th></th>
    		</tr>
    	</thead>
    	<tbody>
        {% for form in formset %}

		    {{ form.id }}
        		        	
		    {% csrf_token %}  

        	<tr>
		    {% for field in form.visible_fields %}					
            	<td> {{ field }} </td>
        	{% endfor %}
        		<td>
        			<button name="_save" type="submit" class="btn btn-default" value="save-{{ form.id.value }}">
			            Save
			        </button>
			        <button name="_start" type="submit" class="btn btn-primary" value="start-{{ form.id.value }}">
			            Start
			        </button>
					<button name="_stop" type="submit" class="btn btn-warning" value="stop-{{ form.id.value }}">
			            Stop
			        </button>				        
			        <button name="_trash" type="submit" class="btn btn-danger" value="trash-{{ form.id.value }}">
			            Trash
			        </button>			        
			        <button type="button" class="btn btn-default btn-lg" data-toggle="popover" data-placement="bottom" data-title="How to connect" data-container="body" data-html="true" data-content="Run this command in your terminal: &lt;br&gt; &lt;strong&gt;curl&nbsp;{{ connect_url }}?name={{ form.name.value }}&nbsp;|&nbsp;bash&lt;/strong&gt;">
  						<span class="glyphicon glyphicon-log-in"></span>
					</button>
		        </td>
			</tr>

        {% endfor %}
        </tbody>
	</table>
	</form>


	
	<div><button id="refreshInstancesButton" class="btn btn-success">Refresh</button></div>
	  	</div>


{% else %}

	<h4> There were no instances found. Consider cloning a new one.</h4>

{% endif %}
