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 20dbcc4  [TE] frontend - harleyjj/yaml-editor - improves yaml 
autocomplete (#3732)
20dbcc4 is described below

commit 20dbcc4de7a8b6210d1c221c79f4e8dcc907bf09
Author: Harley Jackson <[email protected]>
AuthorDate: Wed Feb 6 13:58:35 2019 -0800

    [TE] frontend - harleyjj/yaml-editor - improves yaml autocomplete (#3732)
    
    Instead of replacing the entire Yaml field upon selecting a metric name, it 
only replaces the metric name row and dataset row.
---
 .../app/pods/components/yaml-editor/component.js   | 24 ++++++--
 thirdeye/thirdeye-frontend/app/utils/constants.js  | 67 ----------------------
 2 files changed, 19 insertions(+), 72 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 1c55b0a..1ef8267 100644
--- a/thirdeye/thirdeye-frontend/app/pods/components/yaml-editor/component.js
+++ b/thirdeye/thirdeye-frontend/app/pods/components/yaml-editor/component.js
@@ -24,7 +24,7 @@
 import Component from '@ember/component';
 import { computed, set, get, getProperties } from '@ember/object';
 import { checkStatus } from 'thirdeye-frontend/utils/utils';
-import { yamlAlertProps, yamlAlertSettings, yamIt } from 
'thirdeye-frontend/utils/constants';
+import { yamlAlertProps, yamlAlertSettings } from 
'thirdeye-frontend/utils/constants';
 import yamljs from 'yamljs';
 import RSVP from "rsvp";
 import fetch from 'fetch';
@@ -152,7 +152,8 @@ export default Component.extend({
    * @method _buildYamlSuggestions
    * @return Promise
    */
-  _buildYamlSuggestions(currentMetric, yamlAsObject, prefix, noResultsArray, 
filtersCache, dimensionsCache) {
+  _buildYamlSuggestions(currentMetric, yamlAsObject, prefix, noResultsArray,
+    filtersCache, dimensionsCache, position) {
     // holds default result to return if all checks fail
     let defaultReturn = Promise.resolve(noResultsArray);
     // when metric is being autocompleted, entire text field will be replaced 
and metricId stored in editor
@@ -166,12 +167,21 @@ export default Component.extend({
               return {
                 value: metricname,
                 caption: metric.alias,
+                row: position.row,
+                column: position.column,
                 metricname,
                 dataset,
                 id: metric.id,
                 completer:{
                   insertMatch: (editor, data) => {
-                    editor.setValue(yamIt(data.metricname, data.dataset));
+                    editor.session.replace({
+                      start: { row: data.row, column: 0 },
+                      end: { row: data.row, column: Number.MAX_VALUE }},
+                    `metric: ${data.metricname}`);
+                    editor.session.replace({
+                      start: { row: data.row+2, column: 0},
+                      end: { row: data.row+2, column: Number.MAX_VALUE }},
+                    `dataset: ${data.dataset}`);
                     editor.metricId = data.id;
                   }
                 }};
@@ -303,13 +313,17 @@ export default Component.extend({
             });
           })
           .then(() => {
-            return get(this, '_buildYamlSuggestions')(currentMetric, 
yamlAsObject, prefix, noResultsArray, get(this, 'filtersCache'), get(this, 
'dimensionsCache'))
+            return get(this, '_buildYamlSuggestions')(currentMetric,
+              yamlAsObject, prefix, noResultsArray, get(this, 'filtersCache'),
+              get(this, 'dimensionsCache'), position)
               .then(results => results);
           });
       }
       const currentMetric = get(this, 'currentMetric');
       // deals with no metricId, which could be autocomplete for metric or for 
filters and dimensions already cached
-      return get(this, '_buildYamlSuggestions')(currentMetric, yamlAsObject, 
prefix, noResultsArray, get(this, 'filtersCache'), get(this, 'dimensionsCache'))
+      return get(this, '_buildYamlSuggestions')(currentMetric, yamlAsObject,
+        prefix, noResultsArray, get(this, 'filtersCache'),
+        get(this, 'dimensionsCache'), position)
         .then(results => results);
 
     },
diff --git a/thirdeye/thirdeye-frontend/app/utils/constants.js 
b/thirdeye/thirdeye-frontend/app/utils/constants.js
index 87dfda0..4bc8d84 100644
--- a/thirdeye/thirdeye-frontend/app/utils/constants.js
+++ b/thirdeye/thirdeye-frontend/app/utils/constants.js
@@ -75,73 +75,6 @@ rules:
 
 `;
 
-export const yamIt = function(metric, dataset){
-  return `# Below are all dummy example. Please update accordingly.
-# give a name for this detection
-detectionName: name_of_the_detection
-# the metric to detect the anomalies
-metric: ${metric}
-# the data set name for this metric
-dataset: ${dataset}
-# ThirdEye pipeline type. Just fill in Composite
-pipelineType: Composite
-
-# (Optional) Config dimension exploration
-dimensionExploration:
-  # Create an alert for each dimension value in the dimension
-  dimensions:
-    - dimensionName
-
-  # (Optional) only create alert for the dimension value if the contribution to
-  # overall metric is above the threshold
-  minContribution: 0.05
-
-  # (Optional) only create alert for the top k dimension values
-  k: 10
-
-# (Optional) Filter the metric by
-filters:
-  dimensionName1:
-     - dimensionValue1
-     - dimensionValue2
-  dimensionName2:
-     - dimensionValue3
-
-# configure rules of anomaly detection
-rules:
-# configure the first rule
-- # configure the detection rule. ThirdEye will detect anomalies based on the
-  # detection rules.
-  detection:
-      # give a name for the detection rule
-    - name: detection_rule_1
-      # ThirdEye rule type
-      type: PERCENTAGE_RULE
-      # parameters for this rule
-      params:
-        offset: wo1w
-        change: 0.1
-
-  # (Optional) configure the exclusion rule. (Exclude the anomalies you don't
-  # want to see but detected by the detection rule above)
-  filter:
-    - name: filter_rule_1
-      type: ABSOLUTE_CHANGE_FILTER
-      params:
-        threshold: 10000
-
-# configure more rule if you'd like to
-- detection:
-    - name: detection_rule_2
-      type: ABSOLUTE_CHANGE_RULE
-      params:
-        offset: wo1w
-        change: 1000000
-        pattern: UP
-
-`;
-};
-
 export const yamlAlertSettings = `# Below are all dummy example. Please update 
accordingly.
 subscriptionGroupName: test_subscription_group
 application: thirdeye-internal


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to