Add a credits page to the dashboard showing the project authors and front-facing libraries used on the website, use /dashboard/edit for both the edit-list and edit-item pages, organize the dashboard styles a bit better, use relative paths instead of the url() function to render the dashboard URLs, add active nav link functionality to links other than the main dashboard pages, pull the nav blade out of the sections folder now that it's the only section, and keep the traditional template in sync

This commit is contained in:
Kevin MacMartin 2018-04-18 23:32:22 -04:00
parent 679ef84d55
commit 58902bb5ee
10 changed files with 225 additions and 130 deletions

View file

@ -11,9 +11,7 @@ use App\Models\Dashboard;
class DashboardController extends Controller { class DashboardController extends Controller {
/** /**
* Create a new controller instance. * Create a new controller instance
*
* @return void
*/ */
public function __construct() public function __construct()
{ {
@ -21,17 +19,23 @@ class DashboardController extends Controller {
} }
/** /**
* Show the application dashboard. * Show the application dashboard
*
* @return Response
*/ */
public function index() public function getIndex()
{ {
return view('dashboard.home', [ return view('dashboard.home', [
'heading' => 'Dashboard Home' 'heading' => 'Dashboard Home'
]); ]);
} }
/**
* Show the dashboard credits
*/
public function getCredits()
{
return view('dashboard.credits');
}
/** /**
* Dashboard View * Dashboard View
*/ */

View file

@ -34,6 +34,35 @@ class Dashboard
] ]
]; ];
/**
* Authors (Credits Page)
*
* @return array
*/
public static $author_credits = [
[ 'name' => 'Kevin MacMartin', 'url' => 'https://github.com/prurigro' ]
];
/**
* Libraries (Credits Page)
*
* @return array
*/
public static $library_credits = [
[ 'name' => 'Bootstrap', 'url' => 'https://getbootstrap.com' ],
[ 'name' => 'Font Awesome', 'url' => 'https://fontawesome.com' ],
[ 'name' => 'GreenSock', 'url' => 'https://greensock.com/gsap' ],
[ 'name' => 'jQuery', 'url' => 'https://jquery.org' ],
[ 'name' => 'List.js', 'url' => 'http://listjs.com' ],
[ 'name' => 'pickadate.js', 'url' => 'http://amsul.ca/pickadate.js/' ],
[ 'name' => 'Popper.js', 'url' => 'https://popper.js.org' ],
[ 'name' => 'SimpleMDE Markdown Editor', 'url' => 'https://simplemde.com' ],
[ 'name' => 'Sortable', 'url' => 'https://github.com/RubaXa/Sortable' ],
[ 'name' => 'SpinKit', 'url' => 'http://tobiasahlin.com/spinkit/' ],
[ 'name' => 'Vue.js', 'url' => 'https://vuejs.org' ],
[ 'name' => 'what-input', 'url' => 'https://github.com/ten1seven/what-input' ]
];
/** /**
* Retrieve a Dashboard Model * Retrieve a Dashboard Model
* *

View file

@ -120,7 +120,7 @@ function editListInit() {
const $newButton = $(".btn.new-button"); const $newButton = $(".btn.new-button");
$newButton.on("click", function() { $newButton.on("click", function() {
window.location.href = "/dashboard/edit-item/" + model + "/new"; window.location.href = "/dashboard/edit/" + model + "/new";
}); });
}; };
@ -134,7 +134,7 @@ function editListInit() {
itemId = $listItem.data("id"); itemId = $listItem.data("id");
// go to the edit page // go to the edit page
window.location.href = "/dashboard/edit-item/" + model + "/" + itemId; window.location.href = "/dashboard/edit/" + model + "/" + itemId;
}); });
}; };

View file

@ -149,37 +149,6 @@ body {
margin-top: 20px; margin-top: 20px;
margin-bottom: 20px; margin-bottom: 20px;
.card-body {
padding: 15px;
background-color: lighten($c-dashboard-light, 1%);
&.dashboard {
@include media-breakpoint-down(sm) {
padding: 0px;
}
}
.search {
margin-bottom: 10px;
width: 100%;
@include media-breakpoint-down(sm) {
margin: 3px 3px 0px 3px;
width: calc(100% - 6px);
}
}
.help-text {
margin-top: 10px;
margin-bottom: 10px;
padding: 5px 10px;
border: 1px solid darken($c-dashboard-dark, 5%);
border-radius: 5px;
background-color: $c-dashboard-dark;
color: $c-text-light;
}
}
> .card-header { > .card-header {
position: relative; position: relative;
padding: 9px 15px; padding: 9px 15px;
@ -210,9 +179,38 @@ body {
} }
} }
} }
.card-body {
padding: 15px;
background-color: lighten($c-dashboard-light, 1%);
&.dashboard {
@include media-breakpoint-down(sm) {
padding: 0px;
}
} }
.card-body .form-group { .search {
margin-bottom: 10px;
width: 100%;
@include media-breakpoint-down(sm) {
margin: 3px 3px 0px 3px;
width: calc(100% - 6px);
}
}
.help-text {
margin-top: 10px;
margin-bottom: 10px;
padding: 5px 10px;
border: 1px solid darken($c-dashboard-dark, 5%);
border-radius: 5px;
background-color: $c-dashboard-dark;
color: $c-text-light;
}
.form-group {
margin-bottom: 15px; margin-bottom: 15px;
label { label {
@ -299,6 +297,32 @@ body {
} }
} }
.dashboard-credits {
padding: $grid-gutter-width;
h2 {
@include font-sans-semibold;
margin-bottom: 15px;
font-size: 18px;
text-transform: uppercase;
&:not(:first-child) {
margin-top: 25px;
}
}
ul {
margin-bottom: 0px;
padding-left: 20px;
li a {
color: $c-text;
}
}
}
}
}
.btn { .btn {
border-color: darken($c-dashboard-dark, 5%); border-color: darken($c-dashboard-dark, 5%);
background-color: $c-dashboard-dark; background-color: $c-dashboard-dark;

View file

@ -0,0 +1,35 @@
@extends('templates.dashboard')
@section('page-content')
<div class="container spark-screen">
<div class="row">
<div class="col-12">
<div class="card">
<div class="card-header">
Credits
</div>
<div class="card-body dashboard">
<div class="dashboard-credits">
<h2>Authors</h2>
<ul>
@foreach(App\Models\Dashboard::$author_credits as $credit)
<li><a href="{{ $credit['url'] }}" target="_blank" rel="noreferrer">{{ $credit['name'] }}</a></li>
@endforeach
</ul>
<h2>Libraries</h2>
<ul>
@foreach(App\Models\Dashboard::$library_credits as $credit)
<li><a href="{{ $credit['url'] }}" target="_blank" rel="noreferrer">{{ $credit['name'] }}</a></li>
@endforeach
</ul>
</div>
</div>
</div>
</div>
</div>
</div>
@endsection

View file

@ -10,7 +10,7 @@
<a <a
class="list-group-item-link" class="list-group-item-link"
href="{{ url('/dashboard/' . $submenu_item['type'] . '/' . $submenu_item['model']) }}"> href="/dashboard/{{ $submenu_item['type'] }}/{{ $submenu_item['model'] }}">
</a> </a>
</li> </li>
@endforeach @endforeach
@ -20,7 +20,7 @@
<a <a
class="list-group-item-link" class="list-group-item-link"
href="{{ url('/dashboard/' . $menu_item['type'] . '/' . $menu_item['model']) }}"> href="/dashboard/{{ $menu_item['type'] }}/{{ $menu_item['model'] }}">
</a> </a>
</li> </li>
@endif @endif

View file

@ -1,7 +1,7 @@
<nav class="navbar navbar-expand-lg"> <nav class="navbar navbar-expand-lg">
@set('current_page', preg_replace([ '/^.*\//', '/\/.*/' ], [ '', '' ], Request::url())) @set('current_page', preg_replace([ '/^.*\//', '/\/.*/' ], [ '', '' ], Request::url()))
<a class="navbar-brand" href="{{ url('/dashboard') }}"> <a class="navbar-brand" href="/dashboard">
{{ env('APP_NAME') }} Dashboard {{ env('APP_NAME') }} Dashboard
</a> </a>
@ -16,10 +16,10 @@
<div id="dashboard-navbar" class="collapse navbar-collapse"> <div id="dashboard-navbar" class="collapse navbar-collapse">
<ul class="navbar-nav ml-auto"> <ul class="navbar-nav ml-auto">
@if (Auth::guest()) @if (Auth::guest())
<li class="nav-item"><a class="nav-link" href="{{ url('/login') }}">Login</a></li> <li class="nav-item"><a class="nav-link {{ $current_page == 'login' ? 'active' : '' }}" href="/login">Login</a></li>
@if(env('REGISTRATION', false)) @if(env('REGISTRATION', false))
<li class="nav-item"><a class="nav-link" href="{{ url('/register') }}">Register</a></li> <li class="nav-item"><a class="nav-link {{ $current_page == 'register' ? 'active' : '' }}" href="/register">Register</a></li>
@endif @endif
@else @else
@foreach(App\Models\Dashboard::$menu as $menu_item) @foreach(App\Models\Dashboard::$menu as $menu_item)
@ -33,13 +33,13 @@
<div class="dropdown-menu dropdown-menu-right" aria-labelledby="menu-dropdown-{{ $dropdown_id }}"> <div class="dropdown-menu dropdown-menu-right" aria-labelledby="menu-dropdown-{{ $dropdown_id }}">
@foreach($menu_item['submenu'] as $submenu_item) @foreach($menu_item['submenu'] as $submenu_item)
<a class="dropdown-item {{ $current_page == $submenu_item['model'] ? 'active' : '' }}" href="{{ url('/dashboard/' . $submenu_item['type'] . '/' . $submenu_item['model']) }}">{{ $submenu_item['title'] }}</a> <a class="dropdown-item {{ $current_page == $submenu_item['model'] ? 'active' : '' }}" href="/dashboard/{{ $submenu_item['type'] }}/{{ $submenu_item['model'] }}">{{ $submenu_item['title'] }}</a>
@endforeach @endforeach
</div> </div>
</li> </li>
@else @else
<li class="nav-item"> <li class="nav-item">
<a class="nav-link {{ $current_page == $menu_item['model'] ? 'active' : '' }}" href="{{ url('/dashboard/' . $menu_item['type'] . '/' . $menu_item['model']) }}"> <a class="nav-link {{ $current_page == $menu_item['model'] ? 'active' : '' }}" href="/dashboard/{{ $menu_item['type'] }}/{{ $menu_item['model'] }}">
{{ $menu_item['title'] }} {{ $menu_item['title'] }}
</a> </a>
</li> </li>
@ -52,7 +52,8 @@
</a> </a>
<div class="dropdown-menu dropdown-menu-right" aria-labelledby="user-dropdown"> <div class="dropdown-menu dropdown-menu-right" aria-labelledby="user-dropdown">
<a class="dropdown-item" href="{{ url('/logout') }}">Logout</a> <a class="dropdown-item {{ $current_page == 'credits' ? 'active' : '' }}" href="/dashboard/credits">Credits</a>
<a class="dropdown-item" href="/logout">Logout</a>
</div> </div>
</li> </li>
@endif @endif

