URLs include address, automatically connected to if password is present
This commit is contained in:
@@ -11,11 +11,12 @@ app.config( function ( $mdThemingProvider, $routeProvider )
|
||||
'default': '700'
|
||||
}).accentPalette( 'blue' );
|
||||
|
||||
$routeProvider.when( "/console", { Title: "Console", templateUrl: "html/console.html", Nav: true } )
|
||||
$routeProvider.when( "/playerlist", { Title: "Player List", templateUrl: "html/playerlist.html", Nav: true } )
|
||||
$routeProvider.when( "/player/:userid", { Title: "Player Info", templateUrl: "html/playerInfo.html" } )
|
||||
$routeProvider.when( "/player/:userid/xp", { Title: "Player Xp Stats", templateUrl: "html/playerXp.html" } )
|
||||
.otherwise( { redirectTo: '/console' } );
|
||||
$routeProvider.when( "/home", { Title: "Home", templateUrl: "html/home.html" } )
|
||||
$routeProvider.when( "/:address/console", { Title: "Console", templateUrl: "html/console.html", Nav: true } )
|
||||
$routeProvider.when( "/:address/playerlist", { Title: "Player List", templateUrl: "html/playerlist.html", Nav: true } )
|
||||
$routeProvider.when( "/:address/player/:userid", { Title: "Player Info", templateUrl: "html/playerInfo.html" } )
|
||||
$routeProvider.when( "/:address/player/:userid/xp", { Title: "Player Xp Stats", templateUrl: "html/playerXp.html" } )
|
||||
$routeProvider.otherwise( { redirectTo: '/home' } );
|
||||
|
||||
} );
|
||||
|
||||
@@ -24,6 +25,7 @@ app.controller( 'RconController', RconController );
|
||||
function RconController( $scope, $rootScope, rconService, $mdSidenav, $timeout, $mdDialog, $route )
|
||||
{
|
||||
$scope.$route = $route;
|
||||
|
||||
|
||||
$scope.pages = $.map( $route.routes, function ( value, index )
|
||||
{
|
||||
@@ -40,6 +42,11 @@ function RconController( $scope, $rootScope, rconService, $mdSidenav, $timeout,
|
||||
return rconService.IsConnected();
|
||||
}
|
||||
|
||||
$rootScope.Nav = function ( url )
|
||||
{
|
||||
return url.replace( ":address", rconService.Address );
|
||||
}
|
||||
|
||||
$rootScope.$on( '$stateChangeStart', function ( next, current )
|
||||
{
|
||||
console.log( next );
|
||||
@@ -50,6 +57,7 @@ function RconController( $scope, $rootScope, rconService, $mdSidenav, $timeout,
|
||||
$scope.Connected = true;
|
||||
$scope.$broadcast( "OnConnected" );
|
||||
$scope.$digest();
|
||||
$scope.address = rconService.Address;
|
||||
}
|
||||
|
||||
rconService.OnClose = function ( ev )
|
||||
@@ -73,55 +81,6 @@ function RconController( $scope, $rootScope, rconService, $mdSidenav, $timeout,
|
||||
}
|
||||
}
|
||||
|
||||
app.controller( 'ConnectionController', ConnectionController );
|
||||
|
||||
function ConnectionController( $scope, rconService )
|
||||
{
|
||||
$scope.Address = "";
|
||||
$scope.Password = "";
|
||||
$scope.SaveConnection = true;
|
||||
|
||||
if ( localStorage.previousConnections != null )
|
||||
$scope.PreviousConnects = angular.fromJson( localStorage.previousConnections );
|
||||
|
||||
if ( $scope.PreviousConnects == null )
|
||||
$scope.PreviousConnects = new Array();
|
||||
|
||||
$scope.Connect = function ()
|
||||
{
|
||||
$scope.LastErrorMessage = null;
|
||||
rconService.Connect( $scope.Address, $scope.Password );
|
||||
}
|
||||
|
||||
$scope.ConnectTo = function ( c )
|
||||
{
|
||||
$scope.SaveConnection = false;
|
||||
$scope.LastErrorMessage = null;
|
||||
rconService.Connect( c.Address, c.Password );
|
||||
}
|
||||
|
||||
$scope.$on( "OnDisconnected", function ( x, ev )
|
||||
{
|
||||
console.log( ev );
|
||||
$scope.LastErrorMessage = "Connection was closed - Error " + ev.code;
|
||||
$scope.$digest();
|
||||
} );
|
||||
|
||||
$scope.$on( "OnConnected", function ( x, ev )
|
||||
{
|
||||
if ( $scope.SaveConnection )
|
||||
{
|
||||
$scope.PreviousConnects.push( { Address: $scope.Address, Password: $scope.Password } );
|
||||
localStorage.previousConnections = angular.toJson( $scope.PreviousConnects );
|
||||
}
|
||||
} );
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
app.filter( 'SecondsToDuration', [SecondsToDuration] );
|
||||
|
||||
function SecondsToDuration()
|
||||
|
||||
@@ -0,0 +1,64 @@
|
||||
|
||||
app.controller( 'ConnectionController', ConnectionController );
|
||||
|
||||
function ConnectionController( $scope, rconService, $routeParams, $timeout )
|
||||
{
|
||||
$scope.Address = "";
|
||||
$scope.Password = "";
|
||||
$scope.SaveConnection = true;
|
||||
|
||||
if ( localStorage.previousConnections != null )
|
||||
$scope.PreviousConnects = angular.fromJson( localStorage.previousConnections );
|
||||
|
||||
if ( $scope.PreviousConnects == null )
|
||||
$scope.PreviousConnects = new Array();
|
||||
|
||||
$scope.Connect = function ()
|
||||
{
|
||||
$scope.LastErrorMessage = null;
|
||||
rconService.Connect( $scope.Address, $scope.Password );
|
||||
}
|
||||
|
||||
$scope.ConnectTo = function ( c )
|
||||
{
|
||||
$scope.SaveConnection = false;
|
||||
$scope.LastErrorMessage = null;
|
||||
rconService.Connect( c.Address, c.Password );
|
||||
}
|
||||
|
||||
$scope.$on( "OnDisconnected", function ( x, ev )
|
||||
{
|
||||
console.log( ev );
|
||||
$scope.LastErrorMessage = "Connection was closed - Error " + ev.code;
|
||||
$scope.$digest();
|
||||
} );
|
||||
|
||||
$scope.$on( "OnConnected", function ( x, ev )
|
||||
{
|
||||
if ( $scope.SaveConnection )
|
||||
{
|
||||
$scope.PreviousConnects.push( { Address: $scope.Address, Password: $scope.Password } );
|
||||
localStorage.previousConnections = angular.toJson( $scope.PreviousConnects );
|
||||
}
|
||||
} );
|
||||
|
||||
|
||||
//
|
||||
// If a server address is passed in.. try to connect if we have a saved entry
|
||||
//
|
||||
$timeout( function ()
|
||||
{
|
||||
$scope.Address = $routeParams.address;
|
||||
|
||||
if ( $scope.Address != null )
|
||||
{
|
||||
var foundAddress = Enumerable.From( $scope.PreviousConnects ).Where( function ( x ) { return x.Address == $scope.Address } ).First();
|
||||
if ( foundAddress != null )
|
||||
{
|
||||
$scope.ConnectTo( foundAddress );
|
||||
}
|
||||
}
|
||||
|
||||
}, 20 );
|
||||
}
|
||||
|
||||
+1
-2
@@ -12,6 +12,7 @@ function RconService()
|
||||
s.Connect = function ( addr, pass )
|
||||
{
|
||||
s.Socket = new WebSocket( "ws://" + addr + "/" + pass );
|
||||
s.Address = addr;
|
||||
|
||||
s.Socket.onmessage = function ( e )
|
||||
{
|
||||
@@ -49,8 +50,6 @@ function RconService()
|
||||
s.Socket.onopen = s.OnOpen;
|
||||
s.Socket.onclose = s.OnClose;
|
||||
s.Socket.onerror = s.OnError;
|
||||
|
||||
console.log( s.Socket );
|
||||
}
|
||||
|
||||
s.Command = function ( msg, identifier )
|
||||
|
||||
Reference in New Issue
Block a user