mirror of
https://github.com/snipe/snipe-it.git
synced 2024-11-09 23:24:06 -08:00
Merge pull request #15244 from snipe/features/play_sound_on_audit
Fixes #10560 - optional ability to play sound on audit
This commit is contained in:
commit
900beaa955
|
@ -49,6 +49,7 @@ class ProfileController extends Controller
|
|||
$user->gravatar = $request->input('gravatar');
|
||||
$user->skin = $request->input('skin');
|
||||
$user->phone = $request->input('phone');
|
||||
$user->enable_sounds = $request->input('enable_sounds', false);
|
||||
|
||||
if (! config('app.lock_passwords')) {
|
||||
$user->locale = $request->input('locale', 'en-US');
|
||||
|
|
|
@ -0,0 +1,28 @@
|
|||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
return new class extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*/
|
||||
public function up(): void
|
||||
{
|
||||
Schema::table('users', function (Blueprint $table) {
|
||||
$table->boolean('enable_sounds')->default(false);
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*/
|
||||
public function down(): void
|
||||
{
|
||||
Schema::table('users', function (Blueprint $table) {
|
||||
$table->dropColumn('enable_sounds');
|
||||
});
|
||||
}
|
||||
};
|
BIN
public/sounds/error.mp3
Normal file
BIN
public/sounds/error.mp3
Normal file
Binary file not shown.
BIN
public/sounds/success.mp3
Normal file
BIN
public/sounds/success.mp3
Normal file
Binary file not shown.
|
@ -12,4 +12,5 @@ return array(
|
|||
'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',
|
||||
'no_tokens' => 'You have not created any personal access tokens.',
|
||||
'enable_sounds' => 'Enable sound effects',
|
||||
);
|
||||
|
|
|
@ -89,6 +89,15 @@
|
|||
</div>
|
||||
</div>
|
||||
|
||||
<div class="form-group{{ $errors->has('enable_sounds') ? ' has-error' : '' }}">
|
||||
<div class="col-md-9 col-md-offset-3">
|
||||
<label for="enable_sounds" class="form-control">
|
||||
<input type="checkbox" name="enable_sounds" value="1" {{ old('enable_sounds', $user->enable_sounds) ? 'checked' : '' }}>
|
||||
{{ trans('account/general.enable_sounds') }}
|
||||
</label>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Gravatar Email -->
|
||||
<div class="form-group {{ $errors->has('gravatar') ? ' has-error' : '' }}">
|
||||
<label for="gravatar" class="col-md-3 control-label">{{ trans('general.gravatar_email') }}
|
||||
|
@ -152,6 +161,7 @@
|
|||
@endif
|
||||
|
||||
|
||||
|
||||
</div> <!-- .box-body -->
|
||||
<div class="text-right box-footer">
|
||||
<a class="btn btn-link" href="{{ URL::previous() }}">{{ trans('button.cancel') }}</a>
|
||||
|
|
|
@ -153,7 +153,13 @@
|
|||
data : formData,
|
||||
success : function (data) {
|
||||
if (data.status == 'success') {
|
||||
$('#audited tbody').prepend("<tr class='success'><td>" + data.payload.asset_tag + "</td><td>" + data.messages + "</td><td><i class='fas fa-check text-success'></i></td></tr>");
|
||||
$('#audited tbody').prepend("<tr class='success'><td>" + data.payload.asset_tag + "</td><td>" + data.messages + "</td><td><i class='fas fa-check text-success' style='font-size:18px;'></i></td></tr>");
|
||||
|
||||
@if ($user->enable_sounds)
|
||||
var audio = new Audio('/sounds/success.mp3');
|
||||
audio.play()
|
||||
@endif
|
||||
|
||||
incrementOnSuccess();
|
||||
} else {
|
||||
handleAuditFail(data);
|
||||
|
@ -173,6 +179,10 @@
|
|||
});
|
||||
|
||||
function handleAuditFail (data) {
|
||||
@if ($user->enable_sounds)
|
||||
var audio = new Audio('/sounds/error.mp3');
|
||||
audio.play()
|
||||
@endif
|
||||
if (data.asset_tag) {
|
||||
var asset_tag = data.asset_tag;
|
||||
} else {
|
||||
|
@ -183,7 +193,7 @@
|
|||
} else {
|
||||
var messages = '';
|
||||
}
|
||||
$('#audited tbody').prepend("<tr class='danger'><td>" + data.payload.asset_tag + "</td><td>" + messages + "</td><td><i class='fas fa-times text-danger'></i></td></tr>");
|
||||
$('#audited tbody').prepend("<tr class='danger'><td>" + data.payload.asset_tag + "</td><td>" + messages + "</td><td><i class='fas fa-times text-danger' style='font-size:18px;'></i></td></tr>");
|
||||
}
|
||||
|
||||
function incrementOnSuccess() {
|
||||
|
|
Loading…
Reference in a new issue