#71: The settings screen is now hooked up to the rebuildPermissionsCache method on the Admin\DefaultController

This commit is contained in:
Andy Heathershaw 2018-09-14 11:14:39 +01:00
parent cb3791b4da
commit b03ab47039
4 changed files with 25 additions and 8 deletions

View File

@ -216,6 +216,11 @@ class DefaultController extends Controller
return $photoController->store($request); return $photoController->store($request);
} }
public function rebuildPermissionsCache()
{
return response()->json(true);
}
public function saveSettings(SaveSettingsRequest $request) public function saveSettings(SaveSettingsRequest $request)
{ {
$this->authorizeAccessToAdminPanel('admin:configure'); $this->authorizeAccessToAdminPanel('admin:configure');

View File

@ -50,7 +50,7 @@ function AboutViewModel(urls) {
* This model is used by admin/settings.blade.php. * This model is used by admin/settings.blade.php.
* @constructor * @constructor
*/ */
function SettingsViewModel(urls) { function SettingsViewModel(urls, lang) {
this.el = '#settings-app'; this.el = '#settings-app';
this.data = { this.data = {
@ -58,7 +58,7 @@ function SettingsViewModel(urls) {
}; };
this.methods = { this.methods = {
rebuildPermissionsCache: function () { rebuildPermissionsCache: function (e) {
var self = this; var self = this;
$.ajax( $.ajax(
@ -69,13 +69,17 @@ function SettingsViewModel(urls) {
}, },
dataType: 'json', dataType: 'json',
error: function (xhr, textStatus, errorThrown) { error: function (xhr, textStatus, errorThrown) {
alert(lang.permissions_cache_rebuild_failed);
}, },
method: 'GET', method: 'POST',
success: function (data) { success: function (data) {
alert('success'); alert(lang.permissions_cache_rebuild_succeeded);
} }
} }
); );
e.preventDefault();
return false;
} }
}; };
} }

View File

@ -212,6 +212,8 @@ return [
'permissions_cache' => 'Permissions Cache', '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.', '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' => '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' => '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.', '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', 'social_facebook' => 'Facebook',

View File

@ -294,7 +294,7 @@
<fieldset> <fieldset>
<legend>@lang('admin.settings.permissions_cache')</legend> <legend>@lang('admin.settings.permissions_cache')</legend>
<p>@lang('admin.settings.permissions_cache_intro')</p> <p>@lang('admin.settings.permissions_cache_intro')</p>
<button class="btn btn-primary">@lang('admin.settings.rebuild_permissions_cache')</button> <button class="btn btn-primary" v-on:click="rebuildPermissionsCache">@lang('admin.settings.rebuild_permissions_cache')</button>
</fieldset> </fieldset>
</div> </div>
@ -491,9 +491,15 @@
@push('scripts') @push('scripts')
<script type="text/javascript"> <script type="text/javascript">
var viewModel = new SettingsViewModel({ var viewModel = new SettingsViewModel(
{
'rebuild_permissions_cache': '{{ route('admin.rebuildPermissionsCache') }}' 'rebuild_permissions_cache': '{{ route('admin.rebuildPermissionsCache') }}'
}); },
{
'permissions_cache_rebuild_failed': '@lang('admin.settings.rebuild_permissions_cache_failed')',
'permissions_cache_rebuild_succeeded': '@lang('admin.settings.rebuild_permissions_cache_succeeded')'
}
);
$(document).ready(function() { $(document).ready(function() {
var app = new Vue(viewModel); var app = new Vue(viewModel);