mirror of
https://github.com/snipe/snipe-it.git
synced 2024-12-25 13:44:06 -08:00
Improved files display
This commit is contained in:
parent
97f748d58e
commit
0be69f57ac
|
@ -787,6 +787,66 @@ class Helper
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public static function filetype_icon($filename) {
|
||||||
|
|
||||||
|
$extension = substr(strrchr($filename,'.'),1);
|
||||||
|
|
||||||
|
if ($extension) {
|
||||||
|
switch ($extension) {
|
||||||
|
case 'jpg':
|
||||||
|
case 'jpeg':
|
||||||
|
case 'gif':
|
||||||
|
case 'png':
|
||||||
|
return "fa fa-file-image-o";
|
||||||
|
break;
|
||||||
|
case 'doc':
|
||||||
|
case 'docx':
|
||||||
|
return "fa fa-file-word-o";
|
||||||
|
break;
|
||||||
|
case 'xls':
|
||||||
|
case 'xlsx':
|
||||||
|
return "fa fa-file-excel-o";
|
||||||
|
break;
|
||||||
|
case 'zip':
|
||||||
|
case 'rar':
|
||||||
|
return "fa fa-file-archive-o";
|
||||||
|
break;
|
||||||
|
case 'pdf':
|
||||||
|
return "fa fa-file-pdf-o";
|
||||||
|
break;
|
||||||
|
case 'txt':
|
||||||
|
return "fa fa-file-text-o";
|
||||||
|
break;
|
||||||
|
case 'lic':
|
||||||
|
return "fa fa-floppy-o";
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
return "fa fa-file-o";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return "fa fa-file-o";
|
||||||
|
}
|
||||||
|
|
||||||
|
public static function show_file_inline($filename) {
|
||||||
|
|
||||||
|
$extension = substr(strrchr($filename,'.'),1);
|
||||||
|
|
||||||
|
if ($extension) {
|
||||||
|
switch ($extension) {
|
||||||
|
case 'jpg':
|
||||||
|
case 'jpeg':
|
||||||
|
case 'gif':
|
||||||
|
case 'png':
|
||||||
|
return true;
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -28,7 +28,6 @@ class ReportsController extends Controller
|
||||||
if (($request->has('target_type')) && ($request->has('target_id'))) {
|
if (($request->has('target_type')) && ($request->has('target_id'))) {
|
||||||
$actionlogs = $actionlogs->where('target_id','=',$request->input('target_id'))
|
$actionlogs = $actionlogs->where('target_id','=',$request->input('target_id'))
|
||||||
->where('target_type','=',"App\\Models\\".ucwords($request->input('target_type')));
|
->where('target_type','=',"App\\Models\\".ucwords($request->input('target_type')));
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (($request->has('item_type')) && ($request->has('item_id'))) {
|
if (($request->has('item_type')) && ($request->has('item_id'))) {
|
||||||
|
@ -40,6 +39,10 @@ class ReportsController extends Controller
|
||||||
$actionlogs = $actionlogs->where('action_type','=',$request->input('action_type'))->orderBy('created_at', 'desc');
|
$actionlogs = $actionlogs->where('action_type','=',$request->input('action_type'))->orderBy('created_at', 'desc');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ($request->has('uploads')) {
|
||||||
|
$actionlogs = $actionlogs->whereNotNull('filename')->orderBy('created_at', 'desc');
|
||||||
|
}
|
||||||
|
|
||||||
$allowed_columns = [
|
$allowed_columns = [
|
||||||
'id',
|
'id',
|
||||||
'created_at',
|
'created_at',
|
||||||
|
|
|
@ -1004,17 +1004,18 @@ class AssetsController extends Controller
|
||||||
* @since [v1.0]
|
* @since [v1.0]
|
||||||
* @return View
|
* @return View
|
||||||
*/
|
*/
|
||||||
public function displayFile($assetId = null, $fileId = null)
|
public function displayFile($assetId = null, $fileId = null, $download = true)
|
||||||
{
|
{
|
||||||
|
|
||||||
$asset = Asset::find($assetId);
|
$asset = Asset::find($assetId);
|
||||||
// the asset is valid
|
|
||||||
if (isset($asset->id)) {
|
if (isset($asset->id)) {
|
||||||
|
|
||||||
$this->authorize('view', $asset);
|
$this->authorize('view', $asset);
|
||||||
|
|
||||||
if (!$log = Actionlog::find($fileId)) {
|
if (!$log = Actionlog::find($fileId)) {
|
||||||
return response('No matching record for that asset/file', 500)
|
return response('No matching record for that asset/file', 500)
|
||||||
->header('Content-Type', 'text/plain');
|
->header('Content-Type', 'text/plain');
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
$file = $log->get_src('assets');
|
$file = $log->get_src('assets');
|
||||||
|
@ -1023,14 +1024,13 @@ class AssetsController extends Controller
|
||||||
$file = $log->get_src('audits');
|
$file = $log->get_src('audits');
|
||||||
}
|
}
|
||||||
|
|
||||||
$filetype = Helper::checkUploadIsImage($file);
|
|
||||||
|
|
||||||
if (!file_exists($file)) {
|
if (!file_exists($file)) {
|
||||||
return response('File '.$file.' not found on server', 404)
|
return response('File '.$file.' not found on server', 404)
|
||||||
->header('Content-Type', 'text/plain');
|
->header('Content-Type', 'text/plain');
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($filetype) {
|
if ($download != 'true') {
|
||||||
if ($contents = file_get_contents($file)) {
|
if ($contents = file_get_contents($file)) {
|
||||||
return Response::make($contents)->header('Content-Type', $filetype);
|
return Response::make($contents)->header('Content-Type', $filetype);
|
||||||
}
|
}
|
||||||
|
|
|
@ -508,7 +508,7 @@ class LicensesController extends Controller
|
||||||
foreach (Input::file('licensefile') as $file) {
|
foreach (Input::file('licensefile') as $file) {
|
||||||
|
|
||||||
$rules = array(
|
$rules = array(
|
||||||
'licensefile' => 'required|mimes:png,gif,jpg,jpeg,doc,docx,pdf,txt,zip,rar,rtf,xml,lic|max:2000'
|
'licensefile' => 'required|mimes:png,gif,jpg,jpeg,doc,docx,pdf,txt,zip,rar,rtf,xml,lic'
|
||||||
);
|
);
|
||||||
$validator = Validator::make(array('licensefile'=> $file), $rules);
|
$validator = Validator::make(array('licensefile'=> $file), $rules);
|
||||||
|
|
||||||
|
@ -516,8 +516,7 @@ class LicensesController extends Controller
|
||||||
return redirect()->back()->with('error', trans('admin/licenses/message.upload.invalidfiles'));
|
return redirect()->back()->with('error', trans('admin/licenses/message.upload.invalidfiles'));
|
||||||
}
|
}
|
||||||
$extension = $file->getClientOriginalExtension();
|
$extension = $file->getClientOriginalExtension();
|
||||||
$filename = 'license-'.$license->id.'-'.str_random(8);
|
$filename = 'license-'.$license->id.'-'.str_random(8).'-'.str_slug(basename($file->getClientOriginalName(), '.'.$extension)).'.'.$extension;
|
||||||
$filename .= '-'.str_slug($file->getClientOriginalName()).'.'.$extension;
|
|
||||||
$upload_success = $file->move($destinationPath, $filename);
|
$upload_success = $file->move($destinationPath, $filename);
|
||||||
|
|
||||||
//Log the upload to the log
|
//Log the upload to the log
|
||||||
|
@ -583,7 +582,7 @@ class LicensesController extends Controller
|
||||||
* @param int $fileId
|
* @param int $fileId
|
||||||
* @return \Symfony\Component\HttpFoundation\BinaryFileResponse
|
* @return \Symfony\Component\HttpFoundation\BinaryFileResponse
|
||||||
*/
|
*/
|
||||||
public function displayFile($licenseId = null, $fileId = null)
|
public function displayFile($licenseId = null, $fileId = null, $download = true)
|
||||||
{
|
{
|
||||||
|
|
||||||
$license = License::find($licenseId);
|
$license = License::find($licenseId);
|
||||||
|
@ -593,8 +592,31 @@ class LicensesController extends Controller
|
||||||
$this->authorize('view', $license);
|
$this->authorize('view', $license);
|
||||||
$log = Actionlog::find($fileId);
|
$log = Actionlog::find($fileId);
|
||||||
$file = $log->get_src('licenses');
|
$file = $log->get_src('licenses');
|
||||||
|
|
||||||
|
|
||||||
|
if ($file =='') {
|
||||||
|
return response('File not found on server', 404)
|
||||||
|
->header('Content-Type', 'text/plain');
|
||||||
|
}
|
||||||
|
|
||||||
|
$mimetype = \File::mimeType($file);
|
||||||
|
|
||||||
|
|
||||||
|
if (!file_exists($file)) {
|
||||||
|
return response('File '.$file.' not found on server', 404)
|
||||||
|
->header('Content-Type', 'text/plain');
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($download != 'true') {
|
||||||
|
if ($contents = file_get_contents($file)) {
|
||||||
|
return Response::make($contents)->header('Content-Type', $mimetype);
|
||||||
|
}
|
||||||
|
return JsonResponse::create(["error" => "Failed validation: "], 500);
|
||||||
|
}
|
||||||
return Response::download($file);
|
return Response::download($file);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
return redirect()->route('licenses.index')->with('error', trans('admin/licenses/message.does_not_exist', compact('id')));
|
return redirect()->route('licenses.index')->with('error', trans('admin/licenses/message.does_not_exist', compact('id')));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -23,8 +23,9 @@ class AssetFileRequest extends Request
|
||||||
*/
|
*/
|
||||||
public function rules()
|
public function rules()
|
||||||
{
|
{
|
||||||
|
$max_file_size = \App\Helpers\Helper::file_upload_max_size();
|
||||||
return [
|
return [
|
||||||
'file.*' => 'required|mimes:png,gif,jpg,jpeg,doc,docx,pdf,txt,zip,rar|max:2000'
|
'file.*' => 'required|mimes:png,gif,jpg,jpeg,doc,docx,pdf,txt,zip,rar|max:'.$max_file_size,
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -22,11 +22,20 @@ class ActionlogsTransformer
|
||||||
|
|
||||||
public function transformActionlog (Actionlog $actionlog, $settings = null)
|
public function transformActionlog (Actionlog $actionlog, $settings = null)
|
||||||
{
|
{
|
||||||
|
$icon = $actionlog->present()->icon();
|
||||||
|
if ($actionlog->filename!='') {
|
||||||
|
$icon = e(\App\Helpers\Helper::filetype_icon($actionlog->filename));
|
||||||
|
}
|
||||||
$array = [
|
$array = [
|
||||||
'id' => (int) $actionlog->id,
|
'id' => (int) $actionlog->id,
|
||||||
'icon' => $actionlog->present()->icon(),
|
'icon' => $icon,
|
||||||
'image' => (method_exists($actionlog->item, 'getImageUrl')) ? $actionlog->item->getImageUrl() : null,
|
'file' => ($actionlog->filename!='') ?
|
||||||
'file' => ($actionlog->filename!='') ? route('show/assetfile', ['assetId' => $actionlog->item->id, 'fileId' => $actionlog->id]) : null,
|
[
|
||||||
|
'url' => route('show/assetfile', ['assetId' => $actionlog->item->id, 'fileId' => $actionlog->id]),
|
||||||
|
'filename' => $actionlog->filename,
|
||||||
|
'inlineable' => (bool) \App\Helpers\Helper::show_file_inline($actionlog->filename),
|
||||||
|
] : null,
|
||||||
|
|
||||||
'item' => ($actionlog->item) ? [
|
'item' => ($actionlog->item) ? [
|
||||||
'id' => (int) $actionlog->item->id,
|
'id' => (int) $actionlog->item->id,
|
||||||
'name' => e($actionlog->item->getDisplayNameAttribute()),
|
'name' => e($actionlog->item->getDisplayNameAttribute()),
|
||||||
|
@ -60,12 +69,11 @@ class ActionlogsTransformer
|
||||||
|
|
||||||
];
|
];
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
return $array;
|
return $array;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
public function transformCheckedoutActionlog (Collection $accessories_users, $total)
|
public function transformCheckedoutActionlog (Collection $accessories_users, $total)
|
||||||
{
|
{
|
||||||
|
|
||||||
|
|
|
@ -133,8 +133,11 @@ class Actionlog extends SnipeModel
|
||||||
**/
|
**/
|
||||||
public function get_src($type = 'assets', $fieldname = 'filename')
|
public function get_src($type = 'assets', $fieldname = 'filename')
|
||||||
{
|
{
|
||||||
$file = config('app.private_uploads') . '/' . $type . '/' . $this->{$fieldname};
|
if ($this->filename!='') {
|
||||||
return $file;
|
$file = config('app.private_uploads') . '/' . $type . '/' . $this->{$fieldname};
|
||||||
|
return $file;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -12,7 +12,6 @@ return array(
|
||||||
'deployable' => 'Deployable',
|
'deployable' => 'Deployable',
|
||||||
'deleted' => 'This asset has been deleted. <a href="/hardware/:asset_id/restore">Click here to restore it</a>.',
|
'deleted' => 'This asset has been deleted. <a href="/hardware/:asset_id/restore">Click here to restore it</a>.',
|
||||||
'edit' => 'Edit Asset',
|
'edit' => 'Edit Asset',
|
||||||
'filetype_info' => 'Allowed filetypes are png, gif, jpg, jpeg, doc, docx, pdf, txt, zip, and rar.',
|
|
||||||
'model_deleted' => 'This Assets model has been deleted. You must restore the model before you can restore the Asset.<br/> <a href="/hardware/models/:model_id/restore">Click here to restore the model</a>.',
|
'model_deleted' => 'This Assets model has been deleted. You must restore the model before you can restore the Asset.<br/> <a href="/hardware/models/:model_id/restore">Click here to restore the model</a>.',
|
||||||
'requestable' => 'Requestable',
|
'requestable' => 'Requestable',
|
||||||
'requested' => 'Requested',
|
'requested' => 'Requested',
|
||||||
|
|
|
@ -206,6 +206,7 @@
|
||||||
'unknown_admin' => 'Unknown Admin',
|
'unknown_admin' => 'Unknown Admin',
|
||||||
'username_format' => 'Username Format',
|
'username_format' => 'Username Format',
|
||||||
'update' => 'Update',
|
'update' => 'Update',
|
||||||
|
'upload_filetypes_help' => 'Allowed filetypes are png, gif, jpg, jpeg, doc, docx, pdf, txt, zip, and rar. Max upload size allowed is :size.',
|
||||||
'uploaded' => 'Uploaded',
|
'uploaded' => 'Uploaded',
|
||||||
'user' => 'User',
|
'user' => 'User',
|
||||||
'accepted' => 'accepted',
|
'accepted' => 'accepted',
|
||||||
|
|
|
@ -8,6 +8,7 @@
|
||||||
|
|
||||||
{{-- Right header --}}
|
{{-- Right header --}}
|
||||||
@section('header_right')
|
@section('header_right')
|
||||||
|
|
||||||
@can('manage', \App\Models\Asset::class)
|
@can('manage', \App\Models\Asset::class)
|
||||||
<div class="dropdown pull-right">
|
<div class="dropdown pull-right">
|
||||||
<button class="btn btn-default dropdown-toggle" data-toggle="dropdown">{{ trans('button.actions') }}
|
<button class="btn btn-default dropdown-toggle" data-toggle="dropdown">{{ trans('button.actions') }}
|
||||||
|
@ -733,27 +734,25 @@
|
||||||
data-sort-name="created_at"
|
data-sort-name="created_at"
|
||||||
data-show-export="true"
|
data-show-export="true"
|
||||||
data-export-options='{
|
data-export-options='{
|
||||||
"fileName": "export{{ (Input::has('status')) ? '-'.str_slug(Input::get('status')) : '' }}-assets",
|
"fileName": "export-asset-{{ $asset->id }}-history",
|
||||||
"ignoreColumn": ["actions","image","change","checkbox","checkincheckout","icon"]
|
"ignoreColumn": ["actions","image","change","checkbox","checkincheckout","icon"]
|
||||||
}'
|
}'
|
||||||
|
|
||||||
data-url="{{ route('api.activity.index', ['item_id' => $asset->id, 'item_type' => 'asset']) }}"
|
data-url="{{ route('api.activity.index', ['item_id' => $asset->id, 'item_type' => 'asset']) }}"
|
||||||
data-cookie-id-table="assetHistory">
|
data-cookie-id-table="assetHistory">
|
||||||
|
|
||||||
|
|
||||||
<thead>
|
<thead>
|
||||||
<tr>
|
<tr>
|
||||||
<th data-field="icon" style="width: 40px;" class="hidden-xs" data-formatter="iconFormatter"></th>
|
<th data-field="icon" data-visible="true" style="width: 40px;" class="hidden-xs" data-formatter="iconFormatter"></th>
|
||||||
<th class="col-sm-2" data-field="created_at" data-formatter="dateDisplayFormatter">{{ trans('general.date') }}</th>
|
<th class="col-sm-2" data-visible="true" data-field="created_at" data-formatter="dateDisplayFormatter">{{ trans('general.date') }}</th>
|
||||||
<th class="col-sm-1" data-field="admin" data-formatter="usersLinkObjFormatter">{{ trans('general.admin') }}</th>
|
<th class="col-sm-1" data-visible="true" data-field="admin" data-formatter="usersLinkObjFormatter">{{ trans('general.admin') }}</th>
|
||||||
<th class="col-sm-1" data-field="action_type">{{ trans('general.action') }}</th>
|
<th class="col-sm-1" data-visible="true" data-field="action_type">{{ trans('general.action') }}</th>
|
||||||
<th class="col-sm-2" data-field="item" data-formatter="polymorphicItemFormatter">{{ trans('general.item') }}</th>
|
<th class="col-sm-2" data-visible="true" data-field="item" data-formatter="polymorphicItemFormatter">{{ trans('general.item') }}</th>
|
||||||
<th class="col-sm-2" data-field="target" data-formatter="polymorphicItemFormatter">{{ trans('general.target') }}</th>
|
<th class="col-sm-2" data-visible="true" data-field="target" data-formatter="polymorphicItemFormatter">{{ trans('general.target') }}</th>
|
||||||
<th class="col-sm-2" data-field="note">{{ trans('general.notes') }}</th>
|
<th class="col-sm-2" data-field="note">{{ trans('general.notes') }}</th>
|
||||||
@if ($snipeSettings->require_accept_signature=='1')
|
@if ($snipeSettings->require_accept_signature=='1')
|
||||||
<th class="col-md-3" data-field="signature_file" data-visible="false" data-formatter="imageFormatter">{{ trans('general.signature') }}</th>
|
<th class="col-md-3" data-field="signature_file" data-visible="false" data-formatter="imageFormatter">{{ trans('general.signature') }}</th>
|
||||||
@endif
|
@endif
|
||||||
<th class="col-md-3" data-visible="false" data-field="file" data-visible="false" data-formatter="imageFormatter">{{ trans('general.image') }}</th>
|
<th class="col-md-3" data-visible="false" data-field="file" data-visible="false" data-formatter="fileUploadFormatter">{{ trans('general.download') }}</th>
|
||||||
<th class="col-sm-2" data-field="log_meta" data-visible="true" data-formatter="changeLogFormatter">Changed</th>
|
<th class="col-sm-2" data-field="log_meta" data-visible="true" data-formatter="changeLogFormatter">Changed</th>
|
||||||
</tr>
|
</tr>
|
||||||
</thead>
|
</thead>
|
||||||
|
@ -785,7 +784,7 @@
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="col-md-12">
|
<div class="col-md-12">
|
||||||
<p>{{ trans('admin/hardware/general.filetype_info') }}</p>
|
<p>{{ trans('general.upload_filetypes_help', ['size' => \App\Helpers\Helper::file_upload_max_size_readable()]) }}</p>
|
||||||
<hr>
|
<hr>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
@ -793,20 +792,38 @@
|
||||||
@endcan
|
@endcan
|
||||||
|
|
||||||
<div class="col-md-12">
|
<div class="col-md-12">
|
||||||
<table class="table table-hover">
|
<table
|
||||||
|
class="table table-striped snipe-table"
|
||||||
|
id="assetFileHistory"
|
||||||
|
data-pagination="true"
|
||||||
|
data-id-table="assetFileHistory"
|
||||||
|
data-search="true"
|
||||||
|
data-side-pagination="client"
|
||||||
|
data-show-columns="true"
|
||||||
|
data-show-refresh="true"
|
||||||
|
data-sort-order="desc"
|
||||||
|
data-sort-name="created_at"
|
||||||
|
data-show-export="true"
|
||||||
|
data-export-options='{
|
||||||
|
"fileName": "export-asset-{{ $asset->id }}-files",
|
||||||
|
"ignoreColumn": ["actions","image","change","checkbox","checkincheckout","icon"]
|
||||||
|
}'
|
||||||
|
data-cookie-id-table="assetFileHistory">
|
||||||
<thead>
|
<thead>
|
||||||
<tr>
|
<tr>
|
||||||
<th class="col-md-4">{{ trans('general.notes') }}</th>
|
<th data-visible="true"></th>
|
||||||
<th class="col-md-2"></th>
|
<th class="col-md-2" data-searchable="true" data-visible="true">{{ trans('general.notes') }}</th>
|
||||||
<th class="col-md-4">{{ trans('general.file_name') }}</th>
|
<th class="col-md-2" data-searchable="true" data-visible="true">{{ trans('general.image') }}</th>
|
||||||
<th class="col-md-2"></th>
|
<th class="col-md-2" data-searchable="true" data-visible="true">{{ trans('general.file_name') }}</th>
|
||||||
<th class="col-md-2"></th>
|
<th class="col-md-2" data-searchable="true" data-visible="true">{{ trans('general.download') }}</th>
|
||||||
|
<th class="col-md-1" data-searchable="true" data-visible="true">{{ trans('general.actions') }}</th>
|
||||||
</tr>
|
</tr>
|
||||||
</thead>
|
</thead>
|
||||||
<tbody>
|
<tbody>
|
||||||
@if ($asset->uploads->count() > 0)
|
@if ($asset->uploads->count() > 0)
|
||||||
@foreach ($asset->uploads as $file)
|
@foreach ($asset->uploads as $file)
|
||||||
<tr>
|
<tr>
|
||||||
|
<td><i class="{{ \App\Helpers\Helper::filetype_icon($file->filename) }} icon-med"></i></td>
|
||||||
<td>
|
<td>
|
||||||
@if ($file->note)
|
@if ($file->note)
|
||||||
{{ $file->note }}
|
{{ $file->note }}
|
||||||
|
@ -822,12 +839,12 @@
|
||||||
</td>
|
</td>
|
||||||
<td>
|
<td>
|
||||||
@if ($file->filename)
|
@if ($file->filename)
|
||||||
<a href="{{ route('show/assetfile', [$asset->id, $file->id]) }}" class="btn btn-default">{{ trans('general.download') }}</a>
|
<a href="{{ route('show/assetfile', [$asset->id, $file->id]) }}" class="btn btn-default"><i class="fa fa-download"></i></a>
|
||||||
@endif
|
@endif
|
||||||
</td>
|
</td>
|
||||||
<td>
|
<td>
|
||||||
@can('update', \App\Models\Asset::class)
|
@can('update', \App\Models\Asset::class)
|
||||||
<a class="btn delete-asset btn-danger btn-sm" href="{{ route('delete/assetfile', [$asset->id, $file->id]) }}" data-tooltip="true" data-title="Delete" data-content="Are you sure you wish to delete {{$file->filename}}"><i class="fa fa-trash icon-white"></i></a>
|
<a class="btn delete-asset btn-sm btn-danger btn-sm" href="{{ route('delete/assetfile', [$asset->id, $file->id]) }}" data-tooltip="true" data-title="Delete" data-content="{{ trans('delete_confirm', ['item' => $file->filename]) }}"><i class="fa fa-trash icon-white"></i></a>
|
||||||
@endcan
|
@endcan
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
|
|
|
@ -285,9 +285,10 @@
|
||||||
}'>
|
}'>
|
||||||
<thead>
|
<thead>
|
||||||
<tr>
|
<tr>
|
||||||
|
<th></th>
|
||||||
<th class="col-md-4" data-field="file_name" data-visible="true" data-sortable="true" data-switchable="true">{{ trans('general.file_name') }}</th>
|
<th class="col-md-4" data-field="file_name" data-visible="true" data-sortable="true" data-switchable="true">{{ trans('general.file_name') }}</th>
|
||||||
<th class="col-md-4" data-field="notes" data-visible="true" data-sortable="true" data-switchable="true">{{ trans('general.notes') }}</th>
|
<th class="col-md-4" data-field="notes" data-visible="true" data-sortable="true" data-switchable="true">{{ trans('general.notes') }}</th>
|
||||||
<th class="col-md-4" data-field="created_at" data-visible="true" data-sortable="true" data-switchable="true">{{ trans('general.created_at') }}</th>
|
<th class="col-md-2" data-field="created_at" data-visible="true" data-sortable="true" data-switchable="true">{{ trans('general.created_at') }}</th>
|
||||||
<th class="col-md-2" data-field="download" data-visible="true" data-sortable="false" data-switchable="true">Download</th>
|
<th class="col-md-2" data-field="download" data-visible="true" data-sortable="false" data-switchable="true">Download</th>
|
||||||
<th class="col-md-2" data-field="delete" data-visible="true" data-sortable="false" data-switchable="true">Delete</th>
|
<th class="col-md-2" data-field="delete" data-visible="true" data-sortable="false" data-switchable="true">Delete</th>
|
||||||
</tr>
|
</tr>
|
||||||
|
@ -296,7 +297,11 @@
|
||||||
@if ($license->uploads->count()> 0)
|
@if ($license->uploads->count()> 0)
|
||||||
@foreach ($license->uploads as $file)
|
@foreach ($license->uploads as $file)
|
||||||
<tr>
|
<tr>
|
||||||
<td>{{ $file->filename }}</td>
|
<td><i class="{{ \App\Helpers\Helper::filetype_icon($file->filename) }} icon-med"></i></td>
|
||||||
|
<td>
|
||||||
|
{{ $file->filename }}
|
||||||
|
|
||||||
|
</td>
|
||||||
<td>
|
<td>
|
||||||
@if ($file->note)
|
@if ($file->note)
|
||||||
{{ $file->note }}
|
{{ $file->note }}
|
||||||
|
@ -304,11 +309,10 @@
|
||||||
</td>
|
</td>
|
||||||
<td>{{ $file->created_at }}</td>
|
<td>{{ $file->created_at }}</td>
|
||||||
<td>
|
<td>
|
||||||
|
|
||||||
@if ($file->filename)
|
@if ($file->filename)
|
||||||
<a href="{{ route('show/licensefile', [$license->id, $file->id]) }}" class="btn btn-default">
|
@if ( \App\Helpers\Helper::checkUploadIsImage($file->get_src('licenses')))
|
||||||
Download
|
<a href="{{ route('show.licensefile', ['licenseId' => $license->id, 'fileId' => $file->id, 'download' => 'false']) }}" data-toggle="lightbox" data-type="image"><img src="{{ route('show.licensefile', ['licenseId' => $license->id, 'fileId' => $file->id]) }}" class="img-thumbnail" style="max-width: 50px;"></a>
|
||||||
</a>
|
@endif
|
||||||
@endif
|
@endif
|
||||||
</td>
|
</td>
|
||||||
<td>
|
<td>
|
||||||
|
@ -379,8 +383,9 @@
|
||||||
'method' => 'POST',
|
'method' => 'POST',
|
||||||
'route' => ['upload/license', $license->id],
|
'route' => ['upload/license', $license->id],
|
||||||
'files' => true, 'class' => 'form-horizontal' ]) }}
|
'files' => true, 'class' => 'form-horizontal' ]) }}
|
||||||
|
<input type="hidden" name="_token" value="{{ csrf_token() }}" />
|
||||||
<div class="modal-body">
|
<div class="modal-body">
|
||||||
<p>{{ trans('admin/licenses/general.filetype_info') }}</p>
|
<p>{{ trans('general.upload_filetypes_help', ['size' => \App\Helpers\Helper::file_upload_max_size_readable()]) }}</p>
|
||||||
<div class="form-group col-md-12">
|
<div class="form-group col-md-12">
|
||||||
<div class="input-group col-md-12">
|
<div class="input-group col-md-12">
|
||||||
<input class="col-md-12 form-control" type="text" name="notes" id="notes" placeholder="Notes">
|
<input class="col-md-12 form-control" type="text" name="notes" id="notes" placeholder="Notes">
|
||||||
|
|
|
@ -507,6 +507,22 @@
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function fileUploadFormatter(value) {
|
||||||
|
if ((value) && (value.url) && (value.inlineable)) {
|
||||||
|
return '<a href="' + value.url + '" data-toggle="lightbox" data-type="image"><img src="' + value.url + '" style="max-height: {{ $snipeSettings->thumbnail_max_h }}px; width: auto;" class="img-responsive"></a>';
|
||||||
|
} else if ((value) && (value.url)) {
|
||||||
|
return '<a href="' + value.url + '" class="btn btn-default"><i class="fa fa-download"></i></a>';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
function fileUploadNameFormatter(value) {
|
||||||
|
console.dir(value);
|
||||||
|
if ((value) && (value.filename) && (value.url)) {
|
||||||
|
return '<a href="' + value.url + '">' + value.filename + '</a>';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
function sumFormatter(data) {
|
function sumFormatter(data) {
|
||||||
if (Array.isArray(data)) {
|
if (Array.isArray(data)) {
|
||||||
var field = this.field;
|
var field = this.field;
|
||||||
|
|
|
@ -38,8 +38,8 @@ Route::group([ 'prefix' => 'licenses', 'middleware' => ['auth'] ], function () {
|
||||||
[ 'as' => 'delete/licensefile', 'uses' => 'LicensesController@getDeleteFile' ]
|
[ 'as' => 'delete/licensefile', 'uses' => 'LicensesController@getDeleteFile' ]
|
||||||
);
|
);
|
||||||
Route::get(
|
Route::get(
|
||||||
'{licenseId}/showfile/{fileId}',
|
'{licenseId}/showfile/{fileId}/{download?}',
|
||||||
[ 'as' => 'show/licensefile', 'uses' => 'LicensesController@displayFile' ]
|
[ 'as' => 'show.licensefile', 'uses' => 'LicensesController@displayFile' ]
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue