Commit 952d0696 by kevalbhatt

ATLAS-3382 : UI: Entity & Classification count are not getting updated after…

ATLAS-3382 : UI: Entity & Classification count are not getting updated after clicking on refresh button
parent a310bc29
...@@ -210,16 +210,16 @@ require(['App', ...@@ -210,16 +210,16 @@ require(['App',
this.enumDefCollection.url = UrlLinks.enumDefApiUrl(); this.enumDefCollection.url = UrlLinks.enumDefApiUrl();
this.enumDefCollection.modelAttrName = "enumDefs"; this.enumDefCollection.modelAttrName = "enumDefs";
this.classificationDefCollection = new VTagList(); this.classificationDefCollection = new VTagList();
this.entityCountCollection = new VTagList(); this.metricCollection = new VTagList();
this.entityCountCollection.url = UrlLinks.entityCountApi(); this.metricCollection.url = UrlLinks.metricsApiUrl();
this.entityCountCollection.modelAttrName = "data"; this.metricCollection.modelAttrName = "data";
App.appRouter = new Router({ App.appRouter = new Router({
entityDefCollection: this.entityDefCollection, entityDefCollection: this.entityDefCollection,
typeHeaders: this.typeHeaders, typeHeaders: this.typeHeaders,
enumDefCollection: this.enumDefCollection, enumDefCollection: this.enumDefCollection,
classificationDefCollection: this.classificationDefCollection, classificationDefCollection: this.classificationDefCollection,
entityCountCollection: this.entityCountCollection metricCollection: this.metricCollection
}); });
var startApp = function() { var startApp = function() {
...@@ -301,7 +301,7 @@ require(['App', ...@@ -301,7 +301,7 @@ require(['App',
} }
}); });
this.entityCountCollection.fetch({ this.metricCollection.fetch({
skipDefaultError: true, skipDefaultError: true,
complete: function() { complete: function() {
--that.asyncFetchCounter; --that.asyncFetchCounter;
......
...@@ -42,7 +42,7 @@ define([ ...@@ -42,7 +42,7 @@ define([
'*actions': 'defaultAction' '*actions': 'defaultAction'
}, },
initialize: function(options) { initialize: function(options) {
_.extend(this, _.pick(options, 'entityDefCollection', 'typeHeaders', 'enumDefCollection', 'classificationDefCollection', 'entityCountCollection')); _.extend(this, _.pick(options, 'entityDefCollection', 'typeHeaders', 'enumDefCollection', 'classificationDefCollection', 'metricCollection'));
this.showRegions(); this.showRegions();
this.bindCommonEvents(); this.bindCommonEvents();
this.listenTo(this, 'route', this.postRouteExecute, this); this.listenTo(this, 'route', this.postRouteExecute, this);
...@@ -58,7 +58,7 @@ define([ ...@@ -58,7 +58,7 @@ define([
'enumDefCollection': this.enumDefCollection, 'enumDefCollection': this.enumDefCollection,
'classificationDefCollection': this.classificationDefCollection, 'classificationDefCollection': this.classificationDefCollection,
'glossaryCollection': this.glossaryCollection, 'glossaryCollection': this.glossaryCollection,
'entityCountCollection': this.entityCountCollection 'metricCollection': this.metricCollection
} }
this.sharedObj = { this.sharedObj = {
searchTableColumns: {}, searchTableColumns: {},
...@@ -77,7 +77,8 @@ define([ ...@@ -77,7 +77,8 @@ define([
require([ require([
'views/site/Statistics', 'views/site/Statistics',
], function(Statistics) { ], function(Statistics) {
new Statistics(); new Statistics(_.extend({}, that.preFetchedCollectionLists,
that.sharedObj));
}); });
}); });
$('body').on('click', 'li.aboutAtlas', function() { $('body').on('click', 'li.aboutAtlas', function() {
......
...@@ -40,7 +40,7 @@ define(['require', 'utils/Enums', 'utils/Utils', 'underscore'], function(require ...@@ -40,7 +40,7 @@ define(['require', 'utils/Enums', 'utils/Utils', 'underscore'], function(require
enumDefApiUrl: function(name) { enumDefApiUrl: function(name) {
return this.getDefApiUrl('enum', name); return this.getDefApiUrl('enum', name);
}, },
entityCountApi: function(){ metricsApiUrl: function(){
return this.baseUrl + '/admin/metrics' return this.baseUrl + '/admin/metrics'
}, },
getDefApiUrl: function(type, name) { getDefApiUrl: function(type, name) {
......
...@@ -89,9 +89,9 @@ define(['require', ...@@ -89,9 +89,9 @@ define(['require',
* @constructs * @constructs
*/ */
initialize: function(options) { initialize: function(options) {
_.extend(this, _.pick(options, 'value', 'typeHeaders', 'searchVent', 'entityDefCollection', 'enumDefCollection', 'classificationDefCollection', 'searchTableColumns', 'searchTableFilters', 'entityCountCollection')); _.extend(this, _.pick(options, 'value', 'typeHeaders', 'searchVent', 'entityDefCollection', 'enumDefCollection', 'classificationDefCollection', 'searchTableColumns', 'searchTableFilters', 'metricCollection'));
this.type = "basic"; this.type = "basic";
this.entityCountObj = _.first(this.entityCountCollection.toJSON()); this.entityCountObj = _.first(this.metricCollection.toJSON());
this.filterTypeSelected = []; this.filterTypeSelected = [];
var param = Utils.getUrlState.getQueryParams(); var param = Utils.getUrlState.getQueryParams();
this.query = { this.query = {
...@@ -358,16 +358,35 @@ define(['require', ...@@ -358,16 +358,35 @@ define(['require',
includeDE: null includeDE: null
}), param); }), param);
}, },
fetchCollection: function(value) {
this.typeHeaders.fetch({ reset: true });
},
onRefreshButton: function() { onRefreshButton: function() {
this.fetchCollection(); var that = this,
//to check url query param contain type or not apiCount = 2,
var checkURLValue = Utils.getUrlState.getQueryParams(this.url); updateSearchList = function() {
if (this.searchVent && (_.has(checkURLValue, "tag") || _.has(checkURLValue, "type") || _.has(checkURLValue, "query"))) { if (apiCount === 0) {
this.searchVent.trigger('search:refresh'); that.initializeValues();
var checkURLValue = Utils.getUrlState.getQueryParams(that.url);
if (that.searchVent && (_.has(checkURLValue, "tag") || _.has(checkURLValue, "type") || _.has(checkURLValue, "query"))) {
that.searchVent.trigger('search:refresh');
}
}
};
this.metricCollection.fetch({
skipDefaultError: true,
complete: function() {
--apiCount;
that.entityCountObj = _.first(that.metricCollection.toJSON());
updateSearchList();
} }
});
this.typeHeaders.fetch({
skipDefaultError: true,
silent: true,
complete: function() {
--apiCount;
updateSearchList();
}
});
}, },
advancedInfo: function(e) { advancedInfo: function(e) {
require([ require([
......
...@@ -85,11 +85,9 @@ define(['require', ...@@ -85,11 +85,9 @@ define(['require',
}, },
bindEvents: function() {}, bindEvents: function() {},
fetchMetricData: function(options) { fetchMetricData: function(options) {
var that = this, var that = this;
entityCountCollection = new VTagList(); this.metricCollection.fetch({
entityCountCollection.url = UrlLinks.entityCountApi(); skipDefaultError: true,
entityCountCollection.modelAttrName = "data";
entityCountCollection.fetch({
success: function(data) { success: function(data) {
var data = _.first(data.toJSON()); var data = _.first(data.toJSON());
that.renderStats({ valueObject: data.general.stats, dataObject: data.general }); that.renderStats({ valueObject: data.general.stats, dataObject: data.general });
......
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