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

Json processing progress #348

Merged
merged 4 commits into from
Apr 15, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 0 additions & 8 deletions app/scripts/app.js
Original file line number Diff line number Diff line change
@@ -1,14 +1,10 @@
'use strict';

require('angular');
require('angular-animate');
require('angular-aria');
require('angular-cookies');
require('angular-resource');
require('angular-route');
require('angular-sanitize');
require('angular-touch');
require('angular-fileupload');
require('./modules/config');
require('./modules/HMDAEngine');
require('./modules/hmdaFilters');
Expand All @@ -24,16 +20,12 @@ require('ng-dialog');
*/
angular
.module('hmdaPilotApp', [
'ngAnimate',
'ngAria',
'ngCookies',
'ngResource',
'ngRoute',
'ngSanitize',
'ngTouch',
'ngDialog',
'services.config',
'filereader',
'HMDAEngine',
'hmdaFilters'
])
Expand Down
10 changes: 7 additions & 3 deletions app/scripts/controllers/progressBar.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,13 @@ module.exports = /*@ngInject*/ function ($scope, HMDAEngine) {

$scope.percentageComplete = 0;

HMDAEngine.getProgress().events.on('progressStep', function(percent) {
$scope.$apply(function(){
function applyProgress(percent) {
$scope.$apply(function($scope){
$scope.percentageComplete = percent;
});
});
}

HMDAEngine.getProgress().events.on('progressStep', applyProgress);
HMDAEngine.getFileProgress().events.on('progressStep', applyProgress);

};
12 changes: 6 additions & 6 deletions app/scripts/controllers/selectFile.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
'use strict';
var ReadableBlobStream = require('readable-blob-stream');

/**
* @ngdoc function
Expand All @@ -7,7 +8,7 @@
* # 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, ngDialog, Configuration) {
module.exports = /*@ngInject*/ function ($scope, $location, $q, $timeout, FileMetadata, HMDAEngine, Wizard, Session, ngDialog, Configuration) {
var progressDialog,
fiscalYears = HMDAEngine.getValidYears();

Expand All @@ -33,10 +34,8 @@ module.exports = /*@ngInject*/ function ($scope, $location, $q, $timeout, FileRe
};

$scope.getFile = function() {
// Read the contents of the file and set a value in the scope when its complete
FileReader.readAsText($scope.file, 'utf-8', $scope).then(function(result) {
$scope.hmdaData.file = result;
});
// Assign selected file as a readable stream
$scope.hmdaData.file = new ReadableBlobStream($scope.file);

// Set the filename so that we can use it when displaying the metadata
FileMetadata.setFilename($scope.file.name);
Expand Down Expand Up @@ -70,7 +69,6 @@ module.exports = /*@ngInject*/ function ($scope, $location, $q, $timeout, FileRe
if (fileErr) {
// Close the progress dialog
progressDialog.close();

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

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

Expand Down
2 changes: 1 addition & 1 deletion app/views/summaryQualityMacro.html
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<div class="content-l_col content-l_col-2-3">
<h2>Quality Edit Report</h2>
</div>
<div class="toolbar content-l_col content-l_col-1-2">
<div class="toolbar content-l_col content-l_col-1-3">
<button class="btn btn__link" hmda-export export="all" type="quality" ng-if="data.qualityErrors"><span class="cf-icon cf-icon-pdf"></span> Export</button>
</div>
</div>
Expand Down
7 changes: 2 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,17 +15,14 @@
},
"dependencies": {
"angular": "1.3.15",
"angular-animate": "1.3.15",
"angular-aria": "1.3.15",
"angular-cookies": "1.3.15",
"angular-filereader": "matteosuppo/angular-filereader#v1.0.2",
"angular-resource": "1.3.15",
"angular-route": "1.3.15",
"angular-sanitize": "1.3.15",
"angular-touch": "1.3.15",
"hmda-rule-engine": "cfpb/hmda-rule-engine#milestone10",
"ng-dialog": "^0.3.12",
"normalize-css": "^2.3.1"
"normalize-css": "^2.3.1",
"readable-blob-stream": "0.0.0"
},
"napa": {
"cf-buttons": "cfpb/cf-buttons#1.4.0",
Expand Down
3 changes: 3 additions & 0 deletions test/spec/controllers/progressBar.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@ describe('Controller: ProgressBarCtrl', function () {
mockEngine = {
getProgress: function() {
return { events: { on: function() {} } };
},
getFileProgress: function() {
return { events: { on: function() {} } };
}
};

Expand Down
10 changes: 3 additions & 7 deletions test/spec/controllers/selectFile.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ describe('Controller: SelectFileCtrl', function () {
Q,
Wizard,
FileMetadata,
FileReader,
HMDAEngine,
mockEngine = {
getValidYears: function() { return ['2013', '2014']; },
Expand Down Expand Up @@ -41,15 +40,14 @@ describe('Controller: SelectFileCtrl', function () {
$templateCache.put(templateId, directiveTemplate);
}));

beforeEach(inject(function ($rootScope, $location, $controller, $q, $timeout, _Wizard_, _FileMetadata_, _FileReader_, _Configuration_, _ngDialog_) {
beforeEach(inject(function ($rootScope, $location, $controller, $q, $timeout, _Wizard_, _FileMetadata_, _Configuration_, _ngDialog_) {
scope = $rootScope.$new();
controller = $controller;
location = $location;
Q = $q;
timeout = $timeout;
Wizard = _Wizard_;
FileMetadata = _FileMetadata_;
FileReader = _FileReader_;
HMDAEngine = mockEngine;

controller('SelectFileCtrl', {
Expand All @@ -59,7 +57,6 @@ describe('Controller: SelectFileCtrl', function () {
$timeout: timeout,
Wizard: _Wizard_,
FileMetadata: _FileMetadata_,
FileReader: _FileReader_,
HMDAEngine: mockEngine,
ngDialog: _ngDialog_,
Configuration: _Configuration_
Expand All @@ -83,9 +80,8 @@ describe('Controller: SelectFileCtrl', function () {

describe('getFile()', function() {
beforeEach(function() {
scope.file = {
name: 'test.dat'
};
scope.file = [];
scope.file.name = 'test.dat';
scope.getFile();
scope.$digest();
});
Expand Down