YARN-6631. Refactor loader.js in new Yarn UI. Contributed by Akhil P B.

This commit is contained in:
Sunil G 2017-08-10 11:53:26 +05:30
parent ac7d0604bc
commit 8d953c2359
1 changed files with 19 additions and 23 deletions

View File

@ -20,25 +20,27 @@
import Ember from 'ember';
function getTimeLineURL() {
return '/conf?name=yarn.timeline-service.webapp.address';
function getTimeLineURL(rmhost) {
var url = window.location.protocol + '//' +
(ENV.hosts.localBaseAddress? ENV.hosts.localBaseAddress + '/' : '') + rmhost;
url += '/conf?name=yarn.timeline-service.webapp.address';
Ember.Logger.log("Get Timeline Address URL: " + url);
return url;
}
function updateConfigs(application) {
var hostname = window.location.hostname;
var rmhost = hostname +
(window.location.port ? ':' + window.location.port: '');
Ember.Logger.log("RM Address:" + rmhost);
var rmhost = hostname + (window.location.port ? ':' + window.location.port: '');
if(!ENV.hosts.rmWebAddress) {
ENV = {
hosts: {
rmWebAddress: rmhost,
},
};
ENV.hosts.rmWebAddress = rmhost;
} else {
rmhost = ENV.hosts.rmWebAddress;
}
Ember.Logger.log("RM Address: " + rmhost);
if(!ENV.hosts.timelineWebAddress) {
var timelinehost = "";
$.ajax({
@ -46,7 +48,7 @@ function updateConfigs(application) {
dataType: 'json',
async: true,
context: this,
url: getTimeLineURL(),
url: getTimeLineURL(rmhost),
success: function(data) {
timelinehost = data.property.value;
ENV.hosts.timelineWebAddress = timelinehost;
@ -54,24 +56,18 @@ function updateConfigs(application) {
var address = timelinehost.split(":")[0];
var port = timelinehost.split(":")[1];
Ember.Logger.log("Timeline Address from RM:" + address + ":" + port);
Ember.Logger.log("Timeline Address from RM: " + timelinehost);
if(address === "0.0.0.0" || address === "localhost") {
var updatedAddress = hostname + ":" + port;
/* Timeline v2 is not supporting CORS, so make as default*/
ENV = {
hosts: {
rmWebAddress: rmhost,
timelineWebAddress: updatedAddress,
},
};
Ember.Logger.log("Timeline Updated Address:" + updatedAddress);
ENV.hosts.timelineWebAddress = updatedAddress;
Ember.Logger.log("Timeline Updated Address: " + updatedAddress);
}
application.advanceReadiness();
},
}
});
} else {
Ember.Logger.log("Timeline Address: " + ENV.hosts.timelineWebAddress);
application.advanceReadiness();
}
}