2020-08-08 13:41:18 +00:00
|
|
|
{% extends "base.html" %}
|
|
|
|
{% set active_page = "admin_keys" %}
|
2023-02-20 14:39:13 +00:00
|
|
|
{% block title %}<title>API Keys - {{ SITE_NAME }}</title>{% endblock %}
|
2023-02-18 16:04:14 +00:00
|
|
|
|
|
|
|
{% block dashboard_stat %}
|
2023-02-20 14:39:13 +00:00
|
|
|
<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</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>
|
2023-02-18 14:04:37 +00:00
|
|
|
</div>
|
2023-02-18 16:04:14 +00:00
|
|
|
</div>
|
|
|
|
{% endblock %}
|
|
|
|
|
|
|
|
{% block content %}
|
2023-02-20 14:39:13 +00:00
|
|
|
<section class="content">
|
|
|
|
<div class="container-fluid">
|
2023-02-22 14:12:13 +00:00
|
|
|
<div class="card card-outline card-primary shadow">
|
2023-02-20 14:39:13 +00:00
|
|
|
<div class="card-header with-border">
|
|
|
|
<h3 class="card-title">API Keys</h3>
|
|
|
|
<div class="card-tools">
|
|
|
|
<a href="{{ url_for('admin.edit_key') }}">
|
|
|
|
<button type="button" class="btn btn-primary float-right button_add_key" title="Create Key">
|
|
|
|
<i class="fa-solid fa-plus"></i> Create Key
|
|
|
|
</button>
|
|
|
|
</a>
|
|
|
|
</div>
|
|
|
|
<!-- /.card-tools -->
|
|
|
|
</div>
|
|
|
|
<!-- /.card-header -->
|
|
|
|
<div class="card-body table-responsive">
|
|
|
|
<table id="tbl_keys" class="table table-bordered table-striped table-hover table-sm records">
|
|
|
|
<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>
|
|
|
|
<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>
|
|
|
|
</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> 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> Delete API Key
|
|
|
|
</font>
|
|
|
|
</button>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</td>
|
|
|
|
</tr>
|
|
|
|
{% endfor %}
|
|
|
|
</tbody>
|
|
|
|
</table>
|
|
|
|
</div>
|
|
|
|
<!-- /.card-body -->
|
|
|
|
</div>
|
|
|
|
<!-- /.card -->
|
|
|
|
</div>
|
|
|
|
<!-- /.container-fluid -->
|
|
|
|
</section>
|
2020-08-08 13:41:18 +00:00
|
|
|
{% endblock %}
|
2023-02-18 16:04:14 +00:00
|
|
|
|
2020-08-08 13:41:18 +00:00
|
|
|
{% block extrascripts %}
|
2023-02-20 14:39:13 +00:00
|
|
|
<script>
|
|
|
|
// 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
|
|
|
|
2023-02-20 14:39:13 +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');
|
|
|
|
});
|
|
|
|
</script>
|
2020-08-08 13:41:18 +00:00
|
|
|
{% endblock %}
|
2023-02-18 16:04:14 +00:00
|
|
|
|
2020-08-08 13:41:18 +00:00
|
|
|
{% block modals %}
|
2023-02-20 14:39:13 +00:00
|
|
|
<div class="modal fade modal-warning" id="modal_delete">
|
|
|
|
<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">×</span>
|
|
|
|
</button>
|
|
|
|
</div>
|
|
|
|
<div class="modal-body">
|
|
|
|
<p></p>
|
|
|
|
</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>
|
2023-02-13 03:57:21 +00:00
|
|
|
</div>
|
2020-08-08 13:41:18 +00:00
|
|
|
</div>
|
|
|
|
{% endblock %}
|