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

xhsun 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 a36105f  Redirect modal (#3961)
a36105f is described below

commit a36105fa65fbbc2d3d4ec8502ce94e8e6adba974
Author: Harley Jackson <harleyy...@gmail.com>
AuthorDate: Wed Mar 13 07:35:22 2019 -0700

    Redirect modal (#3961)
    
    * [TE] frontend - harleyjj/manage-alert-explore - pin redirect link to 
manage/alert/explore route
    
    * [TE] frontend - harleyjj/manage-explore - push folder
---
 .../app/pods/manage/explore/controller.js          |   9 ++
 .../app/pods/manage/explore/route.js               | 135 +++++++++++++++++++++
 .../app/pods/manage/explore/template.hbs           |  37 ++++++
 3 files changed, 181 insertions(+)

diff --git a/thirdeye/thirdeye-frontend/app/pods/manage/explore/controller.js 
b/thirdeye/thirdeye-frontend/app/pods/manage/explore/controller.js
new file mode 100644
index 0000000..96ef85f
--- /dev/null
+++ b/thirdeye/thirdeye-frontend/app/pods/manage/explore/controller.js
@@ -0,0 +1,9 @@
+/**
+ * Controller for Alert Landing and Details Page
+ * @module manage/alert
+ * @exports manage/alert
+ */
+import Controller from '@ember/controller';
+
+export default Controller.extend({
+});
diff --git a/thirdeye/thirdeye-frontend/app/pods/manage/explore/route.js 
b/thirdeye/thirdeye-frontend/app/pods/manage/explore/route.js
new file mode 100644
index 0000000..d219d42
--- /dev/null
+++ b/thirdeye/thirdeye-frontend/app/pods/manage/explore/route.js
@@ -0,0 +1,135 @@
+/**
+ * Handles the 'alert details' route.
+ * @module manage/alert/route
+ * @exports manage alert model
+ */
+import Route from '@ember/routing/route';
+import RSVP from 'rsvp';
+import { set, get } from '@ember/object';
+import { inject as service } from '@ember/service';
+import yamljs from 'yamljs';
+import moment from 'moment';
+
+export default Route.extend({
+  notifications: service('toast'),
+
+  async model(params) {
+    const alertId = params.alert_id;
+    const postProps = {
+      method: 'get',
+      headers: { 'content-type': 'application/json' }
+    };
+    const notifications = get(this, 'notifications');
+    //detection alert fetch
+    const detectionUrl = `/detection/${alertId}`;
+    try {
+      const detection_result = await fetch(detectionUrl, postProps);
+      const detection_status  = get(detection_result, 'status');
+      const detection_json = await detection_result.json();
+      if (detection_status !== 200) {
+        notifications.error('Retrieval of alert yaml failed.', 'Error');
+      } else {
+        if (detection_json.yaml) {
+          const detectionInfo = yamljs.parse(detection_json.yaml);
+          const lastDetection = new Date(detection_json.lastTimestamp);
+          Object.assign(detectionInfo, {
+            isActive: detection_json.active,
+            createdBy: detection_json.createdBy,
+            updatedBy: detection_json.updatedBy,
+            exploreDimensions: detection_json.dimensions,
+            filters: this._formatYamlFilter(detectionInfo.filters),
+            dimensionExploration: 
this._formatYamlFilter(detectionInfo.dimensionExploration),
+            lastDetectionTime: lastDetection.toDateString() + ", " +  
lastDetection.toLocaleTimeString() + " (" + moment.tz.guess() + ")",
+            rawYaml: detection_json.yaml
+          });
+
+          this.setProperties({
+            alertId: alertId,
+            detectionInfo,
+            rawDetectionYaml: get(this, 'detectionInfo') ? get(this, 
'detectionInfo').rawYaml : null,
+            metricUrn: detection_json.properties.nested[0].nestedMetricUrns[0],
+            metricUrnList: detection_json.properties.nested[0].nestedMetricUrns
+          });
+
+        }
+      }
+    } catch (error) {
+      notifications.error('Retrieving alert yaml failed.', error);
+    }
+
+    //subscription group fetch
+    const subUrl = `/detection/subscription-groups/${alertId}`;//dropdown of 
subscription groups
+    try {
+      const settings_result = await fetch(subUrl, postProps);
+      const settings_status  = get(settings_result, 'status');
+      const settings_json = await settings_result.json();
+      if (settings_status !== 200) {
+        notifications.error('Retrieving subscription groups failed.', 'Error');
+      } else {
+        set(this, 'subscriptionGroups', settings_json);
+      }
+    } catch (error) {
+      notifications.error('Retrieving subscription groups failed.', error);
+    }
+
+    let subscribedGroups = "";
+    if (typeof get(this, 'subscriptionGroups') === 'object' && get(this, 
'subscriptionGroups').length > 0) {
+      const groups = get(this, 'subscriptionGroups');
+      for (let key in groups) {
+        if (groups.hasOwnProperty(key)) {
+          let group = groups[key];
+          if (subscribedGroups === "") {
+            subscribedGroups = group.name
+          } else {
+            subscribedGroups = subscribedGroups + ", " + group.name;
+          }
+        }
+      }
+    }
+
+    return RSVP.hash({
+      alertId,
+      alertData: get(this, 'detectionInfo'),
+      detectionYaml: get(this, 'rawDetectionYaml'),
+      subscribedGroups,
+      metricUrn: get(this, 'metricUrn'),
+      metricUrnList: get(this, 'metricUrnList') ? get(this, 'metricUrnList') : 
[]
+    });
+  },
+
+  /**
+   * The yaml filters formatter. Convert filters in the yaml file in to a 
legacy filters string
+   * For example, filters = {
+   *   "country": ["us", "cn"],
+   *   "browser": ["chrome"]
+   * }
+   * will be convert into "country=us;country=cn;browser=chrome"
+   *
+   * @method _formatYamlFilter
+   * @param {Map} filters multimap of filters
+   * @return {String} - formatted filters string
+   */
+  _formatYamlFilter(filters) {
+    if (filters){
+      const filterStrings = [];
+
+      Object.keys(filters).forEach(
+        function(filterKey) {
+          const filter = filters[filterKey];
+          if (filter && typeof filter === 'object') {
+
+            filter.forEach(
+              function (filterValue) {
+                filterStrings.push(filterKey + '=' + filterValue);
+              }
+            );
+          } else {
+            filterStrings.push(filterKey + '=' + filter);
+          }
+        }
+      );
+      return filterStrings.join(';');
+    }
+    return '';
+  }
+});
diff --git a/thirdeye/thirdeye-frontend/app/pods/manage/explore/template.hbs 
b/thirdeye/thirdeye-frontend/app/pods/manage/explore/template.hbs
new file mode 100644
index 0000000..d0f178b
--- /dev/null
+++ b/thirdeye/thirdeye-frontend/app/pods/manage/explore/template.hbs
@@ -0,0 +1,37 @@
+<section class="te-page__top te-search-results {{if isEditModeActive 
"te-search-results--slim"}}">
+  <div class="container">
+    {{#self-serve-alert-yaml-details
+      alertData=model.alertData
+      subscribedGroups=model.subscribedGroups
+      isLoadError=isLoadError
+    }}
+      <div class="te-search-results__cta">
+        {{#link-to "manage.yaml" model.alertId}}
+          <button class="te-button te-button--outline">Edit</button>
+        {{/link-to}}
+      </div>
+    {{/self-serve-alert-yaml-details}}
+  </div>
+</section>
+
+<section class="te-page__bottom">
+  <div class="container">
+    {{#if isLoadError}}
+      <div class="te-alert-page-pending">
+        <img src="{{rootURL}}assets/images/te-alert-error.png" 
class="te-alert-page-pending__image te-alert-page-pending__image--error" 
alt="error">
+        <h2 class="te-alert-page-pending__title">Oops, something went 
wrong</h2>
+        <p class="te-alert-page-pending__text">{{errorText}}</p>
+      </div>
+    {{else}}
+      {{alert-details
+        isPreviewMode=false
+        alertYaml=model.detectionYaml
+        showDetails=true
+        dataIsCurrent=true
+        alertId=model.alertId
+        metricUrn=model.metricUrn
+        metricUrnList=model.metricUrnList
+      }}
+    {{/if}}
+  </div>
+</section>


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

Reply via email to