mirror of
https://github.com/snipe/snipe-it.git
synced 2025-01-12 14:27:33 -08:00
Added nicer formatting for fields in log meta
Signed-off-by: snipe <snipe@snipe.net>
This commit is contained in:
parent
9d887484c8
commit
ff72c4fbaa
|
@ -3,6 +3,7 @@ namespace App\Http\Transformers;
|
||||||
|
|
||||||
use App\Helpers\Helper;
|
use App\Helpers\Helper;
|
||||||
use App\Models\Actionlog;
|
use App\Models\Actionlog;
|
||||||
|
use App\Models\Asset;
|
||||||
use App\Models\CustomField;
|
use App\Models\CustomField;
|
||||||
use App\Models\Setting;
|
use App\Models\Setting;
|
||||||
use App\Models\Company;
|
use App\Models\Company;
|
||||||
|
@ -12,6 +13,7 @@ use App\Models\AssetModel;
|
||||||
use Illuminate\Database\Eloquent\Collection;
|
use Illuminate\Database\Eloquent\Collection;
|
||||||
use Illuminate\Contracts\Encryption\DecryptException;
|
use Illuminate\Contracts\Encryption\DecryptException;
|
||||||
use Illuminate\Support\Facades\Crypt;
|
use Illuminate\Support\Facades\Crypt;
|
||||||
|
use Illuminate\Support\Facades\Gate;
|
||||||
|
|
||||||
class ActionlogsTransformer
|
class ActionlogsTransformer
|
||||||
{
|
{
|
||||||
|
@ -98,6 +100,12 @@ class ActionlogsTransformer
|
||||||
\Log::debug('custom fields do not match');
|
\Log::debug('custom fields do not match');
|
||||||
$clean_meta[$fieldname]['old'] = "************";
|
$clean_meta[$fieldname]['old'] = "************";
|
||||||
$clean_meta[$fieldname]['new'] = "************";
|
$clean_meta[$fieldname]['new'] = "************";
|
||||||
|
|
||||||
|
if (Gate::allows('admin')) {
|
||||||
|
$clean_meta[$fieldname]['old'] = unserialize($enc_old);
|
||||||
|
$clean_meta[$fieldname]['new'] = unserialize($enc_new);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -530,15 +530,42 @@
|
||||||
|
|
||||||
|
|
||||||
function changeLogFormatter(value) {
|
function changeLogFormatter(value) {
|
||||||
|
|
||||||
|
console.dir(value);
|
||||||
var result = '';
|
var result = '';
|
||||||
|
var pretty_index = '';
|
||||||
|
|
||||||
|
console.error('first the formatter');
|
||||||
|
|
||||||
for (var index in value) {
|
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;
|
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 list
|
// Create a linked phone number in the table list
|
||||||
function phoneFormatter(value) {
|
function phoneFormatter(value) {
|
||||||
|
|
Loading…
Reference in a new issue