You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tez.apache.org by sr...@apache.org on 2015/12/29 18:07:53 UTC

tez git commit: TEZ-3018. Tez UI 2: Add config.env (sree)

Repository: tez
Updated Branches:
  refs/heads/TEZ-2980 e565cae10 -> 260e13cba


TEZ-3018. Tez UI 2: Add config.env (sree)


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

Branch: refs/heads/TEZ-2980
Commit: 260e13cba1fceccbbcfc789642806b6bde443664
Parents: e565cae
Author: Sreenath Somarajapuram <sr...@apache.org>
Authored: Tue Dec 29 22:37:26 2015 +0530
Committer: Sreenath Somarajapuram <sr...@apache.org>
Committed: Tue Dec 29 22:37:26 2015 +0530

----------------------------------------------------------------------
 TEZ-2980-CHANGES.txt                            |  1 +
 tez-ui2/src/main/webapp/app/app.js              | 20 +++++++++++-
 tez-ui2/src/main/webapp/app/index.html          | 20 ++++++++++++
 tez-ui2/src/main/webapp/app/services/hosts.js   | 27 ++++++++++------
 .../main/webapp/app/templates/application.hbs   | 20 ++++++++++++
 tez-ui2/src/main/webapp/config/configs.env      |  4 +++
 tez-ui2/src/main/webapp/ember-cli-build.js      | 24 +++++---------
 tez-ui2/src/main/webapp/package.json            |  1 +
 .../webapp/tests/unit/services/hosts-test.js    | 34 ++++++++++++++++++++
 9 files changed, 125 insertions(+), 26 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/tez/blob/260e13cb/TEZ-2980-CHANGES.txt
----------------------------------------------------------------------
diff --git a/TEZ-2980-CHANGES.txt b/TEZ-2980-CHANGES.txt
index 4a4edaf..e792420 100644
--- a/TEZ-2980-CHANGES.txt
+++ b/TEZ-2980-CHANGES.txt
@@ -2,3 +2,4 @@ ALL CHANGES:
   TEZ-2982. Tez UI: Create tez-ui2 directory and get a basic dummy page working in ember 2.2
   TEZ-3016. Tez UI 2: Make bower dependency silent
   TEZ-2983. Tez UI 2: Get ember initializers functional
+  TEZ-3018. Tez UI 2: Add config.env

http://git-wip-us.apache.org/repos/asf/tez/blob/260e13cb/tez-ui2/src/main/webapp/app/app.js
----------------------------------------------------------------------
diff --git a/tez-ui2/src/main/webapp/app/app.js b/tez-ui2/src/main/webapp/app/app.js
index 8b234d6..fb4695c 100644
--- a/tez-ui2/src/main/webapp/app/app.js
+++ b/tez-ui2/src/main/webapp/app/app.js
@@ -1,5 +1,23 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
 import Ember from 'ember';
-import Resolver from 'ember/resolver';
+import Resolver from 'ember-resolver';
 import loadInitializers from 'ember/load-initializers';
 import config from './config/environment';
 

http://git-wip-us.apache.org/repos/asf/tez/blob/260e13cb/tez-ui2/src/main/webapp/app/index.html
----------------------------------------------------------------------
diff --git a/tez-ui2/src/main/webapp/app/index.html b/tez-ui2/src/main/webapp/app/index.html
index 23a7578..2108d0f 100644
--- a/tez-ui2/src/main/webapp/app/index.html
+++ b/tez-ui2/src/main/webapp/app/index.html
@@ -1,3 +1,21 @@
+<!--
+* Licensed to the Apache Software Foundation (ASF) under one
+* or more contributor license agreements.  See the NOTICE file
+* distributed with this work for additional information
+* regarding copyright ownership.  The ASF licenses this file
+* to you under the Apache License, Version 2.0 (the
+* "License"); you may not use this file except in compliance
+* with the License.  You may obtain a copy of the License at
+*
+*     http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+-->
+
 <!DOCTYPE html>
 <html>
   <head>
@@ -17,6 +35,8 @@
   <body>
     {{content-for 'body'}}
 
+    <script src="config/configs.env"></script>
+
     <script src="assets/vendor.js"></script>
     <script src="assets/tez-ui.js"></script>
 

