fix incomplete wallet process

This commit is contained in:
Javier 2016-09-06 11:22:10 -03:00
parent 2354a46bed
commit b6bcc57cfd
8 changed files with 96 additions and 141 deletions

View File

@ -1,15 +1,12 @@
<ion-view ng-controller="copayersController"> <ion-view>
<ion-nav-bar class="bar-royal"> <ion-nav-bar class="bar-royal">
<ion-nav-title>{{wallet.name}}</ion-nav-title> <ion-nav-back-button>
<ion-nav-buttons side="primary"> <i class="icon ion-ios-arrow-thin-left"></i>
<button class="button back-button" ui-sref="tabs.home"> </ion-nav-back-button>
<i class="icon ion-ios-arrow-thin-left"></i>
</button>
</ion-nav-buttons>
</ion-nav-bar> </ion-nav-bar>
<ion-content delegate-handle="my-handle" overflow-scroll="true"> <ion-content ng-controller="copayersController">
<div ng-show="!wallet.notAuthorized"> <div ng-show="!wallet.notAuthorized">
<h1 class="text-center" translate>Share this invitation with your copayers</h1> <h1 class="text-center" translate>Share this invitation with your copayers</h1>
@ -43,14 +40,14 @@
[ <span translate>{{wallet.m}}-of-{{wallet.n}}</span> ] [ <span translate>{{wallet.m}}-of-{{wallet.n}}</span> ]
</span> </span>
</h4> </h4>
<div class="white line-b p10" ng-include="'views/includes/copayers.html'"></div> <div ng-include="'views/includes/copayers.html'"></div>
<div ng-if="!wallet.isComplete()" class="line-b p10 white size-12"> <div ng-if="!wallet.isComplete()" class="line-b p10 white size-12">
<i class="fi-loop m5r p10l"></i> <i class="icon ion-loop"></i>
<span translate>Waiting...</span> <span translate>Waiting...</span>
</div> </div>
<div ng-if="wallet.isComplete()" class="line-b p10 white size-12" href> <div ng-if="wallet.isComplete()" class="line-b p10 white size-12" href>
<button class="button" href ui-sref="tabs.home"> <button class="button" href ui-sref="tabs.home">
<span translate>WALLET COMPLETE!</span> <span translate>WALLET COMPLETE!</span>
</button> </button>
</div> </div>

View File

@ -1,10 +1,8 @@
<ul class="no-bullet m0"> <div ng-repeat="copayer in copayers">
<li class="" ng-repeat="copayer in index.copayers"> <span class="item size-12" ng-show="copayer.id == wallet.copayerId">
<span class="size-12" ng-show="copayer.id == index.copayerId"> <i class="icon ion-checkmark"></i> {{'Me'|translate}}
<i class="fi-check m5r"></i> {{'Me'|translate}}
</span> </span>
<span class="size-12 text-gray" ng-show="copayer.id != index.copayerId"> <span class="item size-12 text-gray" ng-show="copayer.id != wallet.copayerId">
<i class="fi-check m5r"></i> {{copayer.name}} <i class="icon ion-checkmark"></i> {{copayer.name}}
</span> </span>
</li> </div>
</ul>

View File

@ -40,7 +40,7 @@
</div> </div>
<a ng-repeat="wallet in wallets track by $index" <a ng-repeat="wallet in wallets track by $index"
class="item item-icon-left item-big-icon-left item-icon-right" class="item item-icon-left item-big-icon-left item-icon-right"
ui-sref="tabs.details({'walletId': wallet.id})"> ng-click="openWallet(wallet)">
<i class="icon big-icon-svg"> <i class="icon big-icon-svg">
<img src="img/icon-wallet.svg" ng-style="{'background-color': wallet.color}"/> <img src="img/icon-wallet.svg" ng-style="{'background-color': wallet.color}"/>
</i> </i>

View File

