NIFI-2224: - Ensuring the template form is reset when the upload template dialog is closed. NIFI-2175: - Not submitting the template form is a template isn't choosen. NIFI-2176: - Ensuring a template is specified during creation. NIFI-2223: - Ensuring templates with the same name cannot be added. NIFI-2296: - Updating the tooltip for the upload template browse button.

- Cleaning up un-used parameters to REST endpoints.

This closes #725

Signed-off-by: jpercivall <joepercivall@yahoo.com>
This commit is contained in:
Matt Gilman 2016-07-26 13:59:30 -04:00 committed by jpercivall
parent f3e49fefa0
commit ae344806c0
25 changed files with 191 additions and 169 deletions

View File

@ -75,10 +75,10 @@ public class ProcessGroupDTO extends ComponentDTO {
} }
/** /**
* @return contents of this process group. This field will be populated if the request is marked verbose * @return contents of this process group.
*/ */
@ApiModelProperty( @ApiModelProperty(
value = "The contents of this process group. This field will be populated if the request is marked verbose." value = "The contents of this process group."
) )
public FlowSnippetDTO getContents() { public FlowSnippetDTO getContents() {
return contents; return contents;

View File

@ -747,6 +747,13 @@ public interface ProcessGroup extends Authorizable, Positionable {
*/ */
void move(final Snippet snippet, final ProcessGroup destination); void move(final Snippet snippet, final ProcessGroup destination);
/**
* Verifies a template with the specified name can be created.
*
* @param name name of the template
*/
void verifyCanAddTemplate(String name);
void verifyCanDelete(); void verifyCanDelete();
/** /**

View File

@ -59,6 +59,7 @@ import org.apache.nifi.remote.RootGroupPort;
import org.apache.nifi.util.NiFiProperties; import org.apache.nifi.util.NiFiProperties;
import org.apache.nifi.util.ReflectionUtils; import org.apache.nifi.util.ReflectionUtils;
import org.apache.nifi.web.Revision; import org.apache.nifi.web.Revision;
import org.apache.nifi.web.api.dto.TemplateDTO;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
@ -126,6 +127,14 @@ public final class StandardProcessGroup implements ProcessGroup {
return parent.get(); return parent.get();
} }
private ProcessGroup getRoot() {
ProcessGroup root = this;
while (root.getParent() != null) {
root = root.getParent();
}
return root;
}
@Override @Override
public void setParent(final ProcessGroup newParent) { public void setParent(final ProcessGroup newParent) {
parent.set(newParent); parent.set(newParent);
@ -1856,7 +1865,6 @@ public final class StandardProcessGroup implements ProcessGroup {
} }
} }
@Override @Override
public void addTemplate(final Template template) { public void addTemplate(final Template template) {
requireNonNull(template); requireNonNull(template);
@ -2216,6 +2224,23 @@ public final class StandardProcessGroup implements ProcessGroup {
} }
} }
@Override
public void verifyCanAddTemplate(final String name) {
// ensure the name is specified
if (StringUtils.isBlank(name)) {
throw new IllegalArgumentException("Template name cannot be blank.");
}
for (final Template template : getRoot().findAllTemplates()) {
final TemplateDTO existingDto = template.getDetails();
// ensure a template with this name doesnt already exist
if (name.equals(existingDto.getName())) {
throw new IllegalStateException(String.format("A template named '%s' already exists.", name));
}
}
}
@Override @Override
public void verifyCanDelete() { public void verifyCanDelete() {
verifyCanDelete(false); verifyCanDelete(false);

View File

@ -17,13 +17,6 @@
package org.apache.nifi.controller.service.mock; package org.apache.nifi.controller.service.mock;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;
import org.apache.nifi.authorization.Resource; import org.apache.nifi.authorization.Resource;
import org.apache.nifi.authorization.resource.Authorizable; import org.apache.nifi.authorization.resource.Authorizable;
import org.apache.nifi.connectable.Connectable; import org.apache.nifi.connectable.Connectable;
@ -41,6 +34,13 @@ import org.apache.nifi.groups.ProcessGroup;
import org.apache.nifi.groups.ProcessGroupCounts; import org.apache.nifi.groups.ProcessGroupCounts;
import org.apache.nifi.groups.RemoteProcessGroup; import org.apache.nifi.groups.RemoteProcessGroup;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;
public class MockProcessGroup implements ProcessGroup { public class MockProcessGroup implements ProcessGroup {
private final Map<String, ControllerServiceNode> serviceMap = new HashMap<>(); private final Map<String, ControllerServiceNode> serviceMap = new HashMap<>();
private final Map<String, ProcessorNode> processorMap = new HashMap<>(); private final Map<String, ProcessorNode> processorMap = new HashMap<>();
@ -537,6 +537,10 @@ public class MockProcessGroup implements ProcessGroup {
} }
@Override
public void verifyCanAddTemplate(String name) {
}
@Override @Override
public void addTemplate(final Template template) { public void addTemplate(final Template template) {
throw new UnsupportedOperationException(); throw new UnsupportedOperationException();

View File

@ -104,7 +104,6 @@ public class AccessPolicyAuditor extends NiFiAuditor {
final AccessPolicy updatedAccessPolicy = (AccessPolicy) proceedingJoinPoint.proceed(); final AccessPolicy updatedAccessPolicy = (AccessPolicy) proceedingJoinPoint.proceed();
// if no exceptions were thrown, add the policy action... // if no exceptions were thrown, add the policy action...
// get the updated verbose state
accessPolicy = accessPolicyDAO.getAccessPolicy(updatedAccessPolicy.getIdentifier()); accessPolicy = accessPolicyDAO.getAccessPolicy(updatedAccessPolicy.getIdentifier());
// get the current user // get the current user

View File

@ -119,7 +119,6 @@ public class ProcessorAuditor extends NiFiAuditor {
final ProcessorNode updatedProcessor = (ProcessorNode) proceedingJoinPoint.proceed(); final ProcessorNode updatedProcessor = (ProcessorNode) proceedingJoinPoint.proceed();
// if no exceptions were thrown, add the processor action... // if no exceptions were thrown, add the processor action...
// get the updated verbose state
processor = processorDAO.getProcessor(updatedProcessor.getIdentifier()); processor = processorDAO.getProcessor(updatedProcessor.getIdentifier());
// get the current user // get the current user

View File

@ -98,7 +98,6 @@ public class UserAuditor extends NiFiAuditor {
final User updatedUser = (User) proceedingJoinPoint.proceed(); final User updatedUser = (User) proceedingJoinPoint.proceed();
// if no exceptions were thrown, add the user action... // if no exceptions were thrown, add the user action...
// get the updated verbose state
user = userDAO.getUser(updatedUser.getIdentifier()); user = userDAO.getUser(updatedUser.getIdentifier());
// get the current user // get the current user

View File

@ -104,7 +104,6 @@ public class UserGroupAuditor extends NiFiAuditor {
final Group updatedUserGroup = (Group) proceedingJoinPoint.proceed(); final Group updatedUserGroup = (Group) proceedingJoinPoint.proceed();
// if no exceptions were thrown, add the user group action... // if no exceptions were thrown, add the user group action...
// get the updated verbose state
user = userGroupDAO.getUserGroup(updatedUserGroup.getIdentifier()); user = userGroupDAO.getUserGroup(updatedUserGroup.getIdentifier());
// get the current user // get the current user

View File

@ -354,6 +354,15 @@ public interface NiFiServiceFacade {
// ---------------------------------------- // ----------------------------------------
// Template methods // Template methods
// ---------------------------------------- // ----------------------------------------
/**
* Verifies a template with the specified name can be created.
*
* @param groupId the id of the group for the template
* @param name name of purposed template
*/
void verifyCanAddTemplate(String groupId, String name);
/** /**
* Creates a new Template based off the specified snippet. * Creates a new Template based off the specified snippet.
* *
@ -816,10 +825,9 @@ public interface NiFiServiceFacade {
* Returns the flow. * Returns the flow.
* *
* @param groupId group * @param groupId group
* @param recurse recurse
* @return the flow * @return the flow
*/ */
ProcessGroupFlowEntity getProcessGroupFlow(String groupId, boolean recurse); ProcessGroupFlowEntity getProcessGroupFlow(String groupId);
// ---------------------------------------- // ----------------------------------------
// ProcessGroup methods // ProcessGroup methods

View File

@ -1428,6 +1428,11 @@ public class StandardNiFiServiceFacade implements NiFiServiceFacade {
return entityFactory.createRemoteProcessGroupEntity(snapshot.getComponent(), dtoFactory.createRevisionDTO(snapshot.getLastModification()), permissions, status, bulletins); return entityFactory.createRemoteProcessGroupEntity(snapshot.getComponent(), dtoFactory.createRevisionDTO(snapshot.getLastModification()), permissions, status, bulletins);
} }
@Override
public void verifyCanAddTemplate(String groupId, String name) {
templateDAO.verifyCanAddTemplate(name, groupId);
}
@Override @Override
public TemplateDTO createTemplate(final String name, final String description, final String snippetId, final String groupId, final Optional<String> idGenerationSeed) { public TemplateDTO createTemplate(final String name, final String description, final String snippetId, final String groupId, final Optional<String> idGenerationSeed) {
// get the specified snippet // get the specified snippet
@ -2531,7 +2536,7 @@ public class StandardNiFiServiceFacade implements NiFiServiceFacade {
} }
@Override @Override
public ProcessGroupFlowEntity getProcessGroupFlow(final String groupId, final boolean recurse) { public ProcessGroupFlowEntity getProcessGroupFlow(final String groupId) {
// get all identifiers for every child component // get all identifiers for every child component
final Set<String> identifiers = new HashSet<>(); final Set<String> identifiers = new HashSet<>();
final ProcessGroup processGroup = processGroupDAO.getProcessGroup(groupId); final ProcessGroup processGroup = processGroupDAO.getProcessGroup(groupId);

View File

@ -16,24 +16,7 @@
*/ */
package org.apache.nifi.web; package org.apache.nifi.web;
import java.io.UnsupportedEncodingException; import com.sun.jersey.core.util.MultivaluedMapImpl;
import java.net.URI;
import java.net.URISyntaxException;
import java.net.URLEncoder;
import java.util.Collection;
import java.util.Collections;
import java.util.Date;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Objects;
import java.util.Set;
import javax.ws.rs.HttpMethod;
import javax.ws.rs.core.MultivaluedMap;
import javax.ws.rs.core.Response;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
import org.apache.nifi.action.Action; import org.apache.nifi.action.Action;
import org.apache.nifi.action.Component; import org.apache.nifi.action.Component;
@ -76,7 +59,22 @@ import org.apache.nifi.web.util.ClientResponseUtils;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import com.sun.jersey.core.util.MultivaluedMapImpl; import javax.ws.rs.HttpMethod;
import javax.ws.rs.core.MultivaluedMap;
import javax.ws.rs.core.Response;
import java.io.UnsupportedEncodingException;
import java.net.URI;
import java.net.URISyntaxException;
import java.net.URLEncoder;
import java.util.Collection;
import java.util.Collections;
import java.util.Date;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Objects;
import java.util.Set;
/** /**
* Implements the NiFiWebConfigurationContext interface to support a context in both standalone and clustered environments. * Implements the NiFiWebConfigurationContext interface to support a context in both standalone and clustered environments.
@ -84,7 +82,6 @@ import com.sun.jersey.core.util.MultivaluedMapImpl;
public class StandardNiFiWebConfigurationContext implements NiFiWebConfigurationContext { public class StandardNiFiWebConfigurationContext implements NiFiWebConfigurationContext {
private static final Logger logger = LoggerFactory.getLogger(StandardNiFiWebConfigurationContext.class); private static final Logger logger = LoggerFactory.getLogger(StandardNiFiWebConfigurationContext.class);
public static final String VERBOSE_PARAM = "verbose";
private NiFiProperties properties; private NiFiProperties properties;
private NiFiServiceFacade serviceFacade; private NiFiServiceFacade serviceFacade;
@ -353,7 +350,6 @@ public class StandardNiFiWebConfigurationContext implements NiFiWebConfiguration
// set the request parameters // set the request parameters
final MultivaluedMap<String, String> parameters = new MultivaluedMapImpl(); final MultivaluedMap<String, String> parameters = new MultivaluedMapImpl();
parameters.add(VERBOSE_PARAM, "true");
// replicate request // replicate request
NodeResponse nodeResponse; NodeResponse nodeResponse;

View File

@ -337,8 +337,6 @@ public class FlowResource extends ApplicationResource {
/** /**
* Retrieves the contents of the specified group. * Retrieves the contents of the specified group.
* *
* @param clientId Optional client id. If the client id is not specified, a new one will be generated. This value (whether specified or generated) is included in the response.
* @param recursive Optional recursive flag that defaults to false. If set to true, all descendent groups and their content will be included if the verbose flag is also set to true.
* @param groupId The id of the process group. * @param groupId The id of the process group.
* @return A processGroupEntity. * @return A processGroupEntity.
* @throws InterruptedException if interrupted * @throws InterruptedException if interrupted
@ -366,21 +364,11 @@ public class FlowResource extends ApplicationResource {
} }
) )
public Response getFlow( public Response getFlow(
@ApiParam(
value = "If the client id is not specified, new one will be generated. This value (whether specified or generated) is included in the response.",
required = false
)
@QueryParam(CLIENT_ID) @DefaultValue(StringUtils.EMPTY) ClientIdParameter clientId,
@ApiParam( @ApiParam(
value = "The process group id.", value = "The process group id.",
required = false required = false
) )
@PathParam("id") String groupId, @PathParam("id") String groupId) throws InterruptedException {
@ApiParam(
value = "Whether the response should contain all encapsulated components or just the immediate children.",
required = false
)
@QueryParam("recursive") @DefaultValue(RECURSIVE) Boolean recursive) throws InterruptedException {
authorizeFlow(); authorizeFlow();
@ -389,7 +377,7 @@ public class FlowResource extends ApplicationResource {
} }
// get this process group flow // get this process group flow
final ProcessGroupFlowEntity entity = serviceFacade.getProcessGroupFlow(groupId, recursive); final ProcessGroupFlowEntity entity = serviceFacade.getProcessGroupFlow(groupId);
populateRemainingFlowContent(entity.getProcessGroupFlow()); populateRemainingFlowContent(entity.getProcessGroupFlow());
return clusterContext(generateOkResponse(entity)).build(); return clusterContext(generateOkResponse(entity)).build();
} }

View File

@ -1402,7 +1402,6 @@ public class ProcessGroupResource extends ApplicationResource {
/** /**
* Retrieves all the of remote process groups in this NiFi. * Retrieves all the of remote process groups in this NiFi.
* *
* @param verbose Optional verbose flag that defaults to false. If the verbose flag is set to true remote group contents (ports) will be included.
* @return A remoteProcessGroupEntity. * @return A remoteProcessGroupEntity.
*/ */
@GET @GET
@ -1429,11 +1428,6 @@ public class ProcessGroupResource extends ApplicationResource {
} }
) )
public Response getRemoteProcessGroups( public Response getRemoteProcessGroups(
@ApiParam(
value = "Whether to include any encapulated ports or just details about the remote process group.",
required = false
)
@QueryParam("verbose") @DefaultValue(VERBOSE) final Boolean verbose,
@ApiParam( @ApiParam(
value = "The process group id.", value = "The process group id.",
required = true required = true
@ -1454,13 +1448,11 @@ public class ProcessGroupResource extends ApplicationResource {
final Set<RemoteProcessGroupEntity> remoteProcessGroups = serviceFacade.getRemoteProcessGroups(groupId); final Set<RemoteProcessGroupEntity> remoteProcessGroups = serviceFacade.getRemoteProcessGroups(groupId);
// prune response as necessary // prune response as necessary
if (!verbose) {
for (RemoteProcessGroupEntity remoteProcessGroupEntity : remoteProcessGroups) { for (RemoteProcessGroupEntity remoteProcessGroupEntity : remoteProcessGroups) {
if (remoteProcessGroupEntity.getComponent() != null) { if (remoteProcessGroupEntity.getComponent() != null) {
remoteProcessGroupEntity.getComponent().setContents(null); remoteProcessGroupEntity.getComponent().setContents(null);
} }
} }
}
// create the response entity // create the response entity
final RemoteProcessGroupsEntity entity = new RemoteProcessGroupsEntity(); final RemoteProcessGroupsEntity entity = new RemoteProcessGroupsEntity();
@ -1893,6 +1885,7 @@ public class ProcessGroupResource extends ApplicationResource {
}); });
} }
if (validationPhase) { if (validationPhase) {
serviceFacade.verifyCanAddTemplate(groupId, createTemplateRequestEntity.getName());
return generateContinueResponse().build(); return generateContinueResponse().build();
} }
@ -1913,9 +1906,6 @@ public class ProcessGroupResource extends ApplicationResource {
* Imports the specified template. * Imports the specified template.
* *
* @param httpServletRequest request * @param httpServletRequest request
* @param clientId Optional client id. If the client id is not specified, a
* new one will be generated. This value (whether specified or generated) is
* included in the response.
* @param in The template stream * @param in The template stream
* @return A templateEntity or an errorResponse XML snippet. * @return A templateEntity or an errorResponse XML snippet.
* @throws InterruptedException if interrupted * @throws InterruptedException if interrupted
@ -1932,7 +1922,6 @@ public class ProcessGroupResource extends ApplicationResource {
required = true required = true
) )
@PathParam("id") final String groupId, @PathParam("id") final String groupId,
@FormDataParam(CLIENT_ID) @DefaultValue(StringUtils.EMPTY) final ClientIdParameter clientId,
@FormDataParam("template") final InputStream in) throws InterruptedException { @FormDataParam("template") final InputStream in) throws InterruptedException {
// unmarshal the template // unmarshal the template
@ -2009,6 +1998,11 @@ public class ProcessGroupResource extends ApplicationResource {
@PathParam("id") final String groupId, @PathParam("id") final String groupId,
final TemplateEntity templateEntity) { final TemplateEntity templateEntity) {
// verify the template was specified
if (templateEntity == null || templateEntity.getTemplate() == null || templateEntity.getTemplate().getSnippet() == null) {
throw new IllegalArgumentException("Template details must be specified.");
}
if (isReplicateRequest()) { if (isReplicateRequest()) {
return replicate(HttpMethod.POST, templateEntity); return replicate(HttpMethod.POST, templateEntity);
} }
@ -2023,15 +2017,11 @@ public class ProcessGroupResource extends ApplicationResource {
}); });
} }
if (validationPhase) { if (validationPhase) {
serviceFacade.verifyCanAddTemplate(groupId, templateEntity.getTemplate().getName());
return generateContinueResponse().build(); return generateContinueResponse().build();
} }
try { try {
// verify the template was specified
if (templateEntity == null || templateEntity.getTemplate() == null) {
throw new IllegalArgumentException("Template details must be specified.");
}
// import the template // import the template
final TemplateDTO template = serviceFacade.importTemplate(templateEntity.getTemplate(), groupId, getIdGenerationSeed()); final TemplateDTO template = serviceFacade.importTemplate(templateEntity.getTemplate(), groupId, getIdGenerationSeed());
templateResource.populateRemainingTemplateContent(template); templateResource.populateRemainingTemplateContent(template);

View File

@ -64,8 +64,6 @@ import java.util.Set;
) )
public class RemoteProcessGroupResource extends ApplicationResource { public class RemoteProcessGroupResource extends ApplicationResource {
private static final String VERBOSE_DEFAULT_VALUE = "false";
private NiFiServiceFacade serviceFacade; private NiFiServiceFacade serviceFacade;
private Authorizer authorizer; private Authorizer authorizer;
@ -96,7 +94,6 @@ public class RemoteProcessGroupResource extends ApplicationResource {
/** /**
* Retrieves the specified remote process group. * Retrieves the specified remote process group.
* *
* @param verbose Optional verbose flag that defaults to false. If the verbose flag is set to true remote group contents (ports) will be included.
* @param id The id of the remote process group to retrieve * @param id The id of the remote process group to retrieve
* @return A remoteProcessGroupEntity. * @return A remoteProcessGroupEntity.
*/ */
@ -124,11 +121,6 @@ public class RemoteProcessGroupResource extends ApplicationResource {
} }
) )
public Response getRemoteProcessGroup( public Response getRemoteProcessGroup(
@ApiParam(
value = "Whether to include any encapulated ports or just details about the remote process group.",
required = false
)
@QueryParam("verbose") @DefaultValue(VERBOSE_DEFAULT_VALUE) final Boolean verbose,
@ApiParam( @ApiParam(
value = "The remote process group id.", value = "The remote process group id.",
required = true required = true
@ -149,13 +141,6 @@ public class RemoteProcessGroupResource extends ApplicationResource {
final RemoteProcessGroupEntity entity = serviceFacade.getRemoteProcessGroup(id); final RemoteProcessGroupEntity entity = serviceFacade.getRemoteProcessGroup(id);
populateRemainingRemoteProcessGroupEntityContent(entity); populateRemainingRemoteProcessGroupEntityContent(entity);
// prune the response as necessary
if (!verbose) {
if (entity.getComponent() != null) {
entity.getComponent().setContents(null);
}
}
return clusterContext(generateOkResponse(entity)).build(); return clusterContext(generateOkResponse(entity)).build();
} }

View File

@ -24,6 +24,14 @@ import java.util.Set;
public interface TemplateDAO { public interface TemplateDAO {
/**
* Verifies a new template can be created with the specifed name in the specified group.
*
* @param name template name
* @param groupId group id
*/
void verifyCanAddTemplate(String name, String groupId);
/** /**
* Creates a template. * Creates a template.
* *

View File

@ -55,6 +55,20 @@ public class StandardTemplateDAO extends ComponentDAO implements TemplateDAO {
return template; return template;
} }
@Override
public void verifyCanAddTemplate(String name, String groupId) {
final ProcessGroup processGroup = flowController.getGroup(groupId);
if (processGroup == null) {
throw new ResourceNotFoundException("Could not find Process Group with ID " + groupId);
}
verifyAdd(name, processGroup);
}
private void verifyAdd(final String name, final ProcessGroup processGroup) {
processGroup.verifyCanAddTemplate(name);
}
@Override @Override
public Template createTemplate(TemplateDTO templateDTO, String groupId) { public Template createTemplate(TemplateDTO templateDTO, String groupId) {
final ProcessGroup processGroup = flowController.getGroup(groupId); final ProcessGroup processGroup = flowController.getGroup(groupId);
@ -62,6 +76,8 @@ public class StandardTemplateDAO extends ComponentDAO implements TemplateDAO {
throw new ResourceNotFoundException("Could not find Process Group with ID " + groupId); throw new ResourceNotFoundException("Could not find Process Group with ID " + groupId);
} }
verifyAdd(templateDTO.getName(), processGroup);
TemplateUtils.scrubTemplate(templateDTO); TemplateUtils.scrubTemplate(templateDTO);
final Template template = new Template(templateDTO); final Template template = new Template(templateDTO);
processGroup.addTemplate(template); processGroup.addTemplate(template);

View File

@ -23,7 +23,7 @@
<div id="select-template-button"> <div id="select-template-button">
<button class="fa fa-search"></button> <button class="fa fa-search"></button>
<form id="template-upload-form" enctype="multipart/form-data" method="post"> <form id="template-upload-form" enctype="multipart/form-data" method="post">
<input type="file" name="template" id="template-file-field"/> <input type="file" name="template" id="template-file-field" title="Browse"/>
</form> </form>
</div> </div>
</div> </div>

View File

@ -280,6 +280,12 @@ span.details-title {
margin-left: 1px; margin-left: 1px;
} }
#upload-template-button {
color: #004849;
font-size: 16px;
cursor: pointer;
}
#template-file-upload { #template-file-upload {
position: absolute; position: absolute;
top: 0; top: 0;

View File

@ -141,7 +141,7 @@ nf.ng.Canvas.OperateCtrl = function () {
} }
}, },
error: function (xhr, statusText, error) { error: function (xhr, statusText, error) {
$('#upload-template-status').text(error); $('#upload-template-status').text(xhr.responseText);
} }
}); });
@ -157,10 +157,16 @@ nf.ng.Canvas.OperateCtrl = function () {
}, },
handler: { handler: {
click: function () { click: function () {
// submit the template var selectedTemplate = $('#selected-template-name').text();
// submit the template if necessary
if (nf.Common.isBlank(selectedTemplate)) {
$('#upload-template-status').text('No template selected. Please browse to select a template.');
} else {
templateForm.submit(); templateForm.submit();
} }
} }
}
}, { }, {
buttonText: 'Cancel', buttonText: 'Cancel',
color: { color: {
@ -172,9 +178,6 @@ nf.ng.Canvas.OperateCtrl = function () {
click: function () { click: function () {
// hide the dialog // hide the dialog
$('#upload-template-dialog').modal('hide'); $('#upload-template-dialog').modal('hide');
// reset the form to ensure that the change fire will fire
templateForm.resetForm();
} }
} }
}], }],
@ -183,6 +186,9 @@ nf.ng.Canvas.OperateCtrl = function () {
// set the filename // set the filename
$('#selected-template-name').text(''); $('#selected-template-name').text('');
$('#upload-template-status').text(''); $('#upload-template-status').text('');
// reset the form to ensure that the change fire will fire
templateForm.resetForm();
} }
} }
}); });

View File

@ -71,9 +71,6 @@ nf.Actions = (function () {
$.ajax({ $.ajax({
type: 'GET', type: 'GET',
url: config.urls.api + '/flow/process-groups/' + encodeURIComponent(response.id), url: config.urls.api + '/flow/process-groups/' + encodeURIComponent(response.id),
data: {
verbose: true
},
dataType: 'json' dataType: 'json'
}).done(function (response) { }).done(function (response) {
nf.Graph.set(response.processGroupFlow.flow); nf.Graph.set(response.processGroupFlow.flow);
@ -1233,11 +1230,22 @@ nf.Actions = (function () {
}, },
handler: { handler: {
click: function () { click: function () {
// get the template details
var templateName = $('#new-template-name').val();
// ensure the template name is not blank
if (nf.Common.isBlank(templateName)) {
nf.Dialog.showOkDialog({
headerText: 'Create Template',
dialogContent: "The template name cannot be blank."
});
return;
}
// hide the dialog // hide the dialog
$('#new-template-dialog').modal('hide'); $('#new-template-dialog').modal('hide');
// get the template details // get the description
var templateName = $('#new-template-name').val();
var templateDescription = $('#new-template-description').val(); var templateDescription = $('#new-template-description').val();
// create a snippet // create a snippet
@ -1281,6 +1289,10 @@ nf.Actions = (function () {
}, },
handler: { handler: {
click: function () { click: function () {
// clear the template dialog fields
$('#new-template-name').val('');
$('#new-template-description').val('');
$('#new-template-dialog').modal('hide'); $('#new-template-dialog').modal('hide');
} }
} }

View File

@ -621,9 +621,6 @@ nf.Canvas = (function () {
return $.ajax({ return $.ajax({
type: 'GET', type: 'GET',
url: config.urls.api + '/flow/process-groups/' + encodeURIComponent(processGroupId), url: config.urls.api + '/flow/process-groups/' + encodeURIComponent(processGroupId),
data: {
verbose: true
},
dataType: 'json' dataType: 'json'
}).done(function (flowResponse) { }).done(function (flowResponse) {
// get the controller and its contents // get the controller and its contents

View File

@ -275,9 +275,6 @@ nf.ConnectionConfiguration = (function () {
$.ajax({ $.ajax({
type: 'GET', type: 'GET',
url: config.urls.api + '/flow/process-groups/' + encodeURIComponent(processGroupData.id), url: config.urls.api + '/flow/process-groups/' + encodeURIComponent(processGroupData.id),
data: {
verbose: true
},
dataType: 'json' dataType: 'json'
}).done(function (response) { }).done(function (response) {
var processGroup = response.processGroupFlow; var processGroup = response.processGroupFlow;
@ -363,9 +360,6 @@ nf.ConnectionConfiguration = (function () {
$.ajax({ $.ajax({
type: 'GET', type: 'GET',
url: remoteProcessGroupData.uri, url: remoteProcessGroupData.uri,
data: {
verbose: true
},
dataType: 'json' dataType: 'json'
}).done(function (response) { }).done(function (response) {
var remoteProcessGroup = response.component; var remoteProcessGroup = response.component;
@ -591,9 +585,6 @@ nf.ConnectionConfiguration = (function () {
$.ajax({ $.ajax({
type: 'GET', type: 'GET',
url: remoteProcessGroupData.uri, url: remoteProcessGroupData.uri,
data: {
verbose: true
},
dataType: 'json' dataType: 'json'
}).done(function (response) { }).done(function (response) {
var remoteProcessGroup = response.component; var remoteProcessGroup = response.component;

View File

@ -471,9 +471,6 @@ nf.RemoteProcessGroupPorts = (function () {
$.ajax({ $.ajax({
type: 'GET', type: 'GET',
url: selectionData.uri, url: selectionData.uri,
data: {
verbose: true
},
dataType: 'json' dataType: 'json'
}).done(function (response) { }).done(function (response) {
var remoteProcessGroup = response.component; var remoteProcessGroup = response.component;

View File

@ -108,9 +108,6 @@ nf.ConnectionDetails = (function () {
$.ajax({ $.ajax({
type: 'GET', type: 'GET',
url: '../nifi-api/remote-process-groups/' + encodeURIComponent(source.groupId), url: '../nifi-api/remote-process-groups/' + encodeURIComponent(source.groupId),
data: {
verbose: true
},
dataType: 'json' dataType: 'json'
}).done(function (response) { }).done(function (response) {
var remoteProcessGroup = response.component; var remoteProcessGroup = response.component;
@ -154,9 +151,6 @@ nf.ConnectionDetails = (function () {
$.ajax({ $.ajax({
type: 'GET', type: 'GET',
url: '../nifi-api/process-groups/' + encodeURIComponent(source.groupId), url: '../nifi-api/process-groups/' + encodeURIComponent(source.groupId),
data: {
verbose: true
},
dataType: 'json' dataType: 'json'
}).done(function (response) { }).done(function (response) {
var processGroup = response.component; var processGroup = response.component;
@ -272,9 +266,6 @@ nf.ConnectionDetails = (function () {
$.ajax({ $.ajax({
type: 'GET', type: 'GET',
url: '../nifi-api/remote-process-groups/' + encodeURIComponent(destination.groupId), url: '../nifi-api/remote-process-groups/' + encodeURIComponent(destination.groupId),
data: {
verbose: true
},
dataType: 'json' dataType: 'json'
}).done(function (response) { }).done(function (response) {
var remoteProcessGroup = response.component; var remoteProcessGroup = response.component;
@ -320,9 +311,6 @@ nf.ConnectionDetails = (function () {
$.ajax({ $.ajax({
type: 'GET', type: 'GET',
url: '../nifi-api/process-groups/' + encodeURIComponent(destination.groupId), url: '../nifi-api/process-groups/' + encodeURIComponent(destination.groupId),
data: {
verbose: true
},
dataType: 'json' dataType: 'json'
}).done(function (response) { }).done(function (response) {
var processGroup = response.component; var processGroup = response.component;

View File

@ -394,9 +394,6 @@ nf.TemplatesTable = (function () {
return $.ajax({ return $.ajax({
type: 'GET', type: 'GET',
url: config.urls.templates, url: config.urls.templates,
data: {
verbose: false
},
dataType: 'json' dataType: 'json'
}).done(function (response) { }).done(function (response) {
// ensure there are groups specified // ensure there are groups specified