token-validator: reorganize tunnels page to clarify active tunnels and connected tunnels
This commit is contained in:
parent
1f47b01294
commit
e7d9b1c89f
2 changed files with 42 additions and 8 deletions
|
@ -33,6 +33,17 @@ angular.module("AdLinApp")
|
|||
});
|
||||
|
||||
angular.module("AdLinApp")
|
||||
.filter("since", function() {
|
||||
return function(passed) {
|
||||
passed -= Date.now()/1000
|
||||
if (passed < 120) {
|
||||
return Math.floor(-passed) + " seconds ago";
|
||||
} else {
|
||||
return Math.floor(-passed/60) + " minutes ago";
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
.component('toast', {
|
||||
bindings: {
|
||||
date: '=',
|
||||
|
@ -157,6 +168,25 @@ angular.module("AdLinApp")
|
|||
var myinterval = $interval($scope.updateTunnelsList, 12000);
|
||||
$scope.$on('$destroy', function () { $interval.cancel(myinterval); });
|
||||
|
||||
$scope.PING_ok = false;
|
||||
$scope.PING_time = '';
|
||||
$scope.PING = false;
|
||||
var refreshPing = function() {
|
||||
$http.get("/api/students/" + $scope.student.id + "/ping").then(function(response) {
|
||||
$scope.PING_ok = response.data.State;
|
||||
$scope.PING_time = new Date(response.data.Date);
|
||||
$scope.PING = (Date.now() - $scope.PING_time)/1000;
|
||||
});
|
||||
}
|
||||
var myPingInterval
|
||||
$scope.$watch("student", function(student) {
|
||||
if (student == null) return;
|
||||
$interval.cancel(myPingInterval);
|
||||
refreshPing();
|
||||
myPingInterval = $interval(refreshPing, 15000);
|
||||
})
|
||||
$scope.$on('$destroy', function () { $interval.cancel(myPingInterval); });
|
||||
|
||||
$scope.newTunnel = function() {
|
||||
$scope.pleaseWaitNew = true;
|
||||
$http({
|
||||
|
|
Reference in a new issue