Adds next step for external services

This commit is contained in:
Gustavo Maximiliano Cortez 2016-08-26 11:11:14 -03:00
parent 72fa77dbef
commit c3188d7d17
No known key found for this signature in database
GPG Key ID: 15EDAD8D9F2EB1AF
12 changed files with 159 additions and 104 deletions

View File

@ -12,7 +12,7 @@
<ion-pane>
<ion-content class="calculator" scroll="false" class="amount" ng-controller="amountController" ng-init="init()">
<div class="list card">
<div class="card">
<div class="item item-divider">
Recipient
@ -22,7 +22,9 @@
<i class="icon ion-ios-person-outline"></i>
{{toName || toAddress}}
</div>
</div>
<div class="card">
<div class="item item-divider">
Amount
</div>
@ -41,7 +43,6 @@
{{globalResult}} <span class="label gray text-white radius">{{alternativeResult || '0.00'}} {{unitName}}</span>
</div>
</div>
</div>
</div>
<div class="button-calc">

View File

@ -0,0 +1,20 @@
<ion-view>
<ion-nav-bar class="bar-stable">
<ion-nav-buttons side="primary">
<button class="button no-border" ui-sref="tabs.home">
Close
</button>
</ion-nav-buttons>
<ion-nav-title translate>Buy and sell</ion-nav-title>
</ion-nav-bar>
<ion-content>
<ion-list>
<ion-item class="item" ui-sref="glidera.main">
<img src="img/glidera-logo.png" width="100">
</ion-item>
<ion-item class="item" ui-sref="coinbase.main">
<img src="img/coinbase-logo.png" width="100"> TODO
</ion-item>
</ion-list>
</ion-content>
</ion-view>

View File

