Add Stratux time to traffic.js

pull/259/head
AvSquirrel 2016-02-17 07:18:04 +00:00
rodzic 367dedc5a6
commit b49bb796ee
2 zmienionych plików z 62 dodań i 1 usunięć

Wyświetl plik

@ -55,6 +55,21 @@ function TrafficCtrl($rootScope, $scope, $state, $http, $interval) {
new_traffic.src = obj.Last_source; // 1=ES, 2=UAT
// return new_aircraft;
}
/*
function getStratuxTime() {
// Simple GET request example (note: response is asynchronous)
$http.get(URL_STATUS_GET).
then(function (response) {
globalStatus = angular.fromJson(response.data);
$scope.UptimeClock = globalStatus.UptimeClock;
$scope.Clock = globalStatus.Clock;
$scope.LocalClock = new Date();
}, function (response) {
// nop
});
};
*/
function connect($scope) {
if (($scope === undefined) || ($scope === null))
@ -86,6 +101,8 @@ function TrafficCtrl($rootScope, $scope, $state, $http, $interval) {
};
socket.onmessage = function (msg) {
console.log('Received traffic update.')
var message = JSON.parse(msg.data);
@ -111,6 +128,33 @@ function TrafficCtrl($rootScope, $scope, $state, $http, $interval) {
};
}
var getClock = $interval(function () {
$http.get(URL_STATUS_GET).
then(function (response) {
globalStatus = angular.fromJson(response.data);
var tempClock = new Date(Date.parse(globalStatus.Clock));
var clockString = tempClock.toUTCString();
$scope.Clock = clockString;
var tempUptimeClock = new Date(Date.parse(globalStatus.UptimeClock));
var uptimeClockString = tempUptimeClock.toUTCString();
$scope.UptimeClock = uptimeClockString;
var tempLocalClock = new Date;
$scope.LocalClock = tempLocalClock.toUTCString();
$scope.SecondsFast = (tempClock-tempLocalClock)/1000;
}, function (response) {
// nop
});
}, 500, 0, false);
// perform cleanup every 60 seconds
var clearStaleTraffic = $interval(function () {
// remove stale aircraft = anything more than 180 seconds without an update

Wyświetl plik

@ -45,6 +45,23 @@
</div>
</div>
</div>
<div class="separator"></div>
<div class="row">
<div class="col-sm-4 label_adj">
<strong class="col-xs-5">Stratux Clock:</strong>
<span class="col-xs-7">{{Clock}}</span>
</div>
<div class="col-sm-4 label_adj">
<strong class="col-xs-5">Device Clock:</strong>
<span class="col-xs-7">{{LocalClock}}</span>
</div>
<div class="col-sm-4 label_adj">
<strong class="col-xs-5">Uptime Clock</strong>
<span class="col-xs-7">{{UptimeClock}}</span>
</div>
</div>
<!--
<div class="col-sm-12">
<div class="panel panel-default">