You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ambari.apache.org by ha...@apache.org on 2020/11/02 10:41:33 UTC

[ambari] branch revert-3247-custom_metrics_download_file_name created (now c9293df)

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

hapylestat pushed a change to branch revert-3247-custom_metrics_download_file_name
in repository https://gitbox.apache.org/repos/asf/ambari.git.


      at c9293df  Revert "AMBARI-25573 Ambari Metrics save as JSON/CSV use custom fileName instead of default name. (#3247)"

This branch includes the following new commits:

     new c9293df  Revert "AMBARI-25573 Ambari Metrics save as JSON/CSV use custom fileName instead of default name. (#3247)"

The 1 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.



[ambari] 01/01: Revert "AMBARI-25573 Ambari Metrics save as JSON/CSV use custom fileName instead of default name. (#3247)"

Posted by ha...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

hapylestat pushed a commit to branch revert-3247-custom_metrics_download_file_name
in repository https://gitbox.apache.org/repos/asf/ambari.git

commit c9293df52b3120a1036d64f6567259be22efcaa7
Author: hapylestat <ha...@gmail.com>
AuthorDate: Mon Nov 2 12:41:23 2020 +0200

    Revert "AMBARI-25573 Ambari Metrics save as JSON/CSV use custom fileName instead of default name. (#3247)"
    
    This reverts commit 0475c203c1c5b16dfe5b1de4d2715af121c479d2.
---
 .../mixins/common/widgets/export_metrics_mixin.js  | 10 ++----
 .../app/views/common/widget/graph_widget_view.js   | 39 +++++++++-------------
 .../views/common/widget/graph_widget_view_test.js  |  2 +-
 3 files changed, 19 insertions(+), 32 deletions(-)

diff --git a/ambari-web/app/mixins/common/widgets/export_metrics_mixin.js b/ambari-web/app/mixins/common/widgets/export_metrics_mixin.js
index 00ba552..aa4f77c 100644
--- a/ambari-web/app/mixins/common/widgets/export_metrics_mixin.js
+++ b/ambari-web/app/mixins/common/widgets/export_metrics_mixin.js
@@ -63,20 +63,14 @@ App.ExportMetricsMixin = Em.Mixin.create({
     });
   },
 
-  getCustomFileName: function () {
-    return this.get('targetView').title.replace(/\s+/g, '_').toLowerCase();
-  },
-
   exportGraphDataSuccessCallback: function (response, request, params) {
     var seriesData = this.get('targetView').getData(response);
     if (!seriesData.length) {
       App.showAlertPopup(Em.I18n.t('graphs.noData.title'), Em.I18n.t('graphs.noData.tooltip.title'));
     } else {
       var fileType = params.isCSV ? 'csv' : 'json',
-          fileName = (Em.isEmpty(this.get('targetView') || Em.isEmpty(this.get('targetView').title)) ?
-          'data' : this.getCustomFileName()) + '.' + fileType,
-          data = params.isCSV ? this.prepareCSV(seriesData) : JSON.stringify(seriesData, this.jsonReplacer(), 4);
-
+        fileName = 'data.' + fileType,
+        data = params.isCSV ? this.prepareCSV(seriesData) : JSON.stringify(seriesData, this.jsonReplacer(), 4);
       fileUtils.downloadTextFile(data, fileType, fileName);
     }
   },
diff --git a/ambari-web/app/views/common/widget/graph_widget_view.js b/ambari-web/app/views/common/widget/graph_widget_view.js
index c1b7020..324358e 100644
--- a/ambari-web/app/views/common/widget/graph_widget_view.js
+++ b/ambari-web/app/views/common/widget/graph_widget_view.js
@@ -364,28 +364,21 @@ App.GraphWidgetView = Em.View.extend(App.WidgetMixin, App.ExportMetricsMixin, {
     }.observes('parentView.data')
   }),
 
-    getCustomFileName: function () {
-        // get current service name if it exists.
-        var currentServiceName = Em.isEmpty(this.get('controller.content.serviceName')) ? "" : this.get('controller.content.serviceName') + '_';
-        // serviceName_widgetName_metricName
-        return (currentServiceName + this.get('content.widgetName').replace(/\s+/g, '_')).toLowerCase();
-    },
-
-    exportGraphData: function (event) {
-        this.set('isExportMenuHidden', true);
-        var data,
-            isCSV = !!event.context,
-            fileType = isCSV ? 'csv' : 'json',
-            fileName = (Em.isEmpty(this.get('content.widgetName')) ? 'data' : this.getCustomFileName()) + '.' + fileType,
-            metrics = this.get('data'),
-            hasData = Em.isArray(metrics) && metrics.some(function (item) {
-                return Em.isArray(item.data);
-            });
-        if (hasData) {
-            data = isCSV ? this.prepareCSV(metrics) : JSON.stringify(metrics, this.jsonReplacer(), 4);
-            fileUtils.downloadTextFile(data, fileType, fileName);
-        } else {
-            App.showAlertPopup(Em.I18n.t('graphs.noData.title'), Em.I18n.t('graphs.noData.tooltip.title'));
-        }
+  exportGraphData: function (event) {
+    this.set('isExportMenuHidden', true);
+    var data,
+      isCSV = !!event.context,
+      fileType = isCSV ? 'csv' : 'json',
+      fileName = 'data.' + fileType,
+      metrics = this.get('data'),
+      hasData = Em.isArray(metrics) && metrics.some(function (item) {
+        return Em.isArray(item.data);
+      });
+    if (hasData) {
+      data = isCSV ? this.prepareCSV(metrics) : JSON.stringify(metrics, this.jsonReplacer(), 4);
+      fileUtils.downloadTextFile(data, fileType, fileName);
+    } else {
+      App.showAlertPopup(Em.I18n.t('graphs.noData.title'), Em.I18n.t('graphs.noData.tooltip.title'));
     }
+  }
 });
diff --git a/ambari-web/test/views/common/widget/graph_widget_view_test.js b/ambari-web/test/views/common/widget/graph_widget_view_test.js
index 5a12cd1..3a35fd8 100644
--- a/ambari-web/test/views/common/widget/graph_widget_view_test.js
+++ b/ambari-web/test/views/common/widget/graph_widget_view_test.js
@@ -815,4 +815,4 @@ describe('App.GraphWidgetView', function () {
     //  });
     //});
   });
-});
+});
\ No newline at end of file