Skip to content

Commit

Permalink
Fixes #68
Browse files Browse the repository at this point in the history
Some stats for #61
  • Loading branch information
Arrow768 committed Jun 1, 2017
1 parent 13fd5a2 commit b22691b
Show file tree
Hide file tree
Showing 10 changed files with 228 additions and 2 deletions.
2 changes: 1 addition & 1 deletion app/Http/Controllers/Git/HookController.php
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ public function index(Request $request)

//Check if it targets development and if ToDos exist
if(count($todo_array) == 0 || $merged_into != config("aurora.github_dev_branch"))
echo "Ignored - No ToDos or not targeting dev";
abort(400,"Ignored - No ToDos or not targeting dev");

//Check if a entry with that pull request id alraedy exists
$db_pull = GitPullRequests::where("git_id",$number)->first();
Expand Down
17 changes: 17 additions & 0 deletions app/Http/Controllers/Server/ExterminatusController.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<?php

namespace App\Http\Controllers\Server;

use Illuminate\Http\Request;
use App\Http\Controllers\Controller;

class ExterminatusController extends Controller
{
public function index(){
return view('server.exterminatus.index');
}

public function exterminate(Request $request){
return redirect()->route('server.exterminatus.index');
}
}
1 change: 1 addition & 0 deletions app/Http/Controllers/Server/IncidentController.php
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,7 @@ public function getIncidentDataChar($char_id, Request $request)
->editColumn('fine', '{{$fine}} Credits')
->addColumn('status','@if(isset($deleted_at)) Deleted @else() Active @endif()')
->addColumn('action', '<p><a href="{{route(\'server.incidents.show.get\',[\'incident_id\'=>$id])}}" class="btn btn-success" role="button">Show</a></p>')
->rawColumns([1, 6])
->make();
}

Expand Down
41 changes: 41 additions & 0 deletions app/Http/Controllers/Server/PlayerController.php
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,47 @@ public function show($player_id, Request $request)
return view('server.player.show', ['player' => $player, 'whitelists' => $player->get_player_whitelists(0)]);
}

/**
* Show the number of chars and players per whitelist
*/
public function showWhitelistStats()
{
$this->middleware(function ($request, $next) {
if ($request->user()->cannot('server_players_whitelists_stats')) {
abort('403', 'You do not have the required permission');
}
return $next($request);
});

$stats = DB::connection('server')->table('whitelist_statuses')->select(DB::raw('status_name, (SELECT COUNT(*) FROM ss13_player WHERE whitelist_status & flag) as player_count, (SELECT COUNT(*) FROM ss13_characters where species = status_name) as char_count, subspecies, flag'))
->orderBy('flag')
->get();

return view('server.player.whitelist_stats',["stats"=>$stats]);
}

public function showWhitelistJobStats($species)
{
$this->middleware(function ($request, $next) {
if ($request->user()->cannot('server_players_whitelists_stats')) {
abort('403', 'You do not have the required permission');
}
return $next($request);
});


$stats = DB::connection('server')
->table('characters_log')
->select('job_name',DB::raw('COUNT(*) as count'))
->join('characters','characters.id','=','characters_log.char_id')
->groupby('job_name')
->where('characters.species',$species)
->orderby('count','desc')
->get();

return view('server.player.whitelist_jobs_stats',["stats"=>$stats,'species'=>$species]);
}


public function addWhitelist($player_id, $whitelist, Request $request)
{
Expand Down
6 changes: 6 additions & 0 deletions app/Http/routes.php
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,10 @@
Route::get('/todo/{todo_id}/data', ['as' => 'server.git.todo.comment.data', 'uses' => 'Git\PullController@getTodoCommentData']);
});

Route::group(['prefix'=>'exterminatus'],function(){
Route::get('', ['as' => 'server.exterminatus.index', 'uses' => 'Server\ExterminatusController@index']);
});