@ -4,21 +4,20 @@
<ion-nav-title>Home</ion-nav-title>
</ion-nav-bar>
<ion-content class="padding" ng-controller="tabHomeController">
<h3 class="title" translate>Recent Activity
</h3>
<ion-content class="padding" ng-controller="tabHomeController" ng-init="updateAllWallets(); nextStep()">
<div ng-if="fetchingNotifications" class="updatingHistory">
<div class="text-center">
<ion-spinner class="spinner-dark" icon="lines"></ion-spinner>
<div class="card">
<div class="item item-divider">
Recent Activity
</div>
</div>
<div ng-if="!fetchingNotifications">
<div class="list card">
<div class="item item-icon-left" ng-repeat="x in notifications" ng-click="x.action()">
<div ng-if="fetchingNotifications" class="item text-center">
<ion-spinner icon="lines"></ion-spinner>
<div translate>Updating activity. Please stand by</div>
</div>
<div ng-if="!fetchingNotifications">
<a class="item item-icon-left" ng-repeat="x in notifications" ng-click="x.action()">
<span ng-include="'views/includes/walletActivity.html'"></span>
</div>
</a>
<a class="item text-center" ui-sref="activity" ng-show="notificationsMore">
@ -32,56 +31,62 @@
</div>
</div>
<div class="row">
<div class="col col-80">
<h3 translate>Wallets</h3>
<div class="card">
<div class="item item-divider item-icon-right">
Wallets
<i class="icon ion-ios-plus-empty" ui-sref="add.main"></i>
</div>
<div class="col text-right" ui-sref="add.main">
<i class="size-32 icon ion-ios-plus-empty"></i>
</div>
</div>
<div class="list card" ng-init="updateAllWallets()">
<div class="item" ng-if="!wallets[0]">
<span translate>No Wallet</span>
</div>
<div ng-repeat="item in wallets track by $index"
class="item item-icon-left"
ui-sref="wallet.details({'walletId': item.id})">
<i class="icon ion-briefcase size-21" ng-style="{'color':item.color}"></i>
{{item.name || item.id}}
<span ng-show="item.n > 1" class="text-light">
{{item.m}}-of-{{item.n}}
</span>
<span class="badge badge-assertive" ng-show="!item.isComplete()" translate>
Incomplete
</span>
<span class="item-note" ng-show="item.isComplete()">
{{item.status.availableBalanceStr}}
</span>
</div>
</div>
<div ng-show="glideraEnabled || coinbaseEnabled">
<h3 class="title" translate>Buy & Sell Bitcoin</h3>
<div class="card">
<div ng-show="glideraEnabled" ui-sref="glidera.main" class="item">
<img src="img/glidera-logo.png" width="90">
</div>
<div ng-show="coinbaseEnabled" ui-sref="exchange.coinbase" class="item">
<img src="img/coinbase-logo.png" width="90"> TODO
</div>
</div>
</div>
<h3 class="title" translate>Next steps</h3>
<div class="card">
<div ui-sref="bitpayCard.main" ng-show="bitpayCardEnabled" class="item item-icon-left">
<a ng-repeat="item in wallets track by $index"
class="item item-icon-left"
ui-sref="wallet.details({'walletId': item.id})">
<i class="icon ion-briefcase size-21" ng-style="{'color':item.color}"></i>
{{item.name || item.id}}
<span ng-show="item.n > 1" class="text-light">
{{item.m}}-of-{{item.n}}
</span>
<span class="badge badge-assertive" ng-show="!item.isComplete()" translate>
Incomplete
</span>
<span class="item-note" ng-show="item.isComplete()">
{{item.status.availableBalanceStr}}
</span>
</a>
<a ui-sref="bitpayCard.main" ng-show="externalServices.BitpayCard" class="item item-icon-left">
<i class="icon ion-card"></i>BitPay Card
</div>
<div ui-sref="amazon.main" class="item item-icon-left">
</a>
<a ui-sref="amazon.main" ng-show="externalServices.AmazonGiftCards" class="item item-icon-left">
<i class="icon ion-ios-cart"></i>Gift Cards
</a>
</div>
<div class="card" ng-show="externalServices.BuyAndSell && (glideraEnabled || coinbaseEnabled)">
<div class="item item-divider">
Buy & Sell Bitcoin
</div>
<a ng-show="glideraEnabled" ui-sref="glidera.main" class="item">
<img src="img/glidera-logo.png" width="90">
</a>
<a ng-show="coinbaseEnabled" ui-sref="exchange.coinbase" class="item">
<img src="img/coinbase-logo.png" width="90"> TODO
</a>
</div>
<div class="card" ng-show="!externalServices.AmazonGiftCards || !externalServices.BitpayCard || !externalServices.BuyAndSell">
<div class="item item-divider">
Next steps
</div>
<a ui-sref="bitpayCard.main" ng-show="!externalServices.BitpayCard" class="item item-icon-left">
<i class="icon ion-card"></i>Add BitPay Card
</a>
<a ng-show="!externalServices.BuyAndSell" ui-sref="buyandsell" class="item item-icon-left">
<i class="icon ion-bag"></i>Buy and Sell Bitcoin
</a>
<a ui-sref="amazon.main" ng-show="!externalServices.AmazonGiftCards" class="item item-icon-left">
<i class="icon ion-ios-cart"></i>Buy a Gift Cards
</a>
</div>
</ion-content>

View File