@ -10,22 +10,7 @@
</ion-header-bar> </ion-header-bar>
<ion-content delegate-handle="my-handle"> <ion-content delegate-handle="my-handle">
<div ng-show="!wallet" translate> <div class="oh pr" ng-show="wallet && wallet.isComplete()">
No Wallet
<a href ui-sref="tabs.home" class="button" translate>
Go home
</a>
</div>
<div ng-show="!wallet.isComplete()">
<a class="button button-block button-assertive" href ui-sref="wallet.copayers" class="button" translate>
Wallet Incomplete
</a>
</div>
<div class="oh pr" ng-show="wallet && wallet.isComplete()">
<div ng-style="{'background-color':wallet.color}" class="amount"> <div ng-style="{'background-color':wallet.color}" class="amount">
<div ng-if="!notAuthorized && !updatingStatus"> <div ng-if="!notAuthorized && !updatingStatus">

View File

@ -1,13 +1,15 @@
'use strict'; 'use strict';
angular.module('copayApp.controllers').controller('copayersController', angular.module('copayApp.controllers').controller('copayersController',
function($scope, $log, $ionicPopup, profileService, platformInfo, gettextCatalog, $stateParams, ongoingProcess, $state) { function($scope, $log, $ionicNavBarDelegate, $stateParams, $state, profileService, popupService, platformInfo, gettextCatalog, ongoingProcess) {
if (!$stateParams.walletId) { if (!$stateParams.walletId) {
$log.debug('No wallet provided...back to home'); $log.debug('No wallet provided...back to home');
return $state.transitionTo('tabs.home'); return $state.go('tabs.home');
} }
var wallet = profileService.getWallet($stateParams.walletId); var wallet = profileService.getWallet($stateParams.walletId);
$ionicNavBarDelegate.title(wallet.name);
var secret; var secret;
try { try {
secret = wallet.status.wallet.secret; secret = wallet.status.wallet.secret;
@ -15,28 +17,12 @@ angular.module('copayApp.controllers').controller('copayersController',
$scope.wallet = wallet; $scope.wallet = wallet;
$scope.secret = secret; $scope.secret = secret;
$scope.copayers = wallet.status.wallet.copayers;
$scope.isCordova = platformInfo.isCordova; $scope.isCordova = platformInfo.isCordova;
$scope.showDeletePopup = function() { $scope.showDeletePopup = function() {
var popup = $ionicPopup.show({ popupService.showConfirm(gettextCatalog.getString('Confirm'), gettextCatalog.getString('Are you sure you want to delete this wallet?'), function(res) {
template: '<span>' + gettextCatalog.getString('Are you sure you want to delete this wallet?') + '</span>', if (res) deleteWallet();
title: gettextCatalog.getString('Confirm'),
buttons: [
{
text: gettextCatalog.getString('Cancel'),
onTap: function(e) {
popup.close();
}
},
{
text: gettextCatalog.getString('Accept'),
type: 'button-positive',
onTap: function(e) {
deleteWallet();
popup.close();
}
}
]
}); });
}; };
@ -47,7 +33,7 @@ angular.module('copayApp.controllers').controller('copayersController',
if (err) { if (err) {
popupService.showAlert(gettextCatalog.getString('Error'), err.message || err); popupService.showAlert(gettextCatalog.getString('Error'), err.message || err);
} else { } else {
$state.transitionTo('tabs.home'); $state.go('tabs.home');
} }
}); });
}; };

View File

@ -1,19 +1,37 @@
'use strict'; 'use strict';
angular.module('copayApp.controllers').controller('tabHomeController', angular.module('copayApp.controllers').controller('tabHomeController',
function($rootScope, $timeout, $scope, $state, $ionicScrollDelegate, lodash, profileService, walletService, configService, txFormatService, $ionicModal, $log, platformInfo, storageService, txpModalService, $window) { function($rootScope, $timeout, $scope, $state, $ionicScrollDelegate, lodash, profileService, walletService, configService, $log, platformInfo, storageService, txpModalService, $window) {
$scope.externalServices = {}; $scope.externalServices = {};
$scope.bitpayCardEnabled = true; // TODO $scope.bitpayCardEnabled = true; // TODO
$scope.openTxpModal = txpModalService.open;
$scope.version = $window.version;
$scope.name = $window.appConfig.nameCase;
configService.whenAvailable(function() {
var config = configService.getSync();
var isWindowsPhoneApp = platformInfo.isWP && isCordova;
$scope.glideraEnabled = config.glidera.enabled && !isWindowsPhoneApp;
$scope.coinbaseEnabled = config.coinbase.enabled && !isWindowsPhoneApp;
});
$scope.openWallet = function(wallet) {
if (!wallet.isComplete()) {
return $state.go('tabs.copayers', {
walletId: wallet.credentials.walletId
});
}
$state.go('tabs.details', {
walletId: wallet.credentials.walletId
});
};
function updateTxps() { function updateTxps() {
profileService.getTxps({ profileService.getTxps({
limit: 3 limit: 3
}, function(err, txps, n) { }, function(err, txps, n) {
if (err) { if (err) $log.error(err);
console.log('[tab-home.js.35:err:]', $log.error(err)); //TODO
}
$scope.txps = txps; $scope.txps = txps;
$scope.txpsN = n; $scope.txpsN = n;
$ionicScrollDelegate.resize(); $ionicScrollDelegate.resize();
@ -24,7 +42,6 @@ angular.module('copayApp.controllers').controller('tabHomeController',
}) })
}; };
$scope.updateAllWallets = function() { $scope.updateAllWallets = function() {
$scope.wallets = profileService.getWallets(); $scope.wallets = profileService.getWallets();
if (lodash.isEmpty($scope.wallets)) return; if (lodash.isEmpty($scope.wallets)) return;
@ -41,7 +58,7 @@ angular.module('copayApp.controllers').controller('tabHomeController',
} else { } else {
wallet.status = status; wallet.status = status;
} }
if (++j==i) { if (++j == i) {
updateTxps(); updateTxps();
} }
}); });
@ -106,7 +123,7 @@ angular.module('copayApp.controllers').controller('tabHomeController',
$scope.updateWallet(wallet); $scope.updateWallet(wallet);
}), }),
$rootScope.$on('Local/TxAction', function(e, walletId) { $rootScope.$on('Local/TxAction', function(e, walletId) {
$log.debug('Got action for wallet '+ walletId); $log.debug('Got action for wallet ' + walletId);
var wallet = profileService.getWallet(walletId); var wallet = profileService.getWallet(walletId);
$scope.updateWallet(wallet); $scope.updateWallet(wallet);
}), }),
@ -117,19 +134,4 @@ angular.module('copayApp.controllers').controller('tabHomeController',
x(); x();
}); });
}); });
configService.whenAvailable(function() {
var config = configService.getSync();
var isWindowsPhoneApp = platformInfo.isWP && isCordova;
$scope.glideraEnabled = config.glidera.enabled && !isWindowsPhoneApp;
$scope.coinbaseEnabled = config.coinbase.enabled && !isWindowsPhoneApp;
});
$scope.openTxpModal = txpModalService.open;
$scope.version = $window.version;
$scope.name = $window.appConfig.nameCase;
}); });

