Skip to content
Merged
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
49 changes: 26 additions & 23 deletions src/static/riot/competitions/public-list.tag
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<public-list>
<h1>Public Benchmarks and Competitions</h1>
<div class="pagination-nav" hide="{(competitions.count < 10)}">
<div class="pagination-nav">
<button show="{competitions.previous}" onclick="{handle_ajax_pages.bind(this, -1)}" class="float-left ui inline button active">Back</button>
<button hide="{competitions.previous}" disabled="disabled" class="float-left ui inline button disabled">Back</button>
{ current_page } of {Math.ceil(competitions.count/competitions.page_size)}
Expand Down Expand Up @@ -61,32 +61,35 @@
}

self.update_competitions_list = function (num) {
self.current_page = num
$('#loading').show()
$('.pagination-nav').hide()
if (self.competitions_cache[self.current_page]){
self.competitions = self.competitions_cache[self.current_page]
history.pushState("", document.title, "?page="+self.current_page)
$('.pagination-nav > button').prop('disabled', false)
self.update()
self.current_page = num;
$('#loading').show(); // Show the loading indicator
$('.pagination-nav').hide(); // Hide pagination navigation

// Function to handle successful data retrieval
function handleSuccess(response) {
self.competitions = response;
self.competitions_cache[self.current_page.toString()] = response;
$('#loading').hide(); // Hide the loading indicator
$('.pagination-nav').show(); // Show pagination navigation
history.pushState("", document.title, "?page=" + self.current_page);
$('.pagination-nav > button').prop('disabled', false);
self.update();
}
// Check if data is in cache
if (self.competitions_cache[self.current_page]) {
handleSuccess(self.competitions_cache[self.current_page]);
} else {
return CODALAB.api.get_public_competitions({"page":self.current_page})
// Fetch data using AJAX call
return CODALAB.api.get_public_competitions({"page": self.current_page})
.fail(function (response) {
$('#loading').hide()
$('.pagination-nav').show()
toastr.error("Could not load competition list")
})
.done(function (response){
self.competitions = response
self.competitions_cache[self.current_page.toString()] = response
$('#loading').hide()
$('.pagination-nav').show()
history.pushState("", document.title, "?page="+self.current_page)
$('.pagination-nav > button').prop('disabled', false)
self.update()
$('#loading').hide(); // Hide the loading indicator
$('.pagination-nav').show(); // Show pagination navigation
toastr.error("Could not load competition list");
})
.done(handleSuccess);
}
}
};


self.get_array_length = function (arr) {
if(arr === undefined){
Expand Down
26 changes: 24 additions & 2 deletions src/static/riot/competitions/tile/front_page_competitions.tag
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<div class="ui two column grid">
<div class="eight wide column">
<div class="ui large header">
<a href="/competitions/public/">Popular Benchmarks</a>
Popular Benchmarks
</div>
<div class="loader-container popular">
<div class="lds-ring">
Expand All @@ -13,11 +13,12 @@
</div>
</div>
<competition-tile each="{popular_competitions}"></competition-tile>
<a class="show-more" href="/competitions/public/">Show more</a>
</div>

<div class="eight wide column">
<div class="ui large header">
<a href="/competitions/public/">Featured Benchmarks</a>
Featured Benchmarks
</div>
<div class="loader-container popular">
<div class="lds-ring">
Expand All @@ -28,6 +29,7 @@
</div>
</div>
<competition-tile each="{featured_competitions}"></competition-tile>
<a class="show-more" href="/competitions/public/">Show more</a>
</div>
</div>

Expand Down Expand Up @@ -58,6 +60,26 @@
margin: 3em 1.5em;
}

.show-more {
display: block;
width: fit-content;
margin: 20px auto;
padding: 10px 20px;
background-color: #4a6778;
color: white;
text-align: center;
border-radius: 5px;
font-size: 1.1em;
text-decoration: none;
transition: background-color 0.3s, transform 0.3s;
}

.show-more:hover {
background-color: #467799;
transform: scale(1.05);
text-decoration: none;
}

.sub-header-link {
line-height: 0.25em;
}
Expand Down