Skip to content

Commit 28cb3a6

Browse files
author
Ali Razmjoo
authored
Merge pull request #282 from spiderxm/development
Fix issue when 0 log records are returned from the api
2 parents 2de22b4 + 124024f commit 28cb3a6

1 file changed

Lines changed: 25 additions & 22 deletions

File tree

web/static/js/explore.js

Lines changed: 25 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -193,27 +193,29 @@ $.fn.dataTable.pipeline = function ( opts ) {
193193
}
194194
}
195195
json = tmpj
196-
index = Object.keys(json['data'][0])[settings.aLastSort[0].col]
197-
order = settings.aLastSort[0].dir
198-
if (order == "asc"){
199-
json['data'].sort(
200-
(a, b) => {
201-
if (a[index] < b[index])
202-
return -1;
203-
if (a[index] > b[index])
204-
return 1;
205-
return 0;
206-
})
207-
208-
} else {
209-
json['data'].sort(
210-
(a, b) => {
211-
if (a[index] > b[index])
212-
return -1;
213-
if (a[index] < b[index])
214-
return 1;
215-
return 0;
216-
})
196+
if(json['data'].length > 0){
197+
index = Object.keys(json['data'][0])[settings.aLastSort[0].col]
198+
order = settings.aLastSort[0].dir
199+
if (order == "asc") {
200+
json['data'].sort(
201+
(a, b) => {
202+
if (a[index] < b[index])
203+
return -1;
204+
if (a[index] > b[index])
205+
return 1;
206+
return 0;
207+
})
208+
209+
} else {
210+
json['data'].sort(
211+
(a, b) => {
212+
if (a[index] > b[index])
213+
return -1;
214+
if (a[index] < b[index])
215+
return 1;
216+
return 0;
217+
})
218+
}
217219
}
218220
return JSON.stringify( json );
219221
},
@@ -295,7 +297,8 @@ function get_event_data(api_endpoint, column_list, api_params) {
295297
processing: true,
296298
language:{
297299
loadingRecords: '&nbsp;',
298-
processing: '<div class="spinner">Loading...</div>'
300+
processing: '<div class="spinner">Loading...</div>',
301+
sEmptyTable: '<div>No records are present for given request</div>'
299302
},
300303
oLanguage: {
301304
sStripClasses: "",

0 commit comments

Comments
 (0)