From 63e341199b1dd9ab7653a98d9bbf93dd74042a07 Mon Sep 17 00:00:00 2001 From: Andy Heathershaw Date: Sun, 11 Sep 2016 09:04:07 +0100 Subject: [PATCH] Implemented a better multi-file upload for browsers that support it. Started adding support for bulk modifying photos (e.g. rotating) --- .../Controllers/Admin/AlbumController.php | 7 + .../Controllers/Admin/PhotoController.php | 16 ++- resources/lang/en/admin.php | 9 ++ resources/lang/en/forms.php | 4 + .../themes/base/admin/show_album.blade.php | 136 ++++++++++++++++-- .../partials/single_photo_admin.blade.php | 4 + 6 files changed, 163 insertions(+), 13 deletions(-) diff --git a/app/Http/Controllers/Admin/AlbumController.php b/app/Http/Controllers/Admin/AlbumController.php index d7caac4..2ea0758 100644 --- a/app/Http/Controllers/Admin/AlbumController.php +++ b/app/Http/Controllers/Admin/AlbumController.php @@ -127,6 +127,13 @@ class AlbumController extends Controller return Theme::render('admin.show_album', [ 'album' => $album, + 'bulk_actions' => [ + 'rotate_left' => trans('admin.photo_actions.rotate_left'), + 'rotate_right' => trans('admin.photo_actions.rotate_right'), + '-' => '-----', + 'refresh_thumbnails' => trans('admin.photo_actions.refresh_thumbnails'), + 'delete' => trans('admin.photo_actions.delete') + ], 'error' => $request->session()->get('error'), 'photos' => $photos ]); diff --git a/app/Http/Controllers/Admin/PhotoController.php b/app/Http/Controllers/Admin/PhotoController.php index 27a8dd7..1e93620 100644 --- a/app/Http/Controllers/Admin/PhotoController.php +++ b/app/Http/Controllers/Admin/PhotoController.php @@ -184,9 +184,16 @@ class PhotoController extends Controller $photo->save(); } - return redirect(route('albums.analyse', [ - 'id' => $album->id - ])); + if ($request->isXmlHttpRequest()) + { + return response()->json(['is_successful' => true]); + } + else + { + return redirect(route('albums.analyse', [ + 'id' => $album->id + ])); + } } public function storeBulk(Request $request) @@ -303,6 +310,9 @@ class PhotoController extends Controller { $photos = $request->get('photo'); + dump($request->all()); + exit(); + /** @var Album $album */ $album = Album::where('id', intval($albumId))->first(); diff --git a/resources/lang/en/admin.php b/resources/lang/en/admin.php index 2bb677a..9176f2a 100644 --- a/resources/lang/en/admin.php +++ b/resources/lang/en/admin.php @@ -19,12 +19,21 @@ return [ 'edit_album' => 'Edit photo album: :album_name', 'edit_album_intro' => 'Photo albums contain individual photographs together in the same way as a physical photo album or memory book.', 'edit_album_intro2' => 'Complete the form below to edit the properties of the album: :album_name.', + 'upload_file_not_image_messages' => 'The file ":file_name" is not recognised as an image and won\'t be uploaded.', + 'upload_file_status_failed' => ':file_name failed to upload', + 'upload_file_status_success' => ':file_name uploaded successfully', 'manage_widget' => [ 'panel_header' => 'Manage' ], 'no_albums_text' => 'You have no photo albums yet. Click the button below to create one.', 'no_albums_title' => 'No Photo Albums', 'open_album' => 'Open album', + 'photo_actions' => [ + 'delete' => 'Delete', + 'refresh_thumbnails' => 'Refresh thumbnails', + 'rotate_left' => 'Rotate left', + 'rotate_right' => 'Rotate right' + ], 'settings_image_protection' => 'Image Protection', 'settings_link' => 'Settings', 'settings_recaptcha' => 'reCAPTCHA settings', diff --git a/resources/lang/en/forms.php b/resources/lang/en/forms.php index e072293..62cd3bd 100644 --- a/resources/lang/en/forms.php +++ b/resources/lang/en/forms.php @@ -1,5 +1,8 @@ 'Apply', + 'bulk_edit_photos_label' => 'Bulk edit selected photos:', + 'bulk_edit_photos_placeholder' => 'Select an action', 'cancel_action' => 'Cancel', 'create_action' => 'Create', 'delete_action' => 'Delete', @@ -14,6 +17,7 @@ return [ 'realname_label' => 'Your name:', 'register_action' => 'Create account', 'remember_me_label' => 'Remember me', + 'select' => 'Select', 'settings_hotlink_protection' => 'Prevent hot-linking to images', 'settings_hotlink_protection_help' => 'With this option enabled, direct linking to images is not allowed. Photos can only be viewed through Blue Twilight.', 'settings_restrict_originals_download' => 'Restrict access to original images', diff --git a/resources/views/themes/base/admin/show_album.blade.php b/resources/views/themes/base/admin/show_album.blade.php index 309f58c..6168171 100644 --- a/resources/views/themes/base/admin/show_album.blade.php +++ b/resources/views/themes/base/admin/show_album.blade.php @@ -47,6 +47,11 @@ @include (Theme::viewName('partials.single_photo_admin')) @endforeach +
+

{!! Form::label('bulk-action', trans('forms.bulk_edit_photos_label'), ['class' => 'control-label']) !!}

+ {!! Form::select('bulk-action', $bulk_actions, null, ['placeholder' => trans('forms.bulk_edit_photos_placeholder'), 'id' => 'bulk-action-apply']) !!} + +
@@ -62,20 +67,37 @@ {{-- Upload --}}
-

Upload single images

+

Upload images

- {!! Form::open(['route' => 'photos.store', 'method' => 'POST', 'files' => true]) !!} - {!! Form::hidden('album_id', $album->id) !!} +
+
+ {!! Form::open(['route' => 'photos.store', 'method' => 'POST', 'files' => true, 'id' => 'single-upload-form']) !!} + {!! Form::hidden('album_id', $album->id) !!} -
- {!! Form::file('photo[]', ['class' => 'control-label', 'multiple' => 'multiple']) !!} +
+ {!! Form::file('photo[]', ['class' => 'control-label', 'multiple' => 'multiple', 'id' => 'single-upload-files']) !!} +
+ +
+ +
+ {!! Form::close() !!} +
+ +
-
- {!! Form::submit(trans('forms.upload_action'), ['class' => 'btn btn-success']) !!} -
- {!! Form::close() !!} -

Bulk upload

@@ -108,6 +130,10 @@ @push('scripts') @endpush \ No newline at end of file diff --git a/resources/views/themes/base/partials/single_photo_admin.blade.php b/resources/views/themes/base/partials/single_photo_admin.blade.php index c2b2ba9..01a476b 100644 --- a/resources/views/themes/base/partials/single_photo_admin.blade.php +++ b/resources/views/themes/base/partials/single_photo_admin.blade.php @@ -30,6 +30,10 @@
+ +

+ +