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 2016/02/24 23:34:39 UTC
[02/45] tez git commit: TEZ-2983. Tez UI 2: Get ember initializers
functional (sree)
TEZ-2983. Tez UI 2: Get ember initializers functional (sree)
Project: http://git-wip-us.apache.org/repos/asf/tez/repo
Commit: http://git-wip-us.apache.org/repos/asf/tez/commit/1e5a3154
Tree: http://git-wip-us.apache.org/repos/asf/tez/tree/1e5a3154
Diff: http://git-wip-us.apache.org/repos/asf/tez/diff/1e5a3154
Branch: refs/heads/TEZ-2980
Commit: 1e5a3154f5db0c3c90dbc3449ea4870599c6fbc9
Parents: 0c9601a
Author: Sreenath Somarajapuram <sr...@apache.org>
Authored: Tue Dec 29 20:32:23 2015 +0530
Committer: Sreenath Somarajapuram <sr...@apache.org>
Committed: Thu Feb 25 03:31:58 2016 +0530
----------------------------------------------------------------------
TEZ-2980-CHANGES.txt | 1 +
.../src/main/webapp/app/initializers/hosts.js | 27 +++++++++
.../src/main/webapp/app/initializers/jquery.js | 43 +++++++++++++++
.../webapp/app/initializers/object-transform.js | 37 +++++++++++++
tez-ui2/src/main/webapp/app/services/hosts.js | 58 ++++++++++++++++++++
tez-ui2/src/main/webapp/app/styles/app.less | 23 ++++++++
tez-ui2/src/main/webapp/bower.json | 3 +-
tez-ui2/src/main/webapp/config/environment.js | 23 ++++++++
tez-ui2/src/main/webapp/ember-cli-build.js | 22 ++++++++
.../tests/unit/initializers/hosts-test.js | 38 +++++++++++++
.../tests/unit/initializers/jquery-test.js | 38 +++++++++++++
.../unit/initializers/object-transform-test.js | 38 +++++++++++++
.../webapp/tests/unit/services/hosts-test.js | 42 ++++++++++++++
13 files changed, 392 insertions(+), 1 deletion(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/tez/blob/1e5a3154/TEZ-2980-CHANGES.txt
----------------------------------------------------------------------
diff --git a/TEZ-2980-CHANGES.txt b/TEZ-2980-CHANGES.txt
index cb91f25..4a4edaf 100644
--- a/TEZ-2980-CHANGES.txt
+++ b/TEZ-2980-CHANGES.txt
@@ -1,3 +1,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
http://git-wip-us.apache.org/repos/asf/tez/blob/1e5a3154/tez-ui2/src/main/webapp/app/initializers/hosts.js
----------------------------------------------------------------------
diff --git a/tez-ui2/src/main/webapp/app/initializers/hosts.js b/tez-ui2/src/main/webapp/app/initializers/hosts.js
new file mode 100644
index 0000000..8791fc7
--- /dev/null
+++ b/tez-ui2/src/main/webapp/app/initializers/hosts.js
@@ -0,0 +1,27 @@
+/**
+ * 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.
+ */
+
+export function initialize(application) {
+ application.inject('controller', 'hosts', 'service:hosts');
+ application.inject('adapter', 'hosts', 'service:hosts');
+}
+
+export default {
+ name: 'hosts',
+ initialize
+};
http://git-wip-us.apache.org/repos/asf/tez/blob/1e5a3154/tez-ui2/src/main/webapp/app/initializers/jquery.js
----------------------------------------------------------------------
diff --git a/tez-ui2/src/main/webapp/app/initializers/jquery.js b/tez-ui2/src/main/webapp/app/initializers/jquery.js
new file mode 100644
index 0000000..b0c52eb
--- /dev/null
+++ b/tez-ui2/src/main/webapp/app/initializers/jquery.js
@@ -0,0 +1,43 @@
+/*global $*/
+
+/**
+ * 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 environment from '../config/environment';
+
+export function initialize(/* application */) {
+ if(environment.environment !== 'test') {
+ $(document).tooltip({
+ delay: 20,
+ tooltipClass: 'generic-tooltip'
+ });
+
+ $.ajaxPrefilter(function(options, originalOptions, jqXHR) {
+ jqXHR.requestOptions = originalOptions;
+ });
+
+ $.ajaxSetup({
+ cache: false
+ });
+ }
+}
+
+export default {
+ name: 'jquery',
+ initialize
+};
http://git-wip-us.apache.org/repos/asf/tez/blob/1e5a3154/tez-ui2/src/main/webapp/app/initializers/object-transform.js
----------------------------------------------------------------------
diff --git a/tez-ui2/src/main/webapp/app/initializers/object-transform.js b/tez-ui2/src/main/webapp/app/initializers/object-transform.js
new file mode 100644
index 0000000..57502cf
--- /dev/null
+++ b/tez-ui2/src/main/webapp/app/initializers/object-transform.js
@@ -0,0 +1,37 @@
+/**
+ * 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 DS from "ember-data";
+
+export function initialize(application) {
+ application.register('transform:object', DS.Transform.extend({
+ deserialize: function(serialized) {
+ return Ember.none(serialized) ? {} : serialized;
+ },
+
+ serialized: function(deserialized) {
+ return Ember.none(deserialized) ? {} : deserialized;
+ }
+ }));
+}
+
+export default {
+ name: 'object-transform',
+ initialize
+};
http://git-wip-us.apache.org/repos/asf/tez/blob/1e5a3154/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
new file mode 100644
index 0000000..5bdc6d1
--- /dev/null
+++ b/tez-ui2/src/main/webapp/app/services/hosts.js
@@ -0,0 +1,58 @@
+/**
+ * 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 environment from '../config/environment';
+
+export default Ember.Service.extend({
+
+ correctProtocol: function (url) {
+ var proto = window.location.protocol;
+
+ if(proto === "file:") {
+ proto = "http:";
+ }
+
+ if(url.match("://")) {
+ url = url.substr(url.indexOf("://") + 3);
+ }
+
+ return proto + "//" + url;
+ },
+
+ normalizeURL: function (url) {
+ url = this.correctProtocol(url);
+
+ // Remove trailing slash
+ if(url && url.charAt(url.length - 1) === '/') {
+ url = url.slice(0, -1);
+ }
+ return url;
+ },
+
+ timelineBaseURL: Ember.computed(function () {
+ // Todo: Use global ENV if available
+ // Todo: Use loaded host if protocol is != file
+ return this.normalizeURL(environment.hosts.timeline);
+ }),
+
+ rmBaseURL: Ember.computed(function () {
+ return this.normalizeURL(environment.hosts.RM);
+ }),
+
+});
http://git-wip-us.apache.org/repos/asf/tez/blob/1e5a3154/tez-ui2/src/main/webapp/app/styles/app.less
----------------------------------------------------------------------
diff --git a/tez-ui2/src/main/webapp/app/styles/app.less b/tez-ui2/src/main/webapp/app/styles/app.less
index 8b13789..8a21537 100644
--- a/tez-ui2/src/main/webapp/app/styles/app.less
+++ b/tez-ui2/src/main/webapp/app/styles/app.less
@@ -1 +1,24 @@
+/**
+ * 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.
+ */
+.generic-tooltip {
+ padding: 3px 5px !important;
+ background: rgba(0,0,0,.8) !important;
+ color: white !important;
+ border: none !important;
+}
http://git-wip-us.apache.org/repos/asf/tez/blob/1e5a3154/tez-ui2/src/main/webapp/bower.json
----------------------------------------------------------------------
diff --git a/tez-ui2/src/main/webapp/bower.json b/tez-ui2/src/main/webapp/bower.json
index fb312cb..b6c7ca5 100644
--- a/tez-ui2/src/main/webapp/bower.json
+++ b/tez-ui2/src/main/webapp/bower.json
@@ -10,6 +10,7 @@
"ember-qunit-notifications": "0.1.0",
"jquery": "^1.11.3",
"loader.js": "3.3.0",
- "qunit": "~1.19.0"
+ "qunit": "~1.19.0",
+ "jquery-ui": "~1.11.4"
}
}
http://git-wip-us.apache.org/repos/asf/tez/blob/1e5a3154/tez-ui2/src/main/webapp/config/environment.js
----------------------------------------------------------------------
diff --git a/tez-ui2/src/main/webapp/config/environment.js b/tez-ui2/src/main/webapp/config/environment.js
index 9243b2b..e061066 100644
--- a/tez-ui2/src/main/webapp/config/environment.js
+++ b/tez-ui2/src/main/webapp/config/environment.js
@@ -1,5 +1,23 @@
/* jshint node: true */
+/**
+ * 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.
+ */
+
module.exports = function(environment) {
var ENV = {
modulePrefix: 'tez-ui',
@@ -16,6 +34,11 @@ module.exports = function(environment) {
APP: {
// Here you can pass flags/options to your application instance
// when it is created
+ },
+
+ hosts: {
+ timeline: 'localhost:8188',
+ RM: 'localhost:8088'
}
};
http://git-wip-us.apache.org/repos/asf/tez/blob/1e5a3154/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 2537ce2..9f33b64 100644
--- a/tez-ui2/src/main/webapp/ember-cli-build.js
+++ b/tez-ui2/src/main/webapp/ember-cli-build.js
@@ -1,5 +1,24 @@
/*jshint node:true*/
/* global require, module */
+
+/**
+ * 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.
+ */
+
var EmberApp = require('ember-cli/lib/broccoli/ember-app');
module.exports = function(defaults) {
@@ -20,5 +39,8 @@ module.exports = function(defaults) {
// please specify an object with the list of modules as keys
// along with the exports of each module as its value.
+ app.import('bower_components/jquery-ui/jquery-ui.js');
+ app.import('bower_components/jquery-ui/ui/tooltip.js');
+
return app.toTree();
};
http://git-wip-us.apache.org/repos/asf/tez/blob/1e5a3154/tez-ui2/src/main/webapp/tests/unit/initializers/hosts-test.js
----------------------------------------------------------------------
diff --git a/tez-ui2/src/main/webapp/tests/unit/initializers/hosts-test.js b/tez-ui2/src/main/webapp/tests/unit/initializers/hosts-test.js
new file mode 100644
index 0000000..5244c77
--- /dev/null
+++ b/tez-ui2/src/main/webapp/tests/unit/initializers/hosts-test.js
@@ -0,0 +1,38 @@
+/**
+ * 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 HostsInitializer from '../../../initializers/hosts';
+import { module, test } from 'qunit';
+
+let application;
+
+module('Unit | Initializer | hosts', {
+ beforeEach() {
+ Ember.run(function() {
+ application = Ember.Application.create();
+ application.deferReadiness();
+ });
+ }
+});
+
+test('it works', function(assert) {
+ HostsInitializer.initialize(application);
+
+ assert.ok(true);
+});
http://git-wip-us.apache.org/repos/asf/tez/blob/1e5a3154/tez-ui2/src/main/webapp/tests/unit/initializers/jquery-test.js
----------------------------------------------------------------------
diff --git a/tez-ui2/src/main/webapp/tests/unit/initializers/jquery-test.js b/tez-ui2/src/main/webapp/tests/unit/initializers/jquery-test.js
new file mode 100644
index 0000000..e30f427
--- /dev/null
+++ b/tez-ui2/src/main/webapp/tests/unit/initializers/jquery-test.js
@@ -0,0 +1,38 @@
+/**
+ * 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 JqueryInitializer from '../../../initializers/jquery';
+import { module, test } from 'qunit';
+
+let application;
+
+module('Unit | Initializer | jquery', {
+ beforeEach() {
+ Ember.run(function() {
+ application = Ember.Application.create();
+ application.deferReadiness();
+ });
+ }
+});
+
+test('it works', function(assert) {
+ JqueryInitializer.initialize(application);
+
+ assert.ok(true);
+});
http://git-wip-us.apache.org/repos/asf/tez/blob/1e5a3154/tez-ui2/src/main/webapp/tests/unit/initializers/object-transform-test.js
----------------------------------------------------------------------
diff --git a/tez-ui2/src/main/webapp/tests/unit/initializers/object-transform-test.js b/tez-ui2/src/main/webapp/tests/unit/initializers/object-transform-test.js
new file mode 100644
index 0000000..a52a7bd
--- /dev/null
+++ b/tez-ui2/src/main/webapp/tests/unit/initializers/object-transform-test.js
@@ -0,0 +1,38 @@
+/**
+ * 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 ObjectTransformInitializer from '../../../initializers/object-transform';
+import { module, test } from 'qunit';
+
+let application;
+
+module('Unit | Initializer | object transform', {
+ beforeEach() {
+ Ember.run(function() {
+ application = Ember.Application.create();
+ application.deferReadiness();
+ });
+ }
+});
+
+test('it works', function(assert) {
+ ObjectTransformInitializer.initialize(application);
+
+ assert.ok(true);
+});
http://git-wip-us.apache.org/repos/asf/tez/blob/1e5a3154/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
new file mode 100644
index 0000000..8136ae4
--- /dev/null
+++ b/tez-ui2/src/main/webapp/tests/unit/services/hosts-test.js
@@ -0,0 +1,42 @@
+/**
+ * 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 { moduleFor, test } from 'ember-qunit';
+
+moduleFor('service:hosts', 'Unit | Service | hosts', {
+ // Specify the other units that are required for this test.
+ // needs: ['service:foo']
+});
+
+// Replace this with your real tests.
+test('Test creation', function(assert) {
+ let service = this.subject();
+ assert.ok(service);
+});
+
+test('Test correctProtocol', function(assert) {
+ let service = this.subject();
+
+ //No correction
+ assert.equal(service.correctProtocol("http://localhost:8088"), "http://localhost:8088");
+
+ // Correction
+ 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");
+});