{% extends 'frontend/base.html.j2' %}

{% block title %}{{ gettext('client certs') }}{% endblock %}

{% block content %}


<ul class="nav nav-tabs" id="myTab" role="tablist">
  {% for service in services.values() %}
	<li class="nav-item">
		<a class="nav-link{{' active' if loop.first else ''}}" id="home-tab" data-toggle="tab" href="#{{ service.name }}" role="tab" aria-controls="home" aria-selected="true">{{ service.name }}</a>
	</li>
  {% endfor %}
</ul>
<div class="tab-content" id="myTabContent">
	{% for service in services.values() if service.client_cert %}

	<div class="tab-pane fade{{ ' show active' if loop.first else '' }}" id="{{ service.name }}" role="tabpanel" aria-labelledby="{{ service.name }}-tab">
		<table class="table">
			<thead>
				<tr>
					<th>not valid before</th>
					<th>not valid after</th>
					<th>serial_number<th>
					<th> <th>
				</tr>
			</thead>
			<tbody>
				{% for cert in client_certs[service.name] %}
				<tr {{ 'class="table-warning"' if not cert.is_valid else ''}}>
					<td>{{ cert.not_valid_before }}</td>
					<td>{{ cert.not_valid_after }}</td>
					<td>{{ cert.serial_number_hex }}</td>
					<td>
						<a title="{{ gettext('Download') }}" href="{{ url_for('.get_client_cert', service_name=service.name, serial_number=cert.serial_number_hex) }}"><i class="fas fa-file-download"></i></a>
						&nbsp;
						{% if cert.is_valid %}
							<a title="{{ gettext('Revoke')}}" href="{{ url_for('.revoke_client_cert', service_name=service.name, serial_number=cert.serial_number_hex) }}" onclick="client_cert.revoke_certificate(this.href, '{{ cert.serial_number_hex }}'); return false;"><i class="fas fa-ban"></i></a>
						{% endif %}
					</td>
				</tr>
				{% endfor %}
		</table>
		<a class="btn btn-primary" href="{{ url_for('frontend.client_cert_new', service_name=service.name) }}">
			New Certificate
		</a>
	</div>
	{% endfor %}
</div>


{% endblock %}


{% block script_js %}

client_cert.init_list();


{% endblock %}
