Repository: incubator-nifi Updated Branches: refs/heads/NIFI-250 c1077baf9 -> 2d4aebf33
NIFI-250: - Continuing to setup Reporting Task management in the UI. Project: http://git-wip-us.apache.org/repos/asf/incubator-nifi/repo Commit: http://git-wip-us.apache.org/repos/asf/incubator-nifi/commit/2d4aebf3 Tree: http://git-wip-us.apache.org/repos/asf/incubator-nifi/tree/2d4aebf3 Diff: http://git-wip-us.apache.org/repos/asf/incubator-nifi/diff/2d4aebf3 Branch: refs/heads/NIFI-250 Commit: 2d4aebf33b50b7603f2c19ba63d368bf125ce498 Parents: c1077ba Author: Matt Gilman <[email protected]> Authored: Fri Feb 20 15:08:39 2015 -0500 Committer: Matt Gilman <[email protected]> Committed: Fri Feb 20 15:08:39 2015 -0500 ---------------------------------------------------------------------- .../nifi/web/api/dto/ReportingTaskDTO.java | 27 +- .../nifi/controller/FlowFromDOMFactory.java | 2 +- .../controller/StandardFlowSynchronizer.java | 14 +- .../apache/nifi/web/api/HistoryResource.java | 31 ++ .../org/apache/nifi/web/api/dto/DtoFactory.java | 60 ++- .../nifi-framework/nifi-web/nifi-web-ui/pom.xml | 2 + .../main/resources/filters/canvas.properties | 1 + .../src/main/webapp/WEB-INF/pages/canvas.jsp | 1 + .../canvas/controller-service-configuration.jsp | 2 +- .../canvas/reporting-task-configuration.jsp | 63 +++ .../nifi-web-ui/src/main/webapp/css/canvas.css | 1 + .../src/main/webapp/css/controller-service.css | 7 - .../src/main/webapp/css/reporting-task.css | 80 ++++ .../src/main/webapp/js/nf/canvas/nf-canvas.js | 1 + .../webapp/js/nf/canvas/nf-reporting-task.js | 426 +++++++++++++++++++ .../src/main/webapp/js/nf/canvas/nf-settings.js | 4 +- 16 files changed, 695 insertions(+), 27 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/incubator-nifi/blob/2d4aebf3/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-client-dto/src/main/java/org/apache/nifi/web/api/dto/ReportingTaskDTO.java ---------------------------------------------------------------------- diff --git a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-client-dto/src/main/java/org/apache/nifi/web/api/dto/ReportingTaskDTO.java b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-client-dto/src/main/java/org/apache/nifi/web/api/dto/ReportingTaskDTO.java index a04e9bb..6a9c7fc 100644 --- a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-client-dto/src/main/java/org/apache/nifi/web/api/dto/ReportingTaskDTO.java +++ b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-client-dto/src/main/java/org/apache/nifi/web/api/dto/ReportingTaskDTO.java @@ -16,6 +16,7 @@ */ package org.apache.nifi.web.api.dto; +import java.util.Collection; import java.util.Map; import javax.xml.bind.annotation.XmlType; @@ -29,7 +30,7 @@ public class ReportingTaskDTO extends NiFiComponentDTO { private String comment; private String type; private String schedulingPeriod; - private String scheduledState; + private String state; private String schedulingStrategy; private String availability; @@ -37,6 +38,8 @@ public class ReportingTaskDTO extends NiFiComponentDTO { private Map<String, PropertyDescriptorDTO> descriptors; private String annotationData; + + private Collection<String> validationErrors; /** * The user-defined name of the reporting task @@ -92,12 +95,12 @@ public class ReportingTaskDTO extends NiFiComponentDTO { * The current scheduling state of the reporting task * @return */ - public String getScheduledState() { - return scheduledState; + public String getState() { + return state; } - public void setScheduledState(String scheduledState) { - this.scheduledState = scheduledState; + public void setState(String state) { + this.state = state; } /** @@ -163,4 +166,18 @@ public class ReportingTaskDTO extends NiFiComponentDTO { this.annotationData = annotationData; } + /** + * Gets the validation errors from this reporting task. These validation errors + * represent the problems with the reporting task that must be resolved before it + * can be scheduled to run. + * + * @return The validation errors + */ + public Collection<String> getValidationErrors() { + return validationErrors; + } + + public void setValidationErrors(Collection<String> validationErrors) { + this.validationErrors = validationErrors; + } } http://git-wip-us.apache.org/repos/asf/incubator-nifi/blob/2d4aebf3/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/main/java/org/apache/nifi/controller/FlowFromDOMFactory.java ---------------------------------------------------------------------- diff --git a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/main/java/org/apache/nifi/controller/FlowFromDOMFactory.java b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/main/java/org/apache/nifi/controller/FlowFromDOMFactory.java index 6e17208..dc10bf0 100644 --- a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/main/java/org/apache/nifi/controller/FlowFromDOMFactory.java +++ b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/main/java/org/apache/nifi/controller/FlowFromDOMFactory.java @@ -105,7 +105,7 @@ public class FlowFromDOMFactory { dto.setComment(getString(element, "comment")); dto.setType(getString(element, "class")); dto.setSchedulingPeriod(getString(element, "schedulingPeriod")); - dto.setScheduledState(getString(element, "scheduledState")); + dto.setState(getString(element, "scheduledState")); dto.setSchedulingStrategy(getString(element, "schedulingStrategy")); dto.setProperties(getProperties(element, encryptor)); http://git-wip-us.apache.org/repos/asf/incubator-nifi/blob/2d4aebf3/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/main/java/org/apache/nifi/controller/StandardFlowSynchronizer.java ---------------------------------------------------------------------- diff --git a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/main/java/org/apache/nifi/controller/StandardFlowSynchronizer.java b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/main/java/org/apache/nifi/controller/StandardFlowSynchronizer.java index 633d58b..f1d169f 100644 --- a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/main/java/org/apache/nifi/controller/StandardFlowSynchronizer.java +++ b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/main/java/org/apache/nifi/controller/StandardFlowSynchronizer.java @@ -417,7 +417,7 @@ public class StandardFlowSynchronizer implements FlowSynchronizer { } if ( autoResumeState ) { - if ( ScheduledState.RUNNING.name().equals(dto.getScheduledState()) ) { + if ( ScheduledState.RUNNING.name().equals(dto.getState()) ) { try { controller.startReportingTask(reportingTask); } catch (final Exception e) { @@ -428,7 +428,7 @@ public class StandardFlowSynchronizer implements FlowSynchronizer { controller.getBulletinRepository().addBulletin(BulletinFactory.createBulletin( "Reporting Tasks", Severity.ERROR.name(), "Failed to start " + reportingTask + " due to " + e)); } - } else if ( ScheduledState.DISABLED.name().equals(dto.getScheduledState()) ) { + } else if ( ScheduledState.DISABLED.name().equals(dto.getState()) ) { try { controller.disableReportingTask(reportingTask); } catch (final Exception e) { @@ -447,9 +447,9 @@ public class StandardFlowSynchronizer implements FlowSynchronizer { final ReportingTaskDTO dto = FlowFromDOMFactory.getReportingTask(reportingTaskElement, encryptor); final ReportingTaskNode taskNode = controller.getReportingTaskNode(dto.getId()); - if (!taskNode.getScheduledState().name().equals(dto.getScheduledState())) { + if (!taskNode.getScheduledState().name().equals(dto.getState())) { try { - switch (ScheduledState.valueOf(dto.getScheduledState())) { + switch (ScheduledState.valueOf(dto.getState())) { case DISABLED: if ( taskNode.isRunning() ) { controller.stopReportingTask(taskNode); @@ -471,16 +471,16 @@ public class StandardFlowSynchronizer implements FlowSynchronizer { break; } } catch (final IllegalStateException ise) { - logger.error("Failed to change Scheduled State of {} from {} to {} due to {}", taskNode, taskNode.getScheduledState().name(), dto.getScheduledState(), ise.toString()); + logger.error("Failed to change Scheduled State of {} from {} to {} due to {}", taskNode, taskNode.getScheduledState().name(), dto.getState(), ise.toString()); logger.error("", ise); // create bulletin for the Processor Node controller.getBulletinRepository().addBulletin(BulletinFactory.createBulletin("Node Reconnection", Severity.ERROR.name(), - "Failed to change Scheduled State of " + taskNode + " from " + taskNode.getScheduledState().name() + " to " + dto.getScheduledState() + " due to " + ise.toString())); + "Failed to change Scheduled State of " + taskNode + " from " + taskNode.getScheduledState().name() + " to " + dto.getState() + " due to " + ise.toString())); // create bulletin at Controller level. controller.getBulletinRepository().addBulletin(BulletinFactory.createBulletin("Node Reconnection", Severity.ERROR.name(), - "Failed to change Scheduled State of " + taskNode + " from " + taskNode.getScheduledState().name() + " to " + dto.getScheduledState() + " due to " + ise.toString())); + "Failed to change Scheduled State of " + taskNode + " from " + taskNode.getScheduledState().name() + " to " + dto.getState() + " due to " + ise.toString())); } } } http://git-wip-us.apache.org/repos/asf/incubator-nifi/blob/2d4aebf3/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/src/main/java/org/apache/nifi/web/api/HistoryResource.java ---------------------------------------------------------------------- diff --git a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/src/main/java/org/apache/nifi/web/api/HistoryResource.java b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/src/main/java/org/apache/nifi/web/api/HistoryResource.java index 934f3a9..0f60f52 100644 --- a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/src/main/java/org/apache/nifi/web/api/HistoryResource.java +++ b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/src/main/java/org/apache/nifi/web/api/HistoryResource.java @@ -294,6 +294,37 @@ public class HistoryResource extends ApplicationResource { return generateOkResponse(entity).build(); } + /** + * Gets the actions for the specified reporting task. + * + * @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 reportingTaskId The id of the reporting task. + * @return An componentHistoryEntity. + */ + @GET + @Produces({MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML}) + @PreAuthorize("hasAnyRole('ROLE_MONITOR', 'ROLE_DFM', 'ROLE_ADMIN')") + @Path("/reporting-tasks/{reportingTaskId}") + @TypeHint(ComponentHistoryEntity.class) + public Response getReportingTaskHistory( + @QueryParam(CLIENT_ID) @DefaultValue(StringUtils.EMPTY) ClientIdParameter clientId, + @PathParam("reportingTaskId") final String reportingTaskId) { + + // create the revision + final RevisionDTO revision = new RevisionDTO(); + revision.setClientId(clientId.getClientId()); + + // create the response entity + final ComponentHistoryEntity entity = new ComponentHistoryEntity(); + entity.setRevision(revision); + entity.setComponentHistory(serviceFacade.getComponentHistory(reportingTaskId)); + + // generate the response + return generateOkResponse(entity).build(); + } + /* setters */ public void setServiceFacade(NiFiServiceFacade serviceFacade) { this.serviceFacade = serviceFacade; http://git-wip-us.apache.org/repos/asf/incubator-nifi/blob/2d4aebf3/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/src/main/java/org/apache/nifi/web/api/dto/DtoFactory.java ---------------------------------------------------------------------- diff --git a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/src/main/java/org/apache/nifi/web/api/dto/DtoFactory.java b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/src/main/java/org/apache/nifi/web/api/dto/DtoFactory.java index cb13247..d425a6c 100644 --- a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/src/main/java/org/apache/nifi/web/api/dto/DtoFactory.java +++ b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/src/main/java/org/apache/nifi/web/api/dto/DtoFactory.java @@ -840,14 +840,66 @@ public final class DtoFactory { public ReportingTaskDTO createReportingTaskDto(final ReportingTaskNode reportingTaskNode) { final ReportingTaskDTO dto = new ReportingTaskDTO(); + dto.setId(reportingTaskNode.getIdentifier()); + dto.setName(reportingTaskNode.getName()); + dto.setType(reportingTaskNode.getReportingTask().getClass().getName()); + dto.setState(reportingTaskNode.getScheduledState().name()); +// dto.setComments(reportingTaskNode.getComments()); + + // sort a copy of the properties + final Map<PropertyDescriptor, String> sortedProperties = new TreeMap<>(new Comparator<PropertyDescriptor>() { + @Override + public int compare(PropertyDescriptor o1, PropertyDescriptor o2) { + return Collator.getInstance(Locale.US).compare(o1.getName(), o2.getName()); + } + }); + sortedProperties.putAll(reportingTaskNode.getProperties()); + + // get the property order from the reporting task + final ReportingTask reportingTask = reportingTaskNode.getReportingTask(); + final Map<PropertyDescriptor, String> orderedProperties = new LinkedHashMap<>(); + final List<PropertyDescriptor> descriptors = reportingTask.getPropertyDescriptors(); + if (descriptors != null && !descriptors.isEmpty()) { + for (PropertyDescriptor descriptor : descriptors) { + orderedProperties.put(descriptor, null); + } + } + orderedProperties.putAll(sortedProperties); + + // build the descriptor and property dtos + dto.setDescriptors(new LinkedHashMap<String, PropertyDescriptorDTO>()); + dto.setProperties(new LinkedHashMap<String, String>()); + for (final Map.Entry<PropertyDescriptor, String> entry : orderedProperties.entrySet()) { + final PropertyDescriptor descriptor = entry.getKey(); + + // store the property descriptor + dto.getDescriptors().put(descriptor.getName(), createPropertyDescriptorDto(descriptor)); + + // determine the property value - don't include sensitive properties + String propertyValue = entry.getValue(); + if (propertyValue != null && descriptor.isSensitive()) { + propertyValue = "********"; + } + + // set the property value + dto.getProperties().put(descriptor.getName(), propertyValue); + } + + // add the validation errors + final Collection<ValidationResult> validationErrors = reportingTaskNode.getValidationErrors(); + if (validationErrors != null && !validationErrors.isEmpty()) { + final List<String> errors = new ArrayList<>(); + for (final ValidationResult validationResult : validationErrors) { + errors.add(validationResult.toString()); + } + + dto.setValidationErrors(errors); + } + return dto; } public ControllerServiceDTO createControllerServiceDto(final ControllerServiceNode controllerServiceNode) { - if (controllerServiceNode == null) { - return null; - } - final ControllerServiceDTO dto = new ControllerServiceDTO(); dto.setId(controllerServiceNode.getIdentifier()); dto.setName(controllerServiceNode.getName()); http://git-wip-us.apache.org/repos/asf/incubator-nifi/blob/2d4aebf3/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/pom.xml ---------------------------------------------------------------------- diff --git a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/pom.xml b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/pom.xml index 68f67a0..a1eb8a0 100644 --- a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/pom.xml +++ b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/pom.xml @@ -268,6 +268,7 @@ <include>${staging.dir}/js/nf/canvas/nf-custom-processor-ui.js</include> <include>${staging.dir}/js/nf/canvas/nf-registration.js</include> <include>${staging.dir}/js/nf/canvas/nf-controller-service.js</include> + <include>${staging.dir}/js/nf/canvas/nf-reporting-task.js</include> <include>${staging.dir}/js/nf/canvas/nf-processor-configuration.js</include> <include>${staging.dir}/js/nf/nf-processor-details.js</include> <include>${staging.dir}/js/nf/canvas/nf-process-group-configuration.js</include> @@ -403,6 +404,7 @@ <insertNewLine>true</insertNewLine> <output>${project.build.directory}/${project.build.finalName}/css/nf-canvas-all.css</output> <includes> + <include>${staging.dir}/css/reporting-task.css</include> <include>${staging.dir}/css/controller-service.css</include> <include>${staging.dir}/css/processor-configuration.css</include> <include>${staging.dir}/css/processor-details.css</include> http://git-wip-us.apache.org/repos/asf/incubator-nifi/blob/2d4aebf3/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/resources/filters/canvas.properties ---------------------------------------------------------------------- diff --git a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/resources/filters/canvas.properties b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/resources/filters/canvas.properties index 6d0d0ef..eae97e0 100644 --- a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/resources/filters/canvas.properties +++ b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/resources/filters/canvas.properties @@ -25,6 +25,7 @@ nf.canvas.script.tags=<script type="text/javascript" src="js/nf/nf-namespace.js? <script type="text/javascript" src="js/nf/canvas/nf-custom-processor-ui.js?${project.version}"></script>\n\ <script type="text/javascript" src="js/nf/canvas/nf-registration.js?${project.version}"></script>\n\ <script type="text/javascript" src="js/nf/canvas/nf-controller-service.js?${project.version}"></script>\n\ +<script type="text/javascript" src="js/nf/canvas/nf-reporting-task.js?${project.version}"></script>\n\ <script type="text/javascript" src="js/nf/canvas/nf-processor-configuration.js?${project.version}"></script>\n\ <script type="text/javascript" src="js/nf/nf-processor-details.js?${project.version}"></script>\n\ <script type="text/javascript" src="js/nf/canvas/nf-process-group-configuration.js?${project.version}"></script>\n\ http://git-wip-us.apache.org/repos/asf/incubator-nifi/blob/2d4aebf3/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/WEB-INF/pages/canvas.jsp ---------------------------------------------------------------------- diff --git a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/WEB-INF/pages/canvas.jsp b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/WEB-INF/pages/canvas.jsp index 77f41bd..c81bb9d 100644 --- a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/WEB-INF/pages/canvas.jsp +++ b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/WEB-INF/pages/canvas.jsp @@ -104,6 +104,7 @@ <jsp:include page="/WEB-INF/partials/canvas/settings-content.jsp"/> <jsp:include page="/WEB-INF/partials/canvas/shell.jsp"/> <jsp:include page="/WEB-INF/partials/canvas/controller-service-configuration.jsp"/> + <jsp:include page="/WEB-INF/partials/canvas/reporting-task-configuration.jsp"/> <jsp:include page="/WEB-INF/partials/canvas/processor-configuration.jsp"/> <jsp:include page="/WEB-INF/partials/processor-details.jsp"/> <jsp:include page="/WEB-INF/partials/canvas/process-group-configuration.jsp"/> http://git-wip-us.apache.org/repos/asf/incubator-nifi/blob/2d4aebf3/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/WEB-INF/partials/canvas/controller-service-configuration.jsp ---------------------------------------------------------------------- diff --git a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/WEB-INF/partials/canvas/controller-service-configuration.jsp b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/WEB-INF/partials/canvas/controller-service-configuration.jsp index 4b4a75c..338a906 100644 --- a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/WEB-INF/partials/canvas/controller-service-configuration.jsp +++ b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/WEB-INF/partials/canvas/controller-service-configuration.jsp @@ -24,7 +24,7 @@ <div class="setting"> <div class="setting-name">Name</div> <div class="setting-field"> - <input type="text" id="controller-service-name" name="controller-service-name"/> + <input type="text" id="controller-service-name" name="controller-service-name" class="setting-input"/> <div class="controller-service-enabled-container"> <div id="controller-service-enabled" class="nf-checkbox checkbox-unchecked"></div> <span> Enabled</span> http://git-wip-us.apache.org/repos/asf/incubator-nifi/blob/2d4aebf3/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/WEB-INF/partials/canvas/reporting-task-configuration.jsp ---------------------------------------------------------------------- diff --git a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/WEB-INF/partials/canvas/reporting-task-configuration.jsp b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/WEB-INF/partials/canvas/reporting-task-configuration.jsp new file mode 100644 index 0000000..c1d816f --- /dev/null +++ b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/WEB-INF/partials/canvas/reporting-task-configuration.jsp @@ -0,0 +1,63 @@ +<%-- + Licensed to the Apache Software Foundation (ASF) under one or more + contributor license agreements. See the NOTICE file distributed with + this work for additional information regarding copyright ownership. + The ASF licenses this file to You under the Apache License, Version 2.0 + (the "License"); you may not use this file except in compliance with + the License. You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +--%> +<%@ page contentType="text/html" pageEncoding="UTF-8" session="false" %> +<div id="reporting-task-configuration"> + <div class="reporting-task-configuration-tab-container"> + <div id="reporting-task-configuration-tabs"></div> + <div id="reporting-task-configuration-tabs-content"> + <div id="reporting-task-standard-settings-tab-content" class="configuration-tab"> + <div class="setting"> + <div class="setting-name">Name</div> + <div class="setting-field"> + <input type="text" id="reporting-task-name" name="reporting-task-name"/> + <div class="reporting-task-enabled-container"> + <div id="reporting-task-enabled" class="nf-checkbox checkbox-unchecked"></div> + <span> Enabled</span> + </div> + </div> + </div> + <div class="setting"> + <div class="setting-name">Id</div> + <div class="setting-field"> + <span id="reporting-task-id"></span> + </div> + </div> + <div class="setting"> + <div class="setting-name">Type</div> + <div class="setting-field"> + <span id="reporting-task-type"></span> + </div> + </div> + <div id="availability-setting-container" class="setting hidden"> + <div class="availability-setting"> + <div class="setting-name"> + Availability + <img class="setting-icon icon-info" src="images/iconInfo.png" alt="Info" title="Where this controller service is available."/> + </div> + <div class="setting-field"> + <div id="availability"></div> + </div> + </div> + <div class="clear"></div> + </div> + </div> + <div id="reporting-task-properties-tab-content" class="configuration-tab"> + <div id="reporting-task-properties"></div> + </div> + </div> + </div> +</div> \ No newline at end of file http://git-wip-us.apache.org/repos/asf/incubator-nifi/blob/2d4aebf3/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/css/canvas.css ---------------------------------------------------------------------- diff --git a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/css/canvas.css b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/css/canvas.css index 7d1852b..a8866ad 100644 --- a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/css/canvas.css +++ b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/css/canvas.css @@ -21,6 +21,7 @@ @import url(process-group-details.css); @import url(remote-process-group-configuration.css); @import url(controller-service.css); +@import url(reporting-task.css); @import url(port-configuration.css); @import url(port-details.css); @import url(label-configuration.css); http://git-wip-us.apache.org/repos/asf/incubator-nifi/blob/2d4aebf3/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/css/controller-service.css ---------------------------------------------------------------------- diff --git a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/css/controller-service.css b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/css/controller-service.css index 54168f1..9ebfbfc 100644 --- a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/css/controller-service.css +++ b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/css/controller-service.css @@ -72,16 +72,9 @@ div.controller-service-configuration-tab-container { #controller-service-configuration .setting-input { font-size: 11px !important; - width: 320px; -} - -#controller-service-configuration .small-setting-input { - font-size: 11px !important; - width: 130px; } #controller-service-name { - font-size: 11px !important; width: 250px; float: left; } http://git-wip-us.apache.org/repos/asf/incubator-nifi/blob/2d4aebf3/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/css/reporting-task.css ---------------------------------------------------------------------- diff --git a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/css/reporting-task.css b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/css/reporting-task.css new file mode 100644 index 0000000..952aebd --- /dev/null +++ b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/css/reporting-task.css @@ -0,0 +1,80 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/* + Reporting task configuration styles. +*/ + +#reporting-task-configuration { + position: absolute; + overflow: hidden; + width: 800px; + height: 450px; + font-size: 10px; + z-index: 1301; + display: none; +} + +div.reporting-task-configuration-tab-container { + margin-top: -10px; + padding: 5px 11px; +} + +#reporting-task-configuration-advanced { + display: none; +} + +#reporting-task-configuration-tabs { + background-color: transparent; + width: 778px; + height: 21px; + border-bottom: 3px solid #666; +} + +#reporting-task-configuration div.configuration-tab { + height: 320px; + overflow: auto; + padding: 10px; + background: #eee url(../images/bgTabContainer.png) repeat-x; + display: none; +} + +/* reporting-task settings */ + +#reporting-task-name { + font-size: 11px !important; + width: 250px; + float: left; +} + +#reporting-task-enabled { + width: 12px; + height: 12px; + float: left; + margin-right: 4px; +} + +div.reporting-task-enabled-container { + float: left; + margin-top: 5px; + margin-left: 10px; +} + +div.availability-setting { + float: left; + width: 140px; +} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/incubator-nifi/blob/2d4aebf3/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/js/nf/canvas/nf-canvas.js ---------------------------------------------------------------------- diff --git a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/js/nf/canvas/nf-canvas.js b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/js/nf/canvas/nf-canvas.js index 31fdf8b..febe6e4 100644 --- a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/js/nf/canvas/nf-canvas.js +++ b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/js/nf/canvas/nf-canvas.js @@ -1033,6 +1033,7 @@ nf.Canvas = (function () { // initialize components nf.ConnectionConfiguration.init(); nf.ControllerService.init(); + nf.ReportingTask.init(); nf.ProcessorConfiguration.init(); nf.ProcessGroupConfiguration.init(); nf.RemoteProcessGroupConfiguration.init(); http://git-wip-us.apache.org/repos/asf/incubator-nifi/blob/2d4aebf3/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/js/nf/canvas/nf-reporting-task.js ---------------------------------------------------------------------- diff --git a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/js/nf/canvas/nf-reporting-task.js b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/js/nf/canvas/nf-reporting-task.js new file mode 100644 index 0000000..b50f7f8 --- /dev/null +++ b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/js/nf/canvas/nf-reporting-task.js @@ -0,0 +1,426 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +nf.ReportingTask = (function () { + + /** + * 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 = nf.Common.formatUnorderedList(errors); + } + + nf.Dialog.showOkDialog({ + dialogContent: content, + overlayBackground: false, + headerText: 'Configuration Error' + }); + } else { + nf.Common.handleAjaxError(xhr, status, error); + } + }; + + /** + * Determines whether the user has made any changes to the reporting task configuration + * that needs to be saved. + */ + var isSaveRequired = function () { + var details = $('#reporting-task-configuration').data('reportingTaskDetails'); + + // determine if any reporting task settings have changed + + if ($('#reporting-task-name').val() !== details.name) { + return true; + } + + if ($('#reporting-task-enabled').hasClass('checkbox-checked')) { + return true; + } + + // defer to the properties + return $('#reporting-task-properties').propertytable('isSaveRequired'); + }; + + /** + * Marshals the data that will be used to update the reporting task's configuration. + */ + var marshalDetails = function () { + // properties + var properties = $('#reporting-task-properties').propertytable('marshalProperties'); + + // create the reporting task dto + var reportingTaskDto = {}; + reportingTaskDto['id'] = $('#reporting-task-id').text(); + reportingTaskDto['name'] = $('#reporting-task-name').val(); + + // set the properties + if ($.isEmptyObject(properties) === false) { + reportingTaskDto['properties'] = properties; + } + + // create the reporting task entity + var reportingTaskEntity = {}; + reportingTaskEntity['revision'] = nf.Client.getRevision(); + reportingTaskEntity['reportingTask'] = reportingTaskDto; + + // return the marshaled details + return reportingTaskEntity; + }; + + /** + * Validates the specified details. + * + * @argument {object} details The details to validate + */ + var validateDetails = function (details) { + return true; + }; + + /** + * Reloads the specified reporting task. + * + * @param {object} reportingTask + */ + var reloadReportingTask = function (reportingTask) { + return $.ajax({ + type: 'GET', + url: reportingTask.uri, + dataType: 'json' + }).done(function (response) { + renderReportingTask(response.reportingTask); + }).fail(nf.Common.handleAjaxError); + }; + + /** + * Renders the specified reporting task. + * + * @param {object} reportingTask + */ + var renderReportingTask = function (reportingTask) { + // get the table and update the row accordingly + var reportingTaskGrid = $('#reporting-tasks-table').data('gridInstance'); + var reportingTaskData = reportingTaskGrid.getData(); + reportingTaskData.updateItem(reportingTask.id, reportingTask); + }; + + /** + * + * @param {object} reportingTask + * @param {boolean} running + */ + var setRunning = function (reportingTask, running) { + var revision = nf.Client.getRevision(); + return $.ajax({ + type: 'PUT', + url: reportingTask.uri, + data: { + clientId: revision.clientId, + version: revision.version, + state: running === true ? 'RUNNING' : 'STOPPED' + }, + dataType: 'json' + }).done(function (response) { + // update the revision + nf.Client.setRevision(response.revision); + + // update the task + renderReportingTask(response.reportingTask); + }).fail(nf.Common.handleAjaxError); + }; + + return { + /** + * Initializes the reporting task configuration dialog. + */ + init: function () { + // initialize the configuration dialog tabs + $('#reporting-task-configuration-tabs').tabbs({ + tabStyle: 'tab', + selectedTabStyle: 'selected-tab', + tabs: [{ + name: 'Settings', + tabContentId: 'reporting-task-standard-settings-tab-content' + }, { + name: 'Properties', + tabContentId: 'reporting-task-properties-tab-content' + }], + select: function () { + // update the property table size in case this is the first time its rendered + if ($(this).text() === 'Properties') { + $('#reporting-task-properties').propertytable('resetTableSize'); + } + + // close all fields currently being edited + $('#reporting-task-properties').propertytable('saveRow'); + } + }); + + // we clustered we need to show the controls for editing the availability + if (nf.Canvas.isClustered()) { + $('#availability-setting-container').show(); + } + + // initialize the reporting task configuration dialog + $('#reporting-task-configuration').modal({ + headerText: 'Configure Reporting Task', + overlayBackground: false, + handler: { + close: function () { + // cancel any active edits + $('#reporting-task-properties').propertytable('cancelEdit'); + + // clear the tables + $('#reporting-task-properties').propertytable('clear'); + + // removed the cached reporting task details + $('#reporting-task-configuration').removeData('reportingTaskDetails'); + } + } + }).draggable({ + containment: 'parent', + handle: '.dialog-header' + }); + + // initialize the property table + $('#reporting-task-properties').propertytable({ + readOnly: false, + newPropertyDialogContainer: 'body' + }); + }, + + /** + * Shows the configuration dialog for the specified reporting task. + * + * @argument {reportingTask} reportingTask The reporting task + */ + showConfiguration: function (reportingTask) { + // reload the task in case the property descriptors have changed + var reloadTask = $.ajax({ + type: 'GET', + url: reportingTask.uri, + dataType: 'json' + }); + + // get the reporting task history + var loadHistory = $.ajax({ + type: 'GET', + url: '../nifi-api/controller/history/reporting-tasks/' + encodeURIComponent(reportingTask.id), + dataType: 'json' + }); + + // once everything is loaded, show the dialog + $.when(reloadTask, loadHistory).done(function (taskResponse, historyResponse) { + // get the updated reporting task + reportingTask = taskResponse[0].reportingTask; + + // get the reporting task history + var reportingTaskHistory = historyResponse[0].componentHistory; + + // record the reporting task details + $('#reporting-task-configuration').data('reportingTaskDetails', reportingTask); + + // populate the reporting task settings + $('#reporting-task-id').text(reportingTask['id']); + $('#reporting-task-type').text(nf.Common.substringAfterLast(reportingTask['type'], '.')); + $('#reporting-task-name').val(reportingTask['name']); + + // select the availability when appropriate + if (nf.Canvas.isClustered()) { + if (reportingTask['availability'] === 'node') { + $('#availability').text('Node'); + } else { + $('#availability').text('Cluster Manager'); + } + } + + var buttons = [{ + buttonText: 'Apply', + handler: { + click: function () { + // close all fields currently being edited + $('#reporting-task-properties').propertytable('saveRow'); + + // marshal the settings and properties and update the reporting task + var updatedReportingTask = marshalDetails(); + + // ensure details are valid as far as we can tell + if (validateDetails(updatedReportingTask)) { + // update the selected component + $.ajax({ + type: 'PUT', + data: JSON.stringify(updatedReportingTask), + url: reportingTask.uri, + dataType: 'json', + processData: false, + contentType: 'application/json' + }).done(function (response) { + if (nf.Common.isDefinedAndNotNull(response.reportingTask)) { + // update the revision + nf.Client.setRevision(response.revision); + + // reload the reporting task + renderReportingTask(response.reportingTask); + + // close the details panel + $('#reporting-task-configuration').modal('hide'); + } + }).fail(handleReportingTaskConfigurationError); + } + } + } + }, { + buttonText: 'Cancel', + handler: { + click: function () { + $('#reporting-task-configuration').modal('hide'); + } + } + }]; + + // determine if we should show the advanced button + if (nf.Common.isDefinedAndNotNull(reportingTask.customUiUrl) && reportingTask.customUiUrl !== '') { + buttons.push({ + buttonText: 'Advanced', + handler: { + click: function () { + var openCustomUi = function () { + // reset state and close the dialog manually to avoid hiding the faded background + $('#reporting-task-configuration').modal('hide'); + + // show the custom ui + nf.CustomProcessorUi.showCustomUi($('#reporting-task-id').text(), reportingTask.customUiUrl, true).done(function () { + // once the custom ui is closed, reload the reporting task + reloadReportingTask(reportingTask); + }); + }; + + // close all fields currently being edited + $('#reporting-task-properties').propertytable('saveRow'); + + // determine if changes have been made + if (isSaveRequired()) { + // see if those changes should be saved + nf.Dialog.showYesNoDialog({ + dialogContent: 'Save changes before opening the advanced configuration?', + overlayBackground: false, + noHandler: openCustomUi, + yesHandler: function () { + // marshal the settings and properties and update the reporting task + var updatedReportingTask = marshalDetails(); + + // ensure details are valid as far as we can tell + if (validateDetails(updatedReportingTask)) { + // update the selected component + $.ajax({ + type: 'PUT', + data: JSON.stringify(updatedReportingTask), + url: reportingTask.uri, + dataType: 'json', + processData: false, + contentType: 'application/json' + }).done(function (response) { + if (nf.Common.isDefinedAndNotNull(response.reportingTask)) { + // update the revision + nf.Client.setRevision(response.revision); + + // open the custom ui + openCustomUi(); + } + }).fail(handleReportingTaskConfigurationError); + } + } + }); + } else { + // if there were no changes, simply open the custom ui + openCustomUi(); + } + } + } + }); + } + + // set the button model + $('#reporting-task-configuration').modal('setButtonModel', buttons); + + // load the property table + $('#reporting-task-properties').propertytable('loadProperties', reportingTask.properties, reportingTask.descriptors, reportingTaskHistory.propertyHistory); + + // show the details + $('#reporting-task-configuration').modal('show'); + }).fail(nf.Common.handleAjaxError); + }, + + showDetails: function(reportingTask) { + + }, + + /** + * Starts the specified reporting task. + * + * @param {object} reportingTask + */ + start: function(reportingTask) { + setRunning(reportingTask, true); + }, + + /** + * Stops the specified reporting task. + * + * @param {object} reportingTask + */ + stop: function(reportingTask) { + setRunning(reportingTask, false); + }, + + /** + * Deletes the specified reporting task. + * + * @param {object} reportingTask + */ + remove: function(reportingTask) { + // prompt for removal? + + var revision = nf.Client.getRevision(); + $.ajax({ + type: 'DELETE', + url: reportingTask.uri + '?' + $.param({ + version: revision.version, + clientId: revision.clientId + }), + dataType: 'json' + }).done(function (response) { + // update the revision + nf.Client.setRevision(response.revision); + + // remove the task + var reportingTaskGrid = $('#reporting-tasks-table').data('gridInstance'); + var reportingTaskData = reportingTaskGrid.getData(); + reportingTaskData.deleteItem(reportingTask.id); + }).fail(nf.Common.handleAjaxError); + } + }; +}()); http://git-wip-us.apache.org/repos/asf/incubator-nifi/blob/2d4aebf3/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/js/nf/canvas/nf-settings.js ---------------------------------------------------------------------- diff --git a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/js/nf/canvas/nf-settings.js b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/js/nf/canvas/nf-settings.js index f4191f7..1fc5498 100644 --- a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/js/nf/canvas/nf-settings.js +++ b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/js/nf/canvas/nf-settings.js @@ -416,7 +416,7 @@ nf.Settings = (function () { // select the new controller service var row = controllerServicesData.getRowById(controllerService.id); controllerServicesGrid.setSelectedRows([row]); - }); + }).fail(nf.Common.handleAjaxError); // hide the dialog $('#new-controller-service-dialog').modal('hide'); @@ -1072,7 +1072,7 @@ nf.Settings = (function () { // select the new reporting task var row = reportingTaskData.getRowById(reportingTask.id); reportingTaskGrid.setSelectedRows([row]); - }); + }).fail(nf.Common.handleAjaxError); // hide the dialog $('#new-reporting-task-dialog').modal('hide');
