Merge branch 'ref/design' of https://github.com/bitpay/bitpay-wallet into feature/onboarding_last_steps

This commit is contained in:
Jamal Jackson 2016-09-07 10:33:23 -04:00
commit a2c509092d
41 changed files with 473 additions and 658 deletions

View file

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

View file

@ -1,21 +1,26 @@
'use strict';
angular.module('copayApp.controllers').controller('importController',
function($scope, $rootScope, $timeout, $log, $state, $stateParams, $ionicHistory, profileService, configService, sjcl, gettext, ledger, trezor, derivationPathHelper, platformInfo, bwcService, ongoingProcess, walletService, popupService, gettextCatalog) {
function($scope, $timeout, $log, $state, $stateParams, profileService, configService, sjcl, ledger, trezor, derivationPathHelper, platformInfo, bwcService, ongoingProcess, walletService, popupService, gettextCatalog) {
var isChromeApp = platformInfo.isChromeApp;
var isDevel = platformInfo.isDevel;
var reader = new FileReader();
var defaults = configService.getDefaults();
var errors = bwcService.getErrors();
$scope.isSafari = platformInfo.isSafari;
$scope.isCordova = platformInfo.isCordova;
$scope.bwsurl = defaults.bws.url;
$scope.derivationPath = derivationPathHelper.default;
$scope.account = 1;
$scope.importErr = false;
var updateSeedSourceSelect = function() {
$scope.init = function() {
$scope.isSafari = platformInfo.isSafari;
$scope.isCordova = platformInfo.isCordova;
$scope.formData = {};
$scope.formData.bwsurl = defaults.bws.url;
$scope.formData.derivationPath = derivationPathHelper.default;
$scope.formData.account = 1;
$scope.importErr = false;
if ($stateParams.code)
$scope.processWalletInfo($stateParams.code);
$scope.seedOptions = [];
if (isChromeApp) {
@ -36,6 +41,7 @@ angular.module('copayApp.controllers').controller('importController',
$scope.processWalletInfo = function(code) {
if (!code) return;
$scope.importErr = false;
var parsedCode = code.split('|');
@ -56,26 +62,19 @@ angular.module('copayApp.controllers').controller('importController',
if (info.type == 1 && info.hasPassphrase)
popupService.showAlert(gettextCatalog.getString('Password required. Make sure to enter your password in advanced options'));
$scope.derivationPath = info.derivationPath;
$scope.testnetEnabled = info.network == 'testnet' ? true : false;
$scope.formData.derivationPath = info.derivationPath;
$scope.formData.testnetEnabled = info.network == 'testnet' ? true : false;
$timeout(function() {
$scope.words = info.data;
$rootScope.$apply();
}, 1);
};
$scope.setType = function(type) {
$scope.type = type;
$timeout(function() {
$rootScope.$apply();
$scope.formData.words = info.data;
$scope.$apply();
}, 1);
};
var _importBlob = function(str, opts) {
var str2, err;
try {
str2 = sjcl.decrypt($scope.password, str);
str2 = sjcl.decrypt($scope.formData.password, str);
} catch (e) {
err = gettextCatalog.getString('Could not decrypt file, check your password');
$log.warn(e);
@ -83,9 +82,6 @@ angular.module('copayApp.controllers').controller('importController',
if (err) {
popupService.showAlert(gettextCatalog.getString('Error'), err);
$timeout(function() {
$rootScope.$apply();
});
return;
}
@ -147,7 +143,7 @@ angular.module('copayApp.controllers').controller('importController',
if (err) $log.error(err);
});
}
$state.go('tabs.home');
});
}, 100);
@ -176,11 +172,8 @@ angular.module('copayApp.controllers').controller('importController',
}, 100);
};
$scope.setDerivationPath = function(testnetEnabled) {
if (testnetEnabled)
$scope.derivationPath = derivationPathHelper.defaultTestnet;
else
$scope.derivationPath = derivationPathHelper.default;
$scope.setDerivationPath = function() {
$scope.formData.derivationPath = $scope.formData.testnetEnabled ? derivationPathHelper.defaultTestnet : derivationPathHelper.default;
};
$scope.getFile = function() {
@ -188,7 +181,7 @@ angular.module('copayApp.controllers').controller('importController',
reader.onloadend = function(evt) {
if (evt.target.readyState == FileReader.DONE) { // DONE == 2
var opts = {};
opts.bwsurl = $scope.bwsurl;
opts.bwsurl = $scope.formData.bwsurl;
_importBlob(evt.target.result, opts);
}
}
@ -200,9 +193,9 @@ angular.module('copayApp.controllers').controller('importController',
return;
}
var backupFile = $scope.file;
var backupText = form.backupText.$modelValue;
var password = form.password.$modelValue;
var backupFile = $scope.formData.file;
var backupText = $scope.formData.backupText;
var password = $scope.formData.password;
if (!backupFile && !backupText) {
popupService.showAlert(gettextCatalog.getString('Error'), gettextCatalog.getString('Please, select your backup file'));
@ -213,7 +206,7 @@ angular.module('copayApp.controllers').controller('importController',
reader.readAsBinaryString(backupFile);
} else {
var opts = {};
opts.bwsurl = $scope.bwsurl;
opts.bwsurl = $scope.formData.bwsurl;
_importBlob(backupText, opts);
}
};
@ -225,19 +218,22 @@ angular.module('copayApp.controllers').controller('importController',
}
var opts = {};
if ($scope.bwsurl)
opts.bwsurl = $scope.bwsurl;
var pathData = derivationPathHelper.parse($scope.derivationPath);
if ($scope.formData.bwsurl)
opts.bwsurl = $scope.formData.bwsurl;
var pathData = derivationPathHelper.parse($scope.formData.derivationPath);
if (!pathData) {
popupService.showAlert(gettextCatalog.getString('Error'), gettextCatalog.getString('Invalid derivation path'));
return;
}
opts.account = pathData.account;
opts.networkName = pathData.networkName;
opts.derivationStrategy = pathData.derivationStrategy;
var words = form.words.$modelValue || null;
var words = $scope.formData.words || null;
if (!words) {
popupService.showAlert(gettextCatalog.getString('Please enter the recovery phrase'));
@ -254,9 +250,7 @@ angular.module('copayApp.controllers').controller('importController',
}
}
var passphrase = form.passphrase.$modelValue;
opts.passphrase = form.passphrase.$modelValue || null;
opts.passphrase = $scope.formData.passphrase || null;
_importMnemonic(words, opts);
};
@ -269,7 +263,7 @@ angular.module('copayApp.controllers').controller('importController',
}
lopts.externalSource = 'trezor';
lopts.bwsurl = $scope.bwsurl;
lopts.bwsurl = $scope.formData.bwsurl;
ongoingProcess.set('importingWallet', true);
$log.debug('Import opts', lopts);
@ -285,45 +279,37 @@ angular.module('copayApp.controllers').controller('importController',
};
$scope.importHW = function(form) {
if (form.$invalid || $scope.account < 0) {
if (form.$invalid || $scope.formData.ccount < 0) {
popupService.showAlert(gettextCatalog.getString('There is an error in the form'));
return;
}
$scope.importErr = false;
var account = +$scope.account;
var account = $scope.formData.ccount;
if ($scope.seedSourceId == 'trezor') {
if ($scope.seedSource.id == 'trezor') {
if (account < 1) {
$scope.error = gettext('Invalid account number');
popupService.showAlert(gettextCatalog.getString('Invalid account number'));
return;
}
account = account - 1;
}
switch ($scope.seedSourceId) {
switch ($scope.seedSource.id) {
case ('ledger'):
ongoingProcess.set('connectingledger', true);
$scope.importLedger(account);
break;
case ('trezor'):
ongoingProcess.set('connectingtrezor', true);
$scope.importTrezor(account, $scope.isMultisig);
$scope.importTrezor(account, $scope.formData.isMultisig);
break;
default:
throw ('Error: bad source id');
};
};
$scope.setSeedSource = function() {
if (!$scope.seedSource) return;
$scope.seedSourceId = $scope.seedSource.id;
$timeout(function() {
$rootScope.$apply();
});
};
$scope.importLedger = function(account) {
ledger.getInfoForNewWallet(true, account, function(err, lopts) {
ongoingProcess.clear();
@ -333,7 +319,7 @@ angular.module('copayApp.controllers').controller('importController',
}
lopts.externalSource = 'ledger';
lopts.bwsurl = $scope.bwsurl;
lopts.bwsurl = $scope.formData.bwsurl;
ongoingProcess.set('importingWallet', true);
$log.debug('Import opts', lopts);
@ -349,7 +335,6 @@ angular.module('copayApp.controllers').controller('importController',
};
var finish = function(wallet) {
walletService.updateRemotePreferences(wallet, {}, function() {
$log.debug('Remote preferences saved for:' + wallet.credentials.walletId)
});
@ -362,8 +347,4 @@ angular.module('copayApp.controllers').controller('importController',
}
$state.go('tabs.home');
};
updateSeedSourceSelect();
$scope.setSeedSource();
if ($stateParams.code) $scope.processWalletInfo($stateParams.code);
});

View file

@ -5,6 +5,7 @@ angular.module('copayApp.controllers').controller('txpDetailsController', functi
var tx = $scope.tx;
var copayers = $scope.copayers;
var isGlidera = $scope.isGlidera;
var GLIDERA_LOCK_TIME = 6 * 60 * 60;
var now = Math.floor(Date.now() / 1000);
$scope.loading = null;

View file

@ -2,6 +2,7 @@
angular.module('copayApp.controllers').controller('termsController', function($scope, $log, $state, uxLanguage, profileService, externalLinkService) {
$scope.lang = uxLanguage.currentLanguage;
$scope.disclaimerUrl = $window.appConfig.disclaimerUrl;
$scope.confirm = function() {
profileService.setDisclaimerAccepted(function(err) {

View file

@ -3,7 +3,7 @@
angular.module('copayApp.controllers').controller('welcomeController', function($scope, $state, $timeout, $log, $ionicPopup, profileService) {
$scope.goImport = function(code) {
$state.go('onboarding.import.phrase', {
$state.go('onboarding.import', {
fromOnboarding: true,
code: code
});

View file

@ -51,7 +51,7 @@ angular.module('copayApp.controllers').controller('preferencesGlideraController'
if (permissions.view_email_address && opts.fullUpdate) {
glideraService.getEmail(accessToken, function(err, data) {
$scope.email = data.email;
$scope.email = data;
});
}
if (permissions.personal_info && opts.fullUpdate) {

View file

@ -1,19 +1,37 @@
'use strict';
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.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 && platformInfo.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() {
profileService.getTxps({
limit: 3
}, function(err, txps, n) {
if (err) {
console.log('[tab-home.js.35:err:]', $log.error(err)); //TODO
}
if (err) $log.error(err);
$scope.txps = txps;
$scope.txpsN = n;
$ionicScrollDelegate.resize();
@ -24,7 +42,6 @@ angular.module('copayApp.controllers').controller('tabHomeController',
})
};
$scope.updateAllWallets = function() {
$scope.wallets = profileService.getWallets();
if (lodash.isEmpty($scope.wallets)) return;
@ -41,7 +58,7 @@ angular.module('copayApp.controllers').controller('tabHomeController',
} else {
wallet.status = status;
}
if (++j==i) {
if (++j == i) {
updateTxps();
}
});
@ -106,7 +123,7 @@ angular.module('copayApp.controllers').controller('tabHomeController',
$scope.updateWallet(wallet);
}),
$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);
$scope.updateWallet(wallet);
}),
@ -117,19 +134,4 @@ angular.module('copayApp.controllers').controller('tabHomeController',
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';
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 currentTxHistoryPage;
var wallet;
$scope.txps = [];
$scope.openExternalLink = function(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) {
if (!txps) {
$scope.txps = [];
@ -169,54 +206,4 @@ angular.module('copayApp.controllers').controller('walletDetailsController', fun
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

@ -107,7 +107,7 @@ angular.module('copayApp.directives')
return {
link: function($scope, el) {
el.bind('change', function(e) {
$scope.file = (e.srcElement || e.target).files[0];
$scope.formData.file = (e.srcElement || e.target).files[0];
$scope.getFile();
});
}

View file

@ -276,37 +276,12 @@ angular.module('copayApp').config(function(historicLogProvider, $provide, $logPr
})
.state('tabs.import', {
url: '/import',
// abstract: true,
views: {
'tab-home': {
templateUrl: 'views/import.html'
},
},
})
.state('tabs.import.phrase', {
url: '/tab-import-phrase',
views: {
'tab-import-phrase': {
templateUrl: 'views/tab-import-phrase.html',
},
}
})
.state('tabs.import.file', {
url: '/tab-import-file',
views: {
'tab-import-file': {
templateUrl: 'views/tab-import-file.html',
},
}
})
.state('tabs.import.hardware', {
url: '/tab-import-hardware',
views: {
'tab-import-hardware': {
templateUrl: 'views/tab-import-hardware.html',
},
}
})
.state('tabs.create', {
url: '/create',
views: {
@ -533,9 +508,9 @@ angular.module('copayApp').config(function(historicLogProvider, $provide, $logPr
*/
.state('tabs.copayers', {
url: '/copayers',
url: '/copayers/:walletId',
views: {
'wallet': {
'tab-home': {
templateUrl: 'views/copayers.html'
}
}
@ -626,7 +601,6 @@ angular.module('copayApp').config(function(historicLogProvider, $provide, $logPr
})
.state('onboarding.import', {
url: '/import',
abstract: true,
views: {
'onboarding': {
templateUrl: 'views/import.html'
@ -637,30 +611,6 @@ angular.module('copayApp').config(function(historicLogProvider, $provide, $logPr
fromOnboarding: null
},
})
.state('onboarding.import.phrase', {
url: '/tab-import-phrase',
views: {
'tab-import-phrase': {
templateUrl: 'views/tab-import-phrase.html',
},
}
})
.state('onboarding.import.file', {
url: '/tab-import-file',
views: {
'tab-import-file': {
templateUrl: 'views/tab-import-file.html',
},
}
})
.state('onboarding.import.hardware', {
url: '/tab-import-hardware',
views: {
'tab-import-hardware': {
templateUrl: 'views/tab-import-hardware.html',
},
}
})
/*
*

View file

@ -1,6 +1,7 @@
.icon.nav-item-arrow-right {
color: #666;
font-size: 26px;
@extend .ion-ios-arrow-right;
}
.item.item-heading {

View file

@ -86,7 +86,7 @@ h3.title {
.box-notification {
padding: 0.5rem;
border: 1px solid;
margin-bottom: 20px;
margin: 10px;
a {
color: #fff;
}

View file

@ -1,7 +1,8 @@
.wallet-activity {
&-not-pending {
background-color:#eee;
opacity: 0.6;
filter: alpha(opacity=60); /* For IE8 and earlier */
}
&-amount {