Fixed API key missing translations

Signed-off-by: snipe <snipe@snipe.net>
This commit is contained in:
snipe 2024-07-09 13:17:46 +01:00
parent 595408d21f
commit 5597992d63
4 changed files with 53 additions and 45 deletions

View file

@ -110,7 +110,7 @@ class ProfileController extends Controller
$accessTokenData['id'] = $token->id; $accessTokenData['id'] = $token->id;
$accessTokenData['token'] = $accessToken; $accessTokenData['token'] = $accessToken;
$accessTokenData['name'] = $accessTokenName; $accessTokenData['name'] = $accessTokenName;
return response()->json(Helper::formatStandardApiResponse('success', $accessTokenData, 'Personal access token '.$accessTokenName.' created successfully')); return response()->json(Helper::formatStandardApiResponse('success', $accessTokenData, trans('account/general.personal_api_keys_success', ['key' => $accessTokenName])));
} }
return response()->json(Helper::formatStandardApiResponse('error', null, 'Token could not be created.')); return response()->json(Helper::formatStandardApiResponse('error', null, 'Token could not be created.'));

View file

@ -2,10 +2,14 @@
return array( return array(
'personal_api_keys' => 'Personal API Keys', 'personal_api_keys' => 'Personal API Keys',
'personal_access_token' => 'Personal Access Token',
'personal_api_keys_success' => 'Personal API Key :key created sucessfully',
'here_is_api_key' => 'Here is your new personal access token. This is the only time it will be shown so do not lose it! You may now use this token to make API requests.',
'api_key_warning' => 'When generating an API token, be sure to copy it down immediately as they will not be visible to you again.', 'api_key_warning' => 'When generating an API token, be sure to copy it down immediately as they will not be visible to you again.',
'api_base_url' => 'Your API base url is located at:', 'api_base_url' => 'Your API base url is located at:',
'api_base_url_endpoint' => '/&lt;endpoint&gt;', 'api_base_url_endpoint' => '/&lt;endpoint&gt;',
'api_token_expiration_time' => 'API tokens are set to expire in:', 'api_token_expiration_time' => 'API tokens are set to expire in:',
'api_reference' => 'Please check the <a href="https://snipe-it.readme.io/reference" target="_blank">API reference</a> to find specific API endpoints and additional API documentation.', 'api_reference' => 'Please check the <a href="https://snipe-it.readme.io/reference" target="_blank">API reference</a> to find specific API endpoints and additional API documentation.',
'profile_updated' => 'Account successfully updated', 'profile_updated' => 'Account successfully updated',
'no_tokens' => 'You have not created any personal access tokens.',
); );

View file

@ -552,5 +552,9 @@ return [
], ],
'more_info' => 'More Info', 'more_info' => 'More Info',
'quickscan_bulk_help' => 'Checking this box will edit the asset record to reflect this new location. Leaving it unchecked will simply note the location in the audit log. Note that if this asset is checked out, it will not change the location of the person, asset or location it is checked out to.', 'quickscan_bulk_help' => 'Checking this box will edit the asset record to reflect this new location. Leaving it unchecked will simply note the location in the audit log. Note that if this asset is checked out, it will not change the location of the person, asset or location it is checked out to.',
'whoops' => 'Whoops!',
'something_went_wrong' => 'Something went wrong with your request.',
'close' => 'Close',
'expires' => 'Expires',
]; ];

View file

