Re-ordered and updated main settings page

This commit is contained in:
Dan Brown 2019-02-16 14:17:35 +00:00
parent 3286f29a61
commit a112c11df8
No known key found for this signature in database
GPG Key ID: 46D9F943C24A2EF9
3 changed files with 116 additions and 99 deletions

View File

@ -1,5 +1,6 @@
<?php namespace BookStack\Http\Controllers;
use BookStack\Auth\User;
use BookStack\Uploads\ImageService;
use Illuminate\Http\Request;
use Illuminate\Http\Response;
@ -19,7 +20,10 @@ class SettingController extends Controller
// Get application version
$version = trim(file_get_contents(base_path('version')));
return view('settings/index', ['version' => $version]);
return view('settings.index', [
'version' => $version,
'guestUser' => User::getDefault()
]);
}
/**
@ -57,7 +61,7 @@ class SettingController extends Controller
// Get application version
$version = trim(file_get_contents(base_path('version')));
return view('settings/maintenance', ['version' => $version]);
return view('settings.maintenance', ['version' => $version]);
}
/**

View File

@ -12,12 +12,18 @@ return [
'settings_save_success' => 'Settings saved',
// App Settings
'app_settings' => 'App Settings',
'app_customization' => 'Customization',
'app_features_security' => 'Features & Security',
'app_name' => 'Application name',
'app_name_desc' => 'This name is shown in the header and in any system-sent emails.',
'app_name_header' => 'Show name in header',
'app_public_access' => 'Public access',
'app_public_access_desc' => 'Enabling this option will allow visitors, that are not logged-in, to access content in your BookStack instance.',
'app_public_access_desc_guest' => 'Access for public visitors can be controlled through the "Guest" user.',
'app_public_access_toggle' => 'Allow public access',
'app_public_viewing' => 'Allow public viewing?',
'app_secure_images' => 'Enable higher security image uploads?',
'app_secure_images' => 'Higher security image uploads',
'app_secure_images_toggle' => 'Enable higher security image uploads',
'app_secure_images_desc' => 'For performance reasons, all images are public. This option adds a random, hard-to-guess string in front of image urls. Ensure directory indexes are not enabled to prevent easy access.',
'app_editor' => 'Page editor',
'app_editor_desc' => 'Select which editor will be used by all users to edit pages.',
@ -31,14 +37,16 @@ return [
'app_homepage_desc' => 'Select a view to show on the homepage instead of the default view. Page permissions are ignored for selected pages.',
'app_homepage_select' => 'Select a page',
'app_disable_comments' => 'Disable comments',
'app_disable_comments_desc' => 'Disable comments across all pages in the application. Existing comments are not shown.',
'app_disable_comments_desc' => 'Disables comments across all pages in the application. <br> Existing comments are not shown.',
// Registration Settings
'reg_settings' => 'Registration Settings',
'reg_allow' => 'Allow registration?',
'reg_settings' => 'Registration',
'reg_enable' => 'Enable registration',
'reg_enable_desc' => 'When registration is enabled user will be able to sign themselves up as an application user. Upon registration they are given a single, default user role.',
'reg_default_role' => 'Default user role after registration',
'reg_confirm_email' => 'Require email confirmation?',
'reg_confirm_email_desc' => 'If domain restriction is used then email confirmation will be required and the below value will be ignored.',
'reg_email_confirmation' => 'Email confirmation',
'reg_email_confirmation_toggle' => 'Require email confirmation',
'reg_confirm_email_desc' => 'If domain restriction is used then email confirmation will be required and this option will be ignored.',
'reg_confirm_restrict_domain' => 'Restrict registration to domain',
'reg_confirm_restrict_domain_desc' => 'Enter a comma separated list of email domains you would like to restrict registration to. Users will be sent an email to confirm their address before being allowed to interact with the application. <br> Note that users will be able to change their email addresses after successful registration.',
'reg_confirm_restrict_domain_placeholder' => 'No restriction set',

View File

@ -1,14 +1,11 @@
@extends('simple-layout')
{{--TODO - Reorder--}}
@section('body')
<div class="container small">
<div class="grid left-focus v-center">
<div class="py-m">
@include('settings/navbar', ['selected' => 'settings'])
@include('settings.navbar', ['selected' => 'settings'])
</div>
<div class="text-right mb-l px-m">
<br>
@ -16,8 +13,72 @@
</div>
</div>
<div class="card content-wrap">
<h2 class="list-heading">{{ trans('settings.app_settings') }}</h2>
<div class="card content-wrap auto-height">
<h2 class="list-heading">{{ trans('settings.app_features_security') }}</h2>
<form action="{{ baseUrl("/settings") }}" method="POST">
{!! csrf_field() !!}
<div class="setting-list">
<div class="grid half large-gap">
<div>
<label for="setting-app-public" class="setting-list-label">{{ trans('settings.app_public_access') }}</label>
<p class="small">{!! trans('settings.app_public_access_desc') !!}</p>
@if(userCan('users-manage'))
<p class="small mb-none">
<a href="{{ baseUrl($guestUser->getEditUrl()) }}">{!! trans('settings.app_public_access_desc_guest') !!}</a>
</p>
@endif
</div>
<div>
@include('components.toggle-switch', [
'name' => 'setting-app-public',
'value' => setting('app-public'),
'label' => trans('settings.app_public_access_toggle'),
])
</div>
</div>
<div class="grid half large-gap">
<div>
<label class="setting-list-label">{{ trans('settings.app_secure_images') }}</label>
<p class="small">{{ trans('settings.app_secure_images_desc') }}</p>
</div>
<div>
@include('components.toggle-switch', [
'name' => 'setting-app-secure-images',
'value' => setting('app-secure-images'),
'label' => trans('settings.app_secure_images_toggle'),
])
</div>
</div>
<div class="grid half large-gap">
<div>
<label class="setting-list-label">{{ trans('settings.app_disable_comments') }}</label>
<p class="small">{!! trans('settings.app_disable_comments_desc') !!}</p>
</div>
<div>
@include('components.toggle-switch', [
'name' => 'setting-app-disable-comments',
'value' => setting('app-disable-comments'),
'label' => trans('settings.app_disable_comments'),
])
</div>
</div>
</div>
<div class="form-group text-right">
<button type="submit" class="button primary">{{ trans('settings.settings_save') }}</button>
</div>
</form>
</div>
<div class="card content-wrap auto-height">
<h2 class="list-heading">{{ trans('settings.app_customization') }}</h2>
<form action="{{ baseUrl("/settings") }}" method="POST">
{!! csrf_field() !!}
@ -38,51 +99,6 @@
</div>
</div>
<div class="grid half large-gap">
<div>
<label for="setting-app-public" class="setting-list-label">{{ trans('settings.app_public_viewing') }}</label>
{{--<p class="small">{{ trans('settings.app_name_desc') }}</p>--}}
</div>
<div>
@include('components.toggle-switch', [
'name' => 'setting-app-public',
'value' => setting('app-public'),
'label' => trans('settings.app_public_viewing'),
])
{{--TODO - Text --}}
</div>
</div>
<div class="grid half large-gap">
<div>
<label class="setting-list-label">{{ trans('settings.app_secure_images') }}</label>
<p class="small">{{ trans('settings.app_secure_images_desc') }}</p>
</div>
<div>
@include('components.toggle-switch', [
'name' => 'setting-app-secure-images',
'value' => setting('app-secure-images'),
'label' => trans('settings.app_secure_images'),
])
{{--TODO - Text --}}
</div>
</div>
<div class="grid half large-gap">
<div>
<label class="setting-list-label">{{ trans('settings.app_disable_comments') }}</label>
<p class="small">{{ trans('settings.app_disable_comments_desc') }}</p>
</div>
<div>
@include('components.toggle-switch', [
'name' => 'setting-app-disable-comments',
'value' => setting('app-disable-comments'),
'label' => trans('settings.app_disable_comments'),
])
{{--TODO - Text --}}
</div>
</div>
<div class="grid half large-gap">
<div>
<label class="setting-list-label">{{ trans('settings.app_editor') }}</label>
@ -93,14 +109,13 @@
<option @if(setting('app-editor') === 'wysiwyg') selected @endif value="wysiwyg">WYSIWYG</option>
<option @if(setting('app-editor') === 'markdown') selected @endif value="markdown">Markdown</option>
</select>
{{--TODO - Text --}}
</div>
</div>
<div class="grid half large-gap">
<div>
<label class="setting-list-label">{{ trans('settings.app_logo') }}</label>
<p class="small">{{ trans('settings.app_logo_desc') }}</p>
<p class="small">{!! trans('settings.app_logo_desc') !!}</p>
</div>
<div>
@include('components.image-picker', [
@ -162,8 +177,7 @@
</form>
</div>
<div class="card content-wrap">
<div class="card content-wrap auto-height">
<h2 class="list-heading">{{ trans('settings.reg_settings') }}</h2>
<form action="{{ baseUrl("/settings") }}" method="POST">
{!! csrf_field() !!}
@ -171,25 +185,17 @@
<div class="setting-list">
<div class="grid half large-gap">
<div>
<label class="setting-list-label">{{ trans('settings.reg_allow') }}</label>
{{--<p class="small">{!! trans('settings.app_primary_color_desc') !!}</p>--}}{{-- TODO--}}
<label class="setting-list-label">{{ trans('settings.reg_enable') }}</label>
<p class="small">{!! trans('settings.reg_enable_desc') !!}</p>
</div>
<div>
@include('components.toggle-switch', [
'name' => 'setting-registration-enabled',
'value' => setting('registration-enabled'),
'label' => trans('settings.reg_allow')
'label' => trans('settings.reg_enable')
])
{{--TODO - label --}}
</div>
</div>
<div class="grid half large-gap">
<div>
<label for="setting-registration-role" class="setting-list-label">{{ trans('settings.reg_default_role') }}</label>
{{--<p class="small">{!! trans('settings.app_primary_color_desc') !!}</p>--}}{{-- TODO--}}
</div>
<div>
<label for="setting-registration-role">{{ trans('settings.reg_default_role') }}</label>
<select id="setting-registration-role" name="setting-registration-role" @if($errors->has('setting-registration-role')) class="neg" @endif>
@foreach(\BookStack\Auth\Role::all() as $role)
<option value="{{$role->id}}" data-role-name="{{ $role->name }}"
@ -202,21 +208,6 @@
</div>
</div>
<div class="grid half large-gap">
<div>
<label class="setting-list-label">{{ trans('settings.reg_confirm_email') }}</label>
<p class="small">{{ trans('settings.reg_confirm_email_desc') }}</p>
</div>
<div>
@include('components.toggle-switch', [
'name' => 'setting-registration-confirmation',
'value' => setting('registration-confirmation'),
'label' => trans('settings.reg_confirm_email')
])
{{--TODO - label --}}
</div>
</div>
<div class="grid half large-gap">
<div>
<label for="setting-registration-restrict" class="setting-list-label">{{ trans('settings.reg_confirm_restrict_domain') }}</label>
@ -226,6 +217,21 @@
<input type="text" id="setting-registration-restrict" name="setting-registration-restrict" placeholder="{{ trans('settings.reg_confirm_restrict_domain_placeholder') }}" value="{{ setting('registration-restrict', '') }}">
</div>
</div>
<div class="grid half large-gap">
<div>
<label class="setting-list-label">{{ trans('settings.reg_email_confirmation') }}</label>
<p class="small">{{ trans('settings.reg_confirm_email_desc') }}</p>
</div>
<div>
@include('components.toggle-switch', [
'name' => 'setting-registration-confirmation',
'value' => setting('registration-confirmation'),
'label' => trans('settings.reg_email_confirmation_toggle')
])
</div>
</div>
</div>
<div class="form-group text-right">
@ -241,24 +247,23 @@
@stop
@section('scripts')
{{--TODO - Merge into JS--}}
<script src="{{ baseUrl("/libs/jq-color-picker/tiny-color-picker.min.js?version=1.0.0") }}"></script>
<script type="text/javascript">
$('#setting-app-color').colorPicker({
opacity: false,
renderCallback: function($elm, toggled) {
var hexVal = '#' + this.color.colors.HEX;
var rgb = this.color.colors.RND.rgb;
var rgbLightVal = 'rgba('+ [rgb.r, rgb.g, rgb.b, '0.15'].join(',') +')';
const hexVal = '#' + this.color.colors.HEX;
const rgb = this.color.colors.RND.rgb;
const rgbLightVal = 'rgba('+ [rgb.r, rgb.g, rgb.b, '0.15'].join(',') +')';
// Set textbox color to hex color code.
var isEmpty = $.trim($elm.val()).length === 0;
const isEmpty = $.trim($elm.val()).length === 0;
if (!isEmpty) $elm.val(hexVal);
$('#setting-app-color-light').val(isEmpty ? '' : rgbLightVal);
var customStyles = document.getElementById('custom-styles');
var oldColor = customStyles.getAttribute('data-color');
var oldColorLight = customStyles.getAttribute('data-color-light');
const customStyles = document.getElementById('custom-styles');
const oldColor = customStyles.getAttribute('data-color');
const oldColorLight = customStyles.getAttribute('data-color-light');
customStyles.innerHTML = customStyles.innerHTML.split(oldColor).join(hexVal);
customStyles.innerHTML = customStyles.innerHTML.split(oldColorLight).join(rgbLightVal);