mirror of https://github.com/apache/nifi.git
NIFI-6160 Apply config error handling convention
What this PR changed: - Standardized required name error message to 'The name of the xxxx must be specified' - Added nfErrorHandler.handleConfigurationUpdateAjaxError - Replaced existing custom error handling for 400 status code - Replaced handleAjxError with this where appropriate - Standardized config error dialog title to 'Configuration Error' - Close the configuration dialog when configuration is successfully updated Above convention applied to following components: - ProcessGroup - Input/OutputPort - RemoteProcessGroup - RemoteGroupPort - Template - Connection - ControllerService - Label - Processor - ReportingTask - NiFi Settings/GENERAL tab - Variable - User NIFI-6170 Provide consistent UX at Connection config Fixed Label. Incorporated review comments Removed unnecessary else block. Disable canvas when the message pane is shown This closes #3401
This commit is contained in:
parent
0e5a80d23f
commit
31463c5dad
|
@ -252,7 +252,7 @@ public final class StandardProcessGroup implements ProcessGroup {
|
|||
@Override
|
||||
public void setName(final String name) {
|
||||
if (StringUtils.isBlank(name)) {
|
||||
throw new IllegalArgumentException("The name cannot be blank.");
|
||||
throw new IllegalArgumentException("The name of the process group must be specified.");
|
||||
}
|
||||
|
||||
this.name.set(name);
|
||||
|
|
|
@ -162,7 +162,7 @@ public class StandardInputPortDAO extends ComponentDAO implements PortDAO {
|
|||
List<String> validationErrors = new ArrayList<>();
|
||||
|
||||
if (isNotNull(portDTO.getName()) && portDTO.getName().trim().isEmpty()) {
|
||||
validationErrors.add("Port name cannot be blank.");
|
||||
validationErrors.add("The name of the port must be specified.");
|
||||
}
|
||||
if (isNotNull(portDTO.getConcurrentlySchedulableTaskCount()) && portDTO.getConcurrentlySchedulableTaskCount() <= 0) {
|
||||
validationErrors.add("Concurrent tasks must be a positive integer.");
|
||||
|
|
|
@ -158,7 +158,7 @@ public class StandardOutputPortDAO extends ComponentDAO implements PortDAO {
|
|||
List<String> validationErrors = new ArrayList<>();
|
||||
|
||||
if (isNotNull(portDTO.getName()) && portDTO.getName().trim().isEmpty()) {
|
||||
validationErrors.add("Port name cannot be blank.");
|
||||
validationErrors.add("The name of the port must be specified.");
|
||||
}
|
||||
if (isNotNull(portDTO.getConcurrentlySchedulableTaskCount()) && portDTO.getConcurrentlySchedulableTaskCount() <= 0) {
|
||||
validationErrors.add("Concurrent tasks must be a positive integer.");
|
||||
|
|
|
@ -102,7 +102,7 @@
|
|||
|
||||
// update the birdseye
|
||||
nfBirdseye.refresh();
|
||||
}).fail(nfErrorHandler.handleAjaxError);
|
||||
}).fail(nfErrorHandler.handleConfigurationUpdateAjaxError);
|
||||
};
|
||||
|
||||
function GroupComponent() {
|
||||
|
@ -235,18 +235,18 @@
|
|||
// get the name of the group and clear the textfield
|
||||
var groupName = $('#new-process-group-name').val();
|
||||
|
||||
// hide the dialog
|
||||
groupComponent.modal.hide();
|
||||
|
||||
// ensure the group name is specified
|
||||
if (nfCommon.isBlank(groupName)) {
|
||||
nfDialog.showOkDialog({
|
||||
headerText: 'Create Process Group',
|
||||
dialogContent: 'The group name is required.'
|
||||
headerText: 'Configuration Error',
|
||||
dialogContent: 'The name of the process group must be specified.'
|
||||
});
|
||||
|
||||
deferred.reject();
|
||||
} else {
|
||||
// hide the dialog
|
||||
groupComponent.modal.hide();
|
||||
|
||||
// create the group and resolve the deferred accordingly
|
||||
createGroup(groupName, pt).done(function (response) {
|
||||
deferred.resolve(response.component);
|
||||
|
|
|
@ -91,12 +91,15 @@
|
|||
'selectAll': true
|
||||
});
|
||||
|
||||
// hide the dialog
|
||||
inputPortComponent.modal.hide();
|
||||
|
||||
// update component visibility
|
||||
nfGraph.updateVisibility();
|
||||
|
||||
// update the birdseye
|
||||
nfBirdseye.refresh();
|
||||
}).fail(nfErrorHandler.handleAjaxError);
|
||||
}).fail(nfErrorHandler.handleConfigurationUpdateAjaxError);
|
||||
};
|
||||
|
||||
function InputPortComponent() {
|
||||
|
@ -217,9 +220,6 @@
|
|||
// get the name of the input port and clear the textfield
|
||||
var portName = $('#new-port-name').val();
|
||||
|
||||
// hide the dialog
|
||||
inputPortComponent.modal.hide();
|
||||
|
||||
// create the input port
|
||||
createInputPort(portName, pt);
|
||||
};
|
||||
|
|
|
@ -91,12 +91,15 @@
|
|||
'selectAll': true
|
||||
});
|
||||
|
||||
// hide the dialog
|
||||
outputPortComponent.modal.hide();
|
||||
|
||||
// update component visibility
|
||||
nfGraph.updateVisibility();
|
||||
|
||||
// update the birdseye
|
||||
nfBirdseye.refresh();
|
||||
}).fail(nfErrorHandler.handleAjaxError);
|
||||
}).fail(nfErrorHandler.handleConfigurationUpdateAjaxError);
|
||||
};
|
||||
|
||||
function OutputPortComponent() {
|
||||
|
@ -208,9 +211,6 @@
|
|||
// get the name of the output port and clear the textfield
|
||||
var portName = $('#new-port-name').val();
|
||||
|
||||
// hide the dialog
|
||||
outputPortComponent.modal.hide();
|
||||
|
||||
// create the output port
|
||||
createOutputPort(portName, pt);
|
||||
};
|
||||
|
|
|
@ -113,25 +113,7 @@
|
|||
|
||||
// update the birdseye
|
||||
nfBirdseye.refresh();
|
||||
}).fail(function (xhr, status, error) {
|
||||
if (xhr.status === 400) {
|
||||
var errors = xhr.responseText.split('\n');
|
||||
|
||||
var content;
|
||||
if (errors.length === 1) {
|
||||
content = $('<span></span>').text(errors[0]);
|
||||
} else {
|
||||
content = nfCommon.formatUnorderedList(errors);
|
||||
}
|
||||
|
||||
nfDialog.showOkDialog({
|
||||
dialogContent: content,
|
||||
headerText: 'Configuration Error'
|
||||
});
|
||||
} else {
|
||||
nfErrorHandler.handleAjaxError(xhr, status, error);
|
||||
}
|
||||
});
|
||||
}).fail(nfErrorHandler.handleConfigurationUpdateAjaxError);
|
||||
};
|
||||
|
||||
function RemoteProcessGroupComponent() {
|
||||
|
|
|
@ -1642,8 +1642,8 @@
|
|||
// ensure the template name is not blank
|
||||
if (nfCommon.isBlank(templateName)) {
|
||||
nfDialog.showOkDialog({
|
||||
headerText: 'Create Template',
|
||||
dialogContent: "The template name cannot be blank."
|
||||
headerText: 'Configuration Error',
|
||||
dialogContent: "The name of the template must be specified."
|
||||
});
|
||||
return;
|
||||
}
|
||||
|
|
|
@ -41,17 +41,10 @@
|
|||
}(this, function (ajaxErrorHandler, nfCommon, nfCanvas, nfContextMenu) {
|
||||
'use strict';
|
||||
|
||||
return {
|
||||
|
||||
/**
|
||||
* Method for handling ajax errors. This also closes the canvas.
|
||||
*
|
||||
* @argument {object} xhr The XmlHttpRequest
|
||||
* @argument {string} status The status of the request
|
||||
* @argument {string} error The error
|
||||
*/
|
||||
handleAjaxError: function (xhr, status, error) {
|
||||
ajaxErrorHandler.handleAjaxError(xhr, status, error);
|
||||
var disableCanvas = function() {
|
||||
// In case no further requests will be successful based on the status,
|
||||
// the canvas is disabled, and the message pane is shown.
|
||||
if ($('#message-pane').is(':visible')) {
|
||||
nfCommon.showLogoutLink();
|
||||
|
||||
// hide the splash screen if required
|
||||
|
@ -65,8 +58,36 @@
|
|||
// shut off the auto refresh
|
||||
nfCanvas.stopPolling();
|
||||
|
||||
// allow page refresh with ctrl-r
|
||||
// disable page refresh with ctrl-r
|
||||
nfCanvas.disableRefreshHotKey();
|
||||
}
|
||||
};
|
||||
|
||||
return {
|
||||
|
||||
/**
|
||||
* Method for handling ajax errors. This also closes the canvas if necessary.
|
||||
*
|
||||
* @argument {object} xhr The XmlHttpRequest
|
||||
* @argument {string} status The status of the request
|
||||
* @argument {string} error The error
|
||||
*/
|
||||
handleAjaxError: function (xhr, status, error) {
|
||||
ajaxErrorHandler.handleAjaxError(xhr, status, error);
|
||||
disableCanvas();
|
||||
},
|
||||
|
||||
/**
|
||||
* Method for handling ajax errors when submitting configuration update (PUT/POST) requests.
|
||||
* This method delegates error handling to ajaxErrorHandler.
|
||||
*
|
||||
* @argument {object} xhr The XmlHttpRequest
|
||||
* @argument {string} status The status of the request
|
||||
* @argument {string} error The error
|
||||
*/
|
||||
handleConfigurationUpdateAjaxError: function (xhr, status, error) {
|
||||
ajaxErrorHandler.handleConfigurationUpdateAjaxError(xhr, status, error);
|
||||
disableCanvas();
|
||||
}
|
||||
};
|
||||
}));
|
|
@ -129,9 +129,6 @@
|
|||
handler: {
|
||||
click: function () {
|
||||
addConnection(getSelectedRelationships());
|
||||
|
||||
// close the dialog
|
||||
$('#connection-configuration').modal('hide');
|
||||
}
|
||||
}
|
||||
},
|
||||
|
@ -195,9 +192,6 @@
|
|||
click: function () {
|
||||
// add the connection
|
||||
addConnection();
|
||||
|
||||
// close the dialog
|
||||
$('#connection-configuration').modal('hide');
|
||||
}
|
||||
}
|
||||
},
|
||||
|
@ -971,6 +965,9 @@
|
|||
'selectAll': true
|
||||
});
|
||||
|
||||
// close the dialog
|
||||
$('#connection-configuration').modal('hide');
|
||||
|
||||
// reload the connections source/destination components
|
||||
nfCanvasUtils.reloadConnectionSourceAndDestination(sourceComponentId, destinationComponentId);
|
||||
|
||||
|
@ -979,10 +976,7 @@
|
|||
|
||||
// update the birdseye
|
||||
nfBirdseye.refresh();
|
||||
}).fail(function (xhr, status, error) {
|
||||
// handle the error
|
||||
nfErrorHandler.handleAjaxError(xhr, status, error);
|
||||
});
|
||||
}).fail(nfErrorHandler.handleConfigurationUpdateAjaxError);
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -1051,21 +1045,15 @@
|
|||
dataType: 'json',
|
||||
contentType: 'application/json'
|
||||
}).done(function (response) {
|
||||
// close the dialog
|
||||
$('#connection-configuration').modal('hide');
|
||||
|
||||
// update this connection
|
||||
nfConnection.set(response);
|
||||
|
||||
// reload the connections source/destination components
|
||||
nfCanvasUtils.reloadConnectionSourceAndDestination(sourceComponentId, destinationComponentId);
|
||||
}).fail(function (xhr, status, error) {
|
||||
if (xhr.status === 400 || xhr.status === 404 || xhr.status === 409) {
|
||||
nfDialog.showOkDialog({
|
||||
headerText: 'Connection Configuration',
|
||||
dialogContent: nfCommon.escapeHtml(xhr.responseText),
|
||||
});
|
||||
} else {
|
||||
nfErrorHandler.handleAjaxError(xhr, status, error);
|
||||
}
|
||||
});
|
||||
}).fail(nfErrorHandler.handleConfigurationUpdateAjaxError);
|
||||
} else {
|
||||
return $.Deferred(function (deferred) {
|
||||
deferred.reject();
|
||||
|
@ -1120,7 +1108,7 @@
|
|||
|
||||
if (errors.length > 0) {
|
||||
nfDialog.showOkDialog({
|
||||
headerText: 'Connection Configuration',
|
||||
headerText: 'Configuration Error',
|
||||
dialogContent: nfCommon.formatUnorderedList(errors)
|
||||
});
|
||||
return false;
|
||||
|
@ -1495,9 +1483,6 @@
|
|||
deferred.reject();
|
||||
});
|
||||
}
|
||||
|
||||
// close the dialog
|
||||
$('#connection-configuration').modal('hide');
|
||||
}
|
||||
}
|
||||
},
|
||||
|
|
|
@ -1614,16 +1614,7 @@
|
|||
}).done(function (response) {
|
||||
// request was successful, update the entry
|
||||
nfConnection.set(response);
|
||||
}).fail(function (xhr, status, error) {
|
||||
if (xhr.status === 400 || xhr.status === 404 || xhr.status === 409) {
|
||||
nfDialog.showOkDialog({
|
||||
headerText: 'Connection',
|
||||
dialogContent: nfCommon.escapeHtml(xhr.responseText)
|
||||
});
|
||||
} else {
|
||||
nfErrorHandler.handleAjaxError(xhr, status, error);
|
||||
}
|
||||
});
|
||||
}).fail(nfErrorHandler.handleConfigurationUpdateAjaxError);
|
||||
};
|
||||
|
||||
// removes the specified connections
|
||||
|
|
|
@ -77,33 +77,6 @@
|
|||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Handle any expected controller service configuration errors.
|
||||
*
|
||||
* @argument {object} xhr The XmlHttpRequest
|
||||
* @argument {string} status The status of the request
|
||||
* @argument {string} error The error
|
||||
*/
|
||||
var handleControllerServiceConfigurationError = function (xhr, status, error) {
|
||||
if (xhr.status === 400) {
|
||||
var errors = xhr.responseText.split('\n');
|
||||
|
||||
var content;
|
||||
if (errors.length === 1) {
|
||||
content = $('<span></span>').text(errors[0]);
|
||||
} else {
|
||||
content = nfCommon.formatUnorderedList(errors);
|
||||
}
|
||||
|
||||
nfDialog.showOkDialog({
|
||||
dialogContent: content,
|
||||
headerText: 'Controller Service'
|
||||
});
|
||||
} else {
|
||||
nfErrorHandler.handleAjaxError(xhr, status, error);
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Determines whether the user has made any changes to the controller service configuration
|
||||
* that needs to be saved.
|
||||
|
@ -1606,7 +1579,7 @@
|
|||
$.each(previouslyReferencedServiceIds, function (_, oldServiceReferenceId) {
|
||||
reloadControllerService(serviceTable, oldServiceReferenceId);
|
||||
});
|
||||
}).fail(handleControllerServiceConfigurationError);
|
||||
}).fail(nfErrorHandler.handleConfigurationUpdateAjaxError);
|
||||
} else {
|
||||
return $.Deferred(function (deferred) {
|
||||
deferred.reject();
|
||||
|
|
|
@ -295,15 +295,7 @@
|
|||
id: d.id
|
||||
});
|
||||
}).fail(function (xhr, status, error) {
|
||||
if (xhr.status === 400 || xhr.status === 404 || xhr.status === 409) {
|
||||
nfDialog.showOkDialog({
|
||||
headerText: 'Component Position',
|
||||
dialogContent: nfCommon.escapeHtml(xhr.responseText)
|
||||
});
|
||||
} else {
|
||||
nfErrorHandler.handleAjaxError(xhr, status, error);
|
||||
}
|
||||
|
||||
nfErrorHandler.handleAjaxError(xhr, status, error);
|
||||
deferred.reject();
|
||||
});
|
||||
}).promise();
|
||||
|
@ -357,14 +349,7 @@
|
|||
id: d.id
|
||||
});
|
||||
}).fail(function (xhr, status, error) {
|
||||
if (xhr.status === 400 || xhr.status === 404 || xhr.status === 409) {
|
||||
nfDialog.showOkDialog({
|
||||
headerText: 'Component Position',
|
||||
dialogContent: nfCommon.escapeHtml(xhr.responseText)
|
||||
});
|
||||
} else {
|
||||
nfErrorHandler.handleAjaxError(xhr, status, error);
|
||||
}
|
||||
nfErrorHandler.handleAjaxError(xhr, status, error);
|
||||
|
||||
deferred.reject();
|
||||
});
|
||||
|
|
|
@ -76,6 +76,7 @@
|
|||
},
|
||||
handler: {
|
||||
click: function () {
|
||||
var self = this;
|
||||
// get the label data
|
||||
var labelData = d3.select('#id-' + labelId).datum();
|
||||
|
||||
|
@ -109,10 +110,11 @@
|
|||
|
||||
// inform Angular app values have changed
|
||||
nfNgBridge.digest();
|
||||
}).fail(nfErrorHandler.handleAjaxError);
|
||||
|
||||
// reset and hide the dialog
|
||||
this.modal('hide');
|
||||
// reset and hide the dialog
|
||||
self.modal('hide');
|
||||
}).fail(nfErrorHandler.handleConfigurationUpdateAjaxError);
|
||||
|
||||
}
|
||||
}
|
||||
},
|
||||
|
|
|
@ -121,32 +121,7 @@
|
|||
|
||||
// close the details panel
|
||||
$('#port-configuration').modal('hide');
|
||||
}).fail(function (xhr, status, error) {
|
||||
// handle bad request locally to keep the dialog open, allowing the user
|
||||
// to make changes. if the request fails for another reason, the dialog
|
||||
// should be closed so the issue can be addressed (stale flow for instance)
|
||||
if (xhr.status === 400) {
|
||||
var errors = xhr.responseText.split('\n');
|
||||
|
||||
var content;
|
||||
if (errors.length === 1) {
|
||||
content = $('<span></span>').text(errors[0]);
|
||||
} else {
|
||||
content = nfCommon.formatUnorderedList(errors);
|
||||
}
|
||||
|
||||
nfDialog.showOkDialog({
|
||||
dialogContent: content,
|
||||
headerText: 'Port Configuration'
|
||||
});
|
||||
} else {
|
||||
// close the details panel
|
||||
$('#port-configuration').modal('hide');
|
||||
|
||||
// handle the error
|
||||
nfErrorHandler.handleAjaxError(xhr, status, error);
|
||||
}
|
||||
});
|
||||
}).fail(nfErrorHandler.handleConfigurationUpdateAjaxError);
|
||||
}
|
||||
}
|
||||
},
|
||||
|
|
|
@ -129,7 +129,7 @@
|
|||
});
|
||||
|
||||
nfCanvasUtils.reload();
|
||||
}).fail(nfErrorHandler.handleAjaxError);
|
||||
}).fail(nfErrorHandler.handleConfigurationUpdateAjaxError);
|
||||
};
|
||||
|
||||
/**
|
||||
|
|
|
@ -140,33 +140,6 @@
|
|||
}];
|
||||
};
|
||||
|
||||
/**
|
||||
* Handle any expected processor configuration errors.
|
||||
*
|
||||
* @argument {object} xhr The XmlHttpRequest
|
||||
* @argument {string} status The status of the request
|
||||
* @argument {string} error The error
|
||||
*/
|
||||
var handleProcessorConfigurationError = function (xhr, status, error) {
|
||||
if (xhr.status === 400) {
|
||||
var errors = xhr.responseText.split('\n');
|
||||
|
||||
var content;
|
||||
if (errors.length === 1) {
|
||||
content = $('<span></span>').text(errors[0]);
|
||||
} else {
|
||||
content = nfCommon.formatUnorderedList(errors);
|
||||
}
|
||||
|
||||
nfDialog.showOkDialog({
|
||||
dialogContent: content,
|
||||
headerText: 'Processor Configuration'
|
||||
});
|
||||
} else {
|
||||
nfErrorHandler.handleAjaxError(xhr, status, error);
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Creates an option for the specified relationship name.
|
||||
*
|
||||
|
@ -426,7 +399,7 @@
|
|||
if (errors.length > 0) {
|
||||
nfDialog.showOkDialog({
|
||||
dialogContent: nfCommon.formatUnorderedList(errors),
|
||||
headerText: 'Processor Configuration'
|
||||
headerText: 'Configuration Error'
|
||||
});
|
||||
return false;
|
||||
} else {
|
||||
|
@ -508,7 +481,7 @@
|
|||
}).done(function (response) {
|
||||
// set the new processor state based on the response
|
||||
nfProcessor.set(response);
|
||||
}).fail(handleProcessorConfigurationError);
|
||||
}).fail(nfErrorHandler.handleConfigurationUpdateAjaxError);
|
||||
} else {
|
||||
return $.Deferred(function (deferred) {
|
||||
deferred.reject();
|
||||
|
|
|
@ -110,25 +110,7 @@
|
|||
|
||||
// close the details panel
|
||||
$('#remote-process-group-configuration').modal('hide');
|
||||
}).fail(function (xhr, status, error) {
|
||||
if (xhr.status === 400) {
|
||||
var errors = xhr.responseText.split('\n');
|
||||
|
||||
var content;
|
||||
if (errors.length === 1) {
|
||||
content = $('<span></span>').text(errors[0]);
|
||||
} else {
|
||||
content = nfCommon.formatUnorderedList(errors);
|
||||
}
|
||||
|
||||
nfDialog.showOkDialog({
|
||||
dialogContent: content,
|
||||
headerText: 'Remote Process Group Configuration'
|
||||
});
|
||||
} else {
|
||||
nfErrorHandler.handleAjaxError(xhr, status, error);
|
||||
}
|
||||
});
|
||||
}).fail(nfErrorHandler.handleConfigurationUpdateAjaxError);
|
||||
}
|
||||
}
|
||||
},
|
||||
|
|
|
@ -146,38 +146,16 @@
|
|||
$('#' + remotePortId + '-batch-size').text(batchSettings.size);
|
||||
$('#' + remotePortId + '-batch-duration').text(batchSettings.duration);
|
||||
|
||||
}).fail(function (xhr, status, error) {
|
||||
if (xhr.status === 400) {
|
||||
var errors = xhr.responseText.split('\n');
|
||||
|
||||
var content;
|
||||
if (errors.length === 1) {
|
||||
content = $('<span></span>').text(errors[0]);
|
||||
} else {
|
||||
content = nfCommon.formatUnorderedList(errors);
|
||||
}
|
||||
|
||||
nfDialog.showOkDialog({
|
||||
dialogContent: content,
|
||||
headerText: 'Remote Process Group Ports'
|
||||
});
|
||||
} else {
|
||||
nfErrorHandler.handleAjaxError(xhr, status, error);
|
||||
}
|
||||
}).always(function () {
|
||||
// close the dialog
|
||||
$('#remote-port-configuration').modal('hide');
|
||||
});
|
||||
}).fail(nfErrorHandler.handleConfigurationUpdateAjaxError);
|
||||
} else {
|
||||
nfDialog.showOkDialog({
|
||||
headerText: 'Remote Process Group Ports',
|
||||
headerText: 'Configuration Error',
|
||||
dialogContent: portValidationErrors.reduce(function (prev, curr) {
|
||||
return typeof(prev) === 'string' ? prev + ' ' + curr : curr;
|
||||
})
|
||||
});
|
||||
|
||||
// close the dialog
|
||||
$('#remote-port-configuration').modal('hide');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -440,23 +418,8 @@
|
|||
transmissionSwitch.replaceWith(newTransmissionSwitch);
|
||||
// update transmissionSwitch variable to reference the new switch
|
||||
transmissionSwitch = newTransmissionSwitch;
|
||||
if (xhr.status === 400) {
|
||||
var errors = xhr.responseText.split('\n');
|
||||
|
||||
var content;
|
||||
if (errors.length === 1) {
|
||||
content = $('<span></span>').text(errors[0]);
|
||||
} else {
|
||||
content = nfCommon.formatUnorderedList(errors);
|
||||
}
|
||||
|
||||
nfDialog.showOkDialog({
|
||||
headerText: 'Remote Process Group Ports',
|
||||
dialogContent: content
|
||||
});
|
||||
} else {
|
||||
nfErrorHandler.handleAjaxError(xhr, status, error);
|
||||
}
|
||||
nfErrorHandler.handleConfigurationUpdateAjaxError(xhr, status, error);
|
||||
});
|
||||
};
|
||||
|
||||
|
|
|
@ -81,33 +81,6 @@
|
|||
return $('#controller-services-table');
|
||||
};
|
||||
|
||||
/**
|
||||
* Handle any expected reporting task configuration errors.
|
||||
*
|
||||
* @argument {object} xhr The XmlHttpRequest
|
||||
* @argument {string} status The status of the request
|
||||
* @argument {string} error The error
|
||||
*/
|
||||
var handleReportingTaskConfigurationError = function (xhr, status, error) {
|
||||
if (xhr.status === 400) {
|
||||
var errors = xhr.responseText.split('\n');
|
||||
|
||||
var content;
|
||||
if (errors.length === 1) {
|
||||
content = $('<span></span>').text(errors[0]);
|
||||
} else {
|
||||
content = nfCommon.formatUnorderedList(errors);
|
||||
}
|
||||
|
||||
nfDialog.showOkDialog({
|
||||
dialogContent: content,
|
||||
headerText: 'Reporting Task'
|
||||
});
|
||||
} else {
|
||||
nfErrorHandler.handleAjaxError(xhr, status, error);
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Determines whether the user has made any changes to the reporting task configuration
|
||||
* that needs to be saved.
|
||||
|
@ -322,7 +295,7 @@
|
|||
}).done(function (response) {
|
||||
// update the reporting task
|
||||
renderReportingTask(response);
|
||||
}).fail(handleReportingTaskConfigurationError);
|
||||
}).fail(nfErrorHandler.handleConfigurationUpdateAjaxError);
|
||||
} else {
|
||||
return $.Deferred(function (deferred) {
|
||||
deferred.reject();
|
||||
|
|
|
@ -108,6 +108,33 @@
|
|||
return $('#controller-services-table');
|
||||
};
|
||||
|
||||
/**
|
||||
* Validates the configured settings.
|
||||
*
|
||||
* @argument {object} configuration The settings to validate
|
||||
*/
|
||||
var validateSettings = function (configuration) {
|
||||
var errors = [];
|
||||
|
||||
// ensure numeric fields are specified correctly
|
||||
if (nfCommon.isDefinedAndNotNull(configuration['maxTimerDrivenThreadCount']) && !$.isNumeric(configuration['maxTimerDrivenThreadCount'])) {
|
||||
errors.push('Maximum Timer Driven Thread Count must be an integer value');
|
||||
}
|
||||
if (nfCommon.isDefinedAndNotNull(configuration['maxEventDrivenThreadCount']) && !$.isNumeric(configuration['maxEventDrivenThreadCount'])) {
|
||||
errors.push('Maximum Event Driven Thread Count must be an integer value');
|
||||
}
|
||||
|
||||
if (errors.length > 0) {
|
||||
nfDialog.showOkDialog({
|
||||
dialogContent: nfCommon.formatUnorderedList(errors),
|
||||
headerText: 'Configuration Error'
|
||||
});
|
||||
return false;
|
||||
} else {
|
||||
return true;
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Saves the settings for the controller.
|
||||
*
|
||||
|
@ -116,35 +143,38 @@
|
|||
var saveSettings = function (version) {
|
||||
// marshal the configuration details
|
||||
var configuration = marshalConfiguration();
|
||||
var entity = {
|
||||
'revision': nfClient.getRevision({
|
||||
'revision': {
|
||||
'version': version
|
||||
}
|
||||
}),
|
||||
'disconnectedNodeAcknowledged': nfStorage.isDisconnectionAcknowledged(),
|
||||
'component': configuration
|
||||
};
|
||||
// ensure settings are valid as far as we can tell
|
||||
if (validateSettings(configuration)) {
|
||||
var entity = {
|
||||
'revision': nfClient.getRevision({
|
||||
'revision': {
|
||||
'version': version
|
||||
}
|
||||
}),
|
||||
'disconnectedNodeAcknowledged': nfStorage.isDisconnectionAcknowledged(),
|
||||
'component': configuration
|
||||
};
|
||||
|
||||
// save the new configuration details
|
||||
$.ajax({
|
||||
type: 'PUT',
|
||||
url: config.urls.controllerConfig,
|
||||
data: JSON.stringify(entity),
|
||||
dataType: 'json',
|
||||
contentType: 'application/json'
|
||||
}).done(function (response) {
|
||||
// close the settings dialog
|
||||
nfDialog.showOkDialog({
|
||||
headerText: 'Settings',
|
||||
dialogContent: 'Settings successfully applied.'
|
||||
});
|
||||
// save the new configuration details
|
||||
$.ajax({
|
||||
type: 'PUT',
|
||||
url: config.urls.controllerConfig,
|
||||
data: JSON.stringify(entity),
|
||||
dataType: 'json',
|
||||
contentType: 'application/json'
|
||||
}).done(function (response) {
|
||||
// close the settings dialog
|
||||
nfDialog.showOkDialog({
|
||||
headerText: 'Settings',
|
||||
dialogContent: 'Settings successfully applied.'
|
||||
});
|
||||
|
||||
// register the click listener for the save button
|
||||
$('#settings-save').off('click').on('click', function () {
|
||||
saveSettings(response.revision.version);
|
||||
});
|
||||
}).fail(nfErrorHandler.handleAjaxError);
|
||||
// register the click listener for the save button
|
||||
$('#settings-save').off('click').on('click', function () {
|
||||
saveSettings(response.revision.version);
|
||||
});
|
||||
}).fail(nfErrorHandler.handleConfigurationUpdateAjaxError);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -519,10 +549,11 @@
|
|||
var row = registriesData.getRowById(registryEntity.id);
|
||||
nfFilteredDialogCommon.choseRow(registriesGrid, row);
|
||||
registriesGrid.scrollRowIntoView(row);
|
||||
}).fail(nfErrorHandler.handleAjaxError);
|
||||
|
||||
// hide the dialog
|
||||
$('#registry-configuration-dialog').modal('hide');
|
||||
// hide the dialog
|
||||
$('#registry-configuration-dialog').modal('hide');
|
||||
}).fail(nfErrorHandler.handleConfigurationUpdateAjaxError);
|
||||
|
||||
|
||||
return addRegistry;
|
||||
};
|
||||
|
@ -560,10 +591,10 @@
|
|||
registriesData.updateItem(registryId, $.extend({
|
||||
type: 'Registry'
|
||||
}, registryEntity));
|
||||
}).fail(nfErrorHandler.handleAjaxError);
|
||||
|
||||
// hide the dialog
|
||||
$('#registry-configuration-dialog').modal('hide');
|
||||
// hide the dialog
|
||||
$('#registry-configuration-dialog').modal('hide');
|
||||
}).fail(nfErrorHandler.handleConfigurationUpdateAjaxError);
|
||||
|
||||
return updateRegistry;
|
||||
};
|
||||
|
|
|
@ -1503,15 +1503,17 @@
|
|||
variableGrid.scrollRowIntoView(matchingRow);
|
||||
}
|
||||
}
|
||||
|
||||
// close the new variable dialog
|
||||
$('#new-variable-dialog').modal('hide');
|
||||
|
||||
} else {
|
||||
nfDialog.showOkDialog({
|
||||
headerText: 'Variable Name',
|
||||
dialogContent: 'Variable name must be specified.'
|
||||
headerText: 'Configuration Error',
|
||||
dialogContent: 'The name of the variable must be specified.'
|
||||
});
|
||||
}
|
||||
|
||||
// close the new variable dialog
|
||||
$('#new-variable-dialog').modal('hide');
|
||||
};
|
||||
|
||||
/**
|
||||
|
|
|
@ -37,7 +37,7 @@
|
|||
}(this, function ($, nfDialog, nfCommon) {
|
||||
'use strict';
|
||||
|
||||
return {
|
||||
var self = {
|
||||
/**
|
||||
* Method for handling ajax errors.
|
||||
*
|
||||
|
@ -142,6 +142,36 @@
|
|||
// show the error pane
|
||||
$('#message-pane').show();
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* Method for handling ajax errors when submitting configuration update (PUT/POST) requests.
|
||||
* In addition to what handleAjaxError does, this function splits
|
||||
* the error message text to display them as an unordered list.
|
||||
*
|
||||
* @argument {object} xhr The XmlHttpRequest
|
||||
* @argument {string} status The status of the request
|
||||
* @argument {string} error The error
|
||||
*/
|
||||
handleConfigurationUpdateAjaxError: function (xhr, status, error) {
|
||||
if (xhr.status === 400) {
|
||||
var errors = xhr.responseText.split('\n');
|
||||
|
||||
var content;
|
||||
if (errors.length === 1) {
|
||||
content = $('<span></span>').text(errors[0]);
|
||||
} else {
|
||||
content = nfCommon.formatUnorderedList(errors);
|
||||
}
|
||||
|
||||
nfDialog.showOkDialog({
|
||||
dialogContent: content,
|
||||
headerText: 'Configuration Error'
|
||||
});
|
||||
} else {
|
||||
self.handleAjaxError(xhr, status, error);
|
||||
}
|
||||
}
|
||||
};
|
||||
return self;
|
||||
}));
|
|
@ -307,16 +307,7 @@
|
|||
if (processorRelationships.is(':visible') && processorRelationships.get(0).scrollHeight > Math.round(processorRelationships.innerHeight())) {
|
||||
processorRelationships.css('border-width', '1px');
|
||||
}
|
||||
}).fail(function (xhr, status, error) {
|
||||
if (xhr.status === 400 || xhr.status === 404 || xhr.status === 409) {
|
||||
nfDialog.showOkDialog({
|
||||
headerText: 'Error',
|
||||
dialogContent: nfCommon.escapeHtml(xhr.responseText)
|
||||
});
|
||||
} else {
|
||||
nfErrorHandler.handleAjaxError(xhr, status, error);
|
||||
}
|
||||
});
|
||||
}).fail(nfErrorHandler.handleAjaxError);
|
||||
}
|
||||
};
|
||||
}));
|
||||
|
|
|
@ -252,6 +252,8 @@
|
|||
|
||||
// if the user was successfully created
|
||||
userXhr.done(function (userEntity) {
|
||||
$('#user-dialog').modal('hide');
|
||||
|
||||
var xhrs = [];
|
||||
$.each(selectedGroups, function (_, selectedGroup) {
|
||||
var groupEntity = usersData.getItemById(selectedGroup.id)
|
||||
|
@ -266,7 +268,7 @@
|
|||
usersGrid.scrollRowIntoView(row);
|
||||
});
|
||||
}).fail(nfErrorHandler.handleAjaxError);
|
||||
}).fail(nfErrorHandler.handleAjaxError);
|
||||
}).fail(nfErrorHandler.handleConfigurationUpdateAjaxError);
|
||||
};
|
||||
|
||||
/**
|
||||
|
@ -302,6 +304,8 @@
|
|||
|
||||
userXhr.done(function (updatedUserEntity) {
|
||||
|
||||
$('#user-dialog').modal('hide');
|
||||
|
||||
// determine what to add/remove
|
||||
var groupsAdded = [];
|
||||
var groupsRemoved = [];
|
||||
|
@ -340,7 +344,7 @@
|
|||
$.when.apply(window, xhrs).always(function () {
|
||||
nfUsersTable.loadUsersTable();
|
||||
}).fail(nfErrorHandler.handleAjaxError);
|
||||
}).fail(nfErrorHandler.handleAjaxError);
|
||||
}).fail(nfErrorHandler.handleConfigurationUpdateAjaxError);
|
||||
};
|
||||
|
||||
/**
|
||||
|
@ -357,6 +361,7 @@
|
|||
dataType: 'json',
|
||||
contentType: 'application/json'
|
||||
}).done(function (groupEntity) {
|
||||
$('#user-dialog').modal('hide');
|
||||
nfUsersTable.loadUsersTable().done(function () {
|
||||
// add the user
|
||||
var usersGrid = $('#users-table').data('gridInstance');
|
||||
|
@ -367,7 +372,7 @@
|
|||
usersGrid.setSelectedRows([row]);
|
||||
usersGrid.scrollRowIntoView(row);
|
||||
});
|
||||
}).fail(nfErrorHandler.handleAjaxError);
|
||||
}).fail(nfErrorHandler.handleConfigurationUpdateAjaxError);
|
||||
};
|
||||
|
||||
var updateGroup = function (groupId, groupIdentity, selectedUsers) {
|
||||
|
@ -394,8 +399,9 @@
|
|||
dataType: 'json',
|
||||
contentType: 'application/json'
|
||||
}).done(function (groupEntity) {
|
||||
$('#user-dialog').modal('hide');
|
||||
nfUsersTable.loadUsersTable();
|
||||
}).fail(nfErrorHandler.handleAjaxError);
|
||||
}).fail(nfErrorHandler.handleConfigurationUpdateAjaxError);
|
||||
};
|
||||
|
||||
/**
|
||||
|
@ -459,7 +465,6 @@
|
|||
}
|
||||
}
|
||||
|
||||
$('#user-dialog').modal('hide');
|
||||
}
|
||||
}
|
||||
}, {
|
||||
|
|
Loading…
Reference in New Issue