Adds cache for amount, backup, amazon, glidera, export, walletDetails

This commit is contained in:
Gustavo Maximiliano Cortez 2016-09-22 10:34:00 -03:00
commit 2a9c3c82e9
No known key found for this signature in database
GPG key ID: 15EDAD8D9F2EB1AF
22 changed files with 181 additions and 165 deletions

View file

@ -1,10 +1,13 @@
<ion-view id="view-amount">
<ion-nav-bar class="bar-royal">
<ion-nav-title>
{{'Enter Amount'|translate}}
</ion-nav-title>
<ion-nav-back-button>
</ion-nav-back-button>
</ion-nav-bar>
<ion-content scroll="false" class="amount" ng-controller="amountController" ng-init="init()">
<ion-content scroll="false">
<div>
<div class="item item-no-bottom-border" translate>Recipient</div>

View file

@ -1,4 +1,4 @@
<ion-view id="wallet-backup-phrase" title="{{viewTitle}}" ng-controller="backupController" ng-init="init()">
<ion-view id="wallet-backup-phrase" title="{{viewTitle}}">
<ion-nav-bar class="bar-royal">
<ion-nav-buttons side="primary">
<button class="button button-back button-clear" ng-click="backupGoBack()">

View file

@ -5,7 +5,7 @@
<ion-nav-title>Buy</ion-nav-title>
</ion-nav-bar>
<ion-content ng-controller="buyAmazonController as buy" ng-init="buy.init()">
<ion-content>
<div ng-show="!buy.giftCard">

View file

@ -5,7 +5,7 @@
<ion-nav-title>Buy</ion-nav-title>
</ion-nav-bar>
<ion-content ng-controller="buyGlideraController as buy" ng-init="init()">
<ion-content>
<div class="box-notification warning" ng-show="network == 'testnet'">
Testnet wallets only work with Glidera Sandbox Accounts

View file

@ -1,4 +1,4 @@
<ion-view id="view-confirm" ng-controller="confirmController" ng-init="init()">
<ion-view id="view-confirm">
<ion-nav-bar class="bar-royal">
<ion-nav-title>
{{'Confirm'|translate}}

View file

@ -5,7 +5,7 @@
</ion-nav-back-button>
</ion-nav-bar>
<ion-content ng-controller="exportController" ng-init="file = true; init();">
<ion-content ng-init="file = true">
<div class="row text-center">
<div class="col" ng-click="file = true" ng-style="file && {'border-bottom': '2px solid'}">
<span class="" translate>File/Text</span>

View file

@ -5,7 +5,7 @@
<ion-nav-title>Glidera</ion-nav-title>
</ion-nav-bar>
<ion-content ng-controller="glideraController as glidera" ng-init="init()">
<ion-content>
<div class="box-notification error" ng-show="!network">
Glidera is disabled for this application

View file

@ -5,7 +5,7 @@
<ion-nav-title>Glidera</ion-nav-title>
</ion-nav-bar>
<ion-content ng-controller="glideraUriController" ng-init="checkCode()">
<ion-content>
<div class="box-notification warning" ng-show="network == 'testnet'">
Testnet wallets only work with Glidera Sandbox Accounts

View file

@ -5,7 +5,7 @@
<ion-nav-title>Sell</ion-nav-title>
</ion-nav-bar>
<ion-content ng-controller="sellGlideraController as sell" ng-init="init()">
<ion-content>
<div class="box-notification warning" ng-show="network == 'testnet'">
Testnet wallets only work with Glidera Sandbox Accounts

View file

@ -1,12 +0,0 @@
<ion-view>
<ion-nav-bar class="bar-royal">
<ion-nav-title>{{'Scan' | translate}}</ion-nav-title>
</ion-nav-bar>
<ion-content class="padding" ng-controller="tabScanController" ng-init="init()">
<canvas id="qr-canvas" width="200" height="150"></canvas>
<video id="qrcode-scanner-video" width="300" height="225"></video>
</ion-content>
</ion-view>

View file

@ -1,4 +1,4 @@
<ion-view id="walletDetails" ng-controller="walletDetailsController" ng-init="init()">
<ion-view id="walletDetails">
<ion-nav-bar ng-style="{'background-color': walletDetailsColor}">
<ion-nav-title>{{walletDetailsName}}</ion-nav-title>
<ion-nav-back-button>

View file