@ -4,33 +4,31 @@
<ion-nav-title>Send</ion-nav-title>
</ion-nav-bar>
<ion-content class="send" ng-controller="tabSendController" ng-init="init()">
<ion-content ng-controller="tabSendController" ng-init="init()">
<div class="padding">
<h2>Recipient</h2>
<label class="item item-input">
<i class="icon ion-search placeholder-icon"></i>
<input type="text" placeholder="Recipient" ng-model="search" ng-model-onblur ng-change="findContact(search)">
</label>
</div>
<div class="row">
<div class="col col-80">
<h3>Contacts & Wallets</h3>
<div class="card">
<div class="item item-divider">
Recipient
</div>
<div class="col col-20 text-right">
<a class="button button-light" ng-click="openAddressbookModal()">
<i class="size-36 icon ion-person-add"></i>
</a>
<div class="list list-inset">
<label class="item item-input">
<i class="icon ion-search placeholder-icon"></i>
<input type="text"
placeholder="Search or enter bitcoin address"
ng-model="search"
ng-change="findContact(search)"
ng-model-onblur>
</label>
</div>
</div>
<div class="list card padding text-center" ng-if="!list[0]">
<span translate>No Wallet - Contact</span>
</div>
<div class="list card" ng-if="list[0]">
<div class="card" ng-if="list[0]">
<div class="item item-divider item-icon-right">
Contacts & Wallets
<i class="icon ion-person-add" ng-click="openAddressbookModal()"></i>
</div>
<div class="item text-center" ng-show="!list[0]" translate>No Wallet - Contact</div>
<a class="item item-icon-left" ng-repeat="item in list" ng-click="goToAmount(item)">
<i ng-show="item.isWallet" class="icon ion-briefcase size-21" ng-style="{'color':item.color}"></i>
<i ng-show="!item.isWallet" class="icon ion-ios-person-outline"></i>

View File

@ -5,7 +5,7 @@
<ion-nav-title>{{wallet.name}}</ion-nav-title>
<ion-nav-buttons side="primary">
<button class="button no-border" ui-sref="tabs.home">
<i class="icon ion-chevron-left"></i> Close
Close
</button>
</ion-nav-buttons>
<ion-nav-buttons side="secondary">

View File

