Skip to content

Commit

Permalink
Issue #176: Clean up error reporting in the UI.
Browse files Browse the repository at this point in the history
  • Loading branch information
mk23 committed Feb 15, 2018
1 parent 1be37e3 commit 24fae09
Showing 1 changed file with 29 additions and 7 deletions.
36 changes: 29 additions & 7 deletions src/main/resources/assets/js/jmxproxy.js
Original file line number Diff line number Diff line change
Expand Up @@ -758,7 +758,12 @@ var endpointHostClass = function(prefix, host) {

var setupAuth = function(jqXHR) {
if (jqXHR.status == 401) {
$('#endpoint-auth').modal();
displayError('Login required.');

$('#endpoint-auth')
.data('used', false)
.modal();

$('#endpoint-creds .input-group:nth(0)')
.find('input')
.remove()
Expand Down Expand Up @@ -787,7 +792,7 @@ var endpointHostClass = function(prefix, host) {
);
$('#endpoint-user').focus();
} else if (jqXHR.status == 404) {
displayError('Selected endpoint is unavailable.');
displayError('Selected endpoint is unavailable.', true);
}
};

Expand All @@ -802,11 +807,14 @@ var endpointHostClass = function(prefix, host) {
};

var checkHost = function() {
$('#welcome-banner, #endpoint-select').addClass('hidden');
$('#endpoint-navbar, #endpoint-loader').removeClass('hidden');
$('#endpoint-loader').removeClass('hidden');
$('#endpoint-select').addClass('hidden');
$('#welcome-banner').addClass('hidden');

fetchData('/java.lang:type=Runtime/Uptime', function(test) {
displayError();
$('#endpoint-loader').addClass('hidden');
$('#endpoint-navbar').removeClass('hidden');
$(document).attr('title', 'JMXProxy - ' + fetchName());
$('#summary-cn, #navbar-label').text(fetchName());
$('a[data-toggle="tab"]:first').tab('show');
Expand Down Expand Up @@ -949,7 +957,9 @@ $(document).ready(function() {
$('#endpoint-creds').submit(function() {
endpointHost.resetAuth($('#endpoint-user').val(), $('#endpoint-pass').val());

$('#endpoint-auth').modal('hide');
$('#endpoint-auth')
.data('used', true)
.modal('hide');
return false;
});

Expand Down Expand Up @@ -999,6 +1009,12 @@ $(document).ready(function() {
return false;
});

$('#endpoint-auth').on('hidden.bs.modal', function() {
if (!$(this).data('used')) {
displayError('Missing required credentials.', true);
}
});

$('[data-toggle="tooltip"]').tooltip();

$('.focused-graph').on('plothover', showGraphTooltip);
Expand Down Expand Up @@ -1130,15 +1146,21 @@ function formatPercent(s) {
return s.toFixed(2) + '%';
}

function displayError(text) {
if (text != null) {
function displayError(text, reload) {
if (text !== undefined) {
$('#endpoint-error').text(text);
$('#endpoint-alert').addClass('in');

clearTimeout(alertTimeout);
alertTimeout = setTimeout(function() {
$('#endpoint-alert').removeClass('in');
if (reload) {
window.location.reload(true);
}
}, 5000);
} else {
clearTimeout(alertTimeout);
$('#endpoint-alert').removeClass('in');
}
}

Expand Down

0 comments on commit 24fae09

Please sign in to comment.