A free open source IT asset/license management system
Added nicer formatting for fields in log meta
snipeff72c4fbaa51
diff --git a/app/Http/Transformers/ActionlogsTransformer.php b/app/Http/Transformers/ActionlogsTransformer.phpindex d3af3bb753..61ae1af9a2 100644--- a/app/Http/Transformers/ActionlogsTransformer.php+++ b/app/Http/Transformers/ActionlogsTransformer.php@@ -3,6 +3,7 @@ namespace App\Http\Transformers;use App\Helpers\Helper;use App\Models\Actionlog;+use App\Models\Asset;use App\Models\CustomField;use App\Models\Setting;use App\Models\Company;@@ -12,6 +13,7 @@ use App\Models\AssetModel;use Illuminate\Database\Eloquent\Collection;use Illuminate\Contracts\Encryption\DecryptException;use Illuminate\Support\Facades\Crypt;+use Illuminate\Support\Facades\Gate;class ActionlogsTransformer{@@ -98,6 +100,12 @@ class ActionlogsTransformer\Log::debug('custom fields do not match');$clean_meta[$fieldname]['old'] = "************";$clean_meta[$fieldname]['new'] = "************";++ if (Gate::allows('admin')) {+ $clean_meta[$fieldname]['old'] = unserialize($enc_old);+ $clean_meta[$fieldname]['new'] = unserialize($enc_new);+ }+}diff --git a/resources/views/partials/bootstrap-table.blade.php b/resources/views/partials/bootstrap-table.blade.phpindex 78f3d152d2..a7c2084adb 100644--- a/resources/views/partials/bootstrap-table.blade.php+++ b/resources/views/partials/bootstrap-table.blade.php@@ -530,15 +530,42 @@function changeLogFormatter(value) {++ console.dir(value);var result = '';+ var pretty_index = '';++ console.error('first the formatter');+for (var index in value) {- result += index + ': <del>' + value[index].old + '</del> <i class="fas fa-long-arrow-alt-right" aria-hidden="true"></i> ' + value[index].new + '<br>'+++ // Check if it's a custom field+ if (index.startsWith('_snipeit_')) {+ console.error('It is a custom field');+ pretty_index = index.replace("_snipeit_", "Custom:_");+ } else {+ console.error('Not a custom field');+ pretty_index = index;+ }++ extra_pretty_index = prettyLog(pretty_index);++ result += extra_pretty_index + ': <del>' + value[index].old + '</del> <i class="fas fa-long-arrow-alt-right" aria-hidden="true"></i> ' + value[index].new + '<br>'}return result;}+ function prettyLog(str) {+ let frags = str.split('_');+ for (let i = 0; i < frags.length; i++) {+ frags[i] = frags[i].charAt(0).toUpperCase() + frags[i].slice(1);+ }+ return frags.join(' ');+ }+// Create a linked phone number in the table listfunction phoneFormatter(value) {