View File

@ -1,21 +1,58 @@
'use strict'; 'use strict';
angular.module('copayApp.controllers').controller('walletDetailsController', function($scope, $rootScope, $interval, $timeout, $filter, $log, $ionicModal, $ionicPopover, $ionicNavBarDelegate, $state, $stateParams, bwcError, profileService, lodash, configService, gettext, gettextCatalog, platformInfo, walletService, $ionicPopup, txpModalService, externalLinkService) { angular.module('copayApp.controllers').controller('walletDetailsController', function($scope, $rootScope, $interval, $timeout, $filter, $log, $ionicModal, $ionicPopover, $ionicNavBarDelegate, $state, $stateParams, bwcError, profileService, lodash, configService, gettext, gettextCatalog, platformInfo, walletService, $ionicPopup, txpModalService, externalLinkService) {
var isCordova = platformInfo.isCordova;
var isWP = platformInfo.isWP;
var isAndroid = platformInfo.isAndroid;
var isChromeApp = platformInfo.isChromeApp;
var errorPopup;
var HISTORY_SHOW_LIMIT = 10; var HISTORY_SHOW_LIMIT = 10;
var currentTxHistoryPage;
var wallet;
$scope.txps = []; $scope.txps = [];
$scope.openExternalLink = function(url, target) { $scope.openExternalLink = function(url, target) {
externalLinkService.open(url, target); externalLinkService.open(url, target);
}; };
$scope.init = function() {
currentTxHistoryPage = 0;
$scope.completeTxHistory = [];
wallet = profileService.getWallet($stateParams.walletId);
/* Set color for header bar */
$rootScope.walletDetailsColor = wallet.color;
$rootScope.walletDetailsName = wallet.name;
$scope.wallet = wallet;
$scope.requiresMultipleSignatures = wallet.credentials.m > 1;
$scope.newTx = false;
$ionicNavBarDelegate.title(wallet.name);
$scope.updateAll(function() {
if ($stateParams.txid) {
var tx = lodash.find($scope.completeTxHistory, {
txid: $stateParams.txid
});
if (tx) {
$scope.openTxModal(tx);
} else {
$ionicPopup.alert({
title: gettext('TX not available'),
});
}
} else if ($stateParams.txpId) {
var txp = lodash.find($scope.txps, {
id: $stateParams.txpId
});
if (txp) {
$scope.openTxpModal(txp);
} else {
$ionicPopup.alert({
title: gettext('Proposal not longer available'),
});
}
}
});
}
var setPendingTxps = function(txps) { var setPendingTxps = function(txps) {
if (!txps) { if (!txps) {
$scope.txps = []; $scope.txps = [];
@ -169,54 +206,4 @@ angular.module('copayApp.controllers').controller('walletDetailsController', fun
if (err) $log.error(err); if (err) $log.error(err);
}); });
} }
var currentTxHistoryPage;
var wallet;
$scope.init = function() {
currentTxHistoryPage = 0;
$scope.completeTxHistory = [];
wallet = profileService.getWallet($stateParams.walletId);
if (!wallet.isComplete()) {
return $state.go('wallet.copayers');
};
/* Set color for header bar */
$rootScope.walletDetailsColor = wallet.color;
$rootScope.walletDetailsName = wallet.name;
$scope.wallet = wallet;
$scope.requiresMultipleSignatures = wallet.credentials.m > 1;
$scope.newTx = false;
$ionicNavBarDelegate.title(wallet.name);
$scope.updateAll(function() {
if ($stateParams.txid) {
var tx = lodash.find($scope.completeTxHistory, {
txid: $stateParams.txid
});
if (tx) {
$scope.openTxModal(tx);
} else {
$ionicPopup.alert({
title: gettext('TX not available'),
});
}
} else if ($stateParams.txpId) {
var txp = lodash.find($scope.txps, {
id: $stateParams.txpId
});
if (txp) {
$scope.openTxpModal(txp);
} else {
$ionicPopup.alert({
title: gettext('Proposal not longer available'),
});
}
}
});
}
}); });

View File

@ -533,9 +533,9 @@ angular.module('copayApp').config(function(historicLogProvider, $provide, $logPr
*/ */
.state('tabs.copayers', { .state('tabs.copayers', {
url: '/copayers', url: '/copayers/:walletId',
views: { views: {
'wallet': { 'tab-home': {
templateUrl: 'views/copayers.html' templateUrl: 'views/copayers.html'
} }
} }