This commit is contained in:
Matias Alejo Garcia 2016-08-19 13:17:54 -03:00
commit 7d98063c43
No known key found for this signature in database
GPG key ID: 02470DB551277AB3
12 changed files with 46 additions and 129 deletions

View file

@ -10,9 +10,9 @@
<ion-content class="has-header" ng-controller="preferencesDeleteWalletController" cache-view="false">
<div translate>Warning!</div>
<div translate>Permanently delete this wallet. THIS ACTION CANNOT BE REVERSED</div>
<div class="right" ng-style="{'color':index.backgroundColor}" ng-show="!isDeletingWallet">
{{index.walletName}}<span ng-show="index.alias">({{index.alias}})</span>
<div class="right" ng-style="{'color':backgroundColor}" ng-show="!isDeletingWallet">
<span ng-show="alias">{{alias}}</span>{{walletName}}
</div>
<button class="button button-block button-stable" ng-click="deleteWallet()"translate>Delete wallet</button>
<button class="button button-block button-stable" ng-click="showDeletePopup()"translate>Delete wallet</button>
</ion-content>
</ion-view>

View file

@ -1,6 +1,6 @@
'use strict';
angular.module('copayApp.controllers').controller('amountController', function($rootScope, $scope, $filter, $timeout, $ionicScrollDelegate, platformInfo, lodash, configService, go, rateService, $stateParams, $window, $state, $log, txFormatService) {
angular.module('copayApp.controllers').controller('amountController', function($rootScope, $scope, $filter, $timeout, $ionicScrollDelegate, platformInfo, lodash, configService, rateService, $stateParams, $window, $state, $log, txFormatService) {
var unitToSatoshi;

View file

@ -1,6 +1,6 @@
'use strict';
angular.module('copayApp.controllers').controller('coinbaseUriController',
function($scope, $stateParams, $timeout, profileService, configService, coinbaseService, storageService, go, ongoingProcess) {
function($scope, $stateParams, $timeout, profileService, configService, coinbaseService, storageService, $state, ongoingProcess) {
this.submitOauthCode = function(code) {
var self = this;
@ -21,7 +21,7 @@ angular.module('copayApp.controllers').controller('coinbaseUriController',
storageService.setCoinbaseRefreshToken(network, data.refresh_token, function() {
$scope.$emit('Local/CoinbaseUpdated', data.access_token);
$timeout(function() {
go.path('coinbase');
$state.go('coinbase');
$scope.$apply();
}, 100);
});

View file

@ -1,6 +1,6 @@
'use strict';
angular.module('copayApp.controllers').controller('confirmController', function($rootScope, $scope, $filter, $timeout, $ionicScrollDelegate, walletService, platformInfo, lodash, configService, go, rateService, $stateParams, $window, $state, $log, profileService, bitcore, $ionicPopup, txStatus, gettext, txFormatService) {
angular.module('copayApp.controllers').controller('confirmController', function($rootScope, $scope, $filter, $timeout, $ionicScrollDelegate, walletService, platformInfo, lodash, configService, rateService, $stateParams, $window, $state, $log, profileService, bitcore, $ionicPopup, txStatus, gettext, txFormatService) {
var cachedTxp = {};

View file

@ -1,7 +1,7 @@
'use strict';
angular.module('copayApp.controllers').controller('copayersController',
function($scope, $rootScope, $timeout, $log, $ionicModal, profileService, $state, notification, platformInfo, gettext, gettextCatalog, $stateParams, $state) {
function($scope, $rootScope, $timeout, $log, $ionicModal, profileService, notification, platformInfo, gettext, gettextCatalog, $stateParams, $state) {
var self = this;
$scope.isCordova = platformInfo.isCordova;
var isWP = platformInfo.isWP;

View file

@ -1,6 +1,6 @@
'use strict';
angular.module('copayApp.controllers').controller('glideraUriController',
function($scope, $log, $stateParams, $timeout, profileService, configService, glideraService, storageService, go, ongoingProcess) {
function($scope, $log, $stateParams, $timeout, profileService, configService, glideraService, storageService, $state, ongoingProcess) {
this.submitOauthCode = function(code) {
$log.debug('Glidera Oauth Code:' + code);
@ -21,7 +21,7 @@ angular.module('copayApp.controllers').controller('glideraUriController',
storageService.setGlideraToken(network, data.access_token, function() {
$scope.$emit('Local/GlideraUpdated', data.access_token);
$timeout(function() {
go.path('glidera');
$state.go('glidera');
$scope.$apply();
}, 100);
});

View file

@ -1,7 +1,7 @@
'use strict';
angular.module('copayApp.controllers').controller('preferencesAltCurrencyController',
function($scope, $log, $timeout, configService, rateService, lodash, go, profileService, walletService) {
function($scope, $log, $timeout, configService, rateService, lodash, profileService, walletService, $state) {
var next = 10;
var completeAlternativeList;
@ -42,7 +42,7 @@ angular.module('copayApp.controllers').controller('preferencesAltCurrencyControl
configService.set(opts, function(err) {
if (err) $log.warn(err);
go.preferencesGlobal();
$state.go('preferencesGlobal');
$scope.$emit('Local/UnitSettingUpdated');
walletService.updateRemotePreferences(profileService.getClients(), {}, function() {
$log.debug('Remote preferences saved');

View file

@ -1,39 +1,39 @@
'use strict';
angular.module('copayApp.controllers').controller('preferencesDeleteWalletController',
function($scope, $rootScope, $filter, $timeout, $log, $ionicModal, storageService, notification, profileService, platformInfo, $state, gettext, gettextCatalog, applicationService, ongoingProcess) {
var isCordova = platformInfo.isCordova;
$scope.isCordova = isCordova;
function($scope, $ionicPopup, $stateParams, lodash, notification, profileService, $state, gettextCatalog, ongoingProcess) {
var wallet = profileService.getWallet($stateParams.walletId);
$scope.alias = lodash.isEqual(wallet.name, wallet.credentials.walletName) ? null : wallet.name + ' ';
$scope.walletName = '[' + wallet.credentials.walletName + ']';
$scope.error = null;
var walletName = $scope.alias || $scope.walletName;
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
}).then(function(modal) {
$scope.confirmationModal = modal;
$scope.confirmationModal.show();
$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();
}
},
{
text: gettextCatalog.getString('Accept'),
type: 'button-positive',
onTap: function(e) {
deleteWallet();
popup.close();
}
}
]
});
};
var doDeleteWallet = function() {
function deleteWallet() {
ongoingProcess.set('deletingWallet', true);
var fc = profileService.focusedClient;
var name = fc.credentials.walletName;
var walletName = (fc.alias || '') + ' [' + name + ']';
profileService.deleteWalletClient(fc, function(err) {
profileService.deleteWalletClient(wallet, function(err) {
ongoingProcess.set('deletingWallet', false);
if (err) {
$scope.error = err.message || err;
@ -45,20 +45,4 @@ angular.module('copayApp.controllers').controller('preferencesDeleteWalletContro
}
});
};
$scope.deleteWallet = function() {
if (isCordova) {
navigator.notification.confirm(
delete_msg,
function(buttonIndex) {
if (buttonIndex == 1) {
doDeleteWallet();
}
},
confirm_msg, [accept_msg, cancel_msg]
);
} else {
_modalDeleteWallet();
}
};
});

View file

@ -1,6 +1,6 @@
'use strict';
angular.module('copayApp.controllers').controller('preferencesUnitController', function($scope, $log, configService, go, walletService, profileService) {
angular.module('copayApp.controllers').controller('preferencesUnitController', function($scope, $log, configService, $state, walletService, profileService) {
$scope.init = function() {
var config = configService.getSync();
@ -36,7 +36,7 @@ angular.module('copayApp.controllers').controller('preferencesUnitController', f
configService.set(opts, function(err) {
if (err) $log.warn(err);
go.preferencesGlobal();
$state.go('preferencesGlobal');
$scope.$emit('Local/UnitSettingUpdated');
walletService.updateRemotePreferences(profileService.getClients(), {}, function() {

View file

@ -1,67 +0,0 @@
'use strict';
angular.module('copayApp.controllers').controller('sidebarController',
function($rootScope, $timeout, $ionicScrollDelegate, lodash, profileService, configService, go, platformInfo, $window) {
var self = this;
self.isWindowsPhoneApp = platformInfo.isWP && platformInfo.isCordova;
self.walletSelection = false;
self.bitpayCardEnabled = $window.appConfig && $window.appConfig._enabledExtensions.debitcard;
// wallet list change
$rootScope.$on('Local/WalletListUpdated', function(event) {
self.walletSelection = false;
self.setWallets();
});
$rootScope.$on('Local/ColorUpdated', function(event) {
self.setWallets();
});
$rootScope.$on('Local/AliasUpdated', function(event) {
self.setWallets();
});
self.signout = function() {
profileService.signout();
};
self.switchWallet = function(selectedWalletId, currentWalletId) {
var client = profileService.focusedClient;
if (selectedWalletId == currentWalletId && client.isComplete()) return;
self.walletSelection = false;
profileService.setAndStoreFocus(selectedWalletId, function() {});
$ionicScrollDelegate.scrollTop();
};
self.toggleWalletSelection = function() {
self.walletSelection = !self.walletSelection;
if (!self.walletSelection) return;
self.setWallets();
};
self.setWallets = function() {
if (!profileService.profile) return;
var config = configService.getSync();
config.colorFor = config.colorFor || {};
config.aliasFor = config.aliasFor || {};
// Sanitize empty wallets (fixed in BWC 1.8.1, and auto fixed when wallets completes)
var credentials = lodash.filter(profileService.profile.credentials, 'walletName');
var ret = lodash.map(credentials, function(c) {
return {
m: c.m,
n: c.n,
name: config.aliasFor[c.walletId] || c.walletName,
id: c.walletId,
color: config.colorFor[c.walletId] || '#4A90E2',
};
});
self.wallets = lodash.sortBy(ret, 'name');
};
self.setWallets();
});

View file

@ -1,6 +1,6 @@
'use strict';
angular.module('copayApp.controllers').controller('tabScanController', function($scope, $timeout, $ionicModal, $log, $ionicPopup, configService, gettextCatalog, platformInfo, go, bitcore, lodash) {
angular.module('copayApp.controllers').controller('tabScanController', function($scope, $timeout, $ionicModal, $log, $ionicPopup, configService, gettextCatalog, platformInfo, bitcore, lodash, $state) {
var isCordova = platformInfo.isCordova;
var isWP = platformInfo.isWP;
@ -36,7 +36,7 @@ angular.module('copayApp.controllers').controller('tabScanController', function(
return;
}
go.confirm(parsedData);
$state.go('confirm', parsedData);
};
var _parseFromUri = function(uri) {
@ -95,7 +95,7 @@ angular.module('copayApp.controllers').controller('tabScanController', function(
$timeout(function() {
var data = isIOS ? result : result.text;
// Check if the current page is tabs.scan
if (go.is('tabs.scan')) {
if ($state.is('tabs.scan')) {
_dataScanned(data);
return;
}
@ -190,7 +190,7 @@ angular.module('copayApp.controllers').controller('tabScanController', function(
}
// Check if the current page is tabs.scan
_scanStop();
if (go.is('tabs.scan')) {
if ($state.is('tabs.scan')) {
_dataScanned(data);
return;
}

View file

@ -1,6 +1,6 @@
'use strict';
angular.module('copayApp.controllers').controller('walletDetailsController', function($scope, $rootScope, $interval, $timeout, $filter, $log, $ionicModal, $ionicPopover, $state, $stateParams, bwcError, profileService, lodash, configService, gettext, gettextCatalog, platformInfo, go, walletService) {
angular.module('copayApp.controllers').controller('walletDetailsController', function($scope, $rootScope, $interval, $timeout, $filter, $log, $ionicModal, $ionicPopover, $state, $stateParams, bwcError, profileService, lodash, configService, gettext, gettextCatalog, platformInfo, walletService) {
var isCordova = platformInfo.isCordova;
var isWP = platformInfo.isWP;