@ -1,7 +1,6 @@
'use strict';
angular.module('copayApp.controllers').controller('amountController', function($rootScope, $scope, $filter, $timeout, $ionicScrollDelegate, $ionicNavBarDelegate, gettextCatalog, platformInfo, lodash, configService, rateService, $stateParams, $window, $state, $log, txFormatService) {
$ionicNavBarDelegate.title(gettextCatalog.getString('Enter Amount'));
angular.module('copayApp.controllers').controller('amountController', function($rootScope, $scope, $filter, $timeout, $ionicScrollDelegate, gettextCatalog, platformInfo, lodash, configService, rateService, $stateParams, $window, $state, $log, txFormatService) {
var unitToSatoshi;
var satToUnit;
@ -11,7 +10,7 @@ angular.module('copayApp.controllers').controller('amountController', function($
var SMALL_FONT_SIZE_LIMIT = 13;
var LENGTH_EXPRESSION_LIMIT = 19;
$scope.init = function() {
$scope.$on("$ionicView.enter", function(event, data){
if (!$stateParams.toAddress) {
$log.error('Bad params at amount')
@ -73,7 +72,7 @@ angular.module('copayApp.controllers').controller('amountController', function($
$timeout(function() {
$ionicScrollDelegate.resize();
}, 100);
};
});
$scope.toggleAlternative = function() {
$scope.showAlternativeAmount = !$scope.showAlternativeAmount;

View file

@ -16,25 +16,6 @@ angular.module('copayApp.controllers').controller('backupController',
return false;
};
$scope.init = function() {
$scope.deleted = isDeletedSeed();
if ($scope.deleted) {
$log.debug('no mnemonics');
return;
}
walletService.getKeys(wallet, function(err, k) {
if (err || !k) {
$log.error('Could not get keys: ', err);
$state.go('wallet.preferences');
return;
}
$scope.credentialsEncrypted = false;
keys = k;
$scope.initFlow();
});
};
var shuffledWords = function(words) {
var sort = lodash.sortBy(words);
@ -222,4 +203,23 @@ angular.module('copayApp.controllers').controller('backupController',
});
};
$scope.$on("$ionicView.enter", function(event, data){
$scope.deleted = isDeletedSeed();
if ($scope.deleted) {
$log.debug('no mnemonics');
return;
}
walletService.getKeys(wallet, function(err, k) {
if (err || !k) {
$log.error('Could not get keys: ', err);
$state.go('wallet.preferences');
return;
}
$scope.credentialsEncrypted = false;
keys = k;
$scope.initFlow();
});
});
});

View file

@ -19,14 +19,6 @@ angular.module('copayApp.controllers').controller('buyAmazonController',
externalLinkService.open(url, target);
};
this.init = function() {
var network = amazonService.getEnvironment();
$scope.wallets = profileService.getWallets({
network: network,
onlyComplete: true
});
};
this.confirm = function() {
var message = gettextCatalog.getString('Amazon.com Gift Card purchase for ${{amount}} USD', {amount: $scope.fiat});
var ok = gettextCatalog.getString('Buy');
@ -216,4 +208,12 @@ angular.module('copayApp.controllers').controller('buyAmazonController',
});
};
$scope.$on("$ionicView.enter", function(event, data){
var network = amazonService.getEnvironment();
$scope.wallets = profileService.getWallets({
network: network,
onlyComplete: true
});
});
});

View file

@ -17,36 +17,6 @@ angular.module('copayApp.controllers').controller('buyGlideraController',
$log.debug('Wallet changed: ' + w.name);
});
$scope.init = function(accessToken) {
$scope.network = glideraService.getEnvironment();
$scope.token = accessToken;
$scope.permissions = null;
$scope.email = null;
$scope.personalInfo = null;
$scope.txs = null;
$scope.status = null;
$scope.limits = null;
ongoingProcess.set('connectingGlidera', true);
glideraService.init($scope.token, function(err, glidera) {
ongoingProcess.set('connectingGlidera');
if (err || !glidera) {
if (err) popupService.showAlert(gettextCatalog.getString('Error'), err);
return;
}
$scope.token = glidera.token;
$scope.permissions = glidera.permissions;
$scope.update({fullUpdate: true});
});
$scope.wallets = profileService.getWallets({
network: $scope.network,
n: 1,
onlyComplete: true
});
};
$scope.update = function(opts) {
if (!$scope.token || !$scope.permissions) return;
$log.debug('Updating Glidera Account...');
@ -145,4 +115,34 @@ angular.module('copayApp.controllers').controller('buyGlideraController',
}, 100);
};
$scope.$on("$ionicView.enter", function(event, data){
$scope.network = glideraService.getEnvironment();
$scope.token = accessToken;
$scope.permissions = null;
$scope.email = null;
$scope.personalInfo = null;
$scope.txs = null;
$scope.status = null;
$scope.limits = null;
ongoingProcess.set('connectingGlidera', true);
glideraService.init($scope.token, function(err, glidera) {
ongoingProcess.set('connectingGlidera');
if (err || !glidera) {
if (err) popupService.showAlert(gettextCatalog.getString('Error'), err);
return;
}
$scope.token = glidera.token;
$scope.permissions = glidera.permissions;
$scope.update({fullUpdate: true});
});
$scope.wallets = profileService.getWallets({
network: $scope.network,
n: 1,
onlyComplete: true
});
});
});

