Skip to content

Commit

Permalink
feat(mass-pay): progress indicator on file loading
Browse files Browse the repository at this point in the history
T323 Added progress indicator to show a user that the file is being processed.
  • Loading branch information
beregovoy68 committed Feb 7, 2017
1 parent 86eec47 commit 05fa686
Show file tree
Hide file tree
Showing 4 changed files with 52 additions and 20 deletions.
9 changes: 9 additions & 0 deletions src/css/style.css
Original file line number Diff line number Diff line change
Expand Up @@ -1546,6 +1546,15 @@ md-autocomplete.fee-autocomplete button:hover md-icon path {
justify-content: center;
}

/* linear progress bar styling */
md-progress-linear .md-container {
background-color: #F0F0F0;
}

md-progress-linear .md-bar {
background-color: #37556E;
}


/* ======================================================================= */

Expand Down
6 changes: 5 additions & 1 deletion src/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -660,8 +660,12 @@ <h2 class="sectionHeader">MASS PAYMENT</h2>
</tbody>
</table>
<br/>
<ng-if ng-if="mass.loadingInProgress">
<md-progress-linear md-mode="indeterminate"></md-progress-linear>
<br/>
</ng-if>
<div class="button-row">
<button class="wButton wButton-neg" ng-click="mass.processInputFile(massPaymentFilesForm)">LOAD</button>
<button class="wButton wButton-neg" ng-disabled="mass.loadingInProgress" ng-click="mass.processInputFile(massPaymentFilesForm)">LOAD</button>
</div>
</form>
<div class="massPayRecap wScroll" ng-switch-when="processing">
Expand Down
45 changes: 27 additions & 18 deletions src/js/portfolio/mass.payment.controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
mass.inputPayments = [];
mass.autocomplete = autocomplete;
mass.stage = LOADING_STAGE;
mass.loadingInProgress = false;
mass.broadcast = new transactionBroadcast.instance(apiService.assets.massPay,
function (transaction, response) {
var displayMessage = 'Sent ' + mass.summary.totalAmount.formatAmount(true) + ' of ' +
Expand Down Expand Up @@ -150,24 +151,7 @@
return $window.JSON.parse(content);
}

function processInputFile(form) {
if (!form.validate(mass.validationOptions)) {
return;
}

if (!mass.inputPayments || mass.inputPayments.length === 0) {
notificationService.error('Payments were not provided or failed to parse. Nothing to load');

return;
}

if (mass.inputPayments.length > MAXIMUM_TRANSACTIONS_PER_FILE) {
notificationService.error('Too many payments for a single file. Maximum payments count ' +
'in a file should not exceed ' + MAXIMUM_TRANSACTIONS_PER_FILE);

return;
}

function loadTransactionsFromFile() {
var sender = {
publicKey: applicationContext.account.keyPair.public,
privateKey: applicationContext.account.keyPair.private
Expand Down Expand Up @@ -230,6 +214,31 @@
throw e;
}
}

mass.loadingInProgress = false;
}

function processInputFile(form) {
if (!form.validate(mass.validationOptions)) {
return;
}

if (!mass.inputPayments || mass.inputPayments.length === 0) {
notificationService.error('Payments were not provided or failed to parse. Nothing to load');

return;
}

if (mass.inputPayments.length > MAXIMUM_TRANSACTIONS_PER_FILE) {
notificationService.error('Too many payments for a single file. Maximum payments count ' +
'in a file should not exceed ' + MAXIMUM_TRANSACTIONS_PER_FILE);

return;
}

mass.loadingInProgress = true;
// loading transactions asynchronously
$timeout(loadTransactionsFromFile, 150);
}

function submitPayment() {
Expand Down
12 changes: 11 additions & 1 deletion src/js/portfolio/mass.payment.controller.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -190,6 +190,7 @@ describe('Mass.Payment.Controller', function() {
spyOn(controller.broadcast, 'setTransaction');

controller.processInputFile(formMock);
timeout.flush();

expect(controller.broadcast.setTransaction).not.toHaveBeenCalled();
expect(controller.invalidPayment).toBe(true);
Expand All @@ -214,6 +215,7 @@ describe('Mass.Payment.Controller', function() {
spyOn(controller.broadcast, 'setTransaction');

controller.processInputFile(formMock);
timeout.flush();

expect(controller.broadcast.setTransaction).not.toHaveBeenCalled();
expect(controller.invalidPayment).toBe(true);
Expand All @@ -238,6 +240,7 @@ describe('Mass.Payment.Controller', function() {
spyOn(controller.broadcast, 'setTransaction');

controller.processInputFile(formMock);
timeout.flush();

expect(controller.broadcast.setTransaction).toHaveBeenCalled();
expect(controller.invalidPayment).toBeFalsy();
Expand Down Expand Up @@ -266,6 +269,8 @@ describe('Mass.Payment.Controller', function() {
];

controller.processInputFile(formMock);
timeout.flush();

expect(controller.submitPayment()).toBe(false);
expect(controller.sendingWaves).toBeFalsy();
expect(notificationService.error).toHaveBeenCalled();
Expand All @@ -291,6 +296,8 @@ describe('Mass.Payment.Controller', function() {
];

controller.processInputFile(formMock);
timeout.flush();

expect(controller.submitPayment()).toBe(false);

expect(controller.sendingWaves).toBe(true);
Expand All @@ -316,6 +323,8 @@ describe('Mass.Payment.Controller', function() {
];

controller.processInputFile(formMock);
timeout.flush();

expect(controller.submitPayment()).toBe(false);

expect(controller.sendingWaves).toBe(false);
Expand All @@ -342,8 +351,9 @@ describe('Mass.Payment.Controller', function() {
];

controller.processInputFile(formMock);
expect(controller.submitPayment()).toBe(true);
timeout.flush();

expect(controller.submitPayment()).toBe(true);
timeout.flush();

expect(controller.confirm.amount.value).toEqual('999');
Expand Down

0 comments on commit 05fa686

Please sign in to comment.