Fix api key delete confirm

This commit is contained in:
amcmanu3 2022-08-04 15:47:52 -04:00
parent b20e303932
commit 719896e4b2

View File

@ -15,7 +15,7 @@
<div class="page-header"> <div class="page-header">
<h4 class="page-title"> <h4 class="page-title">
{{ translate('apiKeys', 'pageTitle', data['lang']) }} - {{ data['user']['user_id'] }} {{ translate('apiKeys', 'pageTitle', data['lang']) }} - {{ data['user']['user_id'] }}
<br/> <br />
<small>UID: {{ data['user']['user_id'] }}</small> <small>UID: {{ data['user']['user_id'] }}</small>
</h4> </h4>
</div> </div>
@ -32,14 +32,12 @@
<ul class="nav nav-tabs col-md-12 tab-simple-styled " role="tablist"> <ul class="nav nav-tabs col-md-12 tab-simple-styled " role="tablist">
<li class="nav-item"> <li class="nav-item">
<a class="nav-link" href="/panel/edit_user?id={{ data['user']['user_id'] }}&subpage=config" <a class="nav-link" href="/panel/edit_user?id={{ data['user']['user_id'] }}&subpage=config"
role="tab" role="tab" aria-selected="false">
aria-selected="false">
<i class="fas fa-cogs"></i>{{ translate('apiKeys', 'config', data['lang']) }}</a> <i class="fas fa-cogs"></i>{{ translate('apiKeys', 'config', data['lang']) }}</a>
</li> </li>
<li class="nav-item"> <li class="nav-item">
<a class="nav-link active" href="/panel/edit_user_apikeys?id={{ data['user']['user_id'] }}" <a class="nav-link active" href="/panel/edit_user_apikeys?id={{ data['user']['user_id'] }}"
role="tab" role="tab" aria-selected="true">
aria-selected="true">
<i class="fas fa-key"></i>{{ translate('apiKeys', 'apiKeys', data['lang']) }}</a> <i class="fas fa-key"></i>{{ translate('apiKeys', 'apiKeys', data['lang']) }}</a>
</li> </li>
</ul> </ul>
@ -48,56 +46,60 @@
<div class="col-md-7 col-sm-12"> <div class="col-md-7 col-sm-12">
<div class="card"> <div class="card">
<div class="card-header header-sm d-flex justify-content-between align-items-center"> <div class="card-header header-sm d-flex justify-content-between align-items-center">
<h4 class="card-title"><i class="fas fa-key"></i>{{ translate('apiKeys', 'apiKeys', data['lang']) }}</h4> <h4 class="card-title"><i class="fas fa-key"></i>{{ translate('apiKeys', 'apiKeys',
data['lang']) }}</h4>
</div> </div>
<div class="card-body"> <div class="card-body">
<div class="form-group"> <div class="form-group">
<div class="table-responsive"> <div class="table-responsive">
<table class="table table-hover"> <table class="table table-hover">
<thead> <thead>
<tr class="rounded"> <tr class="rounded">
<!--<th>ID</th>--> <!--<th>ID</th>-->
<th>{{ translate('apiKeys', 'name', data['lang']) }}</th> <th>{{ translate('apiKeys', 'name', data['lang']) }}</th>
<th>{{ translate('apiKeys', 'created', data['lang']) }}</th> <th>{{ translate('apiKeys', 'created', data['lang']) }}</th>
<th>{{ translate('apiKeys', 'superUser', data['lang']) }}</th> <th>{{ translate('apiKeys', 'superUser', data['lang']) }}</th>
<th>{{ translate('apiKeys', 'perms', data['lang']) }}</th> <th>{{ translate('apiKeys', 'perms', data['lang']) }}</th>
<th>{{ translate('apiKeys', 'buttons', data['lang']) }}</th> <th>{{ translate('apiKeys', 'buttons', data['lang']) }}</th>
</tr> </tr>
</thead> </thead>
<tbody> <tbody>
{% for apikey in data['api_keys'] %} {% for apikey in data['api_keys'] %}
<tr> <tr>
<!--<td>{-{ apikey.token_id }-}</td>--> <!--<td>{-{ apikey.token_id }-}</td>-->
<td>{{ apikey.name }}</td> <td>{{ apikey.name }}</td>
<td>{{ apikey.created.strftime('%d/%m/%Y %H:%M:%S') }}</td> <td>{{ apikey.created.strftime('%d/%m/%Y %H:%M:%S') }}</td>
<td> <td>
{% if apikey.superuser %} {% if apikey.superuser %}
<span class="text-success"> <span class="text-success">
<i class="fas fa-check-square"></i> {{ translate('apiKeys', 'yes', data['lang']) }} <i class="fas fa-check-square"></i> {{
</span> translate('apiKeys', 'yes', data['lang']) }}
{% else %} </span>
<span class="text-danger"> {% else %}
<i class="far fa-times-square"></i> {{ translate('apiKeys', 'no', data['lang']) }} <span class="text-danger">
</span> <i class="far fa-times-square"></i> {{
{% end %} translate('apiKeys', 'no', data['lang']) }}
</td> </span>
<td>{{ translate('apiKeys', 'server', data['lang']) }} {{ apikey.server_permissions }} {% end %}
{{ translate('apiKeys', 'crafty', data['lang']) }} {{ apikey.crafty_permissions }}</td> </td>
<td> <td>{{ translate('apiKeys', 'server', data['lang']) }} {{
<button apikey.server_permissions }}
class="btn btn-danger delete-api-key" {{ translate('apiKeys', 'crafty', data['lang']) }} {{
apikey.crafty_permissions }}</td>
<td>
<button class="btn btn-danger delete-api-key"
data-key-id="{{ apikey.token_id }}" data-key-id="{{ apikey.token_id }}"
data-key-name="{{ apikey.name }}" data-key-name="{{ apikey.name }}">{{
>{{ translate('panelConfig', 'delete', data['lang']) }}</button> translate('panelConfig', 'delete', data['lang'])
<button }}</button>
class="btn btn-outline-primary get-a-token" <button class="btn btn-outline-primary get-a-token"
data-key-id="{{ apikey.token_id }}" data-key-id="{{ apikey.token_id }}"
data-key-name="{{ apikey.name }}" data-key-name="{{ apikey.name }}">{{
>{{ translate('apiKeys', 'getToken', data['lang']) }} translate('apiKeys', 'getToken', data['lang']) }}
</button> </button>
</td> </td>
</tr> </tr>
{% end %} {% end %}
</tbody> </tbody>
</table> </table>
</div> </div>
@ -109,68 +111,69 @@
<div class="col-md-5 col-sm-12"> <div class="col-md-5 col-sm-12">
<div class="card"> <div class="card">
<div class="card-header header-sm d-flex justify-content-between align-items-center"> <div class="card-header header-sm d-flex justify-content-between align-items-center">
<h4 class="card-title"><i class="fas fa-plus"></i> {{ translate('apiKeys', 'createNew', data['lang']) }}</h4> <h4 class="card-title"><i class="fas fa-plus"></i> {{ translate('apiKeys',
'createNew', data['lang']) }}</h4>
</div> </div>
<div class="card-body"> <div class="card-body">
<form id="user_form" class="forms-sample" method="post" <form id="user_form" class="forms-sample" method="post"
action="/panel/edit_user_apikeys"> action="/panel/edit_user_apikeys">
{% raw xsrf_form_html() %} {% raw xsrf_form_html() %}
<input type="hidden" name="id" value="{{ data['user']['user_id'] }}"> <input type="hidden" name="id" value="{{ data['user']['user_id'] }}">
<div class="form-group"> <div class="form-group">
<label class="form-label" for="username">{{ translate('apiKeys', 'name', data['lang']) }}<small <label class="form-label" for="username">{{ translate('apiKeys', 'name',
class="text-muted ml-1"> - {{ translate('apiKeys', 'nameDesc', data['lang']) }}</small> </label> data['lang']) }}<small class="text-muted ml-1"> - {{
translate('apiKeys', 'nameDesc', data['lang']) }}</small> </label>
<input type="text" class="form-control" name="name" id="name" <input type="text" class="form-control" name="name" id="name"
placeholder="API Key"> placeholder="API Key">
</div> </div>
<table class="table table-hover mb-3"> <table class="table table-hover mb-3">
<thead> <thead>
<tr class="rounded"> <tr class="rounded">
<th>{{ translate('apiKeys', 'permName', data['lang']) }}</th> <th>{{ translate('apiKeys', 'permName', data['lang']) }}</th>
<th>{{ translate('apiKeys', 'auth', data['lang']) }}</th> <th>{{ translate('apiKeys', 'auth', data['lang']) }}</th>
</tr> </tr>
</thead> </thead>
<tbody> <tbody>
{% for permission in data['server_permissions_all'] %} {% for permission in data['server_permissions_all'] %}
<tr> <tr>
<td><label <td><label for="permission_{{ permission.name }}">{{ permission.name
for="permission_{{ permission.name }}">{{ permission.name }}</label> }}</label>
</td> </td>
<td> <td>
<input type="checkbox" class="" <input type="checkbox" class=""
id="permission_{{ permission.name }}" id="permission_{{ permission.name }}"
name="permission_{{ permission.name }}" value="1"> name="permission_{{ permission.name }}" value="1">
</td> </td>
</tr> </tr>
{% end %} {% end %}
{% for permission in data['crafty_permissions_all'] %} {% for permission in data['crafty_permissions_all'] %}
<tr> <tr>
<td><label <td><label for="permission_{{ permission.name }}">{{ permission.name
for="permission_{{ permission.name }}">{{ permission.name }}</label> }}</label>
</td> </td>
<td> <td>
<input type="checkbox" class="" <input type="checkbox" class=""
id="permission_{{ permission.name }}" id="permission_{{ permission.name }}"
name="permission_{{ permission.name }}" value="1"> name="permission_{{ permission.name }}" value="1">
</td> </td>
</tr> </tr>
{% end %} {% end %}
</tbody> </tbody>
</table> </table>
<label for="superuser">Superuser</label> <label for="superuser">Superuser</label>
<input type="checkbox" class="" id="superuser" <input type="checkbox" class="" id="superuser" name="superuser" value="1">
name="superuser" value="1">
<br/> <br />
<button type="submit" class="btn btn-success mr-2"><i class="fas fa-plus"></i> <button type="submit" class="btn btn-success mr-2"><i class="fas fa-plus"></i>
Create Create
</button> </button>
<button type="reset" class="btn btn-light"><i <button type="reset" class="btn btn-light"><i class="fas fa-undo-alt"></i> {{
class="fas fa-undo-alt"></i> {{ translate('panelConfig', 'cancel', data['lang']) }} translate('panelConfig', 'cancel', data['lang']) }}
</button> </button>
</form> </form>
</div> </div>
@ -216,15 +219,17 @@
} }
}, },
callback: function (result) { callback: function (result) {
var token = getCookie("_xsrf") if (result) {
$.ajax({ var token = getCookie("_xsrf")
type: "DELETE", $.ajax({
headers: {'X-XSRFToken': token}, type: "DELETE",
url: '/panel/remove_apikey?id=' + keyId, headers: { 'X-XSRFToken': token },
success: function (data) { url: '/panel/remove_apikey?id=' + keyId,
location.reload(); success: function (data) {
}, location.reload();
}); },
});
}
} }
}); });
}) })
@ -234,7 +239,7 @@
var token = getCookie("_xsrf") var token = getCookie("_xsrf")
$.ajax({ $.ajax({
type: "POST", type: "POST",
headers: {'X-XSRFToken': token}, headers: { 'X-XSRFToken': token },
url: '/panel/get_token?id=' + keyId, url: '/panel/get_token?id=' + keyId,
success: function (data) { success: function (data) {
bootbox.alert({ bootbox.alert({
@ -249,4 +254,4 @@
</script> </script>
{% end %} {% end %}