From b03ab47039e00873e06f79776f4d999a6b4c43bb Mon Sep 17 00:00:00 2001 From: Andy Heathershaw Date: Fri, 14 Sep 2018 11:14:39 +0100 Subject: [PATCH] #71: The settings screen is now hooked up to the rebuildPermissionsCache method on the Admin\DefaultController --- app/Http/Controllers/Admin/DefaultController.php | 5 +++++ resources/assets/js/admin.js | 12 ++++++++---- resources/lang/en/admin.php | 2 ++ .../views/themes/base/admin/settings.blade.php | 14 ++++++++++---- 4 files changed, 25 insertions(+), 8 deletions(-) diff --git a/app/Http/Controllers/Admin/DefaultController.php b/app/Http/Controllers/Admin/DefaultController.php index ad75047..a797918 100644 --- a/app/Http/Controllers/Admin/DefaultController.php +++ b/app/Http/Controllers/Admin/DefaultController.php @@ -216,6 +216,11 @@ class DefaultController extends Controller return $photoController->store($request); } + public function rebuildPermissionsCache() + { + return response()->json(true); + } + public function saveSettings(SaveSettingsRequest $request) { $this->authorizeAccessToAdminPanel('admin:configure'); diff --git a/resources/assets/js/admin.js b/resources/assets/js/admin.js index 4d948d6..d194f1b 100644 --- a/resources/assets/js/admin.js +++ b/resources/assets/js/admin.js @@ -50,7 +50,7 @@ function AboutViewModel(urls) { * This model is used by admin/settings.blade.php. * @constructor */ -function SettingsViewModel(urls) { +function SettingsViewModel(urls, lang) { this.el = '#settings-app'; this.data = { @@ -58,7 +58,7 @@ function SettingsViewModel(urls) { }; this.methods = { - rebuildPermissionsCache: function () { + rebuildPermissionsCache: function (e) { var self = this; $.ajax( @@ -69,13 +69,17 @@ function SettingsViewModel(urls) { }, dataType: 'json', error: function (xhr, textStatus, errorThrown) { + alert(lang.permissions_cache_rebuild_failed); }, - method: 'GET', + method: 'POST', success: function (data) { - alert('success'); + alert(lang.permissions_cache_rebuild_succeeded); } } ); + + e.preventDefault(); + return false; } }; } \ No newline at end of file diff --git a/resources/lang/en/admin.php b/resources/lang/en/admin.php index 3cfe68d..47df8e0 100644 --- a/resources/lang/en/admin.php +++ b/resources/lang/en/admin.php @@ -212,6 +212,8 @@ return [ 'permissions_cache' => 'Permissions Cache', 'permissions_cache_intro' => 'Blue Twilight maintains the permissions each user has to albums in the database. If you feel these aren\'t correct based on what\'s configured, you can rebuild the cache by clicking the button below.', 'rebuild_permissions_cache' => 'Rebuild Permissions Cache', + 'rebuild_permissions_cache_failed' => 'The permissions cache rebuild failed to complete. Please check the server logs.', + 'rebuild_permissions_cache_succeeded' => 'The permissions cache rebuild completed successfully.', 'security_allow_self_registration' => 'Allow self-registration', 'security_allow_self_registration_description' => 'With this option enabled, users can sign up for their own accounts. You can grant permissions to accounts to allow users to upload their own photos or manage yours.', 'social_facebook' => 'Facebook', diff --git a/resources/views/themes/base/admin/settings.blade.php b/resources/views/themes/base/admin/settings.blade.php index e16249a..63c4202 100644 --- a/resources/views/themes/base/admin/settings.blade.php +++ b/resources/views/themes/base/admin/settings.blade.php @@ -294,7 +294,7 @@
@lang('admin.settings.permissions_cache')

@lang('admin.settings.permissions_cache_intro')

- +
@@ -491,9 +491,15 @@ @push('scripts')