Merge pull request #1307 from matiu/feature/drive

Feature/ Async storage + Google Drive example
This commit is contained in:
Manuel Aráoz 2014-09-22 09:57:49 -03:00
commit 3a79f039cd
38 changed files with 1980 additions and 1192 deletions

View file

@ -86,8 +86,9 @@ angular.module('copayApp.controllers').controller('CreateController',
privateKeyHex: $scope.private,
networkName: $scope.networkName,
};
var w = walletFactory.create(opts);
controllerUtils.startNetwork(w, $scope);
walletFactory.create(opts, function(err, w) {
controllerUtils.startNetwork(w, $scope);
});
});
};

View file

@ -1,10 +1,12 @@
'use strict';
angular.module('copayApp.controllers').controller('HomeController',
function($scope, $rootScope, $location, walletFactory, notification, controllerUtils) {
controllerUtils.redirIfLogged();
angular.module('copayApp.controllers').controller('HomeController', function($scope, $rootScope, $location, walletFactory, notification, controllerUtils) {
$scope.loading = false;
$scope.hasWallets = (walletFactory.getWallets() && walletFactory.getWallets().length > 0) ? true : false;
controllerUtils.redirIfLogged();
$scope.retreiving = true;
walletFactory.getWallets(function(err,ret) {
$scope.retreiving = false;
$scope.hasWallets = (ret && ret.length > 0) ? true : false;
});
});

View file

@ -119,7 +119,12 @@ angular.module('copayApp.controllers').controller('JoinController',
$scope.loading = true;
Passphrase.getBase64Async($scope.joinPassword, function(passphrase) {
walletFactory.joinCreateSession($scope.connectionId, $scope.nickname, passphrase, $scope.private, function(err, w) {
walletFactory.joinCreateSession({
secret: $scope.connectionId,
nickname: $scope.nickname,
passphrase: passphrase,
privateHex: $scope.private,
}, function(err, w) {
$scope.loading = false;
if (err || !w) {
if (err === 'joinError')

View file

@ -25,6 +25,7 @@ angular.module('copayApp.controllers').controller('MoreController',
value: 100000000,
decimals: 8
}];
$scope.selectedAlternative = {
name: w.settings.alternativeName,
isoCode: w.settings.alternativeIsoCode

View file

@ -14,15 +14,32 @@ angular.module('copayApp.controllers').controller('OpenController', function($sc
};
$rootScope.fromSetup = false;
$scope.loading = false;
$scope.wallets = walletFactory.getWallets().sort(cmp);
$scope.selectedWalletId = walletFactory.storage.getLastOpened() || ($scope.wallets[0] && $scope.wallets[0].id);
$scope.retreiving = true;
walletFactory.getWallets(function(err, wallets) {
if (err || !wallets || !wallets.length) {
$location.path('/');
} else {
$scope.retreiving = false;
$scope.wallets = wallets.sort(cmp);
walletFactory.storage.getLastOpened(function(ret) {
if (ret && _.indexOf(_.pluck($scope.wallets, 'id')) == -1)
ret = null;
$scope.selectedWalletId = ret || ($scope.wallets[0] && $scope.wallets[0].id);
setTimeout(function() {
$rootScope.$digest();
}, 0);
});
}
});
$scope.openPassword = '';
$scope.isMobile = !!window.cordova;
if (!$scope.wallets.length){
$location.path('/');
}
$scope.open = function(form) {
if (form && form.$invalid) {
notification.error('Error', 'Please enter the required fields');
@ -34,19 +51,16 @@ angular.module('copayApp.controllers').controller('OpenController', function($sc
Passphrase.getBase64Async(password, function(passphrase) {
var w, errMsg;
try {
w = walletFactory.open($scope.selectedWalletId, passphrase);
} catch (e) {
errMsg = e.message;
};
if (!w) {
$scope.loading = false;
notification.error('Error', errMsg || 'Wrong password');
$rootScope.$digest();
return;
}
$rootScope.updatingBalance = true;
controllerUtils.startNetwork(w, $scope);
walletFactory.open($scope.selectedWalletId, passphrase, function(err, w) {
if (!w) {
$scope.loading = false;
notification.error('Error', err.errMsg || 'Wrong password');
$rootScope.$digest();
} else {
$rootScope.updatingBalance = true;
controllerUtils.startNetwork(w, $scope);
}
});
});
};