Fixed slider jump issue by making an API call to fetch the next batch of rows only after a user stops scrolling down. Fixes #3269

This commit is contained in:
Nagesh Dhope 2020-04-22 17:54:32 +05:30 committed by Akshay Joshi
parent 6e5dbf7beb
commit 5e91ed2bb1
2 changed files with 15 additions and 9 deletions

View File

@ -564,8 +564,6 @@ def fetch(trans_id, fetch_all=None, fetch_till=None):
else:
status = 'Success'
res_len = len(result)
if fetch_row_cnt != -1 and res_len == ON_DEMAND_RECORD_COUNT:
has_more_rows = True
if res_len:
rows_fetched_from = trans_obj.get_fetched_row_cnt()
@ -574,6 +572,9 @@ def fetch(trans_id, fetch_all=None, fetch_till=None):
rows_fetched_to = trans_obj.get_fetched_row_cnt()
session_obj['command_obj'] = pickle.dumps(trans_obj, -1)
update_session_grid_transaction(trans_id, session_obj)
if fetch_row_cnt != -1 and rows_fetched_to < conn.rows_affected():
has_more_rows = True
else:
status = 'NotConnected'
result = error_msg

View File

@ -1213,12 +1213,17 @@ define('tools.querytool', [
}.bind(editor_data));
grid.onScroll.subscribe((e, args) => {
if (self.handler.has_more_rows && !self.handler.fetching_rows && args.grid.getViewport().bottom > self.handler.rows_fetched_to + self.handler.rows_fetch_batch_count) {
// fast scrolling
let fetch_till = ((args.grid.getViewport().bottom % self.handler.rows_fetch_batch_count) + 1) * self.handler.rows_fetch_batch_count;
self.fetch_next(null, null, fetch_till);
} else if (self.handler.has_more_rows && !self.handler.fetching_rows && args.grid.getViewport().bottom + 100 > self.handler.rows_fetched_to) {
// gentle scroll
clearTimeout($.data(this, 'scrollTimer'));
$.data(this, 'scrollTimer', setTimeout(function () {
if (self.handler.has_more_rows && !self.handler.fetching_rows && args.grid.getViewport().bottom > self.handler.rows_fetched_to + self.handler.rows_fetch_batch_count) {
// fast scrolling using slider
let fetch_till = (parseInt(args.grid.getViewport().bottom / self.handler.rows_fetch_batch_count) + 1) * self.handler.rows_fetch_batch_count;
self.fetch_next(null, null, fetch_till);
}
}, 250));
// If its gentle scroll, when last 10% of rows are left to scroll then fetch next batch of rows
if (self.handler.has_more_rows && !self.handler.fetching_rows && args.grid.getViewport().bottom + (self.handler.rows_fetch_batch_count * 0.1) > self.handler.rows_fetched_to) {
// gentle scroll using mouse
setTimeout(self.fetch_next.bind(self));
}
});
@ -1310,7 +1315,7 @@ define('tools.querytool', [
$('#btn-download').prop('disabled', false);
self.handler.trigger('pgadmin-sqleditor:loading-icon:hide');
self.handler.rows_fetched_to = res.data.rows_fetched_to;
self.update_grid_data(res.data.result);
setTimeout(() => self.update_grid_data(res.data.result), 100);
self.handler.fetching_rows = false;
if (typeof cb == 'function') {
cb();