Browse Source

#99: Added a basic user profile settings screen

tags/v2.2.0-beta.1
Andy Heathershaw 1 year ago
parent
commit
4a54544756
6 changed files with 94 additions and 4 deletions
  1. +7
    -0
      app/Http/Controllers/Gallery/UserController.php
  2. +5
    -0
      resources/lang/en/gallery.php
  3. +2
    -1
      resources/lang/en/navigation.php
  4. +70
    -0
      resources/views/themes/base/gallery/user_settings.blade.php
  5. +2
    -1
      resources/views/themes/base/partials/navbar.blade.php
  6. +8
    -2
      routes/web.php

+ 7
- 0
app/Http/Controllers/Gallery/UserController.php View File

@@ -15,6 +15,13 @@ use Symfony\Component\HttpFoundation\Request;

class UserController extends Controller
{
public function settings(Request $request)
{
return Theme::render('gallery.user_settings', [
'user' => $this->getUser()
]);
}

public function show(Request $request, $idOrAlias)
{
// If a user has a profile alias set, their profile page cannot be accessed by the ID


+ 5
- 0
resources/lang/en/gallery.php View File

@@ -77,5 +77,10 @@ return [
'cameras' => 'Cameras',
'no_albums_p1' => 'No Photo Albums',
'no_albums_p2' => ':user_name has not created any albums yet.'
],
'user_settings' => [
'change_password' => 'Change password',
'show_public_profile' => 'Allow others to see my profile page',
'title' => 'Change my settings'
]
];

+ 2
- 1
resources/lang/en/navigation.php View File

@@ -36,6 +36,7 @@ return [
'public_profile_page' => 'My public profile',
'quick_post' => 'Quick Upload',
'register' => 'Register',
'statistics' => 'Statistics'
'statistics' => 'Statistics',
'user_settings' => 'Change my settings'
]
];

+ 70
- 0
resources/views/themes/base/gallery/user_settings.blade.php View File

@@ -0,0 +1,70 @@
@extends(Theme::viewName('layout'))
@section('title', trans('gallery.user_settings.title'))

@section('content')
<div class="container">
<div class="row">
<div class="col-md-8 mr-md-auto ml-md-auto">
<div class="card">
<div class="card-header">
<ul class="nav nav-tabs card-header-tabs">
<li class="nav-item">
<a class="nav-link active" href="{{ url('/password/change') }}">@yield('title')</a>
</li>
</ul>
</div>
<div class="card-body">
<form action="{{ route('saveUserSettings') }}" method="post">
{{ csrf_field() }}
{{ method_field('PUT') }}

<div class="form-group row{{ $errors->has('name') ? ' has-danger' : '' }}">
<label class="col-md-4 col-form-label text-md-right" for="user-name">@lang('forms.name_label')</label>

<div class="col-md-6">
<input type="text" class="form-control{{ $errors->has('name') ? ' is-invalid' : '' }}" id="user-name" name="name" value="{{ old('name', $user->name) }}">

@if ($errors->has('name'))
<div class="invalid-feedback">
<strong>{{ $errors->first('name') }}</strong>
</div>
@endif
</div>
</div>

<div class="form-group row{{ $errors->has('email') ? ' has-danger' : '' }}">
<label class="col-md-4 col-form-label text-md-right" for="user-email">@lang('forms.email_label')</label>

<div class="col-md-6">
<input type="text" class="form-control{{ $errors->has('email') ? ' is-invalid' : '' }}" id="user-email" name="email" value="{{ old('email', $user->email) }}">

@if ($errors->has('email'))
<div class="invalid-feedback">
<strong>{{ $errors->first('email') }}</strong>
</div>
@endif
</div>
</div>

<div class="row">
<div class="col-md-6 offset-md-4">
<a href="{{ route('auth.changePassword') }}" class="btn btn-link"><i class="fa fa-lock"></i>&nbsp;&nbsp;@lang('gallery.user_settings.change_password')</a>
</div>
</div>

<div class="form-check mt-4">
<input type="checkbox" class="form-check-input" id="is-admin" name="is_admin"@if (old('is_admin', $user->is_admin)) checked="checked"@endif>
<label class="form-check-label" for="is-admin">@lang('forms.admin_user_label')</label>
</div>

<div class="text-right" style="margin-top: 20px;">
<a href="{{ route('home') }}" class="btn btn-link">@lang('forms.cancel_action')</a>
<button type="submit" class="btn btn-success"><i class="fa fa-fw fa-check"></i> @lang('forms.save_action')</button>
</div>
</form>
</div>
</div>
</div>
</div>
</div>
@endsection

+ 2
- 1
resources/views/themes/base/partials/navbar.blade.php View File

@@ -78,8 +78,9 @@
<div class="dropdown-menu dropdown-menu-right">
@if (UserConfig::get('social_user_profiles') && Auth::user()->enable_profile_page)
<a class="dropdown-item" href="{{ Auth::user()->profileUrl() }}">@lang('navigation.navbar.public_profile_page')</a>
<div class="dropdown-divider"></div>
@endif
<a class="dropdown-item" href="{{ route('userSettings') }}">@lang('navigation.navbar.user_settings')</a>
<div class="dropdown-divider"></div>
<a class="dropdown-item" href="{{ route('auth.changePassword') }}">@lang('navigation.navbar.change_password')</a>
<a class="dropdown-item" href="{{ url('/logout') }}" onclick="event.preventDefault(); document.getElementById('logout-form').submit();">@lang('navigation.navbar.logout')</a>
<form id="logout-form" action="{{ url('/logout') }}" method="POST" style="display: none;">


+ 8
- 2
routes/web.php View File

@@ -104,6 +104,12 @@ Route::get('i/{albumUrlAlias}/{photoFilename}', 'Gallery\PhotoController@downloa
Route::get('label/{labelAlias}', 'Gallery\LabelController@show')
->name('viewLabel')
->where('labelAlias', '.*');
Route::get('user/{idOrAlias}', 'Gallery\UserController@show')
Route::get('u/{idOrAlias}', 'Gallery\UserController@show')
->name('viewUser')
->where('idOrAlias', '.*');
->where('idOrAlias', '.*');
Route::get('me/settings', 'Gallery\UserController@settings')
->name('userSettings')
->middleware('auth');
Route::get('me/save-settings', 'Gallery\UserController@saveSettings')
->name('saveUserSettings')
->middleware('auth');

Loading…
Cancel
Save