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

38 lines
710 B
JavaScript
Executable File

'use strict';
angular.module('insight.system').controller('HeaderController',
function($scope, getSocket, Global, Block) {
$scope.global = Global;
$scope.menu = [
{
'title': 'Blocks',
'link': 'blocks'
},
{
'title': 'Status',
'link': 'status'
}
];
var socket = getSocket($scope);
socket.emit('subscribe', 'inv');
var _getBlock = function(hash) {
Block.get({
blockHash: hash
}, function(res) {
$scope.totalBlocks = res.height;
});
};
socket.on('block', function(block) {
var blockHash = block.hash.toString();
console.log('Updated Blocks Height!');
_getBlock(blockHash);
});
$scope.isCollapsed = false;
});