NIFI-2837: - Immediately hiding the template dialog after clicking the Upload button to prevent an accidental re-submission.

This closes #1086.

Signed-off-by: Bryan Bende <bbende@apache.org>
This commit is contained in:
Matt Gilman 2016-09-29 14:57:07 -04:00 committed by Bryan Bende
parent af27179322
commit a25b651da9
No known key found for this signature in database
GPG Key ID: A0DDA9ED50711C39
1 changed files with 18 additions and 10 deletions

View File

@ -121,34 +121,39 @@ nf.ng.Canvas.OperateCtrl = function () {
options.url += (encodeURIComponent(nf.Canvas.getGroupId()) + '/templates/upload');
},
success: function (response, statusText, xhr, form) {
// see if the import was successful
// see if the import was successful and inform the user
if (response.documentElement.tagName === 'templateEntity') {
// close the dialog
$('#upload-template-dialog').modal('hide');
// close the settings dialog
nf.Dialog.showOkDialog({
headerText: 'Success',
dialogContent: 'Template successfully imported.'
});
} else {
// import failed
var status = 'Unable to import template. Please check the log for errors.';
var statusText = 'Unable to import template. Please check the log for errors.';
if (response.documentElement.tagName === 'errorResponse') {
// if a more specific error was given, use it
var errorMessage = response.documentElement.getAttribute('statusText');
if (!nf.Common.isBlank(errorMessage)) {
status = errorMessage;
statusText = errorMessage;
}
}
$('#upload-template-status').text(status);
// show reason
nf.Dialog.showOkDialog({
headerText: 'Unable to Upload',
dialogContent: nf.Common.escapeHtml(statusText)
});
}
},
error: function (xhr, statusText, error) {
$('#upload-template-status').text(xhr.responseText);
// request failed
nf.Dialog.showOkDialog({
headerText: 'Unable to Upload',
dialogContent: nf.Common.escapeHtml(xhr.responseText)
});
}
});
// configure the upload template dialog
this.getElement().modal({
headerText: 'Upload Template',
@ -168,6 +173,9 @@ nf.ng.Canvas.OperateCtrl = function () {
$('#upload-template-status').text('No template selected. Please browse to select a template.');
} else {
templateForm.submit();
// hide the dialog
$('#upload-template-dialog').modal('hide');
}
}
}