From b22691be67ceefcaea622764b1cf64e6fc533ac3 Mon Sep 17 00:00:00 2001 From: Werner Date: Thu, 1 Jun 2017 20:45:40 +0200 Subject: [PATCH] Fixes #68 Some stats for #61 --- app/Http/Controllers/Git/HookController.php | 2 +- .../Server/ExterminatusController.php | 17 ++++++ .../Controllers/Server/IncidentController.php | 1 + .../Controllers/Server/PlayerController.php | 41 ++++++++++++++ app/Http/routes.php | 6 ++ permissions_reference | 1 + resources/views/layouts/app.blade.php | 2 +- .../views/server/exterminatus/index.blade.php | 52 +++++++++++++++++ .../player/whitelist_jobs_stats.blade.php | 52 +++++++++++++++++ .../server/player/whitelist_stats.blade.php | 56 +++++++++++++++++++ 10 files changed, 228 insertions(+), 2 deletions(-) create mode 100644 app/Http/Controllers/Server/ExterminatusController.php create mode 100644 resources/views/server/exterminatus/index.blade.php create mode 100644 resources/views/server/player/whitelist_jobs_stats.blade.php create mode 100644 resources/views/server/player/whitelist_stats.blade.php diff --git a/app/Http/Controllers/Git/HookController.php b/app/Http/Controllers/Git/HookController.php index c7d6f39..c5f4534 100644 --- a/app/Http/Controllers/Git/HookController.php +++ b/app/Http/Controllers/Git/HookController.php @@ -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(); diff --git a/app/Http/Controllers/Server/ExterminatusController.php b/app/Http/Controllers/Server/ExterminatusController.php new file mode 100644 index 0000000..6c1e3a9 --- /dev/null +++ b/app/Http/Controllers/Server/ExterminatusController.php @@ -0,0 +1,17 @@ +route('server.exterminatus.index'); + } +} diff --git a/app/Http/Controllers/Server/IncidentController.php b/app/Http/Controllers/Server/IncidentController.php index 9d91fa6..2f0cb5a 100644 --- a/app/Http/Controllers/Server/IncidentController.php +++ b/app/Http/Controllers/Server/IncidentController.php @@ -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', '

Show

') + ->rawColumns([1, 6]) ->make(); } diff --git a/app/Http/Controllers/Server/PlayerController.php b/app/Http/Controllers/Server/PlayerController.php index d894189..70ea922 100644 --- a/app/Http/Controllers/Server/PlayerController.php +++ b/app/Http/Controllers/Server/PlayerController.php @@ -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) { diff --git a/app/Http/routes.php b/app/Http/routes.php index 6fe20b8..5d1bf68 100644 --- a/app/Http/routes.php +++ b/app/Http/routes.php @@ -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']); @@ -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']); diff --git a/permissions_reference b/permissions_reference index f88bdf8..6fc7279 100644 --- a/permissions_reference +++ b/permissions_reference @@ -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) diff --git a/resources/views/layouts/app.blade.php b/resources/views/layouts/app.blade.php index 3e579f0..3c57e60 100644 --- a/resources/views/layouts/app.blade.php +++ b/resources/views/layouts/app.blade.php @@ -189,7 +189,7 @@ Whitelist Log
  • - Exterminatus + Exterminatus
  • diff --git a/resources/views/server/exterminatus/index.blade.php b/resources/views/server/exterminatus/index.blade.php new file mode 100644 index 0000000..abfc873 --- /dev/null +++ b/resources/views/server/exterminatus/index.blade.php @@ -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 .--}} + +@extends('layouts.app') + +@section('content') +
    +
    +
    + @include('components.formerrors') + +
    +
    Exterminatus Control Panel
    + +
    + {{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() }} +
    +
    +
    +
    +
    +@endsection \ No newline at end of file diff --git a/resources/views/server/player/whitelist_jobs_stats.blade.php b/resources/views/server/player/whitelist_jobs_stats.blade.php new file mode 100644 index 0000000..98911a0 --- /dev/null +++ b/resources/views/server/player/whitelist_jobs_stats.blade.php @@ -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 .--}} + +@extends('layouts.app') + +@section('content') +
    +
    +
    +
    +
    Rounds played as a Specific Job by {{$species}}
    + + + + + + + + + + @foreach($stats as $stat) + + + + + @endforeach() + +
    JobRounds Played
    {{$stat->job_name}}{{$stat->count}}
    +
    +
    +
    +
    +@endsection + +@section('javascripts') + + +@endsection \ No newline at end of file diff --git a/resources/views/server/player/whitelist_stats.blade.php b/resources/views/server/player/whitelist_stats.blade.php new file mode 100644 index 0000000..214b5e6 --- /dev/null +++ b/resources/views/server/player/whitelist_stats.blade.php @@ -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 .--}} + +@extends('layouts.app') + +@section('content') +
    +
    +
    +
    +
    Whitelist Stats
    + + + + + + + + + + + + @foreach($stats as $stat) + subspecies == 1)class="bg-info"@endif()> + + + + + + @endforeach() + +
    SpeciesWhitelistCharacters
    {{$stat->status_name}}{{$stat->player_count}}{{$stat->char_count}}Jobs
    +
    +
    +
    +
    +@endsection + +@section('javascripts') + + +@endsection \ No newline at end of file