insight-ui-zcash/public/js/controllers/status.js

42 lines
873 B
JavaScript
Raw Normal View History

'use strict';
2014-01-20 13:09:18 -08:00
angular.module('insight.status').controller('StatusController',
2014-01-23 08:00:27 -08:00
function($scope, $routeParams, $location, Global, Status, Sync, getSocket) {
$scope.global = Global;
2014-01-17 06:46:12 -08:00
2014-01-20 06:45:01 -08:00
$scope.getStatus = function(q) {
Status.get({
2014-01-21 08:28:01 -08:00
q: 'get' + q
},
function(d) {
2014-01-23 08:00:27 -08:00
$scope.loaded = 1;
2014-01-20 06:45:01 -08:00
angular.extend($scope, d);
2014-01-21 08:28:01 -08:00
},
function(e) {
2014-01-23 10:10:52 -08:00
$scope.error = 'API ERROR: ' + e.data;
});
};
var _onSyncUpdate = function(sync) {
2014-01-21 08:28:01 -08:00
$scope.sync = sync;
};
2014-01-20 06:45:01 -08:00
$scope.getSync = function() {
2014-01-21 08:28:01 -08:00
Sync.get({},
function(sync) {
_onSyncUpdate(sync);
2014-01-21 08:28:01 -08:00
},
function(e) {
2014-01-23 08:00:27 -08:00
var err = 'Could not get sync information' + e.toString();
$scope.sync = { error: err };
2014-01-20 06:45:01 -08:00
});
};
var socket = getSocket($scope);
socket.emit('subscribe', 'sync');
2014-01-21 08:28:01 -08:00
socket.on('status', function(sync) {
_onSyncUpdate(sync);
});
2014-01-20 13:09:18 -08:00
});