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

Sup 3006 upload complete #687

Merged
merged 4 commits into from
Jan 22, 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
8 changes: 5 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
@@ -58,6 +58,8 @@ Spec files live alongside the code they are testing. For example, in peer-review
## UI-Router and States
See any *.routes.js file as an example.

**Important** Make sure the url in your routes files ends with a /

## Contributing

### Style Guide and Naming Conventions
@@ -78,9 +80,9 @@ Jade Files
```
.wrapper
h1 Lorem ipsum

p Sibling tag

.wrapper2
p Child
```
@@ -99,7 +101,7 @@ SCSS Files
height: 100px;
width: 100px;
}

.inside-box {
font-size: 14px;
@media screen and (min-width: 768px) {
4 changes: 3 additions & 1 deletion app/index.jade
Original file line number Diff line number Diff line change
@@ -156,6 +156,8 @@ html
script(src='../bower_components/react/react.js')
script(src='../bower_components/react/react-dom.js')
script(src='../bower_components/classnames/index.js')
script(src='../bower_components/classnames/bind.js')
script(src='../bower_components/classnames/dedupe.js')
script(src='../bower_components/react-input-autosize/dist/react-input-autosize.min.js')
script(src='../bower_components/react-select/dist/react-select.min.js')
script(src='../bower_components/ngReact/ngReact.js')
@@ -333,7 +335,7 @@ html
script(src="submissions/submissions.module.js")
script(src="submissions/submissions.controller.js")
script(src="submissions/submissions.routes.js")
script(src="submissions/submit-file/submit-file.controller.js")
script(src="submissions/submit-design-files/submit-design-files.controller.js")
script(src="topcoder.constants.js")
script(src="topcoder.controller.js")
script(src="topcoder.interceptors.js")
12 changes: 6 additions & 6 deletions app/specs.html
Original file line number Diff line number Diff line change
@@ -108,7 +108,7 @@ <h1><a href="specs.html">Spec Runner</a></h1>
<script src="/app/topcoder.controller.js"></script>
<script src="/app/topcoder.constants.js"></script>
<script src="/app/submissions/submissions.module.js"></script>
<script src="/app/submissions/submit-file/submit-file.controller.js"></script>
<script src="/app/submissions/submit-design-files/submit-design-files.controller.js"></script>
<script src="/app/submissions/submissions.routes.js"></script>
<script src="/app/submissions/submissions.controller.js"></script>
<script src="/app/skill-picker/skill-picker.module.js"></script>
@@ -288,8 +288,8 @@ <h1><a href="specs.html">Spec Runner</a></h1>
<script src="/app/account/login/login.spec.js"></script>
<script src="/app/account/logout/logout.controller.spec.js"></script>
<script src="/app/account/reset-password/reset-password.spec.js"></script>
<script src="/app/blocks/exception/exception-handler.provider.spec.js"></script>
<script src="/app/account/register/register.spec.js"></script>
<script src="/app/blocks/exception/exception-handler.provider.spec.js"></script>
<script src="/app/directives/badges/badge-tooltip.spec.js"></script>
<script src="/app/directives/busy-button/busy-button.directive.spec.js"></script>
<script src="/app/directives/challenge-tile/challenge-tile.spec.js"></script>
@@ -298,9 +298,9 @@ <h1><a href="specs.html">Spec Runner</a></h1>
<script src="/app/directives/external-account/external-link-deletion.controller.spec.js"></script>
<script src="/app/directives/external-account/external-links-data.directive.spec.js"></script>
<script src="/app/directives/external-account/external-web-links.directive.spec.js"></script>
<script src="/app/directives/tc-endless-paginator/tc-endless-paginator.spec.js"></script>
<script src="/app/directives/tc-file-input/tc-file-input.spec.js"></script>
<script src="/app/directives/tc-form-fonts/tc-form-fonts.spec.js"></script>
<script src="/app/directives/tc-endless-paginator/tc-endless-paginator.spec.js"></script>
<script src="/app/directives/tc-form-stockart/tc-form-stockart.spec.js"></script>
<script src="/app/directives/tc-input/tc-input.spec.js"></script>
<script src="/app/directives/tc-paginator/tc-paginator.spec.js"></script>
@@ -309,19 +309,19 @@ <h1><a href="specs.html">Spec Runner</a></h1>
<script src="/app/my-dashboard/header-dashboard/header-dashboard.spec.js"></script>
<script src="/app/my-dashboard/my-challenges/my-challenges.spec.js"></script>
<script src="/app/my-dashboard/programs/programs.spec.js"></script>
<script src="/app/my-dashboard/srms/srms.spec.js"></script>
<script src="/app/my-dashboard/subtrack-stats/subtrack-stats.controller.spec.js"></script>
<script src="/app/my-dashboard/srms/srms.spec.js"></script>
<script src="/app/peer-review/completed-review/completed-review.spec.js"></script>
<script src="/app/peer-review/edit-review/edit-review.spec.js"></script>
<script src="/app/peer-review/readOnlyScorecard/readOnlyScorecard.spec.js"></script>
<script src="/app/profile/about/about.controller.spec.js"></script>
<script src="/app/peer-review/review-status/review-status.spec.js"></script>
<script src="/app/profile/about/about.controller.spec.js"></script>
<script src="/app/profile/badges/badges.spec.js"></script>
<script src="/app/profile/subtrack/subtrack.spec.js"></script>
<script src="/app/settings/account-info/account-info.spec.js"></script>
<script src="/app/settings/edit-profile/edit-profile.spec.js"></script>
<script src="/app/settings/preferences/preferences.spec.js"></script>
<script src="/app/submissions/submit-file/submit-file.spec.js"></script>
<script src="/app/submissions/submit-design-files/submit-design-files.spec.js"></script>
<script src="/app/directives/account/toggle-password/toggle-password.spec.js"></script>
<script src="/app/directives/account/toggle-password-with-tips/toggle-password-with-tips.spec.js"></script>
<!-- endinject -->
15 changes: 12 additions & 3 deletions app/submissions/submissions.controller.js
Original file line number Diff line number Diff line change
@@ -3,9 +3,10 @@

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

SubmissionsController.$inject = ['challengeToSubmitTo'];
SubmissionsController.$inject = ['challengeToSubmitTo', '$state'];

function SubmissionsController(challengeToSubmitTo, $state) {

function SubmissionsController(challengeToSubmitTo) {
var vm = this;

var challenge = challengeToSubmitTo.challenge;
@@ -15,6 +16,14 @@

activate();

function activate() {}
function activate() {
var track = challengeToSubmitTo.challenge.track;

if (track === 'DESIGN') {
$state.go('submissions.file.design');
} else if (track === 'DEVELOP') {
$state.go('submissions.file.develop')
}
}
}
})();
26 changes: 17 additions & 9 deletions app/submissions/submissions.routes.js
Original file line number Diff line number Diff line change
@@ -18,9 +18,7 @@
controllerAs: 'submissions',
data: {
authRequired: true,

// TODO: Get title from PMs
title: 'Submit'
title: 'Challenge Submission'
},
resolve: {
challengeToSubmitTo: ['ChallengeService', '$stateParams', 'UserService', function(ChallengeService, $stateParams, UserService) {
@@ -36,10 +34,9 @@
challenge = challenge[0];

if (!challenge) {
// There should be a challenge, redirect?
// TODO: There should be a challenge, redirect?
alert('User is not associated with this challenge.');
}

var phaseType;
var phaseId;

@@ -84,11 +81,22 @@
}
},
'submissions.file': {
url: '?method=file',
templateUrl: 'submissions/submit-file/submit-file.html',
controller: 'SubmitFileController',
url:'file/',
abstract: true,
template: '<ui-view/>'
},
'submissions.file.design': {
url:'',
templateUrl: 'submissions/submit-design-files/submit-design-files.html',
controller: 'SubmitDesignFilesController',
controllerAs: 'vm',
}
},
'submissions.file.develop': {
url:'',
templateUrl: 'submissions/submit-develop-files/submit-develop-files.html',
controller: 'SubmitDevelopFilesController',
controllerAs: 'vm',
},
};

