ambari-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From srima...@apache.org
Subject ambari git commit: AMBARI-13783. Tez Ambari View : Make UI use proxy end points provided by AMBARI-13612 (Sreenath Somarajapuram via srimanth)
Date Tue, 10 Nov 2015 05:45:54 GMT
Repository: ambari
Updated Branches:
  refs/heads/trunk 47e8d3ad9 -> ec6da401e


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/ec6da401
Tree: http://git-wip-us.apache.org/repos/asf/ambari/tree/ec6da401
Diff: http://git-wip-us.apache.org/repos/asf/ambari/diff/ec6da401

Branch: refs/heads/trunk
Commit: ec6da401e28f5146ab2d71c7e0a078254c0282b3
Parents: 47e8d3a
Author: Srimanth Gunturi <sgunturi@hortonworks.com>
Authored: Mon Nov 9 21:44:46 2015 -0800
Committer: Srimanth Gunturi <sgunturi@hortonworks.com>
Committed: Mon Nov 9 21:45:39 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/ec6da401/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();
 }


Mime
View raw message