|
| 1 | +@extends('layouts.admin') |
| 2 | + |
| 3 | +@section('title') |
| 4 | + API Management |
| 5 | +@endsection |
| 6 | + |
| 7 | +@section('content') |
| 8 | +<div class="col-md-12"> |
| 9 | + <ul class="breadcrumb"> |
| 10 | + <li><a href="/admin">Admin Control</a></li> |
| 11 | + <li class="active">API Management</li> |
| 12 | + </ul> |
| 13 | + <h3>API Key Information</h3><hr /> |
| 14 | + <table class="table table-bordered table-hover"> |
| 15 | + <thead> |
| 16 | + <tr> |
| 17 | + <th>API Public Key</th> |
| 18 | + <th>Allowed IPs</th> |
| 19 | + <th>Permissions</th> |
| 20 | + <th class="text-center">Created</th> |
| 21 | + <th class="text-center"></th> |
| 22 | + </tr> |
| 23 | + </thead> |
| 24 | + <tbody> |
| 25 | + @foreach ($keys as $key) |
| 26 | + <tr> |
| 27 | + <td><code>{{ $key->public }}</code></td> |
| 28 | + <td> |
| 29 | + @if (is_null($key->allowed_ips)) |
| 30 | + <code>*</code> |
| 31 | + @else |
| 32 | + @foreach(json_decode($key->allowed_ips) as $ip) |
| 33 | + <code style="line-height:2;">{{ $ip }}</code><br /> |
| 34 | + @endforeach |
| 35 | + @endif |
| 36 | + </td> |
| 37 | + <td> |
| 38 | + @foreach(json_decode($key->permissions) as &$perm) |
| 39 | + <code style="line-height:2;">{{ $perm->permission }}</code><br /> |
| 40 | + @endforeach |
| 41 | + </td> |
| 42 | + <td class="text-center">{{ $key->created_at }}</td> |
| 43 | + <td class="text-center"><a href="#delete" class="text-danger" data-action="delete" data-attr="{{ $key->public }}"><i class="fa fa-trash"></i></a></td> |
| 44 | + </tr> |
| 45 | + @endforeach |
| 46 | + </tbody> |
| 47 | + </table> |
| 48 | + <div class="well"> |
| 49 | + <a href="{{ route('admin.api.new') }}"><button class="btn btn-success btn-sm">Create New API Key</button></a> |
| 50 | + </div> |
| 51 | +</div> |
| 52 | +<script> |
| 53 | +$(document).ready(function () { |
| 54 | + $('#sidebar_links').find("a[href='/admin/api']").addClass('active'); |
| 55 | + $('[data-action="delete"]').click(function (event) { |
| 56 | + var self = $(this); |
| 57 | + event.preventDefault(); |
| 58 | + swal({ |
| 59 | + type: 'error', |
| 60 | + title: 'Revoke API Key', |
| 61 | + text: 'Once this API key is revoked any applications currently using it will stop working.', |
| 62 | + showCancelButton: true, |
| 63 | + allowOutsideClick: true, |
| 64 | + confirmButtonText: 'Revoke', |
| 65 | + confirmButtonColor: '#d9534f', |
| 66 | + }, function () { |
| 67 | + $.ajax({ |
| 68 | + method: 'DELETE', |
| 69 | + url: '{{ route('admin.api.revoke') }}/' + self.data('attr'), |
| 70 | + headers: { |
| 71 | + 'X-CSRF-TOKEN': '{{ csrf_token() }}' |
| 72 | + } |
| 73 | + }).done(function (data) { |
| 74 | + swal({ |
| 75 | + type: 'success', |
| 76 | + }); |
| 77 | + self.parent().parent().slideUp(); |
| 78 | + }).fail(function (jqXHR) { |
| 79 | + console.error(jqXHR); |
| 80 | + swal({ |
| 81 | + type: 'error', |
| 82 | + title: 'Whoops!', |
| 83 | + text: 'An error occured while attempting to revoke this key.' |
| 84 | + }); |
| 85 | + }); |
| 86 | + }); |
| 87 | + }); |
| 88 | +}); |
| 89 | +</script> |
| 90 | +@endsection |
0 commit comments