for (var name in states) {
36 changes: 33 additions & 3 deletions app/submissions/submissions.spec.js
Original file line number Diff line number Diff line change
@@ -10,6 +10,10 @@ describe('Submissions Controller', function() {
}
};

var state = {
go: sinon.spy()
}

beforeEach(function() {
bard.appModule('tc.submissions');
bard.inject(this, '$controller');
@@ -19,18 +23,44 @@ describe('Submissions Controller', function() {

beforeEach(function() {
controller = $controller('SubmissionsController', {
challengeToSubmitTo: mockChallenge
challengeToSubmitTo: mockChallenge,
$state: state
});
vm = controller;
});

it('should exist', function() {
it('exists', function() {
expect(vm).to.exist;
});

it('should have properties on vm from the routes resolve', function() {
it('has properties on vm from the routes resolve', function() {
expect(vm.challengeTitle).to.equal(mockChallenge.challenge.name);
expect(vm.challengeId).to.equal(30049240);
expect(vm.track).to.equal(mockChallenge.challenge.track.toLowerCase());
});

describe('routes to the correct child state for', function() {
it('design challenges', function() {

expect(state.go).calledWith('submissions.file.design');
});

it('develop challenges', function() {

controller = $controller('SubmissionsController', {
challengeToSubmitTo: {
challenge: {
name: 'Challenge Name',
track: 'DEVELOP',
id: 30049240
}
},
$state: state
});
vm = controller;

expect(state.go).calledWith('submissions.file.develop');
});

});
});
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
(function () {
'use strict';

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

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

function SubmitFileController($scope, $stateParams, $log, UserService, SubmissionsService, challengeToSubmitTo) {
function SubmitDesignFilesController($scope, $window, $stateParams, $log, UserService, SubmissionsService, challengeToSubmitTo) {
var vm = this;
$log = $log.getInstance('SubmitFileController');
$log = $log.getInstance('SubmitDesignFilesController');
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\.\/\?\%\#\&\=]*)?$/);
@@ -39,18 +39,14 @@

vm.submissionsBody = {
reference: {

// type dynamic or static?
type: 'CHALLENGE',
id: $stateParams.challengeId,
phaseType: challengeToSubmitTo.phaseType,
phaseId: challengeToSubmitTo.phaseId
},
userId: userId,
data: {

// Dynamic or static?
method: 'DESIGN_CHALLENGE_ZIP_FILE',
method: challengeToSubmitTo.challenge.track.toUpperCase() + '_CHALLENGE_ZIP_FILE',

// Can delete below since they are processed and added later?
files: [],
@@ -64,6 +60,7 @@
vm.setRankTo1 = setRankTo1;
vm.setFileReference = setFileReference;
vm.uploadSubmission = uploadSubmission;
vm.refreshPage = refreshPage;
vm.cancelRetry = cancelRetry;

activate();
@@ -194,11 +191,13 @@
count++;
}
vm.uploadProgress = total / count;

// initiate digest cycle because this event (xhr event) is caused outside angular
$scope.$apply();
} else { // typeof args === 'number', mainly used a s fallback to mark completion of the UPLOAD phase
vm.uploadProgress = args;
}

// start next phase when UPLOAD is done
if (vm.uploadProgress == 100) {
$log.debug('Uploaded files.');
@@ -209,20 +208,20 @@
// we are concerned only for completion of the phase
if (args === 100) {
$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
} else {
// assume it to be error condition
$log.debug("Error Condition: " + phase);
vm.errorInUpload = true;
}
}

function refreshPage() {
$window.location.reload(true);
}

function cancelRetry() {
vm.showProgress = false;
// TODO redirect to submission listing / challenge details page
}
}
})();
Original file line number Diff line number Diff line change
@@ -151,25 +151,32 @@

button.tc-btn.tc-btn-secondary(type="submit", ng-disabled="submissionForm.$invalid") Submit

modal.transition(show="vm.showProgress", background-click-close="true", style="background-color:white;")
modal.transition(show="vm.showProgress", background-click-close="false", style="background-color:white;")
.upload-progress(ng-class="{'upload-progress--error': vm.errorInUpload}")
.upload-progress__title
p Uploading submission for

p.upload-progress-title__challenge-name [Challenge name]

img.upload-progress__image(src="/images/robot.svg", ng-hide="vm.errorInUpload")

img.upload-progress__image--error(src="/images/robot-embarresed.svg", ng-show="vm.errorInUpload")

p.upload-progress__message(ng-hide="vm.errorInUpload") Hey, your work is AWESOME! Please don’t close the window while I’m working, you’ll loose all files!
p.upload-progress__message(ng-hide="vm.errorInUpload") Hey, your work is AWESOME! Please don’t close the window while I’m working or you’ll loose all files!

p.upload-progress__message--error(ng-show="vm.errorInUpload") Oh, that’s embarrassing! The file couldn’t be uploaded, I’m so sorry.
p.upload-progress__message--error(ng-show="vm.errorInUpload") Oh, that’s embarrassing! One of the files couldn’t be uploaded, I’m so sorry.

progress-bar.upload-progress__progress-bar(completed="vm.uploadProgress", message="of 3 files uploaded")

.upload-progress__preparing(ng-show="vm.preparing && !vm.errorInUpload") #[span Preparing...]
.upload-progress__finishing(ng-show="vm.finishing && !vm.errorInUpload") #[span Finishing...]
.upload-progress__finishing(ng-show="vm.finishing && !vm.errorInUpload")
p Finished!

.upload-progess__links
a.tc-btn.tc-btn-s(ng-href="https://www.{{DOMAIN}}/challenge-details/{{submissions.challengeId}}/?type={{submissions.track}}") Back to the challenge

a.tc-btn.tc-btn-s.tc-btn-ghost(ng-click="vm.refreshPage()") Submit another


.upload-progress__error(ng-show="vm.errorInUpload") #[span File upload failed]

.upload-progress__error-action(ng-show="vm.errorInUpload")
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/* jshint -W117, -W030 */
describe('Submit File Controller', function() {
describe('Submit Design Files Controller', function() {
var controller, vm, scope;

var mockChallenge = {
@@ -22,6 +22,12 @@ describe('Submit File Controller', function() {
getPresignedURL: function() {}
};

var mockWindow = {
location: {
reload: function(val) { return val; }
}
};

beforeEach(function() {
bard.appModule('tc.submissions');
bard.inject(this, '$controller', '$rootScope');
@@ -32,19 +38,40 @@ describe('Submit File Controller', function() {
bard.verifyNoOutstandingHttpRequests();

beforeEach(function() {
controller = $controller('SubmitFileController', {
controller = $controller('SubmitDesignFilesController', {
$scope: scope,
UserService: userService,
challengeToSubmitTo: mockChallenge,
SubmissionsService: submissionsService
SubmissionsService: submissionsService,
$window: mockWindow
});
vm = controller;
});

it('should exist', function() {
it('exists', function() {
expect(vm).to.exist;
});

it('sets the right track for the method', function() {
controller = $controller('SubmitDesignFilesController', {
$scope: scope,
UserService: userService,
challengeToSubmitTo: {
challenge: {
name: 'Challenge Name',
track: 'DEVELOP',
id: 30049240
}
},
SubmissionsService: submissionsService,
$window: mockWindow
});
vm = controller;
scope.$digest();

expect(vm.submissionsBody.data.method).to.equal('DEVELOP_CHALLENGE_ZIP_FILE');
});

describe('setRankTo1', function() {
it('returns 1 if the input is blank', function() {
expect(vm.setRankTo1('')).to.equal(1);
@@ -265,6 +292,18 @@ describe('Submit File Controller', function() {
});
});

describe('refreshPage', function() {
it('reloads the page', function() {
var mockRefresh = sinon.spy(mockWindow.location, 'reload');

vm.refreshPage();
scope.$digest();

expect(mockRefresh).calledWith(true);
expect(mockRefresh).calledOnce;
});
});

describe('cancelRetry', function() {
it('sets showProgress to false', function() {
vm.showProgress = true;
8 changes: 2 additions & 6 deletions app/topcoder.routes.js
Original file line number Diff line number Diff line change
@@ -42,10 +42,8 @@
window.location.href = CONSTANTS.MAIN_URL + '/404/';
}]
},
/**
* Base state that all other routes should inherit from.
* Child routes can override any of the specified regions
*/
// Base state that all other routes should inherit from.
// Child routes can override any of the specified regions
'root': {
url: '',
abstract: true,
@@ -70,10 +68,8 @@
}
},
'home': {
// TODO - set new home page
parent: 'root',
url: '/',
// template: 'This is the home page',
controller: ['$state', function($state) {
$state.go('dashboard');
}]
20 changes: 15 additions & 5 deletions assets/css/submissions/submit-file.scss
Original file line number Diff line number Diff line change
@@ -112,11 +112,8 @@ tc-form-fonts, tc-form-stockart {
}

modal {
.close {
.icon.cross {
background-image: url(/images/x-mark-gray.svg);
background-size: 25px;
}
> button {
display: none;
}
}
.upload-progress {
@@ -162,6 +159,7 @@ modal {
font-size: 12px;
line-height: 14px;
color: $accent-gray-dark;
text-align: center;
}

.upload-progress__error {
@@ -180,3 +178,15 @@ modal {
}
}
}

.upload-progess__links {
margin-top: 40px;

a {
display: inline-block;

&:first-child {
margin-right: 10px;
}
}
}