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