@ -1,7 +1,7 @@
'use strict';
angular.module('copayApp.controllers').controller('tabHomeController',
function($rootScope, $timeout, $scope, $state, lodash, profileService, walletService, configService, txFormatService, $ionicModal, $log, platformInfo) {
function($rootScope, $timeout, $scope, $state, lodash, profileService, walletService, configService, txFormatService, $ionicModal, $log, platformInfo, storageService) {
var setNotifications = function(notifications) {
var n = walletService.processNotifications(notifications, 5);
@ -68,7 +68,14 @@ console.log('[tab-home.js.39]', wallet.name, n); //TODO
});
};
$scope.externalServices = {};
$scope.nextStep = function() {
lodash.each(['AmazonGiftCards', 'BitpayCard', 'BuyAndSell'], function(service) {
storageService.getNextStep(service, function(err, value) {
$scope.externalServices[service] = value ? true : false;
});
});
};
$scope.bitpayCardEnabled = true; // TODO

View File

@ -105,7 +105,10 @@ angular.module('copayApp').config(function(historicLogProvider, $provide, $logPr
templateUrl: 'views/starting.html'
})
.state('buyandsell', {
url: '/buyandsell',
templateUrl: 'views/buyandsell.html'
})
/*
*

View File

@ -68,6 +68,9 @@ angular.module('copayApp.services').factory('amazonService', function($http, $lo
return cb(err);
});
});
// Show pending task from the UI
storageService.setNextStep('AmazonGiftCards', true, function(err) {});
};
root.getPendingGiftCards = function(cb) {

View File

@ -36,6 +36,8 @@ angular.module('copayApp.services').factory('bitpayCardService', function($http,
storageService.setBitpayCard(credentials.NETWORK, user, function(err) {
return cb(err);
});
// Show pending task from the UI
storageService.setNextStep('BitpayCard', true, function(err) {});
};
var _getSession = function(cb) {

View File

@ -41,9 +41,9 @@ angular.module('copayApp.services').factory('coinbaseService', function($http, $
};
root.getOauthCodeUrl = function() {
return credentials.HOST
+ '/oauth/authorize?response_type=code&client_id='
+ credentials.CLIENT_ID
return credentials.HOST
+ '/oauth/authorize?response_type=code&client_id='
+ credentials.CLIENT_ID
+ '&redirect_uri='
+ credentials.REDIRECT_URI
+ '&state=SECURE_RANDOM&scope='
@ -59,7 +59,7 @@ angular.module('copayApp.services').factory('coinbaseService', function($http, $
'Content-Type': 'application/json',
'Accept': 'application/json'
},
data: {
data: {
grant_type : 'authorization_code',
code: code,
client_id : credentials.CLIENT_ID,
@ -70,7 +70,9 @@ angular.module('copayApp.services').factory('coinbaseService', function($http, $
$http(req).then(function(data) {
$log.info('Coinbase Authorization Access Token: SUCCESS');
return cb(null, data.data);
// Show pending task from the UI
storageService.setNextStep('BuyAndSell', true, function(err) {});
return cb(null, data.data);
}, function(data) {
$log.error('Coinbase Authorization Access Token: ERROR ' + data.statusText);
return cb(data.data);
@ -85,18 +87,18 @@ angular.module('copayApp.services').factory('coinbaseService', function($http, $
'Content-Type': 'application/json',
'Accept': 'application/json'
},
data: {
data: {
grant_type : 'refresh_token',
client_id : credentials.CLIENT_ID,
client_secret: credentials.CLIENT_SECRET,
redirect_uri: credentials.REDIRECT_URI,
refresh_token: refreshToken
refresh_token: refreshToken
}
};
$http(req).then(function(data) {
$log.info('Coinbase Refresh Access Token: SUCCESS');
return cb(null, data.data);
return cb(null, data.data);
}, function(data) {
$log.error('Coinbase Refresh Access Token: ERROR ' + data.statusText);
return cb(data.data);
@ -195,17 +197,17 @@ angular.module('copayApp.services').factory('coinbaseService', function($http, $
root.sellPrice = function(token, currency, cb) {
$http(_get('/prices/sell?currency=' + currency, token)).then(function(data) {
$log.info('Coinbase Sell Price: SUCCESS');
return cb(null, data.data);
return cb(null, data.data);
}, function(data) {
$log.error('Coinbase Sell Price: ERROR ' + data.statusText);
return cb(data.data);
});
};
};
root.buyPrice = function(token, currency, cb) {
$http(_get('/prices/buy?currency=' + currency, token)).then(function(data) {
$log.info('Coinbase Buy Price: SUCCESS');
return cb(null, data.data);
return cb(null, data.data);
}, function(data) {
$log.error('Coinbase Buy Price: ERROR ' + data.statusText);
return cb(data.data);
@ -215,7 +217,7 @@ angular.module('copayApp.services').factory('coinbaseService', function($http, $
root.getPaymentMethods = function(token, cb) {
$http(_get('/payment-methods', token)).then(function(data) {
$log.info('Coinbase Get Payment Methods: SUCCESS');
return cb(null, data.data);
return cb(null, data.data);
}, function(data) {
$log.error('Coinbase Get Payment Methods: ERROR ' + data.statusText);
return cb(data.data);
@ -225,7 +227,7 @@ angular.module('copayApp.services').factory('coinbaseService', function($http, $
root.getPaymentMethod = function(token, paymentMethodId, cb) {
$http(_get('/payment-methods/' + paymentMethodId, token)).then(function(data) {
$log.info('Coinbase Get Payment Method: SUCCESS');
return cb(null, data.data);
return cb(null, data.data);
}, function(data) {
$log.error('Coinbase Get Payment Method: ERROR ' + data.statusText);
return cb(data.data);
@ -243,7 +245,7 @@ angular.module('copayApp.services').factory('coinbaseService', function($http, $
},
data: data
};
};
};
root.sellRequest = function(token, accountId, data, cb) {
var data = {
@ -254,7 +256,7 @@ angular.module('copayApp.services').factory('coinbaseService', function($http, $
};
$http(_post('/accounts/' + accountId + '/sells', token, data)).then(function(data) {
$log.info('Coinbase Sell Request: SUCCESS');
return cb(null, data.data);
return cb(null, data.data);
}, function(data) {
$log.error('Coinbase Sell Request: ERROR ' + data.statusText);
return cb(data.data);
@ -264,12 +266,12 @@ angular.module('copayApp.services').factory('coinbaseService', function($http, $
root.sellCommit = function(token, accountId, sellId, cb) {
$http(_post('/accounts/' + accountId + '/sells/' + sellId + '/commit', token)).then(function(data) {
$log.info('Coinbase Sell Commit: SUCCESS');
return cb(null, data.data);
return cb(null, data.data);
}, function(data) {
$log.error('Coinbase Sell Commit: ERROR ' + data.statusText);
return cb(data.data);
});
};
};
root.buyRequest = function(token, accountId, data, cb) {
var data = {
@ -280,7 +282,7 @@ angular.module('copayApp.services').factory('coinbaseService', function($http, $
};
$http(_post('/accounts/' + accountId + '/buys', token, data)).then(function(data) {
$log.info('Coinbase Buy Request: SUCCESS');
return cb(null, data.data);
return cb(null, data.data);
}, function(data) {
$log.error('Coinbase Buy Request: ERROR ' + data.statusText);
return cb(data.data);
@ -290,7 +292,7 @@ angular.module('copayApp.services').factory('coinbaseService', function($http, $
root.buyCommit = function(token, accountId, buyId, cb) {
$http(_post('/accounts/' + accountId + '/buys/' + buyId + '/commit', token)).then(function(data) {
$log.info('Coinbase Buy Commit: SUCCESS');
return cb(null, data.data);
return cb(null, data.data);
}, function(data) {
$log.error('Coinbase Buy Commit: ERROR ' + data.statusText);
return cb(data.data);
@ -303,7 +305,7 @@ angular.module('copayApp.services').factory('coinbaseService', function($http, $
};
$http(_post('/accounts/' + accountId + '/addresses', token, data)).then(function(data) {
$log.info('Coinbase Create Address: SUCCESS');
return cb(null, data.data);
return cb(null, data.data);
}, function(data) {
$log.error('Coinbase Create Address: ERROR ' + data.statusText);
return cb(data.data);
@ -320,7 +322,7 @@ angular.module('copayApp.services').factory('coinbaseService', function($http, $
};
$http(_post('/accounts/' + accountId + '/transactions', token, data)).then(function(data) {
$log.info('Coinbase Create Address: SUCCESS');
return cb(null, data.data);
return cb(null, data.data);
}, function(data) {
$log.error('Coinbase Create Address: ERROR ' + data.statusText);
return cb(data.data);
@ -328,7 +330,7 @@ angular.module('copayApp.services').factory('coinbaseService', function($http, $
};
// Pending transactions
root.savePendingTransaction = function(ctx, opts, cb) {
var network = configService.getSync().coinbase.testnet ? 'testnet' : 'livenet';
storageService.getCoinbaseTxs(network, function(err, oldTxs) {

View File

@ -74,6 +74,8 @@ angular.module('copayApp.services').factory('glideraService', function($http, $l
$http(req).then(function(data) {
$log.info('Glidera Authorization Access Token: SUCCESS');
// Show pending task from the UI
storageService.setNextStep('BuyAndSell', true, function(err) {});
return cb(null, data.data);
}, function(data) {
$log.error('Glidera Authorization Access Token: ERROR ' + data.statusText);

View File

@ -264,6 +264,18 @@ angular.module('copayApp.services')
storage.remove('addressbook-' + network, cb);
};
root.setNextStep = function(service, status, cb) {
storage.set('nextStep-' + service, status, cb);
};
root.getNextStep = function(service, cb) {
storage.get('nextStep-' + service, cb);
};
root.removeNextStep = function(service, cb) {
storage.remove('nextStep-' + service, cb);
};
root.checkQuota = function() {
var block = '';