snipe-it/resources/views/livewire/oauth-clients.blade.php

403 lines
18 KiB
PHP
Raw Normal View History

<div>
<div class="box box-default">
<div class="box-header">
<h2 class="box-title">
{{ trans('admin/settings/general.oauth_clients') }}
</h2>
@if ($authorizationError)
2023-12-05 18:36:59 -08:00
<div class="alert alert-danger">
<p>{{ trans('admin/users/message.insufficient_permissions') }}
2023-12-05 18:36:59 -08:00
<br>
{{ $authorizationError }}
</p>
2023-12-05 18:36:59 -08:00
</div>
@endif
<div class="box-tools pull-right">
<a class="btn btn-primary"
wire:click="$dispatch('openModal')"
onclick="$('#modal-create-client').modal('show');">
{{ trans('general.create') }}
</a>
</div>
2023-12-05 12:52:14 -08:00
</div>
<div class="box-body">
<!-- Current Clients -->
@if($clients->count() === 0)
<p>
{{ trans('admin/settings/general.oauth_no_clients') }}
</p>
@endif
@if ($clients->count() > 0)
<table data-cookie-id-table="OAuthClientsTable"
data-pagination="true"
data-id-table="OAuthClientsTable"
data-side-pagination="client"
data-sort-order="desc"
data-sort-name="created_at"
id="OAuthClientsTable"
class="table table-striped snipe-table">
<thead>
2023-12-05 12:52:14 -08:00
<tr>
<th>{{ trans('general.id') }}</th>
<th data-sortable="true">{{ trans('general.name') }}</th>
<th data-sortable="true">{{ trans('admin/settings/general.oauth_redirect_url') }}</th>
<th data-sortable="true">{{ trans('admin/settings/general.oauth_secret') }}</th>
<th data-sortable="true">{{ trans('general.created_at') }}</th>
<th data-sortable="true">{{ trans('general.updated_at') }}</th>
<th data-sortable="true"><span class="sr-only">{{ trans('general.actions') }}</span></th>
2023-12-05 12:52:14 -08:00
</tr>
</thead>
<tbody>
2023-12-05 12:52:14 -08:00
@foreach($clients as $client)
<tr>
2023-12-05 12:52:14 -08:00
<!-- ID -->
<td>
2023-12-05 12:52:14 -08:00
{{ $client->id }}
</td>
<!-- Name -->
<td>
2023-12-05 12:52:14 -08:00
{{ $client->name }}
</td>
<!-- Redirect -->
<td>
<code>{{ $client->redirect }}</code>
</td>
2023-12-05 12:52:14 -08:00
<!-- Secret -->
<td>
2023-12-05 12:52:14 -08:00
<code>{{ $client->secret }}</code>
</td>
<td>
{{ $client->created_at ? Helper::getFormattedDateObject($client->created_at, 'datetime', false) : '' }}
</td>
<td>
@if ($client->created_at != $client->updated_at)
{{ $client->updated_at ? Helper::getFormattedDateObject($client->updated_at, 'datetime', false) : '' }}
@endif
</td>
<!-- Edit / Delete Button -->
<td class="text-right">
<a class="action-link btn btn-sm btn-warning"
wire:click="editClient('{{ $client->id }}')"
onclick="$('#modal-edit-client').modal('show');">
<i class="fas fa-pencil-alt" aria-hidden="true"></i><span class="sr-only">{{ trans('general.update') }}</span>
2023-12-05 12:52:14 -08:00
</a>
<a class="action-link btn btn-danger btn-sm" wire:click="deleteClient('{{ $client->id }}')">
<i class="fas fa-trash" aria-hidden="true"></i>
<span class="sr-only">
{{ trans('general.delete') }}
</span>
2023-12-05 12:52:14 -08:00
</a>
</td>
</tr>
@endforeach
</tbody>
</table>
@endif
2023-12-05 12:52:14 -08:00
</div>
</div>
2023-12-06 14:20:30 -08:00
<div>
@if ($authorized_tokens->count() > 0)
<div>
<div class="box box-default">
<div class="box-header">
<h2 class="box-title">
{{ trans('admin/settings/general.oauth_authorized_apps') }}
</h2>
</div>
2023-12-06 14:20:30 -08:00
<div class="box-body">
2023-12-06 14:20:30 -08:00
<!-- Authorized Tokens -->
<table data-cookie-id-table="AuthorizedAppsTale"
data-pagination="true"
data-id-table="AuthorizedAppsTale"
data-toolbar="#AuthorizedAppsToolbar"
data-side-pagination="client"
data-sort-order="desc"
data-sort-name="created_at"
id="AuthorizedAppsTale"
class="table table-striped snipe-table">
2023-12-06 14:20:30 -08:00
<thead>
<tr>
<th data-sortable="true">{{ trans('general.name') }}</th>
<th data-sortable="true"> {{ trans('account/general.personal_access_token') }}</th>
<th data-sortable="true">{{ trans('admin/settings/general.oauth_scopes') }}</th>
<th data-sortable="true">{{ trans('general.created_at') }}</th>
<th data-sortable="true">{{ trans('account/general.expires') }}</th>
<th></th>
2023-12-06 14:20:30 -08:00
</tr>
</thead>
<tbody>
@foreach($authorized_tokens as $token)
<tr>
<!-- Client Name -->
<td>
2023-12-06 14:20:30 -08:00
{{ $token->client->name }}
</td>
<td>
{{ $token->name }}
</td>
2023-12-06 14:20:30 -08:00
<!-- Scopes -->
<td>
2023-12-06 14:20:30 -08:00
@if(!$token->scopes)
<span class="label label-default">
{{ trans('admin/settings/general.no_scopes') }}
</span>
2023-12-06 14:20:30 -08:00
@endif
</td>
<td>
{{ $token->created_at ? Helper::getFormattedDateObject($token->created_at, 'datetime', false) : '' }}
</td>
<td>
{{ $token->expires_at ? Helper::getFormattedDateObject($token->expires_at, 'datetime', false) : '' }}
</td>
2023-12-06 14:20:30 -08:00
<!-- Revoke Button -->
<td>
<a class="btn btn-sm btn-danger pull-right"
2023-12-06 14:20:30 -08:00
wire:click="deleteToken('{{ $token->id }}')"
>
<i class="fas fa-trash" aria-hidden="true"></i>
<span class="sr-only">
{{ trans('general.delete') }}
</span>
2023-12-06 14:20:30 -08:00
</a>
</td>
</tr>
@endforeach
</tbody>
</table>
</div>
</div>
</div>
@endif
2023-12-05 12:52:14 -08:00
<!-- Create Client Modal -->
<div class="modal fade" id="modal-create-client" tabindex="-1" role="dialog" wire:ignore.self>
<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>
2023-12-05 12:52:14 -08:00
<h2 class="modal-title">
{{ trans('admin/settings/general.create_client') }}
</h2>
</div>
2023-12-05 12:52:14 -08:00
<div class="modal-body">
<!-- Form Errors -->
@if($errors->has('name') || $errors->has('redirect'))
<div class="alert alert-danger">
<p><strong>Whoops!</strong> Something went wrong!</p>
<br>
<ul>
@if($errors->has('name'))
<li>{{ $errors->first('name') }}</li>
@endif
@if($errors->has('redirect'))
<li>{{ $errors->first('redirect') }}</li>
@endif
</ul>
</div>
@endif
2023-12-05 12:52:14 -08:00
<!-- Create Client Form -->
<form class="form-horizontal" role="form">
<!-- Name -->
<div class="form-group">
<label class="col-md-3 control-label" for="create-client-name">
{{ trans('general.name') }}
</label>
2023-12-05 12:52:14 -08:00
<div class="col-md-7">
<input id="create-client-name"
type="text"
aria-label="create-client-name"
class="form-control"
2024-06-17 13:03:27 -07:00
wire:model="name"
2023-12-12 11:28:04 -08:00
wire:keydown.enter="createClient"
autofocus>
2023-12-05 12:52:14 -08:00
<span class="help-block">
{{ trans('admin/settings/general.oauth_name_help') }}
</span>
2023-12-05 12:52:14 -08:00
</div>
</div>
2023-12-05 12:52:14 -08:00
<!-- Redirect URL -->
<div class="form-group">
<label class="col-md-3 control-label" for="redirect">{{ trans('admin/settings/general.oauth_redirect_url') }}</label>
2023-12-05 12:52:14 -08:00
<div class="col-md-7">
<input type="text"
class="form-control"
aria-label="redirect"
name="redirect"
2024-06-17 13:03:27 -07:00
wire:model="redirect"
2023-12-12 11:28:04 -08:00
wire:keydown.enter="createClient"
>
2023-12-05 12:52:14 -08:00
<span class="help-block">
{{ trans('admin/settings/general.oauth_callback_url') }}
</span>
2023-12-05 12:52:14 -08:00
</div>
</div>
</form>
</div>
2023-12-05 12:52:14 -08:00
<!-- Modal Actions -->
<div class="modal-footer">
<button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
<button type="button"
class="btn btn-primary"
wire:click="createClient"
>
Create
</button>
2023-12-05 12:52:14 -08:00
</div>
</div>
</div>
</div>
</div>
2023-12-05 12:52:14 -08:00
<!-- Edit Client Modal -->
<div class="modal fade" id="modal-edit-client" tabindex="-1" role="dialog" wire:ignore.self>
<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">
{{ trans('general.update') }}
</h4>
</div>
2023-12-05 12:52:14 -08:00
<div class="modal-body">
@if($errors->has('newName') || $errors->has('newRedirect'))
<div class="alert alert-danger">
<p><strong>Whoops!</strong> Something went wrong!</p>
<br>
<ul>
@if($errors->has('newName'))
<li>{{ $errors->first('newName') }}</li>
@endif
@if($errors->has('newRedirect'))
<li>{{ $errors->first('newRedirect') }}</li>
@endif
2023-12-05 18:36:59 -08:00
@if($authorizationError)
2023-12-05 18:22:20 -08:00
<li>{{ $authorizationError }}</li>
@endif
</ul>
</div>
@endif
2023-12-05 12:52:14 -08:00
<!-- Edit Client Form -->
<form class="form-horizontal">
<!-- Name -->
<div class="form-group">
<label class="col-md-3 control-label" for="edit-client-name">Name</label>
2023-12-05 12:52:14 -08:00
<div class="col-md-7">
<input
id="edit-client-name"
type="text"
aria-label="edit-client-name"
class="form-control"
2024-05-29 12:08:25 -07:00
wire:model.live="editName"
2023-12-12 11:33:51 -08:00
wire:keydown.enter="updateClient('{{ $editClientId }}')"
>
2023-12-05 12:52:14 -08:00
<span class="help-block">
{{ trans('admin/settings/general.oauth_name_help') }}
</span>
2023-12-05 12:52:14 -08:00
</div>
</div>
2023-12-05 12:52:14 -08:00
<!-- Redirect URL -->
<div class="form-group">
<label class="col-md-3 control-label" for="redirect">{{ trans('admin/settings/general.oauth_redirect_url') }}</label>
2023-12-05 12:52:14 -08:00
<div class="col-md-7">
<input
type="text"
class="form-control"
name="redirect"
aria-label="redirect"
2024-06-17 13:03:27 -07:00
wire:model="editRedirect"
2023-12-12 11:33:51 -08:00
wire:keydown.enter="updateClient('{{ $editClientId }}')"
>
2023-12-05 12:52:14 -08:00
<span class="help-block">
{{ trans('admin/settings/general.oauth_callback_url') }}
</span>
2023-12-05 12:52:14 -08:00
</div>
</div>
</form>
</div>
2023-12-05 12:52:14 -08:00
<!-- Modal Actions -->
<div class="modal-footer">
<button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
2023-12-05 12:52:14 -08:00
2023-12-05 18:22:20 -08:00
<button
class="btn btn-primary"
wire:click="updateClient('{{ $editClientId }}')"
>
Update Client
</button>
2023-12-05 12:52:14 -08:00
</div>
</div>
</div>
</div>
<script>
2023-12-05 18:22:20 -08:00
document.addEventListener('DOMContentLoaded', function() {
2024-06-04 15:37:41 -07:00
Livewire.on('openModal', () => {
2023-12-12 11:28:04 -08:00
$('#modal-create-client').modal('show').on('shown.bs.modal', function() {
$(this).find('[autofocus]').focus();
});
});
});
2023-12-05 18:22:20 -08:00
window.addEventListener('clientCreated', function() {
$('#modal-create-client').modal('hide');
});
2023-12-05 18:22:20 -08:00
window.addEventListener('editClient', function() {
$('#modal-edit-client').modal('show');
});
2023-12-05 18:22:20 -08:00
window.addEventListener('clientUpdated', function() {
$('#modal-edit-client').modal('hide');
});
</script>
2024-06-04 15:37:41 -07:00
</div>
@section('moar_scripts')
@include ('partials.bootstrap-table')
@endsection