Skip to content

Commit

Permalink
added 2 more
Browse files Browse the repository at this point in the history
  • Loading branch information
supertick committed Mar 2, 2024
1 parent 3b63f25 commit ea1a1d4
Show file tree
Hide file tree
Showing 2 changed files with 89 additions and 0 deletions.
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)
},
])
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>

0 comments on commit ea1a1d4

Please sign in to comment.