Media show stylesheet...
This commit is contained in:
parent
2e6c42f7ba
commit
373c2f89e5
@ -28,6 +28,42 @@ class Uploads extends Controller
|
||||
return response()->file($path);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the specified resource.
|
||||
*
|
||||
* @param $id
|
||||
* @return mixed
|
||||
*/
|
||||
public function show($id)
|
||||
{
|
||||
$file = false;
|
||||
|
||||
$media = Media::find($id);
|
||||
|
||||
// Get file path
|
||||
if (!$path = $this->getPath($media)) {
|
||||
return response()->json([
|
||||
'success' => false,
|
||||
'error' => true,
|
||||
'data' => [],
|
||||
'message' => 'null',
|
||||
'html' => '',
|
||||
]);
|
||||
}
|
||||
|
||||
$file = $media;
|
||||
|
||||
$html = view('partials.media.file', compact('file'))->render();
|
||||
|
||||
return response()->json([
|
||||
'success' => true,
|
||||
'error' => false,
|
||||
'data' => [],
|
||||
'message' => 'null',
|
||||
'html' => $html,
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Download the specified resource.
|
||||
*
|
||||
|
11
public/css/app.css
vendored
11
public/css/app.css
vendored
@ -933,3 +933,14 @@ input[type="number"] {
|
||||
.table-report {
|
||||
overflow-x: auto !important;
|
||||
}
|
||||
|
||||
.mailbox-attachment-file-name {
|
||||
white-space: nowrap;
|
||||
width: 100%;
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
}
|
||||
|
||||
.mailbox-attachment-download {
|
||||
margin-right: 5px;
|
||||
}
|
||||
|
@ -257,27 +257,23 @@
|
||||
text : '{{ trans('general.form.select.file') }}',
|
||||
style : 'btn-default',
|
||||
@if($invoice->attachment)
|
||||
placeholder : '<?php echo $invoice->attachment->basename; ?>'
|
||||
placeholder : '{{ $invoice->attachment->basename }}'
|
||||
@else
|
||||
placeholder : '{{ trans('general.form.no_file_selected') }}'
|
||||
@endif
|
||||
});
|
||||
|
||||
@if($invoice->attachment)
|
||||
attachment_html = '<span class="attachment">';
|
||||
attachment_html += ' <a href="{{ url('uploads/' . $invoice->attachment->id . '/download') }}">';
|
||||
attachment_html += ' <span id="download-attachment" class="text-primary">';
|
||||
attachment_html += ' <i class="fa fa-file-{{ $invoice->attachment->aggregate_type }}-o"></i> {{ $invoice->attachment->basename }}';
|
||||
attachment_html += ' </span>';
|
||||
attachment_html += ' </a>';
|
||||
attachment_html += ' {!! Form::open(['id' => 'attachment-' . $invoice->attachment->id, 'method' => 'DELETE', 'url' => [url('uploads/' . $invoice->attachment->id)], 'style' => 'display:inline']) !!}';
|
||||
attachment_html += ' <a id="remove-attachment" href="javascript:void();">';
|
||||
attachment_html += ' <span class="text-danger"><i class="fa fa fa-times"></i></span>';
|
||||
attachment_html += ' </a>';
|
||||
attachment_html += ' {!! Form::close() !!}';
|
||||
attachment_html += '</span>';
|
||||
|
||||
$('.fancy-file .fake-file').append(attachment_html);
|
||||
$.ajax({
|
||||
url: '{{ url('uploads/' . $invoice->attachment->id . '/show') }}',
|
||||
type: 'GET',
|
||||
dataType: 'JSON',
|
||||
success: function(json) {
|
||||
if (json['success']) {
|
||||
$('.fancy-file').after(json['html']);
|
||||
}
|
||||
}
|
||||
});
|
||||
@endif
|
||||
|
||||
@if(old('item'))
|
||||
|
@ -339,23 +339,8 @@
|
||||
</div>
|
||||
|
||||
@if($invoice->attachment)
|
||||
<span class="attachment">
|
||||
<a href="{{ url('uploads/' . $invoice->attachment->id . '/download') }}">
|
||||
<span id="download-attachment" class="text-primary">
|
||||
<i class="fa fa-file-{{ $invoice->attachment->aggregate_type }}-o"></i> {{ $invoice->attachment->basename }}
|
||||
</span>
|
||||
</a>
|
||||
{!! Form::open([
|
||||
'id' => 'attachment-' . $invoice->attachment->id,
|
||||
'method' => 'DELETE',
|
||||
'url' => [url('uploads/' . $invoice->attachment->id)],
|
||||
'style' => 'display:inline'
|
||||
]) !!}
|
||||
<a id="remove-attachment" href="javascript:void();">
|
||||
<span class="text-danger"><i class="fa fa fa-times"></i></span>
|
||||
</a>
|
||||
{!! Form::close() !!}
|
||||
</span>
|
||||
@php $file = $invoice->attachment; @endphp
|
||||
@include('partials.media.file')
|
||||
@endif
|
||||
</div>
|
||||
</div>
|
||||
|
40
resources/views/partials/media/file.blade.php
Normal file
40
resources/views/partials/media/file.blade.php
Normal file
@ -0,0 +1,40 @@
|
||||
<ul class="mailbox-attachments clearfix margin-top">
|
||||
<li>
|
||||
@if ($file->aggregate_type != 'image')
|
||||
<span class="mailbox-attachment-icon">
|
||||
<i class="fa fa-file-{{ $file->aggregate_type }}-o"></i>
|
||||
</span>
|
||||
@else
|
||||
<span class="mailbox-attachment-icon has-img">
|
||||
<img src="{{ url('uploads/' . $file->id) }}" alt="{{ $file->basename }}">
|
||||
</span>
|
||||
@endif
|
||||
|
||||
<div class="mailbox-attachment-info">
|
||||
<a href="javascript:void();" class="mailbox-attachment-name">
|
||||
<p class="mailbox-attachment-file-name">
|
||||
<i class="fa fa-paperclip"></i> {{ $file->basename }}
|
||||
</p>
|
||||
</a>
|
||||
|
||||
<span class="mailbox-attachment-size">
|
||||
{{ $file->readableSize() }}
|
||||
|
||||
{!! Form::open([
|
||||
'id' => 'attachment-' . $file->id,
|
||||
'method' => 'DELETE',
|
||||
'url' => [url('uploads/' . $file->id)],
|
||||
'style' => 'display:inline'
|
||||
]) !!}
|
||||
<a id="remove-attachment" href="javascript:void();" class="btn btn-danger btn-xs pull-right">
|
||||
<i class="fa fa fa-times"></i>
|
||||
</a>
|
||||
{!! Form::close() !!}
|
||||
|
||||
<a href="{{ url('uploads/' . $file->id . '/download') }}" class="btn btn-info btn-xs pull-right mailbox-attachment-download">
|
||||
<i class="fa fa-cloud-download"></i>
|
||||
</a>
|
||||
</span>
|
||||
</div>
|
||||
</li>
|
||||
</ul>
|
42
resources/views/partials/media/files.blade.php
Normal file
42
resources/views/partials/media/files.blade.php
Normal file
@ -0,0 +1,42 @@
|
||||
<ul class="mailbox-attachments clearfix margin-top">
|
||||
@foreach ($files as $file)
|
||||
<li>
|
||||
@if ($file->aggregate_type != 'image')
|
||||
<span class="mailbox-attachment-icon">
|
||||
<i class="fa fa-file-{{ $file->aggregate_type }}-o"></i>
|
||||
</span>
|
||||
@else
|
||||
<span class="mailbox-attachment-icon has-img">
|
||||
<img src="{{ url('uploads/' . $file->id) }}" alt="{{ $file->basename }}">
|
||||
</span>
|
||||
@endif
|
||||
|
||||
<div class="mailbox-attachment-info">
|
||||
<a href="javascript:void();" class="mailbox-attachment-name">
|
||||
<p class="mailbox-attachment-file-name">
|
||||
<i class="fa fa-paperclip"></i> {{ $file->basename }}
|
||||
</p>
|
||||
</a>
|
||||
|
||||
<span class="mailbox-attachment-size">
|
||||
{{ $file->readableSize() }}
|
||||
|
||||
{!! Form::open([
|
||||
'id' => 'attachment-' . $file->id,
|
||||
'method' => 'DELETE',
|
||||
'url' => [url('uploads/' . $file->id)],
|
||||
'style' => 'display:inline'
|
||||
]) !!}
|
||||
<a id="remove-attachment" href="javascript:void();" class="btn btn-danger btn-xs pull-right">
|
||||
<i class="fa fa fa-times"></i>
|
||||
</a>
|
||||
{!! Form::close() !!}
|
||||
|
||||
<a href="{{ url('uploads/' . $file->id . '/download') }}" class="btn btn-info btn-xs pull-right mailbox-attachment-download">
|
||||
<i class="fa fa-cloud-download"></i>
|
||||
</a>
|
||||
</span>
|
||||
</div>
|
||||
</li>
|
||||
@endforeach
|
||||
</ul>
|
@ -4,6 +4,7 @@ Route::group(['middleware' => 'language'], function () {
|
||||
Route::group(['middleware' => 'auth'], function () {
|
||||
Route::group(['prefix' => 'uploads'], function () {
|
||||
Route::get('{id}', 'Common\Uploads@get');
|
||||
Route::get('{id}/show', 'Common\Uploads@show');
|
||||
Route::get('{id}/download', 'Common\Uploads@download');
|
||||
});
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user