From 9eef255053d96ea9b7e9ef74904dcd47f7ea5255 Mon Sep 17 00:00:00 2001 From: alexfriesen Date: Sun, 1 May 2016 17:55:40 +0200 Subject: [PATCH 1/7] fix server Info layout --- html/serverInfo.html | 40 +++++++++------------------------------- 1 file changed, 9 insertions(+), 31 deletions(-) diff --git a/html/serverInfo.html b/html/serverInfo.html index 25ec4d9..1ebd2bc 100644 --- a/html/serverInfo.html +++ b/html/serverInfo.html @@ -13,63 +13,41 @@
-
-

Map: {{info.Map}}

-
+

Map: {{info.Map}}

-
-

Max Players: {{info.MaxPlayers}}

-
+

Max Players: {{info.MaxPlayers}}

-
-

GameTime: {{info.GameTime}}

-
+

GameTime: {{info.GameTime}}

-
-

Framerate: {{info.Framerate}}

-
+

Framerate: {{info.Framerate}}

-
-

EntityCount: {{info.EntityCount}}

-
+

EntityCount: {{info.EntityCount}}

-
-

Uptime: {{info.Uptime}}s

-
+

Uptime: {{info.Uptime}}

-
-

Players: {{info.Players}}

-
+

Players: {{info.Players}}

-
-

Joining: {{info.Joining}}

-
+

Joining: {{info.Joining}}

-
-

Queued: {{info.Queued}}

-
+

Queued: {{info.Queued}}

-
- -
- From 7a6a1e13fcf230572633975341096c5a29e78223 Mon Sep 17 00:00:00 2001 From: alexfriesen Date: Wed, 18 May 2016 14:03:54 +0200 Subject: [PATCH 2/7] make info columns responsive --- html/serverInfo.html | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/html/serverInfo.html b/html/serverInfo.html index 1ebd2bc..9c3a95a 100644 --- a/html/serverInfo.html +++ b/html/serverInfo.html @@ -12,39 +12,39 @@ -
+

Map: {{info.Map}}

-
+

Max Players: {{info.MaxPlayers}}

-
+

GameTime: {{info.GameTime}}

-
+

Framerate: {{info.Framerate}}

-
+

EntityCount: {{info.EntityCount}}

-
+

Uptime: {{info.Uptime}}

-
+

Players: {{info.Players}}

-
+

Joining: {{info.Joining}}

-
+

Queued: {{info.Queued}}

From 172ee95216df367e88aa0c110a8429ce5c7ecbf1 Mon Sep 17 00:00:00 2001 From: alexfriesen Date: Wed, 18 May 2016 14:10:03 +0200 Subject: [PATCH 3/7] rconService.getUsers() will get and parse the userdata PlayerInfo displays Info and provide a link to steam profile Dropdown in the Playerlist offers more options the selected Player --- html/playerInfo.html | 44 +++++++++++++++++++++++++++++++++++++++++--- html/playerlist.html | 18 +++++++++++++++++- js/playerInfo.js | 32 ++++++++++++++++++++++++++++++++ js/playerlist.js | 6 +++--- js/rconService.js | 17 ++++++++++++++--- 5 files changed, 107 insertions(+), 10 deletions(-) diff --git a/html/playerInfo.html b/html/playerInfo.html index 781ddfa..d44223e 100644 --- a/html/playerInfo.html +++ b/html/playerInfo.html @@ -1,9 +1,47 @@
- Info about player {{userid}} +
-

View XP info for this player

-Show info about this player here +
+ +

+ Player: {{getUsername()}} +
+ +
+

+ + + +
+ +
+

+ Info +

+ +
+ This Player is currently not connected to this server! +
+
+ +
+

{{key}}: {{value}}

