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
This commit is contained in:
alexfriesen
2016-05-18 14:10:03 +02:00
parent 7a6a1e13fc
commit 172ee95216
5 changed files with 107 additions and 10 deletions
+41 -3
View File
@@ -1,9 +1,47 @@
<div ng-controller="PlayerInfoController" flex layout="column" id="PlayerInfoController"> <div ng-controller="PlayerInfoController" flex layout="column" id="PlayerInfoController">
Info about player {{userid}} <div class="row">
<p>View <a href="#/{{address}}/player/{{userid}}/xp">XP info for this player</a></p> <div class="col-lg-12">
Show info about this player here
<h2 class="center">
Player: {{getUsername()}}
<div class="btn-group pull-right">
<button ng-click="refresh()" class="btn btn-default" type="button"><i class="glyphicon glyphicon-refresh"></i></button>
</div>
</h2>
<div class="btn-group btn-group-lg btn-group-justified">
<div class="btn-group">
<a href="#/{{address}}/player/{{userid}}/xp" class="btn btn-default">
<span class="glyphicon glyphicon-education"></span>
XP Info
</a>
</div>
<div class="btn-group">
<a href="http://www.steamcommunity.com/profiles/{{userid}}" target="_blank" class="btn btn-default">
<span class="glyphicon glyphicon-info-sign"></span>
Steam Profile
</a>
</div>
</div>
</div>
<div class="col-lg-12">
<h2 class="center">
Info
</h2>
<div class="alert alert-warning" ng-show="!info">
This Player is currently not connected to this server!
</div>
</div>
<div class="col-sm-4" ng-repeat="(key, value) in info">
<p>{{key}}: <span class="badge">{{value}}</span></p>
</div>
</div>
</div> </div>
+17 -1
View File
@@ -34,7 +34,23 @@
</button> </button>
<ul class="dropdown-menu"> <ul class="dropdown-menu">
<li> <li>
<a href ng-click="KickPlayer(line.SteamID)">Kick</a> <a href="#/{{address}}/player/{{line.SteamID}}/xp">
<span class="glyphicon glyphicon-education"></span>
XP Info
</a>
</li>
<li>
<a href="http://www.steamcommunity.com/profiles/{{line.SteamID}}" target="_blank">
<span class="glyphicon glyphicon-info-sign"></span>
Steam Profile
</a>
</li>
<li class="divider"></li>
<li>
<a href ng-click="KickPlayer(line.SteamID)">
<span class="glyphicon glyphicon-trash"></span>
Kick
</a>
</li> </li>
</ul> </ul>
</div> </div>
+32
View File
@@ -4,4 +4,36 @@ app.controller( 'PlayerInfoController', PlayerInfoController );
function PlayerInfoController( $scope, rconService, $routeParams ) function PlayerInfoController( $scope, rconService, $routeParams )
{ {
$scope.userid = $routeParams.userid; $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 )
} }
+3 -3
View File
@@ -3,14 +3,14 @@ app.controller( 'PlayerListController', PlayerListController );
function PlayerListController( $scope, rconService, $interval ) function PlayerListController( $scope, rconService, $interval )
{ {
$scope.Output = new Array(); $scope.Output = [];
$scope.OrderBy = '-ConnectedSeconds'; $scope.OrderBy = '-ConnectedSeconds';
$scope.Refresh = function () $scope.Refresh = function ()
{ {
rconService.Request( "playerlist", $scope, function ( msg ) rconService.getUsers($scope, function ( users )
{ {
$scope.Players = JSON.parse( msg.Message ); $scope.Players = users;
}); });
} }
+14 -3
View File
@@ -1,9 +1,9 @@
function RconService() function RconService()
{ {
var s = {}; var s = {
Callbacks: {}
s.Callbacks = {}; };
s.Connect = function ( addr, pass ) 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; return s;
} }