powerdns-admin/powerdnsadmin/templates/admin_manage_keys.html

154 lines
5.0 KiB
HTML
Raw Normal View History

2020-08-08 13:41:18 +00:00
{% extends "base.html" %}
2020-08-08 13:41:18 +00:00
{% set active_page = "admin_keys" %}
2020-08-08 13:41:18 +00:00
{% block title %}
<title>
Key Management - {{ SITE_NAME }}
</title>
{% endblock %}
{% block dashboard_stat %}
<div class="content-header">
<div class="container-fluid">
<div class="row mb-2">
<div class="col-sm-6">
<h1 class="m-0 text-dark">
API Keys
<small>Management</small>
</h1>
</div>
<div class="col-sm-6">
<ol class="breadcrumb float-sm-right">
<li class="breadcrumb-item"><a href="{{ url_for('dashboard.dashboard') }}">Dashboard</a></li>
<li class="breadcrumb-item active">API Keys</li>
</ol>
</div>
</div>
</div>
</div>
{% endblock %}
{% block content %}
2020-08-08 13:41:18 +00:00
<section class="content">
<div class="container-fluid">
<div class="card">
<div class="card-header with-border">
<h3 class="card-title">Key Management</h3>
<a href="{{ url_for('admin.edit_key') }}">
<button type="button" class="btn btn-primary float-right button_add_key">
<i class="fa-solid fa-plus"></i>&nbsp;Add Key
</button>
</a>
</div>
<div class="card-body">
<table id="tbl_keys" class="table table-bordered table-striped">
<thead>
<tr>
<th>Id</th>
<th>Role</th>
<th>Description</th>
<th>Domains</th>
<th>Accounts</th>
<th>Actions</th>
</tr>
</thead>
<tbody>
{% for key in keys %}
<tr class="odd gradeX">
<td>{{ key.id }}</td>
<td>{{ key.role.name }}</td>
<td>{{ key.description }}</td>
<td>{% for domain in key.domains %}{{ domain.name }}{% if not loop.last %}, {% endif %}{% endfor %}</td>
<td>{% for account in key.accounts %}{{ account.name }}{% if not loop.last %}, {% endif %}{% endfor %}</td>
<td width="15%">
<div class="dropdown">
<button class="btn btn-primary dropdown-toggle" type="button" id="dropdownMenu" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
<i class="fa-solid fa-bars"></i>&nbsp;Actions
</button>
<div class="dropdown-menu" aria-labelledby="dropdownMenu">
<button type="button" class="dropdown-item btn-warning" onclick="window.location.href='{{ url_for('admin.edit_key', key_id=key.id) }}'">
<i class="fa-solid fa-edit"></i>&nbsp;Edit API Key
</button>
<div class="dropdown-divider"></div>
<button type="button"class="dropdown-item btn-secondary button_delete" id="{{ key.id }}">
<font color="red">
<i class="fa-solid fa-trash"></i>&nbsp;Delete API Key
</font>
</button>
</div>
</div>
</td>
</tr>
{% endfor %}
</tbody>
</table>
</div>
2020-08-08 13:41:18 +00:00
</div>
</div>
2020-08-08 13:41:18 +00:00
</section>
{% endblock %}
2020-08-08 13:41:18 +00:00
{% block extrascripts %}
<script>
2020-08-08 13:41:18 +00:00
// set up key data table
$("#tbl_keys").DataTable({
"paging": true,
"lengthChange": true,
"searching": true,
"ordering": true,
"info": false,
"autoWidth": false,
"lengthMenu": [
[10, 25, 50, 100, -1],
[10, 25, 50, 100, "All"]
],
"pageLength": 10
2020-08-08 13:41:18 +00:00
});
// handle deletion of keys
$(document.body).on('click', '.button_delete', function () {
var modal = $("#modal_delete");
var key_id = $(this).prop('id');
var info = "Are you sure you want to delete key #" + key_id + "?";
modal.find('.modal-body p').text(info);
modal.find('#button_delete_confirm').click(function () {
var postdata = {
'action': 'delete_key',
'data': key_id,
'_csrf_token': '{{ csrf_token() }}'
}
applyChanges(postdata, $SCRIPT_ROOT + '/admin/manage-keys', false, true);
modal.modal('hide');
})
modal.modal('show');
2020-08-08 13:41:18 +00:00
});
</script>
2020-08-08 13:41:18 +00:00
{% endblock %}
2020-08-08 13:41:18 +00:00
{% block modals %}
<div class="modal fade modal-warning" id="modal_delete">
2020-08-08 13:41:18 +00:00
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<h4 class="modal-title">Confirmation</h4>
<button type="button" class="close" data-dismiss="modal" aria-label="Close">
<span aria-hidden="true">&times;</span>
</button>
</div>
<div class="modal-body">
<p></p>
2020-08-08 13:41:18 +00:00
</div>
<div class="modal-footer">
<button type="button" class="btn btn-secondary" data-dismiss="modal">
Close
</button>
<button type="button" class="btn btn-danger" id="button_delete_confirm">
Delete
</button>
</div>
</div>
2020-08-08 13:41:18 +00:00
</div>
</div>
2020-08-08 13:41:18 +00:00
{% endblock %}