Wallet/src/js/services/txStatus.js

46 lines
1.2 KiB
JavaScript
Raw Normal View History

2015-03-06 12:00:10 -03:00
'use strict';
angular.module('copayApp.services').factory('txStatus', function($modal, lodash, profileService, $timeout, gettext) {
2015-03-06 12:00:10 -03:00
var root = {};
2015-04-27 02:07:26 -03:00
root.notify = function(txp, cb) {
2015-03-06 12:00:10 -03:00
var fc = profileService.focusedClient;
var msg;
var status = txp.status;
2015-04-27 02:07:26 -03:00
2015-03-06 12:00:10 -03:00
if (status == 'broadcasted') {
msg = gettext('Transaction broadcasted');
2015-04-27 02:07:26 -03:00
} else {
2015-03-06 12:00:10 -03:00
var action = lodash.find(txp.actions, {
copayerId: fc.credentials.copayerId
});
if (!action) {
msg = gettext('Transaction proposal created');
2015-03-06 12:00:10 -03:00
} else if (action.type == 'accept') {
msg = gettext('Transaction proposal signed');
2015-03-06 12:00:10 -03:00
} else if (action.type == 'reject') {
msg = gettext('Transaction was rejected');
2015-03-06 12:00:10 -03:00
}
}
2015-04-27 02:07:26 -03:00
root.openModal(msg, cb);
2015-03-06 12:00:10 -03:00
};
2015-04-27 02:07:26 -03:00
root.openModal = function(statusStr, cb) {
2015-03-06 12:00:10 -03:00
var ModalInstanceCtrl = function($scope, $modalInstance) {
$scope.statusStr = statusStr;
$scope.cancel = function() {
$modalInstance.dismiss('cancel');
};
2015-04-27 02:07:26 -03:00
if (cb) $timeout(cb, 100);
2015-03-06 12:00:10 -03:00
};
$modal.open({
templateUrl: 'views/modals/tx-status.html',
windowClass: 'full popup-tx-status',
2015-03-06 12:00:10 -03:00
controller: ModalInstanceCtrl,
});
};
return root;
});