Added Command History to console
This commit is contained in:
+4
-4
@@ -1,11 +1,11 @@
|
|||||||
<div ng-controller="ConsoleController" id="ConsoleController">
|
<div ng-controller="ConsoleController" id="ConsoleController">
|
||||||
|
|
||||||
<div id="vertical-container" style="height: 600px" class="Output scrollable"><div ng-repeat="line in Output" ng-class="line.Class">{{line.Message}}</div></div>
|
<div id="vertical-container" style="height: 600px" class="Output scrollable">
|
||||||
|
<div ng-repeat="line in Output" ng-class="line.Class">{{line.Message}}</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
<form ng-submit="SubmitCommand()" class="md-inline-form">
|
<form ng-submit="SubmitCommand()" class="md-inline-form">
|
||||||
<div>
|
<input type="text" class="form-control" ng-model="Command" ng-keyup="KeyUp($event)" />
|
||||||
<input class="form-control" ng-model="Command" style="width: 100%">
|
|
||||||
</div>
|
|
||||||
</form>
|
</form>
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
+33
-3
@@ -3,16 +3,46 @@ app.controller( 'ConsoleController', ConsoleController );
|
|||||||
|
|
||||||
function ConsoleController( $scope, rconService, $timeout )
|
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.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 );
|
rconService.Command( $scope.Command, 1 );
|
||||||
$scope.Command = "";
|
$scope.Command = "";
|
||||||
|
$scope.commandHistoryIndex = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
$scope.$on( "OnMessage", function ( event, msg ) { $scope.OnMessage( msg ); } );
|
$scope.$on( "OnMessage", function ( event, msg ) { $scope.OnMessage( msg ); } );
|
||||||
|
|
||||||
$scope.OnMessage = function( msg )
|
$scope.OnMessage = function( msg )
|
||||||
|
|||||||
Reference in New Issue
Block a user