Commit 64988b8a by Kalyani Committed by nixonrodrigues

ATLAS-1811 : UI : Audit Events are not shown in sorted order based on time sometimes.

parent bd69a4f1
...@@ -59,7 +59,7 @@ define(['require', ...@@ -59,7 +59,7 @@ define(['require',
initialize: function(options) { initialize: function(options) {
_.extend(this, _.pick(options, 'guid', 'entity', 'entityName', 'entityDef')); _.extend(this, _.pick(options, 'guid', 'entity', 'entityName', 'entityDef'));
this.entityCollection = new VEntityList(); this.entityCollection = new VEntityList();
this.count = 26; this.limit = 26;
this.entityCollection.url = UrlLinks.entityCollectionaudit(this.guid); this.entityCollection.url = UrlLinks.entityCollectionaudit(this.guid);
this.entityCollection.modelAttrName = "events"; this.entityCollection.modelAttrName = "events";
this.entityModel = new this.entityCollection.model(); this.entityModel = new this.entityCollection.model();
...@@ -80,17 +80,20 @@ define(['require', ...@@ -80,17 +80,20 @@ define(['require',
this.currPage = 1; this.currPage = 1;
}, },
onRender: function() { onRender: function() {
$.extend(this.entityCollection.queryParams, { count: this.count }); $.extend(this.entityCollection.queryParams, { count: this.limit });
this.fetchCollection({ this.fetchCollection({
next: this.ui.nextAuditData, next: this.ui.nextAuditData,
nextClick: false, nextClick: false,
previous: this.ui.previousAuditData previous: this.ui.previousAuditData
}); });
this.entityCollection.comparator = function(model) {
return -model.get('timestamp');
}
}, },
bindEvents: function() {}, bindEvents: function() {},
getToOffset: function() { getToOffset: function() {
var toOffset = 0; var toOffset = 0;
if (this.entityCollection.models.length < this.count) { if (this.entityCollection.models.length < this.limit) {
toOffset = (this.getFromOffset() + (this.entityCollection.models.length)); toOffset = (this.getFromOffset() + (this.entityCollection.models.length));
} else { } else {
toOffset = (this.getFromOffset() + (this.entityCollection.models.length - 1)); toOffset = (this.getFromOffset() + (this.entityCollection.models.length - 1));
...@@ -98,7 +101,7 @@ define(['require', ...@@ -98,7 +101,7 @@ define(['require',
return toOffset; return toOffset;
}, },
getFromOffset: function(options) { getFromOffset: function(options) {
var count = (this.currPage - 1) * (this.count - 1); var count = (this.currPage - 1) * (this.limit - 1);
if (options && (options.nextClick || options.previousClick || this.entityCollection.models.length)) { if (options && (options.nextClick || options.previousClick || this.entityCollection.models.length)) {
return count + 1; return count + 1;
} else { } else {
...@@ -106,6 +109,7 @@ define(['require', ...@@ -106,6 +109,7 @@ define(['require',
} }
}, },
renderOffset: function(options) { renderOffset: function(options) {
var entityLength;
if (options.nextClick) { if (options.nextClick) {
options.previous.removeAttr("disabled"); options.previous.removeAttr("disabled");
if (this.entityCollection.length != 0) { if (this.entityCollection.length != 0) {
...@@ -118,7 +122,12 @@ define(['require', ...@@ -118,7 +122,12 @@ define(['require',
this.currPage--; this.currPage--;
} }
} }
this.ui.pageRecordText.html("Showing " + this.getFromOffset(options) + " - " + this.getToOffset()); if (this.entityCollection.models.length > 25) {
entityLength = this.entityCollection.models.length - 1;
} else {
entityLength = this.entityCollection.models.length
}
this.ui.pageRecordText.html("Showing <u>" + entityLength + " records</u> From " + this.getFromOffset(options) + " - " + this.getToOffset());
}, },
fetchCollection: function(options) { fetchCollection: function(options) {
var that = this; var that = this;
...@@ -134,13 +143,14 @@ define(['require', ...@@ -134,13 +143,14 @@ define(['require',
if (!(that.ui.pageRecordText instanceof jQuery)) { if (!(that.ui.pageRecordText instanceof jQuery)) {
return; return;
} }
if (that.entityCollection.models.length < that.count) { if (that.entityCollection.models.length < that.limit) {
options.previous.attr('disabled', true); options.previous.attr('disabled', true);
options.next.attr('disabled', true); options.next.attr('disabled', true);
} }
that.renderOffset(options); that.renderOffset(options);
that.entityCollection.sort();
if (that.entityCollection.models.length) { if (that.entityCollection.models.length) {
if (that.entityCollection && (that.entityCollection.models.length < that.count && that.currPage == 1) && that.next == that.entityCollection.last().get('eventKey')) { if (that.entityCollection && (that.entityCollection.models.length < that.limit && that.currPage == 1) && that.next == that.entityCollection.last().get('eventKey')) {
options.next.attr('disabled', true); options.next.attr('disabled', true);
options.previous.removeAttr("disabled"); options.previous.removeAttr("disabled");
} else { } else {
...@@ -165,7 +175,7 @@ define(['require', ...@@ -165,7 +175,7 @@ define(['require',
that.RAuditTableLayoutView.show(new TableLayout(_.extend({}, that.commonTableOptions, { that.RAuditTableLayoutView.show(new TableLayout(_.extend({}, that.commonTableOptions, {
columns: cols columns: cols
}))); })));
if (!(that.entityCollection.models.length < that.count)) { if (!(that.entityCollection.models.length < that.limit)) {
that.RAuditTableLayoutView.$el.find('table tr').last().hide(); that.RAuditTableLayoutView.$el.find('table tr').last().hide();
} }
}); });
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment