UNPKG

@axerunners/insight-ui

Version:

An open-source frontend for the Insight API. The Insight API provides you with a convenient, powerful and simple way to query and broadcast data on the Axe network and build your own services with it.

55 lines (45 loc) 1.31 kB
'use strict'; angular.module('insight.system').controller('HeaderController', function($scope, $rootScope, $uibModal, getSocket, Global, Block, Status) { $scope.global = Global; // This allow us to do crafted logic by the network, such can be seen in BlockHash.test(). $rootScope.network = 'testnet'; Status.get({}, function(status) { $rootScope.network = status.info && status.info.network || 'testnet'; }); $rootScope.currency = { factor: 1, bitstamp: 0, symbol: 'AXE' }; $scope.menu = [{ 'title': 'Blocks', 'link': 'blocks' }, { 'title': 'Status', 'link': 'status' }]; $scope.openScannerModal = function() { var modalInstance = $uibModal.open({ templateUrl: 'scannerModal.html', controller: 'ScannerController' }); }; var _getBlock = function(hash) { Block.get({ blockHash: hash }, function(res) { $scope.totalBlocks = res.height; }); }; var socket = getSocket($scope); socket.on('connect', function() { socket.emit('subscribe', 'inv'); socket.on('block', function(block) { var blockHash = block.toString(); _getBlock(blockHash); }); }); $rootScope.isCollapsed = true; });