You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@pinot.apache.org by xh...@apache.org on 2019/10/22 14:36:37 UTC

[incubator-pinot] branch master updated: [TE] web - harleyjj/rca-session - save dimension-algorithm table settings with session and load them (#4712)

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 15bde95  [TE] web - harleyjj/rca-session - save dimension-algorithm table settings with session and load them (#4712)
15bde95 is described below

commit 15bde959a2d6cd090483d616d26532d29e57606c
Author: Harley Jackson <hj...@linkedin.com>
AuthorDate: Tue Oct 22 07:36:31 2019 -0700

    [TE] web - harleyjj/rca-session - save dimension-algorithm table settings with session and load them (#4712)
---
 .../rootcause-dimensions-algorithm/component.js    | 22 +++++++++++++--
 .../rootcause-dimensions-settings/template.hbs     |  2 ++
 .../partials/rootcause/dimensions/template.hbs     |  3 +++
 .../app/pods/rootcause/controller.js               | 21 ++++++++++++---
 .../thirdeye-frontend/app/pods/rootcause/route.js  |  9 ++++++-
 .../component-test.js                              |  4 ++-
 thirdeye/thirdeye-frontend/yarn.lock               | 31 +++++-----------------
 .../resources/v2/RootCauseSessionResource.java     |  6 +++++
 .../datalayer/pojo/RootcauseSessionBean.java       | 17 ++++++++++--
 9 files changed, 82 insertions(+), 33 deletions(-)

diff --git a/thirdeye/thirdeye-frontend/app/pods/components/rootcause-dimensions-algorithm/component.js b/thirdeye/thirdeye-frontend/app/pods/components/rootcause-dimensions-algorithm/component.js
index 20d3f8b..0d021eb 100644
--- a/thirdeye/thirdeye-frontend/app/pods/components/rootcause-dimensions-algorithm/component.js
+++ b/thirdeye/thirdeye-frontend/app/pods/components/rootcause-dimensions-algorithm/component.js
@@ -181,6 +181,17 @@ export default Component.extend({
   init() {
     this._super(...arguments);
     this._resetSettings(['initialTableSettings', 'savedSettings'], 'customTableSettings');
+    const {
+      sessionTableSettings,
+      sessionUserCustomized
+    } = this.getProperties('sessionTableSettings', 'sessionUserCustomized');
+    if (sessionTableSettings && sessionUserCustomized) {
+      set(this, 'customTableSettings', sessionTableSettings);
+      this.send('onSave');
+    } else {
+      // send table settings to parent so session can store them
+      this.get('sendTableSettings')(this.get('customTableSettings'), this.get('isUserCustomizingRequest'));
+    }
   },
 
   /**
@@ -395,14 +406,17 @@ export default Component.extend({
     // Concatenate incoming settings for bulk comparison
     const newMetricSettings = `${metricUrn}:${range[0]}:${range[1]}:${mode}`;
     const newCustomSettings = Object.values(customTableSettings).join(':');
-    // Compare current and incoming settings
-    const isSameMetricSettings = (previousMetricSettings === newMetricSettings);
+    // Compare current and incoming metric settings if there are previous settings
+    const isSameMetricSettings = previousMetricSettings ? (previousMetricSettings === newMetricSettings) : true;
+    // Compare current and incoming custom settings
     const isSameCustomSettings = (previousCustomSettings === newCustomSettings);
 
     // Reset settings if metrics have changed
     if (!isSameMetricSettings) {
       isUserCustomizingRequest = true;
       this._resetSettings(['customTableSettings', 'savedSettings'], 'initialTableSettings');
+      // send table settings to parent so session can store them
+      this.get('sendTableSettings')(this.get('customTableSettings'), this.get('isUserCustomizingRequest'));
     }
 
     // Abort if metric with exclusion filters
@@ -550,6 +564,8 @@ export default Component.extend({
       });
       // Cache saved state
       this._resetSettings(['savedSettings'], 'customTableSettings');
+      // send table settings to parent so session can store them
+      this.get('sendTableSettings')(this.get('customTableSettings'), this.get('isUserCustomizingRequest'));
       this._fetchIfNewContext();
     },
 
@@ -558,6 +574,8 @@ export default Component.extend({
      */
     onCancel() {
       this._resetSettings(['customTableSettings'], 'savedSettings');
+      // send table settings to parent so session can store them
+      this.get('sendTableSettings')(this.get('customTableSettings'), this.get('isUserCustomizingRequest'));
       set(this, 'openSettingsModal', false);
     },
 
diff --git a/thirdeye/thirdeye-frontend/app/pods/components/rootcause-dimensions-settings/template.hbs b/thirdeye/thirdeye-frontend/app/pods/components/rootcause-dimensions-settings/template.hbs
index 6a890ef..02f7ecb 100644
--- a/thirdeye/thirdeye-frontend/app/pods/components/rootcause-dimensions-settings/template.hbs
+++ b/thirdeye/thirdeye-frontend/app/pods/components/rootcause-dimensions-settings/template.hbs
@@ -20,6 +20,7 @@
       triggerId="dimension-select-include"
       triggerClass="te-form__select"
       verticalPosition="below"
+      closeOnSelect=false
       as |dimension|
     }}
       {{dimension}}
@@ -67,6 +68,7 @@
       triggerId="dimension-select-exclude"
       triggerClass="te-form__select"
       verticalPosition="below"
+      closeOnSelect=false
       as |dimension|
     }}
       {{dimension}}
diff --git a/thirdeye/thirdeye-frontend/app/pods/partials/rootcause/dimensions/template.hbs b/thirdeye/thirdeye-frontend/app/pods/partials/rootcause/dimensions/template.hbs
index 2c5ddc7..96e62c3 100644
--- a/thirdeye/thirdeye-frontend/app/pods/partials/rootcause/dimensions/template.hbs
+++ b/thirdeye/thirdeye-frontend/app/pods/partials/rootcause/dimensions/template.hbs
@@ -48,6 +48,9 @@
       selectedUrns=selectedUrns
       enableSubTotals=false
       onSelection=(action "onSelection")
+      sendTableSettings=(action "saveTableSettings")
+      sessionTableSettings=sessionTableSettings
+      sessionUserCustomized=sessionUserCustomized
     }}
   {{/subtab.tabpanel}}
 
diff --git a/thirdeye/thirdeye-frontend/app/pods/rootcause/controller.js b/thirdeye/thirdeye-frontend/app/pods/rootcause/controller.js
index 10759e4..9375165 100644
--- a/thirdeye/thirdeye-frontend/app/pods/rootcause/controller.js
+++ b/thirdeye/thirdeye-frontend/app/pods/rootcause/controller.js
@@ -735,8 +735,11 @@ export default Controller.extend({
    * @private
    */
   _makeSession() {
-    const { context, selectedUrns, sessionId, sessionName, sessionText, sessionOwner, sessionPermissions } =
-      getProperties(this, 'context', 'selectedUrns', 'sessionId', 'sessionName', 'sessionText', 'sessionOwner', 'sessionPermissions');
+    const { context, selectedUrns, sessionId, sessionName, sessionText, sessionOwner,
+      sessionPermissions, isUserCustomizingRequest, customTableSettings } =
+      getProperties(this, 'context', 'selectedUrns', 'sessionId', 'sessionName',
+      'sessionText', 'sessionOwner', 'sessionPermissions', 'isUserCustomizingRequest',
+      'customTableSettings');
 
     return {
       id: sessionId,
@@ -752,7 +755,9 @@ export default Controller.extend({
       analysisRangeEnd: context.analysisRange[1],
       contextUrns: context.urns,
       anomalyUrns: context.anomalyUrns,
-      selectedUrns
+      selectedUrns,
+      isUserCustomizingRequest,
+      customTableSettings
     };
   },
 
@@ -1247,6 +1252,16 @@ export default Controller.extend({
      */
     onCreateEventClick() {
       set(this, 'showCreateEventModal', true);
+    },
+
+    /**
+     * Save dimensions-algorithm table settings to post to session (called by child)
+     */
+    saveTableSettings(customTableSettings, isUserCustomizingRequest) {
+      this.setProperties({
+        customTableSettings,
+        isUserCustomizingRequest
+      });
     }
   }
 });
diff --git a/thirdeye/thirdeye-frontend/app/pods/rootcause/route.js b/thirdeye/thirdeye-frontend/app/pods/rootcause/route.js
index 42b2e7e..407c6cd 100644
--- a/thirdeye/thirdeye-frontend/app/pods/rootcause/route.js
+++ b/thirdeye/thirdeye-frontend/app/pods/rootcause/route.js
@@ -318,6 +318,8 @@ export default Route.extend(AuthenticatedRouteMixin, {
     let sessionUpdatedBy = '';
     let sessionUpdatedTime = '';
     let sessionModified = true;
+    let sessionTableSettings = null;
+    let sessionUserCustomized = false;
     let setupMode = ROOTCAUSE_SETUP_MODE_CONTEXT;
     let routeErrors = new Set();
 
@@ -398,7 +400,8 @@ export default Route.extend(AuthenticatedRouteMixin, {
     // session-initialized context
     if (sessionId) {
       if (!_.isEmpty(session)) {
-        const { name, text, updatedBy, updated, owner, permissions } = model.session;
+        const { name, text, updatedBy, updated, owner, permissions,
+        isUserCustomizingRequest, customTableSettings } = model.session;
         context = {
           urns: new Set(session.contextUrns),
           anomalyRange: [session.anomalyRangeStart, session.anomalyRangeEnd],
@@ -417,6 +420,8 @@ export default Route.extend(AuthenticatedRouteMixin, {
         sessionUpdatedTime = updated;
         sessionModified = false;
         setupMode = ROOTCAUSE_SETUP_MODE_NONE;
+        sessionTableSettings = customTableSettings;
+        sessionUserCustomized = isUserCustomizingRequest;
 
       } else {
         routeErrors.add(`Could not find sessionId ${sessionId}`);
@@ -454,6 +459,8 @@ export default Route.extend(AuthenticatedRouteMixin, {
       sessionUpdatedBy,
       sessionUpdatedTime,
       sessionModified,
+      sessionTableSettings,
+      sessionUserCustomized,
       selectedUrns,
       sizeMetricUrns,
       setupMode,
diff --git a/thirdeye/thirdeye-frontend/tests/integration/pods/components/rootcause-dimensions-algorithm/component-test.js b/thirdeye/thirdeye-frontend/tests/integration/pods/components/rootcause-dimensions-algorithm/component-test.js
index d8e7336..5436e51 100644
--- a/thirdeye/thirdeye-frontend/tests/integration/pods/components/rootcause-dimensions-algorithm/component-test.js
+++ b/thirdeye/thirdeye-frontend/tests/integration/pods/components/rootcause-dimensions-algorithm/component-test.js
@@ -20,7 +20,8 @@ module('Integration | Component | rootcause-dimensions-algorithm', function(hook
         compareMode: 'WoW'
       },
       selectedUrns: {},
-      onSelection: () => {}
+      onSelection: () => {},
+      saveTableSettings: () => {}
     });
 
     await render(hbs`
@@ -32,6 +33,7 @@ module('Integration | Component | rootcause-dimensions-algorithm', function(hook
         selectedUrns=selectedUrns
         isLoading=true
         onSelection=(action onSelection)
+        sendTableSettings=(action saveTableSettings)
       }}
     `);
 
diff --git a/thirdeye/thirdeye-frontend/yarn.lock b/thirdeye/thirdeye-frontend/yarn.lock
index feec03e..8b5cb7e 100644
--- a/thirdeye/thirdeye-frontend/yarn.lock
+++ b/thirdeye/thirdeye-frontend/yarn.lock
@@ -4695,7 +4695,7 @@ debug@^4.0.0, debug@^4.1.0, debug@^4.1.1:
   dependencies:
     ms "^2.1.1"
 
-debuglog@*, debuglog@^1.0.1:
+debuglog@^1.0.1:
   version "1.0.1"
   resolved "https://registry.yarnpkg.com/debuglog/-/debuglog-1.0.1.tgz#aa24ffb9ac3df9a2351837cfb2d279360cd78492"
   integrity sha1-qiT/uaw9+aI1GDfPstJ5NgzXhJI=
@@ -8238,7 +8238,7 @@ import-lazy@^2.1.0:
   resolved "https://registry.yarnpkg.com/import-lazy/-/import-lazy-2.1.0.tgz#05698e3d45c88e8d7e9d92cb0584e77f096f3e43"
   integrity sha1-BWmOPUXIjo1+nZLLBYTnfwlvPkM=
 
-imurmurhash@*, imurmurhash@^0.1.4:
+imurmurhash@^0.1.4:
   version "0.1.4"
   resolved "https://registry.yarnpkg.com/imurmurhash/-/imurmurhash-0.1.4.tgz#9218b9b2b928a238b13dc4fb6b6d576f231453ea"
   integrity sha1-khi5srkoojixPcT7a21XbyMUU+o=
@@ -9398,11 +9398,6 @@ lodash._baseflatten@^3.0.0:
     lodash.isarguments "^3.0.0"
     lodash.isarray "^3.0.0"
 
-lodash._baseindexof@*:
-  version "3.1.0"
-  resolved "https://registry.yarnpkg.com/lodash._baseindexof/-/lodash._baseindexof-3.1.0.tgz#fe52b53a1c6761e42618d654e4a25789ed61822c"
-  integrity sha1-/lK1OhxnYeQmGNZU5KJXie1hgiw=
-
 lodash._basetostring@^3.0.0:
   version "3.0.1"
   resolved "https://registry.yarnpkg.com/lodash._basetostring/-/lodash._basetostring-3.0.1.tgz#d1861d877f824a52f669832dcaf3ee15566a07d5"
@@ -9421,16 +9416,11 @@ lodash._basevalues@^3.0.0:
   resolved "https://registry.yarnpkg.com/lodash._basevalues/-/lodash._basevalues-3.0.0.tgz#5b775762802bde3d3297503e26300820fdf661b7"
   integrity sha1-W3dXYoAr3j0yl1A+JjAIIP32Ybc=
 
-lodash._bindcallback@*, lodash._bindcallback@^3.0.0:
+lodash._bindcallback@^3.0.0:
   version "3.0.1"
   resolved "https://registry.yarnpkg.com/lodash._bindcallback/-/lodash._bindcallback-3.0.1.tgz#e531c27644cf8b57a99e17ed95b35c748789392e"
   integrity sha1-5THCdkTPi1epnhftlbNcdIeJOS4=
 
-lodash._cacheindexof@*:
-  version "3.0.2"
-  resolved "https://registry.yarnpkg.com/lodash._cacheindexof/-/lodash._cacheindexof-3.0.2.tgz#3dc69ac82498d2ee5e3ce56091bafd2adc7bde92"
-  integrity sha1-PcaayCSY0u5ePOVgkbr9Ktx73pI=
-
 lodash._createassigner@^3.0.0:
   version "3.1.1"
   resolved "https://registry.yarnpkg.com/lodash._createassigner/-/lodash._createassigner-3.1.1.tgz#838a5bae2fdaca63ac22dee8e19fa4e6d6970b11"
@@ -9440,13 +9430,6 @@ lodash._createassigner@^3.0.0:
     lodash._isiterateecall "^3.0.0"
     lodash.restparam "^3.0.0"
 
-lodash._createcache@*:
-  version "3.1.2"
-  resolved "https://registry.yarnpkg.com/lodash._createcache/-/lodash._createcache-3.1.2.tgz#56d6a064017625e79ebca6b8018e17440bdcf093"
-  integrity sha1-VtagZAF2JeeevKa4AY4XRAvc8JM=
-  dependencies:
-    lodash._getnative "^3.0.0"
-
 lodash._createset@~4.0.0:
   version "4.0.3"
   resolved "https://registry.yarnpkg.com/lodash._createset/-/lodash._createset-4.0.3.tgz#0f4659fbb09d75194fa9e2b88a6644d363c9fe26"
@@ -9473,7 +9456,7 @@ lodash._escapestringchar@~2.3.0:
   resolved "https://registry.yarnpkg.com/lodash._escapestringchar/-/lodash._escapestringchar-2.3.0.tgz#cce73ae60fc6da55d2bf8a0679c23ca2bab149fc"
   integrity sha1-zOc65g/G2lXSv4oGecI8orqxSfw=
 
-lodash._getnative@*, lodash._getnative@^3.0.0:
+lodash._getnative@^3.0.0:
   version "3.9.1"
   resolved "https://registry.yarnpkg.com/lodash._getnative/-/lodash._getnative-3.9.1.tgz#570bc7dede46d61cdcde687d65d3eecbaa3aaff5"
   integrity sha1-VwvH3t5G1hzc3mh9ZdPuy6o6r/U=
@@ -9800,7 +9783,7 @@ lodash.pick@^4.4.0:
   resolved "https://registry.yarnpkg.com/lodash.pick/-/lodash.pick-4.4.0.tgz#52f05610fff9ded422611441ed1fc123a03001b3"
   integrity sha1-UvBWEP/53tQiYRRB7R/BI6AwAbM=
 
-lodash.restparam@*, lodash.restparam@^3.0.0:
+lodash.restparam@^3.0.0:
   version "3.6.1"
   resolved "https://registry.yarnpkg.com/lodash.restparam/-/lodash.restparam-3.6.1.tgz#936a4e309ef330a7645ed4145986c85ae5b20805"
   integrity sha1-k2pOMJ7zMKdkXtQUWYbIWuWyCAU=
@@ -12145,7 +12128,7 @@ readable-stream@~1.1.10:
     isarray "0.0.1"
     string_decoder "~0.10.x"
 
-readdir-scoped-modules@*, readdir-scoped-modules@^1.0.0:
+readdir-scoped-modules@^1.0.0:
   version "1.1.0"
   resolved "https://registry.yarnpkg.com/readdir-scoped-modules/-/readdir-scoped-modules-1.1.0.tgz#8d45407b4f870a0dcaebc0e28670d18e74514309"
   integrity sha512-asaikDeqAQg7JifRsZn1NJZXo9E+VwlyCfbkZhwyISinqk5zNS6266HS5kah6P0SaQKGF6SkNnZVHUzHFYxYDw==
@@ -14467,7 +14450,7 @@ uuid@~3.1.0:
   resolved "https://registry.yarnpkg.com/uuid/-/uuid-3.1.0.tgz#3dd3d3e790abc24d7b0d3a034ffababe28ebbc04"
   integrity sha512-DIWtzUkw04M4k3bf1IcpS2tngXEL26YUD2M0tMDUpnUrz2hgzUBlD55a4FjdLGPvfHxS6uluGWvaVEqgBcVa+g==
 
-validate-npm-package-license@*, validate-npm-package-license@^3.0.1:
+validate-npm-package-license@^3.0.1:
   version "3.0.4"
   resolved "https://registry.yarnpkg.com/validate-npm-package-license/-/validate-npm-package-license-3.0.4.tgz#fc91f6b9c7ba15c857f4cb2c5defeec39d4f410a"
   integrity sha512-DpKm2Ui/xN7/HQKCtpZxoRWBhZ9Z0kqtygG8XCgNQ8ZlDnxuQmWhj566j8fN4Cu3/JmbhsDo7fcAJq4s9h27Ew==
diff --git a/thirdeye/thirdeye-pinot/src/main/java/org/apache/pinot/thirdeye/dashboard/resources/v2/RootCauseSessionResource.java b/thirdeye/thirdeye-pinot/src/main/java/org/apache/pinot/thirdeye/dashboard/resources/v2/RootCauseSessionResource.java
index 069b7af..86eac35 100644
--- a/thirdeye/thirdeye-pinot/src/main/java/org/apache/pinot/thirdeye/dashboard/resources/v2/RootCauseSessionResource.java
+++ b/thirdeye/thirdeye-pinot/src/main/java/org/apache/pinot/thirdeye/dashboard/resources/v2/RootCauseSessionResource.java
@@ -239,6 +239,12 @@ public class RootCauseSessionResource {
     if (other.getPermissions() != null)
       session.setPermissions(other.getPermissions());
 
+    if (other.getIsUserCustomizingRequest() != null)
+      session.setIsUserCustomizingRequest(other.getIsUserCustomizingRequest());
+
+    if (other.getCustomTableSettings() != null)
+      session.setCustomTableSettings(other.getCustomTableSettings());
+
     return session;
   }
 
diff --git a/thirdeye/thirdeye-pinot/src/main/java/org/apache/pinot/thirdeye/datalayer/pojo/RootcauseSessionBean.java b/thirdeye/thirdeye-pinot/src/main/java/org/apache/pinot/thirdeye/datalayer/pojo/RootcauseSessionBean.java
index e4d0489..66871a0 100644
--- a/thirdeye/thirdeye-pinot/src/main/java/org/apache/pinot/thirdeye/datalayer/pojo/RootcauseSessionBean.java
+++ b/thirdeye/thirdeye-pinot/src/main/java/org/apache/pinot/thirdeye/datalayer/pojo/RootcauseSessionBean.java
@@ -20,6 +20,7 @@
 package org.apache.pinot.thirdeye.datalayer.pojo;
 
 import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
+import java.util.Map;
 import java.util.Objects;
 import java.util.Set;
 
@@ -52,6 +53,8 @@ public class RootcauseSessionBean extends AbstractBean {
   private Set<String> selectedUrns;
   private Long anomalyId;
   private String permissions = PermissionType.READ_WRITE.toString();
+  private Map<String, Object> customTableSettings;
+  private Boolean isUserCustomizingRequest;
 
   public String getName() {
     return name;
@@ -189,6 +192,14 @@ public class RootcauseSessionBean extends AbstractBean {
     this.permissions = permissions;
   }
 
+  public Map<String, Object> getCustomTableSettings() { return customTableSettings; }
+
+  public void setCustomTableSettings(Map<String, Object> customTableSettings) { this.customTableSettings = customTableSettings; }
+
+  public Boolean getIsUserCustomizingRequest() { return isUserCustomizingRequest; }
+
+  public void setIsUserCustomizingRequest( Boolean isUserCustomizingRequest ) { this.isUserCustomizingRequest = isUserCustomizingRequest; }
+
   @Override
   public boolean equals(Object o) {
     if (this == o) {
@@ -205,13 +216,15 @@ public class RootcauseSessionBean extends AbstractBean {
         that.analysisRangeStart) && Objects.equals(analysisRangeEnd, that.analysisRangeEnd) && Objects.equals(created,
         that.created) && Objects.equals(updated, that.updated) && Objects.equals(contextUrns, that.contextUrns)
         && Objects.equals(anomalyUrns, that.anomalyUrns) && Objects.equals(selectedUrns, that.selectedUrns)
-        && Objects.equals(anomalyId, that.anomalyId) && Objects.equals(permissions, that.permissions);
+        && Objects.equals(anomalyId, that.anomalyId) && Objects.equals(permissions, that.permissions)
+        && Objects.equals(customTableSettings, that.customTableSettings)
+        && Objects.equals(isUserCustomizingRequest, that.isUserCustomizingRequest);
   }
 
   @Override
   public int hashCode() {
     return Objects.hash(name, text, owner, compareMode, granularity, previousId, anomalyRangeStart, anomalyRangeEnd,
         analysisRangeStart, analysisRangeEnd, created, updated, contextUrns, anomalyUrns, selectedUrns, anomalyId,
-        permissions);
+        permissions, customTableSettings, isUserCustomizingRequest);
   }
 }


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