From 19bce009c1bf7730cc293dcb4ab3c4726fa82d49 Mon Sep 17 00:00:00 2001 From: Vishnu Vardhan V Date: Fri, 1 May 2015 20:05:36 +0530 Subject: [PATCH] Related-bug:#1449860 In search flow we are fetching all the records and displaying, restricted the page size to 10,so that map flow button and topology will be visible even though we scroll down Change-Id: Id5541580ef85046526460d2f7d39dc935991f646 --- .../infra/underlay/ui/js/flow_queries.js | 41 +++++++++++-------- 1 file changed, 23 insertions(+), 18 deletions(-) diff --git a/webroot/monitor/infra/underlay/ui/js/flow_queries.js b/webroot/monitor/infra/underlay/ui/js/flow_queries.js index 76a48917a..a57ffcc1b 100644 --- a/webroot/monitor/infra/underlay/ui/js/flow_queries.js +++ b/webroot/monitor/infra/underlay/ui/js/flow_queries.js @@ -728,13 +728,11 @@ function runFRQuery() { columnDisplay, selectArray, queryId; //if ($("#" + queryPrefix + "-query-form").valid()) { //collapseWidget('#fr-query-widget'); - queryId = randomUUID(); collapseWidget('#fr-query-widget'); var option = {}; reqQueryObj = setUTCTimeObj('fr', reqQueryObj, option); reqQueryObj.table = 'FlowRecordTable'; - reqQueryObj.queryId = queryId; - reqQueryObj.async = 'true'; + reqQueryObj.async = 'false'; selectArray = parseStringToArray(select, ','); selectArray = selectArray.concat(queries['fr']['defaultColumns']); columnDisplay = getColumnDisplay4Grid(queries['fr']['columnDisplay'], selectArray, true); @@ -786,7 +784,9 @@ function viewFRQueryResults(dataItem, params) { function loadFlowResultsForUnderlay(options, reqQueryObj, columnDisplay, fcGridDisplay,reverseTraceFlow) { var grid = $('#' + options.elementId).data('contrailGrid'), url = "/api/admin/reports/query", - btnId = options.btnId; + btnId = options.btnId, + dataView = new ContrailDataView(), + gridObject; var gridConfig = { header: { @@ -808,16 +808,7 @@ function loadFlowResultsForUnderlay(options, reqQueryObj, columnDisplay, fcGridD forceFitColumns: true, }, dataSource : { - remote: { - ajaxConfig: { - url: url, - timeout: options.timeOut, - type: "POST", - data: reqQueryObj - }, - serverSidePagination: true, - exportFunction: exportServersideQueryResults - }, + dataView: dataView, events : { onRequestStartCB : function() { onQueryRequestStart(btnId); @@ -878,7 +869,6 @@ function loadFlowResultsForUnderlay(options, reqQueryObj, columnDisplay, fcGridD } } }; - if(options.queryPrefix == 'fs'){ if (grid) { $('#ts-chart').empty(); @@ -915,7 +905,8 @@ function loadFlowResultsForUnderlay(options, reqQueryObj, columnDisplay, fcGridD $(e['currentTarget']).attr('checked',true); } }, - actionCell: [] + actionCell: [], + lazyLoading:true, }; $("#mapflow").die('click').live('click',function(e){ var startTime = $("#"+options.queryPrefix+"-results").data('startTimeUTC'); @@ -927,8 +918,22 @@ function loadFlowResultsForUnderlay(options, reqQueryObj, columnDisplay, fcGridD showUnderlayPaths(dataItem); }); } - $("#" + options.elementId).contrailGrid(gridConfig); + gridObject = $("#"+options.elementId).data('contrailGrid'); + $.ajax({ + url:url+'?'+$.param(reqQueryObj), + }).done(function(response){ + dataView.setData(response['data']); + if(response['data'].length == 0 && gridObject != null) { + gridObject.showGridMessage('empty'); + } + }).fail(function(error){ + if(gridObject != null) { + gridObject.showGridMessage('error'); + } + }).always(function() { + $("#" + options.elementId).find('.grid-header-icon-loading').hide(); + }); $("#" + options.elementId).find('input.headerRowCheckbox').parent('span').remove(); $('#fs-results').find('a[data-action="collapse"]').on('click', function(){ if($(this).find('i.collapse-icon').hasClass('icon-chevron-up')){ @@ -948,7 +953,7 @@ function loadFlowResultsForUnderlay(options, reqQueryObj, columnDisplay, fcGridD function getFRDefaultOptions() { return { elementId:'fr-results', gridHeight:480, - timeOut:60000, pageSize:15, queryPrefix:'fr', export:true, + timeOut:60000, pageSize:10, queryPrefix:'fr', export:true, btnId:'fr-query-submit' }; };