http://git-wip-us.apache.org/repos/asf/tez/blob/260e13cb/tez-ui2/src/main/webapp/app/services/hosts.js
----------------------------------------------------------------------
diff --git a/tez-ui2/src/main/webapp/app/services/hosts.js b/tez-ui2/src/main/webapp/app/services/hosts.js
index 5bdc6d1..7ffdc29 100644
--- a/tez-ui2/src/main/webapp/app/services/hosts.js
+++ b/tez-ui2/src/main/webapp/app/services/hosts.js
@@ -21,18 +21,27 @@ import environment from '../config/environment';
 
 export default Ember.Service.extend({
 
-  correctProtocol: function (url) {
-    var proto = window.location.protocol;
+  correctProtocol: function (url, localProto) {
+    var urlProto;
 
-    if(proto === "file:") {
-      proto = "http:";
+    localProto = localProto || window.location.protocol;
+
+    if(url.match("://")) {
+      urlProto = url.substr(0, url.indexOf("//"));
+    }
+
+    if(localProto === "file:") {
+      urlProto = urlProto || "http:";
+    }
+    else {
+      urlProto = localProto;
     }
 
     if(url.match("://")) {
       url = url.substr(url.indexOf("://") + 3);
     }
 
-    return proto + "//" + url;
+    return urlProto + "//" + url;
   },
 
   normalizeURL: function (url) {
@@ -46,13 +55,13 @@ export default Ember.Service.extend({
   },
 
   timelineBaseURL: Ember.computed(function () {
-    // Todo: Use global ENV if available
-    // Todo: Use loaded host if protocol is != file
-    return this.normalizeURL(environment.hosts.timeline);
+    var ENV = window.ENV;
+    return this.normalizeURL((ENV && ENV.timelineBaseURL) || environment.hosts.timeline);
   }),
 
   rmBaseURL: Ember.computed(function () {
-    return this.normalizeURL(environment.hosts.RM);
+    var ENV = window.ENV;
+    return this.normalizeURL((ENV && ENV.rmBaseURL) || environment.hosts.RM);
   }),
 
 });

http://git-wip-us.apache.org/repos/asf/tez/blob/260e13cb/tez-ui2/src/main/webapp/app/templates/application.hbs
----------------------------------------------------------------------
diff --git a/tez-ui2/src/main/webapp/app/templates/application.hbs b/tez-ui2/src/main/webapp/app/templates/application.hbs
index f8bc38e..c1c380d 100644
--- a/tez-ui2/src/main/webapp/app/templates/application.hbs
+++ b/tez-ui2/src/main/webapp/app/templates/application.hbs
@@ -1,3 +1,23 @@
+{{!
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+}}
+
 <h2 id="title">Welcome to Ember</h2>
 
 {{outlet}}
+
+{{hosts.timelineBaseURL}}

http://git-wip-us.apache.org/repos/asf/tez/blob/260e13cb/tez-ui2/src/main/webapp/config/configs.env
----------------------------------------------------------------------
diff --git a/tez-ui2/src/main/webapp/config/configs.env b/tez-ui2/src/main/webapp/config/configs.env
new file mode 100644
index 0000000..6e12286
--- /dev/null
+++ b/tez-ui2/src/main/webapp/config/configs.env
@@ -0,0 +1,4 @@
+ENV = {
+  //timelineBaseURL: "http://localhost:8188",
+  //rmBaseURL: "http://localhost:8088"
+};

http://git-wip-us.apache.org/repos/asf/tez/blob/260e13cb/tez-ui2/src/main/webapp/ember-cli-build.js
----------------------------------------------------------------------
diff --git a/tez-ui2/src/main/webapp/ember-cli-build.js b/tez-ui2/src/main/webapp/ember-cli-build.js
index 9f33b64..ede63b3 100644
--- a/tez-ui2/src/main/webapp/ember-cli-build.js
+++ b/tez-ui2/src/main/webapp/ember-cli-build.js
@@ -19,28 +19,20 @@
  * limitations under the License.
  */
 
+var Funnel = require("broccoli-funnel");
 var EmberApp = require('ember-cli/lib/broccoli/ember-app');
 
 module.exports = function(defaults) {
-  var app = new EmberApp(defaults, {
-    // Add options here
-  });
+  var app = new EmberApp(defaults, {});
 
-  // Use `app.import` to add additional libraries to the generated
-  // output files.
-  //
-  // If you need to use different assets in different
-  // environments, specify an object as the first parameter. That
-  // object's keys should be the environment name and the values
-  // should be the asset to use in that environment.
-  //
-  // If the library that you are including contains AMD or ES6
-  // modules that you would like to import into your application
-  // please specify an object with the list of modules as keys
-  // along with the exports of each module as its value.
+  var extraAssets = new Funnel('config', {
+     srcDir: '/',
+     include: ['*.env'],
+     destDir: '/config'
+  });
 
   app.import('bower_components/jquery-ui/jquery-ui.js');
   app.import('bower_components/jquery-ui/ui/tooltip.js');
 
-  return app.toTree();
+  return app.toTree(extraAssets);
 };

http://git-wip-us.apache.org/repos/asf/tez/blob/260e13cb/tez-ui2/src/main/webapp/package.json
----------------------------------------------------------------------
diff --git a/tez-ui2/src/main/webapp/package.json b/tez-ui2/src/main/webapp/package.json
index 38c76da..da85316 100644
--- a/tez-ui2/src/main/webapp/package.json
+++ b/tez-ui2/src/main/webapp/package.json
@@ -40,6 +40,7 @@
     "ember-resolver": "^2.0.3"
   },
   "dependencies": {
+    "broccoli-funnel": "^1.0.1",
     "ember-cli-htmlbars": "^1.0.1",
     "ember-cli-less": "^1.4.0"
   }

http://git-wip-us.apache.org/repos/asf/tez/blob/260e13cb/tez-ui2/src/main/webapp/tests/unit/services/hosts-test.js
----------------------------------------------------------------------
diff --git a/tez-ui2/src/main/webapp/tests/unit/services/hosts-test.js b/tez-ui2/src/main/webapp/tests/unit/services/hosts-test.js
index 8136ae4..b130a2c 100644
--- a/tez-ui2/src/main/webapp/tests/unit/services/hosts-test.js
+++ b/tez-ui2/src/main/webapp/tests/unit/services/hosts-test.js
@@ -39,4 +39,38 @@ test('Test correctProtocol', function(assert) {
   assert.equal(service.correctProtocol("localhost:8088"), "http://localhost:8088");
   assert.equal(service.correctProtocol("https://localhost:8088"), "http://localhost:8088");
   assert.equal(service.correctProtocol("file://localhost:8088"), "http://localhost:8088");
+
+  assert.equal(service.correctProtocol("localhost:8088", "http:"), "http://localhost:8088");
+  assert.equal(service.correctProtocol("https://localhost:8088", "http:"), "http://localhost:8088");
+  assert.equal(service.correctProtocol("file://localhost:8088", "http:"), "http://localhost:8088");
+
+  assert.equal(service.correctProtocol("localhost:8088", "https:"), "https://localhost:8088");
+  assert.equal(service.correctProtocol("https://localhost:8088", "https:"), "https://localhost:8088");
+  assert.equal(service.correctProtocol("file://localhost:8088", "https:"), "https://localhost:8088");
+});
+
+test('Test correctProtocol with protocol=file:', function(assert) {
+  let service = this.subject();
+
+  assert.equal(service.correctProtocol("file://localhost:8088", "file:"), "file://localhost:8088");
+  assert.equal(service.correctProtocol("http://localhost:8088", "file:"), "http://localhost:8088");
+  assert.equal(service.correctProtocol("https://localhost:8088", "file:"), "https://localhost:8088");
+});
+
+test('Test base URLs', function(assert) {
+  let service = this.subject();
+
+  assert.equal(service.get("timelineBaseURL"), "http://localhost:8188");
+  assert.equal(service.get("rmBaseURL"), "http://localhost:8088");
+});
+
+test('Test base URLs with ENV set', function(assert) {
+  let service = this.subject();
+
+  window.ENV = {
+    timelineBaseURL: "https://localhost:3333",
+    rmBaseURL: "https://localhost:4444"
+  };
+  assert.equal(service.get("timelineBaseURL"), "http://localhost:3333");
+  assert.equal(service.get("rmBaseURL"), "http://localhost:4444");
 });