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

261 lines
10 KiB
PHP
Raw Normal View History

<div>
<div class="panel panel-default">
<div class="panel-heading">
<div style="display: flex; justify-content: space-between; align-items: center;">
<h2>
(Livewire) OAuth Clients
</h2>
<a class="button button-small"
wire:click="$emit('openModal')"
>
Create New Client
</a>
2023-12-05 12:52:14 -08:00
</div>
</div>
2023-12-05 12:52:14 -08:00
<div class="panel-body">
<!-- Current Clients -->
@if($clients->count() === 0)
<p class="m-b-none">
You have not created any OAuth clients.
</p>
@endif
@if($clients->count() > 0)
<table class="table table-borderless m-b-none">
<thead>
2023-12-05 12:52:14 -08:00
<tr>
<th>Client ID</th>
<th>Name</th>
<th>Secret</th>
<th><span class="sr-only">Edit</span></th>
<th><span class="sr-only">Delete</span></th>
</tr>
</thead>
2023-12-05 12:52:14 -08:00
<tbody>
2023-12-05 12:52:14 -08:00
@foreach($clients as $client)
<tr>
2023-12-05 12:52:14 -08:00
<!-- ID -->
<td style="vertical-align: middle;">
{{ $client->id }}
</td>
<!-- Name -->
<td style="vertical-align: middle;">
{{ $client->name }}
</td>
<!-- Secret -->
<td style="vertical-align: middle;">
<code>{{ $client->secret }}</code>
</td>
<!-- Edit Button -->
<td style="vertical-align: middle;">
<a class="action-link"
wire:click="editClient('{{ $client->id }}')"
2023-12-05 12:52:14 -08:00
>
Edit
</a>
</td>
<!-- Delete Button -->
<td style="vertical-align: middle;" class="text-right">
<a class="action-link btn btn-danger btn-sm" wire:click="deleteClient('{{ $client->id }}')">
<i class="fas fa-trash"></i>
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-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">
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">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"
wire:model="name"
>
2023-12-05 12:52:14 -08:00
<span class="help-block">
Something your users will recognize and trust.
</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">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"
wire:model="redirect"
>
2023-12-05 12:52:14 -08:00
<span class="help-block">
Your application's authorization 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>
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>
2023-12-05 12:52:14 -08:00
<h4 class="modal-title">
Edit Client
</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
</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"
wire:model="editName"
>
2023-12-05 12:52:14 -08:00
<span class="help-block">
Something your users will recognize and trust.
</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">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"
wire:model="editRedirect"
>
2023-12-05 12:52:14 -08:00
<span class="help-block">
Your application's authorization 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
<button type="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>
document.addEventListener('DOMContentLoaded', function () {
window.livewire.on('openModal', () => {
$('#modal-create-client').modal('show');
});
});
window.addEventListener('clientCreated', event => {
$('#modal-create-client').modal('hide');
});
window.addEventListener('editClient', event => {
$('#modal-edit-client').modal('show');
});
</script>
</div>