+
+
\ No newline at end of file diff --git a/html/playerlist.html b/html/playerlist.html index 4feacba..db35f53 100644 --- a/html/playerlist.html +++ b/html/playerlist.html @@ -33,8 +33,24 @@
diff --git a/js/playerInfo.js b/js/playerInfo.js index 92d07a2..87c2dc8 100644 --- a/js/playerInfo.js +++ b/js/playerInfo.js @@ -4,4 +4,36 @@ app.controller( 'PlayerInfoController', PlayerInfoController ); function PlayerInfoController( $scope, rconService, $routeParams ) { $scope.userid = $routeParams.userid; + + $scope.info = null; + + $scope.refresh = function () + { + rconService.getUsers($scope, function(users) { + + for(var i in users) { + if(users[i].SteamID === $scope.userid){ + + // set player data + $scope.info = users[i]; + + return; + } + } + + // info not found + $scope.info = null; + }); + } + + $scope.getUsername = function () + { + if($scope.info && $scope.info.DisplayName) { + return $scope.info.DisplayName; + } + + return $scope.userid; + } + + rconService.InstallService( $scope, $scope.refresh ) } \ No newline at end of file diff --git a/js/playerlist.js b/js/playerlist.js index 390ab88..45955d2 100644 --- a/js/playerlist.js +++ b/js/playerlist.js @@ -3,14 +3,14 @@ app.controller( 'PlayerListController', PlayerListController ); function PlayerListController( $scope, rconService, $interval ) { - $scope.Output = new Array(); + $scope.Output = []; $scope.OrderBy = '-ConnectedSeconds'; $scope.Refresh = function () { - rconService.Request( "playerlist", $scope, function ( msg ) + rconService.getUsers($scope, function ( users ) { - $scope.Players = JSON.parse( msg.Message ); + $scope.Players = users; }); } diff --git a/js/rconService.js b/js/rconService.js index 58aa456..4703e69 100644 --- a/js/rconService.js +++ b/js/rconService.js @@ -1,9 +1,9 @@ function RconService() { - var s = {}; - - s.Callbacks = {}; + var s = { + Callbacks: {} + }; s.Connect = function ( addr, pass ) { @@ -102,5 +102,16 @@ function RconService() } } + s.getUsers = function(scope, success) { + this.Request( "playerlist", scope, function ( response ) + { + var players = JSON.parse( response.Message ); + + if(typeof success === 'function') { + success.call(scope, players); + } + }); + } + return s; } \ No newline at end of file From 12c58af9affaeaf325e9f0585a19db9666adec7f Mon Sep 17 00:00:00 2001 From: alexfriesen Date: Wed, 18 May 2016 14:16:27 +0200 Subject: [PATCH 4/7] Added Command History to console --- html/console.html | 8 ++++---- js/console.js | 36 +++++++++++++++++++++++++++++++++--- 2 files changed, 37 insertions(+), 7 deletions(-) diff --git a/html/console.html b/html/console.html index 89d066c..acb194b 100644 --- a/html/console.html +++ b/html/console.html @@ -1,11 +1,11 @@
-
{{line.Message}}
+
+
{{line.Message}}
+
-
- -
+
\ No newline at end of file diff --git a/js/console.js b/js/console.js index 02ce256..1bd5537 100644 --- a/js/console.js +++ b/js/console.js @@ -3,16 +3,46 @@ app.controller( 'ConsoleController', ConsoleController ); function ConsoleController( $scope, rconService, $timeout ) { - $scope.Output = new Array(); + $scope.Output = []; + $scope.commandHistory = []; + $scope.commandHistoryIndex = 0; + + $scope.KeyUp = function (event) + { + switch(event.keyCode) { + + // Arrow Up Key + case 38: + // rotate through commandHistory + $scope.commandHistoryIndex++; + if($scope.commandHistoryIndex >= $scope.commandHistory.length) { + $scope.commandHistoryIndex = 0; + } + + // set command from history + if($scope.commandHistory[$scope.commandHistoryIndex]) { + $scope.Command = $scope.commandHistory[$scope.commandHistoryIndex]; + } + + break; + + default: + // reset command history index + $scope.commandHistoryIndex = 0; + break; + } + } $scope.SubmitCommand = function () { - $scope.OnMessage( { Message: $scope.Command, Type: 'Command' } ) + $scope.OnMessage( { Message: $scope.Command, Type: 'Command' } ); + + $scope.commandHistory.push($scope.Command); rconService.Command( $scope.Command, 1 ); $scope.Command = ""; + $scope.commandHistoryIndex = 0; } - $scope.$on( "OnMessage", function ( event, msg ) { $scope.OnMessage( msg ); } ); $scope.OnMessage = function( msg ) From 90c60f9fa9534c5aa1bd2ed4f0e1ed0f3f3df674 Mon Sep 17 00:00:00 2001 From: alexfriesen Date: Thu, 19 May 2016 18:58:36 +0200 Subject: [PATCH 5/7] renamed rconService.getUsers() to rconService.getPlayers() to be consistent console History rotates correctly up and down --- js/console.js | 21 +++++++++++++++++++-- js/playerInfo.js | 13 ++++++++----- js/playerlist.js | 4 ++-- js/rconService.js | 2 +- 4 files changed, 30 insertions(+), 10 deletions(-) diff --git a/js/console.js b/js/console.js index 1bd5537..abd19c2 100644 --- a/js/console.js +++ b/js/console.js @@ -11,8 +11,25 @@ function ConsoleController( $scope, rconService, $timeout ) { switch(event.keyCode) { - // Arrow Up Key + // Arrow Key Up case 38: + + // rotate through commandHistory + $scope.commandHistoryIndex--; + if($scope.commandHistoryIndex < 0) { + $scope.commandHistoryIndex = $scope.commandHistory.length; + } + + // set command from history + if($scope.commandHistory[$scope.commandHistoryIndex]) { + $scope.Command = $scope.commandHistory[$scope.commandHistoryIndex]; + } + + break; + + // Arrow Key Down + case 40: + // rotate through commandHistory $scope.commandHistoryIndex++; if($scope.commandHistoryIndex >= $scope.commandHistory.length) { @@ -28,7 +45,7 @@ function ConsoleController( $scope, rconService, $timeout ) default: // reset command history index - $scope.commandHistoryIndex = 0; + $scope.commandHistoryIndex = $scope.commandHistory.length; break; } } diff --git a/js/playerInfo.js b/js/playerInfo.js index 87c2dc8..24f594f 100644 --- a/js/playerInfo.js +++ b/js/playerInfo.js @@ -9,29 +9,32 @@ function PlayerInfoController( $scope, rconService, $routeParams ) $scope.refresh = function () { - rconService.getUsers($scope, function(users) { + rconService.getPlayers($scope, function(players) { - for(var i in users) { - if(users[i].SteamID === $scope.userid){ + for(var i in players) { + if(players[i].SteamID === $scope.userid){ // set player data - $scope.info = users[i]; + $scope.info = players[i]; return; } } - // info not found + // player not found + // reset data to null $scope.info = null; }); } $scope.getUsername = function () { + // try to find players name in info if($scope.info && $scope.info.DisplayName) { return $scope.info.DisplayName; } + // otherwise show the id return $scope.userid; } diff --git a/js/playerlist.js b/js/playerlist.js index 45955d2..820faea 100644 --- a/js/playerlist.js +++ b/js/playerlist.js @@ -8,9 +8,9 @@ function PlayerListController( $scope, rconService, $interval ) $scope.Refresh = function () { - rconService.getUsers($scope, function ( users ) + rconService.getPlayers($scope, function ( players ) { - $scope.Players = users; + $scope.Players = players; }); } diff --git a/js/rconService.js b/js/rconService.js index 4703e69..15853fb 100644 --- a/js/rconService.js +++ b/js/rconService.js @@ -102,7 +102,7 @@ function RconService() } } - s.getUsers = function(scope, success) { + s.getPlayers = function(scope, success) { this.Request( "playerlist", scope, function ( response ) { var players = JSON.parse( response.Message ); From b6558c68e830f45418a2429182d1b23c78599e78 Mon Sep 17 00:00:00 2001 From: alexfriesen Date: Thu, 2 Jun 2016 10:18:57 +0200 Subject: [PATCH 6/7] only scroll if already on bottom in console and cleaned some code --- js/console.js | 67 +++++++++++++++++++++++++++++++++++++++++---------- 1 file changed, 54 insertions(+), 13 deletions(-) diff --git a/js/console.js b/js/console.js index abd19c2..699bafc 100644 --- a/js/console.js +++ b/js/console.js @@ -65,23 +65,52 @@ function ConsoleController( $scope, rconService, $timeout ) $scope.OnMessage = function( msg ) { - if ( msg.Message.startsWith( "[rcon] " ) ) return; - if ( msg.Type != "Generic" && msg.Type != "Log" && msg.Type != "Error" && msg.Type != "Warning" ) - { - console.log( msg ); - return; + if ( msg.Message.startsWith( "[rcon] " ) ) { + return; } - msg.Class = msg.Type; - $scope.Output.push( msg ); + switch(msg.Type) { + case 'Generic': + case 'Log': + case 'Error': + case 'Warning': + $scope.addOutput(msg); + break; - $timeout( $scope.ScrollToBottom, 50 ); + default: + console.log( msg ); + return; + } } $scope.ScrollToBottom = function() { - // TODO - don't scroll if we're not at the bottom ! - $( "#ConsoleController .Output" ).scrollTop( $( "#ConsoleController .Output" )[0].scrollHeight ); + var element = $( "#ConsoleController .Output" ); + + $timeout( function() { + element.scrollTop( element.prop('scrollHeight') ); + }, 50 ); + } + + $scope.isOnBottom = function() + { + // get jquery element + var element = $( "#ConsoleController .Output" ); + + // height of the element + var height = element.height(); + + // scroll position from top position + var scrollTop = element.scrollTop(); + + // full height of the element + var scrollHeight = element.prop('scrollHeight'); + + if((scrollTop + height) > (scrollHeight - 10)) { + return true; + } + + return false; } // @@ -90,15 +119,27 @@ function ConsoleController( $scope, rconService, $timeout ) // $scope.GetHistory = function () { - console.log( "GetHistory" ); - rconService.Request( "console.tail 128", $scope, function ( msg ) { var messages = JSON.parse( msg.Message ); - messages.forEach( function ( x ) { $scope.OnMessage( x ); } ); + messages.forEach( function ( msg ) { + $scope.OnMessage( msg ); + }); + + $scope.ScrollToBottom(); } ); } + $scope.addOutput = function (msg) + { + msg.Class = msg.Type; + $scope.Output.push( msg ); + + if($scope.isOnBottom()) { + $scope.ScrollToBottom(); + } + } + rconService.InstallService( $scope, $scope.GetHistory ) } \ No newline at end of file From 7697c6baac0396c52af3b28ca6e893334bc6bbb1 Mon Sep 17 00:00:00 2001 From: alexfriesen Date: Thu, 2 Jun 2016 15:40:54 +0200 Subject: [PATCH 7/7] reworked the connection view - use bootstrap styling - connections will save the date - connection duplicates will be removed on a new connection - saved connections can be toggled between 5 items and all --- html/connect.html | 68 +++++++++++++++++++++-------------------------- js/connection.js | 60 ++++++++++++++++++++++++++++++++++++----- 2 files changed, 85 insertions(+), 43 deletions(-) diff --git a/html/connect.html b/html/connect.html index 72e7ed3..c9cdbd8 100644 --- a/html/connect.html +++ b/html/connect.html @@ -1,57 +1,51 @@
-
+

Connect

-
{{LastErrorMessage}}
+
{{LastErrorMessage}}
-

Enter the address (including rcon port) and the rcon password below to connect.

+

Enter the address (including rcon port) and the rcon password below to connect.

-
-
- - -
- - -
- -
- - -
- -
- - Save Connection -
- -

- -
- -
- -
+ +
+
+ +
- -
+
+ + +
-
+
+ +
+ + + +
+ + +
+ +

Saved Connections

-
- - -
\ No newline at end of file diff --git a/js/connection.js b/js/connection.js index d4781f8..f11882d 100644 --- a/js/connection.js +++ b/js/connection.js @@ -7,11 +7,51 @@ function ConnectionController( $scope, rconService, $routeParams, $timeout, $loc $scope.Password = ""; $scope.SaveConnection = true; - if ( localStorage.previousConnections != null ) - $scope.PreviousConnects = angular.fromJson( localStorage.previousConnections ); + $scope.connectionsLimit = 5; - if ( $scope.PreviousConnects == null ) - $scope.PreviousConnects = new Array(); + function _loadFromLocalStorage() { + var connections = []; + + // load and parse from local storage + if ( localStorage && localStorage.previousConnections ) { + connections = angular.fromJson( localStorage.previousConnections ); + } + + // double check + if ( !connections ) { + connections = []; + } + + return connections; + } + + function _addWithoutDuplicates(connections, connection) { + // prepare new array + var filteredConnections = []; + + for(var i in connections) { + if(connections[i].Address !== connection.Address && connections[i].Password !== connection.Password) { + // add old connection info to our new array + filteredConnections.push(connections[i]); + } + } + + // add new connection + filteredConnections.push(connection); + + return filteredConnections; + } + + $scope.toggleConnectionsLimit = function () + { + // toggle limit between undefined and 5 + // undefined sets limit to max + if($scope.connectionsLimit === undefined) { + $scope.connectionsLimit = 5; + } else { + $scope.connectionsLimit = undefined; + } + } $scope.Connect = function () { @@ -42,11 +82,19 @@ function ConnectionController( $scope, rconService, $routeParams, $timeout, $loc { if ( $scope.SaveConnection ) { - $scope.PreviousConnects.push( { Address: $scope.Address, Password: $scope.Password } ); + // new connection to add + var connection = { Address: $scope.Address, Password: $scope.Password, date: new Date() }; + + // remove old entries and add our new connection info + var connections = _addWithoutDuplicates(_loadFromLocalStorage(), connection); + + // push to scope and save data + $scope.PreviousConnects = connections; localStorage.previousConnections = angular.toJson( $scope.PreviousConnects ); } } ); + $scope.PreviousConnects = _loadFromLocalStorage(); // // If a server address is passed in.. try to connect if we have a saved entry @@ -83,5 +131,5 @@ function ConnectionController( $scope, rconService, $routeParams, $timeout, $loc } }, 20 ); + } -