Updates new spinner

This commit is contained in:
Gustavo Maximiliano Cortez 2016-06-13 21:50:48 -03:00
parent 7793be3615
commit 02334320d0
No known key found for this signature in database
GPG Key ID: 15EDAD8D9F2EB1AF
5 changed files with 22 additions and 51 deletions

View File

@ -25,19 +25,6 @@
<div class="content amazon p20b" ng-controller="amazonController as amazon">
<div class="onGoingProcess" ng-show="amazon.loading">
<div class="onGoingProcess-content">
<div class="spinner">
<div class="rect1"></div>
<div class="rect2"></div>
<div class="rect3"></div>
<div class="rect4"></div>
<div class="rect5"></div>
</div>
<span ng-show="amazon.loading">{{amazon.loading}}</span>
</div>
</div>
<div ng-init="amazon.init()">
<div class="box-notification text-center size-12 text-warning m10t" ng-show="amazon.sandbox">

View File

@ -7,19 +7,6 @@
<div class="content amazon" ng-controller="buyAmazonController as buy">
<div class="onGoingProcess" ng-show="buy.loading">
<div class="onGoingProcess-content">
<div class="spinner">
<div class="rect1"></div>
<div class="rect2"></div>
<div class="rect3"></div>
<div class="rect4"></div>
<div class="rect5"></div>
</div>
<span>{{buy.loading}}</span>
</div>
</div>
<div class="row m20t" ng-show="!buy.giftCard" ng-init="buy.init()">
<div class="columns">
@ -73,7 +60,7 @@
<div class="input m20t">
<input class="button black round expand"
ng-disabled="!buy.selectedWalletId || buy.loading || !fiat"
ng-disabled="!buy.selectedWalletId || !fiat"
type="submit" value="Buy now">
</div>
</form>

View File

@ -53,7 +53,7 @@
</span>
</div>
<div class="text-center size-12" ng-show="card.status != 'SUCCESS' && !loading">
<div class="text-center size-12" ng-show="card.status != 'SUCCESS'">
<div ng-show="card.status == 'RESEND'">
<div class="text-secondary m10h">
There was a temporary/recoverable system failure that can be resolved by retrying the request
@ -116,8 +116,7 @@
This action will remove the gift card
</p>
<button class="button outline round dark-gray tiny"
ng-click="remove();"
ng-disabled="loading">
ng-click="remove()">
<i class="fi-x"></i>
Remove
</button>
@ -130,8 +129,7 @@
This action will cancel the gift card
</p>
<button class="button outline round dark-gray tiny"
ng-click="cancelGiftCard()"
ng-disabled="loading">
ng-click="cancelGiftCard()">
<i class="fi-x"></i>
Cancel
</button>

View File

@ -1,7 +1,7 @@
'use strict';
angular.module('copayApp.controllers').controller('buyAmazonController',
function($rootScope, $scope, $ionicModal, $log, $timeout, lodash, profileService, bwsError, configService, walletService, fingerprintService, amazonService) {
function($rootScope, $scope, $ionicModal, $log, $timeout, lodash, profileService, bwsError, configService, walletService, fingerprintService, amazonService, ongoingProcess) {
var self = this;
var client;
@ -60,7 +60,6 @@ angular.module('copayApp.controllers').controller('buyAmazonController',
};
this.setAmount = function(plus) {
if (self.loading) return;
if (plus && $scope.fiat < maximumAmount ) {
stepAmount = stepAmount + 1;
$scope.fiat = stepAmount * multiplierAmount;
@ -86,12 +85,12 @@ angular.module('copayApp.controllers').controller('buyAmazonController',
var walletSettings = configWallet.settings;
self.loading = 'Creating invoice...';
ongoingProcess.set('Creating invoice...', true);
$timeout(function() {
amazonService.createBitPayInvoice(dataSrc, function(err, data) {
ongoingProcess.set('Creating invoice...', false);
if (err) {
self.loading = null;
self.error = bwsError.msg(err);
$scope.$apply();
return;
@ -119,23 +118,22 @@ angular.module('copayApp.controllers').controller('buyAmazonController',
feeLevel: walletSettings.feeLevel || 'normal'
};
self.loading = 'Creating transaction...';
ongoingProcess.set('Creating transaction...', true);
walletService.createTx(client, txp, function(err, createdTxp) {
self.loading = null;
ongoingProcess.set('Creating transaction...', false);
if (err) {
self.loading = null;
$log.debug(err);
self.error = bwsError.msg(err);
$scope.$apply();
return;
}
$scope.$emit('Local/NeedsConfirmation', createdTxp, function(accept) {
if (accept) {
self.loading = 'Sending bitcoin...';
ongoingProcess.set('Sending bitcoin...', true);
self.confirmTx(createdTxp, function(err, tx) {
ongoingProcess.set('Sending bitcoin...', false);
if (err) {
self.loading = null;
self.error = err;
self.error = bwsError.msg(err);
$scope.$apply();
return;
}
var gift = {
@ -144,12 +142,13 @@ angular.module('copayApp.controllers').controller('buyAmazonController',
bitpayInvoiceId: data.data.id,
bitpayInvoiceUrl: data.data.url
};
self.loading = 'Creating gift card...';
ongoingProcess.set('Creating gift card...', true);
amazonService.createGiftCard(gift, function(err, giftCard) {
self.loading = null;
ongoingProcess.set('Creating gift card...', false);
if (err) {
self.error = err;
self.error = bwsError.msg(err);
self.errorInfo = gift;
$scope.$apply();
return;
}
amazonService.setAmountByDay(dataSrc.price);

View File

@ -1,6 +1,6 @@
'use strict';
angular.module('copayApp.controllers').controller('amazonCardDetailsController', function($scope, $timeout, amazonService) {
angular.module('copayApp.controllers').controller('amazonCardDetailsController', function($scope, $timeout, amazonService, ongoingProcess) {
$scope.cancelGiftCard = function() {
var dataSrc = {
@ -10,9 +10,9 @@ angular.module('copayApp.controllers').controller('amazonCardDetailsController',
bitpayInvoiceUrl: $scope.card.bitpayInvoiceUrl,
date: $scope.card.date
};
$scope.loading = true;
ongoingProcess.set('Canceling gift card...', true);
amazonService.cancelGiftCard(dataSrc, function(err, data) {
$scope.loading = null;
ongoingProcess.set('Canceling gift card...', false);
if (err || data.status != 'SUCCESS') {
$scope.error = err || data.status;
return;
@ -36,9 +36,9 @@ angular.module('copayApp.controllers').controller('amazonCardDetailsController',
bitpayInvoiceUrl: $scope.card.bitpayInvoiceUrl,
date: $scope.card.date
};
$scope.loading = true;
ongoingProcess.set('Updating gift card...', true);
amazonService.createGiftCard(dataSrc, function(err, data) {
$scope.loading = null;
ongoingProcess.set('Updating gift card...', false);
if (err) {
$scope.error = err;
return;