Skip to content

Commit

Permalink
Re-apply Task Pagination PR #395
Browse files Browse the repository at this point in the history
Changes made in #395 were accidentally reverted by #383, because code
in #395 was mistakenly committed to the compiled javascript assets.
This commit fixes that, and re-introduces the intended code changes to
the source javascript file, and commits both copies.
  • Loading branch information
jhunt committed Jun 13, 2018
1 parent 2b7e0a2 commit 6cf673d
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 0 deletions.
20 changes: 20 additions & 0 deletions web2/htdocs/shield.js
Original file line number Diff line number Diff line change
Expand Up @@ -2070,6 +2070,9 @@ function dispatch(page) {
error: "Failed retrieving metadata for protected system from the SHIELD API.",
success: function (data) {
$('#main').html(template('system', { target: data }));

oldest = data["tasks"][data.tasks.length-1]["requested_at"]

watchTasks($global.auth.tenant.uuid, data.uuid, function (r) {
task = JSON.parse(r.data);
for (var i = 0; i < data.tasks.length; i++) {
Expand All @@ -2082,6 +2085,23 @@ function dispatch(page) {
data.tasks.unshift(task);
$('#main').html(template('system', { target: data }));
});

$(document.body).on('click', 'a[href^="load_more"]', function (event) {
event.preventDefault();
api({
type: 'GET',
url: '/v2/tenants/' + $global.auth.tenant.uuid + '/systems/' + args.uuid + '?before=' + oldest,
error: "Failed retrieving metadata for protected system from the SHIELD API.",
success: function (older_tasks) {
data.tasks = $.merge(data.tasks, older_tasks.tasks);
$('#main').html(template('system', { target: data }));
oldest = data["tasks"][data.tasks.length - 1]["requested_at"]
if (older_tasks.tasks.length == 0) {
$(".paginated-loading").remove();
}
}
});
});
}
});
break; /* #!/systems/system */
Expand Down
20 changes: 20 additions & 0 deletions web2/src/js/shield.js
Original file line number Diff line number Diff line change
Expand Up @@ -773,6 +773,9 @@ function dispatch(page) {
error: "Failed retrieving metadata for protected system from the SHIELD API.",
success: function (data) {
$('#main').html(template('system', { target: data }));

oldest = data["tasks"][data.tasks.length-1]["requested_at"]

watchTasks($global.auth.tenant.uuid, data.uuid, function (r) {
task = JSON.parse(r.data);
for (var i = 0; i < data.tasks.length; i++) {
Expand All @@ -785,6 +788,23 @@ function dispatch(page) {
data.tasks.unshift(task);
$('#main').html(template('system', { target: data }));
});

$(document.body).on('click', 'a[href^="load_more"]', function (event) {
event.preventDefault();
api({
type: 'GET',
url: '/v2/tenants/' + $global.auth.tenant.uuid + '/systems/' + args.uuid + '?before=' + oldest,
error: "Failed retrieving metadata for protected system from the SHIELD API.",
success: function (older_tasks) {
data.tasks = $.merge(data.tasks, older_tasks.tasks);
$('#main').html(template('system', { target: data }));
oldest = data["tasks"][data.tasks.length - 1]["requested_at"]
if (older_tasks.tasks.length == 0) {
$(".paginated-loading").remove();
}
}
});
});
}
});
break; /* #!/systems/system */
Expand Down

0 comments on commit 6cf673d

Please sign in to comment.