admin dashboard rework

This commit is contained in:
2019-10-28 19:28:01 -05:00
parent 2dabefa2e1
commit 1ec7760d12
7 changed files with 395 additions and 58 deletions

View File

@@ -23,16 +23,79 @@ class AdminController extends Controller
$this->middleware('role:Admin');
}
public function displayDashboard() {
public function displayUsers(Request $request) {
//Declare array variables
$user = array();
$permission = array();
$userArr = array();
/**
* For each user we want to build their name and permission set into one array
* Having all of the data in one array will allow us to build the table for the admin page more fluently.
* Example: userArr[0]['name'] = Minerva Arbosa
* userArr[0]['role'] = W4RP
* userArr[0]['permissions'] = ['admin', 'contract.admin', superuser]
*/
$usersTable = User::orderBy('name', 'asc')->get()->toArray();
foreach($usersTable as $user) {
$perms = UserPermission::where([
'character_id' => $user['character_id'],
])->get('permission')->toArray();
$tempUser['name'] = $user['name'];
$tempUser['role'] = $user['user_type'];
$tempUser['permissions'] = $perms;
array_push($userArr, $tempUser);
}
//Get a user count for the view so we can do pagination
$userCount = User::orderBy('name', 'asc')->count();
//Set the amount of pages for the data
$userPages = ceil($userCount / 50);
/**
* Miscellaneous data for populating arrays
*
*/
$users = User::pluck('name')->all();
return view('admin.dashboards.users')->with('users', $users)
->with('userArr', $userArr)
->with('page', $page)
->with('userCount', $userCount)
->with('userPages', $userPages);
}
public function displayAllowedLogins() {
//Declare array variables
$entities = array();
/** Entities for allowed logins */
$legacys = AllowedLogin::where(['login_type' => 'Legacy'])->pluck('entity_name')->toArray();
$renters = AllowedLogin::where(['login_type' => 'Renter'])->pluck('entity_name')->toArray();
//Compile a list of entities by their entity_id
foreach($legacys as $legacy) {
$entities[] = $legacy;
}
foreach($renters as $renter) {
$entities[] = $renter;
}
return view('admin.dashboards.allowed_logins')->with('entities', $entities);
}
public function displayPurgeWiki() {
return view('admin.dashboards.purge_wiki');
}
public function displayTaxes() {
//Declare variables needed for displaying items on the page
$months = 3;
$pi = array();
$industry = array();
$reprocessing = array();
$office = array();
$user = array();
$permission = array();
$entities = array();
$corpId = 98287666;
$srpActual = array();
$srpLoss = array();
@@ -93,57 +156,15 @@ class AdminController extends Controller
];
}
/** Users & Permissions Pane */
$userArr = array();
/**
* For each user we want to build their name and permission set into one array
* Having all of the data in one array will allow us to build the table for the admin page more fluently.
* Example: userArr[0]['name'] = Minerva Arbosa
* userArr[0]['role'] = W4RP
* userArr[0]['permissions'] = ['admin', 'contract.admin', superuser]
*/
$usersTable = User::orderBy('name', 'asc')->get()->toArray();
foreach($usersTable as $user) {
$perms = UserPermission::where([
'character_id' => $user['character_id'],
])->get('permission')->toArray();
$tempUser['name'] = $user['name'];
$tempUser['role'] = $user['user_type'];
$tempUser['permissions'] = $perms;
array_push($userArr, $tempUser);
}
/**
* Miscellaneous data for populating arrays
*
*/
$users = User::pluck('name')->all();
/** Entities for allowed logins */
$legacys = AllowedLogin::where(['login_type' => 'Legacy'])->pluck('entity_name')->toArray();
$renters = AllowedLogin::where(['login_type' => 'Renter'])->pluck('entity_name')->toArray();
//Compile a list of entities by their entity_id
foreach($legacys as $legacy) {
$entities[] = $legacy;
}
foreach($renters as $renter) {
$entities[] = $renter;
}
return view('admin.dashboard')->with('users', $users)
->with('userArr', $userArr)
->with('pis', $pis)
->with('industrys', $industrys)
->with('offices', $offices)
->with('markets', $markets)
->with('jumpgates', $jumpgates)
->with('reprocessings', $reprocessings)
->with('entities', $entities)
->with('pigross', $pigross)
->with('srpActual', $srpActual)
->with('srpLoss', $srpLoss);
return view('admin.dashboards.taxes')->with('pis', $pis)
->with('industrys', $industrys)
->with('offices', $offices)
->with('markets', $markets)
->with('jumpgates', $jumpgates)
->with('reprocessings', $reprocessings)
->with('pigross', $pigross)
->with('sprActual', $srpActual)
->with('srpLoss', $srpLoss);
}
public function displayModifyUser(Request $request) {

View File

@@ -0,0 +1,51 @@
@extends('admin.layouts.b4')
@section('content')
<div class="container">
<div class="row">
<div class="col">
<div class="card">
<div class="card-header">
Add Allowed Login
</div>
<div class="card-body">
{!! Form::open(['action' => 'Dashboard\AdminController@addAllowedLogin', 'method' => 'POST']) !!}
<div class="form-group">
{{ Form::label('allowedEntityId', 'Allowed Entity ID') }}
{{ Form::text('allowedEntityId', '', ['class' => 'form-control']) }}
</div>
<div class="form-group">
{{ Form::label('allowedEntityType', 'Allowed Entity Type') }}
{{ Form::select('allowedEtntityType', ['Corporation' => 'Corporation', 'Alliance' => 'Alliance'], null, ['class' => 'form-control']) }}
</div>
<div class="form-group">
{{ Form::label('allowedEntityName', 'Allowed Entity Name') }}
{{ Form::text('allowedEntityName', '', ['class' => 'form-control']) }}
</div>
<div class="form-group">
{{ Form::label('allowedLoginType', 'Allowed Login Type') }}
{{ Form::select('allowedLoginType', ['Legacy' => 'Legacy', 'Renter' => 'Renter'], null, ['class' => 'form-control']) }}
</div>
{{ Form::submit('Submit', ['class' => 'btn btn-primary']) }}
{!! Form::close() !!}
</div>
</div>
</div>
<div class="col">
<div class="card">
<div class="card-header">
Remove Allowed Login
</div>
<div class="card-body">
{!! Form::open(['action' => 'Dashboard\AdminController@removeAllowedLogin', 'method' => 'POST']) !!}
<div class="form-group">
{{ Form::label('removeAllowedLogin', 'Remove Entity') }}
{{ Form::select('removeAllowedLogin', $entities, null, ['class' => 'form-control']) }}
</div>
{{ Form::submit('Submit', ['class' => 'btn btn-primary']) }}
{!! Form::close() !!}
</div>
</div>
</div>
</div>
</div>
@endsection

View File

@@ -0,0 +1,14 @@
@extends('admin.layouts.b4')
@section('content')
<div class="container">
<div class="row">
{!! Form::open(['action' => 'Wiki\WikiController@purgeUsers', 'method' => 'POST']) !!}
<div class="form-group">
{{ Form::label('admin', 'This action will log the administrator who peformed the action.') }}
{{ Form::hidden('admin', auth()->user()->character_id) }}
</div>
{{ Form::submit('Purge Wiki', ['class' => 'btn btn-primary']) }}
{!! Form::close() !!}
</div>
</div>
@endsection

View File

@@ -0,0 +1,231 @@
@extends('admin.layouts.b4')
@section('content')
<div class="container">
<div class="row justify-content-center">
<h2>Taxes Dashboard</h2>
</div>
</div>
<br>
<div class="container-fluid">
<div class="row">
<div class="col">
<div class="card">
<div class="card-header">
PI Taxes
</div>
<div class="card-body">
<table class="table table-striped table-bordered">
<thead>
<th>Month</th>
<th>PI Taxes</th>
</thead>
<tbody>
@foreach($pis as $pi)
<tr>
<td>{{ $pi['date'] }}</td>
<td>{{ $pi['gross'] }}</td>
</tr>
@endforeach
</tbody>
</table>
</div>
</div>
</div>
<div class="col">
<div class="card">
<div class="card-header">
Office Taxes
</div>
<div class="card-body">
<table class="table table-striped table-bordered">
<thead>
<th>Month</th>
<th>Office Taxes</th>
</thead>
<tbody>
@foreach($offices as $office)
<tr>
<td>{{ $office['date'] }}</td>
<td>{{ $office['gross'] }}</td>
</tr>
@endforeach
</tbody>
</table>
</div>
</div>
</div>
<div class="col">
<div class="card">
<div class="card-header">
Industry Taxes
</div>
<div class="card-body">
<table class="table table-striped table-bordered">
<thead>
<th>Month</th>
<th>Industry Taxes</th>
</thead>
<tbody>
@foreach($industrys as $industry)
<tr>
<td>{{ $industry['date'] }}</td>
<td>{{ $industry['gross'] }}</td>
</tr>
@endforeach
</tbody>
</table>
</div>
</div>
</div>
</div>
</div>
<br>
<div class="container-fluid">
<div class="row">
<div class="col">
<div class="card">
<div class="card-header">
Reprocessing Taxes
</div>
<div class="card-body">
<table class="table table-striped table-bordered">
<thead>
<th>Month</th>
<th>Reprocessing Taxes</th>
</thead>
<tbody>
@foreach($reprocessings as $reprocessing)
<tr>
<td>{{ $reprocessing['date'] }}</td>
<td>{{ $reprocessing['gross'] }}</td>
</tr>
@endforeach
</tbody>
</table>
</div>
</div>
</div>
<div class="col">
<div class="card">
<div class="card-header">
Market Taxes
</div>
<div class="card-body">
<table class="table table-striped table-bordered">
<thead>
<th>Month</th>
<th>Market Taxes</th>
</thead>
<tbody>
@foreach($markets as $market)
<tr>
<td>{{ $market['date'] }}</td>
<td>{{ $market['gross'] }}</td>
</tr>
@endforeach
</tbody>
</table>
</div>
</div>
</div>
<div class="col">
<div class="card">
<div class="card-header">
Jump Gate Taxes
</div>
<div class="card-body">
<table class="table table-striped table-bordered">
<thead>
<th>Month</th>
<th>Jump Gate Taxes</th>
</thead>
<tbody>
@foreach($jumpgates as $jumpgate)
<tr>
<td>{{ $jumpgate['date'] }}</td>
<td>{{ $jumpgate['gross'] }}</td>
</tr>
@endforeach
</tbody>
</table>
</div>
</div>
</div>
</div>
</div>
<br>
<div class="container-fluid">
<div class="row">
<div class="col">
<div class="card">
<div class="card-header">
PI Transactions
</div>
<div class="card-body">
<table class="table table-striped table-bordered">
<thead>
<th>Month</th>
<th>PI Transactions</th>
</thead>
<tbody>
@foreach($pigross as $pi)
<tr>
<td>{{ $pi['date'] }}</td>
<td>{{ $pi['gross'] }}</td>
</tr>
@endforeach
</tbody>
</table>
</div>
</div>
</div>
<div class="col">
<div class="card">
<div class="card-header">
SRP Actual Paid Out
</div>
<div class="card-body">
<table class="table table-striped table-bordered">
<thead>
<th>Month</th>
<th>SRP Actual</th>
</thead>
<tbody>
@foreach($srpActual as $actual)
<tr>
<td>{{ $actual['date'] }}</td>
<td>{{ $actual['gross'] }}</td>
</tr>
@endforeach
</tbody>
</table>
</div>
</div>
</div>
<div class="col">
<div class="card">
<div class="card-header">
SRP Loss Values
</div>
<div class="card-body">
<table class="table table-striped table-bordered">
<thead>
<th>Month</th>
<th>SRP Loss</th>
</thead>
<tbody>
@foreach($srpLoss as $loss)
<tr>
<td>{{ $loss['date'] }}</td>
<td>{{ $loss['gross'] }}</td>
</tr>
@endforeach
</tbody>
</table>
</div>
</div>
</div>
</div>
</div>
@endsection

View File

@@ -89,8 +89,14 @@
<a class="nav-link" href="/scopes/select">Add Esi Scopes</a>
</li>
@if(auth()->user()->hasRole('Admin'))
<li class="nav-item">
<a class="nav-link" href="/admin/dashboard">Admin</a>
<li class="nav-item dropdown">
<a class="nav-link dropdown-toggle" href="#" id="navbarDropDownMenuLink" role="button" data-toggle="dropdown" aria-haspop="true" aria-expanded="false">Admin</a>
<div class="dropdown-menu" aria-labelledby="navbarDropDownMenuLink">
<a class="dropdown-item" href="/admin/dashboard/users">Users</a>
<a class="dropdown-item" href="/admin/dashboard/taxes">Taxes</a>
<a class="dropdown-item" href="/admin/dashboard/logins">Allowed Logins</a>
<a class="dropdown-item" href="/admin/dashboard/wiki">Wiki Purge</a>
</div>
</li>
@endif
<li class="nav-item">

View File

@@ -0,0 +1,10 @@
<div class="wrapper">
<nav id="sidebar">
<div class="sidebar-header">
<h3>W4RP</h3>
</div>
<ul class="list-unstyled">
</ul>
</nav>
</div>

View File

@@ -23,7 +23,11 @@ Route::group(['middleware' => ['auth']], function(){
/**
* Admin Controller display pages
*/
Route::get('/admin/dashboard', 'Dashboard\AdminController@displayDashboard');
Route::get('/admin/dashboard/users', 'Dashboard\AdminController@displayUsers');
Route::get('/admin/dashboard/taxes', 'Dashboard\AdminController@displayTaxes');
Route::get('/admin/dashboard/logins', 'Dashboard\AdminController@displayAllowedLogins');
Route::get('/admin/dashboard/purgewiki', 'Dashboard\AdminController@displayPurgeWiki');
Route::post('/admin/add/role', 'Dashboard\AdminController@addRole');
Route::post('/admin/remove/role', 'Dashboard\AdminController@removeRole');
Route::post('/admin/add/permission', 'Dashboard\AdminController@addPermission');