{% extends "base.html" %}
{% block title %}<title>DNS Control Panel - Templates</title>{% endblock %}

{% block dashboard_stat %}
    <!-- Content Header (Page header) -->
    <section class="content-header">
      <h1>
        Templates
        <small>List</small>
      </h1>
      <ol class="breadcrumb">
        <li><a href="{{ url_for('templates') }}"><i class="fa fa-dashboard"></i> Templates</a></li>
        <li class="active">List</li>
      </ol>
    </section>
{% endblock %}
{% block content %}
 <!-- Main content -->
    <section class="content">
    {% with errors = get_flashed_messages(category_filter=["error"]) %} {% if errors %}
<div class="row">
	<div class="col-md-12">
		<div class="alert alert-danger alert-dismissible">
			<button type="button" class="close" data-dismiss="alert"
				aria-hidden="true">&times;</button>
			<h4>
				<i class="icon fa fa-ban"></i> Error!
			</h4>
			<div class="alert-message block-message error">
				<a class="close" href="#">x</a>
				<ul>
					{%- for msg in errors %}
					<li>{{ msg }}</li> {% endfor -%}
				</ul>
			</div>
		</div>
	</div>
</div>
{% endif %} {% endwith %}
      <div class="row">
        <div class="col-xs-12">
          <div class="box">
            <div class="box-header">
              <h3 class="box-title">Templates</h3>
            </div>
            <div class="box-body">
            	<a href="{{ url_for('create_template') }}">
	              <button type="button" class="btn btn-flat btn-primary pull-left">
	                  Create Template&nbsp;<i class="fa fa-plus"></i>
	              </button>
              	</a>
            </div>
            <div class="box-body">
              <table id="tbl_template_list" class="table table-bordered table-striped">
                <thead>
                <tr>
                  <th>Name</th>
                  <th>Description</th>
                  <th>Number of Records</th>
                  <th width="20%">Action</th>
                </tr>
                </thead>
                <tbody>
                {% for template in templates %}
                <tr>
                  <td>
                    <a href="{{ url_for('edit_template', template=template.name) }}"><strong>{{ template.name }}</strong></a>
                  </td>
                  <td>
                    {{ template.description }}
                  </td>
                  <td>
                    {{ template.records|count }}
                  </td>
                  <td>
                  <a href="{{ url_for('edit_template', template=template.name) }}">
                    <button type="button" class="btn btn-flat btn-warning button_edit" id="">
                                            Edit&nbsp;<i class="fa fa-edit"></i>
                                        </button>
                                        </a>
                  	<a href="{{ url_for('delete_template', template=template.name) }}">
                   		<button type="button" class="btn btn-flat btn-danger button_delete" id="">
                    		  Delete&nbsp;<i class="fa fa-trash"></i>
                   		</button>
                   	</a>
                  </td>
                </tr>
                {% endfor %}
                </tbody>
              </table>
            </div>
            <!-- /.box-body -->
          </div>
          <!-- /.box -->
        </div>
        <!-- /.col -->
      </div>
      <!-- /.row -->
    </section>
    <!-- /.content -->
{% endblock %}
{% block extrascripts %}
<script>
    // set up history data table
    $("#tbl_template_list").DataTable({
        "paging" : true,
        "lengthChange" : true,
        "searching" : true,
        "ordering" : true,
        "info" : false,
        "autoWidth" : false
    });
</script>
{% endblock %}
{% block modals %}
{% endblock %}