Wallet/src/js/services/onGoingProcess.js

86 lines
2.9 KiB
JavaScript
Raw Normal View History

2016-06-13 15:25:40 -03:00
'use strict';
2016-06-15 10:30:15 -03:00
angular.module('copayApp.services').factory('ongoingProcess', function($log, $timeout, $filter, lodash, $ionicLoading, gettext, platformInfo) {
2016-06-13 15:25:40 -03:00
var root = {};
var isCordova = platformInfo.isCordova;
var ongoingProcess = {};
var processNames = {
2016-06-15 10:30:15 -03:00
'scanning': gettext('Scanning Wallet funds...'),
'recreating': gettext('Recreating Wallet...'),
'generatingCSV': gettext('Generating .csv file...'),
'creatingTx': gettext('Creating transaction'),
'sendingTx': gettext('Sending transaction'),
'signingTx': gettext('Signing transaction'),
'broadcastingTx': gettext('Broadcasting transaction'),
2016-08-05 10:46:27 -03:00
'rejectTx': gettext('Rejecting payment proposal'),
'removeTx': gettext('Deleting payment proposal'),
2016-06-15 10:30:15 -03:00
'fetchingPayPro': gettext('Fetching Payment Information'),
'calculatingFee': gettext('Calculating fee'),
'joiningWallet': gettext('Joining Wallet...'),
'retrivingInputs': gettext('Retrieving inputs information'),
'creatingWallet': gettext('Creating Wallet...'),
'validatingWallet': gettext('Validating wallet integrity...'),
'connectingledger': gettext('Waiting for Ledger...'),
'connectingtrezor': gettext('Waiting for Trezor...'),
'validatingWords': gettext('Validating recovery phrase...'),
'connectingCoinbase': gettext('Connecting to Coinbase...'),
'connectingGlidera': gettext('Connecting to Glidera...'),
'importingWallet': gettext('Importing Wallet...'),
'sweepingWallet': gettext('Sweeping Wallet...'),
'deletingWallet': gettext('Deleting Wallet...'),
2016-06-29 17:04:40 -03:00
'extractingWalletInfo': gettext('Extracting Wallet Information...'),
'gettingFeeLevels': gettext('Getting fee levels...'),
2016-06-13 15:25:40 -03:00
};
root.clear = function() {
ongoingProcess = {};
if (isCordova) {
window.plugins.spinnerDialog.hide();
} else {
$ionicLoading.hide();
}
2016-06-13 15:25:40 -03:00
};
root.get = function(processName) {
return ongoingProcess[processName];
};
2016-06-13 15:25:40 -03:00
root.set = function(processName, isOn) {
$log.debug('ongoingProcess', processName, isOn);
root[processName] = isOn;
ongoingProcess[processName] = isOn;
var name;
root.any = lodash.any(ongoingProcess, function(isOn, processName) {
if (isOn)
name = name || processName;
return isOn;
});
// The first one
root.onGoingProcessName = name;
2016-06-15 10:30:15 -03:00
var showName = $filter('translate')(processNames[name] || name);
2016-06-13 17:10:03 -03:00
2016-06-13 15:25:40 -03:00
if (root.onGoingProcessName) {
if (isCordova) {
window.plugins.spinnerDialog.show(null, showName, true);
} else {
2016-08-24 11:33:43 -03:00
var tmpl = '<div class="item-icon-left">' + showName + '<ion-spinner class="spinner-stable" icon="lines"></ion-spinner></div>';
2016-06-13 15:25:40 -03:00
$ionicLoading.show({
2016-06-15 10:30:15 -03:00
template: tmpl
2016-06-13 15:25:40 -03:00
});
}
} else {
if (isCordova) {
window.plugins.spinnerDialog.hide();
} else {
$ionicLoading.hide();
}
}
};
return root;
});