|
3 | 3 |
|
4 | 4 | angular.module('tc.submissions').controller('SubmitFileController', SubmitFileController);
|
5 | 5 |
|
6 |
| - SubmitFileController.$inject = ['$scope', '$stateParams', 'UserService', 'SubmissionsService', 'challengeToSubmitTo']; |
| 6 | + SubmitFileController.$inject = ['$scope', '$stateParams', '$log', 'UserService', 'SubmissionsService', 'challengeToSubmitTo']; |
7 | 7 |
|
8 |
| - function SubmitFileController($scope, $stateParams, UserService, SubmissionsService, challengeToSubmitTo) { |
| 8 | + function SubmitFileController($scope, $stateParams, $log, UserService, SubmissionsService, challengeToSubmitTo) { |
9 | 9 | var vm = this;
|
| 10 | + $log = $log.getInstance("SubmitFileController"); |
10 | 11 | var files = {};
|
11 | 12 | var fileUploadProgress = {};
|
12 | 13 | vm.urlRegEx = new RegExp(/^(http(s?):\/\/)?(www\.)?[a-zA-Z0-9\.\-\_]+(\.[a-zA-Z]{2,3})+(\/[a-zA-Z0-9\_\-\s\.\/\?\%\#\&\=]*)?$/);
|
|
141 | 142 | vm.fileUploadProgress = {};
|
142 | 143 | vm.showProgress = true;
|
143 | 144 | vm.preparing = true;
|
| 145 | + vm.uploading = false; |
| 146 | + vm.finishing = false; |
144 | 147 | vm.submissionsBody.data.submitterComments = vm.comments;
|
145 | 148 | vm.submissionsBody.data.submitterRank = vm.submissionForm.submitterRank;
|
146 | 149 |
|
|
173 | 176 | });
|
174 | 177 | }
|
175 | 178 |
|
176 |
| - console.log('Body for request: ', vm.submissionsBody); |
| 179 | + $log.debug('Body for request: ', vm.submissionsBody); |
177 | 180 | SubmissionsService.getPresignedURL(vm.submissionsBody, files, updateProgress);
|
178 | 181 | }
|
179 | 182 |
|
|
188 | 191 | if (args === 100) {
|
189 | 192 | vm.preparing = false;
|
190 | 193 | vm.uploading = true;
|
191 |
| - console.log('Prapared'); |
| 194 | + $log.debug('Prepared for upload.'); |
192 | 195 | }
|
193 | 196 | } else if (phase === 'UPLOAD') {
|
194 | 197 | // if args is object, this update is about XHRRequest's upload progress
|
|
212 | 215 | }
|
213 | 216 | // start next phase when UPLOAD is done
|
214 | 217 | if (vm.uploadProgress == 100) {
|
215 |
| - console.log('Uploaded'); |
| 218 | + $log.debug('Uploaded files.'); |
216 | 219 | vm.uploading = false;
|
217 | 220 | vm.finishing = true;
|
218 | 221 | }
|
219 | 222 | } else if (phase === 'FINISH') {
|
220 | 223 | // we are concerned only for completion of the phase
|
221 | 224 | if (args === 100) {
|
222 |
| - console.log('Finished'); |
| 225 | + $log.debug('Finished upload.'); |
223 | 226 | vm.finishing = false;
|
224 | 227 | vm.showProgress = false;
|
225 | 228 |
|
226 | 229 | // TODO redirect to submission listing / challenge details page
|
227 | 230 | }
|
228 | 231 | } else { // assume it to be error condition
|
229 |
| - console.log("Else: " + phase); |
| 232 | + $log.debug("Error Condition: " + phase); |
230 | 233 | vm.errorInUpload = true;
|
231 | 234 | }
|
232 | 235 | }
|
|
0 commit comments