From c2e9fe617bbed7be2fb66097115e5efca3de86cf Mon Sep 17 00:00:00 2001 From: Andy Heathershaw Date: Sun, 10 Sep 2017 15:46:16 +0100 Subject: [PATCH] #2: Added a loading animation to the quick-post/upload function whilst uploading --- .../Controllers/Admin/DefaultController.php | 21 +++++++++++++++++-- resources/lang/en/forms.php | 1 + resources/lang/en/global.php | 1 + resources/views/themes/base/layout.blade.php | 9 ++++++++ .../base/partials/quick_upload.blade.php | 7 ++++++- 5 files changed, 36 insertions(+), 3 deletions(-) diff --git a/app/Http/Controllers/Admin/DefaultController.php b/app/Http/Controllers/Admin/DefaultController.php index cc6eb8a..fb561ca 100644 --- a/app/Http/Controllers/Admin/DefaultController.php +++ b/app/Http/Controllers/Admin/DefaultController.php @@ -15,6 +15,7 @@ use App\Http\Requests\SaveSettingsRequest; use App\Label; use App\Mail\TestMailConfig; use App\Photo; +use App\Storage; use App\User; use Illuminate\Http\Request; use Illuminate\Support\Facades\App; @@ -78,8 +79,24 @@ class DefaultController extends Controller $albumID = $request->get('album_id'); if (intval($albumID) == 0) { - $request->session()->flash('error', trans('admin.quick_upload.no_album_selected')); - return redirect($returnUrl); + $albumName = trim($request->get('album_name')); + if (strlen($albumName) == 0) + { + $request->session()->flash('error', trans('admin.quick_upload.no_album_selected')); + return redirect($returnUrl); + } + + $albumViews = UserConfig::allowedAlbumViews(); + + $album = new Album(); + $album->storage_id = Storage::where('is_default', true)->first()->id; + $album->user_id = Auth::user()->id; + $album->default_view = UserConfig::get('default_album_view'); + $album->name = $albumName; + $album->description = ''; + $album->save(); + + $request->request->set('album_id', $album->id); } /** @var PhotoController $photoController */ diff --git a/resources/lang/en/forms.php b/resources/lang/en/forms.php index 2399198..2d5e15e 100644 --- a/resources/lang/en/forms.php +++ b/resources/lang/en/forms.php @@ -14,6 +14,7 @@ return [ 'cancel_action' => 'Cancel', 'continue_action' => 'Continue', 'create_action' => 'Create', + 'create_album_label' => 'Create a new album:', 'default_album_view_label' => 'Default view mode in the gallery:', 'default_storage_label' => 'Use as the default storage location for new albums', 'delete_action' => 'Delete', diff --git a/resources/lang/en/global.php b/resources/lang/en/global.php index 2954fca..20b9fca 100644 --- a/resources/lang/en/global.php +++ b/resources/lang/en/global.php @@ -15,6 +15,7 @@ return [ 'powered_by' => 'Powered by :link_startBlue Twilight:link_end - the self-hosted PHP photo gallery software.', 'quick_upload' => [ 'intro' => 'Use the quick upload feature to quickly add a new photo to an album.', + 'or' => '- or -', 'title' => 'Quick Upload' ], 'units' => [ diff --git a/resources/views/themes/base/layout.blade.php b/resources/views/themes/base/layout.blade.php index 8aadbfc..43af545 100644 --- a/resources/views/themes/base/layout.blade.php +++ b/resources/views/themes/base/layout.blade.php @@ -118,6 +118,15 @@ 'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content') } }); + + // Quick upload + $(document).ready(function() + { + $('#quick-upload-form').submit(function() + { + $('.modal-footer', '#quick-upload-modal').html('
'); + }); + }); @stack('scripts') {!! \App\Facade\UserConfig::get('analytics_code') !!} diff --git a/resources/views/themes/base/partials/quick_upload.blade.php b/resources/views/themes/base/partials/quick_upload.blade.php index 9039091..8253460 100644 --- a/resources/views/themes/base/partials/quick_upload.blade.php +++ b/resources/views/themes/base/partials/quick_upload.blade.php @@ -1,4 +1,4 @@ -
+ {{ csrf_field() }}