FEATURE #1508: merge files and directories overview.
This commit merges list of all uploaded files and created directories into one page. It also modifies way of uploading files. Special page for uploading files was removed (because of no support for directories) and files can be uploaded only via overview.
This commit is contained in:
@@ -38,7 +38,7 @@ abstract class Handler implements AppHandler
|
||||
'basicInfo' => 'admin.content.formParts.basicInformation',
|
||||
'meta' => 'admin.content.formParts.metaInformation',
|
||||
'publication' => 'admin.content.formParts.publicationSetup',
|
||||
'appearance' => 'admin.content.formParts.appearance',
|
||||
'appearance' => 'admin.content.formParts.appearance',
|
||||
];
|
||||
}
|
||||
|
||||
@@ -93,11 +93,7 @@ abstract class Handler implements AppHandler
|
||||
|
||||
$sub->route('content.overview', trans('admin/mainMenu.contentPageOverview'), [], 20, ['icon' => 'fa fa-list']);
|
||||
}, 15, ['icon' => 'fa fa-database']);
|
||||
$menu->dropdown(trans('admin/mainMenu.fileManager'), function ($sub) {
|
||||
$sub->route('upload.directories', trans('admin/mainMenu.directories'), [], 1, ['icon' => 'fa fa-folder']);
|
||||
$sub->route('upload.file', trans('admin/mainMenu.uploadFile'), [], 10, ['icon' => 'fa fa-file']);
|
||||
$sub->route('upload.overview', trans('admin/mainMenu.uploadedFiles'), [], 150, ['icon' => 'fa fa-files-o']);
|
||||
}, 25, ['icon' => 'fa fa-film']);
|
||||
$menu->route('upload.overview', trans('admin/mainMenu.fileManager'), [], 30, ['icon' => 'fa fa-folder']);
|
||||
$menu->dropdown(trans('admin/mainMenu.widgets'), function ($sub) {
|
||||
// create list of all widget types
|
||||
$sub->dropdown(trans('admin/mainMenu.newWidget'), function ($sub) {
|
||||
|
||||
@@ -2,7 +2,6 @@
|
||||
namespace App\Http\Controllers\Admin;
|
||||
|
||||
use App\Http\Requests\UploadFileRequest;
|
||||
use App\Http\Requests\UploadImageRequest;
|
||||
use App\Models\File;
|
||||
use Symfony\Component\HttpFoundation\File\Exception\FileException;
|
||||
|
||||
@@ -19,10 +18,6 @@ class UploadFile extends Controller
|
||||
$this->file = $file;
|
||||
}
|
||||
|
||||
public function getFile()
|
||||
{
|
||||
return view('admin/fileManager.newFile');
|
||||
}
|
||||
|
||||
/**
|
||||
* Uploads any file
|
||||
@@ -47,7 +42,7 @@ class UploadFile extends Controller
|
||||
|
||||
// upload was not performed via ajax, redirect user
|
||||
return redirect()
|
||||
->route('upload.file')
|
||||
->route('upload.overview', ['directory' => $request->directoryId])
|
||||
->with('success', trans('admin/fileManager.uploadSuccessfull'));
|
||||
} catch (FileException $e) {
|
||||
return $this->invalidUpload('invalidFile');
|
||||
|
||||
@@ -4,30 +4,46 @@ namespace App\Http\Controllers\Admin;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\Http\Requests;
|
||||
use App\Models\Directory;
|
||||
use App\Models\File;
|
||||
use Illuminate\Support\Facades\Input;
|
||||
|
||||
class UploadedFilesOverview extends Controller
|
||||
{
|
||||
public function getOverview($type = null, $subtype = null)
|
||||
/**
|
||||
* List of all files and directories
|
||||
*
|
||||
* @param null $directoryId
|
||||
* @param null $fileType
|
||||
* @param null $fileSubtype
|
||||
*
|
||||
* @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View
|
||||
*/
|
||||
public function getOverview($directoryId = null, $fileType = null, $fileSubtype = null)
|
||||
{
|
||||
$directories = [];
|
||||
// get directory information
|
||||
$directory = is_null($directoryId) ? new Directory() : Directory::findOrFail($directoryId);
|
||||
|
||||
$files = File::orderBy('updated_at', 'DESC');
|
||||
// get all files in this directory
|
||||
$files = File::orderBy('updated_at', 'DESC')
|
||||
->where('directory_id', $directory->id);
|
||||
|
||||
// try to filter by given type
|
||||
if (!is_null($type)) {
|
||||
if (is_null($subtype))
|
||||
$files = $files->where('mime_type', 'LIKE', $type.'%');
|
||||
else {
|
||||
$files = $files->where('mime_type', $type.'/'.$subtype);
|
||||
if (!is_null($fileType)) {
|
||||
if (is_null($fileSubtype)) {
|
||||
$files = $files->where('mime_type', 'LIKE', $fileType . '%');
|
||||
} else {
|
||||
$files = $files->where('mime_type', $fileType . '/' . $fileSubtype);
|
||||
}
|
||||
}
|
||||
|
||||
$files = $files->paginate(18);
|
||||
// include hidden directories?
|
||||
$includeHidden = Input::get('hidden');
|
||||
|
||||
return view('admin.fileManager.overview', [
|
||||
'direcories' => $directories,
|
||||
'files' => $files
|
||||
'directory' => $directory,
|
||||
'subdirectories' => $directory->subdirectories($includeHidden),
|
||||
'files' => $files->get()
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -17,7 +17,8 @@ abstract class UploadRequest extends Request
|
||||
{
|
||||
// some globaly defined rules
|
||||
$rules = [
|
||||
'keywords' => 'max:255'
|
||||
'keywords' => 'max:255',
|
||||
'directoryId' => 'exists:directories,id'
|
||||
];
|
||||
|
||||
// setup additional rules
|
||||
|
||||
@@ -184,8 +184,6 @@ Route::group([
|
||||
->name('widgets.makeAssociation');
|
||||
|
||||
// uploader methods
|
||||
Route::get('upload/file', 'UploadFile@getFile')
|
||||
->name('upload.file');
|
||||
Route::get('directories/new/{id?}', 'CreateNewDirectory@getNew')
|
||||
->name('upload.newDirectory');
|
||||
|
||||
|
||||
+2
-1
@@ -101,9 +101,10 @@ class File extends Model
|
||||
$newFile->hash_algorithm = self::HASH_ALGORITHM;
|
||||
$newFile->mime_type = $file->getMimeType();
|
||||
$newFile->file_size = $file->getSize();
|
||||
$newFile->directory_id = $request->directoryId;
|
||||
|
||||
// save optional fields
|
||||
$optionalFields = ['description', 'keywords', 'directory'];
|
||||
$optionalFields = ['description', 'keywords'];
|
||||
foreach ($optionalFields as $field) {
|
||||
if ($request->has($field)) {
|
||||
$newFile->$field = $request->$field;
|
||||
|
||||
@@ -0,0 +1,32 @@
|
||||
<div class="row tile-overview" data-equalizer>
|
||||
@forelse($files as $file)
|
||||
<div class="columns large-2">
|
||||
<div class="item" data-equalizer-watch>
|
||||
<div class="preview row" title="{{ \App\Helpers\FileManager::getFormattedSize($file) }}">
|
||||
<a href="{{route('upload.detail', ['id' => $file->id])}}">
|
||||
{!! \App\Helpers\FileManager::getPreview($file) !!}
|
||||
</a>
|
||||
</div>
|
||||
<div class="detail row text-center">
|
||||
<div class="highlight">
|
||||
{{str_limit($file->original_filename, 15)}}
|
||||
</div>
|
||||
<div class="small">
|
||||
{{$file->mime_type}}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="controls row">
|
||||
<a href="{{route('upload.detail', ['id' => $file->id])}}" class="button text-center primary column large-6" title="@lang('admin/fileManager.edit')">
|
||||
<i class="fa fa-edit"></i>
|
||||
</a>
|
||||
<a href="{{route('upload.delete', ['id' => $file->id])}}" class="button text-center confirm alert column large-6" title="@lang('admin/fileManager.delete')">
|
||||
<i class="fa fa-remove"></i>
|
||||
</a>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@empty
|
||||
<em>@lang('admin/fileManager.noFiles')</em>
|
||||
@endforelse
|
||||
</div>
|
||||
@@ -1,14 +0,0 @@
|
||||
@extends('admin.layout')
|
||||
|
||||
@section('pageName', @trans('admin/fileManager.newFile'))
|
||||
|
||||
@section('content')
|
||||
|
||||
<div class="row">
|
||||
<h2>@lang('admin/fileManager.newFile')</h2>
|
||||
</div>
|
||||
|
||||
<div class="row">
|
||||
@include('admin.fileManager.newFileForm')
|
||||
</div>
|
||||
@stop
|
||||
@@ -1,56 +1,39 @@
|
||||
@if (session('success'))
|
||||
<div data-alert class="callout success">
|
||||
<strong>{{ session('success') }}</strong>
|
||||
</div>
|
||||
@endif
|
||||
|
||||
@if (session('error'))
|
||||
<div data-alert class="callout alert">
|
||||
<strong>{{ session('error') }}</strong>
|
||||
</div>
|
||||
@endif
|
||||
<h3>@lang('admin/fileManager.newFile')</h3>
|
||||
|
||||
<form method="POST" action="{{route('upload.postFile')}}" enctype="multipart/form-data">
|
||||
{!! csrf_field() !!}
|
||||
|
||||
<div class="row">
|
||||
<div class="column large-4">
|
||||
<label>
|
||||
@lang('admin/fileManager.selectFile')
|
||||
@if(isset($directory))
|
||||
<input type="hidden" name="directoryId" value="{{$directory->id}}" />
|
||||
@endif
|
||||
|
||||
<input type="file" name="file" id="file" />
|
||||
<label>
|
||||
@lang('admin/fileManager.selectFile')
|
||||
|
||||
@if (isset($errors) && $errors->has('file'))
|
||||
<div class="callout alert">
|
||||
{{ $errors->first('file') }}
|
||||
</div>
|
||||
@endif
|
||||
</label>
|
||||
</div>
|
||||
<div class="column large-8">
|
||||
<label>
|
||||
@lang('admin/fileManager.keywords')
|
||||
<input type="file" name="file" id="file" />
|
||||
|
||||
<input type="text" name="keywords" id="keywords" />
|
||||
@if (isset($errors) && $errors->has('file'))
|
||||
<div class="callout alert">
|
||||
{{ $errors->first('file') }}
|
||||
</div>
|
||||
@endif
|
||||
</label>
|
||||
<label>
|
||||
@lang('admin/fileManager.keywords')
|
||||
|
||||
@if (isset($errors) && $errors->has('keywords'))
|
||||
<div class="callout alert">
|
||||
{{ $errors->first('keywords') }}
|
||||
</div>
|
||||
@endif
|
||||
</label>
|
||||
<input type="text" name="keywords" id="keywords" value="{{old('keywords')}}" />
|
||||
|
||||
<label>
|
||||
@lang('admin/fileManager.description')
|
||||
@if (isset($errors) && $errors->has('keywords'))
|
||||
<div class="callout alert">
|
||||
{{ $errors->first('keywords') }}
|
||||
</div>
|
||||
@endif
|
||||
</label>
|
||||
|
||||
<textarea rows="3" name="description" id="description"></textarea>
|
||||
</label>
|
||||
</div>
|
||||
</div>
|
||||
<label>
|
||||
@lang('admin/fileManager.description')
|
||||
|
||||
<div class="row text-right">
|
||||
<div class="column">
|
||||
<button type="submit" class="button primary">@lang('admin/fileManager.upload')</button>
|
||||
</div>
|
||||
</div>
|
||||
<textarea rows="3" name="description" id="description">{{old('description')}}</textarea>
|
||||
</label>
|
||||
<button type="submit" class="button primary">@lang('admin/fileManager.upload')</button>
|
||||
</form>
|
||||
@@ -1,14 +0,0 @@
|
||||
@extends('admin.layout')
|
||||
|
||||
@section('pageName', @trans('admin/fileManager.newFile'))
|
||||
|
||||
@section('content')
|
||||
|
||||
<div class="row">
|
||||
<h2>@lang('admin/fileManager.new')</h2>
|
||||
</div>
|
||||
|
||||
<div class="row">
|
||||
@include('admin.fileManager.newFileForm')
|
||||
</div>
|
||||
@stop
|
||||
@@ -1,48 +1,71 @@
|
||||
@extends('admin.layout')
|
||||
|
||||
@section('pageName', @trans('admin/fileManager.overview'))
|
||||
@if ($directory->id)
|
||||
@section('pageName', @trans('admin/fileManager.directories', ['directory' => $directory->name]))
|
||||
@else
|
||||
@section('pageName', @trans('admin/fileManager.rootDirectories'))
|
||||
@endif
|
||||
|
||||
|
||||
@section('content')
|
||||
|
||||
<div class="row">
|
||||
<h2>@lang('admin/fileManager.overview')</h2>
|
||||
<h2>
|
||||
@if ($directory->id)
|
||||
@lang('admin/fileManager.directories', ['directory' => $directory->name])
|
||||
@else
|
||||
@lang('admin/fileManager.rootDirectories')
|
||||
@endif
|
||||
</h2>
|
||||
</div>
|
||||
|
||||
<div class="row tile-overview" data-equalizer>
|
||||
@forelse($files as $file)
|
||||
@if (session('success'))
|
||||
<div data-alert class="callout success">
|
||||
<strong>{{ session('success') }}</strong>
|
||||
</div>
|
||||
@endif
|
||||
|
||||
<div class="columns large-2">
|
||||
<div class="item" data-equalizer-watch>
|
||||
<div class="preview row" title="{{ \App\Helpers\FileManager::getFormattedSize($file) }}">
|
||||
<a href="{{route('upload.detail', ['id' => $file->id])}}">
|
||||
{!! \App\Helpers\FileManager::getPreview($file) !!}
|
||||
</a>
|
||||
</div>
|
||||
<div class="detail row text-center">
|
||||
<div class="highlight">
|
||||
{{str_limit($file->original_filename, 15)}}
|
||||
</div>
|
||||
<div class="small">
|
||||
{{$file->mime_type}}
|
||||
</div>
|
||||
</div>
|
||||
@if (session('error'))
|
||||
<div data-alert class="callout alert">
|
||||
<strong>{{ session('error') }}</strong>
|
||||
</div>
|
||||
@endif
|
||||
|
||||
<div class="controls row">
|
||||
<a href="{{route('upload.detail', ['id' => $file->id])}}" class="button text-center primary column large-6" title="@lang('admin/fileManager.edit')">
|
||||
<i class="fa fa-edit"></i>
|
||||
</a>
|
||||
<a href="{{route('upload.delete', ['id' => $file->id])}}" class="button text-center confirm alert column large-6" title="@lang('admin/fileManager.delete')">
|
||||
<i class="fa fa-remove"></i>
|
||||
</a>
|
||||
</div>
|
||||
<div class="columns large-8">
|
||||
<div class="row">
|
||||
@include('admin.fileManager.directories.subdirectoriesTiles')
|
||||
</div>
|
||||
<div class="row">
|
||||
@include('admin.fileManager.filesTiles')
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="column large-4">
|
||||
<ul class="accordion" data-accordion data-allow-all-closed="true">
|
||||
<li class="accordion-item is-active" data-accordion-item>
|
||||
<a href="#" class="accordion-title">@lang('admin/fileManager.newFile')</a>
|
||||
|
||||
<div class="accordion-content" data-tab-content>
|
||||
@include('admin.fileManager.newFileForm')
|
||||
</div>
|
||||
</div>
|
||||
@empty
|
||||
<em>@lang('admin/fileManager.noFiles')</em>
|
||||
@endforelse
|
||||
</div>
|
||||
</li>
|
||||
<li class="accordion-item" data-accordion-item>
|
||||
<a href="#" class="accordion-title">@lang('admin/fileManager.newDirectory')</a>
|
||||
|
||||
<div class="row">
|
||||
{!! $files->render() !!}
|
||||
<div class="accordion-content" data-tab-content>
|
||||
@include('admin.fileManager.directories.newForm')
|
||||
</div>
|
||||
</li>
|
||||
|
||||
@if ($directory->id)
|
||||
<li class="accordion-item" data-accordion-item>
|
||||
<a href="#" class="accordion-title">@lang('admin/fileManager.editDirectory')</a>
|
||||
|
||||
<div class="accordion-content" data-tab-content>
|
||||
@include('admin.fileManager.directories.editForm')
|
||||
</div>
|
||||
</li>
|
||||
@endif
|
||||
|
||||
</ul>
|
||||
</div>
|
||||
@stop
|
||||
Reference in New Issue
Block a user