Commit 737a07c4 authored by Sean O'Donnell's avatar Sean O'Donnell

admin Views

parent 6e1e45f5
<?php
namespace App\Http\Controllers\Admin;
use App\Http\Controllers\Controller;
use Illuminate\Http\Request;
use Redirect;
use Illuminate\Validation\Rule;
use App\User;
class AdminController extends Controller
{
public function dashboard(){
$users = User::orderBy('created_at', 'dec')->paginate(10);
return view('admin.dashboard',[
'users' => $users
]);
}
/*
*************************
User Functions
*************************
*/
public function deleteUser($id){
$user = User::find($id);
$user->softDelete();
return view('admin.dashboard',
[
'status' => 'success',
'deleted' => $user->deleted
]);
}
}
......@@ -59,6 +59,7 @@ class Kernel extends HttpKernel
'activity' => \App\Http\Middleware\checkOwnsActivity::class,
'bot' => \App\Http\Middleware\checkOwnsBot::class,
'twitchAuth' => \App\Http\Middleware\checkTwitchAuth::class,
'adminCheck' => \App\Http\Middleware\checkAdmin::class,
'checkAPIKey' => \App\Http\Middleware\checkAPIKey::class,
'CheckAPIRouteAPIKey' => \App\Http\Middleware\CheckAPIRouteAPIKey::class
];
......
<?php
namespace App\Http\Middleware;
use Closure;
use Auth;
class checkAdmin
{
/**
* Handle an incoming request.
*
* @param \Illuminate\Http\Request $request
* @param \Closure $next
* @return mixed
*/
public function handle($request, Closure $next)
{
// Check the user has an API Key we can use with twitch otherwise it's all rather pointless really.
if(Auth::user()->role != 1)
{
return redirect('/');
}
return $next($request);
}
}
......@@ -15,7 +15,7 @@ class User extends Authenticatable
* @var array
*/
protected $fillable = [
'display_name', 'email', 'twitch_id', 'avatar', 'token', 'refreshtoken', 'expirestime', 'refreshtime', 'bio','partnered', 'apikey','twitch_auth_failed', 'game_mode', 'payment_email', 'delete_data'
'display_name', 'email', 'twitch_id', 'avatar', 'token', 'refreshtoken', 'expirestime', 'deleted', 'refreshtime', 'bio','partnered', 'apikey','twitch_auth_failed', 'game_mode', 'payment_email', 'delete_data'
];
/**
......@@ -103,4 +103,12 @@ class User extends Authenticatable
return $this->hasOne('App\UserConsent');
}
public function softDelete()
{
return $this->Update([
'id' => $this->id,
'deleted' => '1'
]);
}
}
......@@ -4481,13 +4481,10 @@ tbody.collapse.show {
.breadcrumb-item.active {
color: #868e96; }
.pagination {
display: -webkit-box;
display: -ms-flexbox;
display: flex;
padding-left: 0;
list-style: none;
border-radius: 0.25rem; }
.pagination li, .pagination2 li, .pagination3 li{
display: inline;
}
.page-item:first-child .page-link {
margin-left: 0;
......@@ -4512,7 +4509,6 @@ tbody.collapse.show {
.page-link {
position: relative;
display: block;
padding: 0.5rem 0.75rem;
margin-left: -1px;
line-height: 1.25;
@include('templates.head')
<title>StreamUpdater - My Dashboard </title>
</head>
<body class="header-centered sidebar-horizontal">
<div id="wrapper" class="wrapper">
@include('templates.nav')
<main class="main-wrapper clearfix">
<div class="row page-title clearfix">
<div class="page-title-left">
<h5 class="mr-0 mr-r-5">Dashboard</h5>
<p class="mr-0 text-muted d-none d-md-inline-block">See everything at a glance!</p>
</div>
<div class="page-title-right d-none d-sm-inline-flex">
<ol class="breadcrumb">
<li class="breadcrumb-item"><a href="{{URL::to('/')}}">Dashboard</a>
</li>
<li class="breadcrumb-item active">Dashboard</li>
<div class="d-none d-sm-inline-flex justify-center align-items-center">
<a href="javascript::void(0)" class="gametoggle btn mr-l-20 btn-sm btn-rounded hidden-xs hidden-sm ripple @if(Auth::user()->game_mode == 0) btn-outline-success @else btn-outline-primary @endif" >@if(Auth::user()->game_mode == 0) Activate Game Only Mode @else Deactivate Game Only Mode @endif
</a>
</div>
</ol>
</div>
</div>
<div class="widget-list">
<div class="row">
<div class="col-sm-4 col-md-4 widget-holder">
<div class="widget-bg">
<div class="widget-body clearfix">
<h5 class="box-title"> Users ({{$users->total()}})</h5>
<div class="padded-reverse">
<table class="table table-striped widget-status-table mr-b-0">
<thead>
<tr>
<th class="pd-l-20">Username</th>
<th>Time</th>
<th>Actions</th>
</tr>
</thead>
<tbody>
@foreach($users as $user)
<tr>
<th class="pd-l-20">
{{$user->display_name}}
</th>
<td>{{$user->created_at}}</td>
<td><a href="{{URL::to('admin/user/edit')}}/{{$user->id}}"><i class="fa fa-pencil-alt"> </i> </a>
<a href="{{URL::to('admin/user/delete')}}/{{$user->id}}"><i class="fa fa-trash"> </i> </a>
</td>
</tr>
@endforeach
</tbody>
</table>
{{ $users->links('vendor.pagination.bootstrap-4', ['foo' => 'bar']) }}
<!-- /.widget-status-table -->
</div>
<!-- /.padded-reverse -->
</div>
<!-- /.widget-body badge -->
</div>
<!-- /.widget-bg -->
</div>
<!-- /.col-md-3 -->
<div class="col-sm-4 col-md-4 widget-holder">
<div class="widget-bg">
<div class="widget-body clearfix">
<h5 class="box-title"> Recent Games Played</h5>
<div class="padded-reverse">
<table class="table table-striped widget-status-table mr-b-0">
<thead>
<tr>
<th class="pd-l-20">Game</th>
<th>Time (Minutes)</th>
</tr>
</thead>
<tbody>
@foreach(App\GameTime::where('user_id', Auth::user()->id)->limit(3)->orderBy('id', 'dec')->get() as $game)
<tr>
<th class="pd-l-20">
{{$game->game->name}}
</th>
@if($game->game_ended != null)
<td>{{\Carbon\Carbon::parse($game->game_started)->diffInMinutes(\Carbon\Carbon::parse($game->game_ended))}}</td>
@else
<td>{{\Carbon\Carbon::parse($game->game_started)->diffInMinutes(\Carbon\Carbon::now())}}</td>
@endif
</tr>
@endforeach
</tbody>
</table>
<!-- /.widget-status-table -->
</div>
<!-- /.padded-reverse -->
</div>
<!-- /.widget-body badge -->
</div>
<!-- /.widget-bg -->
</div>
@if(Auth::user()->spotify)
<div class="col-sm-4 col-md-4 widget-holder">
<div class="widget-bg">
<div class="widget-body clearfix">
<h5 class="box-title"> Current Spotify Song</h5>
{{\App\Http\Controllers\API\APIController::spotifyCurrentSong()}}
</div>
<!-- /.widget-body badge -->
</div>
<!-- /.widget-bg -->
</div>
@endif
<!-- /.col-md-3 -->
</div>
</div>
<!-- /.widget-list -->
</main>
@include('templates.chat')
<!-- /.main-wrappper -->
</div>
<!-- /.content-wrapper -->
@include('templates.footer')
</div>
<!--/ #wrapper -->
@include('templates.scripts')
<script>
$('.gametoggle').on("click", function(){
var id = {{Auth::user()->id}};
var apikey = "{{Auth::user()->apikey}}";
$.ajax({
type: "POST",
url: '{{URL::to('api/gameonlytoggle')}}',
data: {id: id, apikey: apikey},
success: function( msg ) {
if(msg["game_mode"] == 0)
{
x = document.getElementsByClassName("gametoggle");
for(var i = 0; i < x.length; i++){
x[i].innerText="Activate Game Only Mode";
x[i].className = "gametoggle btn-outline-success btn mr-l-20 btn-sm btn-rounded hidden-xs hidden-sm ripple";
}
}
if(msg["game_mode"] == 1)
{
x = document.getElementsByClassName("gametoggle");
for(var i = 0; i < x.length; i++){
x[i].innerText="Deactivate Game Only Mode";
x[i].className = "gametoggle btn-outline-primary btn mr-l-20 btn-sm btn-rounded hidden-xs hidden-sm ripple";
}
}
}
});
});
</script>
</body>
</html>
......@@ -18,6 +18,8 @@
<link href="https://d1a4w6ucfnf7xc.cloudfront.net/su-assets/assets/css/all.css" rel="stylesheet" type="text/css">
<!-- Head Libs -->
<script src="https://d1a4w6ucfnf7xc.cloudfront.net/su-assets/assets/js/modernizr.min.js"></script>
<link rel="stylesheet" href="https://use.fontawesome.com/releases/v5.8.1/css/all.css" integrity="sha384-50oBUHEmvpQ+1lW4y57PTFmhCaXp0ML5d60M1M7uH2+nqUivzIebhndOJK28anvf" crossorigin="anonymous">
<!-- Pace Options, stops preloader from firing on every ajax request -->
<script>
window.paceOptions = {
......
......@@ -72,6 +72,10 @@
</li>
<li><a href="{{URL::to('streams')}}"><i class="list-icon material-icons">tv</i> <span class="hide-menu">Streams <span class="badge badge-border bg-primary pull-right">5</span></span></a>
</li>
@if(Auth::user()->role == '1')
<li><a href="{{URL::to('admin')}}"><i class="list-icon material-icons">build</i> <span class="hide-menu">Admin <span class="badge badge-border bg-primary pull-right">5</span></span></a>
</li>
@endif
<li><a href="{{URL::to('profile')}}/{{Auth::user()->display_name}}"><i class="list-icon material-icons">person</i> <span class="hide-menu">My Profile <span class="badge badge-border bg-primary pull-right">5</span></span></a>
</li>
<li class="menu-item-has-children"><a href="javascript:void(0);"><i class="list-icon material-icons">get_app</i> <span class="hide-menu">Download</span></a>
......
@if ($paginator->hasPages())
<ul class="pagination">
{{-- Previous Page Link --}}
@if ($paginator->onFirstPage())
<li class="page-item disabled"><span class="page-link">&laquo;</span></li>
@else
<li class="page-item"><a class="page-link" href="{{ $paginator->previousPageUrl() }}" rel="prev">&laquo;</a></li>
@endif
{{-- Pagination Elements --}}
@foreach ($elements as $element)
{{-- "Three Dots" Separator --}}
@if (is_string($element))
<li class="page-item disabled"><span class="page-link">{{ $element }}</span></li>
@endif
{{-- Array Of Links --}}
@if (is_array($element))
@foreach ($element as $page => $url)
@if ($page == $paginator->currentPage())
<li class="page-item active"><span class="page-link">{{ $page }}</span></li>
@else
<li class="page-item"><a class="page-link" href="{{ $url }}">{{ $page }}</a></li>
@endif
@endforeach
@endif
@endforeach
{{-- Next Page Link --}}
@if ($paginator->hasMorePages())
<li class="page-item"><a class="page-link" href="{{ $paginator->nextPageUrl() }}" rel="next">&raquo;</a></li>
@else
<li class="page-item disabled"><span class="page-link">&raquo;</span></li>
@endif
</ul>
@endif
@if ($paginator->hasPages())
<ul class="pagination">
{{-- Previous Page Link --}}
@if ($paginator->onFirstPage())
<li class="disabled"><span>&laquo;</span></li>
@else
<li><a href="{{ $paginator->previousPageUrl() }}" rel="prev">&laquo;</a></li>
@endif
{{-- Pagination Elements --}}
@foreach ($elements as $element)
{{-- "Three Dots" Separator --}}
@if (is_string($element))
<li class="disabled"><span>{{ $element }}</span></li>
@endif
{{-- Array Of Links --}}
@if (is_array($element))
@foreach ($element as $page => $url)
@if ($page == $paginator->currentPage())
<li class="active"><span>{{ $page }}</span></li>
@else
<li><a href="{{ $url }}">{{ $page }}</a></li>
@endif
@endforeach
@endif
@endforeach
{{-- Next Page Link --}}
@if ($paginator->hasMorePages())
<li><a href="{{ $paginator->nextPageUrl() }}" rel="next">&raquo;</a></li>
@else
<li class="disabled"><span>&raquo;</span></li>
@endif
</ul>
@endif
@if ($paginator->hasPages())
<div class="ui pagination menu">
{{-- Previous Page Link --}}
@if ($paginator->onFirstPage())
<a class="icon item disabled"> <i class="left chevron icon"></i> </a>
@else
<a class="icon item" href="{{ $paginator->previousPageUrl() }}" rel="prev"> <i class="left chevron icon"></i> </a>
@endif
{{-- Pagination Elements --}}
@foreach ($elements as $element)
{{-- "Three Dots" Separator --}}
@if (is_string($element))
<a class="icon item disabled">{{ $element }}</a>
@endif
{{-- Array Of Links --}}
@if (is_array($element))
@foreach ($element as $page => $url)
@if ($page == $paginator->currentPage())
<a class="item active" href="{{ $url }}">{{ $page }}</a>
@else
<a class="item" href="{{ $url }}">{{ $page }}</a>
@endif
@endforeach
@endif
@endforeach
{{-- Next Page Link --}}
@if ($paginator->hasMorePages())
<a class="icon item" href="{{ $paginator->nextPageUrl() }}" rel="next"> <i class="right chevron icon"></i> </a>
@else
<a class="icon item disabled"> <i class="right chevron icon"></i> </a>
@endif
</div>
@endif
@if ($paginator->hasPages())
<ul class="pagination">
{{-- Previous Page Link --}}
@if ($paginator->onFirstPage())
<li class="page-item disabled"><span class="page-link">@lang('pagination.previous')</span></li>
@else
<li class="page-item"><a class="page-link" href="{{ $paginator->previousPageUrl() }}" rel="prev">@lang('pagination.previous')</a></li>
@endif
{{-- Next Page Link --}}
@if ($paginator->hasMorePages())
<li class="page-item"><a class="page-link" href="{{ $paginator->nextPageUrl() }}" rel="next">@lang('pagination.next')</a></li>
@else
<li class="page-item disabled"><span class="page-link">@lang('pagination.next')</span></li>
@endif
</ul>
@endif
@if ($paginator->hasPages())
<ul class="pagination">
{{-- Previous Page Link --}}
@if ($paginator->onFirstPage())
<li class="disabled"><span>@lang('pagination.previous')</span></li>
@else
<li><a href="{{ $paginator->previousPageUrl() }}" rel="prev">@lang('pagination.previous')</a></li>
@endif
{{-- Next Page Link --}}
@if ($paginator->hasMorePages())
<li><a href="{{ $paginator->nextPageUrl() }}" rel="next">@lang('pagination.next')</a></li>
@else
<li class="disabled"><span>@lang('pagination.next')</span></li>
@endif
</ul>
@endif
......@@ -104,8 +104,18 @@ Route::group(['middleware' => ['auth', 'twitchAuth']], function () {
});
Route::any('followlisten', 'ListenController@processFollow');
Route::get('admin/twitchlease', 'ListenController@forceLeaseGet');
Route::get('admin/twitchfollowers/{username}', 'User\UserController@getTwitchFollowers');
/*
******************
Admin Routes
******************
*/
Route::group(['middleware' => ['auth', 'adminCheck']], function () {
Route::get('admin', 'Admin\AdminController@dashboard');
Route::get('admin/twitchlease', 'ListenController@forceLeaseGet');
Route::get('admin/twitchfollowers/{username}', 'User\UserController@getTwitchFollowers');
Route::get('admin/user/delete/{id}', 'Admin\AdminController@deleteUser');
});
// Social
Route::get('profile/edit', function () {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment