NIFI-3780 - Should be able to specify Service...

...name when I create a new Controller Service within a Processor/Service configuration dialog

Changed CS name default's behavior according to PR feedback.

Signed-off-by: Scott Aslan <scottyaslan@gmail.com>

This closes #2081
This commit is contained in:
yuri1969 2017-08-15 20:50:51 +02:00 committed by Scott Aslan
parent 79300de7a9
commit 02c05bc203
3 changed files with 28 additions and 9 deletions

View File

@ -228,7 +228,7 @@ div.disable-referencing-components, div.enable-referencing-components {
New inline controller service dialog
*/
div.new-inline-controller-service-requirement, div.new-inline-controller-service-combo, div.new-inline-controller-service-bundle, div.new-inline-controller-service-tags, div.new-inline-controller-service-description {
div.new-inline-controller-service-requirement, div.new-inline-controller-service-combo, input.new-inline-controller-service-name, div.new-inline-controller-service-bundle, div.new-inline-controller-service-tags {
margin-bottom: 15px;
}

View File

@ -996,6 +996,12 @@
'<div class="new-inline-controller-service-combo"></div>' +
'</div>' +
'</div>' +
'<div>' +
'<div class="setting-name">Controller Service Name</div>' +
'<div class="setting-field">' +
'<input type="text" class="new-inline-controller-service-name"/>' +
'</div>' +
'</div>' +
'<div>' +
'<div class="setting-name">Bundle</div>' +
'<div class="setting-field">' +
@ -1014,22 +1020,16 @@
'<div class="new-inline-controller-service-description"></div>' +
'</div>' +
'</div>' +
'<div>' +
'<div class="setting-name">Controller Service Name</div>' +
'<div class="setting-field">' +
'<input type="text" class="new-inline-controller-service-name"/>' +
'</div>' +
'</div>' +
'</div>' +
'</div>';
var newControllerServiceDialog = $(newControllerServiceDialogMarkup).appendTo(configurationOptions.dialogContainer);
var newControllerServiceRequirement = newControllerServiceDialog.find('div.new-inline-controller-service-requirement');
var newControllerServiceCombo = newControllerServiceDialog.find('div.new-inline-controller-service-combo');
var newControllerServiceNameInput = newControllerServiceDialog.find('input.new-inline-controller-service-name');
var newControllerServiceBundle = newControllerServiceDialog.find('div.new-inline-controller-service-bundle');
var newControllerServiceTags = newControllerServiceDialog.find('div.new-inline-controller-service-tags');
var newControllerServiceDescription = newControllerServiceDialog.find('div.new-inline-controller-service-description');
var newControllerServiceNameInput = newControllerServiceDialog.find('input.new-inline-controller-service-name');
// include the required service
var formattedType = nfCommon.formatType({
@ -1050,6 +1050,10 @@
return aName === bName ? -nfCommon.sortVersion(aCS.bundle.version, bCS.bundle.version) : aName > bName ? 1 : -1;
});
// default to the first service
var newControllerServiceNameDefault = nfCommon.formatClassName(controllerServiceLookup.get(0));
newControllerServiceNameInput.val(newControllerServiceNameDefault);
// build the combo field
newControllerServiceCombo.combo({
options: options,
@ -1059,6 +1063,12 @@
newControllerServiceBundle.text(nfCommon.formatBundle(service.bundle));
newControllerServiceTags.text(service.tags.join(', '));
newControllerServiceDescription.text(service.description);
// update default when no edits were made
if (newControllerServiceNameDefault === newControllerServiceNameInput.val().trim()) {
newControllerServiceNameDefault = nfCommon.formatClassName(service);
newControllerServiceNameInput.val(newControllerServiceNameDefault);
}
}
});

View File

@ -417,13 +417,22 @@
return nfCommon.typeBundleFormatter(row, cell, value, columnDef, dataContext.component);
},
/**
* Formats the class name of this component.
*
* @param dataContext component datum
*/
formatClassName: function (dataContext) {
return nfCommon.substringAfterLast(dataContext.type, '.');
},
/**
* Formats the type of this component.
*
* @param dataContext component datum
*/
formatType: function (dataContext) {
var typeString = nfCommon.substringAfterLast(dataContext.type, '.');
var typeString = nfCommon.formatClassName(dataContext);
if (dataContext.bundle.version !== 'unversioned') {
typeString += (' ' + dataContext.bundle.version);
}