Error fixing and code cleanup

This commit is contained in:
Pauli Jokela
2016-12-16 21:44:07 +02:00
parent 2da3351935
commit 3fcc651262
7 changed files with 9 additions and 211 deletions
Vendored
BIN
View File
Binary file not shown.
-42
View File
@@ -1,42 +0,0 @@
<div ng-controller="PlayerXpController" id="PlayerXpController">
<div class="row">
<div class="col-md-12">
<h2>
Statistics for player: <a href="#/{{address}}/player/{{userid}}/">{{userid}}</a>
</h2>
</div>
</div>
<div class="row">
<div class="col-md-12">
<h3>Xp Income Sources</h3>
<h5>Where has this user got their Xp from</h5>
<div class="panel">
<nvd3 options="Sources.Options" data="Sources.Data"></nvd3>
</div>
</div>
</div>
<div class="row">
<div class="col-md-12">
<h3>Xp Outgoing Sources</h3>
<h5>Where has this user spent their Xp</h5>
<div class="panel">
<nvd3 flex options="Outgoings.Options" data="Outgoings.Data"></nvd3>
</div>
</div>
</div>
<div class="row">
<div class="col-md-12">
<h3>Xp Over Time</h3>
<h5>How much XP has this user got over time</h5>
<div class="panel">
<nvd3 flex options="OverTime.Options" data="OverTime.Data"></nvd3>
</div>
</div>
</div>
</div>
+2 -18
View File
@@ -18,10 +18,8 @@
<th>Actions</th> <th>Actions</th>
<th ng-click="Order( 'DisplayName' )" ng-class="SortClass( 'DisplayName' )">Username</th> <th ng-click="Order( 'DisplayName' )" ng-class="SortClass( 'DisplayName' )">Username</th>
<th class="text-right" ng-click="Order( 'SteamID' )" ng-class="SortClass( 'SteamID' )">Steamid</th> <th class="text-right" ng-click="Order( 'SteamID' )" ng-class="SortClass( 'SteamID' )">Steam ID</th>
<th class="text-right" ng-click="Order( 'VoiationLevel' )" ng-class="SortClass( 'VoiationLevel' )">Voilation</th> <th class="text-right" ng-click="Order( 'VoiationLevel' )" ng-class="SortClass( 'VoiationLevel' )">Violation Level</th>
<th class="text-right" ng-click="Order( 'CurrentLevel' )" ng-class="SortClass( 'CurrentLevel' )">Level</th>
<th class="text-right" ng-click="Order( 'UnspentXp' )" ng-class="SortClass( 'UnspentXp' )">XP</th>
<th class="text-right" ng-click="Order( 'Address' )" ng-class="SortClass( 'Address' )">Address</th> <th class="text-right" ng-click="Order( 'Address' )" ng-class="SortClass( 'Address' )">Address</th>
<th class="text-right" ng-click="Order( 'Ping' )" ng-class="SortClass( 'Ping' )">Ping</th> <th class="text-right" ng-click="Order( 'Ping' )" ng-class="SortClass( 'Ping' )">Ping</th>
<th class="text-right" ng-click="Order( 'ConnectedSeconds' )" ng-class="SortClass( 'ConnectedSeconds' )">Duration</th> <th class="text-right" ng-click="Order( 'ConnectedSeconds' )" ng-class="SortClass( 'ConnectedSeconds' )">Duration</th>
@@ -35,12 +33,6 @@
<span class="glyphicon glyphicon-cog"></span> <span class="caret"></span> <span class="glyphicon glyphicon-cog"></span> <span class="caret"></span>
</button> </button>
<ul class="dropdown-menu"> <ul class="dropdown-menu">
<li>
<a href="#/{{address}}/player/{{line.SteamID}}/xp">
<span class="glyphicon glyphicon-education"></span>
XP Info
</a>
</li>
<li> <li>
<a href="http://www.steamcommunity.com/profiles/{{line.SteamID}}" target="_blank"> <a href="http://www.steamcommunity.com/profiles/{{line.SteamID}}" target="_blank">
<span class="glyphicon glyphicon-info-sign"></span> <span class="glyphicon glyphicon-info-sign"></span>
@@ -70,14 +62,6 @@
{{line.VoiationLevel}} {{line.VoiationLevel}}
</td> </td>
<td class="text-right">
{{line.CurrentLevel}}
</td>
<td class="text-right">
<a href="#/{{address}}/player/{{line.SteamID}}/xp">{{line.UnspentXp}}</a>
</td>
<td class="text-right"> <td class="text-right">
{{line.Address}} {{line.Address}}
</td> </td>
-1
View File
@@ -81,7 +81,6 @@
<script src="js/console.js"></script> <script src="js/console.js"></script>
<script src="js/playerlist.js"></script> <script src="js/playerlist.js"></script>
<script src="js/playerInfo.js"></script> <script src="js/playerInfo.js"></script>
<script src="js/playerXp.js"></script>
<script src="js/chat.js"></script> <script src="js/chat.js"></script>
</body> </body>
+1 -1
View File
@@ -114,7 +114,7 @@ function ConsoleController( $scope, rconService, $timeout )
} }
// //
// Calls console.tail - which returns the last 256 entries from the console. // Calls console.tail - which returns the last 128 entries from the console.
// This is then added to the console // This is then added to the console
// //
$scope.GetHistory = function () $scope.GetHistory = function ()
-149
View File
@@ -1,149 +0,0 @@
app.controller( 'PlayerXpController', PlayerXpController );
function PlayerXpController( $scope, rconService, $routeParams )
{
$scope.userid = $routeParams.userid;
$scope.Sources =
{
Options: {
chart: {
type: "pieChart",
height: 400,
x: function ( d ) { return d.key; },
y: function ( d ) { return d.value; },
showLabels : false
}
}
};
$scope.Outgoings =
{
Options: {
chart: {
type: "pieChart",
height: 400,
x: function ( d ) { return d.key; },
y: function ( d ) { return d.value; },
showLabels: false
}
}
};
$scope.OverTime =
{
Options: {
chart: {
type: "multiBarChart",
height: 700,
stacked: true,
x: function ( d ) { return d[0]; },
y: function ( d ) { return Math.round( d[1] * 10 ) / 10; },
showLabels: false,
xAxis: { showMaxMin: false, tickFormat: function ( d ) { return d3.time.format( '%d %b %H%p' )( new Date( d ) ) } },
yAxis: { tickFormat: function ( d ) { return d3.format( ',.2f' )( d ); } },
clipEdge: true,
useInteractiveGuideline: true,
defined: function(d) { return d[0] != null }
}
}
}
$scope.Refresh = function ()
{
rconService.Request( "xp.history " + $scope.userid, $scope, function ( msg )
{
$scope.History = JSON.parse( msg.Message );
$scope.Sources.Data = Enumerable.From( $scope.History )
.Where( function ( x ) { return x.Amount > 0; } )
.GroupBy( "$.Type", null,
function ( key, g )
{
return {
key: key,
value: g.Sum( "$.Amount" )
}
} )
.ToArray();
$scope.Outgoings.Data = Enumerable.From( $scope.History )
.Where( function ( x ) { return x.Amount < 0; } )
.GroupBy( "$.Type", null,
function ( key, g )
{
return {
key: key,
value: -1 * g.Sum( "$.Amount" )
}
} )
.ToArray();
var Hour = 60 * 60;
$scope.OverTime.Data = FixMissingData( Enumerable.From( $scope.History )
.Where( function ( x ) { return x.Amount > 0; } )
.GroupBy( "$.Type", null,
function ( key, g )
{
return {
key: key,
values: g.GroupBy( function ( x ) { return Math.round( x.Date / Hour ) * Hour; }, null, function ( key, g )
{
return [key * 1000, g.Sum( "$.Amount" )];
} )
.ToArray()
}
} )
.ToArray(), Hour * 1000 );
console.log( $scope.OverTime.Data );
} );
}
rconService.InstallService( $scope, $scope.Refresh )
}
// Fix missing gaps in a range
function FixMissingData( data, series )
{
// Get the range
var min = Enumerable.From( data ).Min( function ( x ) { return Enumerable.From( x.values ).Min( "$[0]" ); } )
var max = Enumerable.From( data ).Max( function ( x ) { return Enumerable.From( x.values ).Max( "$[0]" ); } )
// Fucking Javascript You Cunt
data.forEach( function ( d )
{
var expected = min;
var newData = [];
d.values.forEach( function ( d )
{
while ( d[0] != expected && expected <= max )
{
newData.push( [expected, 0.0] );
expected += series;
}
if ( d[0] == expected )
{
newData.push( d );
expected += series;
}
} );
while ( expected <= max )
{
newData.push( [expected, 0.0] );
expected += series;
}
d.values = newData;
} );
return data;
}
+6
View File
@@ -52,6 +52,12 @@ function RconService()
if ( identifier == null ) if ( identifier == null )
identifier = -1; identifier = -1;
if ( s.Socket == null )
return;
if ( !s.IsConnected )
return;
var packet = var packet =
{ {
Identifier: identifier, Identifier: identifier,