2014-03-25 07:35:04 -07:00
'use strict' ;
2014-03-28 11:08:14 -07:00
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 = [
{
2014-04-20 16:21:54 -07:00
'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 ) {
2014-05-13 00:03:09 -07:00
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 ( ) ;
2014-04-17 12:27:15 -07:00
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 ;
2014-05-06 13:36:16 -07:00
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-17 02:43:30 -07:00
2014-04-20 15:39:16 -07:00
$rootScope . isCollapsed = true ;
2014-03-25 07:35:04 -07:00
} ) ;