copay/js/controllers/header.js

68 lines
1.8 KiB
JavaScript
Raw Normal View History

2014-03-25 07:35:04 -07:00
'use strict';
angular.module('copay.header').controller('HeaderController',
2014-05-14 22:13:25 -07:00
function($scope, $rootScope, $location, $notification, walletFactory, controllerUtils) {
2014-04-29 15:26:12 -07:00
$scope.menu = [
{
'title': 'Addresses',
'icon': 'fi-address-book',
'link': '#/addresses'
2014-03-26 05:18:42 -07:00
}, {
'title': 'Transactions',
2014-04-15 08:33:00 -07:00
'icon': 'fi-loop',
2014-03-26 05:18:42 -07:00
'link': '#/transactions'
}, {
'title': 'Send',
2014-04-15 08:33:00 -07:00
'icon': 'fi-arrow-right',
2014-03-26 05:18:42 -07:00
'link': '#/send'
}, {
'title': 'Backup',
2014-04-15 08:33:00 -07:00
'icon': 'fi-archive',
2014-03-26 05:18:42 -07:00
'link': '#/backup'
2014-04-15 10:02:45 -07:00
}];
2014-03-25 07:35:04 -07:00
2014-04-18 15:08:01 -07:00
$rootScope.$watch('wallet', function(wallet) {
if (wallet) {
controllerUtils.updateTxs();
2014-04-18 15:08:01 -07:00
}
});
2014-05-14 22:13:25 -07:00
// Initialize alert notification (not show when init wallet)
$rootScope.showTxAlert = 0;
$notification.enableHtml5Mode(); // for chrome: if support, enable it
$rootScope.$watch('showTxAlert', function(showTxAlert) {
if (showTxAlert && showTxAlert > 0) {
$notification.info('New Transaction', ($rootScope.showTxAlert == 1) ? 'You have pending a transaction proposal' : 'You have pending ' + $rootScope.showTxAlert + ' transaction proposals', showTxAlert);
}
});
2014-03-26 05:18:42 -07:00
$scope.isActive = function(item) {
2014-04-15 10:02:45 -07:00
if (item.link && item.link.replace('#','') == $location.path()) {
2014-03-26 05:18:42 -07:00
return true;
}
return false;
};
2014-03-25 07:35:04 -07:00
$scope.signout = function() {
2014-04-16 15:14:58 -07:00
var w = $rootScope.wallet;
if (w) {
w.disconnect();
controllerUtils.logout();
2014-04-16 15:14:58 -07:00
}
2014-04-30 15:50:13 -07:00
$scope.clearFlashMessage();
};
$scope.refresh = function() {
2014-05-06 12:21:56 -07:00
var w = $rootScope.wallet;
w.connectToAll();
2014-04-30 15:50:13 -07:00
controllerUtils.updateBalance(function() {
});
2014-03-25 07:35:04 -07:00
};
2014-04-09 07:05:25 -07:00
$scope.clearFlashMessage = function() {
$rootScope.flashMessage = {};
};
2014-04-20 15:39:16 -07:00
$rootScope.isCollapsed = true;
2014-03-25 07:35:04 -07:00
});