From 71efdf93d8f4add40d126f4774c9af2e46ba5735 Mon Sep 17 00:00:00 2001 From: Miguel Nogueira Date: Sat, 27 Jun 2020 04:49:55 +0100 Subject: [PATCH] Add dashboard widgets --- app/Http/Controllers/DashboardController.php | 18 +- config/adminlte.php | 21 ++ public/js/dashboard.js | 18 ++ resources/views/dashboard/dashboard.blade.php | 227 ++++++++++++++++-- 4 files changed, 258 insertions(+), 26 deletions(-) create mode 100644 public/js/dashboard.js diff --git a/app/Http/Controllers/DashboardController.php b/app/Http/Controllers/DashboardController.php index 672dd6c..d397d89 100644 --- a/app/Http/Controllers/DashboardController.php +++ b/app/Http/Controllers/DashboardController.php @@ -3,13 +3,29 @@ namespace App\Http\Controllers; use Illuminate\Http\Request; +use App\Vacancy; +use App\User; +use App\Ban; +use App\Application; class DashboardController extends Controller { public function index() { - return view('dashboard.dashboard'); + $totalPeerReview = Application::where('applicationStatus', 'STAGE_PEERAPPROVAL')->get()->count(); + $totalNewApplications = Application::where('applicationStatus', 'STAGE_SUBMITTED')->get()->count(); + $totalDenied = Application::where('applicationStatus', 'DENIED')->get()->count(); + + return view('dashboard.dashboard') + ->with([ + 'vacancies' => Vacancy::all(), + 'totalUserCount' => User::all()->count(), + 'totalDenied' => $totalDenied, + 'totalPeerReview' => $totalPeerReview, + 'totalNewApplications' => $totalNewApplications + ]); + } } diff --git a/config/adminlte.php b/config/adminlte.php index dc4d3bb..ad07b8e 100644 --- a/config/adminlte.php +++ b/config/adminlte.php @@ -208,6 +208,11 @@ return [ */ 'menu' => [ + [ + 'text' => 'Home', + 'icon' => 'fas fa-home', + 'url' => 'dashboard' + ], [ 'header' => 'Applications', 'can' => 'applications.view.own' @@ -494,6 +499,22 @@ return [ 'location' => '/js/datepick.js' ] ] + ], + [ + 'name' => 'Fullcalendar', + 'active' => true, + 'files' => [ + [ + 'type' => 'js', + 'asset' => false, + 'location' => 'https://cdn.jsdelivr.net/npm/fullcalendar@5.0.1/main.min.js', + ], + [ + 'type' => 'css', + 'asset' => false, + 'location' => 'https://cdn.jsdelivr.net/npm/fullcalendar@5.0.1/main.min.css' + ] + ] ] ], ]; diff --git a/public/js/dashboard.js b/public/js/dashboard.js new file mode 100644 index 0000000..2cf163f --- /dev/null +++ b/public/js/dashboard.js @@ -0,0 +1,18 @@ +document.addEventListener('DOMContentLoaded', function() { + var calendarEl = document.getElementById('upcomingCalendar'); + var calendar = new FullCalendar.Calendar(calendarEl, { + initialView: 'dayGridMonth', + themeSystem: 'bootstrap', + headerToolbar: { + left: 'dayGridMonth,timeGridWeek,timeGridDay', + center: 'title', + right: 'prevYear,prev,next,nextYear' + }, + footerToolbar: { + center: '', + right: 'prev,next' + } + + }); + calendar.render(); +}); diff --git a/resources/views/dashboard/dashboard.blade.php b/resources/views/dashboard/dashboard.blade.php index ea2f66f..61f7de1 100644 --- a/resources/views/dashboard/dashboard.blade.php +++ b/resources/views/dashboard/dashboard.blade.php @@ -3,44 +3,34 @@ @section('title', 'Raspberry Network Team Management') @section('content_header') -

Team Management Panel | Backoffice

+

RaspberryNet Teams / Dashboard (At a glance)

@stop +@section('js') + + + +@endsection + @section('content') -
+
-
+
- @if (!is_null($mcstatus)) +
- @if($mcstatus[4]['sessionserver.mojang.com'] == 'red') +

Welcome back, {{ Auth::user()->name }}!

-
-

Mojang's session servers are (apparently) down

+
-

If you see missing profile pictures in our dashboard or in the staff list (homepage), or are unable to login to Raspberry Network or Minecraft itself, be advised that Mojang's session server is currently experiencing technical difficulties.

-

We hope this issue is resolved soon! For more information please visit the Mojang Support Center.

+
-

Raspberry Network and Spacejewel Hosting are not affiliated with Mojang AB or Microsoft Corporation. Minecraft(™) is a trademark of Mojang AB.

-
- @else - -
- -

All OK! Feel free to explore the team management dashboard, manage your applications, or join our server.

- -
- - @endif - - @endif - -
-
+ +
@@ -52,4 +42,191 @@
+ + @if (!Auth::user()->isStaffMember()) + +
+
+ +
+
+

{{ $openApplications ?? 0 }}

+ +

Ongoing Apps

+
+
+ +
+ Open +
+
+ +
+ +
+
+

{{ $deniedApplications ?? 0 }}

+ +

Denied Apps

+
+
+ +
+ Open +
+
+
+ + @else + +
+
+ +
+
+

{{ $totalUserCount }}

+ +

Total Users + Staff

+
+
+ +
+ @if (Auth::user()->hasRole('admin')) + + Open + + @endif +
+
+ +
+ +
+
+

{{ $totalDenied }}

+ +

Denied applications

+
+
+ +
+
+
+ +
+ +
+
+

{{ $totalNewApplications }}

+ +

New applications

+
+
+ +
+ Open +
+
+ +
+ +
+
+

{{ $totalPeerReview }}

+ +

Vote backlog

+
+
+ +
+ Open +
+
+ +
+ + @endif + + + @if ($isEligibleForApplication && !Auth::user()->isStaffMember()) +
+ +
+ +

Available ranks

+
+ +
+ +
+ @endif + +
+ + @if (!$vacancies->isEmpty() && $isEligibleForApplication && !Auth::user()->isStaffMember()) + + + @foreach($vacancies as $vacancy) + + +
+ +
+
+

{{ $vacancy->vacancyName }}

+ +
+ +
+ +
+ +
+ {{$vacancy->vacancyDescription}} +
+ + + +
+ +
+ + @endforeach + + @endif + +
+ + +
+ +
+ +
+ +
+ +

+   Your upcoming interviews (coming soon) +

+ +
+ +
+ +
+ +
+ +
+ +
+ +
@stop