snipe-it/resources/views/livewire/personal-access-tokens.blade.php

170 lines
6.6 KiB
PHP
Raw Normal View History

2023-11-14 09:50:27 -08:00
<div>
<div class="box box-default">
<div class="box-header with-border">
<div class="text-right">
<a class="btn btn-info btn-sm pull-right"
2023-11-14 09:50:27 -08:00
onclick="$('#modal-create-token').modal('show');"
wire:click="$dispatch('openModal')">
{{ trans('general.create') }}
2023-11-14 09:50:27 -08:00
</a>
</div>
</div>
<div class="box-body">
2023-11-14 09:50:27 -08:00
<!-- No Tokens Notice -->
@if($tokens->count() === 0)
<p>
{{ trans('account/general.no_tokens') }}
2023-11-14 09:50:27 -08:00
</p>
@endif
<!-- Personal Access Tokens -->
<div class="table table-responsive">
<table class="table table-striped snipe-table">
2023-11-14 09:50:27 -08:00
@if($tokens->count() > 0)
<thead>
<tr>
<th class="col-md-3">{{ trans('general.name') }}</th>
<th class="col-md-2">{{ trans('general.created_at') }}</th>
<th class="col-md-2">{{ trans('general.expires') }}</th>
<th class="col-md-2"><span class="sr-only">{{ trans('general.delete') }}</span></th>
2023-11-14 09:50:27 -08:00
</tr>
</thead>
<tbody>
2023-11-14 09:50:27 -08:00
@endif
@foreach($tokens as $token)
2023-11-14 09:50:27 -08:00
<tr>
<td>
2023-11-14 09:50:27 -08:00
{{ $token->name }}
</td>
<td>
2023-11-14 09:50:27 -08:00
{{ $token->created_at }}
</td>
<td>
2023-11-14 09:50:27 -08:00
{{ $token->expires_at }}
</td>
<td class="text-right">
2024-07-03 14:12:55 -07:00
<a class="action-link btn btn-danger btn-sm" wire:click="deleteToken('{{ $token->id }}')"
wire:loading.attr="disabled" data-tooltip="true" title="{{ trans('general.delete') }}">
<i class="fas fa-trash" aria-hidden="true"></i>
<span class="sr-only">
{{ trans('general.delete') }}
</span>
2023-11-14 09:50:27 -08:00
</a>
</td>
</tr>
2023-11-15 14:27:01 -08:00
@endforeach
</tbody>
2023-11-14 09:50:27 -08:00
</table>
</div>
2023-11-14 09:50:27 -08:00
</div>
</div>
<!-- Create Token Modal -->
2023-11-15 18:19:03 -08:00
<div wire:ignore.self class="modal fade" id="modal-create-token" tabindex="-1" role="dialog">
2023-11-15 14:51:09 -08:00
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
<h4 class="modal-title">
Create Token
</h4>
</div>
<div class="modal-body">
<!-- Form Errors -->
2023-11-15 18:29:14 -08:00
@if($errors->has('name'))
<div class="alert alert-danger">
<p><strong>{{ trans('general.whoops') }}</strong> {{ trans('general.something_went_wrong') }}</p>
2023-11-15 14:51:09 -08:00
<br>
<ul>
<li>
@error('name')
<span class="error">
{{ $message }}
</span>
@enderror
2023-11-15 14:51:09 -08:00
</li>
</ul>
</div>
@endif
<!-- Create Token Form -->
<form class="form-horizontal" role="form">
2023-11-15 14:51:09 -08:00
<!-- Name -->
<div class="form-group">
<label class="col-md-4 control-label" for="name">Name</label>
<div class="col-md-6">
2023-11-15 20:35:20 -08:00
<input id="create-token-name" type="text" aria-label="name" class="form-control"
name="name"
2023-11-16 08:54:32 -08:00
wire:keydown.enter="createToken(name)"
2024-05-29 12:10:46 -07:00
wire:model="name"
autofocus
2023-11-15 14:51:09 -08:00
>
</div>
</div>
</form>
2023-12-05 07:44:03 -08:00
2023-11-15 14:51:09 -08:00
</div>
<!-- Modal Actions -->
<div class="modal-footer">
<button type="button" class="btn primary" data-dismiss="modal">{{ trans('general.close') }}</button>
2023-11-15 14:51:09 -08:00
<button type="button" class="btn btn-primary" wire:click="createToken(name)">
{{ trans('general.create') }}
2023-11-15 14:51:09 -08:00
</button>
</div>
</div>
</div>
</div>
2023-11-15 18:19:03 -08:00
2023-11-14 09:50:27 -08:00
<!-- View New Token Modal -->
2023-11-15 18:19:03 -08:00
<div class="modal fade" id="modal-access-token" tabindex="-1" role="dialog">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
2023-11-16 08:54:32 -08:00
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
2023-11-15 18:19:03 -08:00
<h4 class="modal-title">
{{ trans('account/general.personal_access_token') }}
2023-11-15 18:19:03 -08:00
</h4>
</div>
<div class="modal-body">
<p>
{{ trans('account/general.here_is_api_key') }}
2023-11-15 18:19:03 -08:00
</p>
2023-11-16 09:31:00 -08:00
<pre><code>{{ $newTokenString }}</code></pre>
2023-11-15 18:19:03 -08:00
</div>
<!-- Modal Actions -->
<div class="modal-footer">
<button type="button" class="btn btn-default" data-dismiss="modal">{{ trans('general.close') }}</button>
2023-11-15 18:19:03 -08:00
</div>
</div>
</div>
</div>
2023-11-15 20:35:20 -08:00
<script>
2023-11-16 09:31:00 -08:00
window.addEventListener('tokenCreated', token => {
2023-11-15 20:35:20 -08:00
$('#modal-create-token').modal('hide');
$('#modal-access-token').modal('show');
})
window.addEventListener('autoFocusModal', function() {
$('#modal-create-token').on('shown.bs.modal', function() {
$(this).find('[autofocus]').focus();
});
})
// was trying to do a submit on the form when enter was pressed
2023-11-16 08:54:32 -08:00
window.addEventListener("keydown", function (event) {
if (event.key === 'Enter') {
event.preventDefault();
}
})
2023-11-15 20:35:20 -08:00
</script>
2023-11-14 09:50:27 -08:00
</div>