committed by
Graham Campbell
parent
2790218530
commit
b6596e722d
@@ -59,5 +59,24 @@ body.dashboard {
|
||||
padding: 8px 0;
|
||||
}
|
||||
}
|
||||
|
||||
.user-grid {
|
||||
.user {
|
||||
img {
|
||||
border-radius: 5px;
|
||||
margin-bottom: 15px;
|
||||
border: 0;
|
||||
}
|
||||
|
||||
.name {
|
||||
font-weight: 600;
|
||||
}
|
||||
|
||||
.email {
|
||||
color: #444;
|
||||
margin-top: 4px;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -49,6 +49,8 @@ return [
|
||||
'metrics-add' => 'Add Metric Point',
|
||||
'status_page' => 'Status Page',
|
||||
'settings' => 'Settings',
|
||||
'team' => 'Team Members',
|
||||
'team-add' => 'Add Team Member',
|
||||
'notifications' => 'Notifications',
|
||||
'toggle_navigation' => 'Toggle Navigation',
|
||||
'search' => 'Search...',
|
||||
|
||||
@@ -28,6 +28,13 @@ Route::group(['before' => 'auth', 'prefix' => 'dashboard', 'namespace' => 'Cache
|
||||
// Notifications
|
||||
Route::get('notifications', ['as' => 'dashboard.notifications', 'uses' => 'DashboardController@showNotifications']);
|
||||
|
||||
// Team Members
|
||||
Route::get('team', ['as' => 'dashboard.team', 'uses' => 'DashboardController@showTeamView']);
|
||||
Route::get('team/add', ['as' => 'dashboard.team.add', 'uses' => 'DashboardController@showAddTeamMemberView']);
|
||||
Route::get('team/{user}', 'DashboardController@showTeamMemberView');
|
||||
Route::post('team/add', 'DashboardController@postAddUser');
|
||||
Route::post('team/{user}', 'DashboardController@postUpdateUser');
|
||||
|
||||
// Settings
|
||||
Route::get('settings/setup', ['as' => 'dashboard.settings.setup', 'uses' => 'DashSettingsController@showSetupView']);
|
||||
Route::get('settings/security', ['as' => 'dashboard.settings.security', 'uses' => 'DashSettingsController@showSecurityView']);
|
||||
@@ -37,7 +44,7 @@ Route::group(['before' => 'auth', 'prefix' => 'dashboard', 'namespace' => 'Cache
|
||||
|
||||
// User Settings
|
||||
Route::get('user', ['as' => 'dashboard.user', 'uses' => 'DashUserController@showUser']);
|
||||
Route::get('/user/{user}/api/regen', 'DashUserController@regenerateApiKey');
|
||||
Route::get('user/{user}/api/regen', 'DashUserController@regenerateApiKey');
|
||||
Route::post('user', 'DashUserController@postUser');
|
||||
|
||||
// Internal API.
|
||||
|
||||
46
app/views/dashboard/team/edit.blade.php
Normal file
46
app/views/dashboard/team/edit.blade.php
Normal file
@@ -0,0 +1,46 @@
|
||||
@extends('layout.dashboard')
|
||||
|
||||
@section('content')
|
||||
<div class="header">
|
||||
<span class='uppercase'>
|
||||
<i class="ion ion-person"></i> {{ trans('cachet.dashboard.user') }}
|
||||
</span>
|
||||
</div>
|
||||
<div class='content-wrapper'>
|
||||
<div class="row">
|
||||
<div class="col-sm-12">
|
||||
@if($updated = Session::get('updated'))
|
||||
<div class='alert alert-{{ $updated ? "success" : "danger" }}'>
|
||||
@if($updated)
|
||||
<strong>Awesome.</strong> Profile updated.
|
||||
@else
|
||||
<strong>Whoops.</strong> Something went wrong when updating.
|
||||
@endif
|
||||
</div>
|
||||
@endif
|
||||
|
||||
<form name='UserForm' class='form-vertical' role='form' action='/dashboard/team/{{ $user->id }}' method='POST'>
|
||||
<fieldset>
|
||||
<div class='form-group'>
|
||||
<label>Username</label>
|
||||
<input type='text' class='form-control' name='username' value='{{ $user->username }}' required />
|
||||
</div>
|
||||
<div class='form-group'>
|
||||
<label>Email Address</label>
|
||||
<input type='email' class='form-control' name='email' value='{{ $user->email }}' required />
|
||||
</div>
|
||||
<div class='form-group'>
|
||||
<label>Password</label>
|
||||
<input type='password' class='form-control' name='password' value='' />
|
||||
</div>
|
||||
</fieldset>
|
||||
|
||||
<button type="submit" class="btn btn-success">Update profile</button>
|
||||
@if(Auth::user()->isAdmin)
|
||||
<a class='btn btn-danger' href='/dashboard/user/{{ $user->id }}/api/regen'>Revoke API Key</a>
|
||||
@endif
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@stop
|
||||
32
app/views/dashboard/team/index.blade.php
Normal file
32
app/views/dashboard/team/index.blade.php
Normal file
@@ -0,0 +1,32 @@
|
||||
@extends('layout.dashboard')
|
||||
|
||||
@section('content')
|
||||
<div class="header fixed">
|
||||
<span class="uppercase">
|
||||
<i class="icon icon ion-android-alert"></i> {{ trans('cachet.dashboard.team') }}
|
||||
</span>
|
||||
<a class="btn btn-sm btn-success pull-right" href="{{ route('dashboard.team.add') }}">
|
||||
{{ trans('cachet.dashboard.team-add') }}
|
||||
</a>
|
||||
<div class="clearfix"></div>
|
||||
</div>
|
||||
<div class="content-wrapper">
|
||||
<div class="row">
|
||||
<div class="col-sm-12">
|
||||
<p class='lead'>Team Members will be able to add, modify & edit components and incidents.</p>
|
||||
|
||||
<div class='user-grid'>
|
||||
@foreach($teamMembers as $member)
|
||||
<div class='user col-sm-3 col-xs-6'>
|
||||
<a href='/dashboard/team/{{ $member->id }}'>
|
||||
<img src='{{ $member->gravatar }}' />
|
||||
</a>
|
||||
<div class='name'>{{ $member->username }}</div>
|
||||
<div class='email'>{{ $member->email }}</div>
|
||||
</div>
|
||||
@endforeach
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@stop
|
||||
43
app/views/dashboard/team/new.blade.php
Normal file
43
app/views/dashboard/team/new.blade.php
Normal file
@@ -0,0 +1,43 @@
|
||||
@extends('layout.dashboard')
|
||||
|
||||
@section('content')
|
||||
<div class="header">
|
||||
<span class='uppercase'>
|
||||
<i class="ion ion-person"></i> {{ trans('cachet.dashboard.user') }}
|
||||
</span>
|
||||
</div>
|
||||
<div class='content-wrapper'>
|
||||
<div class="row">
|
||||
<div class="col-sm-12">
|
||||
@if($created = Session::get('created'))
|
||||
<div class='alert alert-success'>
|
||||
<strong>Awesome.</strong> New user has been created.
|
||||
</div>
|
||||
@elseif($errors = Session::get('errors'))
|
||||
<div class='alert alert-danger'>
|
||||
<strong>Whoops.</strong> Something went wrong: {{ $errors }}
|
||||
</div>
|
||||
@endif
|
||||
|
||||
<form name='UserForm' class='form-vertical' role='form' action='/dashboard/team/add' method='POST'>
|
||||
<fieldset>
|
||||
<div class='form-group'>
|
||||
<label>Username</label>
|
||||
<input type='text' class='form-control' name='username' value='{{ Input::old("username") }}' required />
|
||||
</div>
|
||||
<div class='form-group'>
|
||||
<label>Email Address</label>
|
||||
<input type='email' class='form-control' name='email' value='{{ Input::old("email") }}' required />
|
||||
</div>
|
||||
<div class='form-group'>
|
||||
<label>Password</label>
|
||||
<input type='password' class='form-control' name='password' value='' />
|
||||
</div>
|
||||
</fieldset>
|
||||
|
||||
<button type="submit" class="btn btn-success">Create member</button>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@stop
|
||||
@@ -48,6 +48,11 @@
|
||||
<span>{{ trans('cachet.dashboard.components') }}</span>
|
||||
</a>
|
||||
</li>
|
||||
<li {{ set_active('dashboard/team*') }}>
|
||||
<a href="{{ route('dashboard.team') }}">
|
||||
<i class="icons ion-ios-people"></i> {{ trans('cachet.dashboard.team') }}
|
||||
</a>
|
||||
</li>
|
||||
{{-- <li {{ set_active('dashboard/metrics') }}>
|
||||
<a href="{{ route('dashboard.metrics') }}">
|
||||
<i class="ion ion-stats-bats"></i> {{ trans('cachet.dashboard.metrics') }}
|
||||
|
||||
@@ -3,7 +3,10 @@
|
||||
namespace CachetHQ\Cachet\Http\Controllers;
|
||||
|
||||
use CachetHQ\Cachet\Models\Component;
|
||||
use CachetHQ\Cachet\Models\User;
|
||||
use GrahamCampbell\Binput\Facades\Binput;
|
||||
use Illuminate\Routing\Controller;
|
||||
use Illuminate\Support\Facades\Redirect;
|
||||
use Illuminate\Support\Facades\View;
|
||||
|
||||
class DashboardController extends Controller
|
||||
@@ -23,6 +26,80 @@ class DashboardController extends Controller
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Shows the team members view.
|
||||
*
|
||||
* @return \Illuminate\View\View
|
||||
*/
|
||||
public function showTeamView()
|
||||
{
|
||||
$team = User::all();
|
||||
|
||||
return View::make('dashboard.team.index')->with([
|
||||
'pageTitle' => 'Team Members - Dashboard',
|
||||
'teamMembers' => $team,
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Shows the edit team member view.
|
||||
*
|
||||
* @return \Illuminate\View\View
|
||||
*/
|
||||
public function showTeamMemberView(User $user)
|
||||
{
|
||||
return View::make('dashboard.team.edit')->with([
|
||||
'pageTitle' => 'Edit User - Dashboard',
|
||||
'user' => $user,
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Shows the add team member view.
|
||||
*
|
||||
* @return \Illuminate\View\View
|
||||
*/
|
||||
public function showAddTeamMemberView()
|
||||
{
|
||||
return View::make('dashboard.team.new')->with([
|
||||
'pageTitle' => 'Add User - Dashboard',
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a new team member.
|
||||
*
|
||||
* @return \Illuminate\Http\RedirectResponse
|
||||
*/
|
||||
public function postAddUser()
|
||||
{
|
||||
$user = User::create(Binput::all());
|
||||
|
||||
if ($user->isValid()) {
|
||||
return Redirect::back()->with('created', $user->isValid());
|
||||
} else {
|
||||
return Redirect::back()
|
||||
->withInput(Binput::except('password'))
|
||||
->with('errors', $user->getErrors());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Updates a user.
|
||||
*
|
||||
* @param \CachetHQ\Cachet\Models\User $user
|
||||
*
|
||||
* @return \Illuminate\View\View
|
||||
*/
|
||||
public function postUpdateUser(User $user)
|
||||
{
|
||||
$items = Binput::all();
|
||||
|
||||
$updated = $user->update($items);
|
||||
|
||||
return Redirect::back()->with('updated', $updated);
|
||||
}
|
||||
|
||||
/**
|
||||
* Shows the metrics view.
|
||||
*
|
||||
|
||||
@@ -9,6 +9,7 @@ use Illuminate\Auth\UserTrait;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\ModelNotFoundException;
|
||||
use Illuminate\Support\Facades\Hash;
|
||||
use Watson\Validating\ValidatingTrait;
|
||||
|
||||
/**
|
||||
* @property int $id
|
||||
@@ -23,7 +24,18 @@ use Illuminate\Support\Facades\Hash;
|
||||
*/
|
||||
class User extends Model implements UserInterface, RemindableInterface
|
||||
{
|
||||
use UserTrait, RemindableTrait;
|
||||
use RemindableTrait, UserTrait, ValidatingTrait;
|
||||
|
||||
/**
|
||||
* The validation rules.
|
||||
*
|
||||
* @var string[]
|
||||
*/
|
||||
protected $rules = [
|
||||
'username' => 'required|alpha|unique:users',
|
||||
'email' => 'required|email|unique:users',
|
||||
'password' => 'required',
|
||||
];
|
||||
|
||||
/**
|
||||
* The hidden properties.
|
||||
@@ -37,7 +49,7 @@ class User extends Model implements UserInterface, RemindableInterface
|
||||
/**
|
||||
* The properties that cannot be mass assigned.
|
||||
*
|
||||
* @var array
|
||||
* @var string[]
|
||||
*/
|
||||
protected $guarded = [];
|
||||
|
||||
@@ -111,4 +123,14 @@ class User extends Model implements UserInterface, RemindableInterface
|
||||
{
|
||||
return str_random(20);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns whether a user is at admin level.
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function getIsAdminAttribute()
|
||||
{
|
||||
return (bool) $this->level;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user