You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@zeppelin.apache.org by mo...@apache.org on 2017/07/05 22:44:32 UTC

zeppelin git commit: Fix zeppelin-web development mode

Repository: zeppelin
Updated Branches:
  refs/heads/master f36b1a157 -> 0443b001f


Fix zeppelin-web development mode

### What is this PR for?

After https://github.com/apache/zeppelin/pull/2373, zeppelin-web dev mode does not work properly.
Dev mode always ask user login (even if authentication is turned off) and any login attempt will fail. So it makes difficult to develop front-end.

This PR fixes problem by not adding `X-Requested-With: XMLHttpRequest` header in dev mode.

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

### Todos
* [x] - Fix devmode

### How should this be tested?
run zeppelin-web dev mode and see if you can login / open notebook

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

Author: Lee moon soo <mo...@apache.org>

Closes #2463 from Leemoonsoo/fix_devmode and squashes the following commits:

073c128 [Lee moon soo] fix indent
bf15efc [Lee moon soo] do not apply X-Requested-With : XMLHttpRequest header in dev mode


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

Branch: refs/heads/master
Commit: 0443b001fd73a72e481f068f0aab804fc30880a0
Parents: f36b1a1
Author: Lee moon soo <mo...@apache.org>
Authored: Wed Jul 5 12:25:36 2017 +0900
Committer: Lee moon soo <mo...@apache.org>
Committed: Thu Jul 6 07:44:27 2017 +0900

----------------------------------------------------------------------
 zeppelin-web/src/app/app.js    | 32 +++++++++++++++++---------------
 zeppelin-web/webpack.config.js |  1 +
 2 files changed, 18 insertions(+), 15 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/zeppelin/blob/0443b001/zeppelin-web/src/app/app.js
----------------------------------------------------------------------
diff --git a/zeppelin-web/src/app/app.js b/zeppelin-web/src/app/app.js
index d83fa98..f645d3b 100644
--- a/zeppelin-web/src/app/app.js
+++ b/zeppelin-web/src/app/app.js
@@ -146,23 +146,25 @@ let zeppelinWebApp = angular.module('zeppelinWebApp', requiredModules)
   })
 
   // handel logout on API failure
-  .config(function ($httpProvider, $provide) {
-    $httpProvider.defaults.headers.common['X-Requested-With'] = 'XMLHttpRequest'
-    $provide.factory('httpInterceptor', function ($q, $rootScope) {
-      return {
-        'responseError': function (rejection) {
-          if (rejection.status === 405) {
-            let data = {}
-            data.info = ''
-            $rootScope.$broadcast('session_logout', data)
+    .config(function ($httpProvider, $provide) {
+      if (process.env.PROD) {
+        $httpProvider.defaults.headers.common['X-Requested-With'] = 'XMLHttpRequest'
+      }
+      $provide.factory('httpInterceptor', function ($q, $rootScope) {
+        return {
+          'responseError': function (rejection) {
+            if (rejection.status === 405) {
+              let data = {}
+              data.info = ''
+              $rootScope.$broadcast('session_logout', data)
+            }
+            $rootScope.$broadcast('httpResponseError', rejection)
+            return $q.reject(rejection)
           }
-          $rootScope.$broadcast('httpResponseError', rejection)
-          return $q.reject(rejection)
         }
-      }
+      })
+      $httpProvider.interceptors.push('httpInterceptor')
     })
-    $httpProvider.interceptors.push('httpInterceptor')
-  })
   .constant('TRASH_FOLDER_ID', '~Trash')
 
 function auth () {
@@ -177,7 +179,7 @@ function auth () {
     },
     crossDomain: true
   })
-  let config = {headers: { 'X-Requested-With': 'XMLHttpRequest' }}
+  let config = (process.env.PROD) ? {headers: { 'X-Requested-With': 'XMLHttpRequest' }} : {}
   return $http.get(baseUrlSrv.getRestApiBase() + '/security/ticket', config).then(function (response) {
     zeppelinWebApp.run(function ($rootScope) {
       $rootScope.ticket = angular.fromJson(response.data).body

http://git-wip-us.apache.org/repos/asf/zeppelin/blob/0443b001/zeppelin-web/webpack.config.js
----------------------------------------------------------------------
diff --git a/zeppelin-web/webpack.config.js b/zeppelin-web/webpack.config.js
index 88c7acc..5c2e1df 100644
--- a/zeppelin-web/webpack.config.js
+++ b/zeppelin-web/webpack.config.js
@@ -236,6 +236,7 @@ module.exports = function makeWebpackConfig () {
           HELIUM_BUNDLE_DEV: process.env.HELIUM_BUNDLE_DEV,
           SERVER_PORT: serverPort,
           WEB_PORT: webPort,
+          PROD: isProd,
           BUILD_CI: (isCI) ? JSON.stringify(true) : JSON.stringify(false)
         }
       })