View file

@ -4,7 +4,7 @@ angular.module('copayApp.controllers').controller('confirmController', function(
var cachedTxp = {};
var isChromeApp = platformInfo.isChromeApp;
$scope.init = function() {
var initConfirm = function() {
if ($stateParams.paypro) {
return setFromPayPro($stateParams.paypro, function(err) {
if (err && !isChromeApp) {
@ -145,7 +145,7 @@ angular.module('copayApp.controllers').controller('confirmController', function(
$stateParams.paypro = null;
$scope._paypro = paypro;
return $scope.init();
return initConfirm();
});
};
@ -307,4 +307,8 @@ angular.module('copayApp.controllers').controller('confirmController', function(
$scope.cancel = function() {
$state.go('tabs.send');
};
$scope.$on("$ionicView.enter", function(event, data){
initConfirm();
});
});

View file

@ -4,7 +4,7 @@ angular.module('copayApp.controllers').controller('exportController',
function($scope, $timeout, $log, $ionicHistory, backupService, walletService, storageService, profileService, platformInfo, gettextCatalog, $state, $stateParams, popupService) {
var wallet = profileService.getWallet($stateParams.walletId);
$scope.init = function() {
var init = function() {
$scope.formData = {};
$scope.isEncrypted = wallet.isPrivKeyEncrypted();
$scope.isCordova = platformInfo.isCordova;
@ -158,4 +158,8 @@ angular.module('copayApp.controllers').controller('exportController',
});
};
$scope.$on("$ionicView.enter", function(event, data){
init();
});
});

View file

@ -7,7 +7,7 @@ angular.module('copayApp.controllers').controller('glideraController',
externalLinkService.open(url, target);
};
$scope.init = function(accessToken) {
var initGlidera = function(accessToken) {
$scope.network = glideraService.getEnvironment();
$scope.token = null;
@ -78,7 +78,7 @@ angular.module('copayApp.controllers').controller('glideraController',
popupService.showAlert(gettextCatalog.getString('Error'), err);
} else if (data && data.access_token) {
storageService.setGlideraToken($scope.network, data.access_token, function() {
$scope.init(data.access_token);
initGlidera(data.access_token);
$timeout(function() {
$scope.$apply();
}, 100);
@ -113,4 +113,8 @@ angular.module('copayApp.controllers').controller('glideraController',
});
};
$scope.$on("$ionicView.enter", function(event, data){
initGlidera();
});
});

View file

@ -23,7 +23,7 @@ angular.module('copayApp.controllers').controller('glideraUriController',
}, 100);
};
$scope.checkCode = function() {
$scope.$on("$ionicView.enter", function(event, data){
if ($stateParams.url) {
var match = $stateParams.url.match(/code=(.+)/);
if (match && match[1]) {
@ -32,5 +32,5 @@ angular.module('copayApp.controllers').controller('glideraUriController',
}
}
$log.error('Bad state: ' + JSON.stringify($stateParams));
}
});
});

View file

@ -18,36 +18,6 @@ angular.module('copayApp.controllers').controller('sellGlideraController',
$log.debug('Wallet changed: ' + w.name);
});
$scope.init = function(accessToken) {
$scope.network = glideraService.getEnvironment();
$scope.token = accessToken;
$scope.permissions = null;
$scope.email = null;
$scope.personalInfo = null;
$scope.txs = null;
$scope.status = null;
$scope.limits = null;
ongoingProcess.set('connectingGlidera', true);
glideraService.init($scope.token, function(err, glidera) {
ongoingProcess.set('connectingGlidera');
if (err || !glidera) {
if (err) popupService.showAlert(gettextCatalog.getString('Error'), err);
return;
}
$scope.token = glidera.token;
$scope.permissions = glidera.permissions;
$scope.update({fullUpdate: true});
});
$scope.wallets = profileService.getWallets({
network: $scope.network,
n: 1,
onlyComplete: true
});
};
$scope.update = function(opts) {
if (!$scope.token || !$scope.permissions) return;
$log.debug('Updating Glidera Account...');
@ -217,4 +187,34 @@ angular.module('copayApp.controllers').controller('sellGlideraController',
});
});
};
$scope.$on("$ionicView.enter", function(event, data){
$scope.network = glideraService.getEnvironment();
$scope.token = accessToken;
$scope.permissions = null;
$scope.email = null;
$scope.personalInfo = null;
$scope.txs = null;
$scope.status = null;
$scope.limits = null;
ongoingProcess.set('connectingGlidera', true);
glideraService.init($scope.token, function(err, glidera) {
ongoingProcess.set('connectingGlidera');
if (err || !glidera) {
if (err) popupService.showAlert(gettextCatalog.getString('Error'), err);
return;
}
$scope.token = glidera.token;
$scope.permissions = glidera.permissions;
$scope.update({fullUpdate: true});
});
$scope.wallets = profileService.getWallets({
network: $scope.network,
n: 1,
onlyComplete: true
});
});
});