View file

@ -7,5 +7,5 @@
@endsection @endsection
@section('page-top') @section('page-top')
@include('dashboard.sections.nav') @include('dashboard.nav')
@endsection @endsection

View file

@ -29,10 +29,11 @@ Route::get('/logout', 'Auth\LoginController@logout');
*/ */
Route::group([ 'prefix' => 'dashboard' ], function() { Route::group([ 'prefix' => 'dashboard' ], function() {
Route::get('/', 'DashboardController@index'); Route::get('/', 'DashboardController@getIndex');
Route::get('/credits', 'DashboardController@getCredits');
Route::get('/view/{model}', 'DashboardController@getView'); Route::get('/view/{model}', 'DashboardController@getView');
Route::get('/edit/{model}', 'DashboardController@getEditList'); Route::get('/edit/{model}', 'DashboardController@getEditList');
Route::get('/edit-item/{model}/{id}', 'DashboardController@getEditItem'); Route::get('/edit/{model}/{id}', 'DashboardController@getEditItem');
Route::get('/export/{model}', 'DashboardController@getExport'); Route::get('/export/{model}', 'DashboardController@getExport');
Route::post('/image-upload', 'DashboardController@postImageUpload'); Route::post('/image-upload', 'DashboardController@postImageUpload');
Route::post('/file-upload', 'DashboardController@postFileUpload'); Route::post('/file-upload', 'DashboardController@postFileUpload');

View file

@ -29,10 +29,11 @@ Route::get('/logout', 'Auth\LoginController@logout');
*/ */
Route::group([ 'prefix' => 'dashboard' ], function() { Route::group([ 'prefix' => 'dashboard' ], function() {
Route::get('/', 'DashboardController@index'); Route::get('/', 'DashboardController@getIndex');
Route::get('/credits', 'DashboardController@getCredits');
Route::get('/view/{model}', 'DashboardController@getView'); Route::get('/view/{model}', 'DashboardController@getView');
Route::get('/edit/{model}', 'DashboardController@getEditList'); Route::get('/edit/{model}', 'DashboardController@getEditList');
Route::get('/edit-item/{model}/{id}', 'DashboardController@getEditItem'); Route::get('/edit/{model}/{id}', 'DashboardController@getEditItem');
Route::get('/export/{model}', 'DashboardController@getExport'); Route::get('/export/{model}', 'DashboardController@getExport');
Route::post('/image-upload', 'DashboardController@postImageUpload'); Route::post('/image-upload', 'DashboardController@postImageUpload');
Route::post('/file-upload', 'DashboardController@postFileUpload'); Route::post('/file-upload', 'DashboardController@postFileUpload');