// Route::group(['prefix' => 'permissions'], function () {
// Route::any('', ['as' => 'server.permissions.index', 'uses'=>'Server\PermissionController@index']);
// Route::get('/{permission_id}/', ['as' => 'server.permissions.show', 'uses'=>'Server\PermissionController@show']);
Expand All @@ -151,6 +155,8 @@

Route::group(['prefix' => 'player'], function () {
Route::get('', ['as' => 'server.players.index', 'uses' => 'Server\PlayerController@index']);
Route::get('/whitelist_stats', ['as' => 'server.players.whitelist_stats', 'uses' => 'Server\PlayerController@showWhitelistStats']);
Route::get('/whitelist_stats/{species}/jobs', ['as' => 'server.players.whitelist_stats.jobs', 'uses' => 'Server\PlayerController@showWhitelistJobStats']);
Route::get('/ckey/{player_ckey}', ['as' => 'server.players.ckey', 'uses' => 'Server\PlayerController@getCkey']);
Route::get('/{player_id}/show', ['as' => 'server.players.show', 'uses' => 'Server\PlayerController@show']);
Route::get('/{player_id}/add_whitelist/{whitelist}', ['as' => 'server.players.whitelist.add', 'uses' => 'Server\PlayerController@addWhitelist']);
Expand Down
1 change: 1 addition & 0 deletions permissions_reference
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ D - server_permissions_edit -> Edit a users permissions on the server (admin_ser
D - server_players_show -> Show the player page (Alone Useless -> Needs some of the perms below) (admin_players_show)
D - server_players_whitelists_show -> Show the whitelists (admin_whitelists_show)
D - server_players_whitelists_edit -> Edit the whitelists (admin_whitelists_edit)
D - server_players_whitelists_stats -> Get some stats about the whitelists and the jobs played by various species
D - server_players_warnings_show -> Show a players warnings (admin_warnings_show)
server_players_warnings_edit -> Edit a players warnings (admin_warnings_edit)
D - server_players_notes_show -> Show a players notes (admin_notes_show)
Expand Down
2 changes: 1 addition & 1 deletion resources/views/layouts/app.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,7 @@
<a href="{{route('server.whitelist.log')}}"><i class="fa fa-btn"></i>Whitelist Log</a>
</li>
<li @cannot('server_exterminatus')class="disabled"@endcannot>
<a href=""><i class="fa fa-btn"></i>Exterminatus</a>
<a href="{{route('server.exterminatus.index')}}"><i class="fa fa-btn"></i>Exterminatus</a>
</li>
</ul>
</li>
Expand Down
52 changes: 52 additions & 0 deletions resources/views/server/exterminatus/index.blade.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
{{--Copyright (c) 2017 "Werner Maisl"--}}

{{--This file is part of the Aurora Webinterface--}}

{{--The Aurora Webinterface is free software: you can redistribute it and/or modify--}}
{{--it under the terms of the GNU Affero General Public License as--}}
{{--published by the Free Software Foundation, either version 3 of the--}}
{{--License, or (at your option) any later version.--}}

{{--This program is distributed in the hope that it will be useful,--}}
{{--but WITHOUT ANY WARRANTY; without even the implied warranty of--}}
{{--MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the--}}
{{--GNU Affero General Public License for more details.--}}

{{--You should have received a copy of the GNU Affero General Public License--}}
{{--along with this program. If not, see <http://www.gnu.org/licenses/>.<!DOCTYPE html>--}}

@extends('layouts.app')

@section('content')
<div class="container">
<div class="row">
<div class="col-md-10 col-md-offset-1">
@include('components.formerrors')

<div class="panel panel-default">
<div class="panel-heading">Exterminatus Control Panel</div>

<div class="panel-body">
{{Form::open(array('route' => 'server.library.add.post','method' => 'post')) }}
{{Form::token()}}

{{Form::bsText('Name')}}
{{Form::bsSelectList('Race',array(
'Tajara'=>'Tajara',
'Unathi'=>'Unathi',
'Skrell'=>'Skrell',
'Bugs'=>'Bugs',
'Trees'=>'Trees',
'Mice'=>'Mice'))}}
{{Form::bsText('Reason')}}

{{Form::submit('Exterminate now', array('class'=>'btn btn-danger disabled'))}}
{{Form::submit('Submit Extermination Request', array('class'=>'btn btn-warning'))}}

{{ Form::close() }}
</div>
</div>
</div>
</div>
</div>
@endsection
52 changes: 52 additions & 0 deletions resources/views/server/player/whitelist_jobs_stats.blade.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
{{--Copyright (c) 2016-2017 "Werner Maisl"--}}

{{--This file is part of the Aurora Webinterface--}}

{{--The Aurora Webinterface is free software: you can redistribute it and/or modify--}}
{{--it under the terms of the GNU Affero General Public License as--}}
{{--published by the Free Software Foundation, either version 3 of the--}}
{{--License, or (at your option) any later version.--}}

{{--This program is distributed in the hope that it will be useful,--}}
{{--but WITHOUT ANY WARRANTY; without even the implied warranty of--}}
{{--MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the--}}
{{--GNU Affero General Public License for more details.--}}

{{--You should have received a copy of the GNU Affero General Public License--}}
{{--along with this program. If not, see <http://www.gnu.org/licenses/>.<!DOCTYPE html>--}}

@extends('layouts.app')

@section('content')
<div class="container">
<div class="row">
<div class="col-md-10 col-md-offset-1">
<div class="panel panel-default">
<div class="panel-heading">Rounds played as a Specific Job by {{$species}}</div>

<table class="table table-bordered">
<thead>
<tr>
<th>Job</th>
<th>Rounds Played</th>
</tr>
</thead>
<tbody>
@foreach($stats as $stat)
<tr>
<td>{{$stat->job_name}}</td>
<td>{{$stat->count}}</td>
</tr>
@endforeach()
</tbody>
</table>
</div>
</div>
</div>
</div>
@endsection

@section('javascripts')
<script src="//cdn.ckeditor.com/4.5.11/standard/ckeditor.js"></script>
<script>CKEDITOR.replace('content');</script>
@endsection
56 changes: 56 additions & 0 deletions resources/views/server/player/whitelist_stats.blade.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
{{--Copyright (c) 2016-2017 "Werner Maisl"--}}

{{--This file is part of the Aurora Webinterface--}}

{{--The Aurora Webinterface is free software: you can redistribute it and/or modify--}}
{{--it under the terms of the GNU Affero General Public License as--}}
{{--published by the Free Software Foundation, either version 3 of the--}}
{{--License, or (at your option) any later version.--}}

{{--This program is distributed in the hope that it will be useful,--}}
{{--but WITHOUT ANY WARRANTY; without even the implied warranty of--}}
{{--MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the--}}
{{--GNU Affero General Public License for more details.--}}

{{--You should have received a copy of the GNU Affero General Public License--}}
{{--along with this program. If not, see <http://www.gnu.org/licenses/>.<!DOCTYPE html>--}}

@extends('layouts.app')

@section('content')
<div class="container">
<div class="row">
<div class="col-md-10 col-md-offset-1">
<div class="panel panel-default">
<div class="panel-heading">Whitelist Stats</div>

<table class="table table-bordered">
<thead>
<tr>
<th>Species</th>
<th>Whitelist</th>
<th>Characters</th>
<th></th>
</tr>
</thead>
<tbody>
@foreach($stats as $stat)
<tr @if($stat->subspecies == 1)class="bg-info"@endif()>
<td>{{$stat->status_name}}</td>
<td>{{$stat->player_count}}</td>
<td>{{$stat->char_count}}</td>
<td><a href="{{route('server.players.whitelist_stats.jobs',['species'=>$stat->status_name])}}" class="btn btn-success">Jobs</a></td>
</tr>
@endforeach()
</tbody>
</table>
</div>
</div>
</div>
</div>
@endsection

@section('javascripts')
<script src="//cdn.ckeditor.com/4.5.11/standard/ckeditor.js"></script>
<script>CKEDITOR.replace('content');</script>
@endsection

0 comments on commit b22691b

Please sign in to comment.