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