@ -1,62 +1,65 @@
<div> <div>
<div class="panel panel-default"> <div class="box box-default">
<div class="panel-heading"> <div class="box-header with-border">
<div class="text-right" style="display: flex; justify-content: space-between; align-items: center;"> <div class="text-right">
<a class="btn btn-info btn-sm action-link pull-right" <a class="btn btn-info btn-sm pull-right"
onclick="$('#modal-create-token').modal('show');" onclick="$('#modal-create-token').modal('show');"
wire:click="$dispatch('openModal')" wire:click="$dispatch('openModal')">
> {{ trans('general.create') }}
Create New Token
</a> </a>
</div> </div>
</div> </div>
<div class="panel-body"> <div class="box-body">
<!-- No Tokens Notice --> <!-- No Tokens Notice -->
@if($tokens->count() === 0) @if($tokens->count() === 0)
<p class="m-b-none" <p>
> {{ trans('account/general.no_tokens') }}
You have not created any personal access tokens.
</p> </p>
@endif @endif
<!-- Personal Access Tokens --> <!-- Personal Access Tokens -->
<table class="table table-borderless m-b-none"> <div class="table table-responsive">
<table class="table table-striped snipe-table">
@if($tokens->count() > 0) @if($tokens->count() > 0)
<thead> <thead>
<tr> <tr>
<th class="col-md-3">Name</th> <th class="col-md-3">{{ trans('general.name') }}</th>
<th class="col-md-2">Created</th> <th class="col-md-2">{{ trans('general.created_at') }}</th>
<th class="col-md-2">Expires</th> <th class="col-md-2">{{ trans('general.expires') }}</th>
<th class="col-md-2"><span class="sr-only">Delete</span></th> <th class="col-md-2"><span class="sr-only">{{ trans('general.delete') }}</span></th>
</tr> </tr>
</thead> </thead>
<tbody>
@endif @endif
@foreach($tokens as $token) @foreach($tokens as $token)
<tbody>
<tr> <tr>
<!-- Client Name --> <td>
<td style="vertical-align: middle;">
{{ $token->name }} {{ $token->name }}
</td> </td>
<td style="vertical-align: middle;"> <td>
{{ $token->created_at }} {{ $token->created_at }}
</td> </td>
<td style="vertical-align: middle;"> <td>
{{ $token->expires_at }} {{ $token->expires_at }}
</td> </td>
<!-- Delete Button --> <td class="text-right">
<td style="vertical-align: middle;" class="text-right">
<a class="action-link btn btn-danger btn-sm" wire:click="deleteToken('{{ $token->id }}')" <a class="action-link btn btn-danger btn-sm" wire:click="deleteToken('{{ $token->id }}')"
wire:loading.attr="disabled"> wire:loading.attr="disabled" data-tooltip="true" title="{{ trans('general.delete') }}">
<i class="fas fa-trash"></i> <i class="fas fa-trash" aria-hidden="true"></i>
<span class="sr-only">
{{ trans('general.delete') }}
</span>
</a> </a>
</td> </td>
</tr> </tr>
</tbody>
@endforeach @endforeach
</tbody>
</table> </table>
</div>
</div> </div>
</div> </div>
<!-- Create Token Modal --> <!-- Create Token Modal -->
@ -74,22 +77,23 @@
<div class="modal-body"> <div class="modal-body">
<!-- Form Errors --> <!-- Form Errors -->
@if($errors->has('name')) @if($errors->has('name'))
<div class="alert alert-danger" <div class="alert alert-danger">
> <p><strong>{{ trans('general.whoops') }}</strong> {{ trans('general.something_went_wrong') }}</p>
<p><strong>Whoops!</strong> Something went wrong!</p>
<br> <br>
<ul> <ul>
<li <li>
> @error('name')
@error('name') <span class="error">{{ $message }}</span> @enderror <span class="error">
{{ $message }}
</span>
@enderror
</li> </li>
</ul> </ul>
</div> </div>
@endif @endif
<!-- Create Token Form --> <!-- Create Token Form -->
<form class="form-horizontal" role="form" <form class="form-horizontal" role="form">
>
<!-- Name --> <!-- Name -->
<div class="form-group"> <div class="form-group">
<label class="col-md-4 control-label" for="name">Name</label> <label class="col-md-4 control-label" for="name">Name</label>
@ -98,7 +102,6 @@
<input id="create-token-name" type="text" aria-label="name" class="form-control" <input id="create-token-name" type="text" aria-label="name" class="form-control"
name="name" name="name"
wire:keydown.enter="createToken(name)" wire:keydown.enter="createToken(name)"
{{-- defer because it's submitting as i type if i don't --}}
wire:model="name" wire:model="name"
autofocus autofocus
> >
@ -110,12 +113,10 @@
<!-- Modal Actions --> <!-- Modal Actions -->
<div class="modal-footer"> <div class="modal-footer">
<button type="button" class="btn primary" data-dismiss="modal">Close</button> <button type="button" class="btn primary" data-dismiss="modal">{{ trans('general.close') }}</button>
<button type="button" class="btn btn-primary" <button type="button" class="btn btn-primary" wire:click="createToken(name)">
wire:click="createToken(name)" {{ trans('general.create') }}
>
Create
</button> </button>
</div> </div>
</div> </div>
@ -130,14 +131,13 @@
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button> <button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
<h4 class="modal-title"> <h4 class="modal-title">
Personal Access Token {{ trans('account/general.personal_access_token') }}
</h4> </h4>
</div> </div>
<div class="modal-body"> <div class="modal-body">
<p> <p>
Here is your new personal access token. This is the only time it will be shown so don't lose it! {{ trans('account/general.here_is_api_key') }}
You may now use this token to make API requests.
</p> </p>
<pre><code>{{ $newTokenString }}</code></pre> <pre><code>{{ $newTokenString }}</code></pre>
@ -145,7 +145,7 @@
<!-- Modal Actions --> <!-- Modal Actions -->
<div class="modal-footer"> <div class="modal-footer">
<button type="button" class="btn btn-default" data-dismiss="modal">Close</button> <button type="button" class="btn btn-default" data-dismiss="modal">{{ trans('general.close') }}</button>
</div> </div>
</div> </div>
</div> </div>