You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@pinot.apache.org by aa...@apache.org on 2019/02/15 17:53:48 UTC

[incubator-pinot] branch master updated: [TE] frontend - aaronucsd/fixed the alert and subscription error messages (#3841)

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

aaronucsd 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 8ecfbcb  [TE] frontend - aaronucsd/fixed the alert and subscription error messages (#3841)
8ecfbcb is described below

commit 8ecfbcb7531bc19b24e2fcd2cfbdb7ed0be65ea4
Author: Long Huynh <lo...@linkedin.com>
AuthorDate: Fri Feb 15 09:53:43 2019 -0800

    [TE] frontend - aaronucsd/fixed the alert and subscription error messages (#3841)
---
 .../app/pods/components/yaml-editor/component.js   | 58 ++++++++++++++--------
 .../app/pods/components/yaml-editor/template.hbs   | 24 ++++++---
 2 files changed, 54 insertions(+), 28 deletions(-)

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 26bf14c..10a8df0 100644
--- a/thirdeye/thirdeye-frontend/app/pods/components/yaml-editor/component.js
+++ b/thirdeye/thirdeye-frontend/app/pods/components/yaml-editor/component.js
@@ -22,7 +22,7 @@
  */
 
 import Component from '@ember/component';
-import { computed, set, get, getProperties } from '@ember/object';
+import { computed, set, get, getProperties, setProperties } from '@ember/object';
 import { checkStatus } from 'thirdeye-frontend/utils/utils';
 import { yamlAlertProps, yamlAlertSettings } from 'thirdeye-frontend/utils/constants';
 import yamljs from 'yamljs';
@@ -49,8 +49,9 @@ export default Component.extend({
   isEditMode: false,
   showSettings: true,
   disableYamlSave: true,
-  errorMsg: '',
-  alertYaml: null,           // The YAML for the anomaly alert detection
+  detectionMsg: '',                   //General alert failures
+  subscriptionMsg: '',                //General subscription failures
+  alertYaml: null,                // The YAML for the anomaly alert detection
   detectionSettingsYaml:  null,   // The YAML for the subscription group
   yamlAlertProps: yamlAlertProps,
   yamlAlertSettings: yamlAlertSettings,
@@ -110,11 +111,19 @@ export default Component.extend({
   ),
 
 
-  isErrorMsg: computed(
-    'errorMsg',
+  isDetectionMsg: computed(
+    'detectionMsg',
     function() {
-      const errorMsg = get(this, 'errorMsg');
-      return errorMsg !== '';
+      const detectionMsg = get(this, 'detectionMsg');
+      return detectionMsg !== '';
+    }
+  ),
+
+  isSubscriptionMsg: computed(
+    'subscriptionMsg',
+    function() {
+      const subscriptionMsg = get(this, 'subscriptionMsg');
+      return subscriptionMsg !== '';
     }
   ),
 
@@ -323,7 +332,7 @@ export default Component.extend({
         return get(this, '_loadAutocompleteById')(currentMetric)
           .then(resultObj => {
             const { filters, dimensions } = resultObj;
-            this.setProperties({
+            setProperties(this, {
               dimensionsCache: dimensions,
               filtersCache: filters
             });
@@ -348,17 +357,22 @@ export default Component.extend({
      * Activates 'Create changes' button and stores YAML content in alertYaml
      */
     onYMLSelectorAction(value) {
-      set(this, 'disableYamlSave', false);
-      set(this, 'alertYaml', value);
-      set(this, 'errorMsg', '');
+      setProperties(this, {
+        disableYamlSave: false,
+        alertYaml: value,
+        detectionMsg: '',
+        subscriptionMsg: ''
+      });
     },
 
     /**
      * Activates 'Create changes' button and stores YAML content in detectionSettingsYaml
      */
     onYMLSettingsSelectorAction(value) {
-      set(this, 'disableYamlSave', false);
-      set(this, 'detectionSettingsYaml', value);
+      setProperties(this, {
+        disableYamlSave: false,
+        detectionSettingsYaml: value
+      });
     },
 
     /**
@@ -380,16 +394,20 @@ export default Component.extend({
 
       fetch(url, postProps).then((res) => {
         res.json().then((result) => {
-          if (result && result.message) {
-            set(this, 'errorMsg', result.message);
-          }
-          if (result.detectionAlertConfigId && result.detectionConfigId) {
-            notifications.success('Save alert yaml successfully.', 'Saved');
+          if(result){
+            if (result.detectionMsg) {
+              set(this, 'detectionMsg', result.detectionMsg);
+            }
+            if (result.subscriptionMsg) {
+              set(this, 'subscriptionMsg', result.subscriptionMsg);
+            }
+            if (result.detectionAlertConfigId && result.detectionConfigId) {
+              notifications.success('Created alert successfully.', 'Created');
+            }
           }
         });
-
       }).catch((error) => {
-        notifications.error('Save alert yaml file failed.', error);
+        notifications.error('Create alert failed.', error);
       });
     },
 
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 0610a82..1a8a5f6 100644
--- a/thirdeye/thirdeye-frontend/app/pods/components/yaml-editor/template.hbs
+++ b/thirdeye/thirdeye-frontend/app/pods/components/yaml-editor/template.hbs
@@ -38,6 +38,14 @@
     }}
   </div>
   <div class="col-xs-12">
+    {{#if isDetectionMsg}}
+      <div class="yaml-editor-msg">
+        <p class="yaml-editor-msg__icon"><i class="yaml-editor-msg__icon--error glyphicon glyphicon-remove-circle"></i>Error in alert yaml</p>
+        <p>Message: {{detectionMsg}}</p>
+      </div>
+    {{/if}}
+  </div>
+  <div class="col-xs-12">
     {{#bs-accordion onChange=(action "changeAccordion") as |acc|}}
       {{#acc.item value=preview as |aitem|}}
         {{#aitem.title}}
@@ -108,15 +116,15 @@
         mode="ace/mode/yaml"
       }}
     </div>
+    <div class="col-xs-12">
+      {{#if isSubscriptionMsg}}
+        <div class="yaml-editor-msg">
+          <p class="yaml-editor-msg__icon"><i class="yaml-editor-msg__icon--error glyphicon glyphicon-remove-circle"></i>Error in the subscription yaml</p>
+          <p>Message: {{subscriptionMsg}}</p>
+        </div>
+      {{/if}}
+    </div>
   {{/if}}
-  <div class="col-xs-12">
-    {{#if isErrorMsg}}
-      <div class="yaml-editor-msg">
-        <p class="yaml-editor-msg__icon"><i class="yaml-editor-msg__icon--error glyphicon glyphicon-remove-circle"></i>Error in the yaml file</p>
-        <p>Message: {{errorMsg}}</p>
-      </div>
-    {{/if}}
-  </div>
 </fieldset>
 
 <fieldset class="te-form__section-submit">


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