add usage to wallets table

This commit is contained in:
Matias Alejo Garcia 2014-12-01 17:21:39 -03:00
commit 2402a22f0a
5 changed files with 81 additions and 7 deletions

View file

@ -1,5 +1,5 @@
'use strict';
angular.module('copayApp.controllers').controller('ProfileController', function($scope, $rootScope, $location, $modal, backupService, identityService) {
angular.module('copayApp.controllers').controller('ProfileController', function($scope, $rootScope, $location, $modal, $filter, backupService, identityService) {
$scope.username = $rootScope.iden.getName();
$scope.isSafari = Object.prototype.toString.call(window.HTMLElement).indexOf('Constructor') > 0;
@ -25,11 +25,29 @@ angular.module('copayApp.controllers').controller('ProfileController', function(
});
};
$scope.setWallets = function() {
if (!$rootScope.iden) return;
$scope.wallets=$rootScope.iden.listWallets();
$scope.init = function() {
if ($rootScope.quotaPerItem) {
$scope.perItem = $filter('noFractionNumber')($rootScope.quotaPerItem/1000,1);
$scope.nrWallets =parseInt($rootScope.quotaItems) - 1;
}
};
$scope.setWallets = function() {
if (!$rootScope.iden) return;
var wallets = $rootScope.iden.listWallets();
var max =$rootScope.quotaPerItem;
_.each(wallets, function(w) {
var bits = w.sizes().total;
w.kb = $filter('noFractionNumber')(bits/1000, 1);
if (max) {
w.usage = $filter('noFractionNumber')(bits/max * 100, 0);
}
});
$scope.wallets = wallets;
};
$scope.downloadWalletBackup = function(w) {
if (!w) return;