mirror of
https://github.com/ansible/awx.git
synced 2026-02-17 03:00:04 -03:30
[WIP] Add event buffering on scroll/resume
This commit is contained in:
committed by
Jake McDermott
parent
60a43015e2
commit
a5bd905f18
@@ -106,33 +106,32 @@ function JobsIndexController (
|
|||||||
}
|
}
|
||||||
|
|
||||||
function processWebSocketEvents (scope, data) {
|
function processWebSocketEvents (scope, data) {
|
||||||
vm.scroll.isActive = true;
|
|
||||||
|
|
||||||
if (data.event === JOB_START) {
|
if (data.event === JOB_START) {
|
||||||
|
vm.scroll.isActive = true;
|
||||||
vm.stream.isActive = true;
|
vm.stream.isActive = true;
|
||||||
vm.scroll.isLocked = true;
|
vm.scroll.isLocked = true;
|
||||||
} else if (data.event === JOB_END) {
|
} else if (data.event === JOB_END) {
|
||||||
vm.stream.isActive = false;
|
vm.stream.isActive = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!vm.scroll.isLocked) {
|
// TODO: Determine how to manage buffered events (store in page cache vs. separate)
|
||||||
vm.scroll.isActive = false;
|
// Leaning towards keeping separate (same as they come in over WS). On resume of scroll,
|
||||||
|
// Clear/reset cache, append buffered events, then back to normal render cycle
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (vm.stream.count % resource.page.size === 0) {
|
if (vm.stream.count % resource.page.size === 0) {
|
||||||
cache.push({
|
cache.push({ page: vm.stream.page });
|
||||||
page: vm.stream.page
|
|
||||||
});
|
|
||||||
|
|
||||||
vm.stream.page++;
|
vm.stream.page++;
|
||||||
|
|
||||||
|
if (buffer.length > (resource.page.resultLimit - resource.page.size)) {
|
||||||
|
buffer.splice(0, (buffer.length - resource.page.resultLimit) + resource.page.size);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
vm.stream.count++;
|
vm.stream.count++;
|
||||||
buffer.push(data);
|
buffer.push(data);
|
||||||
|
|
||||||
if (vm.stream.isRendering) {
|
if (vm.stream.isRendering || !vm.scroll.isLocked) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -280,7 +279,7 @@ function prepend (events) {
|
|||||||
function pop () {
|
function pop () {
|
||||||
// console.log('[3] popping old page');
|
// console.log('[3] popping old page');
|
||||||
return $q(resolve => {
|
return $q(resolve => {
|
||||||
if (cache.length <= resource.page.limit) {
|
if (cache.length <= resource.page.pageLimit) {
|
||||||
// console.log('[3.1] nothing to pop');
|
// console.log('[3.1] nothing to pop');
|
||||||
return resolve();
|
return resolve();
|
||||||
}
|
}
|
||||||
@@ -299,16 +298,16 @@ function pop () {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function shift () {
|
function shift () {
|
||||||
// console.log('[3] shifting old page');
|
console.log('[3] shifting old page', cache.length);
|
||||||
return $q(resolve => {
|
return $q(resolve => {
|
||||||
if (cache.length <= resource.page.limit) {
|
if (cache.length <= resource.page.pageLimit) {
|
||||||
// console.log('[3.1] nothing to shift');
|
// console.log('[3.1] nothing to shift');
|
||||||
return resolve();
|
return resolve();
|
||||||
}
|
}
|
||||||
|
|
||||||
window.requestAnimationFrame(() => {
|
window.requestAnimationFrame(() => {
|
||||||
const ejected = cache.shift();
|
const ejected = cache.shift();
|
||||||
// console.log('[3.1] shifting', ejected);
|
console.log('[3.1] shifting', ejected);
|
||||||
const rows = $(ELEMENT_TBODY).children().slice(0, ejected.lines);
|
const rows = $(ELEMENT_TBODY).children().slice(0, ejected.lines);
|
||||||
|
|
||||||
rows.empty();
|
rows.empty();
|
||||||
@@ -639,8 +638,16 @@ function scrollHome () {
|
|||||||
function scrollEnd () {
|
function scrollEnd () {
|
||||||
if (vm.scroll.isLocked) {
|
if (vm.scroll.isLocked) {
|
||||||
vm.scroll.isLocked = false;
|
vm.scroll.isLocked = false;
|
||||||
|
vm.scroll.isActive = false;
|
||||||
|
|
||||||
return;
|
return;
|
||||||
|
} else if (!vm.scroll.isLocked && vm.stream.isActive) {
|
||||||
|
vm.scroll.isActive = true;
|
||||||
|
|
||||||
|
return clear()
|
||||||
|
.then(() => {
|
||||||
|
vm.scroll.isLocked = true;
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
const config = {
|
const config = {
|
||||||
|
|||||||
@@ -59,8 +59,9 @@ function resolveResource (Job, ProjectUpdate, AdHocCommand, SystemJob, WorkflowJ
|
|||||||
ws: getWebSocketResource(type),
|
ws: getWebSocketResource(type),
|
||||||
page: {
|
page: {
|
||||||
cache: PAGE_CACHE,
|
cache: PAGE_CACHE,
|
||||||
limit: PAGE_LIMIT,
|
size: PAGE_SIZE,
|
||||||
size: PAGE_SIZE
|
pageLimit: PAGE_LIMIT,
|
||||||
|
resultLimit: PAGE_SIZE * PAGE_LIMIT
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
});
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user