Merge pull request #228 from JDonadio/ref/delete-wallet
Shows delete wallet popup - Copayers view
This commit is contained in:
commit
05df98df28
2 changed files with 84 additions and 115 deletions
|
|
@ -1,7 +1,5 @@
|
||||||
|
|
||||||
<ion-view ng-controller="copayersController">
|
<ion-view ng-controller="copayersController">
|
||||||
|
|
||||||
|
|
||||||
<ion-nav-bar class="bar-stable">
|
<ion-nav-bar class="bar-stable">
|
||||||
<ion-nav-title>{{wallet.name}}</ion-nav-title>
|
<ion-nav-title>{{wallet.name}}</ion-nav-title>
|
||||||
<ion-nav-buttons side="primary">
|
<ion-nav-buttons side="primary">
|
||||||
|
|
@ -11,75 +9,70 @@
|
||||||
</ion-nav-buttons>
|
</ion-nav-buttons>
|
||||||
</ion-nav-bar>
|
</ion-nav-bar>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
<ion-nav-buttons side="primary">
|
<ion-nav-buttons side="primary">
|
||||||
<button class="button" href ui-sref="tabs.home">
|
<button class="button" href ui-sref="tabs.home">
|
||||||
<i class="ion-arrow-left-c"></i> Back
|
<i class="ion-arrow-left-c"></i> Back
|
||||||
</button>
|
</button>
|
||||||
</ion-nav-buttons>
|
</ion-nav-buttons>
|
||||||
|
|
||||||
|
|
||||||
<ion-content delegate-handle="my-handle" overflow-scroll="true">
|
<ion-content delegate-handle="my-handle" overflow-scroll="true">
|
||||||
|
<div ng-show="!wallet.notAuthorized">
|
||||||
|
<h1 class="text-center" translate>Share this invitation with your copayers</h1>
|
||||||
|
|
||||||
<div ng-show="!wallet.notAuthorized">
|
<div ng-click="copySecret()" ng-class="{'enable_text_select': !isCordova}">
|
||||||
<h1 class="text-center" translate>Share this invitation with your copayers</h1>
|
<div class="text-center">
|
||||||
|
<qrcode size="220" error-correction-level="L" data="{{secret}}"></qrcode>
|
||||||
<div ng-click="copySecret()" ng-class="{'enable_text_select': !isCordova}">
|
<div ng-show="!secret" style="position:relative; top:-226px; height:0px">
|
||||||
<div class="text-center">
|
<div style="height:220px; width:220px; margin:auto; background: white">
|
||||||
<qrcode size="220" error-correction-level="L" data="{{secret}}"></qrcode>
|
<ion-spinner class="spinner-dark" icon="lines"></ion-spinner>
|
||||||
<div ng-show="!secret" style="position:relative; top:-226px; height:0px">
|
</div>
|
||||||
<div style="height:220px; width:220px; margin:auto; background: white">
|
</div>
|
||||||
<ion-spinner class="spinner-stable" icon="lines"></ion-spinner>
|
<div class="secret" ng-show="!isCordova">
|
||||||
|
{{secret || ('Loading...'|translate)}}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="secret" ng-show="!isCordova">
|
|
||||||
{{secret || ('Loading...'|translate)}}
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div ng-show="secret">
|
|
||||||
<div class="text-center m10t" ng-if="isCordova">
|
|
||||||
<span class="button outline round dark-gray tiny m0"
|
|
||||||
ng-click="shareSecret()">
|
|
||||||
<i class="fi-share"></i>
|
|
||||||
<span translate>Share invitation</span>
|
|
||||||
</span>
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="m30v line-t">
|
<div ng-show="secret">
|
||||||
<h4 class="size-14 p10h m10t">
|
<div class="text-center m10t" ng-if="isCordova">
|
||||||
<span translate>Waiting for copayers</span>
|
<span class="button outline round dark-gray tiny m0"
|
||||||
<span class="text-gray right">
|
ng-click="shareSecret()">
|
||||||
[ <span translate>{{wallet.m}}-of-{{wallet.n}}</span> ]
|
<i class="fi-share"></i>
|
||||||
|
<span translate>Share invitation</span>
|
||||||
</span>
|
</span>
|
||||||
</h4>
|
|
||||||
<div class="white line-b p10" ng-include="'views/includes/copayers.html'"></div>
|
|
||||||
<div ng-if="!wallet.isComplete()" class="line-b p10 white size-12">
|
|
||||||
<i class="fi-loop m5r p10l"></i>
|
|
||||||
<span translate>Waiting...</span>
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div ng-if="wallet.isComplete()" class="line-b p10 white size-12" href>
|
<div class="m30v line-t">
|
||||||
<button class="button" href ui-sref="tabs.home">
|
<h4 class="size-14 p10h m10t">
|
||||||
<span translate>WALLET COMPLETE!</span>
|
<span translate>Waiting for copayers</span>
|
||||||
|
<span class="text-gray right">
|
||||||
|
[ <span translate>{{wallet.m}}-of-{{wallet.n}}</span> ]
|
||||||
|
</span>
|
||||||
|
</h4>
|
||||||
|
<div class="white line-b p10" ng-include="'views/includes/copayers.html'"></div>
|
||||||
|
<div ng-if="!wallet.isComplete()" class="line-b p10 white size-12">
|
||||||
|
<i class="fi-loop m5r p10l"></i>
|
||||||
|
<span translate>Waiting...</span>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div ng-if="wallet.isComplete()" class="line-b p10 white size-12" href>
|
||||||
|
<button class="button" href ui-sref="tabs.home">
|
||||||
|
<span translate>WALLET COMPLETE!</span>
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="m20b text-center" ng-show="wallet.notAuthorized">
|
||||||
|
<h1 translate>Wallet incomplete and broken</h1>
|
||||||
|
<h4 translate>Delete it and create a new one</h4>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="text-center">
|
||||||
|
<button class="tiny round outline dark-gray warning" ng-click="showDeletePopup()">
|
||||||
|
<i class="fi-trash"></i> <span translate>Cancel and delete the wallet</span>
|
||||||
</button>
|
</button>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="m20b text-center" ng-show="wallet.notAuthorized">
|
|
||||||
<h1 translate>Wallet incomplete and broken</h1>
|
|
||||||
<h4 translate>Delete it and create a new one</h4>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div class="text-center">
|
|
||||||
<button class="tiny round outline dark-gray warning" ng-click="deleteWallet()">
|
|
||||||
<i class="fi-trash"></i> <span translate>Cancel and delete the wallet</span>
|
|
||||||
</button>
|
|
||||||
</div>
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
|
||||||
</ion-content>
|
</ion-content>
|
||||||
|
|
||||||
</ion-view>
|
</ion-view>
|
||||||
|
|
|
||||||
|
|
@ -1,63 +1,55 @@
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
angular.module('copayApp.controllers').controller('copayersController',
|
angular.module('copayApp.controllers').controller('copayersController',
|
||||||
function($scope, $rootScope, $timeout, $log, $ionicModal, profileService, platformInfo, gettext, gettextCatalog, $stateParams, $state) {
|
function($scope, $log, $ionicPopup, profileService, platformInfo, gettextCatalog, $stateParams, ongoingProcess, $state) {
|
||||||
var self = this;
|
if (!$stateParams.walletId) {
|
||||||
|
$log.debug('No wallet provided...back to home');
|
||||||
|
return $state.transitionTo('tabs.home');
|
||||||
|
}
|
||||||
|
|
||||||
|
var wallet = profileService.getWallet($stateParams.walletId);
|
||||||
|
var secret;
|
||||||
|
try {
|
||||||
|
secret = wallet.status.wallet.secret;
|
||||||
|
} catch (e) {};
|
||||||
|
|
||||||
|
$scope.wallet = wallet;
|
||||||
|
$scope.secret = secret;
|
||||||
$scope.isCordova = platformInfo.isCordova;
|
$scope.isCordova = platformInfo.isCordova;
|
||||||
var isWP = platformInfo.isWP;
|
|
||||||
var isAndroid = platformInfo.isAndroid;
|
|
||||||
|
|
||||||
var delete_msg = gettextCatalog.getString('Are you sure you want to delete this wallet?');
|
$scope.showDeletePopup = function() {
|
||||||
var accept_msg = gettextCatalog.getString('Accept');
|
var popup = $ionicPopup.show({
|
||||||
var cancel_msg = gettextCatalog.getString('Cancel');
|
template: '<span>' + gettextCatalog.getString('Are you sure you want to delete this wallet?') + '</span>',
|
||||||
var confirm_msg = gettextCatalog.getString('Confirm');
|
title: gettextCatalog.getString('Confirm'),
|
||||||
|
buttons: [
|
||||||
var _modalDeleteWallet = function() {
|
{
|
||||||
$scope.title = delete_msg;
|
text: gettextCatalog.getString('Cancel'),
|
||||||
$scope.accept_msg = accept_msg;
|
onTap: function(e) {
|
||||||
$scope.cancel_msg = cancel_msg;
|
popup.close();
|
||||||
$scope.confirm_msg = confirm_msg;
|
|
||||||
$scope.okAction = doDeleteWallet;
|
|
||||||
$scope.loading = false;
|
|
||||||
|
|
||||||
$ionicModal.fromTemplateUrl('views/modals/confirmation.html', {
|
|
||||||
scope: $scope,
|
|
||||||
animation: 'slide-in-up'
|
|
||||||
}).then(function(modal) {
|
|
||||||
$scope.confirmationModal = modal;
|
|
||||||
$scope.confirmationModal.show();
|
|
||||||
});
|
|
||||||
};
|
|
||||||
|
|
||||||
var doDeleteWallet = function() {
|
|
||||||
var wallet = profileService.getWallet($stateParams.walletId);
|
|
||||||
var walletName = wallet.credentials.walletName;
|
|
||||||
profileService.deleteWalletClient(wallet, function(err) {
|
|
||||||
if (err) {
|
|
||||||
self.error = err.message || err;
|
|
||||||
$timeout(function() {
|
|
||||||
$scope.$digest();
|
|
||||||
});
|
|
||||||
} else {
|
|
||||||
$state.go('tabs.home');
|
|
||||||
}
|
|
||||||
});
|
|
||||||
};
|
|
||||||
|
|
||||||
$scope.deleteWallet = function() {
|
|
||||||
if ($scope.isCordova) {
|
|
||||||
navigator.notification.confirm(
|
|
||||||
delete_msg,
|
|
||||||
function(buttonIndex) {
|
|
||||||
if (buttonIndex == 1) {
|
|
||||||
doDeleteWallet();
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
confirm_msg, [accept_msg, cancel_msg]
|
{
|
||||||
);
|
text: gettextCatalog.getString('Accept'),
|
||||||
} else {
|
type: 'button-positive',
|
||||||
_modalDeleteWallet();
|
onTap: function(e) {
|
||||||
}
|
deleteWallet();
|
||||||
|
popup.close();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
function deleteWallet() {
|
||||||
|
ongoingProcess.set('deletingWallet', true);
|
||||||
|
profileService.deleteWalletClient(wallet, function(err) {
|
||||||
|
ongoingProcess.set('deletingWallet', false);
|
||||||
|
if (err) {
|
||||||
|
$scope.error = err.message || err;
|
||||||
|
} else {
|
||||||
|
$state.transitionTo('tabs.home');
|
||||||
|
}
|
||||||
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
$scope.copySecret = function() {
|
$scope.copySecret = function() {
|
||||||
|
|
@ -75,20 +67,4 @@ angular.module('copayApp.controllers').controller('copayersController',
|
||||||
window.plugins.socialsharing.share(message, gettextCatalog.getString('Invitation to share a Copay Wallet'), null, null);
|
window.plugins.socialsharing.share(message, gettextCatalog.getString('Invitation to share a Copay Wallet'), null, null);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
if (!$stateParams.walletId) {
|
|
||||||
$log.debug('No wallet provided...back to home');
|
|
||||||
return $state.transitionTo('tabs.home')
|
|
||||||
}
|
|
||||||
|
|
||||||
var wallet = profileService.getWallet($stateParams.walletId);
|
|
||||||
var secret;
|
|
||||||
try {
|
|
||||||
secret = wallet.status.wallet.secret;
|
|
||||||
} catch (e) {};
|
|
||||||
|
|
||||||
|
|
||||||
$scope.wallet = wallet;
|
|
||||||
$scope.secret = secret;
|
|
||||||
});
|
});
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue