Skip to content
This repository was archived by the owner on Mar 4, 2025. It is now read-only.

SUP-1159, Progress bar to show %complete on upload #649

Merged
merged 1 commit into from
Jan 11, 2016
Merged
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
17 changes: 10 additions & 7 deletions app/submissions/submit-file/submit-file.controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,11 @@

angular.module('tc.submissions').controller('SubmitFileController', SubmitFileController);

SubmitFileController.$inject = ['$scope', '$stateParams', 'UserService', 'SubmissionsService', 'challengeToSubmitTo'];
SubmitFileController.$inject = ['$scope', '$stateParams', '$log', 'UserService', 'SubmissionsService', 'challengeToSubmitTo'];

function SubmitFileController($scope, $stateParams, UserService, SubmissionsService, challengeToSubmitTo) {
function SubmitFileController($scope, $stateParams, $log, UserService, SubmissionsService, challengeToSubmitTo) {
var vm = this;
$log = $log.getInstance("SubmitFileController");
var files = {};
var fileUploadProgress = {};
vm.urlRegEx = new RegExp(/^(http(s?):\/\/)?(www\.)?[a-zA-Z0-9\.\-\_]+(\.[a-zA-Z]{2,3})+(\/[a-zA-Z0-9\_\-\s\.\/\?\%\#\&\=]*)?$/);
Expand Down Expand Up @@ -141,6 +142,8 @@
vm.fileUploadProgress = {};
vm.showProgress = true;
vm.preparing = true;
vm.uploading = false;
vm.finishing = false;
vm.submissionsBody.data.submitterComments = vm.comments;
vm.submissionsBody.data.submitterRank = vm.submissionForm.submitterRank;

Expand Down Expand Up @@ -173,7 +176,7 @@
});
}

console.log('Body for request: ', vm.submissionsBody);
$log.debug('Body for request: ', vm.submissionsBody);
SubmissionsService.getPresignedURL(vm.submissionsBody, files, updateProgress);
}

Expand All @@ -188,7 +191,7 @@
if (args === 100) {
vm.preparing = false;
vm.uploading = true;
console.log('Prapared');
$log.debug('Prepared for upload.');
}
} else if (phase === 'UPLOAD') {
// if args is object, this update is about XHRRequest's upload progress
Expand All @@ -212,21 +215,21 @@
}
// start next phase when UPLOAD is done
if (vm.uploadProgress == 100) {
console.log('Uploaded');
$log.debug('Uploaded files.');
vm.uploading = false;
vm.finishing = true;
}
} else if (phase === 'FINISH') {
// we are concerned only for completion of the phase
if (args === 100) {
console.log('Finished');
$log.debug('Finished upload.');
vm.finishing = false;
vm.showProgress = false;

// TODO redirect to submission listing / challenge details page
}
} else { // assume it to be error condition
console.log("Else: " + phase);
$log.debug("Error Condition: " + phase);
vm.errorInUpload = true;
}
}
Expand Down