From d1149730be99fdc8e59e91ce3b02c863a08d4aa1 Mon Sep 17 00:00:00 2001 From: snipe Date: Thu, 17 Oct 2024 16:31:17 +0100 Subject: [PATCH] Apply blade component to files views Signed-off-by: snipe --- app/Helpers/StorageHelper.php | 1 + resources/views/accessories/view.blade.php | 104 +---------- resources/views/blade/filestable.blade.php | 140 ++++++++++++++ resources/views/components/view.blade.php | 98 +--------- resources/views/consumables/view.blade.php | 102 +---------- resources/views/hardware/view.blade.php | 201 +-------------------- resources/views/licenses/view.blade.php | 97 +--------- resources/views/models/view.blade.php | 98 +--------- resources/views/users/view.blade.php | 104 +---------- 9 files changed, 192 insertions(+), 753 deletions(-) create mode 100644 resources/views/blade/filestable.blade.php diff --git a/app/Helpers/StorageHelper.php b/app/Helpers/StorageHelper.php index ef0facc27b..950e70cc49 100644 --- a/app/Helpers/StorageHelper.php +++ b/app/Helpers/StorageHelper.php @@ -29,6 +29,7 @@ class StorageHelper /** * This determines the file types that should be allowed inline and checks their fileinfo extension + * to determine that they are safe to display inline. * * @author [ * @since v7.0.14 diff --git a/resources/views/accessories/view.blade.php b/resources/views/accessories/view.blade.php index 1f7e5f0b9a..e3f98bf61a 100644 --- a/resources/views/accessories/view.blade.php +++ b/resources/views/accessories/view.blade.php @@ -154,103 +154,17 @@ @can('accessories.files', $accessory)
+
+
+ -
-
-
- - - - - - - - - - - - - - - @if ($accessory->uploads->count() > 0) - @foreach ($accessory->uploads as $file) - - - - - - - - - - - - @endforeach - @else - - - - @endif - -
{{trans('general.file_type')}}{{ trans('general.image') }}{{ trans('general.file_name') }}{{ trans('general.filesize') }}{{ trans('general.notes') }}{{ trans('general.download') }}{{ trans('general.created_at') }}{{ trans('table.actions') }}
- - - {{ Helper::filetype_icon($file->filename) }} - - - @if ($file->filename) - @if ( Helper::checkUploadIsImage($file->get_src('accessories'))) - - @endif - @endif - - {{ $file->filename }} - - {{ @Helper::formatFilesizeUnits(Storage::exists('private_uploads/accessories/'.$file->filename) ? Storage::size('private_uploads/accessories/'.$file->filename) : '') }} - - @if ($file->note) - {{ $file->note }} - @endif - - @if ($file->filename) - - - {{ trans('general.download') }} - - - - - - - @endif - {{ $file->created_at }} - - - {{ trans('general.delete') }} - -
{{ trans('general.no_results') }}
+
-
-
-
+
@endcan diff --git a/resources/views/blade/filestable.blade.php b/resources/views/blade/filestable.blade.php new file mode 100644 index 0000000000..8d258d606d --- /dev/null +++ b/resources/views/blade/filestable.blade.php @@ -0,0 +1,140 @@ + +@props([ + 'filepath', + 'object', + 'showfile_routename', + 'deletefile_routename', +]) + + +
+ + + + + + + + + + + + + + + + + + @foreach ($object->uploads as $file) + + + + + + + + + + + + + + + + @endforeach + + +
+ {{trans('general.id')}} + + {{trans('general.file_type')}} + + {{ trans('general.image') }} + + {{ trans('general.file_name') }} + + {{ trans('general.filesize') }} + + {{ trans('general.notes') }} + + {{ trans('general.download') }} + + {{ trans('general.created_at') }} + + {{ trans('general.created_by') }} + + {{ trans('table.actions') }} +
+ {{ $file->id }} + + @if (Storage::exists($filepath.$file->filename)) + {{ pathinfo($filepath.$file->filename, PATHINFO_EXTENSION) }} + + @endif + + @if (($file->filename) && (Storage::exists($filepath.$file->filename))) + @if (Helper::checkUploadIsImage($file->get_src($object))) + + + + @else + {{ trans('general.preview_not_available') }} + @endif + @else + + {{ trans('general.file_not_found') }} + @endif + + {{ $file->filename }} + + {{ (Storage::exists($filepath.$file->filename)) ? Helper::formatFilesizeUnits(Storage::size($filepath.$file->filename)) : '' }} + + @if ($file->note) + {{ $file->note }} + @endif + + @if ($file->filename) + @if (Storage::exists($filepath.$file->filename)) + + + + {{ trans('general.download') }} + + + + + + + @endif + @endif + + {{ $file->created_at }} + + {{ $file->created_by }} + + + + {{ trans('general.delete') }} + +
+
+ \ No newline at end of file diff --git a/resources/views/components/view.blade.php b/resources/views/components/view.blade.php index 287b0b23a8..5bd185bedf 100644 --- a/resources/views/components/view.blade.php +++ b/resources/views/components/view.blade.php @@ -140,96 +140,14 @@ @can('components.files', $component)
- -
- - - - - - - - - - - - - - - @if ($component->uploads->count() > 0) - @foreach ($component->uploads as $file) - - - - - - - - - - - - @endforeach - @else - - - - @endif - -
{{trans('general.file_type')}}{{ trans('general.image') }}{{ trans('general.file_name') }}{{ trans('general.filesize') }}{{ trans('general.notes') }}{{ trans('general.download') }}{{ trans('general.created_at') }}{{ trans('table.actions') }}
- - {{ Helper::filetype_icon($file->filename) }} - - - @if ($file->filename) - @if ( Helper::checkUploadIsImage($file->get_src('components'))) - - @endif - @endif - - {{ $file->filename }} - - {{ @Helper::formatFilesizeUnits(Storage::exists('private_uploads/components/'.$file->filename) ? Storage::size('private_uploads/components/'.$file->filename) : '') }} - - @if ($file->note) - {{ $file->note }} - @endif - - @if ($file->filename) - - - {{ trans('general.download') }} - - - - - - - @endif - {{ $file->created_at }} - - - {{ trans('general.delete') }} - -
{{ trans('general.no_results') }}
+
+
+ +
@endcan diff --git a/resources/views/consumables/view.blade.php b/resources/views/consumables/view.blade.php index 88ea19195f..87650ac9eb 100644 --- a/resources/views/consumables/view.blade.php +++ b/resources/views/consumables/view.blade.php @@ -428,102 +428,18 @@
+
+
+ -
-
- - - - - - - - - - - - - - - - @if ($consumable->uploads->count() > 0) - @foreach ($consumable->uploads as $file) - - - - - - - - - - - - @endforeach - @else - - - - @endif - -
{{trans('general.file_type')}}{{ trans('general.image') }}{{ trans('general.file_name') }}{{ trans('general.filesize') }}{{ trans('general.notes') }}{{ trans('general.download') }}{{ trans('general.created_at') }}{{ trans('table.actions') }}
- - {{ Helper::filetype_icon($file->filename) }} - - - @if ($file->filename) - @if ( Helper::checkUploadIsImage($file->get_src('consumables'))) - - @endif - @endif - - {{ $file->filename }} - - {{ @Helper::formatFilesizeUnits(Storage::exists('private_uploads/consumables/'.$file->filename) ? Storage::size('private_uploads/consumables/'.$file->filename) : '') }} - - @if ($file->note) - {!! nl2br(Helper::parseEscapedMarkedownInline($file->note)) !!} - @endif - - @if ($file->filename) - - - {{ trans('general.download') }} - - - - - - @endif - {{ $file->created_at }} - - - {{ trans('general.delete') }} - - -
{{ trans('general.no_results') }}
-
-
+
+
diff --git a/resources/views/hardware/view.blade.php b/resources/views/hardware/view.blade.php index 1e040b7603..f93c26cf8e 100755 --- a/resources/views/hardware/view.blade.php +++ b/resources/views/hardware/view.blade.php @@ -1362,102 +1362,11 @@
- - @if ($asset->uploads->count() > 0) - - - - - - - - - - - - - - - - @foreach ($asset->uploads as $file) - - - - - - - - - - - @endforeach - -
{{trans('general.file_type')}}{{ trans('general.image') }}{{ trans('general.file_name') }}{{ trans('general.filesize') }}{{ trans('general.notes') }}{{ trans('general.download') }}{{ trans('general.created_at') }}{{ trans('table.actions') }}
- @if ( Helper::checkUploadIsImage($file->get_src('assets'))) - - - - @endif - - @if (Storage::exists('private_uploads/assets/'.$file->filename)) - {{ $file->filename }} - @else - {{ $file->filename }} - @endif - - {{ @Helper::formatFilesizeUnits(Storage::exists('private_uploads/assets/'.$file->filename) ? Storage::size('private_uploads/assets/'.$file->filename) : '') }} - - @if ($file->note) - {{ $file->note }} - @endif - - @if (($file->filename) && (Storage::exists('private_uploads/assets/'.$file->filename))) - - - - - - - - @endif - - @if ($file->created_at) - {{ Helper::getFormattedDateObject($file->created_at, 'datetime', false) }} - @endif - - @can('update', \App\Models\Asset::class) - - - - @endcan -
- - @else - -
- - {{ trans('general.no_results') }} -
- @endif - +
@@ -1467,101 +1376,11 @@
- @if (($asset->model) && ($asset->model->uploads->count() > 0)) - - - - - - - - - - - - - - - - @foreach ($asset->model->uploads as $file) - - - - - - - - - - - @endforeach - -
{{trans('general.file_type')}}{{ trans('general.image') }}{{ trans('general.file_name') }}{{ trans('general.filesize') }}{{ trans('general.notes') }}{{ trans('general.download') }}{{ trans('general.created_at') }}{{ trans('table.actions') }}
- @if ( Helper::checkUploadIsImage($file->get_src('assetmodels'))) - - - - @endif - - @if (Storage::exists('private_uploads/assetmodels/'.$file->filename)) - {{ $file->filename }} - @else - {{ $file->filename }} - @endif - - {{ (Storage::exists('private_uploads/assetmodels/'.$file->filename)) ? Helper::formatFilesizeUnits(Storage::size('private_uploads/assetmodels/'.$file->filename)) : '' }} - - @if ($file->note) - {{ $file->note }} - @endif - - @if (($file->filename) && (Storage::exists('private_uploads/assetmodels/'.$file->filename))) - - - - - - - - - @endif - - @if ($file->created_at) - {{ Helper::getFormattedDateObject($file->created_at, 'datetime', false) }} - @endif - - @can('update', \App\Models\AssetModel::class) - - - - @endcan -
- - @else - -
- - {{ trans('general.no_results') }} -
- @endif +
diff --git a/resources/views/licenses/view.blade.php b/resources/views/licenses/view.blade.php index c20ef87b2d..2de0f9d6e0 100755 --- a/resources/views/licenses/view.blade.php +++ b/resources/views/licenses/view.blade.php @@ -464,100 +464,13 @@ @can('licenses.files', $license)
-
- - - - - - - - - - - - - - - @if ($license->uploads->count() > 0) - @foreach ($license->uploads as $file) - - - - - + - - - - - - @endforeach - @else - - - - @endif - -
{{trans('general.file_type')}}{{ trans('general.image') }}{{ trans('general.file_name') }}{{ trans('general.filesize') }}{{ trans('general.notes') }}{{ trans('general.download') }}{{ trans('general.created_at') }}{{ trans('table.actions') }}
- - {{ Helper::filetype_icon($file->filename) }} - - @if ($file->filename) - @if ((Storage::exists('private_uploads/licenses/'.$file->filename)) && ( Helper::checkUploadIsImage($file->get_src('licenses')))) - - @endif - @endif - - @if (Storage::exists('private_uploads/licenses/'.$file->filename)) - {{ $file->filename }} - @else - {{ $file->filename }} - @endif - - {{ (Storage::exists('private_uploads/licenses/'.$file->filename)) ? Helper::formatFilesizeUnits(Storage::size('private_uploads/licenses/'.$file->filename)) : '' }} - - @if ($file->note) - {{ $file->note }} - @endif - - @if ($file->filename) - - - {{ trans('general.download') }} - - - - - - - @endif - {{ $file->created_at }} - - - {{ trans('general.delete') }} - -
{{ trans('general.no_results') }}
-
@endcan diff --git a/resources/views/models/view.blade.php b/resources/views/models/view.blade.php index 65f9bdd4fe..f26b9babd4 100755 --- a/resources/views/models/view.blade.php +++ b/resources/views/models/view.blade.php @@ -107,99 +107,11 @@
- @if ($model->uploads->count() > 0) - - - - - - - - - - - - - - - - @foreach ($model->uploads as $file) - - - - - - - - - - - @endforeach - -
{{trans('general.file_type')}}{{ trans('general.image') }}{{ trans('general.file_name') }}{{ trans('general.filesize') }}{{ trans('general.notes') }}{{ trans('general.download') }}{{ trans('general.created_at') }}{{ trans('table.actions') }}
- @if ((Storage::exists('private_uploads/assetmodels/'.$file->filename)) && ( Helper::checkUploadIsImage($file->get_src('assetmodels')))) - - - - @endif - - @if (Storage::exists('private_uploads/assetmodels/'.$file->filename)) - {{ $file->filename }} - @else - {{ $file->filename }} - @endif - - {{ (Storage::exists('private_uploads/assetmodels/'.$file->filename)) ? Helper::formatFilesizeUnits(Storage::size('private_uploads/assetmodels/'.$file->filename)) : '' }} - - @if ($file->note) - {{ $file->note }} - @endif - - @if (($file->filename) && (Storage::exists('private_uploads/assetmodels/'.$file->filename))) - - - - - - - - - @endif - - @if ($file->created_at) - {{ Helper::getFormattedDateObject($file->created_at, 'datetime', false) }} - @endif - - @can('update', \App\Models\AssetModel::class) - - @endcan -
- - @else - -
- - {{ trans('general.no_results') }} -
- @endif +
diff --git a/resources/views/users/view.blade.php b/resources/views/users/view.blade.php index 7821b87402..495d0a2ca6 100755 --- a/resources/views/users/view.blade.php +++ b/resources/views/users/view.blade.php @@ -971,105 +971,11 @@
-
- - - - - - - - - - - - - - - - @foreach ($user->uploads as $file) - - - - - - - - - - - - - - - @endforeach - - -
{{trans('general.file_type')}}{{ trans('general.image') }}{{ trans('general.file_name') }}{{ trans('general.filesize') }}{{ trans('general.notes') }}{{ trans('general.download') }}{{ trans('general.created_at') }}{{ trans('table.actions') }}
- @if (Storage::exists('private_uploads/users/'.$file->filename)) - - {{ Helper::filetype_icon($file->filename) }} - @endif - - @if (($file->filename) && (Storage::exists('private_uploads/users/'.$file->filename))) - @if (Helper::checkUploadIsImage($file->get_src('users'))) - - - - @else - {{ trans('general.preview_not_available') }} - @endif - @else - - {{ trans('general.file_not_found') }} - @endif - - {{ $file->filename }} - - {{ (Storage::exists('private_uploads/users/'.$file->filename)) ? Helper::formatFilesizeUnits(Storage::size('private_uploads/users/'.$file->filename)) : '' }} - - @if ($file->note) - {{ $file->note }} - @endif - - @if ($file->filename) - @if (Storage::exists('private_uploads/users/'.$file->filename)) - - - {{ trans('general.download') }} - - - - - - @endif - @endif - {{ $file->created_at }} - - - {{ trans('general.delete') }} - -
-
+