From 9359809b4fd2f186180083b32b2893c8cd4ab924 Mon Sep 17 00:00:00 2001 From: MrM <11910225+mauro-miatello@users.noreply.github.com> Date: Sun, 10 Mar 2024 15:09:46 +0100 Subject: [PATCH 1/2] Hide / Show encrypted values in web ui added a span element to hide encrypted values --- resources/views/hardware/view.blade.php | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/resources/views/hardware/view.blade.php b/resources/views/hardware/view.blade.php index 72a2603948..a32503d7ea 100755 --- a/resources/views/hardware/view.blade.php +++ b/resources/views/hardware/view.blade.php @@ -410,12 +410,13 @@
@if (($field->field_encrypted=='1') && ($asset->{$field->db_column_name()}!='')) - + @endif @if ($field->isFieldDecryptable($asset->{$field->db_column_name()} )) @can('assets.view.encrypted_custom_fields') - + ******** + @if (($field->format=='URL') && ($asset->{$field->db_column_name()}!='')) {{ Helper::gracefulDecrypt($field, $asset->{$field->db_column_name()}) }} @elseif (($field->format=='DATE') && ($asset->{$field->db_column_name()}!='')) @@ -427,7 +428,7 @@ - @else + @else {{ strtoupper(trans('admin/custom_fields/general.encrypted')) }} @endcan From 8abd359b5b5ed69949beea2fc38f4b0d3d085b58 Mon Sep 17 00:00:00 2001 From: MrM <11910225+mauro-miatello@users.noreply.github.com> Date: Sun, 10 Mar 2024 15:18:54 +0100 Subject: [PATCH 2/2] Script to hide / show encrypted values in web ui added a function to show/hide encrypted values with a simple trick because ClipboardJS can't copy display:none element's value --- resources/views/layouts/default.blade.php | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/resources/views/layouts/default.blade.php b/resources/views/layouts/default.blade.php index 95a82ce41f..216632ccf8 100644 --- a/resources/views/layouts/default.blade.php +++ b/resources/views/layouts/default.blade.php @@ -964,8 +964,7 @@ var clickedElement = $(e.trigger); // Get the target element selector from data attribute var targetSelector = clickedElement.data('data-clipboard-target'); - // Find the target element - var targetEl = $(targetSelector); + // Show the alert that the content was copied clickedElement.tooltip('hide').attr('data-original-title', '{{ trans('general.copied') }}').tooltip('show'); }); @@ -979,6 +978,23 @@ }); + function showHideEncValue(e) { + // Use element id to find the text element to hide / show + var targetElement = e.id+"-to-show"; + var hiddenElement = e.id+"-to-hide"; + if($(e).hasClass('fa-lock')) { + $(e).removeClass('fa-lock').addClass('fa-unlock'); + // Show the encrypted custom value and hide the element with asterisks + document.getElementById(targetElement).style.fontSize = "100%"; + document.getElementById(hiddenElement).style.display = "none"; + } else { + $(e).removeClass('fa-unlock').addClass('fa-lock'); + // ClipboardJS can't copy display:none elements so use a trick to hide the value + document.getElementById(targetElement).style.fontSize = "0px"; + document.getElementById(hiddenElement).style.display = ""; + } + } + $(function () { // Invoke Bootstrap 3's tooltip