Wallet/js/controllers/sidebar.js

77 lines
1.9 KiB
JavaScript
Raw Normal View History

2014-03-25 11:35:04 -03:00
'use strict';
angular.module('copayApp.controllers').controller('SidebarController',
2014-07-31 22:49:11 -03:00
function($scope, $rootScope, $sce, $location, $http, notification, controllerUtils) {
$scope.menu = [{
'title': 'Addresses',
'icon': 'fi-address-book',
'link': 'addresses'
2014-03-26 09:18:42 -03:00
}, {
'title': 'Transactions',
2014-06-23 10:34:40 -03:00
'icon': 'fi-clipboard-pencil',
'link': 'transactions'
2014-03-26 09:18:42 -03:00
}, {
'title': 'Send',
2014-04-15 12:33:00 -03:00
'icon': 'fi-arrow-right',
'link': 'send'
2014-03-26 09:18:42 -03:00
}, {
2014-07-21 16:25:47 -03:00
'title': 'More',
2014-07-08 10:48:56 -03:00
'icon': 'fi-download',
'link': 'backup'
2014-04-15 14:02:45 -03:00
}];
2014-03-25 11:35:04 -03:00
$scope.signout = function() {
2014-05-15 13:04:26 -07:00
logout();
2014-04-30 19:50:13 -03:00
};
// Ensures a graceful disconnect
window.onbeforeunload = logout;
$scope.$on('$destroy', function() {
window.onbeforeunload = undefined;
});
2014-04-30 19:50:13 -03:00
$scope.refresh = function() {
2014-05-06 16:21:56 -03:00
var w = $rootScope.wallet;
w.connectToAll();
if ($rootScope.addrInfos.length > 0) {
controllerUtils.updateBalance(function() {
$rootScope.$digest();
});
}
2014-03-25 11:35:04 -03:00
};
2014-04-09 11:05:25 -03:00
2014-07-18 15:23:01 -03:00
$scope.isActive = function(item) {
return item.link && item.link == $location.path().split('/')[1];
};
2014-05-15 13:04:26 -07:00
function logout() {
var w = $rootScope.wallet;
if (w) {
w.disconnect();
controllerUtils.logout();
}
}
2014-07-16 19:00:34 -03:00
// ng-repeat defined number of times instead of repeating over array?
$scope.getNumber = function(num) {
return new Array(num);
}
// Init socket handlers (with no wallet yet)
controllerUtils.setSocketHandlers();
2014-07-08 15:26:20 -03:00
if ($rootScope.wallet) {
$scope.$on('$idleStart', function(a) {
2014-08-01 10:51:26 -03:00
notification.warning('Session will be closed', 'Your session is about to expire due to inactivity');
});
$scope.$on('$idleTimeout', function() {
$scope.signout();
2014-08-01 10:44:33 -03:00
notification.warning('Session closed', 'Session closed because a long time of inactivity');
});
}
2014-03-25 11:35:04 -03:00
});