Skip to content
This repository has been archived by the owner on Feb 1, 2019. It is now read-only.

Commit

Permalink
Merge pull request #335 from poorgeek/progress-bar
Browse files Browse the repository at this point in the history
Progress bar
  • Loading branch information
LinuxBozo committed Apr 10, 2015
2 parents 1d856a1 + 5135aec commit 18a9a1a
Show file tree
Hide file tree
Showing 22 changed files with 255 additions and 406 deletions.
6 changes: 6 additions & 0 deletions app/partials/progressBar.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<div class="progress-bar">
<div role="progressbar" aria-valuemin="0" aria-valuemax="100" aria-valuenow="{{percentageComplete}}" aria-valuetext="Complete" class="meter">
<span style="width:{{percentageComplete}}%"></span>
</div>
<p class="description">{{processStep}}</p>
</div>
1 change: 1 addition & 0 deletions app/scripts/controllers/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,4 @@ app.controller('ErrorDetailCtrl', require('./errorDetail'));
app.controller('SpecialErrorDetailCtrl', require('./specialErrorDetail'));
app.controller('IRSReportCtrl', require('./irsReport'));
app.controller('PaginationCtrl', require('./pagination'));
app.controller('ProgressBarCtrl', require('./progressBar'));
19 changes: 19 additions & 0 deletions app/scripts/controllers/progressBar.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
'use strict';

