You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ambari.apache.org by sr...@apache.org on 2015/11/10 06:45:13 UTC

ambari git commit: AMBARI-13783. Tez Ambari View : Make UI use proxy end points provided by AMBARI-13612 (Sreenath Somarajapuram via srimanth)

Repository: ambari
Updated Branches:
  refs/heads/branch-2.1 8144dbdd4 -> e6b276c84


AMBARI-13783. Tez Ambari View : Make UI use proxy end points provided by AMBARI-13612 (Sreenath Somarajapuram via srimanth)


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

Branch: refs/heads/branch-2.1
Commit: e6b276c84bd85dd57cb29bf4d886f380abb2a1db
Parents: 8144dbd
Author: Srimanth Gunturi <sg...@hortonworks.com>
Authored: Mon Nov 9 21:44:46 2015 -0800
Committer: Srimanth Gunturi <sg...@hortonworks.com>
Committed: Mon Nov 9 21:44:46 2015 -0800

----------------------------------------------------------------------
 .../resources/ui/scripts/init-ambari-view.js    | 146 +++++--------------
 1 file changed, 33 insertions(+), 113 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ambari/blob/e6b276c8/contrib/views/tez/src/main/resources/ui/scripts/init-ambari-view.js
----------------------------------------------------------------------
diff --git a/contrib/views/tez/src/main/resources/ui/scripts/init-ambari-view.js b/contrib/views/tez/src/main/resources/ui/scripts/init-ambari-view.js
index 5c616e5..5152fb9 100644
--- a/contrib/views/tez/src/main/resources/ui/scripts/init-ambari-view.js
+++ b/contrib/views/tez/src/main/resources/ui/scripts/init-ambari-view.js
@@ -102,92 +102,6 @@ function redirectionCheck() {
   }
 }
 
-App.Helpers.ambari = (function () {
-  /**
-   * Stores parameters from Ambari.
-   */
-  var ambariParameters = {},
-
-  /**
-   * Constructs URL for fetching Ambari view instance parameters.
-   * @return {String}
-   */
-  getURL = function () {
-    var urlParts = location.pathname.split('/');
-
-    return "/api/v1/views/%@/versions/%@/instances/%@/resources/status".fmt(
-      urlParts[2],
-      urlParts[3],
-      urlParts[4]
-    );
-  };
-
-  return {
-    /**
-     * Key for the property representing ATS url.
-     */
-    TIMELINE_URL: 'yarn.timeline-server.url',
-    RM_URL: 'yarn.resourcemanager.url',
-
-    /**
-     * Returns parameter value.
-     * @param {String} name
-     * @return {String}
-     * @method getParam
-     */
-    getParam: function (name) {
-      Ember.assert('Parameter not found!', ambariParameters[name]);
-      return ambariParameters[name];
-    },
-
-    /**
-     * Get view instance properties provided by user.
-     * @returns {$.ajax}
-     * @method getInstanceParameters
-     */
-    getInstanceParameters: function () {
-      var hashArray = location.pathname.split('/'),
-      params = {
-        view: hashArray[2],
-        version: hashArray[3],
-        instanceName: hashArray[4],
-        clusterName: App.get('clusterName')
-      };
-
-      return $.ajax({
-        type: 'GET',
-        dataType: 'json',
-        async: true,
-        context: this,
-        url: getURL(),
-        success: this.getInstanceParametersSuccessCallback,
-        error: this.getInstanceParametersErrorCallback
-      });
-    },
-
-    /**
-     * Success callback for getInstanceParameters-request.
-     * @param {object} data
-     * @method getInstanceParametersSuccessCallback
-     */
-    getInstanceParametersSuccessCallback: function (data) {
-      Ember.assert('Ambari instance parameter weren`t returned by the service!', data.parameters);
-      ambariParameters = data.parameters;
-    },
-
-    /**
-     * Error callback for getInstanceParameters-request.
-     * @method getInstanceParametersErrorCallback
-     */
-    getInstanceParametersErrorCallback: function (request, ajaxOptions, error) {
-      var json = request.responseJSON;
-      App.Helpers.ErrorBar.getInstance().show(json.message, json.trace);
-      Ember.assert(json.message);
-    }
-  };
-
-})();
-
 function allowFullScreen() {
   if(window.parent) {
     var arrFrames = parent.document.getElementsByTagName("IFRAME"),
@@ -205,26 +119,6 @@ function allowFullScreen() {
   }
 }
 
-function loadParams() {
-  App.Helpers.ambari.getInstanceParameters().then(function () {
-    var timelineBaseUrl = App.Helpers.ambari.getParam(App.Helpers.ambari.TIMELINE_URL),
-        RMWebUrl = App.Helpers.ambari.getParam(App.Helpers.ambari.RM_URL);
-    $.extend(true, App.Configs, {
-      envDefaults: {
-        isStandalone: false,
-        timelineBaseUrl: timelineBaseUrl.match('://') ?
-            timelineBaseUrl :
-            '%@//%@'.fmt(location.protocol, timelineBaseUrl),
-        RMWebUrl: RMWebUrl.match('://') ?
-            RMWebUrl :
-            '%@//%@'.fmt(location.protocol, RMWebUrl)
-      }
-    });
-
-    App.advanceReadiness();
-  });
-}
-
 function onPathChange() {
   var path = window.location.hash.substr(2).trim(),
       pathParts = path.split('?'),
@@ -248,6 +142,38 @@ function scheduleChangeHandler(arguments) {
   setTimeout(onPathChange, 100);
 }
 
+function setConfigs() {
+  var host = window.location.origin,
+      urlParts = location.pathname.split('/'),
+      resourcesPrefix = 'api/v1/views/%@/versions/%@/instances/%@/resources/'.fmt(
+        urlParts[2],
+        urlParts[3],
+        urlParts[4]
+      );
+
+  $.extend(true, App.Configs, {
+    envDefaults: {
+      isStandalone: false,
+      timelineBaseUrl: host,
+      RMWebUrl: host,
+    },
+    restNamespace: {
+      timeline: '%@atsproxy/ws/v1/timeline'.fmt(resourcesPrefix),
+      applicationHistory: '%@atsproxy/ws/v1/applicationhistory'.fmt(resourcesPrefix),
+
+      aminfo: '%@rmproxy/proxy/__app_id__/ws/v1/tez'.fmt(resourcesPrefix),
+      aminfoV2: '%@rmproxy/proxy/__app_id__/ws/v2/tez'.fmt(resourcesPrefix),
+      cluster: '%@rmproxy/ws/v1/cluster'.fmt(resourcesPrefix)
+    }
+  });
+
+  App.TimelineRESTAdapter.reopen({
+    namespace: App.Configs.restNamespace.timeline
+  });
+
+  App.advanceReadiness();
+}
+
 if(!redirectionCheck()) {
   App.ApplicationRoute.reopen({
     actions: {
@@ -257,11 +183,5 @@ if(!redirectionCheck()) {
   });
 
   allowFullScreen();
-  loadParams();
-
-  Ember.$.ajaxSetup({
-    beforeSend: function (jqXHR, settings) {
-      settings.url = location.pathname + 'proxy?url=' + encodeURIComponent(settings.url);
-    }
-  });
+  setConfigs();
 }