mirror of https://github.com/apache/nifi.git
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:
parent
f3e49fefa0
commit
ae344806c0
|
@ -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(
|
||||
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() {
|
||||
return contents;
|
||||
|
|
|
@ -747,6 +747,13 @@ public interface ProcessGroup extends Authorizable, Positionable {
|
|||
*/
|
||||
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();
|
||||
|
||||
/**
|
||||
|
|
|
@ -59,6 +59,7 @@ import org.apache.nifi.remote.RootGroupPort;
|
|||
import org.apache.nifi.util.NiFiProperties;
|
||||
import org.apache.nifi.util.ReflectionUtils;
|
||||
import org.apache.nifi.web.Revision;
|
||||
import org.apache.nifi.web.api.dto.TemplateDTO;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
|
@ -126,6 +127,14 @@ public final class StandardProcessGroup implements ProcessGroup {
|
|||
return parent.get();
|
||||
}
|
||||
|
||||
private ProcessGroup getRoot() {
|
||||
ProcessGroup root = this;
|
||||
while (root.getParent() != null) {
|
||||
root = root.getParent();
|
||||
}
|
||||
return root;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setParent(final ProcessGroup newParent) {
|
||||
parent.set(newParent);
|
||||
|
@ -1856,7 +1865,6 @@ public final class StandardProcessGroup implements ProcessGroup {
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void addTemplate(final Template 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
|
||||
public void verifyCanDelete() {
|
||||
verifyCanDelete(false);
|
||||
|
|
|
@ -17,13 +17,6 @@
|
|||
|
||||
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.Authorizable;
|
||||
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.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 {
|
||||
private final Map<String, ControllerServiceNode> serviceMap = 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
|
||||
public void addTemplate(final Template template) {
|
||||
throw new UnsupportedOperationException();
|
||||
|
|
|
@ -104,7 +104,6 @@ public class AccessPolicyAuditor extends NiFiAuditor {
|
|||
final AccessPolicy updatedAccessPolicy = (AccessPolicy) proceedingJoinPoint.proceed();
|
||||
|
||||
// if no exceptions were thrown, add the policy action...
|
||||
// get the updated verbose state
|
||||
accessPolicy = accessPolicyDAO.getAccessPolicy(updatedAccessPolicy.getIdentifier());
|
||||
|
||||
// get the current user
|
||||
|
|
|
@ -119,7 +119,6 @@ public class ProcessorAuditor extends NiFiAuditor {
|
|||
final ProcessorNode updatedProcessor = (ProcessorNode) proceedingJoinPoint.proceed();
|
||||
|
||||
// if no exceptions were thrown, add the processor action...
|
||||
// get the updated verbose state
|
||||
processor = processorDAO.getProcessor(updatedProcessor.getIdentifier());
|
||||
|
||||
// get the current user
|
||||
|
|
|
@ -98,7 +98,6 @@ public class UserAuditor extends NiFiAuditor {
|
|||
final User updatedUser = (User) proceedingJoinPoint.proceed();
|
||||
|
||||
// if no exceptions were thrown, add the user action...
|
||||
// get the updated verbose state
|
||||
user = userDAO.getUser(updatedUser.getIdentifier());
|
||||
|
||||
// get the current user
|
||||
|
|
|
@ -104,7 +104,6 @@ public class UserGroupAuditor extends NiFiAuditor {
|
|||
final Group updatedUserGroup = (Group) proceedingJoinPoint.proceed();
|
||||
|
||||
// if no exceptions were thrown, add the user group action...
|
||||
// get the updated verbose state
|
||||
user = userGroupDAO.getUserGroup(updatedUserGroup.getIdentifier());
|
||||
|
||||
// get the current user
|
||||
|
|
|
@ -354,6 +354,15 @@ public interface NiFiServiceFacade {
|
|||
// ----------------------------------------
|
||||
// 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.
|
||||
*
|
||||
|
@ -816,10 +825,9 @@ public interface NiFiServiceFacade {
|
|||
* Returns the flow.
|
||||
*
|
||||
* @param groupId group
|
||||
* @param recurse recurse
|
||||
* @return the flow
|
||||
*/
|
||||
ProcessGroupFlowEntity getProcessGroupFlow(String groupId, boolean recurse);
|
||||
ProcessGroupFlowEntity getProcessGroupFlow(String groupId);
|
||||
|
||||
// ----------------------------------------
|
||||
// ProcessGroup methods
|
||||
|
|
|
@ -1428,6 +1428,11 @@ public class StandardNiFiServiceFacade implements NiFiServiceFacade {
|
|||
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
|
||||
public TemplateDTO createTemplate(final String name, final String description, final String snippetId, final String groupId, final Optional<String> idGenerationSeed) {
|
||||
// get the specified snippet
|
||||
|
@ -2531,7 +2536,7 @@ public class StandardNiFiServiceFacade implements NiFiServiceFacade {
|
|||
}
|
||||
|
||||
@Override
|
||||
public ProcessGroupFlowEntity getProcessGroupFlow(final String groupId, final boolean recurse) {
|
||||
public ProcessGroupFlowEntity getProcessGroupFlow(final String groupId) {
|
||||
// get all identifiers for every child component
|
||||
final Set<String> identifiers = new HashSet<>();
|
||||
final ProcessGroup processGroup = processGroupDAO.getProcessGroup(groupId);
|
||||
|
|
|
@ -16,24 +16,7 @@
|
|||
*/
|
||||
package org.apache.nifi.web;
|
||||
|
||||
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;
|
||||
|
||||
import javax.ws.rs.HttpMethod;
|
||||
import javax.ws.rs.core.MultivaluedMap;
|
||||
import javax.ws.rs.core.Response;
|
||||
|
||||
import com.sun.jersey.core.util.MultivaluedMapImpl;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.apache.nifi.action.Action;
|
||||
import org.apache.nifi.action.Component;
|
||||
|
@ -76,7 +59,22 @@ import org.apache.nifi.web.util.ClientResponseUtils;
|
|||
import org.slf4j.Logger;
|
||||
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.
|
||||
|
@ -84,7 +82,6 @@ import com.sun.jersey.core.util.MultivaluedMapImpl;
|
|||
public class StandardNiFiWebConfigurationContext implements NiFiWebConfigurationContext {
|
||||
|
||||
private static final Logger logger = LoggerFactory.getLogger(StandardNiFiWebConfigurationContext.class);
|
||||
public static final String VERBOSE_PARAM = "verbose";
|
||||
|
||||
private NiFiProperties properties;
|
||||
private NiFiServiceFacade serviceFacade;
|
||||
|
@ -353,7 +350,6 @@ public class StandardNiFiWebConfigurationContext implements NiFiWebConfiguration
|
|||
|
||||
// set the request parameters
|
||||
final MultivaluedMap<String, String> parameters = new MultivaluedMapImpl();
|
||||
parameters.add(VERBOSE_PARAM, "true");
|
||||
|
||||
// replicate request
|
||||
NodeResponse nodeResponse;
|
||||
|
|
|
@ -337,8 +337,6 @@ public class FlowResource extends ApplicationResource {
|
|||
/**
|
||||
* 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.
|
||||
* @return A processGroupEntity.
|
||||
* @throws InterruptedException if interrupted
|
||||
|
@ -366,21 +364,11 @@ public class FlowResource extends ApplicationResource {
|
|||
}
|
||||
)
|
||||
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(
|
||||
value = "The process group id.",
|
||||
required = false
|
||||
)
|
||||
@PathParam("id") String groupId,
|
||||
@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 {
|
||||
@PathParam("id") String groupId) throws InterruptedException {
|
||||
|
||||
authorizeFlow();
|
||||
|
||||
|
@ -389,7 +377,7 @@ public class FlowResource extends ApplicationResource {
|
|||
}
|
||||
|
||||
// get this process group flow
|
||||
final ProcessGroupFlowEntity entity = serviceFacade.getProcessGroupFlow(groupId, recursive);
|
||||
final ProcessGroupFlowEntity entity = serviceFacade.getProcessGroupFlow(groupId);
|
||||
populateRemainingFlowContent(entity.getProcessGroupFlow());
|
||||
return clusterContext(generateOkResponse(entity)).build();
|
||||
}
|
||||
|
|
|
@ -1402,7 +1402,6 @@ public class ProcessGroupResource extends ApplicationResource {
|
|||
/**
|
||||
* 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.
|
||||
*/
|
||||
@GET
|
||||
|
@ -1429,11 +1428,6 @@ public class ProcessGroupResource extends ApplicationResource {
|
|||
}
|
||||
)
|
||||
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(
|
||||
value = "The process group id.",
|
||||
required = true
|
||||
|
@ -1454,11 +1448,9 @@ public class ProcessGroupResource extends ApplicationResource {
|
|||
final Set<RemoteProcessGroupEntity> remoteProcessGroups = serviceFacade.getRemoteProcessGroups(groupId);
|
||||
|
||||
// prune response as necessary
|
||||
if (!verbose) {
|
||||
for (RemoteProcessGroupEntity remoteProcessGroupEntity : remoteProcessGroups) {
|
||||
if (remoteProcessGroupEntity.getComponent() != null) {
|
||||
remoteProcessGroupEntity.getComponent().setContents(null);
|
||||
}
|
||||
for (RemoteProcessGroupEntity remoteProcessGroupEntity : remoteProcessGroups) {
|
||||
if (remoteProcessGroupEntity.getComponent() != null) {
|
||||
remoteProcessGroupEntity.getComponent().setContents(null);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1893,6 +1885,7 @@ public class ProcessGroupResource extends ApplicationResource {
|
|||
});
|
||||
}
|
||||
if (validationPhase) {
|
||||
serviceFacade.verifyCanAddTemplate(groupId, createTemplateRequestEntity.getName());
|
||||
return generateContinueResponse().build();
|
||||
}
|
||||
|
||||
|
@ -1913,9 +1906,6 @@ public class ProcessGroupResource extends ApplicationResource {
|
|||
* Imports the specified template.
|
||||
*
|
||||
* @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
|
||||
* @return A templateEntity or an errorResponse XML snippet.
|
||||
* @throws InterruptedException if interrupted
|
||||
|
@ -1932,7 +1922,6 @@ public class ProcessGroupResource extends ApplicationResource {
|
|||
required = true
|
||||
)
|
||||
@PathParam("id") final String groupId,
|
||||
@FormDataParam(CLIENT_ID) @DefaultValue(StringUtils.EMPTY) final ClientIdParameter clientId,
|
||||
@FormDataParam("template") final InputStream in) throws InterruptedException {
|
||||
|
||||
// unmarshal the template
|
||||
|
@ -2009,6 +1998,11 @@ public class ProcessGroupResource extends ApplicationResource {
|
|||
@PathParam("id") final String groupId,
|
||||
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()) {
|
||||
return replicate(HttpMethod.POST, templateEntity);
|
||||
}
|
||||
|
@ -2023,15 +2017,11 @@ public class ProcessGroupResource extends ApplicationResource {
|
|||
});
|
||||
}
|
||||
if (validationPhase) {
|
||||
serviceFacade.verifyCanAddTemplate(groupId, templateEntity.getTemplate().getName());
|
||||
return generateContinueResponse().build();
|
||||
}
|
||||
|
||||
try {
|
||||
// verify the template was specified
|
||||
if (templateEntity == null || templateEntity.getTemplate() == null) {
|
||||
throw new IllegalArgumentException("Template details must be specified.");
|
||||
}
|
||||
|
||||
// import the template
|
||||
final TemplateDTO template = serviceFacade.importTemplate(templateEntity.getTemplate(), groupId, getIdGenerationSeed());
|
||||
templateResource.populateRemainingTemplateContent(template);
|
||||
|
|
|
@ -64,8 +64,6 @@ import java.util.Set;
|
|||
)
|
||||
public class RemoteProcessGroupResource extends ApplicationResource {
|
||||
|
||||
private static final String VERBOSE_DEFAULT_VALUE = "false";
|
||||
|
||||
private NiFiServiceFacade serviceFacade;
|
||||
private Authorizer authorizer;
|
||||
|
||||
|
@ -96,7 +94,6 @@ public class RemoteProcessGroupResource extends ApplicationResource {
|
|||
/**
|
||||
* 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
|
||||
* @return A remoteProcessGroupEntity.
|
||||
*/
|
||||
|
@ -124,11 +121,6 @@ public class RemoteProcessGroupResource extends ApplicationResource {
|
|||
}
|
||||
)
|
||||
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(
|
||||
value = "The remote process group id.",
|
||||
required = true
|
||||
|
@ -149,13 +141,6 @@ public class RemoteProcessGroupResource extends ApplicationResource {
|
|||
final RemoteProcessGroupEntity entity = serviceFacade.getRemoteProcessGroup(id);
|
||||
populateRemainingRemoteProcessGroupEntityContent(entity);
|
||||
|
||||
// prune the response as necessary
|
||||
if (!verbose) {
|
||||
if (entity.getComponent() != null) {
|
||||
entity.getComponent().setContents(null);
|
||||
}
|
||||
}
|
||||
|
||||
return clusterContext(generateOkResponse(entity)).build();
|
||||
}
|
||||
|
||||
|
|
|
@ -24,6 +24,14 @@ import java.util.Set;
|
|||
|
||||
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.
|
||||
*
|
||||
|
|
|
@ -55,6 +55,20 @@ public class StandardTemplateDAO extends ComponentDAO implements TemplateDAO {
|
|||
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
|
||||
public Template createTemplate(TemplateDTO templateDTO, String 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);
|
||||
}
|
||||
|
||||
verifyAdd(templateDTO.getName(), processGroup);
|
||||
|
||||
TemplateUtils.scrubTemplate(templateDTO);
|
||||
final Template template = new Template(templateDTO);
|
||||
processGroup.addTemplate(template);
|
||||
|
|
|
@ -23,7 +23,7 @@
|
|||
<div id="select-template-button">
|
||||
<button class="fa fa-search"></button>
|
||||
<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>
|
||||
</div>
|
||||
</div>
|
||||
|
|
|
@ -280,6 +280,12 @@ span.details-title {
|
|||
margin-left: 1px;
|
||||
}
|
||||
|
||||
#upload-template-button {
|
||||
color: #004849;
|
||||
font-size: 16px;
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
#template-file-upload {
|
||||
position: absolute;
|
||||
top: 0;
|
||||
|
|
|
@ -141,7 +141,7 @@ nf.ng.Canvas.OperateCtrl = function () {
|
|||
}
|
||||
},
|
||||
error: function (xhr, statusText, error) {
|
||||
$('#upload-template-status').text(error);
|
||||
$('#upload-template-status').text(xhr.responseText);
|
||||
}
|
||||
});
|
||||
|
||||
|
@ -157,8 +157,14 @@ nf.ng.Canvas.OperateCtrl = function () {
|
|||
},
|
||||
handler: {
|
||||
click: function () {
|
||||
// submit the template
|
||||
templateForm.submit();
|
||||
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();
|
||||
}
|
||||
}
|
||||
}
|
||||
}, {
|
||||
|
@ -172,9 +178,6 @@ nf.ng.Canvas.OperateCtrl = function () {
|
|||
click: function () {
|
||||
// hide the dialog
|
||||
$('#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
|
||||
$('#selected-template-name').text('');
|
||||
$('#upload-template-status').text('');
|
||||
|
||||
// reset the form to ensure that the change fire will fire
|
||||
templateForm.resetForm();
|
||||
}
|
||||
}
|
||||
});
|
||||
|
|
|
@ -71,9 +71,6 @@ nf.Actions = (function () {
|
|||
$.ajax({
|
||||
type: 'GET',
|
||||
url: config.urls.api + '/flow/process-groups/' + encodeURIComponent(response.id),
|
||||
data: {
|
||||
verbose: true
|
||||
},
|
||||
dataType: 'json'
|
||||
}).done(function (response) {
|
||||
nf.Graph.set(response.processGroupFlow.flow);
|
||||
|
@ -1233,58 +1230,73 @@ nf.Actions = (function () {
|
|||
},
|
||||
handler: {
|
||||
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
|
||||
$('#new-template-dialog').modal('hide');
|
||||
|
||||
// get the template details
|
||||
var templateName = $('#new-template-name').val();
|
||||
// get the description
|
||||
var templateDescription = $('#new-template-description').val();
|
||||
|
||||
// create a snippet
|
||||
var snippet = nf.Snippet.marshal(selection);
|
||||
// create a snippet
|
||||
var snippet = nf.Snippet.marshal(selection);
|
||||
|
||||
// create the snippet
|
||||
nf.Snippet.create(snippet).done(function (response) {
|
||||
var createSnippetEntity = {
|
||||
'name': templateName,
|
||||
'description': templateDescription,
|
||||
'snippetId': response.snippet.id
|
||||
};
|
||||
// create the snippet
|
||||
nf.Snippet.create(snippet).done(function (response) {
|
||||
var createSnippetEntity = {
|
||||
'name': templateName,
|
||||
'description': templateDescription,
|
||||
'snippetId': response.snippet.id
|
||||
};
|
||||
|
||||
// create the template
|
||||
$.ajax({
|
||||
type: 'POST',
|
||||
url: config.urls.api + '/process-groups/' + encodeURIComponent(nf.Canvas.getGroupId()) + '/templates',
|
||||
data: JSON.stringify(createSnippetEntity),
|
||||
dataType: 'json',
|
||||
contentType: 'application/json'
|
||||
}).done(function () {
|
||||
// show the confirmation dialog
|
||||
nf.Dialog.showOkDialog({
|
||||
headerText: 'Create Template',
|
||||
dialogContent: "Template '" + nf.Common.escapeHtml(templateName) + "' was successfully created."
|
||||
});
|
||||
}).always(function () {
|
||||
// clear the template dialog fields
|
||||
$('#new-template-name').val('');
|
||||
$('#new-template-description').val('');
|
||||
}).fail(nf.Common.handleAjaxError);
|
||||
// create the template
|
||||
$.ajax({
|
||||
type: 'POST',
|
||||
url: config.urls.api + '/process-groups/' + encodeURIComponent(nf.Canvas.getGroupId()) + '/templates',
|
||||
data: JSON.stringify(createSnippetEntity),
|
||||
dataType: 'json',
|
||||
contentType: 'application/json'
|
||||
}).done(function () {
|
||||
// show the confirmation dialog
|
||||
nf.Dialog.showOkDialog({
|
||||
headerText: 'Create Template',
|
||||
dialogContent: "Template '" + nf.Common.escapeHtml(templateName) + "' was successfully created."
|
||||
});
|
||||
}).always(function () {
|
||||
// clear the template dialog fields
|
||||
$('#new-template-name').val('');
|
||||
$('#new-template-description').val('');
|
||||
}).fail(nf.Common.handleAjaxError);
|
||||
}
|
||||
}).fail(nf.Common.handleAjaxError);
|
||||
}
|
||||
}, {
|
||||
buttonText: 'Cancel',
|
||||
color: {
|
||||
base: '#E3E8EB',
|
||||
hover: '#C7D2D7',
|
||||
text: '#004849'
|
||||
},
|
||||
handler: {
|
||||
click: function () {
|
||||
$('#new-template-dialog').modal('hide');
|
||||
}
|
||||
}
|
||||
}, {
|
||||
buttonText: 'Cancel',
|
||||
color: {
|
||||
base: '#E3E8EB',
|
||||
hover: '#C7D2D7',
|
||||
text: '#004849'
|
||||
},
|
||||
handler: {
|
||||
click: function () {
|
||||
// clear the template dialog fields
|
||||
$('#new-template-name').val('');
|
||||
$('#new-template-description').val('');
|
||||
|
||||
$('#new-template-dialog').modal('hide');
|
||||
}
|
||||
}]).modal('show');
|
||||
}
|
||||
}]).modal('show');
|
||||
|
||||
// auto focus on the template name
|
||||
$('#new-template-name').focus();
|
||||
|
|
|
@ -621,9 +621,6 @@ nf.Canvas = (function () {
|
|||
return $.ajax({
|
||||
type: 'GET',
|
||||
url: config.urls.api + '/flow/process-groups/' + encodeURIComponent(processGroupId),
|
||||
data: {
|
||||
verbose: true
|
||||
},
|
||||
dataType: 'json'
|
||||
}).done(function (flowResponse) {
|
||||
// get the controller and its contents
|
||||
|
|
|
@ -275,9 +275,6 @@ nf.ConnectionConfiguration = (function () {
|
|||
$.ajax({
|
||||
type: 'GET',
|
||||
url: config.urls.api + '/flow/process-groups/' + encodeURIComponent(processGroupData.id),
|
||||
data: {
|
||||
verbose: true
|
||||
},
|
||||
dataType: 'json'
|
||||
}).done(function (response) {
|
||||
var processGroup = response.processGroupFlow;
|
||||
|
@ -363,9 +360,6 @@ nf.ConnectionConfiguration = (function () {
|
|||
$.ajax({
|
||||
type: 'GET',
|
||||
url: remoteProcessGroupData.uri,
|
||||
data: {
|
||||
verbose: true
|
||||
},
|
||||
dataType: 'json'
|
||||
}).done(function (response) {
|
||||
var remoteProcessGroup = response.component;
|
||||
|
@ -591,9 +585,6 @@ nf.ConnectionConfiguration = (function () {
|
|||
$.ajax({
|
||||
type: 'GET',
|
||||
url: remoteProcessGroupData.uri,
|
||||
data: {
|
||||
verbose: true
|
||||
},
|
||||
dataType: 'json'
|
||||
}).done(function (response) {
|
||||
var remoteProcessGroup = response.component;
|
||||
|
|
|
@ -471,9 +471,6 @@ nf.RemoteProcessGroupPorts = (function () {
|
|||
$.ajax({
|
||||
type: 'GET',
|
||||
url: selectionData.uri,
|
||||
data: {
|
||||
verbose: true
|
||||
},
|
||||
dataType: 'json'
|
||||
}).done(function (response) {
|
||||
var remoteProcessGroup = response.component;
|
||||
|
|
|
@ -108,9 +108,6 @@ nf.ConnectionDetails = (function () {
|
|||
$.ajax({
|
||||
type: 'GET',
|
||||
url: '../nifi-api/remote-process-groups/' + encodeURIComponent(source.groupId),
|
||||
data: {
|
||||
verbose: true
|
||||
},
|
||||
dataType: 'json'
|
||||
}).done(function (response) {
|
||||
var remoteProcessGroup = response.component;
|
||||
|
@ -154,9 +151,6 @@ nf.ConnectionDetails = (function () {
|
|||
$.ajax({
|
||||
type: 'GET',
|
||||
url: '../nifi-api/process-groups/' + encodeURIComponent(source.groupId),
|
||||
data: {
|
||||
verbose: true
|
||||
},
|
||||
dataType: 'json'
|
||||
}).done(function (response) {
|
||||
var processGroup = response.component;
|
||||
|
@ -272,9 +266,6 @@ nf.ConnectionDetails = (function () {
|
|||
$.ajax({
|
||||
type: 'GET',
|
||||
url: '../nifi-api/remote-process-groups/' + encodeURIComponent(destination.groupId),
|
||||
data: {
|
||||
verbose: true
|
||||
},
|
||||
dataType: 'json'
|
||||
}).done(function (response) {
|
||||
var remoteProcessGroup = response.component;
|
||||
|
@ -320,9 +311,6 @@ nf.ConnectionDetails = (function () {
|
|||
$.ajax({
|
||||
type: 'GET',
|
||||
url: '../nifi-api/process-groups/' + encodeURIComponent(destination.groupId),
|
||||
data: {
|
||||
verbose: true
|
||||
},
|
||||
dataType: 'json'
|
||||
}).done(function (response) {
|
||||
var processGroup = response.component;
|
||||
|
|
|
@ -394,9 +394,6 @@ nf.TemplatesTable = (function () {
|
|||
return $.ajax({
|
||||
type: 'GET',
|
||||
url: config.urls.templates,
|
||||
data: {
|
||||
verbose: false
|
||||
},
|
||||
dataType: 'json'
|
||||
}).done(function (response) {
|
||||
// ensure there are groups specified
|
||||
|
|
Loading…
Reference in New Issue