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-nav-bar class="bar-stable">
|
||||
<ion-nav-title>{{wallet.name}}</ion-nav-title>
|
||||
<ion-nav-buttons side="primary">
|
||||
|
|
@ -11,75 +9,70 @@
|
|||
</ion-nav-buttons>
|
||||
</ion-nav-bar>
|
||||
|
||||
|
||||
|
||||
<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
|
||||
</button>
|
||||
</ion-nav-buttons>
|
||||
|
||||
|
||||
<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">
|
||||
<h1 class="text-center" translate>Share this invitation with your copayers</h1>
|
||||
|
||||
<div ng-click="copySecret()" ng-class="{'enable_text_select': !isCordova}">
|
||||
<div class="text-center">
|
||||
<qrcode size="220" error-correction-level="L" data="{{secret}}"></qrcode>
|
||||
<div ng-show="!secret" style="position:relative; top:-226px; height:0px">
|
||||
<div style="height:220px; width:220px; margin:auto; background: white">
|
||||
<ion-spinner class="spinner-stable" icon="lines"></ion-spinner>
|
||||
<div ng-click="copySecret()" ng-class="{'enable_text_select': !isCordova}">
|
||||
<div class="text-center">
|
||||
<qrcode size="220" error-correction-level="L" data="{{secret}}"></qrcode>
|
||||
<div ng-show="!secret" style="position:relative; top:-226px; height:0px">
|
||||
<div style="height:220px; width:220px; margin:auto; background: white">
|
||||
<ion-spinner class="spinner-dark" icon="lines"></ion-spinner>
|
||||
</div>
|
||||
</div>
|
||||
<div class="secret" ng-show="!isCordova">
|
||||
{{secret || ('Loading...'|translate)}}
|
||||
</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 class="m30v line-t">
|
||||
<h4 class="size-14 p10h m10t">
|
||||
<span translate>Waiting for copayers</span>
|
||||
<span class="text-gray right">
|
||||
[ <span translate>{{wallet.m}}-of-{{wallet.n}}</span> ]
|
||||
<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>
|
||||
</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>
|
||||
<div class="m30v line-t">
|
||||
<h4 class="size-14 p10h m10t">
|
||||
<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>
|
||||
</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>
|
||||
</ion-content>
|
||||
|
||||
</ion-view>
|
||||
|
|
|
|||
|
|
@ -1,63 +1,55 @@
|
|||
'use strict';
|
||||
|
||||
angular.module('copayApp.controllers').controller('copayersController',
|
||||
function($scope, $rootScope, $timeout, $log, $ionicModal, profileService, platformInfo, gettext, gettextCatalog, $stateParams, $state) {
|
||||
var self = this;
|
||||
function($scope, $log, $ionicPopup, profileService, platformInfo, gettextCatalog, $stateParams, ongoingProcess, $state) {
|
||||
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;
|
||||
var isWP = platformInfo.isWP;
|
||||
var isAndroid = platformInfo.isAndroid;
|
||||
|
||||
var delete_msg = gettextCatalog.getString('Are you sure you want to delete this wallet?');
|
||||
var accept_msg = gettextCatalog.getString('Accept');
|
||||
var cancel_msg = gettextCatalog.getString('Cancel');
|
||||
var confirm_msg = gettextCatalog.getString('Confirm');
|
||||
|
||||
var _modalDeleteWallet = function() {
|
||||
$scope.title = delete_msg;
|
||||
$scope.accept_msg = accept_msg;
|
||||
$scope.cancel_msg = cancel_msg;
|
||||
$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();
|
||||
$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();
|
||||
}
|
||||
},
|
||||
confirm_msg, [accept_msg, cancel_msg]
|
||||
);
|
||||
} else {
|
||||
_modalDeleteWallet();
|
||||
}
|
||||
{
|
||||
text: gettextCatalog.getString('Accept'),
|
||||
type: 'button-positive',
|
||||
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() {
|
||||
|
|
@ -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);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
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