This is an automated email from the ASF dual-hosted git repository.

kbhatt pushed a commit to branch branch-2.0
in repository https://gitbox.apache.org/repos/asf/atlas.git

commit 120ef7a00eda19df3d1a7c56d569bb3842476def
Author: kevalbhatt <[email protected]>
AuthorDate: Wed Aug 21 19:58:57 2019 +0530

    ATLAS-3382 : UI: Entity & Classification count are not getting updated 
after clicking on refresh button
---
 dashboardv2/public/js/main.js                      | 10 +++---
 dashboardv2/public/js/router/Router.js             |  7 ++--
 dashboardv2/public/js/utils/UrlLinks.js            |  2 +-
 .../public/js/views/search/SearchLayoutView.js     | 41 ++++++++++++++++------
 dashboardv2/public/js/views/site/Statistics.js     |  8 ++---
 5 files changed, 43 insertions(+), 25 deletions(-)

diff --git a/dashboardv2/public/js/main.js b/dashboardv2/public/js/main.js
index cb98f12..7b33da7 100644
--- a/dashboardv2/public/js/main.js
+++ b/dashboardv2/public/js/main.js
@@ -210,16 +210,16 @@ require(['App',
     this.enumDefCollection.url = UrlLinks.enumDefApiUrl();
     this.enumDefCollection.modelAttrName = "enumDefs";
     this.classificationDefCollection = new VTagList();
-    this.entityCountCollection = new VTagList();
-    this.entityCountCollection.url = UrlLinks.entityCountApi();
-    this.entityCountCollection.modelAttrName = "data";
+    this.metricCollection = new VTagList();
+    this.metricCollection.url = UrlLinks.metricsApiUrl();
+    this.metricCollection.modelAttrName = "data";
 
     App.appRouter = new Router({
         entityDefCollection: this.entityDefCollection,
         typeHeaders: this.typeHeaders,
         enumDefCollection: this.enumDefCollection,
         classificationDefCollection: this.classificationDefCollection,
-        entityCountCollection: this.entityCountCollection
+        metricCollection: this.metricCollection
     });
 
     var startApp = function() {
@@ -301,7 +301,7 @@ require(['App',
         }
     });
 
-    this.entityCountCollection.fetch({
+    this.metricCollection.fetch({
         skipDefaultError: true,
         complete: function() {
             --that.asyncFetchCounter;
diff --git a/dashboardv2/public/js/router/Router.js 
b/dashboardv2/public/js/router/Router.js
index 99a5d92..7965c95 100644
--- a/dashboardv2/public/js/router/Router.js
+++ b/dashboardv2/public/js/router/Router.js
@@ -42,7 +42,7 @@ define([
             '*actions': 'defaultAction'
         },
         initialize: function(options) {
-            _.extend(this, _.pick(options, 'entityDefCollection', 
'typeHeaders', 'enumDefCollection', 'classificationDefCollection', 
'entityCountCollection'));
+            _.extend(this, _.pick(options, 'entityDefCollection', 
'typeHeaders', 'enumDefCollection', 'classificationDefCollection', 
'metricCollection'));
             this.showRegions();
             this.bindCommonEvents();
             this.listenTo(this, 'route', this.postRouteExecute, this);
@@ -58,7 +58,7 @@ define([
                 'enumDefCollection': this.enumDefCollection,
                 'classificationDefCollection': 
this.classificationDefCollection,
                 'glossaryCollection': this.glossaryCollection,
-                'entityCountCollection': this.entityCountCollection
+                'metricCollection': this.metricCollection
             }
             this.sharedObj = {
                 searchTableColumns: {},
@@ -77,7 +77,8 @@ define([
                 require([
                     'views/site/Statistics',
                 ], function(Statistics) {
-                    new Statistics();
+                    new Statistics(_.extend({}, that.preFetchedCollectionLists,
+                        that.sharedObj));
                 });
             });
             $('body').on('click', 'li.aboutAtlas', function() {
diff --git a/dashboardv2/public/js/utils/UrlLinks.js 
b/dashboardv2/public/js/utils/UrlLinks.js
index 1bc5949..f6e1795 100644
--- a/dashboardv2/public/js/utils/UrlLinks.js
+++ b/dashboardv2/public/js/utils/UrlLinks.js
@@ -40,7 +40,7 @@ define(['require', 'utils/Enums', 'utils/Utils', 
'underscore'], function(require
         enumDefApiUrl: function(name) {
             return this.getDefApiUrl('enum', name);
         },
-        entityCountApi: function(){
+        metricsApiUrl: function(){
             return this.baseUrl + '/admin/metrics'
         },
         getDefApiUrl: function(type, name) {
diff --git a/dashboardv2/public/js/views/search/SearchLayoutView.js 
b/dashboardv2/public/js/views/search/SearchLayoutView.js
index 76edd58..3851bca 100644
--- a/dashboardv2/public/js/views/search/SearchLayoutView.js
+++ b/dashboardv2/public/js/views/search/SearchLayoutView.js
@@ -89,9 +89,9 @@ define(['require',
              * @constructs
              */
             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.entityCountObj = 
_.first(this.entityCountCollection.toJSON());
+                this.entityCountObj = _.first(this.metricCollection.toJSON());
                 this.filterTypeSelected = [];
                 var param = Utils.getUrlState.getQueryParams();
                 this.query = {
@@ -358,16 +358,35 @@ define(['require',
                         includeDE: null
                     }), param);
             },
-            fetchCollection: function(value) {
-                this.typeHeaders.fetch({ reset: true });
-            },
             onRefreshButton: function() {
-                this.fetchCollection();
-                //to check url query param contain type or not
-                var checkURLValue = Utils.getUrlState.getQueryParams(this.url);
-                if (this.searchVent && (_.has(checkURLValue, "tag") || 
_.has(checkURLValue, "type") || _.has(checkURLValue, "query"))) {
-                    this.searchVent.trigger('search:refresh');
-                }
+                var that = this,
+                    apiCount = 2,
+                    updateSearchList = function() {
+                        if (apiCount === 0) {
+                            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) {
                 require([
diff --git a/dashboardv2/public/js/views/site/Statistics.js 
b/dashboardv2/public/js/views/site/Statistics.js
index 8929e54..8befe68 100644
--- a/dashboardv2/public/js/views/site/Statistics.js
+++ b/dashboardv2/public/js/views/site/Statistics.js
@@ -85,11 +85,9 @@ define(['require',
             },
             bindEvents: function() {},
             fetchMetricData: function(options) {
-                var that = this,
-                    entityCountCollection = new VTagList();
-                entityCountCollection.url = UrlLinks.entityCountApi();
-                entityCountCollection.modelAttrName = "data";
-                entityCountCollection.fetch({
+                var that = this;
+                this.metricCollection.fetch({
+                    skipDefaultError: true,
                     success: function(data) {
                         var data = _.first(data.toJSON());
                         that.renderStats({ valueObject: data.general.stats, 
dataObject: data.general });

Reply via email to