Skip to content

Commit d114973

Browse files
committed
Apply blade component to files views
Signed-off-by: snipe <[email protected]>
1 parent 0e9b3c9 commit d114973

File tree

9 files changed

+194
-755
lines changed

9 files changed

+194
-755
lines changed

app/Helpers/StorageHelper.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ public static function downloader($filename, $disk = 'default') : BinaryFileResp
2929

3030
/**
3131
* This determines the file types that should be allowed inline and checks their fileinfo extension
32+
* to determine that they are safe to display inline.
3233
*
3334
* @author <A. Gianotto> [<[email protected]]>
3435
* @since v7.0.14

resources/views/accessories/view.blade.php

Lines changed: 10 additions & 96 deletions
Original file line numberDiff line numberDiff line change
@@ -154,103 +154,17 @@ class="table table-striped snipe-table"
154154

155155
@can('accessories.files', $accessory)
156156
<div class="tab-pane" id="files">
157-
158-
<div class="table table-responsive">
159-
<div class="row">
160-
<div class="col-md-12">
161-
<table
162-
data-cookie-id-table="accessoryUploadsTable"
163-
data-id-table="accessoryUploadsTable"
164-
id="accessoryUploadsTable"
165-
data-search="true"
166-
data-pagination="true"
167-
data-side-pagination="client"
168-
data-show-columns="true"
169-
data-show-export="true"
170-
data-show-footer="true"
171-
data-toolbar="#upload-toolbar"
172-
data-show-refresh="true"
173-
data-sort-order="asc"
174-
data-sort-name="name"
175-
class="table table-striped snipe-table"
176-
data-export-options='{
177-
"fileName": "export-accessories-uploads-{{ str_slug($accessory->name) }}-{{ date('Y-m-d') }}",
178-
"ignoreColumn": ["actions","image","change","checkbox","checkincheckout","delete","download","icon"]
179-
}'>
180-
<thead>
181-
<tr>
182-
<th data-visible="true" data-field="icon" data-sortable="true">{{trans('general.file_type')}}</th>
183-
<th class="col-md-2" data-searchable="true" data-visible="true" data-field="image">{{ trans('general.image') }}</th>
184-
<th class="col-md-2" data-searchable="true" data-visible="true" data-field="filename" data-sortable="true">{{ trans('general.file_name') }}</th>
185-
<th class="col-md-1" data-searchable="true" data-visible="true" data-field="filesize">{{ trans('general.filesize') }}</th>
186-
<th class="col-md-2" data-searchable="true" data-visible="true" data-field="notes" data-sortable="true">{{ trans('general.notes') }}</th>
187-
<th class="col-md-1" data-searchable="true" data-visible="true" data-field="download">{{ trans('general.download') }}</th>
188-
<th class="col-md-2" data-searchable="true" data-visible="true" data-field="created_at" data-sortable="true">{{ trans('general.created_at') }}</th>
189-
<th class="col-md-1" data-searchable="true" data-visible="true" data-field="actions">{{ trans('table.actions') }}</th>
190-
</tr>
191-
</thead>
192-
<tbody>
193-
@if ($accessory->uploads->count() > 0)
194-
@foreach ($accessory->uploads as $file)
195-
<tr>
196-
<td>
197-
<x-icon type="paperclip" class="fa-2x" />
198-
<i class="{{ Helper::filetype_icon($file->filename) }} icon-med" aria-hidden="true"></i>
199-
<span class="sr-only">{{ Helper::filetype_icon($file->filename) }}</span>
200-
201-
</td>
202-
<td>
203-
@if ($file->filename)
204-
@if ( Helper::checkUploadIsImage($file->get_src('accessories')))
205-
<a href="{{ route('show.accessoryfile', ['accessoryId' => $accessory->id, 'fileId' => $file->id, 'download' => 'false']) }}" data-toggle="lightbox" data-type="image"><img src="{{ route('show.accessoryfile', ['accessoryId' => $accessory->id, 'fileId' => $file->id]) }}" class="img-thumbnail" style="max-width: 50px;"></a>
206-
@endif
207-
@endif
208-
</td>
209-
<td>
210-
{{ $file->filename }}
211-
</td>
212-
<td data-value="{{ (Storage::exists('private_uploads/accessories/'.$file->filename) ? Storage::size('private_uploads/accessories/'.$file->filename) : '') }}">
213-
{{ @Helper::formatFilesizeUnits(Storage::exists('private_uploads/accessories/'.$file->filename) ? Storage::size('private_uploads/accessories/'.$file->filename) : '') }}
214-
</td>
215-
216-
<td>
217-
@if ($file->note)
218-
{{ $file->note }}
219-
@endif
220-
</td>
221-
<td style="white-space: nowrap;">
222-
@if ($file->filename)
223-
<a href="{{ route('show.accessoryfile', [$accessory->id, $file->id]) }}" class="btn btn-sm btn-default">
224-
<i class="fas fa-download" aria-hidden="true"></i>
225-
<span class="sr-only">{{ trans('general.download') }}</span>
226-
</a>
227-
228-
<a href="{{ route('show.accessoryfile', [$accessory->id, $file->id, 'inline' => 'true']) }}" class="btn btn-sm btn-default" target="_blank">
229-
<x-icon type="external-link" />
230-
</a>
231-
232-
@endif
233-
</td>
234-
<td>{{ $file->created_at }}</td>
235-
<td>
236-
<a class="btn delete-asset btn-danger btn-sm" href="{{ route('delete/accessoryfile', [$accessory->id, $file->id]) }}" data-content="{{ trans('general.delete_confirm', ['item' => $file->filename]) }}" data-title="{{ trans('general.delete') }}">
237-
<i class="fas fa-trash icon-white" aria-hidden="true"></i>
238-
<span class="sr-only">{{ trans('general.delete') }}</span>
239-
</a>
240-
</td>
241-
</tr>
242-
@endforeach
243-
@else
244-
<tr>
245-
<td colspan="8">{{ trans('general.no_results') }}</td>
246-
</tr>
247-
@endif
248-
</tbody>
249-
</table>
157+
<div class="row">
158+
<div class="col-md-12">
159+
<x-filestable
160+
filepath="private_uploads/accessories/"
161+
showfile_routename="show.accessoryfile"
162+
deletefile_routename="delete/accessoryfile"
163+
:object="$accessory" />
164+
165+
</div>
250166
</div>
251-
</div>
252-
</div>
253-
</div> <!-- /.tab-pane -->
167+
</div> <!-- /.tab-pane -->
254168
@endcan
255169
</div>
256170
</div>
Lines changed: 140 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,140 @@
1+
<!-- begin redirect submit options -->
2+
@props([
3+
'filepath',
4+
'object',
5+
'showfile_routename',
6+
'deletefile_routename',
7+
])
8+
9+
<!-- begin non-ajaxed file listing table -->
10+
<div class="table-responsive">
11+
<table
12+
data-cookie-id-table="{{ $object }}UploadsTable"
13+
data-id-table="{{ $object }}UploadsTable"
14+
id="{{ $object }}UploadsTable"
15+
data-search="true"
16+
data-pagination="true"
17+
data-side-pagination="client"
18+
data-show-columns="true"
19+
data-show-fullscreen="true"
20+
data-show-export="true"
21+
data-show-footer="true"
22+
data-toolbar="#upload-toolbar"
23+
data-show-refresh="true"
24+
data-sort-order="asc"
25+
data-sort-name="name"
26+
class="table table-striped snipe-table"
27+
data-export-options='{
28+
"fileName": "export-license-uploads-{{ str_slug($object->name) }}-{{ date('Y-m-d') }}",
29+
"ignoreColumn": ["actions","image","change","checkbox","checkincheckout","delete","download","icon"]
30+
}'>
31+
32+
<thead>
33+
<tr>
34+
<th data-visible="false" data-field="id" data-sortable="true">
35+
{{trans('general.id')}}
36+
</th>
37+
<th data-visible="true" data-field="type" data-sortable="true">
38+
{{trans('general.file_type')}}
39+
</th>
40+
<th class="col-md-2" data-searchable="true" data-visible="true" data-field="image">
41+
{{ trans('general.image') }}
42+
</th>
43+
<th class="col-md-2" data-searchable="true" data-visible="true" data-field="filename" data-sortable="true">
44+
{{ trans('general.file_name') }}
45+
</th>
46+
<th class="col-md-1" data-searchable="true" data-visible="true" data-field="filesize">
47+
{{ trans('general.filesize') }}
48+
</th>
49+
<th class="col-md-2" data-searchable="true" data-visible="true" data-field="notes" data-sortable="true">
50+
{{ trans('general.notes') }}
51+
</th>
52+
<th class="col-md-1" data-searchable="true" data-visible="true" data-field="download">
53+
{{ trans('general.download') }}
54+
</th>
55+
<th class="col-md-2" data-searchable="true" data-visible="true" data-field="created_at" data-sortable="true">
56+
{{ trans('general.created_at') }}
57+
</th>
58+
<th class="col-md-2" data-searchable="true" data-visible="true" data-field="created_by" data-sortable="true">
59+
{{ trans('general.created_by') }}
60+
</th>
61+
<th class="col-md-1" data-searchable="true" data-visible="true" data-field="actions">
62+
{{ trans('table.actions') }}
63+
</th>
64+
</tr>
65+
</thead>
66+
<tbody>
67+
@foreach ($object->uploads as $file)
68+
<tr>
69+
<td>
70+
{{ $file->id }}
71+
</td>
72+
<td data-sort-value="{{ pathinfo($filepath.$file->filename, PATHINFO_EXTENSION) }}">
73+
@if (Storage::exists($filepath.$file->filename))
74+
<span class="sr-only">{{ pathinfo($filepath.$file->filename, PATHINFO_EXTENSION) }}</span>
75+
<i class="{{ Helper::filetype_icon($file->filename) }} icon-med" aria-hidden="true" data-tooltip="true" data-title="{{ pathinfo($filepath.$file->filename, PATHINFO_EXTENSION) }}"></i>
76+
@endif
77+
</td>
78+
<td>
79+
@if (($file->filename) && (Storage::exists($filepath.$file->filename)))
80+
@if (Helper::checkUploadIsImage($file->get_src($object)))
81+
<a href="{{ route($showfile_routename, [$object->id, $file->id, 'inline' => 'true']) }}" data-toggle="lightbox" data-type="image">
82+
<img src="{{ route($showfile_routename, [$object->id, $file->id, 'inline' => 'true']) }}" class="img-thumbnail" style="max-width: 50px;">
83+
</a>
84+
@else
85+
{{ trans('general.preview_not_available') }}
86+
@endif
87+
@else
88+
<x-icon type="x" class="text-danger" />
89+
{{ trans('general.file_not_found') }}
90+
@endif
91+
</td>
92+
<td>
93+
{{ $file->filename }}
94+
</td>
95+
<td data-value="{{ (Storage::exists($filepath.$file->filename)) ? Storage::size($filepath.$file->filename) : '' }}">
96+
{{ (Storage::exists($filepath.$file->filename)) ? Helper::formatFilesizeUnits(Storage::size($filepath.$file->filename)) : '' }}
97+
</td>
98+
99+
<td>
100+
@if ($file->note)
101+
{{ $file->note }}
102+
@endif
103+
</td>
104+
<td style="white-space: nowrap;">
105+
@if ($file->filename)
106+
@if (Storage::exists($filepath.$file->filename))
107+
<a href="{{ route($showfile_routename, [$object->id, $file->id]) }}" class="btn btn-sm btn-default">
108+
<x-icon type="download" />
109+
<span class="sr-only">
110+
{{ trans('general.download') }}
111+
</span>
112+
</a>
113+
114+
<a href="{{ StorageHelper::allowSafeInline($filepath.$file->filename) ? route($showfile_routename, [$object->id, $file->id, 'inline' => 'true']) : '#' }}" class="btn btn-sm btn-default{{ StorageHelper::allowSafeInline($filepath.$file->filename) ? '' : ' disabled' }}" target="_blank">
115+
<x-icon type="external-link" />
116+
</a>
117+
@endif
118+
@endif
119+
</td>
120+
<td>
121+
{{ $file->created_at }}
122+
</td>
123+
<td>
124+
{{ $file->created_by }}
125+
</td>
126+
<td>
127+
<a class="btn delete-asset btn-danger btn-sm hidden-print" href="{{ route($deletefile_routename, [$object->id, $file->id]) }}" data-content="Are you sure you wish to delete this file?" data-title="{{ trans('general.delete') }} {{ $file->filename }}?">
128+
<x-icon type="delete" />
129+
<span class="sr-only">{{ trans('general.delete') }}</span>
130+
</a>
131+
</td>
132+
133+
134+
</tr>
135+
@endforeach
136+
137+
</tbody>
138+
</table>
139+
</div>
140+
<!-- end non-ajaxed file listing table -->

0 commit comments

Comments
 (0)