2018-07-09 19:27:22 +02:00
|
|
|
|
var apiKeysTable = $('#apikeys-table').DataTable({
|
|
|
|
|
'order': [[4, 'desc']],
|
|
|
|
|
'columnDefs': [
|
2020-01-03 14:18:56 +01:00
|
|
|
|
{ 'orderable': false, 'targets': 0 },
|
|
|
|
|
{ 'searchable': false, "targets": 0 }
|
2019-10-15 19:38:51 +02:00
|
|
|
|
]
|
2018-07-09 19:27:22 +02:00
|
|
|
|
});
|
2019-01-05 20:06:35 +01:00
|
|
|
|
$('#apikeys-table tbody').removeClass("d-none");
|
2019-03-04 17:43:12 +01:00
|
|
|
|
apiKeysTable.columns.adjust().draw();
|
2018-07-09 19:27:22 +02:00
|
|
|
|
|
|
|
|
|
var createdApiKeyId = GetUriParam('CreatedApiKeyId');
|
|
|
|
|
if (createdApiKeyId !== undefined)
|
|
|
|
|
{
|
|
|
|
|
$('#apiKeyRow_' + createdApiKeyId).effect('highlight', {}, 3000);
|
|
|
|
|
}
|
|
|
|
|
|
2019-10-15 19:59:14 +02:00
|
|
|
|
$("#search").on("keyup", Delay(function()
|
2018-07-09 19:27:22 +02:00
|
|
|
|
{
|
|
|
|
|
var value = $(this).val();
|
|
|
|
|
if (value === "all")
|
|
|
|
|
{
|
|
|
|
|
value = "";
|
|
|
|
|
}
|
2019-01-19 00:37:21 -07:00
|
|
|
|
|
2018-07-09 19:27:22 +02:00
|
|
|
|
apiKeysTable.search(value).draw();
|
2019-10-15 19:59:14 +02:00
|
|
|
|
}, 200));
|
2018-07-09 19:27:22 +02:00
|
|
|
|
|
|
|
|
|
$(document).on('click', '.apikey-delete-button', function (e)
|
2018-04-21 19:18:00 +02:00
|
|
|
|
{
|
|
|
|
|
var objectName = $(e.currentTarget).attr('data-apikey-apikey');
|
|
|
|
|
var objectId = $(e.currentTarget).attr('data-apikey-id');
|
|
|
|
|
|
|
|
|
|
bootbox.confirm({
|
2019-05-01 20:19:18 +02:00
|
|
|
|
message: __t('Are you sure to delete API key "%s"?', objectName),
|
2019-09-24 10:24:47 +02:00
|
|
|
|
closeButton: false,
|
2018-04-21 19:18:00 +02:00
|
|
|
|
buttons: {
|
|
|
|
|
confirm: {
|
2019-05-01 20:19:18 +02:00
|
|
|
|
label: __t('Yes'),
|
2018-04-21 19:18:00 +02:00
|
|
|
|
className: 'btn-success'
|
|
|
|
|
},
|
|
|
|
|
cancel: {
|
2019-05-01 20:19:18 +02:00
|
|
|
|
label: __t('No'),
|
2018-04-21 19:18:00 +02:00
|
|
|
|
className: 'btn-danger'
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
callback: function(result)
|
|
|
|
|
{
|
|
|
|
|
if (result === true)
|
|
|
|
|
{
|
2019-01-19 14:51:51 +01:00
|
|
|
|
Grocy.Api.Delete('objects/api_keys/' + objectId, {},
|
2018-04-21 19:18:00 +02:00
|
|
|
|
function(result)
|
|
|
|
|
{
|
|
|
|
|
window.location.href = U('/manageapikeys');
|
|
|
|
|
},
|
|
|
|
|
function(xhr)
|
|
|
|
|
{
|
|
|
|
|
console.error(xhr);
|
|
|
|
|
}
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
});
|