Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixes #10560 - optional ability to play sound on audit #15244

Merged
merged 4 commits into from
Aug 7, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions app/Http/Controllers/ProfileController.php
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ public function postIndex(ImageUploadRequest $request) : RedirectResponse
$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');
Expand Down
Original file line number Diff line number Diff line change
@@ -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');
});
}
};
Binary file added public/sounds/error.mp3
Binary file not shown.
Binary file added public/sounds/success.mp3
Binary file not shown.
1 change: 1 addition & 0 deletions resources/lang/en-US/account/general.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,5 @@
'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',
);
10 changes: 10 additions & 0 deletions resources/views/account/profile.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -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') }}
Expand Down Expand Up @@ -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>
Expand Down
14 changes: 12 additions & 2 deletions resources/views/hardware/quickscan.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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 {
Expand All @@ -183,7 +193,7 @@ function handleAuditFail (data) {
} 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() {
Expand Down
Loading