View file

@ -15,49 +15,6 @@ angular.module('copayApp.controllers').controller('walletDetailsController', fun
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) {
/* Uncomment to test multiple outputs */
@ -232,11 +189,54 @@ angular.module('copayApp.controllers').controller('walletDetailsController', fun
$scope.updateAll = function(cb)  {
$scope.updateStatus(false);
$scope.updateTxHistory(cb);
}
};
$scope.hideToggle = function() {
profileService.toggleHideBalanceFlag(wallet.credentials.walletId, function(err) {
if (err) $log.error(err);
});
}
};
$scope.$on("$ionicView.enter", function(event, data){
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'),
});
}
}
});
});
});

View file

@ -136,6 +136,7 @@ angular.module('copayApp').config(function(historicLogProvider, $provide, $logPr
})
.state('uriglidera', {
url: '/uri-glidera/:url',
controller: 'glideraUriController',
templateUrl: 'views/glideraUri.html'
})
.state('uricoinbase', {
@ -153,6 +154,7 @@ angular.module('copayApp').config(function(historicLogProvider, $provide, $logPr
url: '/details/{walletId}/{fromOnboarding}',
views: {
'tab-home': {
controller: 'walletDetailsController',
templateUrl: 'views/walletDetails.html'
}
},
@ -238,6 +240,7 @@ angular.module('copayApp').config(function(historicLogProvider, $provide, $logPr
url: '/amount/:toAddress/:toName/:toEmail',
views: {
'tab-send@tabs': {
controller: 'amountController',
templateUrl: 'views/amount.html'
}
}
@ -246,6 +249,7 @@ angular.module('copayApp').config(function(historicLogProvider, $provide, $logPr
url: '/confirm/:toAddress/:toName/:toAmount/:toEmail/:description/:paypro',
views: {
'tab-send@tabs': {
controller: 'confirmController',
templateUrl: 'views/confirm.html'
}
}
@ -429,6 +433,7 @@ angular.module('copayApp').config(function(historicLogProvider, $provide, $logPr
url: '/backup',
views: {
'preferences': {
controller: 'backupController',
templateUrl: 'views/backup.html'
}
}
@ -453,6 +458,7 @@ angular.module('copayApp').config(function(historicLogProvider, $provide, $logPr
url: '/export',
views: {
'preferences': {
controller: 'exportController',
templateUrl: 'views/export.html'
}
}
@ -671,6 +677,8 @@ angular.module('copayApp').config(function(historicLogProvider, $provide, $logPr
url: '/glidera',
views: {
'tab-home@tabs': {
controller: 'glideraController',
controllerAs: 'glidera',
templateUrl: 'views/glidera.html'
}
}
@ -679,6 +687,8 @@ angular.module('copayApp').config(function(historicLogProvider, $provide, $logPr
url: '/buy',
views: {
'tab-home@tabs': {
controller: 'buyGlideraController',
controllerAs: 'buy',
templateUrl: 'views/buyGlidera.html'
}
}
@ -687,6 +697,8 @@ angular.module('copayApp').config(function(historicLogProvider, $provide, $logPr
url: '/sell',
views: {
'tab-home@tabs': {
controller: 'sellGlideraController',
controllerAs: 'sell',
templateUrl: 'views/sellGlidera.html'
}
}
@ -753,6 +765,8 @@ angular.module('copayApp').config(function(historicLogProvider, $provide, $logPr
url: '/buy',
views: {
'tab-home@tabs': {
controller: 'buyAmazonController',
controllerAs: 'buy',
templateUrl: 'views/buyAmazon.html'
}
}