diff --git a/token-validator/htdocs/js/adlin-main.js b/token-validator/htdocs/js/adlin-main.js index 65df507..7700889 100644 --- a/token-validator/htdocs/js/adlin-main.js +++ b/token-validator/htdocs/js/adlin-main.js @@ -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({ diff --git a/token-validator/htdocs/views/tunnels.html b/token-validator/htdocs/views/tunnels.html index b2b6cec..784c981 100644 --- a/token-validator/htdocs/views/tunnels.html +++ b/token-validator/htdocs/views/tunnels.html @@ -5,22 +5,23 @@
Token | Dernière utilisation | Clef publique | -||||
---|---|---|---|---|---|---|
+ > + ❌ + | {{ tunnel.TokenText }} |
- {{ tunnel.Time | date:"medium" }} | +{{ tunnel.Time | date:"medium" }} (VM TP {{ tunnel.Version }}) | {{ tunnel.PubKey }} (none) |
- 💻 - | -- |