-
-
Notifications
You must be signed in to change notification settings - Fork 109
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
89 additions
and
0 deletions.
There are no files selected for viewing
60 changes: 60 additions & 0 deletions
60
src/main/resources/resource/WebGui/app/service/js/TerminalManagerGui.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
angular.module("mrlapp.service.TerminalManagerGui", []).controller("TerminalManagerGuiCtrl", [ | ||
"$scope", | ||
"mrl", | ||
function ($scope, mrl) { | ||
console.info("TerminalManagerGuiCtrl") | ||
var _self = this | ||
var msg = this.msg | ||
|
||
// GOOD TEMPLATE TO FOLLOW | ||
this.updateState = function (service) { | ||
$scope.service = service | ||
} | ||
|
||
// init scope variables | ||
$scope.onTime = null | ||
$scope.onEpoch = null | ||
|
||
this.onMsg = function (inMsg) { | ||
let data = inMsg.data[0] | ||
switch (inMsg.method) { | ||
case "onState": | ||
_self.updateState(data) | ||
$scope.$apply() | ||
break | ||
case "onTime": | ||
const date = new Date(data) | ||
$scope.onTime = date.toLocaleString() | ||
$scope.$apply() | ||
break | ||
case "onEpoch": | ||
$scope.onEpoch = data | ||
$scope.$apply() | ||
break | ||
default: | ||
console.error("ERROR - unhandled method " + $scope.name + " " + inMsg.method) | ||
break | ||
} | ||
} | ||
|
||
// Assuming `service` is your service managing terminals | ||
$scope.startTerminal = function (key) { | ||
msg.send("startTerminal", key) | ||
} | ||
|
||
$scope.terminateTerminal = function (key) { | ||
msg.send("terminateTerminal", key) | ||
} | ||
|
||
$scope.saveTerminal = function (key) { | ||
msg.send("saveTerminal", key) | ||
} | ||
|
||
$scope.deleteTerminal = function (key) { | ||
msg.send("deleteTerminal", key) | ||
} | ||
|
||
msg.subscribe("publishEpoch") | ||
msg.subscribe(this) | ||
}, | ||
]) |
29 changes: 29 additions & 0 deletions
29
src/main/resources/resource/WebGui/app/service/views/TerminalManagerGui.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
<table class="table table-striped"> | ||
<thead> | ||
<tr> | ||
<th style="width: 10%"></th> | ||
<th style="width: 10%"></th> | ||
<th style="width: 10%"></th> | ||
<th style="width: 10%">Name</th> | ||
<th style="width: 10%">PID</th> | ||
<th style="width: 10%">Shell</th> | ||
<th style="width: 70%">Command</th> | ||
<th style="width: 70%">Control</th> | ||
</tr> | ||
</thead> | ||
<tr ng-repeat="(key, value) in service.terminals"> | ||
<td style="width: 10%"><input type="radio" name="selectedTerminal" ng-model="ctrl.selectedTerminal" ng-value="terminal" /></td> | ||
<td style="width: 10%"><img src="TerminalManager.png" width="16" /></td> | ||
<td style="width: 10%"><img ng-src="{{value.connected ? 'connected.png' : 'disconnected.png'}}" alt="Connection Status" width="16" /></td> | ||
<td style="width: 10%"><small>{{key}}</small></td> | ||
<td><small>{{value.pid}}</small></td> | ||
<td><small>{{value.shellCommand}}</small></td> | ||
<td><small>{{value.lastInput}}</small></td> | ||
<td> | ||
<button ng-click="startTerminal(key)">Start</button> | ||
<button ng-click="terminateTerminal(key)">Terminate</button> | ||
<button ng-click="saveTerminal(key)">Save</button> | ||
<button ng-click="deleteTerminal(key)">Delete</button> | ||
</td> | ||
</tr> | ||
</table> |