On HTTP 500 error provide link to logs if possible
This commit is contained in:
parent
f0f19c8199
commit
b7f6d497f9
@ -94,6 +94,16 @@ function(models, commonViews, ClusterPage, ClustersPage, ReleasesPage, Notificat
|
||||
showSupportPage: function() {
|
||||
this.setPage(new SupportPage());
|
||||
},
|
||||
serializeTabOptions: function(options) {
|
||||
return _.map(options, function(value, key) {
|
||||
return key + ':' + value;
|
||||
}).join(',');
|
||||
},
|
||||
deserializeTabOptions: function(serializedOptions) {
|
||||
return _.object(_.map(serializedOptions.split(','), function(option) {
|
||||
return option.split(':');
|
||||
}));
|
||||
},
|
||||
urlify: function (text) {
|
||||
var urlRegexp = /http:(\&\#x2F\;){2}(?:(?:[0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])\.){3}(?:[0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])(\&\#x2F\;)/g;
|
||||
return text.replace(/\n/g, '<br/>').replace(urlRegexp, function(url) {
|
||||
|
@ -156,7 +156,7 @@ function(models, commonViews, logsTabTemplate, logEntryTemplate) {
|
||||
|
||||
var options = this.getOptions();
|
||||
this.model.set({'log_options': options}, {silent: true});
|
||||
app.navigate('#cluster/' + this.model.id + '/logs/' + this.serializeOptions(options), {trigger: false, replace: true});
|
||||
app.navigate('#cluster/' + this.model.id + '/logs/' + app.serializeTabOptions(options), {trigger: false, replace: true});
|
||||
|
||||
this.$('.logs-fetch-error, .node-sources-error').hide();
|
||||
if (!this.reversed) {
|
||||
@ -222,16 +222,6 @@ function(models, commonViews, logsTabTemplate, logEntryTemplate) {
|
||||
}
|
||||
}
|
||||
},
|
||||
serializeOptions: function(options) {
|
||||
return _.map(options, function(value, key) {
|
||||
return key + ':' + value;
|
||||
}).join(',');
|
||||
},
|
||||
deserializeOptions: function(serializedOptions) {
|
||||
return _.object(_.map(serializedOptions.split(','), function(option) {
|
||||
return option.split(':');
|
||||
}));
|
||||
},
|
||||
getOptions: function() {
|
||||
var options = {};
|
||||
options.type = this.chosenType;
|
||||
@ -267,7 +257,7 @@ function(models, commonViews, logsTabTemplate, logEntryTemplate) {
|
||||
// this part is run on first rendering only
|
||||
var options = {};
|
||||
if (this.tabOptions) {
|
||||
options = this.deserializeOptions(this.tabOptions);
|
||||
options = app.deserializeTabOptions(this.tabOptions);
|
||||
} else if (this.model.get('log_options')) {
|
||||
options = this.model.get('log_options');
|
||||
}
|
||||
|
@ -3,13 +3,12 @@ define(
|
||||
'models',
|
||||
'views/common',
|
||||
'views/dialogs',
|
||||
'views/cluster_page_tabs/logs_tab',
|
||||
'text!templates/cluster/nodes_tab_summary.html',
|
||||
'text!templates/cluster/edit_nodes_screen.html',
|
||||
'text!templates/cluster/node_list.html',
|
||||
'text!templates/cluster/node.html'
|
||||
],
|
||||
function(models, commonViews, dialogViews, LogsTab, nodesTabSummaryTemplate, editNodesScreenTemplate, nodeListTemplate, nodeTemplate) {
|
||||
function(models, commonViews, dialogViews, nodesTabSummaryTemplate, editNodesScreenTemplate, nodeListTemplate, nodeTemplate) {
|
||||
'use strict';
|
||||
var NodesTab, NodesByRolesScreen, EditNodesScreen, AddNodesScreen, DeleteNodesScreen, NodeList, Node;
|
||||
|
||||
@ -412,7 +411,7 @@ function(models, commonViews, dialogViews, LogsTab, nodesTabSummaryTemplate, edi
|
||||
} else if (status == 'deploying' || status == 'ready' || (status == 'error' && error == 'deploy')) {
|
||||
options.source = 'install/puppet';
|
||||
}
|
||||
return '#cluster/' + app.page.model.id + '/logs/' + LogsTab.prototype.serializeOptions(options);
|
||||
return '#cluster/' + app.page.model.id + '/logs/' + app.serializeTabOptions(options);
|
||||
},
|
||||
beforeTearDown: function() {
|
||||
$('html').off(this.eventNamespace);
|
||||
|
@ -24,7 +24,14 @@ function(models, simpleMessageTemplate, createClusterDialogTemplate, changeClust
|
||||
this.$el.modal('hide');
|
||||
},
|
||||
displayErrorMessage: function () {
|
||||
this.$('.modal-body').html(this.errorMessageTemplate());
|
||||
var logsLink;
|
||||
try {
|
||||
if (app.page.model.constructor == models.Cluster) {
|
||||
var options = {type: 'local', source: 'nailgun', level: 'error'};
|
||||
logsLink = '#cluster/' + app.page.model.id + '/logs/' + app.serializeTabOptions(options);
|
||||
}
|
||||
} catch(e) {}
|
||||
this.$('.modal-body').html(this.errorMessageTemplate({logsLink: logsLink}));
|
||||
},
|
||||
initialize: function(options) {
|
||||
_.defaults(this, options);
|
||||
|
@ -1,3 +1,8 @@
|
||||
<div class="text-error request-failed">
|
||||
Server error has occurred. Please contact the administrators.
|
||||
</div>
|
||||
<div class="text-error request-failed">
|
||||
Server error has occurred.
|
||||
<% if (logsLink) { %>
|
||||
Please contact the administrators or <a href="<%- logsLink %>" target="_blank">see the logs</a>.
|
||||
<% } else { %>
|
||||
Please contact the administrators.
|
||||
<% } %>
|
||||
</div>
|
||||
|
Loading…
Reference in New Issue
Block a user