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',
|
'basicInfo' => 'admin.content.formParts.basicInformation',
|
||||||
'meta' => 'admin.content.formParts.metaInformation',
|
'meta' => 'admin.content.formParts.metaInformation',
|
||||||
'publication' => 'admin.content.formParts.publicationSetup',
|
'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']);
|
$sub->route('content.overview', trans('admin/mainMenu.contentPageOverview'), [], 20, ['icon' => 'fa fa-list']);
|
||||||
}, 15, ['icon' => 'fa fa-database']);
|
}, 15, ['icon' => 'fa fa-database']);
|
||||||
$menu->dropdown(trans('admin/mainMenu.fileManager'), function ($sub) {
|
$menu->route('upload.overview', trans('admin/mainMenu.fileManager'), [], 30, ['icon' => 'fa fa-folder']);
|
||||||
$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->dropdown(trans('admin/mainMenu.widgets'), function ($sub) {
|
$menu->dropdown(trans('admin/mainMenu.widgets'), function ($sub) {
|
||||||
// create list of all widget types
|
// create list of all widget types
|
||||||
$sub->dropdown(trans('admin/mainMenu.newWidget'), function ($sub) {
|
$sub->dropdown(trans('admin/mainMenu.newWidget'), function ($sub) {
|
||||||
|
|||||||
@@ -2,7 +2,6 @@
|
|||||||
namespace App\Http\Controllers\Admin;
|
namespace App\Http\Controllers\Admin;
|
||||||
|
|
||||||
use App\Http\Requests\UploadFileRequest;
|
use App\Http\Requests\UploadFileRequest;
|
||||||
use App\Http\Requests\UploadImageRequest;
|
|
||||||
use App\Models\File;
|
use App\Models\File;
|
||||||
use Symfony\Component\HttpFoundation\File\Exception\FileException;
|
use Symfony\Component\HttpFoundation\File\Exception\FileException;
|
||||||
|
|
||||||
@@ -19,10 +18,6 @@ class UploadFile extends Controller
|
|||||||
$this->file = $file;
|
$this->file = $file;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getFile()
|
|
||||||
{
|
|
||||||
return view('admin/fileManager.newFile');
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Uploads any file
|
* Uploads any file
|
||||||
@@ -47,7 +42,7 @@ class UploadFile extends Controller
|
|||||||
|
|
||||||
// upload was not performed via ajax, redirect user
|
// upload was not performed via ajax, redirect user
|
||||||
return redirect()
|
return redirect()
|
||||||
->route('upload.file')
|
->route('upload.overview', ['directory' => $request->directoryId])
|
||||||
->with('success', trans('admin/fileManager.uploadSuccessfull'));
|
->with('success', trans('admin/fileManager.uploadSuccessfull'));
|
||||||
} catch (FileException $e) {
|
} catch (FileException $e) {
|
||||||
return $this->invalidUpload('invalidFile');
|
return $this->invalidUpload('invalidFile');
|
||||||
|
|||||||
@@ -4,30 +4,46 @@ namespace App\Http\Controllers\Admin;
|
|||||||
|
|
||||||
use App\Http\Controllers\Controller;
|
use App\Http\Controllers\Controller;
|
||||||
use App\Http\Requests;
|
use App\Http\Requests;
|
||||||
|
use App\Models\Directory;
|
||||||
use App\Models\File;
|
use App\Models\File;
|
||||||
|
use Illuminate\Support\Facades\Input;
|
||||||
|
|
||||||
class UploadedFilesOverview extends Controller
|
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
|
// try to filter by given type
|
||||||
if (!is_null($type)) {
|
if (!is_null($fileType)) {
|
||||||
if (is_null($subtype))
|
if (is_null($fileSubtype)) {
|
||||||
$files = $files->where('mime_type', 'LIKE', $type.'%');
|
$files = $files->where('mime_type', 'LIKE', $fileType . '%');
|
||||||
else {
|
} else {
|
||||||
$files = $files->where('mime_type', $type.'/'.$subtype);
|
$files = $files->where('mime_type', $fileType . '/' . $fileSubtype);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$files = $files->paginate(18);
|
// include hidden directories?
|
||||||
|
$includeHidden = Input::get('hidden');
|
||||||
|
|
||||||
return view('admin.fileManager.overview', [
|
return view('admin.fileManager.overview', [
|
||||||
'direcories' => $directories,
|
'directory' => $directory,
|
||||||
'files' => $files
|
'subdirectories' => $directory->subdirectories($includeHidden),
|
||||||
|
'files' => $files->get()
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -17,7 +17,8 @@ abstract class UploadRequest extends Request
|
|||||||
{
|
{
|
||||||
// some globaly defined rules
|
// some globaly defined rules
|
||||||
$rules = [
|
$rules = [
|
||||||
'keywords' => 'max:255'
|
'keywords' => 'max:255',
|
||||||
|
'directoryId' => 'exists:directories,id'
|
||||||
];
|
];
|
||||||
|
|
||||||
// setup additional rules
|
// setup additional rules
|
||||||
|
|||||||
@@ -184,8 +184,6 @@ Route::group([
|
|||||||
->name('widgets.makeAssociation');
|
->name('widgets.makeAssociation');
|
||||||
|
|
||||||
// uploader methods
|
// uploader methods
|
||||||
Route::get('upload/file', 'UploadFile@getFile')
|
|
||||||
->name('upload.file');
|
|
||||||
Route::get('directories/new/{id?}', 'CreateNewDirectory@getNew')
|
Route::get('directories/new/{id?}', 'CreateNewDirectory@getNew')
|
||||||
->name('upload.newDirectory');
|
->name('upload.newDirectory');
|
||||||
|
|
||||||
|
|||||||
+2
-1
@@ -101,9 +101,10 @@ class File extends Model
|
|||||||
$newFile->hash_algorithm = self::HASH_ALGORITHM;
|
$newFile->hash_algorithm = self::HASH_ALGORITHM;
|
||||||
$newFile->mime_type = $file->getMimeType();
|
$newFile->mime_type = $file->getMimeType();
|
||||||
$newFile->file_size = $file->getSize();
|
$newFile->file_size = $file->getSize();
|
||||||
|
$newFile->directory_id = $request->directoryId;
|
||||||
|
|
||||||
// save optional fields
|
// save optional fields
|
||||||
$optionalFields = ['description', 'keywords', 'directory'];
|
$optionalFields = ['description', 'keywords'];
|
||||||
foreach ($optionalFields as $field) {
|
foreach ($optionalFields as $field) {
|
||||||
if ($request->has($field)) {
|
if ($request->has($field)) {
|
||||||
$newFile->$field = $request->$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'))
|
<h3>@lang('admin/fileManager.newFile')</h3>
|
||||||
<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
|
|
||||||
|
|
||||||
<form method="POST" action="{{route('upload.postFile')}}" enctype="multipart/form-data">
|
<form method="POST" action="{{route('upload.postFile')}}" enctype="multipart/form-data">
|
||||||
{!! csrf_field() !!}
|
{!! csrf_field() !!}
|
||||||
|
|
||||||
<div class="row">
|
@if(isset($directory))
|
||||||
<div class="column large-4">
|
<input type="hidden" name="directoryId" value="{{$directory->id}}" />
|
||||||
<label>
|
@endif
|
||||||
@lang('admin/fileManager.selectFile')
|
|
||||||
|
|
||||||
<input type="file" name="file" id="file" />
|
<label>
|
||||||
|
@lang('admin/fileManager.selectFile')
|
||||||
|
|
||||||
@if (isset($errors) && $errors->has('file'))
|
<input type="file" name="file" id="file" />
|
||||||
<div class="callout alert">
|
|
||||||
{{ $errors->first('file') }}
|
|
||||||
</div>
|
|
||||||
@endif
|
|
||||||
</label>
|
|
||||||
</div>
|
|
||||||
<div class="column large-8">
|
|
||||||
<label>
|
|
||||||
@lang('admin/fileManager.keywords')
|
|
||||||
|
|
||||||
<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'))
|
<input type="text" name="keywords" id="keywords" value="{{old('keywords')}}" />
|
||||||
<div class="callout alert">
|
|
||||||
{{ $errors->first('keywords') }}
|
|
||||||
</div>
|
|
||||||
@endif
|
|
||||||
</label>
|
|
||||||
|
|
||||||
<label>
|
@if (isset($errors) && $errors->has('keywords'))
|
||||||
@lang('admin/fileManager.description')
|
<div class="callout alert">
|
||||||
|
{{ $errors->first('keywords') }}
|
||||||
|
</div>
|
||||||
|
@endif
|
||||||
|
</label>
|
||||||
|
|
||||||
<textarea rows="3" name="description" id="description"></textarea>
|
<label>
|
||||||
</label>
|
@lang('admin/fileManager.description')
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div class="row text-right">
|
<textarea rows="3" name="description" id="description">{{old('description')}}</textarea>
|
||||||
<div class="column">
|
</label>
|
||||||
<button type="submit" class="button primary">@lang('admin/fileManager.upload')</button>
|
<button type="submit" class="button primary">@lang('admin/fileManager.upload')</button>
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</form>
|
</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')
|
@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')
|
@section('content')
|
||||||
|
|
||||||
<div class="row">
|
<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>
|
||||||
|
|
||||||
<div class="row tile-overview" data-equalizer>
|
@if (session('success'))
|
||||||
@forelse($files as $file)
|
<div data-alert class="callout success">
|
||||||
|
<strong>{{ session('success') }}</strong>
|
||||||
|
</div>
|
||||||
|
@endif
|
||||||
|
|
||||||
<div class="columns large-2">
|
@if (session('error'))
|
||||||
<div class="item" data-equalizer-watch>
|
<div data-alert class="callout alert">
|
||||||
<div class="preview row" title="{{ \App\Helpers\FileManager::getFormattedSize($file) }}">
|
<strong>{{ session('error') }}</strong>
|
||||||
<a href="{{route('upload.detail', ['id' => $file->id])}}">
|
</div>
|
||||||
{!! \App\Helpers\FileManager::getPreview($file) !!}
|
@endif
|
||||||
</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">
|
<div class="columns large-8">
|
||||||
<a href="{{route('upload.detail', ['id' => $file->id])}}" class="button text-center primary column large-6" title="@lang('admin/fileManager.edit')">
|
<div class="row">
|
||||||
<i class="fa fa-edit"></i>
|
@include('admin.fileManager.directories.subdirectoriesTiles')
|
||||||
</a>
|
</div>
|
||||||
<a href="{{route('upload.delete', ['id' => $file->id])}}" class="button text-center confirm alert column large-6" title="@lang('admin/fileManager.delete')">
|
<div class="row">
|
||||||
<i class="fa fa-remove"></i>
|
@include('admin.fileManager.filesTiles')
|
||||||
</a>
|
</div>
|
||||||
</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>
|
||||||
</div>
|
</li>
|
||||||
@empty
|
<li class="accordion-item" data-accordion-item>
|
||||||
<em>@lang('admin/fileManager.noFiles')</em>
|
<a href="#" class="accordion-title">@lang('admin/fileManager.newDirectory')</a>
|
||||||
@endforelse
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div class="row">
|
<div class="accordion-content" data-tab-content>
|
||||||
{!! $files->render() !!}
|
@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>
|
</div>
|
||||||
@stop
|
@stop
|
||||||
Reference in New Issue
Block a user