/**
* @ngdoc function
* @name hmdaPilotApp.controller:ProgressBarCtrl
* @description
* # ProgressBarCtrl
* Controller of the hmdaPilotApp
*/
module.exports = /*@ngInject*/ function ($scope, HMDAEngine) {

$scope.percentageComplete = 0;

HMDAEngine.getProgress().events.on('progressStep', function(percent) {
$scope.$apply(function(){
$scope.percentageComplete = percent;
});
});
};
32 changes: 20 additions & 12 deletions app/scripts/controllers/selectFile.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,19 +7,20 @@
* # Select File
* Controller for selecting a HMDA file and Reporting Year for verification.
*/
module.exports = /*@ngInject*/ function ($scope, $location, $q, $timeout, FileReader, FileMetadata, HMDAEngine, Wizard, Session) {
var fiscalYears = HMDAEngine.getValidYears();
module.exports = /*@ngInject*/ function ($scope, $location, $q, $timeout, FileReader, FileMetadata, HMDAEngine, Wizard, Session, ngDialog, Configuration) {
var progressDialog,
fiscalYears = HMDAEngine.getValidYears();

// Set/Reset the state of different objects on load
Session.reset();
HMDAEngine.clearHmdaJson();
HMDAEngine.clearErrors();
HMDAEngine.clearProgress();
$scope.metadata = FileMetadata.clear();
$scope.wizardSteps = Wizard.initSteps();

// Populate the $scope
$scope.reportingYears = fiscalYears;
$scope.isProcessing = false;

// Initialize the errors for the form fields
$scope.errors = {};
Expand All @@ -45,14 +46,18 @@ module.exports = /*@ngInject*/ function ($scope, $location, $q, $timeout, FileRe
$scope.submit = function(hmdaData) {
// Clear out any existing errors
$scope.errors.global = null;
// Toggle processing flag on so that we can notify the user
$scope.isProcessing = true;

$timeout(function() { $scope.process(hmdaData); }, 100); // Pause before starting the conversion so that the DOM can update
// Give a name to the current step in the process (shown in the progressDialog)
$scope.processStep = 'Processing HMDA file...';

progressDialog = ngDialog.open(angular.extend(Configuration.progressDialog, {scope: $scope}));

$timeout(function() { $scope.process(hmdaData); }, 100); // Pause before starting the conversion so that the DOM can update
};

$scope.process = function(hmdaData) {

// Enable LocalDB support?
HMDAEngine.setUseLocalDB(hmdaData.local);

/* istanbul ignore if debug */
Expand All @@ -63,8 +68,8 @@ module.exports = /*@ngInject*/ function ($scope, $location, $q, $timeout, FileRe
// Convert the file to JSON
HMDAEngine.fileToJson(hmdaData.file, hmdaData.year, function(fileErr) {
if (fileErr) {
// Toggle processing flag off
$scope.isProcessing = false;
// Close the progress dialog
progressDialog.close();

$scope.errors.global = fileErr;
$scope.$apply();
Expand All @@ -77,6 +82,9 @@ module.exports = /*@ngInject*/ function ($scope, $location, $q, $timeout, FileRe
console.time('total time for syntactical and validity edits');
}

// Give a name to the current step in the process (shown in the progressDialog)
$scope.processStep = 'Validating Syntactical and Validity edits...';

$q.all([HMDAEngine.runSyntactical(hmdaData.year), HMDAEngine.runValidity(hmdaData.year)])
.then(function() {

Expand All @@ -94,12 +102,12 @@ module.exports = /*@ngInject*/ function ($scope, $location, $q, $timeout, FileRe
// And go the summary page
$location.path('/summarySyntacticalValidity');

// Toggle processing flag off
$scope.isProcessing = false;
// Close the progress dialog
progressDialog.close();
})
.catch(function(err) {
// Toggle processing flag off
$scope.isProcessing = false;
// Close the progress dialog
progressDialog.close();

$scope.errors.global = err.message;
return;
Expand Down
4 changes: 1 addition & 3 deletions app/scripts/controllers/summaryMSA-IRS.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,8 @@ module.exports = /*@ngInject*/ function ($scope, $location, Wizard, HMDAEngine,
}

// Get the list of errors from the HMDAEngine
var editErrors = HMDAEngine.getErrors();

$scope.data = {
specialErrors: editErrors.special
specialErrors: HMDAEngine.getErrors().special
};

$scope.showIRSReport = function() {
Expand Down
28 changes: 16 additions & 12 deletions app/scripts/controllers/summaryQualityMacro.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,10 @@
* # SummaryQualityMacroCtrl
* Controller for the Syntactical and Validity Summary view
*/
module.exports = /*@ngInject*/ function ($scope, $location, $q, $timeout, HMDAEngine, Wizard, Session) { /*jshint ignore:line*/
module.exports = /*@ngInject*/ function ($scope, $location, $q, $timeout, HMDAEngine, Wizard, Session, ngDialog, Configuration) { /*jshint ignore:line*/

// Set/Reset the state of different objects on load
HMDAEngine.clearProgress();

Array.prototype.diff = function(a) {
return this.filter(function(i) { return a.indexOf(i) < 0; });
Expand Down Expand Up @@ -39,14 +42,13 @@ module.exports = /*@ngInject*/ function ($scope, $location, $q, $timeout, HMDAEn

// Populate the $scope
$scope.errors = {};
$scope.isProcessing = false;

// Get the list of errors from the HMDAEngine
var editErrors = HMDAEngine.getErrors();
var progressDialog;

$scope.data = {
qualityErrors: editErrors.quality,
macroErrors: editErrors.macro
qualityErrors: HMDAEngine.getErrors().quality,
macroErrors: HMDAEngine.getErrors().macro
};

$scope.previous = function () {
Expand All @@ -58,11 +60,13 @@ module.exports = /*@ngInject*/ function ($scope, $location, $q, $timeout, HMDAEn
};

$scope.next = function() {
if (hasErrors(editErrors.special)) {
if (hasErrors(HMDAEngine.getErrors().special)) {
$location.path('/summaryMSA-IRS');
} else {
// Toggle processing flag on so that we can notify the user
$scope.isProcessing = true;
// Give a name to the current step in the process (shown in the progressDialog)
$scope.processStep = 'Processing MSA/MD Data...';

progressDialog = ngDialog.open(angular.extend(Configuration.progressDialog, {scope: $scope}));

// Pause before starting the validation so that the DOM can update
$timeout(function() { $scope.process(); }, 100);
Expand Down Expand Up @@ -91,11 +95,11 @@ module.exports = /*@ngInject*/ function ($scope, $location, $q, $timeout, HMDAEn
// And go the next summary page
$location.path('/summaryMSA-IRS');

// Toggle processing flag off
$scope.isProcessing = false;
// Close the progress dialog
progressDialog.close();
}).catch(function(err) {
// Toggle processing flag off
$scope.isProcessing = false;
// Close the progress dialog
progressDialog.close();

$scope.errors.global = err.message;
return;
Expand Down
31 changes: 17 additions & 14 deletions app/scripts/controllers/summarySyntacticalValidity.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,16 @@
*/
module.exports = /*@ngInject*/ function ($scope, $location, $q, $timeout, HMDAEngine, Wizard, ngDialog, Configuration) {

// Populate the $scope
$scope.errors = {};
$scope.isProcessing = false;
// Set/Reset the state of different objects on load
HMDAEngine.clearProgress();

// Get the list of errors from the HMDAEngine
var editErrors = HMDAEngine.getErrors();
var progressDialog;

$scope.syntacticalErrors = editErrors.syntactical || {};
$scope.validityErrors = editErrors.validity || {};
// Populate the $scope
$scope.errors = {};
$scope.syntacticalErrors = HMDAEngine.getErrors().syntactical;
$scope.validityErrors = HMDAEngine.getErrors().validity;

$scope.previous = function() {
if (Configuration.confirmSessionReset) {
Expand All @@ -34,19 +35,21 @@ module.exports = /*@ngInject*/ function ($scope, $location, $q, $timeout, HMDAEn
};

$scope.hasNext = function() {
return angular.equals({}, $scope.syntacticalErrors) && angular.equals({}, $scope.validityErrors);
return angular.equals({}, HMDAEngine.getErrors().syntactical) && angular.equals({}, HMDAEngine.getErrors().validity);
};

function hasErrors(obj) {
return Object.keys(obj).length > 0;
}

$scope.next = function() {
if (hasErrors(editErrors.quality) || hasErrors(editErrors.macro)) {
if (hasErrors(HMDAEngine.getErrors().quality) || hasErrors(HMDAEngine.getErrors().macro)) {
$location.path('/summaryQualityMacro');
} else{
// Toggle processing flag on so that we can notify the user
$scope.isProcessing = true;
// Give a name to the current step in the process (shown in the progressDialog)
$scope.processStep = 'Processing Quality and Macro edits...';

progressDialog = ngDialog.open(angular.extend(Configuration.progressDialog, {scope: $scope}));

// Pause before starting the validation so that the DOM can update
$timeout(function() { $scope.process(); }, 100);
Expand Down Expand Up @@ -76,12 +79,12 @@ module.exports = /*@ngInject*/ function ($scope, $location, $q, $timeout, HMDAEn
// And go the next summary page
$location.path('/summaryQualityMacro');

// Toggle processing flag off
$scope.isProcessing = false;
// Close the progress dialog
progressDialog.close();
})
.catch(function(err) {
// Toggle processing flag off
$scope.isProcessing = false;
// Close the progress dialog
progressDialog.close();

$scope.errors.global = err.message;
return;
Expand Down
124 changes: 0 additions & 124 deletions app/scripts/directives/cfButton.js

This file was deleted.

1 change: 0 additions & 1 deletion app/scripts/directives/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ app.directive('errorSummary', require('./errorSummary'));
app.directive('errorDetail', require('./errorDetail'));
app.directive('fileMetadata', require('./fileMetadata'));
app.directive('wizardNav', require('./wizardNav'));
app.directive('cfButton', require('./cfButton'));
app.directive('disclaimer', require('./disclaimer'));
app.directive('paginationSize', require('./paginationSize'));
app.directive('paginationNav', require('./paginationNav'));
Expand Down
Loading

0 comments on commit 18a9a1a

Please sign in to comment.