You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@pinot.apache.org by ji...@apache.org on 2019/02/27 18:44:20 UTC

[incubator-pinot] branch master updated: [TE] frontend - fix some bugs with alert details graph on range change (#3876)

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

jihao pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-pinot.git


The following commit(s) were added to refs/heads/master by this push:
     new 52a9559  [TE] frontend - fix some bugs with alert details graph on range change (#3876)
52a9559 is described below

commit 52a9559625877e38417dba5d06b95034231aca2d
Author: Harley Jackson <ha...@gmail.com>
AuthorDate: Wed Feb 27 10:44:10 2019 -0800

    [TE] frontend - fix some bugs with alert details graph on range change (#3876)
---
 .../app/pods/components/alert-details/component.js | 46 ++++++++++++----------
 .../pods/components/timeseries-chart/component.js  |  1 +
 .../app/pods/components/yaml-editor/component.js   |  4 +-
 .../app/pods/components/yaml-editor/template.hbs   |  4 +-
 .../app/pods/manage/explore-new/route.js           |  6 ++-
 .../app/pods/manage/explore-new/template.hbs       |  1 +
 6 files changed, 36 insertions(+), 26 deletions(-)

diff --git a/thirdeye/thirdeye-frontend/app/pods/components/alert-details/component.js b/thirdeye/thirdeye-frontend/app/pods/components/alert-details/component.js
index 3ec89e6..9c38947 100644
--- a/thirdeye/thirdeye-frontend/app/pods/components/alert-details/component.js
+++ b/thirdeye/thirdeye-frontend/app/pods/components/alert-details/component.js
@@ -23,6 +23,7 @@ import { getYamlPreviewAnomalies,
   getFormattedDuration,
   anomalyResponseMapNew,
   anomalyResponseObj,
+  anomalyResponseObjNew,
   updateAnomalyFeedback,
   verifyAnomalyFeedback  } from 'thirdeye-frontend/utils/anomaly';
 import { inject as service } from '@ember/service';
@@ -46,7 +47,7 @@ export default Component.extend({
   anomalyMapping: {},
   timeseries: null,
   isLoading: false,
-  analysisRange: [moment().subtract(1, 'week').startOf('hour').valueOf(), moment().startOf('hour').valueOf()],
+  analysisRange: [moment().add(1, 'day').startOf('day').subtract(1, 'week').valueOf(), moment().add(1, 'day').startOf('day').valueOf()],
   isPendingData: false,
   colorMapping: colorMapping,
   zoom: {
@@ -105,6 +106,7 @@ export default Component.extend({
       } else {
         this._fetchTimeseries();
       }
+
     }),
 
   /**
@@ -227,7 +229,7 @@ export default Component.extend({
   axis: computed(
     'analysisRange',
     function () {
-      const analysisRange = getProperties(this, 'analysisRange');
+      const analysisRange = get(this, 'analysisRange');
 
       return {
         y: {
@@ -350,7 +352,6 @@ export default Component.extend({
         tableData.push(tableRow);
         i++;
       });
-
       return tableData;
     }
   ),
@@ -426,8 +427,8 @@ export default Component.extend({
     'analysisRange', 'startDate', 'endDate', 'duration',
     function() {
       const analysisRange = get(this, 'analysisRange');
-      const startDate = Number(analysisRange[0]) || Number(get(this, 'startDate'));
-      const endDate = Number(analysisRange[1]) || Number(get(this, 'endDate'));
+      const startDate = Number(analysisRange[0]);
+      const endDate = Number(analysisRange[1]);
       const duration = get(this, 'duration') || DEFAULT_ACTIVE_DURATION;
       const predefinedRanges = {
         'Today': [moment().startOf('day'), moment().startOf('day').add(1, 'days')],
@@ -506,7 +507,7 @@ export default Component.extend({
     this._super(...arguments);
     const isPreviewMode = get(this, 'isPreviewMode');
     if (!isPreviewMode) {
-      set(this, 'analysisRange', [moment().subtract(1, 'month').startOf('hour').valueOf(), moment().startOf('hour').valueOf()]);
+      set(this, 'analysisRange', [moment().add(1, 'day').subtract(1, 'month').startOf('day').valueOf(), moment().add(1, 'day').startOf('day').valueOf()]);
       set(this, 'duration', '1m');
       this._fetchAnomalies();
     } else {
@@ -623,15 +624,14 @@ export default Component.extend({
      * @param {String} selectedResponse - user-selected anomaly feedback option
      * @param {Object} inputObj - the selection object
      */
-    onChangeAnomalyFeedback: async function(anomalyRecord, selectedResponse, inputObj) {
-      const labelMap = get(this, 'labelMap');
-      const loadedResponsesArr = [];
-      const newOptionsArr = [];
-      // Update select field
-      set(inputObj, 'selected', selectedResponse);
+    onChangeAnomalyFeedback: async function(anomalyRecord, selectedResponse) {
+      const anomalies = get(this, 'anomalies');
       // Reset status icon
       set(this, 'renderStatusIcon', false);
+  
       const responseObj = anomalyResponseObj.find(res => res.name === selectedResponse);
+      // get the response object from anomalyResponseObjNew
+      const newFeedbackValue = anomalyResponseObjNew.find(res => res.name === selectedResponse).value;
       try {
         // Save anomaly feedback
         await updateAnomalyFeedback(anomalyRecord.anomalyId, responseObj.value);
@@ -642,24 +642,28 @@ export default Component.extend({
         const keyPresent = filterMap && Object.keys(filterMap).find(key => responseObj.status.includes(key));
         if (keyPresent) {
           this.set('labelResponse', {
-            anomalyId: anomalyRecord.id,
+            anomalyId: anomalyRecord.anomalyId,
             showResponseSaved: true,
             showResponseFailed: false
           });
 
-          // Collect all available new labels
-          loadedResponsesArr.push(responseObj.status, ...get(this, 'anomalyData').mapBy('anomalyFeedback'));
-          loadedResponsesArr.forEach((response) => {
-            if (labelMap[response]) { newOptionsArr.push(labelMap[response]); }
-          });
-          // Update resolutionOptions array - we may have a new option now
-          set(this, 'resolutionOptions', [ ...new Set([ 'All Resolutions', ...newOptionsArr ])]);
+          // replace anomaly feedback with selectedFeedback
+          let i = 0;
+          let found = false;
+          while (i < anomalies.length && !found) {
+            if (anomalies[i].id === anomalyRecord.anomalyId) {
+              anomalies[i].feedback.feedbackType = newFeedbackValue;
+              found = true;
+            }
+            i++;
+          }
+          set(this, 'anomalies', anomalies);
         } else {
           throw 'Response not saved';
         }
       } catch (err) {
         this.set('labelResponse', {
-          anomalyId: anomalyRecord.id,
+          anomalyId: anomalyRecord.anomalyId,
           showResponseSaved: false,
           showResponseFailed: true
         });
diff --git a/thirdeye/thirdeye-frontend/app/pods/components/timeseries-chart/component.js b/thirdeye/thirdeye-frontend/app/pods/components/timeseries-chart/component.js
index 46e9085..3e4b29f 100644
--- a/thirdeye/thirdeye-frontend/app/pods/components/timeseries-chart/component.js
+++ b/thirdeye/thirdeye-frontend/app/pods/components/timeseries-chart/component.js
@@ -192,6 +192,7 @@ export default Component.extend({
     const chart = this.get('_chart');
     chart.regions(diffConfig.regions);
     chart.axis.range(this._makeAxisRange(diffConfig.axis));
+    chart.unzoom();
     chart.load(diffConfig);
     this._updateCache();
   },
diff --git a/thirdeye/thirdeye-frontend/app/pods/components/yaml-editor/component.js b/thirdeye/thirdeye-frontend/app/pods/components/yaml-editor/component.js
index 10a8df0..b7b1c87 100644
--- a/thirdeye/thirdeye-frontend/app/pods/components/yaml-editor/component.js
+++ b/thirdeye/thirdeye-frontend/app/pods/components/yaml-editor/component.js
@@ -60,6 +60,7 @@ export default Component.extend({
   currentYamlAlertOriginal: '',
   currentYamlSettingsOriginal: '',
   toggleCollapsed: true,
+  alertDataIsCurrent: true,
 
 
 
@@ -361,7 +362,8 @@ export default Component.extend({
         disableYamlSave: false,
         alertYaml: value,
         detectionMsg: '',
-        subscriptionMsg: ''
+        subscriptionMsg: '',
+        alertDataIsCurrent: false
       });
     },
 
diff --git a/thirdeye/thirdeye-frontend/app/pods/components/yaml-editor/template.hbs b/thirdeye/thirdeye-frontend/app/pods/components/yaml-editor/template.hbs
index 41a8a34..9aaae46 100644
--- a/thirdeye/thirdeye-frontend/app/pods/components/yaml-editor/template.hbs
+++ b/thirdeye/thirdeye-frontend/app/pods/components/yaml-editor/template.hbs
@@ -49,7 +49,7 @@
     {{#bs-accordion onChange=(action "changeAccordion") as |acc|}}
       {{#acc.item value=preview as |aitem|}}
         {{#aitem.title}}
-          <section class="dashboard-container__title">Preview alert [Beta] {{if toggleCollapsed "/ Enter YAML configuration to preview alert." ""}}
+          <section class="dashboard-container__title thirdeye-link-secondary">Preview alert [Beta] {{if toggleCollapsed "/ Enter YAML configuration to preview alert." ""}}
             <span class="pull-right"><i class="glyphicon glyphicon-menu-{{if toggleCollapsed "down" "up"}}"></i></span>
           </section>
         {{/aitem.title}}
@@ -57,7 +57,7 @@
           {{#alert-details
             isPreviewMode=true
             alertYaml=alertYaml
-            dataIsCurrent=disableYamlSave
+            dataIsCurrent=alertDataIsCurrent
           }}
             {{yield}}
           {{/alert-details}}
diff --git a/thirdeye/thirdeye-frontend/app/pods/manage/explore-new/route.js b/thirdeye/thirdeye-frontend/app/pods/manage/explore-new/route.js
index b554704..fd5efd4 100644
--- a/thirdeye/thirdeye-frontend/app/pods/manage/explore-new/route.js
+++ b/thirdeye/thirdeye-frontend/app/pods/manage/explore-new/route.js
@@ -47,7 +47,8 @@ export default Route.extend({
           this.setProperties({
             detectionYaml: yaml,
             alertId: alertId,
-            metricUrn: alert_json.properties.nested[0].nestedMetricUrns[0]
+            metricUrn: alert_json.properties.nested[0].nestedMetricUrns[0],
+            metricUrnList: alert_json.properties.nested[0].nestedMetricUrns
           });
         }
       }
@@ -80,7 +81,8 @@ export default Route.extend({
       detectionYaml: get(this, 'detectionYaml').yaml,
       subscriptionGroups: get(this, 'subscriptionGroups'),
       subscriptionGroupYamlDisplay,
-      metricUrn: get(this, 'metricUrn')
+      metricUrn: get(this, 'metricUrn'),
+      metricUrnList: get(this, 'metricUrnList')
     });
   },
 
diff --git a/thirdeye/thirdeye-frontend/app/pods/manage/explore-new/template.hbs b/thirdeye/thirdeye-frontend/app/pods/manage/explore-new/template.hbs
index e86a26e..ff5671f 100644
--- a/thirdeye/thirdeye-frontend/app/pods/manage/explore-new/template.hbs
+++ b/thirdeye/thirdeye-frontend/app/pods/manage/explore-new/template.hbs
@@ -29,6 +29,7 @@
         dataIsCurrent=true
         alertId=model.alertId
         metricUrn=model.metricUrn
+        metricUrnList=model.metricUrnList
       }}
     {{/if}}
   </div>


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@pinot.apache.org
For additional commands, e-mail: commits-help@pinot.apache.org