Merge pull request #1913 from matiu/feature/quota

Feature/quota
This commit is contained in:
Gustavo Maximiliano Cortez 2014-12-02 09:46:11 -03:00
commit 17614d2968
13 changed files with 162 additions and 32 deletions

View file

@ -41,7 +41,7 @@ angular.module('copayApp.controllers').controller('CreateController',
$scope.create = function(form) {
if (form && form.$invalid) {
notification.error('Error', 'Please enter the required fields');
$scope.error = 'Please enter the required fields';
return;
}
var opts = {
@ -56,7 +56,11 @@ angular.module('copayApp.controllers').controller('CreateController',
$rootScope.starting = false;
if (err || !wallet) {
copay.logger.debug(err);
$scope.error = 'Could not create wallet.' + err;
if (err.match('OVERQUOTA')){
$scope.error = 'Could not create wallet: storage limits on remove server exceeded';
} else {
$scope.error = 'Could not create wallet: ' + err;
}
}
$rootScope.$digest()
});

View file

@ -18,6 +18,7 @@ angular.module('copayApp.controllers').controller('HomeController', function($sc
$scope.done = function() {
$rootScope.starting = false;
$rootScope.$digest();
};
@ -46,11 +47,13 @@ angular.module('copayApp.controllers').controller('HomeController', function($sc
} else {
$scope.error = 'Unknown error';
}
return $scope.done();
}
if (iden) {
iden.on('newWallet', $scope.done);
iden.on('noWallets', $scope.done);
iden.openWallets();
}
});
}

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;
@ -20,16 +20,35 @@ angular.module('copayApp.controllers').controller('ProfileController', function(
identityService.deleteWallet(w, function(err) {
$scope.loading = false;
if (err) {
log.warn(err);
copay.logger.warn(err);
}
$scope.setWallets();
});
};
$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;
$scope.wallets=$rootScope.iden.listWallets();
};
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;