Skip to content

Commit

Permalink
TEZ-1823. default ATS url should be the same host as ui (Prakash Rama…
Browse files Browse the repository at this point in the history
…chandran via Rajesh Balamohan)
  • Loading branch information
Rajesh Balamohan committed Dec 8, 2014
1 parent 7f44359 commit 58a9119
Show file tree
Hide file tree
Showing 8 changed files with 42 additions and 11 deletions.
3 changes: 2 additions & 1 deletion tez-ui/src/main/webapp/app/scripts/controllers/dag_tasks.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ App.DagTasksController = Em.ObjectController.extend(App.PaginatedContentMixin, A
store = this.get('store'),
fetcher;
childEntityType = this.get('childEntityType');
var defaultErrMsg = 'Error while loading tasks. could not connect to %@'.fmt(App.env.timelineBaseUrl);

store.unloadAll(childEntityType);
store.findQuery(childEntityType, this.getFilterProperties()).then(function(entities){
Expand All @@ -70,7 +71,7 @@ App.DagTasksController = Em.ObjectController.extend(App.PaginatedContentMixin, A
});
}).catch(function(error){
Em.Logger.error(error);
var err = App.Helpers.misc.formatError(error);
var err = App.Helpers.misc.formatError(error, defaultErrMsg);
var msg = 'error code: %@, message: %@'.fmt(err.errCode, err.msg);
App.Helpers.ErrorBar.getInstance().show(msg, error.details);
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ App.DagsController = Em.ObjectController.extend(App.PaginatedContentMixin, App.C
store = this.get('store'),
childEntityType = this.get('childEntityType'),
fetcher;
var defaultErrMsg = 'Error while loading dag info. could not connect to %@'.fmt(App.env.timelineBaseUrl);

store.unloadAll(childEntityType);
store.findQuery(childEntityType, this.getFilterProperties()).then(function(entities){
Expand Down Expand Up @@ -101,7 +102,7 @@ App.DagsController = Em.ObjectController.extend(App.PaginatedContentMixin, App.C
});
}).catch(function(error){
Em.Logger.error(error);
var err = App.Helpers.misc.formatError(error);
var err = App.Helpers.misc.formatError(error, defaultErrMsg);
var msg = 'error code: %@, message: %@'.fmt(err.errCode, err.msg);
App.Helpers.ErrorBar.getInstance().show(msg, err.details);
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ App.VertexTasksController = Em.ObjectController.extend(App.PaginatedContentMixin
store = this.get('store'),
fetcher;
childEntityType = this.get('childEntityType');
var defaultErrMsg = 'Error while loading tasks. could not connect to %@'.fmt(App.env.timelineBaseUrl);

store.unloadAll(childEntityType);
store.findQuery(childEntityType, this.getFilterProperties()).then(function(entities){
Expand All @@ -67,7 +68,7 @@ App.VertexTasksController = Em.ObjectController.extend(App.PaginatedContentMixin
});
}).catch(function(jqXHR){
Em.Logger.error(error);
var err = App.Helpers.misc.formatError(error);
var err = App.Helpers.misc.formatError(error, defaultErrMsg);
var msg = 'error code: %@, message: %@'.fmt(err.errCode, err.msg);
App.Helpers.ErrorBar.getInstance().show(msg, err.details);
});
Expand Down
18 changes: 16 additions & 2 deletions tez-ui/src/main/webapp/app/scripts/default-configs.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,26 @@
* limitations under the License.
*/

var getDefaultTimelineUrl = function() {
var location = window.location;
var protocol = App.env.isStandalone ? location.protocol : 'http';
var hostname = App.env.isStandalone ? location.hostname : 'localhost';
return '%@//%@:8188'.fmt(protocol, hostname);
};

var getDefaultRMWebUrl = function() {
var location = window.location;
var protocol = App.env.isStandalone ? location.protocol : 'http';
var hostname = App.env.isStandalone ? location.hostname : 'localhost';
return '%@//%@:8088'.fmt(protocol, hostname);
};

$.extend(true, App.Configs, {
envDefaults: {
version: "0.6.0",

timelineBaseUrl: 'http://localhost:8188',
RMWebUrl: 'http://localhost:8088',
timelineBaseUrl: getDefaultTimelineUrl(),
RMWebUrl: getDefaultRMWebUrl(),
},

restNamespace: {
Expand Down
16 changes: 12 additions & 4 deletions tez-ui/src/main/webapp/app/scripts/helpers/misc.js
Original file line number Diff line number Diff line change
Expand Up @@ -133,9 +133,17 @@ App.Helpers.misc = {
* returns a formatted message, the real cause is unknown and the error object details
* depends on the error cause. the function tries to handle ajax error or a native errors
*/
formatError: function(error) {
var msg = error.statusText || error.message || '';
if (error.responseText) {
formatError: function(error, defaultErrorMessage) {
var msg;
// for cross domain requests, the error is not set if no access control headers were found.
// this could be either because there was a n/w error or the cors headers being not set.
if (error.status === 0 && error.statusText === 'error') {
msg = defaultErrorMessage ;
} else {
msg = error.statusText || error.message;
}
msg = msg || 'Unknown error';
if (!!error.responseText) {
msg += error.responseText;
}
return {
Expand Down Expand Up @@ -177,4 +185,4 @@ App.Helpers.misc = {
replace: true
}

}
}
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,9 @@ App.PaginatedContentMixin = Em.Mixin.create({
loadEntities: function() {
var that = this;
var childEntityType = this.get('childEntityType');
var defaultErrMsg = 'Error while loading %@. could not connect to %@'
.fmt(childEntityType, App.env.timelineBaseUrl);


that.set('loading', true);

Expand All @@ -57,7 +60,7 @@ App.PaginatedContentMixin = Em.Mixin.create({
that.set('loading', false);
}).catch(function(jqXHR){
Em.Logger.error(error);
var err = App.Helpers.misc.formatError(error);
var err = App.Helpers.misc.formatError(error, defaultErrMsg);
var msg = 'error code: %@, message: %@'.fmt(err.errCode, err.msg);
App.Helpers.ErrorBar.getInstance().show(msg, err.details);
});
Expand Down
3 changes: 2 additions & 1 deletion tez-ui/src/main/webapp/app/scripts/router.js
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,8 @@ App.ApplicationRoute = Em.Route.extend({
error: function(error, transition, originRoute) {
this.replaceWith('error');
Em.Logger.error(error);
var err = App.Helpers.misc.formatError(error);
var defaultError = 'Error while loading %@. could not connect to %@'.fmt(transition.targetName, App.env.timelineBaseUrl);
var err = App.Helpers.misc.formatError(error, defaultError);
var msg = 'error code: %@, message: %@'.fmt(err.errCode, err.msg);
App.Helpers.ErrorBar.getInstance().show(msg, error.details);
}
Expand Down
2 changes: 2 additions & 0 deletions tez-ui/src/main/webapp/app/styles/main.less
Original file line number Diff line number Diff line change
Expand Up @@ -188,6 +188,8 @@ body, html, body > .ember-view {

.details {
display: none;
overflow: auto;
max-height: 300px;

&.visible {
display: inline;
Expand Down

0 comments on commit 58a9119

Please sign in to comment.