diff --git a/frontend/src/api.js b/frontend/src/api.js index 748848715..087f0f8cb 100644 --- a/frontend/src/api.js +++ b/frontend/src/api.js @@ -81,6 +81,19 @@ class Api { ); } + static getTournamentSubmissions(episode, page, callback) { + $.get( + `${URL}/api/compete/${episode}/submission/tournament/?page=${page}` + ).done((data, status) => { + data = { + count: data.length, + results: data, + }; + const pageLimit = Math.ceil(data.count / PAGE_SIZE); + callback(data, pageLimit); + }); + } + //----TEAM STATS--- // clean these calls, fix in #368 @@ -557,10 +570,12 @@ class Api { }); } - static getTournaments(callback) { - $.get(`${URL}/api/${LEAGUE}/tournament/`).done((data, status) => { - callback(data.results); - }); + static getTournaments(episode, callback) { + return $.get(`${URL}/api/episode/${episode}/tournament/`).done( + (data, status) => { + callback(data.results); + } + ); } //----AUTHENTICATION---- diff --git a/frontend/src/components/submissionList.js b/frontend/src/components/submissionList.js index fea2d0ffc..645758a5c 100644 --- a/frontend/src/components/submissionList.js +++ b/frontend/src/components/submissionList.js @@ -37,7 +37,10 @@ class SubmissionList extends Component { getPage = (page) => { this.setState({ submissions: [], page, loading: true }); - Api.getSubmissions(this.props.episode, page, (data, pageLimit) => { + const getter = this.props.tournament + ? Api.getTournamentSubmissions + : Api.getSubmissions; + getter(this.props.episode, page, (data, pageLimit) => { // This check handles the case where a new page is requested while a // previous page was loading. if (page == this.state.page) { @@ -57,34 +60,53 @@ class SubmissionList extends Component { const created_date_string = created_date_text.local_full_string; return ( + {this.props.tournament ? ( + + { + (this.props.tournament_info ?? []).filter((t) => { + return t.name_short == submission.tournament; + })[0]?.name_long + } + + ) : ( + "" + )} {created_date_string} - - {submission.status == "OK!" - ? SUBMISSION_ACCEPTED[submission.accepted] - : SUBMISSION_STATUS[submission.status]} - + {this.props.tournament ? ( + "" + ) : ( + + {submission.status == "OK!" + ? SUBMISSION_ACCEPTED[submission.accepted] + : SUBMISSION_STATUS[submission.status]} + + )} {submission.description} {submission.package} {submission.username} - - {" "} - { - // Prevent default behavior when clicking a link - $event.preventDefault(); + {this.props.tournament ? ( + "" + ) : ( + + {" "} + { + // Prevent default behavior when clicking a link + $event.preventDefault(); - let fileURL = URL.createObjectURL( - new Blob([submission.logs], { type: "text/plain" }) - ); - window.open(fileURL); - }} - target="_blank" - rel="noopener noreferrer" - > - View log - {" "} - + let fileURL = URL.createObjectURL( + new Blob([submission.logs], { type: "text/plain" }) + ); + window.open(fileURL); + }} + target="_blank" + rel="noopener noreferrer" + > + View log + {" "} + + )} {" "}