Skip to content
This repository has been archived by the owner on Jul 6, 2020. It is now read-only.

[WIP] Unique url for view_all_submissions and my_submission #322

Draft
wants to merge 5 commits into
base: master
Choose a base branch
from
Draft
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
2 changes: 2 additions & 0 deletions src/app/components/challenge/challenge-routing.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@ const routes: Routes = [
{path: 'my-submissions/:phase', component: ChallengesubmissionsComponent},
{path: 'mysubmissions/:phase/:submission', component: ChallengesubmissionsComponent},
{path: 'view-all-submissions', component: ChallengeviewallsubmissionsComponent},
{path: 'view-all-submissions/:phase', component: ChallengeviewallsubmissionsComponent},
{path: 'view-all-submissions/:phase/:submission', component: ChallengeviewallsubmissionsComponent},
{path: 'leaderboard', component: ChallengeleaderboardComponent},
{path: 'leaderboard/:split', component: ChallengeleaderboardComponent},
{path: 'leaderboard/:split/:entry', component: ChallengeleaderboardComponent},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -228,20 +228,27 @@ export class ChallengesubmissionsComponent implements OnInit, AfterViewInit {
phaseSelected() {
const SELF = this;
return (phase) => {
SELF.selectedPhase = phase;
if (SELF.router.url.endsWith('my-submissions')) {
SELF.router.navigate([phase['slug']], {relativeTo: this.route});
} else if (SELF.router.url.split('/').length === 5) {
SELF.router.navigate(['../' + phase['slug']], {relativeTo: this.route});
} else if (SELF.router.url.split('/').length === 6) {
SELF.router.navigate(['../../' + phase['slug']], {relativeTo: this.route});
}
SELF.isPhaseSelected = true;
SELF.submissionCount = 0;
if (SELF.challenge['id'] && phase['id']) {
SELF.fetchSubmissions(SELF.challenge['id'], phase['id']);
SELF.fetchSubmissionCounts(this.challenge['id'], phase['id']);
SELF.selectedPhase = phase;
if (SELF.challenge['id'] && phase['slug']) {
SELF.fetchSubmissions(SELF.challenge['id'], phase['slug']);
SELF.fetchSubmissionCounts(this.challenge['id'], phase['slug']);
}
};
}

/**
* Fetch submissions from API.
* @param challenge challenge id
* @param phase phase id
* @param phase phase slug
*/
fetchSubmissions(challenge, phase) {
const SELF = this;
Expand Down Expand Up @@ -298,7 +305,7 @@ export class ChallengesubmissionsComponent implements OnInit, AfterViewInit {
filterSubmissions(participantTeamName) {
const SELF = this;
SELF.filterSubmissionsQuery = participantTeamName;
SELF.fetchSubmissions(SELF.challenge['id'], SELF.selectedPhase['id']);
SELF.fetchSubmissions(SELF.challenge['id'], SELF.selectedPhase['slug']);
}

/**
Expand Down Expand Up @@ -450,7 +457,7 @@ export class ChallengesubmissionsComponent implements OnInit, AfterViewInit {
/**
* Fetch number of submissions for a challenge phase.
* @param challenge challenge id
* @param phase phase id
* @param phase phase slug
*/
fetchSubmissionCounts(challenge, phase) {
const API_PATH = this.endpointsService.challengeSubmissionCountURL(challenge, phase);
Expand Down Expand Up @@ -485,7 +492,7 @@ export class ChallengesubmissionsComponent implements OnInit, AfterViewInit {
() => {
// Success Message in data.message
SELF.globalService.showToast('success', 'Data updated successfully', 5);
SELF.fetchSubmissions(SELF.challenge.id, SELF.selectedPhase.id);
SELF.fetchSubmissions(SELF.challenge.id, SELF.selectedPhase.slug);
},
err => {
SELF.globalService.handleApiError(err, true);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -216,20 +216,27 @@ export class ChallengeviewallsubmissionsComponent implements OnInit, AfterViewIn
phaseSelected() {
const SELF = this;
return (phase) => {
if (SELF.router.url.endsWith('view-all-submissions')) {
SELF.router.navigate([phase['slug']], {relativeTo: this.route});
} else if (SELF.router.url.split('/').length === 5) {
SELF.router.navigate(['../' + phase['slug']], {relativeTo: this.route});
} else if (SELF.router.url.split('/').length === 6) {
SELF.router.navigate(['../../' + phase['slug']], {relativeTo: this.route});
}
SELF.selectedPhase = phase;
SELF.isPhaseSelected = true;
SELF.submissionCount = 0;
if (SELF.challenge['id'] && phase['id']) {
SELF.fetchSubmissions(SELF.challenge['id'], phase['id']);
SELF.fetchSubmissionCounts(this.challenge['id'], phase['id']);
if (SELF.challenge['id'] && phase['slug']) {
SELF.fetchSubmissions(SELF.challenge['id'], phase['slug']);
SELF.fetchSubmissionCounts(this.challenge['id'], phase['slug']);
}
};
}

/**
* Fetch submissions from API.
* @param challenge challenge id
* @param phase phase id
* @param phase phase slug
*/
fetchSubmissions(challenge, phase) {
const SELF = this;
Expand Down Expand Up @@ -298,7 +305,7 @@ export class ChallengeviewallsubmissionsComponent implements OnInit, AfterViewIn
filterSubmissions(participantTeamName) {
const SELF = this;
SELF.filterSubmissionsQuery = participantTeamName;
SELF.fetchSubmissions(SELF.challenge['id'], SELF.selectedPhase['id']);
SELF.fetchSubmissions(SELF.challenge['id'], SELF.selectedPhase['slug']);
}

/**
Expand Down Expand Up @@ -481,7 +488,7 @@ export class ChallengeviewallsubmissionsComponent implements OnInit, AfterViewIn
/**
* Fetch number of submissions for a challenge phase.
* @param challenge challenge id
* @param phase phase id
* @param phase phase slug
*/
fetchSubmissionCounts(challenge, phase) {
const API_PATH = this.endpointsService.challengeSubmissionCountURL(challenge, phase);
Expand Down
20 changes: 10 additions & 10 deletions src/app/services/endpoints.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -219,30 +219,30 @@ export class EndpointsService {
/**
* Challenge Submission
* @param challenge challenge id
* @param phase phase id
* @param phase phase slug
*/
challengeSubmissionURL(challenge, phase) {
return `${this.jobs}${this.challenge}${challenge}/challenge_phase/${phase}/submission/`;
return `${this.jobs}${this.challenge}${challenge}/challenge_phase/v2/${phase}/submission/`;
}

/**
* Filter challenge submissions in my submissions by participant team name
* @param challenge challenge id
* @param phase phase id
* @param phase phase slug
* @param participantTeamName participant team name
*/
challengeSubmissionWithFilterQueryURL(challenge, phase, participantTeamName) {
return `${this.jobs}${this.challenge}${challenge}/challenge_phase/
return `${this.jobs}${this.challenge}${challenge}/challenge_phase/v2/
${phase}/submission?participant_team__team_name=${participantTeamName}`;
}

/**
* Get all Challenge Submission
* @param challenge challenge id
* @param phase phase id
* @param phase phase slug
*/
allChallengeSubmissionURL(challenge, phase) {
return `${this.challenges}${challenge}/challenge_phase/${phase}/submissions`;
return `${this.challenges}${challenge}/challenge_phase/v2/${phase}/submissions`;
}

/**
Expand All @@ -252,13 +252,13 @@ ${phase}/submission?participant_team__team_name=${participantTeamName}`;
* @param participantTeamName participant team name
*/
allChallengeSubmissionWithFilterQueryUrl(challenge, phase, participantTeamName) {
return `${this.challenges}${challenge}/challenge_phase/${phase}/submissions?participant_team__team_name=${participantTeamName}`;
return `${this.challenges}${challenge}/challenge_phase/v2/${phase}/submissions?participant_team__team_name=${participantTeamName}`;
}

/**
* Challenge Submission Download
* @param challenge challenge id
* @param phase phase id
* @param phase phase slug
*/
challengeSubmissionDownloadURL(challenge, phase, fileSelected) {
return `${this.challenges}${challenge}/phase/${phase}/download_all_submissions/${fileSelected}/`;
Expand All @@ -267,10 +267,10 @@ ${phase}/submission?participant_team__team_name=${participantTeamName}`;
/**
* Challenge Submission Counts
* @param challenge challenge id
* @param phase phase id
* @param phase phase slug
*/
challengeSubmissionCountURL(challenge, phase) {
return `${this.analytics}${this.challenge}${challenge}/challenge_phase/${phase}/count`;
return `${this.analytics}${this.challenge}${challenge}/challenge_phase/v2/${phase}/count`;
}

/**
Expand Down