wallet details refactor
This commit is contained in:
parent
e3076d18ab
commit
8aefbe25b3
9 changed files with 703 additions and 706 deletions
|
|
@ -11,7 +11,7 @@ angular.module('copayApp.controllers').controller('preferencesController',
|
|||
$scope.externalSource = null;
|
||||
|
||||
if (wallet) {
|
||||
walletService.updateStatus(wallet, {}, function(err, status) {});
|
||||
walletService.getStatus(wallet, {}, function(err, status) {});
|
||||
var config = configService.getSync();
|
||||
config.aliasFor = config.aliasFor || {};
|
||||
$scope.alias = config.aliasFor[walletId] || wallet.credentials.walletName;
|
||||
|
|
|
|||
|
|
@ -7,22 +7,19 @@ angular.module('copayApp.controllers').controller('preferencesUnitController', f
|
|||
$scope.currentUnit = config.wallet.settings.unitCode;
|
||||
}
|
||||
|
||||
$scope.unitList = [
|
||||
{
|
||||
name: 'bits (1,000,000 bits = 1BTC)',
|
||||
shortName: 'bits',
|
||||
value: 100,
|
||||
decimals: 2,
|
||||
code: 'bit',
|
||||
},
|
||||
{
|
||||
name: 'BTC',
|
||||
shortName: 'BTC',
|
||||
value: 100000000,
|
||||
decimals: 8,
|
||||
code: 'btc',
|
||||
}
|
||||
];
|
||||
$scope.unitList = [{
|
||||
name: 'bits (1,000,000 bits = 1BTC)',
|
||||
shortName: 'bits',
|
||||
value: 100,
|
||||
decimals: 2,
|
||||
code: 'bit',
|
||||
}, {
|
||||
name: 'BTC',
|
||||
shortName: 'BTC',
|
||||
value: 100000000,
|
||||
decimals: 8,
|
||||
code: 'btc',
|
||||
}];
|
||||
|
||||
$scope.save = function(newUnit) {
|
||||
var opts = {
|
||||
|
|
|
|||
|
|
@ -88,11 +88,9 @@ angular.module('copayApp.controllers').controller('tabHomeController',
|
|||
|
||||
self.updateAllClients = function() {
|
||||
var txps = [];
|
||||
var wallets = profileService.getWallets();
|
||||
var l = wallets.length,
|
||||
i = 0;
|
||||
var i = $scope.wallets.length;
|
||||
|
||||
lodash.each(wallets, function(wallet) {
|
||||
lodash.each($scope.wallets, function(wallet) {
|
||||
walletService.getStatus(wallet, {}, function(err, status) {
|
||||
if (err) {
|
||||
console.log('[tab-home.js.35:err:]', $log.error(err)); //TODO
|
||||
|
|
@ -101,9 +99,10 @@ angular.module('copayApp.controllers').controller('tabHomeController',
|
|||
if (status.pendingTxps && status.pendingTxps[0]) {
|
||||
txps = txps.concat(status.pendingTxps);
|
||||
}
|
||||
if (++i == l) {
|
||||
if (--i == 0) {
|
||||
setPendingTxps(txps);
|
||||
}
|
||||
wallet.status = status;
|
||||
});
|
||||
});
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,36 +1,16 @@
|
|||
'use strict';
|
||||
|
||||
angular.module('copayApp.controllers').controller('walletDetailsController', function($scope, $rootScope, $interval, $timeout, $filter, $log, $ionicModal, $ionicPopover, $state, $stateParams, 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, go, walletService) {
|
||||
|
||||
var isCordova = platformInfo.isCordova;
|
||||
var isWP = platformInfo.isWP;
|
||||
var isAndroid = platformInfo.isAndroid;
|
||||
var isChromeApp = platformInfo.isChromeApp;
|
||||
|
||||
var self = this;
|
||||
$rootScope.shouldHideMenuBar = false;
|
||||
$rootScope.wpInputFocused = false;
|
||||
var config = configService.getSync();
|
||||
var configWallet = config.wallet;
|
||||
var walletSettings = configWallet.settings;
|
||||
var ret = {};
|
||||
var errorPopup;
|
||||
|
||||
var HISTORY_SHOW_LIMIT = 10;
|
||||
|
||||
// INIT. Global value
|
||||
ret.unitToSatoshi = walletSettings.unitToSatoshi;
|
||||
ret.satToUnit = 1 / ret.unitToSatoshi;
|
||||
ret.unitName = walletSettings.unitName;
|
||||
ret.alternativeIsoCode = walletSettings.alternativeIsoCode;
|
||||
ret.alternativeName = walletSettings.alternativeName;
|
||||
ret.alternativeAmount = 0;
|
||||
ret.unitDecimals = walletSettings.unitDecimals;
|
||||
ret.isCordova = isCordova;
|
||||
ret.addresses = [];
|
||||
ret.isMobile = platformInfo.isMobile;
|
||||
ret.isWindowsPhoneApp = platformInfo.isWP;
|
||||
ret.countDown = null;
|
||||
ret.sendMaxInfo = {};
|
||||
ret.showAlternative = false;
|
||||
|
||||
$scope.openSearchModal = function() {
|
||||
var fc = profileService.focusedClient;
|
||||
|
|
@ -61,48 +41,100 @@ angular.module('copayApp.controllers').controller('walletDetailsController', fun
|
|||
});
|
||||
};
|
||||
|
||||
$scope.updateAll = function() {
|
||||
$scope.update();
|
||||
}
|
||||
$scope.recreate = function() {
|
||||
walletService.recreate();
|
||||
};
|
||||
|
||||
$scope.update = function() {
|
||||
$scope.updating = true;
|
||||
$scope.updateStatus = function(force) {
|
||||
$scope.updatingStatus = true;
|
||||
$scope.updateStatusError = false;
|
||||
$timeout(function() {
|
||||
walletService.getStatus(wallet, {
|
||||
force: true
|
||||
force: !!force,
|
||||
}, function(err, status) {
|
||||
if (err) {} // TODO
|
||||
$scope.updatingStatus = false;
|
||||
if (err) {
|
||||
$scope.status = null;
|
||||
$scope.updateStatusError = true;
|
||||
return;
|
||||
}
|
||||
$scope.status = status;
|
||||
$scope.updating = false;
|
||||
});
|
||||
})
|
||||
};
|
||||
|
||||
$scope.updateTxHistory = function() {
|
||||
|
||||
if ($scope.updatingTxHistory) return;
|
||||
|
||||
$scope.updatingTxHistory = true;
|
||||
$scope.updateTxHistoryError = false;
|
||||
$scope.updatingTxHistoryProgress = null;
|
||||
|
||||
var progressFn = function(txs) {
|
||||
$scope.updatingTxHistoryProgress = txs ? txs.length : 0;
|
||||
completeTxHistory = txs;
|
||||
$scope.showHistory();
|
||||
$scope.$digest();
|
||||
};
|
||||
|
||||
$timeout(function() {
|
||||
walletService.getTxHistory(wallet, {
|
||||
progressFn: progressFn,
|
||||
}, function(err, txHistory) {
|
||||
$scope.updatingTxHistory = false;
|
||||
if (err) {
|
||||
$scope.txHistory = null;
|
||||
$scope.updateTxHistoryError = true;
|
||||
return;
|
||||
}
|
||||
completeTxHistory = txHistory;
|
||||
|
||||
$scope.showHistory();
|
||||
$scope.$apply();
|
||||
});
|
||||
});
|
||||
};
|
||||
|
||||
$scope.showHistory = function() {
|
||||
if ($scope.isSearching) {
|
||||
$scope.txHistorySearchResults = filteredTxHistory ? filteredTxHistory.slice(0, (currentTxHistoryPage + 1) * HISTORY_SHOW_LIMIT) : [];
|
||||
$scope.txHistoryShowMore = filteredTxHistory.length > $scope.txHistorySearchResults.length;
|
||||
} else {
|
||||
$scope.txHistory = completeTxHistory ? completeTxHistory.slice(0, (currentTxHistoryPage + 1) * HISTORY_SHOW_LIMIT) : [];
|
||||
$scope.txHistoryShowMore = completeTxHistory.length > $scope.txHistory.length;
|
||||
}
|
||||
};
|
||||
|
||||
$scope.showMore = function() {
|
||||
currentTxHistoryPage++;
|
||||
$scope.showHistory();
|
||||
$scope.$broadcast('scroll.infiniteScrollComplete');
|
||||
};
|
||||
|
||||
$scope.updateAll = function() {
|
||||
$scope.updateStatus(false);
|
||||
$scope.updateTxHistory();
|
||||
}
|
||||
|
||||
$scope.hideToggle = function() {
|
||||
console.log('[walletDetails.js.70:hideToogle:] TODO'); //TODO
|
||||
};
|
||||
|
||||
if (!$stateParams.walletId) {
|
||||
$log.debug('No wallet provided... using the first one');
|
||||
$stateParams.walletId = profileService.getWallets({
|
||||
onlyComplete: true
|
||||
})[0].id;
|
||||
}
|
||||
var currentTxHistoryPage;
|
||||
var completeTxHistory;
|
||||
var wallet;
|
||||
|
||||
$scope.init = function() {
|
||||
currentTxHistoryPage = 0;
|
||||
completeTxHistory = [];
|
||||
|
||||
var wallet = profileService.getWallet($stateParams.walletId);
|
||||
$scope.wallet = wallet;
|
||||
wallet = profileService.getWallet($stateParams.walletId);
|
||||
$scope.wallet = wallet;
|
||||
$scope.requiresMultipleSignatures = wallet.credentials.m > 1;
|
||||
$scope.newTx = false;
|
||||
|
||||
$scope.updateAll();
|
||||
};
|
||||
|
||||
if (wallet) {
|
||||
walletService.getStatus(wallet, {}, function(err, status) {
|
||||
console.log('*** [walletDetails.js ln89] status:', status); // TODO
|
||||
if (err) {} // TODO
|
||||
$scope.status = status;
|
||||
});
|
||||
walletService.getHistory(wallet, {}, function(err, txHistory) {
|
||||
console.log('*** [walletDetails.js ln93] txHistory:', txHistory); // TODO
|
||||
if (err) {} // TODO
|
||||
$scope.txHistory = txHistory;
|
||||
});
|
||||
}
|
||||
});
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue