zeppelin-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From k..@apache.org
Subject zeppelin git commit: [ZEPPELIN-2690] fix: should respect helium vis order in result
Date Wed, 28 Jun 2017 03:05:08 GMT
Repository: zeppelin
Updated Branches:
  refs/heads/master c016062ed -> e3590e795


[ZEPPELIN-2690] fix: should respect helium vis order in result

### What is this PR for?

Fixed to respect helium vis order in results.

This PR is written based on https://github.com/apache/zeppelin/pull/2424. Will be rebased
after 2760 is handled.

### What type of PR is it?
[Bug Fix]

### Todos
DONE

### What is the Jira issue?

[ZEPPELIN-2670](https://issues.apache.org/jira/browse/ZEPPELIN-2690)

### How should this be tested?

1. Set vis order in `#helium`
2. Open a paragraph containing a table.

### Screenshots (if appropriate)

#### Before

![image](https://user-images.githubusercontent.com/4968473/27524943-a0788edc-5a74-11e7-8fbf-8d5d8f6b3644.png)

#### After

![2690_after](https://user-images.githubusercontent.com/4968473/27525004-0b34ac1a-5a75-11e7-8c9a-6532988297b1.gif)

### Questions:
* Does the licenses files need update? - NO
* Is there breaking changes for older versions? - NO
* Does this needs documentation? - NO

Author: 1ambda <1amb4a@gmail.com>

Closes #2436 from 1ambda/ZEPPELIN-2690/should-respect-helium-vis-order-in-result and squashes
the following commits:

b6166bb1 [1ambda] fix: Respect helium vis order in result


Project: http://git-wip-us.apache.org/repos/asf/zeppelin/repo
Commit: http://git-wip-us.apache.org/repos/asf/zeppelin/commit/e3590e79
Tree: http://git-wip-us.apache.org/repos/asf/zeppelin/tree/e3590e79
Diff: http://git-wip-us.apache.org/repos/asf/zeppelin/diff/e3590e79

Branch: refs/heads/master
Commit: e3590e79568075505094c1aa7da4b4fec1dc6689
Parents: c016062
Author: 1ambda <1amb4a@gmail.com>
Authored: Mon Jun 26 13:35:15 2017 +0900
Committer: 1ambda <1amb4a@gmail.com>
Committed: Wed Jun 28 12:04:58 2017 +0900

----------------------------------------------------------------------
 .../paragraph/result/result.controller.js       | 28 ++++++++++++--------
 .../src/components/helium/helium.service.js     | 21 ++++++++++++---
 2 files changed, 34 insertions(+), 15 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/zeppelin/blob/e3590e79/zeppelin-web/src/app/notebook/paragraph/result/result.controller.js
----------------------------------------------------------------------
diff --git a/zeppelin-web/src/app/notebook/paragraph/result/result.controller.js b/zeppelin-web/src/app/notebook/paragraph/result/result.controller.js
index 6913b02..df9ebe9 100644
--- a/zeppelin-web/src/app/notebook/paragraph/result/result.controller.js
+++ b/zeppelin-web/src/app/notebook/paragraph/result/result.controller.js
@@ -170,18 +170,24 @@ function ResultCtrl ($scope, $rootScope, $route, $window, $routeParams,
$locatio
   }
 
   $scope.init = function (result, config, paragraph, index) {
-    // register helium plugin vis
-    let visBundles = heliumService.getVisualizationBundles()
-    visBundles.forEach(function (vis) {
-      $scope.builtInTableDataVisualizationList.push({
-        id: vis.id,
-        name: vis.name,
-        icon: $sce.trustAsHtml(vis.icon),
-        supports: [DefaultDisplayType.TABLE, DefaultDisplayType.NETWORK]
+    // register helium plugin vis packages
+    let visPackages = heliumService.getVisualizationCachedPackages()
+    const visPackageOrder = heliumService.getVisualizationCachedPackageOrder()
+
+    // push the helium vis packages following the order
+    visPackageOrder.map(visName => {
+      visPackages.map(vis => {
+        if (vis.name !== visName) { return }
+        $scope.builtInTableDataVisualizationList.push({
+          id: vis.id,
+          name: vis.name,
+          icon: $sce.trustAsHtml(vis.icon),
+          supports: [DefaultDisplayType.TABLE, DefaultDisplayType.NETWORK]
+        })
+        builtInVisualizations[vis.id] = {
+          class: vis.class
+        }
       })
-      builtInVisualizations[vis.id] = {
-        class: vis.class
-      }
     })
 
     updateData(result, config, paragraph, index)

http://git-wip-us.apache.org/repos/asf/zeppelin/blob/e3590e79/zeppelin-web/src/components/helium/helium.service.js
----------------------------------------------------------------------
diff --git a/zeppelin-web/src/components/helium/helium.service.js b/zeppelin-web/src/components/helium/helium.service.js
index d1c1077..46fcc85 100644
--- a/zeppelin-web/src/components/helium/helium.service.js
+++ b/zeppelin-web/src/components/helium/helium.service.js
@@ -28,6 +28,7 @@ export default function heliumService ($http, $sce, baseUrlSrv) {
   'ngInject'
 
   let visualizationBundles = []
+  let visualizationPackageOrder = []
   // name `heliumBundles` should be same as `HeliumBundleFactory.HELIUM_BUNDLES_VAR`
   let heliumBundles = []
   // map for `{ magic: interpreter }`
@@ -70,17 +71,23 @@ export default function heliumService ($http, $sce, baseUrlSrv) {
     })
   }
 
-  this.getVisualizationBundles = function () {
+  this.getVisualizationCachedPackages = function () {
     return visualizationBundles
   }
 
+  this.getVisualizationCachedPackageOrder = function () {
+    return visualizationPackageOrder
+  }
+
   /**
-   * @returns {Promise} which returns bundleOrder
+   * @returns {Promise} which returns bundleOrder and cache it in `visualizationPackageOrder`
    */
   this.getVisualizationPackageOrder = function () {
     return $http.get(baseUrlSrv.getRestApiBase() + '/helium/order/visualization')
       .then(function (response, status) {
-        return response.data.body
+        const order = response.data.body
+        visualizationPackageOrder = order
+        return order
       })
       .catch(function (error) {
         console.error('Can not get bundle order', error)
@@ -126,7 +133,6 @@ export default function heliumService ($http, $sce, baseUrlSrv) {
   this.getAllPackageInfo = function () {
     return $http.get(`${baseUrlSrv.getRestApiBase()}/helium/package`)
       .then(function (response, status) {
-        console.warn(Object.keys(response.data.body).length)
         return response.data.body
       })
       .catch(function (error) {
@@ -285,4 +291,11 @@ export default function heliumService ($http, $sce, baseUrlSrv) {
       }
     })
   })
+
+  this.init = function() {
+    this.getVisualizationPackageOrder()
+  }
+
+  // init
+  this.init()
 }


Mime
View raw message