ambari-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From GitBox <...@apache.org>
Subject [GitHub] [ambari] pidhaietsdp commented on a change in pull request #3247: [AMBARI-25573] Ambari Metrics save as JSON/CSV use custom fileName instead of default name.
Date Tue, 27 Oct 2020 13:42:29 GMT

pidhaietsdp commented on a change in pull request #3247:
URL: https://github.com/apache/ambari/pull/3247#discussion_r512700039



##########
File path: ambari-web/app/views/common/widget/graph_widget_view.js
##########
@@ -364,21 +364,28 @@ App.GraphWidgetView = Em.View.extend(App.WidgetMixin, App.ExportMetricsMixin,
{
     }.observes('parentView.data')
   }),
 
-  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'));
+    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(/ /g, '_')).toLowerCase();

Review comment:
       It would be more clear to use **.replace(/ \s+/g, '_')**
   Everything else looks good for me.




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



Mime
View raw message