[NIFI-3360] taking bottom up approach to modularizing the canvas...wrapping modulaes with UMD and keep the app loading

- taking top down approach from this point and leveraging inversion of control desgin pattern
- This closes #1487
This commit is contained in:
Scott Aslan 2017-02-03 18:09:16 -05:00 committed by Matt Gilman
parent 2e1b87fa43
commit bf3b1640fc
No known key found for this signature in database
GPG Key ID: DF61EC19432AEE37
96 changed files with 9188 additions and 6628 deletions

View File

@ -422,56 +422,57 @@
<insertNewLine>true</insertNewLine>
<output>${project.build.directory}/${project.build.finalName}/js/nf/canvas/nf-canvas-all.js</output>
<includes>
<include>${staging.dir}/js/nf/nf-dialog.js</include>
<include>${staging.dir}/js/nf/nf-ng-bridge.js</include>
<include>${staging.dir}/js/nf/nf-ng-service-provider.js</include>
<include>${staging.dir}/js/nf/nf-cluster-summary.js</include>
<include>${staging.dir}/js/nf/nf-storage.js</include>
<include>${staging.dir}/js/nf/nf-ajax-setup.js</include>
<include>${staging.dir}/js/nf/nf-common.js</include>
<include>${staging.dir}/js/nf/nf-client.js</include>
<include>${staging.dir}/js/nf/nf-error-handler.js</include>
<include>${staging.dir}/js/nf/canvas/nf-context-menu.js</include>
<include>${staging.dir}/js/nf/nf-ng-bridge.js</include>
<include>${staging.dir}/js/nf/nf-cluster-summary.js</include>
<include>${staging.dir}/js/nf/canvas/nf-canvas.js</include>
<include>${staging.dir}/js/nf/canvas/nf-canvas-error-handler.js</include>
<include>${staging.dir}/js/nf/nf-universal-capture.js</include>
<include>${staging.dir}/js/nf/nf-shell.js</include>
<include>${staging.dir}/js/nf/canvas/nf-snippet.js</include>
<include>${staging.dir}/js/nf/canvas/nf-queue-listing.js</include>
<include>${staging.dir}/js/nf/nf-dialog.js</include>
<include>${staging.dir}/js/nf/nf-common.js</include>
<include>${staging.dir}/js/nf/nf-error-handler.js</include>
<include>${staging.dir}/js/nf/canvas/nf-component-state.js</include>
<include>${staging.dir}/js/nf/nf-shell.js</include>
<include>${staging.dir}/js/nf/nf-client.js</include>
<include>${staging.dir}/js/nf/canvas/nf-clipboard.js</include>
<include>${staging.dir}/js/nf/canvas/nf-custom-ui.js</include>
<include>${staging.dir}/js/nf/canvas/nf-controller-service.js</include>
<include>${staging.dir}/js/nf/canvas/nf-controller-services.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>
<include>${staging.dir}/js/nf/canvas/nf-policy-management.js</include>
<include>${staging.dir}/js/nf/canvas/nf-remote-process-group-configuration.js</include>
<include>${staging.dir}/js/nf/canvas/nf-remote-process-group-details.js</include>
<include>${staging.dir}/js/nf/canvas/nf-remote-process-group-ports.js</include>
<include>${staging.dir}/js/nf/canvas/nf-port-configuration.js</include>
<include>${staging.dir}/js/nf/canvas/nf-port-details.js</include>
<include>${staging.dir}/js/nf/canvas/nf-label-configuration.js</include>
<include>${staging.dir}/js/nf/canvas/nf-connection-configuration.js</include>
<include>${staging.dir}/js/nf/nf-connection-details.js</include>
<include>${staging.dir}/js/nf/nf-status-history.js</include>
<include>${staging.dir}/js/nf/canvas/nf-graph.js</include>
<include>${staging.dir}/js/nf/canvas/nf-processor.js</include>
<include>${staging.dir}/js/nf/canvas/nf-canvas-utils.js</include>
<include>${staging.dir}/js/nf/canvas/nf-go-to.js</include>
<include>${staging.dir}/js/nf/canvas/nf-snippet.js</include>
<include>${staging.dir}/js/nf/canvas/nf-connection.js</include>
<include>${staging.dir}/js/nf/canvas/nf-funnel.js</include>
<include>${staging.dir}/js/nf/canvas/nf-label.js</include>
<include>${staging.dir}/js/nf/canvas/nf-port.js</include>
<include>${staging.dir}/js/nf/canvas/nf-process-group.js</include>
<include>${staging.dir}/js/nf/canvas/nf-remote-process-group.js</include>
<include>${staging.dir}/js/nf/canvas/nf-funnel.js</include>
<include>${staging.dir}/js/nf/canvas/nf-connection.js</include>
<include>${staging.dir}/js/nf/canvas/nf-draggable.js</include>
<include>${staging.dir}/js/nf/canvas/nf-connectable.js</include>
<include>${staging.dir}/js/nf/canvas/nf-processor.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-label-configuration.js</include>
<include>${staging.dir}/js/nf/canvas/nf-port-configuration.js</include>
<include>${staging.dir}/js/nf/canvas/nf-port-details.js</include>
<include>${staging.dir}/js/nf/canvas/nf-process-group-configuration.js</include>
<include>${staging.dir}/js/nf/canvas/nf-remote-process-group-configuration.js</include>
<include>${staging.dir}/js/nf/canvas/nf-remote-process-group-details.js</include>
<include>${staging.dir}/js/nf/canvas/nf-remote-process-group-ports.js</include>
<include>${staging.dir}/js/nf/canvas/nf-connection-configuration.js</include>
<include>${staging.dir}/js/nf/nf-connection-details.js</include>
<include>${staging.dir}/js/nf/canvas/nf-context-menu.js</include>
<include>${staging.dir}/js/nf/canvas/nf-selectable.js</include>
<include>${staging.dir}/js/nf/canvas/nf-birdseye.js</include>
<include>${staging.dir}/js/nf/canvas/nf-settings.js</include>
<include>${staging.dir}/js/nf/canvas/nf-go-to.js</include>
<include>${staging.dir}/js/nf/canvas/nf-draggable.js</include>
<include>${staging.dir}/js/nf/canvas/nf-connectable.js</include>
<include>${staging.dir}/js/nf/canvas/nf-graph.js</include>
<include>${staging.dir}/js/nf/nf-status-history.js</include>
<include>${staging.dir}/js/nf/canvas/nf-queue-listing.js</include>
<include>${staging.dir}/js/nf/canvas/nf-policy-management.js</include>
<include>${staging.dir}/js/nf/canvas/nf-actions.js</include>
<include>${staging.dir}/js/nf/canvas/nf-clipboard.js</include>
<include>${staging.dir}/js/nf/nf-ng-service-provider.js</include>
<include>${staging.dir}/js/nf/canvas/nf-canvas.js</include>
<include>${staging.dir}/js/nf/canvas/nf-canvas-error-handler.js</include>
<include>${staging.dir}/js/nf/canvas/nf-controller-service.js</include>
<include>${staging.dir}/js/nf/canvas/nf-controller-services.js</include>
<include>${staging.dir}/js/nf/canvas/nf-reporting-task.js</include>
<include>${staging.dir}/js/nf/canvas/nf-settings.js</include>
<include>${staging.dir}/js/nf/canvas/controllers/nf-ng-breadcrumbs-controller.js</include>
<include>${staging.dir}/js/nf/canvas/controllers/nf-ng-canvas-header-controller.js</include>
<include>${staging.dir}/js/nf/canvas/controllers/nf-ng-canvas-toolbox-controller.js</include>
@ -492,7 +493,7 @@
<include>${staging.dir}/js/nf/canvas/directives/nf-ng-draggable-directive.js</include>
<include>${staging.dir}/js/nf/nf-ng-app-controller.js</include>
<include>${staging.dir}/js/nf/nf-ng-app-config.js</include>
<include>${staging.dir}/js/nf/canvas/nf-canvas-utils.js</include>
<include>${staging.dir}/js/nf/canvas/nf-canvas-bootstrap.js</include>
</includes>
</aggregation>
<aggregation>

View File

@ -13,56 +13,57 @@
# See the License for the specific language governing permissions and
# limitations under the License.
nf.canvas.script.tags=<script type="text/javascript" src="js/nf/nf-dialog.js?${project.version}"></script>\n\
nf.canvas.script.tags=<script type="text/javascript" src="js/nf/nf-ng-bridge.js?${project.version}"></script>\n\
<script type="text/javascript" src="js/nf/nf-ng-service-provider.js?${project.version}"></script>\n\
<script type="text/javascript" src="js/nf/nf-cluster-summary.js?${project.version}"></script>\n\
<script type="text/javascript" src="js/nf/nf-storage.js?${project.version}"></script>\n\
<script type="text/javascript" src="js/nf/nf-ajax-setup.js?${project.version}"></script>\n\
<script type="text/javascript" src="js/nf/nf-common.js?${project.version}"></script>\n\
<script type="text/javascript" src="js/nf/nf-client.js?${project.version}"></script>\n\
<script type="text/javascript" src="js/nf/nf-error-handler.js?${project.version}"></script>\n\
<script type="text/javascript" src="js/nf/canvas/nf-context-menu.js?${project.version}"></script>\n\
<script type="text/javascript" src="js/nf/nf-ng-bridge.js?${project.version}"></script>\n\
<script type="text/javascript" src="js/nf/nf-cluster-summary.js?${project.version}"></script>\n\
<script type="text/javascript" src="js/nf/canvas/nf-canvas.js?${project.version}"></script>\n\
<script type="text/javascript" src="js/nf/canvas/nf-canvas-error-handler.js?${project.version}"></script>\n\
<script type="text/javascript" src="js/nf/nf-universal-capture.js?${project.version}"></script>\n\
<script type="text/javascript" src="js/nf/nf-shell.js?${project.version}"></script>\n\
<script type="text/javascript" src="js/nf/canvas/nf-snippet.js?${project.version}"></script>\n\
<script type="text/javascript" src="js/nf/canvas/nf-queue-listing.js?${project.version}"></script>\n\
<script type="text/javascript" src="js/nf/nf-dialog.js?${project.version}"></script>\n\
<script type="text/javascript" src="js/nf/nf-common.js?${project.version}"></script>\n\
<script type="text/javascript" src="js/nf/nf-error-handler.js?${project.version}"></script>\n\
<script type="text/javascript" src="js/nf/canvas/nf-component-state.js?${project.version}"></script>\n\
<script type="text/javascript" src="js/nf/nf-shell.js?${project.version}"></script>\n\
<script type="text/javascript" src="js/nf/nf-client.js?${project.version}"></script>\n\
<script type="text/javascript" src="js/nf/canvas/nf-clipboard.js?${project.version}"></script>\n\
<script type="text/javascript" src="js/nf/canvas/nf-custom-ui.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-controller-services.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\
<script type="text/javascript" src="js/nf/canvas/nf-policy-management.js?${project.version}"></script>\n\
<script type="text/javascript" src="js/nf/canvas/nf-remote-process-group-configuration.js?${project.version}"></script>\n\
<script type="text/javascript" src="js/nf/canvas/nf-remote-process-group-details.js?${project.version}"></script>\n\
<script type="text/javascript" src="js/nf/canvas/nf-remote-process-group-ports.js?${project.version}"></script>\n\
<script type="text/javascript" src="js/nf/canvas/nf-port-configuration.js?${project.version}"></script>\n\
<script type="text/javascript" src="js/nf/canvas/nf-port-details.js?${project.version}"></script>\n\
<script type="text/javascript" src="js/nf/canvas/nf-label-configuration.js?${project.version}"></script>\n\
<script type="text/javascript" src="js/nf/canvas/nf-connection-configuration.js?${project.version}"></script>\n\
<script type="text/javascript" src="js/nf/nf-connection-details.js?${project.version}"></script>\n\
<script type="text/javascript" src="js/nf/nf-status-history.js?${project.version}"></script>\n\
<script type="text/javascript" src="js/nf/canvas/nf-graph.js?${project.version}"></script>\n\
<script type="text/javascript" src="js/nf/canvas/nf-processor.js?${project.version}"></script>\n\
<script type="text/javascript" src="js/nf/canvas/nf-canvas-utils.js?${project.version}"></script>\n\
<script type="text/javascript" src="js/nf/canvas/nf-go-to.js?${project.version}"></script>\n\
<script type="text/javascript" src="js/nf/canvas/nf-snippet.js?${project.version}"></script>\n\
<script type="text/javascript" src="js/nf/canvas/nf-connection.js?${project.version}"></script>\n\
<script type="text/javascript" src="js/nf/canvas/nf-funnel.js?${project.version}"></script>\n\
<script type="text/javascript" src="js/nf/canvas/nf-label.js?${project.version}"></script>\n\
<script type="text/javascript" src="js/nf/canvas/nf-port.js?${project.version}"></script>\n\
<script type="text/javascript" src="js/nf/canvas/nf-process-group.js?${project.version}"></script>\n\
<script type="text/javascript" src="js/nf/canvas/nf-remote-process-group.js?${project.version}"></script>\n\
<script type="text/javascript" src="js/nf/canvas/nf-funnel.js?${project.version}"></script>\n\
<script type="text/javascript" src="js/nf/canvas/nf-connection.js?${project.version}"></script>\n\
<script type="text/javascript" src="js/nf/canvas/nf-draggable.js?${project.version}"></script>\n\
<script type="text/javascript" src="js/nf/canvas/nf-connectable.js?${project.version}"></script>\n\
<script type="text/javascript" src="js/nf/canvas/nf-processor.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-label-configuration.js?${project.version}"></script>\n\
<script type="text/javascript" src="js/nf/canvas/nf-port-configuration.js?${project.version}"></script>\n\
<script type="text/javascript" src="js/nf/canvas/nf-port-details.js?${project.version}"></script>\n\
<script type="text/javascript" src="js/nf/canvas/nf-process-group-configuration.js?${project.version}"></script>\n\
<script type="text/javascript" src="js/nf/canvas/nf-remote-process-group-configuration.js?${project.version}"></script>\n\
<script type="text/javascript" src="js/nf/canvas/nf-remote-process-group-details.js?${project.version}"></script>\n\
<script type="text/javascript" src="js/nf/canvas/nf-remote-process-group-ports.js?${project.version}"></script>\n\
<script type="text/javascript" src="js/nf/canvas/nf-connection-configuration.js?${project.version}"></script>\n\
<script type="text/javascript" src="js/nf/nf-connection-details.js?${project.version}"></script>\n\
<script type="text/javascript" src="js/nf/canvas/nf-context-menu.js?${project.version}"></script>\n\
<script type="text/javascript" src="js/nf/canvas/nf-selectable.js?${project.version}"></script>\n\
<script type="text/javascript" src="js/nf/canvas/nf-birdseye.js?${project.version}"></script>\n\
<script type="text/javascript" src="js/nf/canvas/nf-settings.js?${project.version}"></script>\n\
<script type="text/javascript" src="js/nf/canvas/nf-go-to.js?${project.version}"></script>\n\
<script type="text/javascript" src="js/nf/canvas/nf-draggable.js?${project.version}"></script>\n\
<script type="text/javascript" src="js/nf/canvas/nf-connectable.js?${project.version}"></script>\n\
<script type="text/javascript" src="js/nf/canvas/nf-graph.js?${project.version}"></script>\n\
<script type="text/javascript" src="js/nf/nf-status-history.js?${project.version}"></script>\n\
<script type="text/javascript" src="js/nf/canvas/nf-queue-listing.js?${project.version}"></script>\n\
<script type="text/javascript" src="js/nf/canvas/nf-policy-management.js?${project.version}"></script>\n\
<script type="text/javascript" src="js/nf/canvas/nf-actions.js?${project.version}"></script>\n\
<script type="text/javascript" src="js/nf/canvas/nf-clipboard.js?${project.version}"></script>\n\
<script type="text/javascript" src="js/nf/nf-ng-service-provider.js?${project.version}"></script>\n\
<script type="text/javascript" src="js/nf/canvas/nf-canvas.js?${project.version}"></script>\n\
<script type="text/javascript" src="js/nf/canvas/nf-canvas-error-handler.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-controller-services.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-settings.js?${project.version}"></script>\n\
<script type="text/javascript" src="js/nf/canvas/controllers/nf-ng-breadcrumbs-controller.js?${project.version}"></script>\n\
<script type="text/javascript" src="js/nf/canvas/controllers/nf-ng-canvas-header-controller.js?${project.version}"></script>\n\
<script type="text/javascript" src="js/nf/canvas/controllers/nf-ng-canvas-toolbox-controller.js?${project.version}"></script>\n\
@ -83,6 +84,6 @@ nf.canvas.script.tags=<script type="text/javascript" src="js/nf/nf-dialog.js?${p
<script type="text/javascript" src="js/nf/canvas/directives/nf-ng-draggable-directive.js?${project.version}"></script>\n\
<script type="text/javascript" src="js/nf/nf-ng-app-controller.js?${project.version}"></script>\n\
<script type="text/javascript" src="js/nf/nf-ng-app-config.js?${project.version}"></script>\n\
<script type="text/javascript" src="js/nf/canvas/nf-canvas-utils.js?${project.version}"></script>
<script type="text/javascript" src="js/nf/canvas/nf-canvas-bootstrap.js?${project.version}"></script>
nf.canvas.style.tags=<link rel="stylesheet" href="css/canvas.css?${project.version}" type="text/css" />\n\
<link rel="stylesheet" href="css/common-ui.css?${project.version}" type="text/css" />

View File

@ -22,56 +22,56 @@
<button title="{{appCtrl.serviceProvider.headerCtrl.toolboxCtrl.config.type.processor}}"
id="processor-component"
class="component-button icon icon-processor"
ng-disabled="!appCtrl.nf.Canvas.canWrite();"
ng-disabled="!appCtrl.nf.CanvasUtils.canWrite();"
nf-draggable="appCtrl.serviceProvider.headerCtrl.toolboxCtrl.draggableComponentConfig(appCtrl.serviceProvider.headerCtrl.toolboxCtrl.processorComponent);">
<span class="component-button-grip"></span>
</button>
<button title="{{appCtrl.serviceProvider.headerCtrl.toolboxCtrl.config.type.inputPort}}"
id="port-in-component"
class="component-button icon icon-port-in"
ng-disabled="!appCtrl.nf.Canvas.canWrite();"
ng-disabled="!appCtrl.nf.CanvasUtils.canWrite();"
nf-draggable="appCtrl.serviceProvider.headerCtrl.toolboxCtrl.draggableComponentConfig(appCtrl.serviceProvider.headerCtrl.toolboxCtrl.inputPortComponent);">
<span class="component-button-grip"></span>
</button>
<button title="{{appCtrl.serviceProvider.headerCtrl.toolboxCtrl.config.type.outputPort}}"
id="port-out-component"
class="component-button icon icon-port-out"
ng-disabled="!appCtrl.nf.Canvas.canWrite();"
ng-disabled="!appCtrl.nf.CanvasUtils.canWrite();"
nf-draggable="appCtrl.serviceProvider.headerCtrl.toolboxCtrl.draggableComponentConfig(appCtrl.serviceProvider.headerCtrl.toolboxCtrl.outputPortComponent);">
<span class="component-button-grip"></span>
</button>
<button title="{{appCtrl.serviceProvider.headerCtrl.toolboxCtrl.config.type.processGroup}}"
id="group-component"
class="component-button icon icon-group"
ng-disabled="!appCtrl.nf.Canvas.canWrite();"
ng-disabled="!appCtrl.nf.CanvasUtils.canWrite();"
nf-draggable="appCtrl.serviceProvider.headerCtrl.toolboxCtrl.draggableComponentConfig(appCtrl.serviceProvider.headerCtrl.toolboxCtrl.groupComponent);">
<span class="component-button-grip"></span>
</button>
<button title="{{appCtrl.serviceProvider.headerCtrl.toolboxCtrl.config.type.remoteProcessGroup}}"
id="group-remote-component"
class="component-button icon icon-group-remote"
ng-disabled="!appCtrl.nf.Canvas.canWrite();"
ng-disabled="!appCtrl.nf.CanvasUtils.canWrite();"
nf-draggable="appCtrl.serviceProvider.headerCtrl.toolboxCtrl.draggableComponentConfig(appCtrl.serviceProvider.headerCtrl.toolboxCtrl.remoteGroupComponent);">
<span class="component-button-grip"></span>
</button>
<button title="{{appCtrl.serviceProvider.headerCtrl.toolboxCtrl.config.type.funnel}}"
id="funnel-component"
class="component-button icon icon-funnel"
ng-disabled="!appCtrl.nf.Canvas.canWrite();"
ng-disabled="!appCtrl.nf.CanvasUtils.canWrite();"
nf-draggable="appCtrl.serviceProvider.headerCtrl.toolboxCtrl.draggableComponentConfig(appCtrl.serviceProvider.headerCtrl.toolboxCtrl.funnelComponent);">
<span class="component-button-grip"></span>
</button>
<button title="{{appCtrl.serviceProvider.headerCtrl.toolboxCtrl.config.type.template}}"
id="template-component"
class="component-button icon icon-template"
ng-disabled="!appCtrl.nf.Canvas.canWrite();"
ng-disabled="!appCtrl.nf.CanvasUtils.canWrite();"
nf-draggable="appCtrl.serviceProvider.headerCtrl.toolboxCtrl.draggableComponentConfig(appCtrl.serviceProvider.headerCtrl.toolboxCtrl.templateComponent);">
<span class="component-button-grip"></span>
</button>
<button title="{{appCtrl.serviceProvider.headerCtrl.toolboxCtrl.config.type.label}}"
id="label-component"
class="component-button icon icon-label"
ng-disabled="!appCtrl.nf.Canvas.canWrite();"
ng-disabled="!appCtrl.nf.CanvasUtils.canWrite();"
nf-draggable="appCtrl.serviceProvider.headerCtrl.toolboxCtrl.draggableComponentConfig(appCtrl.serviceProvider.headerCtrl.toolboxCtrl.labelComponent);">
<span class="component-button-grip"></span>
</button>
@ -146,15 +146,15 @@
<i class="fa fa-history"></i>Flow Configuration History
</a>
</md-menu-item>
<md-menu-divider ng-if="appCtrl.nf.Canvas.isConfigurableAuthorizer()"></md-menu-divider>
<md-menu-item layout-align="space-around center" ng-if="appCtrl.nf.Canvas.isConfigurableAuthorizer()">
<md-menu-divider ng-if="appCtrl.nf.CanvasUtils.isConfigurableAuthorizer()"></md-menu-divider>
<md-menu-item layout-align="space-around center" ng-if="appCtrl.nf.CanvasUtils.isConfigurableAuthorizer()">
<a id="users-link" layout="row"
ng-click="appCtrl.serviceProvider.headerCtrl.globalMenuCtrl.users.shell.launch();"
ng-class="{disabled: !(appCtrl.nf.Common.canAccessTenants())}">
<i class="fa fa-users"></i>Users
</a>
</md-menu-item>
<md-menu-item layout-align="space-around center" ng-if="appCtrl.nf.Canvas.isConfigurableAuthorizer()">
<md-menu-item layout-align="space-around center" ng-if="appCtrl.nf.CanvasUtils.isConfigurableAuthorizer()">
<a id="policies-link" layout="row"
ng-click="appCtrl.serviceProvider.headerCtrl.globalMenuCtrl.policies.shell.launch();"
ng-class="{disabled: !(appCtrl.nf.Common.canAccessTenants() && appCtrl.nf.Common.canModifyPolicies())}">

View File

@ -17,8 +17,8 @@
<%@ page contentType="text/html" pageEncoding="UTF-8" session="false" %>
<nf-breadcrumbs
breadcrumbs="appCtrl.serviceProvider.breadcrumbsCtrl.getBreadcrumbs();"
click-func="appCtrl.nf.CanvasUtils.enterGroup"
highlight-crumb-id="appCtrl.nf.Canvas.getGroupId();"
click-func="appCtrl.nf.CanvasUtils.getComponentByType('ProcessGroup').enterGroup"
highlight-crumb-id="appCtrl.nf.CanvasUtils.getGroupId();"
separator-func="appCtrl.nf.Common.isDefinedAndNotNull">
</nf-breadcrumbs>
<div id="graph-controls">
@ -95,8 +95,8 @@
ng-disabled="!(appCtrl.serviceProvider.graphControlsCtrl.canConfigureOrOpenDetails())">
<div class="graph-control-action-icon fa fa-gear"></div></button>
</div>
<div class="button-spacer-small" ng-if="appCtrl.nf.Canvas.isConfigurableAuthorizer()">&nbsp;</div>
<div id="operate-policy" class="action-button" title="Access Policies" ng-if="appCtrl.nf.Canvas.isConfigurableAuthorizer()">
<div class="button-spacer-small" ng-if="appCtrl.nf.CanvasUtils.isConfigurableAuthorizer()">&nbsp;</div>
<div id="operate-policy" class="action-button" title="Access Policies" ng-if="appCtrl.nf.CanvasUtils.isConfigurableAuthorizer()">
<button ng-click="appCtrl.nf.Actions['managePolicies'](appCtrl.nf.CanvasUtils.getSelection());"
ng-disabled="!(appCtrl.serviceProvider.graphControlsCtrl.canManagePolicies())">
<div class="graph-control-action-icon fa fa-key"></div></button>
@ -128,13 +128,13 @@
<div class="button-spacer-large">&nbsp;</div>
<div id="operate-template" class="action-button" title="Create Template">
<button ng-click="appCtrl.nf.Actions['template'](appCtrl.nf.CanvasUtils.getSelection());"
ng-disabled="!(appCtrl.nf.Canvas.canWrite() && (appCtrl.nf.CanvasUtils.getSelection().empty() || appCtrl.nf.CanvasUtils.canRead(appCtrl.nf.CanvasUtils.getSelection())));">
ng-disabled="!(appCtrl.nf.CanvasUtils.canWrite() && (appCtrl.nf.CanvasUtils.getSelection().empty() || appCtrl.nf.CanvasUtils.canRead(appCtrl.nf.CanvasUtils.getSelection())));">
<div class="graph-control-action-icon icon icon-template-save"></div></button>
</div>
<div class="button-spacer-small">&nbsp;</div>
<div id="operate-template-upload" class="action-button" title="Upload Template">
<button ng-click="appCtrl.nf.Actions['uploadTemplate']();"
ng-disabled="!(appCtrl.nf.Canvas.canWrite() && appCtrl.nf.CanvasUtils.getSelection().empty());">
ng-disabled="!(appCtrl.nf.CanvasUtils.canWrite() && appCtrl.nf.CanvasUtils.getSelection().empty());">
<div class="graph-control-action-icon icon icon-template-import"></div></button>
</div>
<div class="clear"></div>
@ -154,7 +154,7 @@
<div class="button-spacer-large">&nbsp;</div>
<div id="operate-group" class="action-button" title="Group">
<button ng-click="appCtrl.nf.Actions['group'](appCtrl.nf.CanvasUtils.getSelection());"
ng-disabled="!appCtrl.nf.CanvasUtils.isDisconnected(appCtrl.nf.CanvasUtils.getSelection()) || !appCtrl.nf.CanvasUtils.canModify(appCtrl.nf.CanvasUtils.getSelection());">
ng-disabled="!appCtrl.nf.Connection.isDisconnected(appCtrl.nf.CanvasUtils.getSelection()) || !appCtrl.nf.CanvasUtils.canModify(appCtrl.nf.CanvasUtils.getSelection());">
<div class="graph-control-action-icon icon icon-group"></div></button>
</div>
<div class="button-spacer-large">&nbsp;</div>

View File

@ -15,7 +15,7 @@
* limitations under the License.
*/
/* global nf, define, module, require, exports */
/* global define, module, require, exports */
/* requires qtip plugin to be loaded first*/

View File

@ -15,7 +15,7 @@
* limitations under the License.
*/
/* global nf, define, module, require, exports */
/* global define, module, require, exports */
(function (root, factory) {
if (typeof define === 'function' && define.amd) {

View File

@ -15,108 +15,92 @@
* limitations under the License.
*/
/* global nf, d3 */
/* global define, module, require, exports */
nf.ng.BreadcrumbsCtrl = function (serviceProvider) {
(function (root, factory) {
if (typeof define === 'function' && define.amd) {
define(['jquery',
'nf.Common'],
function ($, common) {
return (nf.ng.BreadcrumbsCtrl = factory($, common));
});
} else if (typeof exports === 'object' && typeof module === 'object') {
module.exports = (nf.ng.BreadcrumbsCtrl =
factory(require('jquery'),
require('nf.Common')));
} else {
nf.ng.BreadcrumbsCtrl = factory(root.$,
root.nf.Common);
}
}(this, function ($, common) {
'use strict';
function BreadcrumbsCtrl() {
this.breadcrumbs = [];
}
BreadcrumbsCtrl.prototype = {
constructor: BreadcrumbsCtrl,
return function (serviceProvider) {
'use strict';
/**
* Register the breadcrumbs controller.
*/
register: function() {
if (serviceProvider.breadcrumbsCtrl === undefined) {
serviceProvider.register('breadcrumbsCtrl', breadcrumbsCtrl);
}
},
/**
* Generate the breadcrumbs.
*
* @param {object} breadcrumbEntity The breadcrumb
*/
generateBreadcrumbs: function(breadcrumbEntity) {
var label = breadcrumbEntity.id;
if (breadcrumbEntity.permissions.canRead) {
label = breadcrumbEntity.breadcrumb.name;
}
this.breadcrumbs.unshift($.extend({
'label': label
}, breadcrumbEntity));
if (nf.Common.isDefinedAndNotNull(breadcrumbEntity.parentBreadcrumb)) {
this.generateBreadcrumbs(breadcrumbEntity.parentBreadcrumb);
}
},
/**
* Reset the breadcrumbs.
*/
resetBreadcrumbs: function() {
function BreadcrumbsCtrl() {
this.breadcrumbs = [];
},
}
/**
* Get the breadcrumbs.
*/
getBreadcrumbs: function() {
return this.breadcrumbs;
},
BreadcrumbsCtrl.prototype = {
constructor: BreadcrumbsCtrl,
/**
* Update the breadcrumbs css.
*
* @param {object} style The style to be applied.
*/
updateBreadcrumbsCss: function(style) {
$('#breadcrumbs').css(style);
},
/**
* Register the breadcrumbs controller.
*/
register: function () {
if (serviceProvider.breadcrumbsCtrl === undefined) {
serviceProvider.register('breadcrumbsCtrl', breadcrumbsCtrl);
}
},
/**
* Reset initial scroll position.
*/
resetScrollPosition: function() {
var title = $('#data-flow-title-container');
var titlePosition = title.position();
var titleWidth = title.outerWidth();
var titleRight = titlePosition.left + titleWidth;
var padding = $('#breadcrumbs-right-border').width();
var viewport = $('#data-flow-title-viewport');
var viewportWidth = viewport.width();
var viewportRight = viewportWidth - padding;
// if the title's right is past the viewport's right, shift accordingly
if (titleRight > viewportRight) {
// adjust the position
title.css('left', (titlePosition.left - (titleRight - viewportRight)) + 'px');
} else {
title.css('left', '10px');
}
},
/**
* Registers a scroll event on the `element`
*
* @param {object} element The element event listener will be registered upon.
*/
registerMouseWheelEvent: function(element) {
// mousewheel -> IE, Chrome
// DOMMouseScroll -> FF
// wheel -> FF, IE
// still having issues with this in IE :/
element.on('DOMMouseScroll mousewheel', function (evt, d) {
if (nf.Common.isUndefinedOrNull(evt.originalEvent)) {
return;
/**
* Generate the breadcrumbs.
*
* @param {object} breadcrumbEntity The breadcrumb
*/
generateBreadcrumbs: function (breadcrumbEntity) {
var label = breadcrumbEntity.id;
if (breadcrumbEntity.permissions.canRead) {
label = breadcrumbEntity.breadcrumb.name;
}
this.breadcrumbs.unshift($.extend({
'label': label
}, breadcrumbEntity));
if (common.isDefinedAndNotNull(breadcrumbEntity.parentBreadcrumb)) {
this.generateBreadcrumbs(breadcrumbEntity.parentBreadcrumb);
}
},
/**
* Reset the breadcrumbs.
*/
resetBreadcrumbs: function () {
this.breadcrumbs = [];
},
/**
* Get the breadcrumbs.
*/
getBreadcrumbs: function () {
return this.breadcrumbs;
},
/**
* Update the breadcrumbs css.
*
* @param {object} style The style to be applied.
*/
updateBreadcrumbsCss: function (style) {
$('#breadcrumbs').css(style);
},
/**
* Reset initial scroll position.
*/
resetScrollPosition: function () {
var title = $('#data-flow-title-container');
var titlePosition = title.position();
var titleWidth = title.outerWidth();
@ -127,46 +111,82 @@ nf.ng.BreadcrumbsCtrl = function (serviceProvider) {
var viewportWidth = viewport.width();
var viewportRight = viewportWidth - padding;
// if the width of the title is larger than the viewport
if (titleWidth > viewportWidth) {
var adjust = false;
// if the title's right is past the viewport's right, shift accordingly
if (titleRight > viewportRight) {
// adjust the position
title.css('left', (titlePosition.left - (titleRight - viewportRight)) + 'px');
} else {
title.css('left', '10px');
}
},
var delta = 0;
/**
* Registers a scroll event on the `element`
*
* @param {object} element The element event listener will be registered upon.
*/
registerMouseWheelEvent: function (element) {
// mousewheel -> IE, Chrome
// DOMMouseScroll -> FF
// wheel -> FF, IE
//Chrome and Safari both have evt.originalEvent.detail defined but
//evt.originalEvent.wheelDelta holds the correct value so we must
//check for evt.originalEvent.wheelDelta first!
if (nf.Common.isDefinedAndNotNull(evt.originalEvent.wheelDelta)) {
delta = evt.originalEvent.wheelDelta;
} else if (nf.Common.isDefinedAndNotNull(evt.originalEvent.detail)) {
delta = -evt.originalEvent.detail;
// still having issues with this in IE :/
element.on('DOMMouseScroll mousewheel', function (evt, d) {
if (common.isUndefinedOrNull(evt.originalEvent)) {
return;
}
// determine the increment
if (delta > 0 && titleRight > viewportRight) {
var increment = -25;
adjust = true;
} else if (delta < 0 && (titlePosition.left - padding) < 0) {
increment = 25;
var title = $('#data-flow-title-container');
var titlePosition = title.position();
var titleWidth = title.outerWidth();
var titleRight = titlePosition.left + titleWidth;
// don't shift too far
if (titlePosition.left + increment > padding) {
increment = padding - titlePosition.left;
var padding = $('#breadcrumbs-right-border').width();
var viewport = $('#data-flow-title-viewport');
var viewportWidth = viewport.width();
var viewportRight = viewportWidth - padding;
// if the width of the title is larger than the viewport
if (titleWidth > viewportWidth) {
var adjust = false;
var delta = 0;
//Chrome and Safari both have evt.originalEvent.detail defined but
//evt.originalEvent.wheelDelta holds the correct value so we must
//check for evt.originalEvent.wheelDelta first!
if (common.isDefinedAndNotNull(evt.originalEvent.wheelDelta)) {
delta = evt.originalEvent.wheelDelta;
} else if (common.isDefinedAndNotNull(evt.originalEvent.detail)) {
delta = -evt.originalEvent.detail;
}
adjust = true;
}
// determine the increment
if (delta > 0 && titleRight > viewportRight) {
var increment = -25;
adjust = true;
} else if (delta < 0 && (titlePosition.left - padding) < 0) {
increment = 25;
if (adjust) {
// adjust the position
title.css('left', (titlePosition.left + increment) + 'px');
// don't shift too far
if (titlePosition.left + increment > padding) {
increment = padding - titlePosition.left;
}
adjust = true;
}
if (adjust) {
// adjust the position
title.css('left', (titlePosition.left + increment) + 'px');
}
}
}
});
});
}
}
}
var breadcrumbsCtrl = new BreadcrumbsCtrl();
breadcrumbsCtrl.register();
return breadcrumbsCtrl;
};
var breadcrumbsCtrl = new BreadcrumbsCtrl();
breadcrumbsCtrl.register();
return breadcrumbsCtrl;
}
}));

View File

@ -15,469 +15,506 @@
* limitations under the License.
*/
/* global nf, d3 */
/* global define, module, require, exports */
nf.ng.Canvas.FlowStatusCtrl = function (serviceProvider) {
(function (root, factory) {
if (typeof define === 'function' && define.amd) {
define(['jquery',
'nf.Common',
'nf.Dialog',
'nf.CanvasUtils',
'nf.ContextMenu',
'nf.ClusterSummary',
'nf.ErrorHandler',
'nf.Settings'],
function ($, common, dialog, canvasUtils, contextMenu, clusterSummary, errorHandler, settings) {
return (nf.ng.Canvas.FlowStatusCtrl = factory($, common, dialog, canvasUtils, contextMenu, clusterSummary, errorHandler, settings));
});
} else if (typeof exports === 'object' && typeof module === 'object') {
module.exports = (nf.ng.Canvas.FlowStatusCtrl =
factory(require('jquery'),
require('nf.Common'),
require('nf.Dialog'),
require('nf.CanvasUtils'),
require('nf.ContextMenu'),
require('nf.ClusterSummary'),
require('nf.ErrorHandler'),
require('nf.Settings')));
} else {
nf.ng.Canvas.FlowStatusCtrl = factory(root.$,
root.nf.Common,
root.nf.Dialog,
root.nf.CanvasUtils,
root.nf.ContextMenu,
root.nf.ClusterSummary,
root.nf.ErrorHandler,
root.nf.Settings);
}
}(this, function ($, common, dialog, canvasUtils, contextMenu, clusterSummary, errorHandler, settings) {
'use strict';
var config = {
search: 'Search',
urls: {
search: '../nifi-api/flow/search-results',
status: '../nifi-api/flow/status'
}
};
return function (serviceProvider) {
'use strict';
function FlowStatusCtrl() {
this.connectedNodesCount = "-";
this.activeThreadCount = "-";
this.totalQueued = "-";
this.controllerTransmittingCount = "-";
this.controllerNotTransmittingCount = "-";
this.controllerRunningCount = "-";
this.controllerStoppedCount = "-";
this.controllerInvalidCount = "-";
this.controllerDisabledCount = "-";
this.statsLastRefreshed = "-";
var config = {
search: 'Search',
urls: {
search: '../nifi-api/flow/search-results',
status: '../nifi-api/flow/status'
}
};
/**
* The search controller.
*/
this.search = {
function FlowStatusCtrl() {
this.connectedNodesCount = "-";
this.activeThreadCount = "-";
this.totalQueued = "-";
this.controllerTransmittingCount = "-";
this.controllerNotTransmittingCount = "-";
this.controllerRunningCount = "-";
this.controllerStoppedCount = "-";
this.controllerInvalidCount = "-";
this.controllerDisabledCount = "-";
this.statsLastRefreshed = "-";
/**
* Get the search input element.
* The search controller.
*/
getInputElement: function () {
return $('#search-field');
},
this.search = {
/**
* Get the search button element.
*/
getButtonElement: function () {
return $('#search-button');
},
/**
* Get the search input element.
*/
getInputElement: function () {
return $('#search-field');
},
/**
* Get the search container element.
*/
getSearchContainerElement: function () {
return $('#search-container');
},
/**
* Get the search button element.
*/
getButtonElement: function () {
return $('#search-button');
},
/**
* Initialize the search controller.
*/
init: function () {
/**
* Get the search container element.
*/
getSearchContainerElement: function () {
return $('#search-container');
},
var searchCtrl = this;
/**
* Initialize the search controller.
*/
init: function () {
// Create new jQuery UI widget
$.widget('nf.searchAutocomplete', $.ui.autocomplete, {
reset: function () {
this.term = null;
},
_create: function() {
this._super();
this.widget().menu('option', 'items', '> :not(.search-header, .search-no-matches)' );
},
_resizeMenu: function () {
var ul = this.menu.element;
ul.width(400);
},
_normalize: function (searchResults) {
var items = [];
items.push(searchResults);
return items;
},
_renderMenu: function (ul, items) {
var nfSearchAutocomplete = this;
var searchCtrl = this;
// the object that holds the search results is normalized into a single element array
var searchResults = items[0];
// Create new jQuery UI widget
$.widget('nf.searchAutocomplete', $.ui.autocomplete, {
reset: function () {
this.term = null;
},
_create: function () {
this._super();
this.widget().menu('option', 'items', '> :not(.search-header, .search-no-matches)');
},
_resizeMenu: function () {
var ul = this.menu.element;
ul.width(400);
},
_normalize: function (searchResults) {
var items = [];
items.push(searchResults);
return items;
},
_renderMenu: function (ul, items) {
var nfSearchAutocomplete = this;
// show all processors
if (!nf.Common.isEmpty(searchResults.processorResults)) {
ul.append('<li class="search-header"><div class="search-result-icon icon icon-processor"></div>Processors</li>');
$.each(searchResults.processorResults, function (i, processorMatch) {
nfSearchAutocomplete._renderItem(ul, processorMatch);
// the object that holds the search results is normalized into a single element array
var searchResults = items[0];
// show all processors
if (!common.isEmpty(searchResults.processorResults)) {
ul.append('<li class="search-header"><div class="search-result-icon icon icon-processor"></div>Processors</li>');
$.each(searchResults.processorResults, function (i, processorMatch) {
nfSearchAutocomplete._renderItem(ul, processorMatch);
});
}
// show all process groups
if (!common.isEmpty(searchResults.processGroupResults)) {
ul.append('<li class="search-header"><div class="search-result-icon icon icon-group"></div>Process Groups</li>');
$.each(searchResults.processGroupResults, function (i, processGroupMatch) {
nfSearchAutocomplete._renderItem(ul, processGroupMatch);
});
}
// show all remote process groups
if (!common.isEmpty(searchResults.remoteProcessGroupResults)) {
ul.append('<li class="search-header"><div class="search-result-icon icon icon-group-remote"></div>Remote Process Groups</li>');
$.each(searchResults.remoteProcessGroupResults, function (i, remoteProcessGroupMatch) {
nfSearchAutocomplete._renderItem(ul, remoteProcessGroupMatch);
});
}
// show all connections
if (!common.isEmpty(searchResults.connectionResults)) {
ul.append('<li class="search-header"><div class="search-result-icon icon icon-connect"></div>Connections</li>');
$.each(searchResults.connectionResults, function (i, connectionMatch) {
nfSearchAutocomplete._renderItem(ul, connectionMatch);
});
}
// show all input ports
if (!common.isEmpty(searchResults.inputPortResults)) {
ul.append('<li class="search-header"><div class="search-result-icon icon icon-port-in"></div>Input Ports</li>');
$.each(searchResults.inputPortResults, function (i, inputPortMatch) {
nfSearchAutocomplete._renderItem(ul, inputPortMatch);
});
}
// show all output ports
if (!common.isEmpty(searchResults.outputPortResults)) {
ul.append('<li class="search-header"><div class="search-result-icon icon icon-port-out"></div>Output Ports</li>');
$.each(searchResults.outputPortResults, function (i, outputPortMatch) {
nfSearchAutocomplete._renderItem(ul, outputPortMatch);
});
}
// show all funnels
if (!common.isEmpty(searchResults.funnelResults)) {
ul.append('<li class="search-header"><div class="search-result-icon icon icon-funnel"></div>Funnels</li>');
$.each(searchResults.funnelResults, function (i, funnelMatch) {
nfSearchAutocomplete._renderItem(ul, funnelMatch);
});
}
// ensure there were some results
if (ul.children().length === 0) {
ul.append('<li class="unset search-no-matches">No results matched the search terms</li>');
}
},
_renderItem: function (ul, match) {
var itemContent = $('<a></a>').append($('<div class="search-match-header"></div>').text(match.name));
$.each(match.matches, function (i, match) {
itemContent.append($('<div class="search-match"></div>').text(match));
});
return $('<li></li>').data('ui-autocomplete-item', match).append(itemContent).appendTo(ul);
}
});
// show all process groups
if (!nf.Common.isEmpty(searchResults.processGroupResults)) {
ul.append('<li class="search-header"><div class="search-result-icon icon icon-group"></div>Process Groups</li>');
$.each(searchResults.processGroupResults, function (i, processGroupMatch) {
nfSearchAutocomplete._renderItem(ul, processGroupMatch);
// configure the new searchAutocomplete jQuery UI widget
this.getInputElement().searchAutocomplete({
appendTo: '#search-flow-results',
position: {
my: 'right top',
at: 'right bottom',
offset: '1 1'
},
source: function (request, response) {
// create the search request
$.ajax({
type: 'GET',
data: {
q: request.term
},
dataType: 'json',
url: config.urls.search
}).done(function (searchResponse) {
response(searchResponse.searchResultsDTO);
});
},
select: function (event, ui) {
var item = ui.item;
// show the selected component
canvasUtils.showComponent(item.groupId, item.id);
searchCtrl.getInputElement().val('').blur();
// stop event propagation
return false;
},
open: function (event, ui) {
// show the glass pane
var searchField = $(this);
$('<div class="search-glass-pane"></div>').one('click', function () {
}).appendTo('body');
},
close: function (event, ui) {
// set the input text to '' and reset the cached term
$(this).searchAutocomplete('reset');
searchCtrl.getInputElement().val('');
// remove the glass pane
$('div.search-glass-pane').remove();
}
});
// show all remote process groups
if (!nf.Common.isEmpty(searchResults.remoteProcessGroupResults)) {
ul.append('<li class="search-header"><div class="search-result-icon icon icon-group-remote"></div>Remote Process Groups</li>');
$.each(searchResults.remoteProcessGroupResults, function (i, remoteProcessGroupMatch) {
nfSearchAutocomplete._renderItem(ul, remoteProcessGroupMatch);
});
}
// hide the search input
searchCtrl.toggleSearchField();
},
// show all connections
if (!nf.Common.isEmpty(searchResults.connectionResults)) {
ul.append('<li class="search-header"><div class="search-result-icon icon icon-connect"></div>Connections</li>');
$.each(searchResults.connectionResults, function (i, connectionMatch) {
nfSearchAutocomplete._renderItem(ul, connectionMatch);
});
}
/**
* Toggle/Slide the search field open/closed.
*/
toggleSearchField: function () {
var searchCtrl = this;
// show all input ports
if (!nf.Common.isEmpty(searchResults.inputPortResults)) {
ul.append('<li class="search-header"><div class="search-result-icon icon icon-port-in"></div>Input Ports</li>');
$.each(searchResults.inputPortResults, function (i, inputPortMatch) {
nfSearchAutocomplete._renderItem(ul, inputPortMatch);
});
}
// hide the context menu if necessary
contextMenu.hide();
// show all output ports
if (!nf.Common.isEmpty(searchResults.outputPortResults)) {
ul.append('<li class="search-header"><div class="search-result-icon icon icon-port-out"></div>Output Ports</li>');
$.each(searchResults.outputPortResults, function (i, outputPortMatch) {
nfSearchAutocomplete._renderItem(ul, outputPortMatch);
});
}
// show all funnels
if (!nf.Common.isEmpty(searchResults.funnelResults)) {
ul.append('<li class="search-header"><div class="search-result-icon icon icon-funnel"></div>Funnels</li>');
$.each(searchResults.funnelResults, function (i, funnelMatch) {
nfSearchAutocomplete._renderItem(ul, funnelMatch);
});
}
// ensure there were some results
if (ul.children().length === 0) {
ul.append('<li class="unset search-no-matches">No results matched the search terms</li>');
}
},
_renderItem: function (ul, match) {
var itemContent = $('<a></a>').append($('<div class="search-match-header"></div>').text(match.name));
$.each(match.matches, function (i, match) {
itemContent.append($('<div class="search-match"></div>').text(match));
});
return $('<li></li>').data('ui-autocomplete-item', match).append(itemContent).appendTo(ul);
}
});
// configure the new searchAutocomplete jQuery UI widget
this.getInputElement().searchAutocomplete({
appendTo: '#search-flow-results',
position: {
my: 'right top',
at: 'right bottom',
offset: '1 1'
},
source: function (request, response) {
// create the search request
$.ajax({
type: 'GET',
data: {
q: request.term
},
dataType: 'json',
url: config.urls.search
}).done(function (searchResponse) {
response(searchResponse.searchResultsDTO);
});
},
select: function (event, ui) {
var item = ui.item;
// show the selected component
nf.CanvasUtils.showComponent(item.groupId, item.id);
searchCtrl.getInputElement().val('').blur();
// stop event propagation
return false;
},
open: function (event, ui) {
// show the glass pane
var searchField = $(this);
$('<div class="search-glass-pane"></div>').one('click', function () {
}).appendTo('body');
},
close: function (event, ui) {
// set the input text to '' and reset the cached term
$(this).searchAutocomplete('reset');
searchCtrl.getInputElement().val('');
// remove the glass pane
$('div.search-glass-pane').remove();
}
});
// hide the search input
searchCtrl.toggleSearchField();
},
/**
* Toggle/Slide the search field open/closed.
*/
toggleSearchField: function () {
var searchCtrl = this;
// hide the context menu if necessary
nf.ContextMenu.hide();
var isVisible = searchCtrl.getInputElement().is(':visible');
var display = 'none';
var class1 = 'search-container-opened';
var class2 = 'search-container-closed';
if (!isVisible) {
searchCtrl.getButtonElement().css('background-color', '#FFFFFF');
display = 'inline-block';
class1 = 'search-container-closed';
class2 = 'search-container-opened';
} else {
searchCtrl.getInputElement().css('display', display);
}
this.getSearchContainerElement().switchClass(class1, class2, 500, function () {
searchCtrl.getInputElement().css('display', display);
var isVisible = searchCtrl.getInputElement().is(':visible');
var display = 'none';
var class1 = 'search-container-opened';
var class2 = 'search-container-closed';
if (!isVisible) {
searchCtrl.getButtonElement().css('background-color', '#FFFFFF');
searchCtrl.getInputElement().focus();
display = 'inline-block';
class1 = 'search-container-closed';
class2 = 'search-container-opened';
} else {
searchCtrl.getButtonElement().css('background-color', '#E3E8EB');
searchCtrl.getInputElement().css('display', display);
}
});
}
}
/**
* The bulletins controller.
*/
this.bulletins = {
this.getSearchContainerElement().switchClass(class1, class2, 500, function () {
searchCtrl.getInputElement().css('display', display);
if (!isVisible) {
searchCtrl.getButtonElement().css('background-color', '#FFFFFF');
searchCtrl.getInputElement().focus();
} else {
searchCtrl.getButtonElement().css('background-color', '#E3E8EB');
}
});
}
}
/**
* Update the bulletins.
*
* @param response The controller bulletins returned from the `../nifi-api/controller/bulletins` endpoint.
* The bulletins controller.
*/
update: function (response) {
this.bulletins = {
// icon for system bulletins
var bulletinIcon = $('#bulletin-button');
var currentBulletins = bulletinIcon.data('bulletins');
/**
* Update the bulletins.
*
* @param response The controller bulletins returned from the `../nifi-api/controller/bulletins` endpoint.
*/
update: function (response) {
// update the bulletins if necessary
if (nf.Common.doBulletinsDiffer(currentBulletins, response.bulletins)) {
bulletinIcon.data('bulletins', response.bulletins);
// icon for system bulletins
var bulletinIcon = $('#bulletin-button');
var currentBulletins = bulletinIcon.data('bulletins');
// get the formatted the bulletins
var bulletins = nf.Common.getFormattedBulletins(response.bulletins);
// update the bulletins if necessary
if (common.doBulletinsDiffer(currentBulletins, response.bulletins)) {
bulletinIcon.data('bulletins', response.bulletins);
// bulletins for this processor are now gone
if (bulletins.length === 0) {
if (bulletinIcon.data('qtip')) {
bulletinIcon.removeClass('has-bulletins').qtip('api').destroy(true);
}
} else {
var newBulletins = nf.Common.formatUnorderedList(bulletins);
// get the formatted the bulletins
var bulletins = common.getFormattedBulletins(response.bulletins);
// different bulletins, refresh
if (bulletinIcon.data('qtip')) {
bulletinIcon.qtip('option', 'content.text', newBulletins);
// bulletins for this processor are now gone
if (bulletins.length === 0) {
if (bulletinIcon.data('qtip')) {
bulletinIcon.removeClass('has-bulletins').qtip('api').destroy(true);
}
} else {
// no bulletins before, show icon and tips
bulletinIcon.addClass('has-bulletins').qtip($.extend({},
nf.CanvasUtils.config.systemTooltipConfig,
{
content: newBulletins,
position: {
at: 'bottom left',
my: 'top right',
adjust: {
x: 4
var newBulletins = common.formatUnorderedList(bulletins);
// different bulletins, refresh
if (bulletinIcon.data('qtip')) {
bulletinIcon.qtip('option', 'content.text', newBulletins);
} else {
// no bulletins before, show icon and tips
bulletinIcon.addClass('has-bulletins').qtip($.extend({},
canvasUtils.config.systemTooltipConfig,
{
content: newBulletins,
position: {
at: 'bottom left',
my: 'top right',
adjust: {
x: 4
}
}
}
}
));
));
}
}
}
// update controller service and reporting task bulletins
settings.setBulletins(response.controllerServiceBulletins, response.reportingTaskBulletins);
}
// update controller service and reporting task bulletins
nf.Settings.setBulletins(response.controllerServiceBulletins, response.reportingTaskBulletins);
}
}
}
FlowStatusCtrl.prototype = {
constructor: FlowStatusCtrl,
FlowStatusCtrl.prototype = {
constructor: FlowStatusCtrl,
/**
* Initialize the flow status controller.
*/
init: function () {
this.search.init();
},
/**
* Initialize the flow status controller.
*/
init: function () {
this.search.init();
},
/**
* Reloads the current status of the flow.
*/
reloadFlowStatus: function () {
var flowStatusCtrl = this;
/**
* Reloads the current status of the flow.
*/
reloadFlowStatus: function () {
var flowStatusCtrl = this;
return $.ajax({
type: 'GET',
url: config.urls.status,
dataType: 'json'
}).done(function (response) {
// report the updated status
if (nf.Common.isDefinedAndNotNull(response.controllerStatus)) {
flowStatusCtrl.update(response.controllerStatus);
}
}).fail(nf.ErrorHandler.handleAjaxError);
},
return $.ajax({
type: 'GET',
url: config.urls.status,
dataType: 'json'
}).done(function (response) {
// report the updated status
if (common.isDefinedAndNotNull(response.controllerStatus)) {
flowStatusCtrl.update(response.controllerStatus);
}
}).fail(errorHandler.handleAjaxError);
},
/**
* Updates the cluster summary.
*
* @param clusterSummary
*/
updateClusterSummary: function (clusterSummary) {
// see if this node has been (dis)connected
if (nf.ClusterSummary.isConnectedToCluster() !== clusterSummary.connectedToCluster) {
if (clusterSummary.connectedToCluster) {
nf.Dialog.showConnectedToClusterMessage();
} else {
nf.Dialog.showDisconnectedFromClusterMessage();
}
}
var color = '#728E9B';
// update the connection state
if (clusterSummary.connectedToCluster) {
if (nf.Common.isDefinedAndNotNull(clusterSummary.connectedNodes)) {
var connectedNodes = clusterSummary.connectedNodes.split(' / ');
if (connectedNodes.length === 2 && connectedNodes[0] !== connectedNodes[1]) {
this.clusterConnectionWarning = true;
color = '#BA554A';
/**
* Updates the cluster summary.
*
* @param summary
*/
updateClusterSummary: function (summary) {
// see if this node has been (dis)connected
if (clusterSummary.isConnectedToCluster() !== summary.connectedToCluster) {
if (summary.connectedToCluster) {
dialog.showConnectedToClusterMessage();
} else {
dialog.showDisconnectedFromClusterMessage();
}
}
this.connectedNodesCount =
nf.Common.isDefinedAndNotNull(clusterSummary.connectedNodes) ? clusterSummary.connectedNodes : '-';
} else {
this.connectedNodesCount = 'Disconnected';
color = '#BA554A';
var color = '#728E9B';
// update the connection state
if (summary.connectedToCluster) {
if (common.isDefinedAndNotNull(summary.connectedNodes)) {
var connectedNodes = summary.connectedNodes.split(' / ');
if (connectedNodes.length === 2 && connectedNodes[0] !== connectedNodes[1]) {
this.clusterConnectionWarning = true;
color = '#BA554A';
}
}
this.connectedNodesCount =
common.isDefinedAndNotNull(summary.connectedNodes) ? summary.connectedNodes : '-';
} else {
this.connectedNodesCount = 'Disconnected';
color = '#BA554A';
}
// update the color
$('#connected-nodes-count').closest('div.fa-cubes').css('color', color);
},
/**
* Update the flow status counts.
*
* @param status The controller status returned from the `../nifi-api/flow/status` endpoint.
*/
update: function (status) {
var controllerInvalidCount = (common.isDefinedAndNotNull(status.invalidCount)) ? status.invalidCount : 0;
if (this.controllerInvalidCount > 0) {
$('#controller-invalid-count').parent().removeClass('zero').addClass('invalid');
} else {
$('#controller-invalid-count').parent().removeClass('invalid').addClass('zero');
}
// update the report values
this.activeThreadCount = status.activeThreadCount;
if (this.activeThreadCount > 0) {
$('#flow-status-container').find('.icon-threads').removeClass('zero');
} else {
$('#flow-status-container').find('.icon-threads').addClass('zero');
}
this.totalQueued = status.queued;
if (this.totalQueued.indexOf('0 / 0') >= 0) {
$('#flow-status-container').find('.fa-list').addClass('zero');
} else {
$('#flow-status-container').find('.fa-list').removeClass('zero');
}
// update the component counts
this.controllerTransmittingCount =
common.isDefinedAndNotNull(status.activeRemotePortCount) ?
status.activeRemotePortCount : '-';
if (this.controllerTransmittingCount > 0) {
$('#flow-status-container').find('.fa-bullseye').removeClass('zero').addClass('transmitting');
} else {
$('#flow-status-container').find('.fa-bullseye').removeClass('transmitting').addClass('zero');
}
this.controllerNotTransmittingCount =
common.isDefinedAndNotNull(status.inactiveRemotePortCount) ?
status.inactiveRemotePortCount : '-';
if (this.controllerNotTransmittingCount > 0) {
$('#flow-status-container').find('.icon-transmit-false').removeClass('zero').addClass('not-transmitting');
} else {
$('#flow-status-container').find('.icon-transmit-false').removeClass('not-transmitting').addClass('zero');
}
this.controllerRunningCount =
common.isDefinedAndNotNull(status.runningCount) ? status.runningCount : '-';
if (this.controllerRunningCount > 0) {
$('#flow-status-container').find('.fa-play').removeClass('zero').addClass('running');
} else {
$('#flow-status-container').find('.fa-play').removeClass('running').addClass('zero');
}
this.controllerStoppedCount =
common.isDefinedAndNotNull(status.stoppedCount) ? status.stoppedCount : '-';
if (this.controllerStoppedCount > 0) {
$('#flow-status-container').find('.fa-stop').removeClass('zero').addClass('stopped');
} else {
$('#flow-status-container').find('.fa-stop').removeClass('stopped').addClass('zero');
}
this.controllerInvalidCount =
common.isDefinedAndNotNull(status.invalidCount) ? status.invalidCount : '-';
if (this.controllerInvalidCount > 0) {
$('#flow-status-container').find('.fa-warning').removeClass('zero').addClass('invalid');
} else {
$('#flow-status-container').find('.fa-warning').removeClass('invalid').addClass('zero');
}
this.controllerDisabledCount =
common.isDefinedAndNotNull(status.disabledCount) ? status.disabledCount : '-';
if (this.controllerDisabledCount > 0) {
$('#flow-status-container').find('.icon-enable-false').removeClass('zero').addClass('disabled');
} else {
$('#flow-status-container').find('.icon-enable-false').removeClass('disabled').addClass('zero');
}
},
/**
* Updates the controller level bulletins
*
* @param response
*/
updateBulletins: function (response) {
this.bulletins.update(response);
}
// update the color
$('#connected-nodes-count').closest('div.fa-cubes').css('color', color);
},
/**
* Update the flow status counts.
*
* @param status The controller status returned from the `../nifi-api/flow/status` endpoint.
*/
update: function (status) {
var controllerInvalidCount = (nf.Common.isDefinedAndNotNull(status.invalidCount)) ? status.invalidCount : 0;
if (this.controllerInvalidCount > 0) {
$('#controller-invalid-count').parent().removeClass('zero').addClass('invalid');
} else {
$('#controller-invalid-count').parent().removeClass('invalid').addClass('zero');
}
// update the report values
this.activeThreadCount = status.activeThreadCount;
if (this.activeThreadCount > 0) {
$('#flow-status-container').find('.icon-threads').removeClass('zero');
} else {
$('#flow-status-container').find('.icon-threads').addClass('zero');
}
this.totalQueued = status.queued;
if (this.totalQueued.indexOf('0 / 0') >= 0) {
$('#flow-status-container').find('.fa-list').addClass('zero');
} else {
$('#flow-status-container').find('.fa-list').removeClass('zero');
}
// update the component counts
this.controllerTransmittingCount =
nf.Common.isDefinedAndNotNull(status.activeRemotePortCount) ?
status.activeRemotePortCount : '-';
if (this.controllerTransmittingCount > 0) {
$('#flow-status-container').find('.fa-bullseye').removeClass('zero').addClass('transmitting');
} else {
$('#flow-status-container').find('.fa-bullseye').removeClass('transmitting').addClass('zero');
}
this.controllerNotTransmittingCount =
nf.Common.isDefinedAndNotNull(status.inactiveRemotePortCount) ?
status.inactiveRemotePortCount : '-';
if (this.controllerNotTransmittingCount > 0) {
$('#flow-status-container').find('.icon-transmit-false').removeClass('zero').addClass('not-transmitting');
} else {
$('#flow-status-container').find('.icon-transmit-false').removeClass('not-transmitting').addClass('zero');
}
this.controllerRunningCount =
nf.Common.isDefinedAndNotNull(status.runningCount) ? status.runningCount : '-';
if (this.controllerRunningCount > 0) {
$('#flow-status-container').find('.fa-play').removeClass('zero').addClass('running');
} else {
$('#flow-status-container').find('.fa-play').removeClass('running').addClass('zero');
}
this.controllerStoppedCount =
nf.Common.isDefinedAndNotNull(status.stoppedCount) ? status.stoppedCount : '-';
if (this.controllerStoppedCount > 0) {
$('#flow-status-container').find('.fa-stop').removeClass('zero').addClass('stopped');
} else {
$('#flow-status-container').find('.fa-stop').removeClass('stopped').addClass('zero');
}
this.controllerInvalidCount =
nf.Common.isDefinedAndNotNull(status.invalidCount) ? status.invalidCount : '-';
if (this.controllerInvalidCount > 0) {
$('#flow-status-container').find('.fa-warning').removeClass('zero').addClass('invalid');
} else {
$('#flow-status-container').find('.fa-warning').removeClass('invalid').addClass('zero');
}
this.controllerDisabledCount =
nf.Common.isDefinedAndNotNull(status.disabledCount) ? status.disabledCount : '-';
if (this.controllerDisabledCount > 0) {
$('#flow-status-container').find('.icon-enable-false').removeClass('zero').addClass('disabled');
} else {
$('#flow-status-container').find('.icon-enable-false').removeClass('disabled').addClass('zero');
}
},
/**
* Updates the controller level bulletins
*
* @param response
*/
updateBulletins: function (response) {
this.bulletins.update(response);
}
}
var flowStatusCtrl = new FlowStatusCtrl();
return flowStatusCtrl;
};
var flowStatusCtrl = new FlowStatusCtrl();
return flowStatusCtrl;
};
}));

View File

@ -15,386 +15,426 @@
* limitations under the License.
*/
/* global nf, d3 */
/* global define, module, require, exports */
nf.ng.Canvas.GlobalMenuCtrl = function (serviceProvider) {
(function (root, factory) {
if (typeof define === 'function' && define.amd) {
define(['jquery',
'nf.Common',
'nf.QueueListing',
'nf.Shell',
'nf.PolicyManagement',
'nf.ClusterSummary',
'nf.ErrorHandler',
'nf.Settings',
'nf.CanvasUtils'],
function ($, common, queueListing, shell, policyManagement, clusterSummary, errorHandler, settings, canvasUtils) {
return (nf.ng.Canvas.GlobalMenuCtrl = factory($, common, queueListing, shell, policyManagement, clusterSummary, errorHandler, settings, canvasUtils));
});
} else if (typeof exports === 'object' && typeof module === 'object') {
module.exports = (nf.ng.Canvas.GlobalMenuCtrl =
factory(require('jquery'),
require('nf.Common'),
require('nf.QueueListing'),
require('nf.Shell'),
require('nf.PolicyManagement'),
require('nf.ClusterSummary'),
require('nf.ErrorHandler'),
require('nf.Settings'),
require('nf.CanvasUtils')));
} else {
nf.ng.Canvas.GlobalMenuCtrl = factory(root.$,
root.nf.Common,
root.nf.QueueListing,
root.nf.Shell,
root.nf.PolicyManagement,
root.nf.ClusterSummary,
root.nf.ErrorHandler,
root.nf.Settings,
root.nf.CanvasUtils);
}
}(this, function ($, common, queueListing, shell, policyManagement, clusterSummary, errorHandler, settings, canvasUtils) {
'use strict';
var config = {
urls: {
helpDocument: '../nifi-docs/documentation',
controllerAbout: '../nifi-api/flow/about'
}
};
return function (serviceProvider) {
'use strict';
function GlobalMenuCtrl(serviceProvider) {
/**
* The summary menu item controller.
*/
this.summary = {
/**
* The summary menu item's shell controller.
*/
shell: {
/**
* Launch the summary shell.
*/
launch: function () {
nf.Shell.showPage('summary');
}
var config = {
urls: {
helpDocument: '../nifi-docs/documentation',
controllerAbout: '../nifi-api/flow/about'
}
};
/**
* The counters menu item controller.
*/
this.counters = {
function GlobalMenuCtrl(serviceProvider) {
/**
* The counters menu item's shell controller.
* The summary menu item controller.
*/
shell: {
this.summary = {
/**
* Launch the counters shell.
* The summary menu item's shell controller.
*/
launch: function () {
if (nf.Common.canAccessCounters()) {
nf.Shell.showPage('counters');
shell: {
/**
* Launch the summary shell.
*/
launch: function () {
shell.showPage('summary');
}
}
}
};
/**
* The bulletin board menu item controller.
*/
this.bulletinBoard = {
};
/**
* The bulletin board menu item's shell controller.
* The counters menu item controller.
*/
shell: {
this.counters = {
/**
* Launch the bulletin board shell.
* The counters menu item's shell controller.
*/
launch: function () {
nf.Shell.showPage('bulletin-board');
}
}
};
shell: {
/**
* The data provenance menu item controller.
*/
this.dataProvenance = {
/**
* The data provenance menu item's shell controller.
*/
shell: {
/**
* Launch the data provenance shell.
*/
launch: function () {
if (nf.Common.canAccessProvenance()) {
nf.Shell.showPage('provenance');
/**
* Launch the counters shell.
*/
launch: function () {
if (common.canAccessCounters()) {
shell.showPage('counters');
}
}
}
}
};
/**
* The controller settings menu item controller.
*/
this.controllerSettings = {
};
/**
* The controller settings menu item's shell controller.
* The bulletin board menu item controller.
*/
shell: {
this.bulletinBoard = {
/**
* Launch the settings shell.
* The bulletin board menu item's shell controller.
*/
launch: function () {
nf.Settings.showSettings();
}
}
};
shell: {
/**
* The cluster menu item controller.
*/
this.cluster = {
/**
* Determines if the cluster menu item is enabled.
*
* @returns {*|boolean}
*/
visible: function () {
return nf.ClusterSummary.isConnectedToCluster();
},
/**
* The cluster menu item's shell controller.
*/
shell: {
/**
* Launch the cluster shell.
*/
launch: function () {
if (nf.Common.canAccessController()) {
nf.Shell.showPage('cluster');
/**
* Launch the bulletin board shell.
*/
launch: function () {
shell.showPage('bulletin-board');
}
}
}
};
/**
* The flow config history menu item controller.
*/
this.flowConfigHistory = {
};
/**
* The flow config history menu item's shell controller.
* The data provenance menu item controller.
*/
shell: {
this.dataProvenance = {
/**
* Launch the history shell.
* The data provenance menu item's shell controller.
*/
launch: function () {
nf.Shell.showPage('history');
}
}
};
shell: {
/**
* The users menu item controller.
*/
this.users = {
/**
* The users menu item's shell controller.
*/
shell: {
/**
* Launch the users shell.
*/
launch: function () {
if (nf.Common.canAccessTenants()) {
nf.Shell.showPage('users');
/**
* Launch the data provenance shell.
*/
launch: function () {
if (common.canAccessProvenance()) {
shell.showPage('provenance');
}
}
}
}
};
/**
* The policies menu item controller.
*/
this.policies = {
};
/**
* The policies menu item's shell controller.
* The controller settings menu item controller.
*/
shell: {
this.controllerSettings = {
/**
* Launch the policies shell.
* The controller settings menu item's shell controller.
*/
launch: function () {
if (nf.Common.canModifyPolicies() && nf.Common.canAccessTenants()) {
nf.PolicyManagement.showGlobalPolicies();
shell: {
/**
* Launch the settings shell.
*/
launch: function () {
settings.showSettings();
}
}
}
};
/**
* The templates menu item controller.
*/
this.templates = {
};
/**
* The templates menu item's shell controller.
* The cluster menu item controller.
*/
shell: {
this.cluster = {
/**
* Launch the templates shell.
*/
launch: function () {
nf.Shell.showPage('templates?' + $.param({
groupId: nf.Canvas.getGroupId()
}));
}
}
};
/**
* The help menu item controller.
*/
this.help = {
/**
* The help menu item's shell controller.
*/
shell: {
/**
* Launch the help documentation shell.
*/
launch: function () {
nf.Shell.showPage(config.urls.helpDocument);
}
}
};
/**
* The about menu item controller.
*/
this.about = {
/**
* Initialize the about details.
*/
init: function () {
// get the about details
$.ajax({
type: 'GET',
url: config.urls.controllerAbout,
dataType: 'json'
}).done(function (response) {
var aboutDetails = response.about;
// set the document title and the about title
document.title = aboutDetails.title;
$('#nf-version').text(aboutDetails.version);
var showVersionDetail = false;
if (aboutDetails.buildTag && aboutDetails.buildTag !== 'HEAD') {
$('#nf-about-build-tag').text(aboutDetails.buildTag);
$('#nf-version-detail-tag').show();
showVersionDetail = true;
}
if (aboutDetails.buildRevision) {
$('#nf-about-build-revision').text(aboutDetails.buildRevision);
$('#nf-about-build-branch').text(aboutDetails.buildBranch);
$('#nf-version-detail-commit').show();
showVersionDetail = true
}
if (aboutDetails.buildTimestamp) {
$('#nf-about-build-timestamp').text(aboutDetails.buildTimestamp);
$('#nf-version-detail-timestamp').show();
showVersionDetail = true;
}
if (showVersionDetail) {
$('#nf-version-detail').show();
}
// store the content viewer url if available
if (!nf.Common.isBlank(aboutDetails.contentViewerUrl)) {
$('#nifi-content-viewer-url').text(aboutDetails.contentViewerUrl);
nf.QueueListing.initFlowFileDetailsDialog();
}
}).fail(nf.ErrorHandler.handleAjaxError);
this.modal.init();
},
/**
* The about menu item's modal controller.
*/
modal: {
/**
* Gets the modal element.
* Determines if the cluster menu item is enabled.
*
* @returns {*|jQuery|HTMLElement}
* @returns {*|boolean}
*/
getElement: function () {
return $('#nf-about');
visible: function () {
return clusterSummary.isConnectedToCluster();
},
/**
* Initialize the modal.
* The cluster menu item's shell controller.
*/
shell: {
/**
* Launch the cluster shell.
*/
launch: function () {
if (common.canAccessController()) {
shell.showPage('cluster');
}
}
}
};
/**
* The flow config history menu item controller.
*/
this.flowConfigHistory = {
/**
* The flow config history menu item's shell controller.
*/
shell: {
/**
* Launch the history shell.
*/
launch: function () {
shell.showPage('history');
}
}
};
/**
* The users menu item controller.
*/
this.users = {
/**
* The users menu item's shell controller.
*/
shell: {
/**
* Launch the users shell.
*/
launch: function () {
if (common.canAccessTenants()) {
shell.showPage('users');
}
}
}
};
/**
* The policies menu item controller.
*/
this.policies = {
/**
* The policies menu item's shell controller.
*/
shell: {
/**
* Launch the policies shell.
*/
launch: function () {
if (common.canModifyPolicies() && common.canAccessTenants()) {
policyManagement.showGlobalPolicies();
}
}
}
};
/**
* The templates menu item controller.
*/
this.templates = {
/**
* The templates menu item's shell controller.
*/
shell: {
/**
* Launch the templates shell.
*/
launch: function () {
shell.showPage('templates?' + $.param({
groupId: canvasUtils.getGroupId()
}));
}
}
};
/**
* The help menu item controller.
*/
this.help = {
/**
* The help menu item's shell controller.
*/
shell: {
/**
* Launch the help documentation shell.
*/
launch: function () {
shell.showPage(config.urls.helpDocument);
}
}
};
/**
* The about menu item controller.
*/
this.about = {
/**
* Initialize the about details.
*/
init: function () {
var aboutModal = this;
// get the about details
$.ajax({
type: 'GET',
url: config.urls.controllerAbout,
dataType: 'json'
}).done(function (response) {
var aboutDetails = response.about;
// set the document title and the about title
document.title = aboutDetails.title;
$('#nf-version').text(aboutDetails.version);
var showVersionDetail = false;
if (aboutDetails.buildTag && aboutDetails.buildTag !== 'HEAD') {
$('#nf-about-build-tag').text(aboutDetails.buildTag);
$('#nf-version-detail-tag').show();
showVersionDetail = true;
}
if (aboutDetails.buildRevision) {
$('#nf-about-build-revision').text(aboutDetails.buildRevision);
$('#nf-about-build-branch').text(aboutDetails.buildBranch);
$('#nf-version-detail-commit').show();
showVersionDetail = true
}
if (aboutDetails.buildTimestamp) {
$('#nf-about-build-timestamp').text(aboutDetails.buildTimestamp);
$('#nf-version-detail-timestamp').show();
showVersionDetail = true;
}
if (showVersionDetail) {
$('#nf-version-detail').show();
}
var resizeAbout = function(){
var dialog = $(this);
var top = $('#nf-about-pic-container').height() + $('.dialog-header').height() + 10; //10 for padding-top
dialog.find('.dialog-content').css('top', top);
};
// store the content viewer url if available
if (!common.isBlank(aboutDetails.contentViewerUrl)) {
$('#nifi-content-viewer-url').text(aboutDetails.contentViewerUrl);
queueListing.initFlowFileDetailsDialog();
}
}).fail(errorHandler.handleAjaxError);
this.getElement().modal({
scrollableContentStyle: 'scrollable',
headerText: 'About Apache NiFi',
handler: {
resize: resizeAbout
},
buttons: [{
buttonText: 'Ok',
color: {
base: '#728E9B',
hover: '#004849',
text: '#ffffff'
},
this.modal.init();
},
/**
* The about menu item's modal controller.
*/
modal: {
/**
* Gets the modal element.
*
* @returns {*|jQuery|HTMLElement}
*/
getElement: function () {
return $('#nf-about');
},
/**
* Initialize the modal.
*/
init: function () {
var aboutModal = this;
var resizeAbout = function () {
var dialog = $(this);
var top = $('#nf-about-pic-container').height() + $('.dialog-header').height() + 10; //10 for padding-top
dialog.find('.dialog-content').css('top', top);
};
this.getElement().modal({
scrollableContentStyle: 'scrollable',
headerText: 'About Apache NiFi',
handler: {
click: function () {
aboutModal.hide();
resize: resizeAbout
},
buttons: [{
buttonText: 'Ok',
color: {
base: '#728E9B',
hover: '#004849',
text: '#ffffff'
},
handler: {
click: function () {
aboutModal.hide();
}
}
}
}]
});
},
}]
});
},
/**
* Updates the modal config.
*
* @param {string} name The name of the property to update.
* @param {object|array} config The config for the `name`.
*/
update: function (name, config) {
this.getElement().modal(name, config);
},
/**
* Updates the modal config.
*
* @param {string} name The name of the property to update.
* @param {object|array} config The config for the `name`.
*/
update: function (name, config) {
this.getElement().modal(name, config);
},
/**
* Show the modal
*/
show: function () {
this.getElement().modal('show');
},
/**
* Show the modal
*/
show: function () {
this.getElement().modal('show');
},
/**
* Hide the modal
*/
hide: function () {
this.getElement().modal('hide');
/**
* Hide the modal
*/
hide: function () {
this.getElement().modal('hide');
}
}
}
}
}
GlobalMenuCtrl.prototype = {
constructor: GlobalMenuCtrl,
GlobalMenuCtrl.prototype = {
constructor: GlobalMenuCtrl,
/**
* Initialize the global menu controls.
*/
init: function () {
this.about.init();
/**
* Initialize the global menu controls.
*/
init: function () {
this.about.init();
}
}
}
var globalMenuCtrl = new GlobalMenuCtrl();
return globalMenuCtrl;
};
var globalMenuCtrl = new GlobalMenuCtrl();
return globalMenuCtrl;
};
}));

View File

@ -15,330 +15,364 @@
* limitations under the License.
*/
/* global nf, d3 */
/* global define, module, require, exports */
nf.ng.Canvas.GraphControlsCtrl = function (serviceProvider, navigateCtrl, operateCtrl) {
(function (root, factory) {
if (typeof define === 'function' && define.amd) {
define(['jquery',
'nf.Actions',
'nf.Birdseye',
'nf.Storage',
'nf.CanvasUtils',
'nf.Common',
'nf.ProcessGroupConfiguration'],
function ($, action, birdseye, storage, canvasUtils, common, processGroupConfiguration) {
return (nf.ng.Canvas.GraphControlsCtrl = factory($, action, birdseye, storage, canvasUtils, common, processGroupConfiguration));
});
} else if (typeof exports === 'object' && typeof module === 'object') {
module.exports = (nf.ng.Canvas.GraphControlsCtrl =
factory(require('jquery'),
require('nf.Actions'),
require('nf.Birdseye'),
require('nf.Storage'),
require('nf.CanvasUtils'),
require('nf.Common'),
require('nf.ProcessGroupConfiguration')));
} else {
nf.ng.Canvas.GraphControlsCtrl = factory(root.$,
root.nf.Actions,
root.nf.Birdseye,
root.nf.Storage,
root.nf.CanvasUtils,
root.nf.Common,
root.nf.ProcessGroupConfiguration);
}
}(this, function ($, actions, birdseye, storage, canvasUtils, common, processGroupConfiguration) {
'use strict';
/**
* Opens the specified graph control.
*
* @param {jQuery} graphControl
*/
var openGraphControl = function (graphControl) {
// undock if necessary
if ($('div.graph-control-content').is(':visible') === false) {
$('#graph-controls div.graph-control-docked').hide();
$('#graph-controls div.graph-control-header-container').show();
$('.graph-control').removeClass('docked');
}
// show the content of the specified graph control
graphControl.children('div.graph-control-content').show();
graphControl.find('div.graph-control-expansion').removeClass('fa-plus-square-o').addClass('fa-minus-square-o');
// handle specific actions as necessary
if (graphControl.attr('id') === 'navigation-control') {
nf.Birdseye.updateBirdseyeVisibility(true);
}
// get the current visibility
var graphControlVisibility = nf.Storage.getItem('graph-control-visibility');
if (graphControlVisibility === null) {
graphControlVisibility = {};
}
// update the visibility for this graph control
var graphControlId = graphControl.attr('id');
graphControlVisibility[graphControlId] = true;
nf.Storage.setItem('graph-control-visibility', graphControlVisibility);
};
/**
* Hides the specified graph control.
*
* @param {jQuery} graphControl
*/
var hideGraphControl = function (graphControl) {
// hide the content of the specified graph control
graphControl.children('div.graph-control-content').hide();
graphControl.find('div.graph-control-expansion').removeClass('fa-minus-square-o').addClass('fa-plus-square-o');
// dock if necessary
if ($('div.graph-control-content').is(':visible') === false) {
$('#graph-controls div.graph-control-header-container').hide();
$('#graph-controls div.graph-control-docked').show();
$('.graph-control').addClass('docked');
}
// handle specific actions as necessary
if (graphControl.attr('id') === 'navigation-control') {
nf.Birdseye.updateBirdseyeVisibility(false);
}
// get the current visibility
var graphControlVisibility = nf.Storage.getItem('graph-control-visibility');
if (graphControlVisibility === null) {
graphControlVisibility = {};
}
// update the visibility for this graph control
var graphControlId = graphControl.attr('id');
graphControlVisibility[graphControlId] = false;
nf.Storage.setItem('graph-control-visibility', graphControlVisibility);
};
function GraphControlsCtrl(navigateCtrl, operateCtrl) {
this.navigateCtrl = navigateCtrl;
this.operateCtrl = operateCtrl;
}
GraphControlsCtrl.prototype = {
constructor: GraphControlsCtrl,
return function (serviceProvider, navigateCtrl, operateCtrl) {
'use strict';
/**
* Register the header controller.
* Opens the specified graph control.
*
* @param {jQuery} graphControl
*/
register: function () {
if (serviceProvider.graphControlsCtrl === undefined) {
serviceProvider.register('graphControlsCtrl', graphControlsCtrl);
var openGraphControl = function (graphControl) {
// undock if necessary
if ($('div.graph-control-content').is(':visible') === false) {
$('#graph-controls div.graph-control-docked').hide();
$('#graph-controls div.graph-control-header-container').show();
$('.graph-control').removeClass('docked');
}
},
/**
* Initialize the graph controls.
*/
init: function () {
this.operateCtrl.init();
// initial the graph control visibility
var graphControlVisibility = nf.Storage.getItem('graph-control-visibility');
if (graphControlVisibility !== null) {
$.each(graphControlVisibility, function (id, isVisible) {
var graphControl = $('#' + id);
if (graphControl) {
if (isVisible) {
openGraphControl(graphControl);
} else {
hideGraphControl(graphControl);
}
}
});
} else {
openGraphControl($('#navigation-control'));
openGraphControl($('#operation-control'));
// show the content of the specified graph control
graphControl.children('div.graph-control-content').show();
graphControl.find('div.graph-control-expansion').removeClass('fa-plus-square-o').addClass('fa-minus-square-o');
// handle specific actions as necessary
if (graphControl.attr('id') === 'navigation-control') {
birdseye.updateBirdseyeVisibility(true);
}
},
/**
* Undock the graph control.
* @param {jQuery} $event
*/
undock: function ($event) {
openGraphControl($($event.target).parent());
},
/**
* Expand the graph control.
* @param {jQuery} $event
*/
expand: function ($event) {
var icon = $($event.target);
if (icon.find('.fa-plus-square-o').length > 0 || icon.hasClass('fa-plus-square-o') || icon.parent().children().find('.fa-plus-square-o').length > 0) {
openGraphControl(icon.closest('div.graph-control'));
} else {
hideGraphControl(icon.closest('div.graph-control'));
// get the current visibility
var graphControlVisibility = storage.getItem('graph-control-visibility');
if (graphControlVisibility === null) {
graphControlVisibility = {};
}
},
// update the visibility for this graph control
var graphControlId = graphControl.attr('id');
graphControlVisibility[graphControlId] = true;
storage.setItem('graph-control-visibility', graphControlVisibility);
};
/**
* Gets the icon to show for the selection context.
* Hides the specified graph control.
*
* @param {jQuery} graphControl
*/
getContextIcon: function () {
var selection = nf.CanvasUtils.getSelection();
var hideGraphControl = function (graphControl) {
// hide the content of the specified graph control
graphControl.children('div.graph-control-content').hide();
graphControl.find('div.graph-control-expansion').removeClass('fa-minus-square-o').addClass('fa-plus-square-o');
if (selection.empty()) {
if (nf.Canvas.getParentGroupId() === null) {
return 'icon-drop';
} else {
return 'icon-group';
// dock if necessary
if ($('div.graph-control-content').is(':visible') === false) {
$('#graph-controls div.graph-control-header-container').hide();
$('#graph-controls div.graph-control-docked').show();
$('.graph-control').addClass('docked');
}
// handle specific actions as necessary
if (graphControl.attr('id') === 'navigation-control') {
birdseye.updateBirdseyeVisibility(false);
}
// get the current visibility
var graphControlVisibility = storage.getItem('graph-control-visibility');
if (graphControlVisibility === null) {
graphControlVisibility = {};
}
// update the visibility for this graph control
var graphControlId = graphControl.attr('id');
graphControlVisibility[graphControlId] = false;
storage.setItem('graph-control-visibility', graphControlVisibility);
};
function GraphControlsCtrl(navigateCtrl, operateCtrl) {
this.navigateCtrl = navigateCtrl;
this.operateCtrl = operateCtrl;
}
GraphControlsCtrl.prototype = {
constructor: GraphControlsCtrl,
/**
* Register the header controller.
*/
register: function () {
if (serviceProvider.graphControlsCtrl === undefined) {
serviceProvider.register('graphControlsCtrl', graphControlsCtrl);
}
} else {
if (selection.size() === 1) {
if (nf.CanvasUtils.isProcessor(selection)) {
return 'icon-processor';
} else if (nf.CanvasUtils.isProcessGroup(selection)) {
return 'icon-group';
} else if (nf.CanvasUtils.isInputPort(selection)) {
return 'icon-port-in';
} else if (nf.CanvasUtils.isOutputPort(selection)) {
return 'icon-port-out';
} else if (nf.CanvasUtils.isRemoteProcessGroup(selection)) {
return 'icon-group-remote';
} else if (nf.CanvasUtils.isFunnel(selection)) {
return 'icon-funnel';
} else if (nf.CanvasUtils.isLabel(selection)) {
return 'icon-label';
} else if (nf.CanvasUtils.isConnection(selection)) {
return 'icon-connect';
}
} else {
return 'icon-drop';
}
}
},
},
/**
* Will hide target when appropriate.
*/
hide: function () {
var selection = nf.CanvasUtils.getSelection();
if (selection.size() > 1) {
return 'invisible'
} else {
return '';
}
},
/**
* Gets the name to show for the selection context.
*/
getContextName: function () {
var selection = nf.CanvasUtils.getSelection();
var canRead = nf.Canvas.canRead();
if (selection.empty()) {
if (canRead) {
return nf.Canvas.getGroupName();
} else {
return nf.Canvas.getGroupId();
}
} else {
if (selection.size() === 1) {
var d = selection.datum();
if (d.permissions.canRead) {
if (nf.CanvasUtils.isLabel(selection)) {
if ($.trim(d.component.label) !== '') {
return d.component.label;
/**
* Initialize the graph controls.
*/
init: function () {
this.operateCtrl.init();
// initial the graph control visibility
var graphControlVisibility = storage.getItem('graph-control-visibility');
if (graphControlVisibility !== null) {
$.each(graphControlVisibility, function (id, isVisible) {
var graphControl = $('#' + id);
if (graphControl) {
if (isVisible) {
openGraphControl(graphControl);
} else {
return '';
hideGraphControl(graphControl);
}
} else if (nf.CanvasUtils.isConnection(selection)) {
return nf.CanvasUtils.formatConnectionName(d.component);
} else {
return d.component.name;
}
});
} else {
openGraphControl($('#navigation-control'));
openGraphControl($('#operation-control'));
}
},
/**
* Undock the graph control.
* @param {jQuery} $event
*/
undock: function ($event) {
openGraphControl($($event.target).parent());
},
/**
* Expand the graph control.
* @param {jQuery} $event
*/
expand: function ($event) {
var icon = $($event.target);
if (icon.find('.fa-plus-square-o').length > 0 || icon.hasClass('fa-plus-square-o') || icon.parent().children().find('.fa-plus-square-o').length > 0) {
openGraphControl(icon.closest('div.graph-control'));
} else {
hideGraphControl(icon.closest('div.graph-control'));
}
},
/**
* Gets the icon to show for the selection context.
*/
getContextIcon: function () {
var selection = canvasUtils.getSelection();
if (selection.empty()) {
if (canvasUtils.getParentGroupId() === null) {
return 'icon-drop';
} else {
return 'icon-group';
}
} else {
if (selection.size() === 1) {
if (canvasUtils.isProcessor(selection)) {
return 'icon-processor';
} else if (canvasUtils.isProcessGroup(selection)) {
return 'icon-group';
} else if (canvasUtils.isInputPort(selection)) {
return 'icon-port-in';
} else if (canvasUtils.isOutputPort(selection)) {
return 'icon-port-out';
} else if (canvasUtils.isRemoteProcessGroup(selection)) {
return 'icon-group-remote';
} else if (canvasUtils.isFunnel(selection)) {
return 'icon-funnel';
} else if (canvasUtils.isLabel(selection)) {
return 'icon-label';
} else if (canvasUtils.isConnection(selection)) {
return 'icon-connect';
}
} else {
return 'icon-drop';
}
}
},
/**
* Will hide target when appropriate.
*/
hide: function () {
var selection = canvasUtils.getSelection();
if (selection.size() > 1) {
return 'invisible'
} else {
return '';
}
},
/**
* Gets the name to show for the selection context.
*/
getContextName: function () {
var selection = canvasUtils.getSelection();
var canRead = canvasUtils.canReadFromGroup();
if (selection.empty()) {
if (canRead) {
return canvasUtils.getGroupName();
} else {
return canvasUtils.getGroupId();
}
} else {
if (selection.size() === 1) {
var d = selection.datum();
if (d.permissions.canRead) {
if (canvasUtils.isLabel(selection)) {
if ($.trim(d.component.label) !== '') {
return d.component.label;
} else {
return '';
}
} else if (canvasUtils.isConnection(selection)) {
return canvasUtils.formatConnectionName(d.component);
} else {
return d.component.name;
}
} else {
return d.id;
}
} else {
return 'Multiple components selected';
}
}
},
/**
* Gets the type to show for the selection context.
*/
getContextType: function () {
var selection = canvasUtils.getSelection();
if (selection.empty()) {
return 'Process Group';
} else {
if (selection.size() === 1) {
if (canvasUtils.isProcessor(selection)) {
return 'Processor';
} else if (canvasUtils.isProcessGroup(selection)) {
return 'Process Group';
} else if (canvasUtils.isInputPort(selection)) {
return 'Input Port';
} else if (canvasUtils.isOutputPort(selection)) {
return 'Output Port';
} else if (canvasUtils.isRemoteProcessGroup(selection)) {
return 'Remote Process Group';
} else if (canvasUtils.isFunnel(selection)) {
return 'Funnel';
} else if (canvasUtils.isLabel(selection)) {
return 'Label';
} else if (canvasUtils.isConnection(selection)) {
return 'Connection';
}
} else {
return 'Multiple selected';
}
}
},
/**
* Gets the id to show for the selection context.
*/
getContextId: function () {
var selection = canvasUtils.getSelection();
if (selection.empty()) {
return canvasUtils.getGroupId();
} else {
if (selection.size() === 1) {
var d = selection.datum();
return d.id;
} else {
return 'Multiple selected';
}
} else {
return 'Multiple components selected';
}
}
},
},
/**
* Gets the type to show for the selection context.
*/
getContextType: function () {
var selection = nf.CanvasUtils.getSelection();
/**
* Determines whether the user can configure or open the details dialog.
*/
canConfigureOrOpenDetails: function () {
var selection = canvasUtils.getSelection();
if (selection.empty()) {
return 'Process Group';
} else {
if (selection.size() === 1) {
if (nf.CanvasUtils.isProcessor(selection)) {
return 'Processor';
} else if (nf.CanvasUtils.isProcessGroup(selection)) {
return 'Process Group';
} else if (nf.CanvasUtils.isInputPort(selection)) {
return 'Input Port';
} else if (nf.CanvasUtils.isOutputPort(selection)) {
return 'Output Port';
} else if (nf.CanvasUtils.isRemoteProcessGroup(selection)) {
return 'Remote Process Group';
} else if (nf.CanvasUtils.isFunnel(selection)) {
return 'Funnel';
} else if (nf.CanvasUtils.isLabel(selection)) {
return 'Label';
} else if (nf.CanvasUtils.isConnection(selection)) {
return 'Connection';
if (selection.empty()) {
return true;
}
return canvasUtils.isConfigurable(selection) || canvasUtils.hasDetails(selection);
},
/**
* Opens either the configuration or details view based on the current state.
*/
openConfigureOrDetailsView: function () {
var selection = canvasUtils.getSelection();
if (selection.empty()) {
processGroupConfiguration.showConfiguration(canvasUtils.getGroupId());
}
if (canvasUtils.isConfigurable(selection)) {
actions.showConfiguration(selection);
} else if (canvasUtils.hasDetails(selection)) {
actions.showDetails(selection);
}
},
/**
* Determines whether the user can configure or open the policy management page.
*/
canManagePolicies: function () {
var selection = canvasUtils.getSelection();
// ensure 0 or 1 components selected
if (selection.size() <= 1) {
// if something is selected, ensure it's not a connection
if (!selection.empty() && canvasUtils.isConnection(selection)) {
return false;
}
} else {
return 'Multiple selected';
}
}
},
/**
* Gets the id to show for the selection context.
*/
getContextId: function () {
var selection = nf.CanvasUtils.getSelection();
if (selection.empty()) {
return nf.Canvas.getGroupId();
} else {
if (selection.size() === 1) {
var d = selection.datum();
return d.id;
} else {
return 'Multiple selected';
}
}
},
/**
* Determines whether the user can configure or open the details dialog.
*/
canConfigureOrOpenDetails: function () {
var selection = nf.CanvasUtils.getSelection();
if (selection.empty()) {
return true;
}
return nf.CanvasUtils.isConfigurable(selection) || nf.CanvasUtils.hasDetails(selection);
},
/**
* Opens either the configuration or details view based on the current state.
*/
openConfigureOrDetailsView: function () {
var selection = nf.CanvasUtils.getSelection();
if (selection.empty()) {
nf.ProcessGroupConfiguration.showConfiguration(nf.Canvas.getGroupId());
}
if (nf.CanvasUtils.isConfigurable(selection)) {
nf.Actions.showConfiguration(selection);
} else if (nf.CanvasUtils.hasDetails(selection)) {
nf.Actions.showDetails(selection);
}
},
/**
* Determines whether the user can configure or open the policy management page.
*/
canManagePolicies: function () {
var selection = nf.CanvasUtils.getSelection();
// ensure 0 or 1 components selected
if (selection.size() <= 1) {
// if something is selected, ensure it's not a connection
if (!selection.empty() && nf.CanvasUtils.isConnection(selection)) {
return false;
// ensure access to read tenants
return common.canAccessTenants();
}
// ensure access to read tenants
return nf.Common.canAccessTenants();
return false;
}
return false;
}
}
var graphControlsCtrl = new GraphControlsCtrl(navigateCtrl, operateCtrl);
graphControlsCtrl.register();
return graphControlsCtrl;
};
var graphControlsCtrl = new GraphControlsCtrl(navigateCtrl, operateCtrl);
graphControlsCtrl.register();
return graphControlsCtrl;
};
}));

View File

@ -15,113 +15,141 @@
* limitations under the License.
*/
/* global nf, d3 */
/* global define, module, require, exports */
nf.ng.Canvas.HeaderCtrl = function (serviceProvider, toolboxCtrl, globalMenuCtrl, flowStatusCtrl) {
(function (root, factory) {
if (typeof define === 'function' && define.amd) {
define(['jquery',
'nf.Common',
'nf.Storage',
'nf.Shell',
'nf.ErrorHandler'],
function ($, common, storage, shell, errorHandler) {
return (nf.ng.Canvas.HeaderCtrl = factory($, common, storage, shell, errorHandler));
});
} else if (typeof exports === 'object' && typeof module === 'object') {
module.exports = (nf.ng.Canvas.HeaderCtrl =
factory(require('jquery'),
require('nf.Common'),
require('nf.Storage'),
require('nf.Shell'),
require('nf.ErrorHandler')));
} else {
nf.ng.Canvas.HeaderCtrl = factory(root.$,
root.nf.Common,
root.nf.Storage,
root.nf.Shell,
root.nf.ErrorHandler);
}
}(this, function ($, common, storage, shell, errorHandler) {
'use strict';
var MIN_TOOLBAR_WIDTH = 640;
return function (serviceProvider, toolboxCtrl, globalMenuCtrl, flowStatusCtrl) {
'use strict';
var config = {
urls: {
accessConfig: '../nifi-api/access/config'
}
};
var MIN_TOOLBAR_WIDTH = 640;
function HeaderCtrl(toolboxCtrl, globalMenuCtrl, flowStatusCtrl) {
this.toolboxCtrl = toolboxCtrl;
this.globalMenuCtrl = globalMenuCtrl;
this.flowStatusCtrl = flowStatusCtrl;
var config = {
urls: {
accessConfig: '../nifi-api/access/config'
}
};
/**
* The login controller.
*/
this.loginCtrl = {
function HeaderCtrl(toolboxCtrl, globalMenuCtrl, flowStatusCtrl) {
this.toolboxCtrl = toolboxCtrl;
this.globalMenuCtrl = globalMenuCtrl;
this.flowStatusCtrl = flowStatusCtrl;
/**
* Initialize the login controller.
* The login controller.
*/
init: function () {
var loginCtrl = this;
this.loginCtrl = {
// if the user is not anonymous or accessing via http
if ($('#current-user').text() !== nf.Common.ANONYMOUS_USER_TEXT || location.protocol === 'http:') {
$('#login-link-container').css('display', 'none');
/**
* Initialize the login controller.
*/
init: function () {
var loginCtrl = this;
// if the user is not anonymous or accessing via http
if ($('#current-user').text() !== common.ANONYMOUS_USER_TEXT || location.protocol === 'http:') {
$('#login-link-container').css('display', 'none');
}
// if accessing via http, don't show the current user
if (location.protocol === 'http:') {
$('#current-user-container').css('display', 'none');
}
// get the login config
var loginXhr = $.ajax({
type: 'GET',
url: config.urls.accessConfig,
dataType: 'json'
});
$.when(loginXhr).done(function (loginResult) {
loginCtrl.supportsLogin = loginResult.config.supportsLogin;
}).fail(errorHandler.handleAjaxError);
},
/**
* Boolean describing whether or not the NiFi instance supports login.
*/
supportsLogin: undefined,
/**
* The login shell controller.
*/
shell: {
/**
* Launch the login shell.
*/
launch: function () {
shell.showPage('login', false);
}
}
};
// if accessing via http, don't show the current user
if (location.protocol === 'http:') {
$('#current-user-container').css('display', 'none');
/**
* The logout controller.
*/
this.logoutCtrl = {
logout: function () {
storage.removeItem("jwt");
window.location = '/nifi';
}
};
}
// get the login config
var loginXhr = $.ajax({
type: 'GET',
url: config.urls.accessConfig,
dataType: 'json'
});
HeaderCtrl.prototype = {
constructor: HeaderCtrl,
$.when(loginXhr).done(function (loginResult) {
loginCtrl.supportsLogin = loginResult.config.supportsLogin;
}).fail(nf.ErrorHandler.handleAjaxError);
/**
* Register the header controller.
*/
register: function () {
if (serviceProvider.headerCtrl === undefined) {
serviceProvider.register('headerCtrl', headerCtrl);
}
},
/**
* Boolean describing whether or not the NiFi instance supports login.
* Initialize the canvas header.
*
* @argument {boolean} supportsLogin Whether login is supported.
*/
supportsLogin: undefined,
/**
* The login shell controller.
*/
shell: {
/**
* Launch the login shell.
*/
launch: function () {
nf.Shell.showPage('login', false);
}
init: function () {
this.toolboxCtrl.init();
this.globalMenuCtrl.init();
this.flowStatusCtrl.init();
this.loginCtrl.init();
}
};
/**
* The logout controller.
*/
this.logoutCtrl = {
logout: function () {
nf.Storage.removeItem("jwt");
window.location = '/nifi';
}
};
}
HeaderCtrl.prototype = {
constructor: HeaderCtrl,
/**
* Register the header controller.
*/
register: function () {
if (serviceProvider.headerCtrl === undefined) {
serviceProvider.register('headerCtrl', headerCtrl);
}
},
/**
* Initialize the canvas header.
*
* @argument {boolean} supportsLogin Whether login is supported.
*/
init: function () {
this.toolboxCtrl.init();
this.globalMenuCtrl.init();
this.flowStatusCtrl.init();
this.loginCtrl.init();
}
}
var headerCtrl = new HeaderCtrl(toolboxCtrl, globalMenuCtrl, flowStatusCtrl);
headerCtrl.register();
return headerCtrl;
};
var headerCtrl = new HeaderCtrl(toolboxCtrl, globalMenuCtrl, flowStatusCtrl);
headerCtrl.register();
return headerCtrl;
};
}));

View File

@ -15,77 +15,97 @@
* limitations under the License.
*/
/* global nf, d3 */
/* global define, module, require, exports */
nf.ng.Canvas.NavigateCtrl = function () {
(function (root, factory) {
if (typeof define === 'function' && define.amd) {
define(['nf.CanvasUtils',
'nf.ContextMenu'],
function (canvasUtils, contextMenu) {
return (nf.ng.Canvas.NavigateCtrl = factory(canvasUtils, contextMenu));
});
} else if (typeof exports === 'object' && typeof module === 'object') {
module.exports = (nf.ng.Canvas.NavigateCtrl =
factory(require('nf.CanvasUtils'),
require('nf.ContextMenu')));
} else {
nf.ng.Canvas.NavigateCtrl = factory(root.nf.CanvasUtils,
root.nf.ContextMenu);
}
}(this, function (canvasUtils, contextMenu) {
'use strict';
function NavigateCtrl() {
return function () {
'use strict';
/**
* Zoom in on the canvas.
*/
this.zoomIn = function () {
nf.Canvas.View.zoomIn();
function NavigateCtrl() {
// hide the context menu
nf.ContextMenu.hide();
/**
* Zoom in on the canvas.
*/
this.zoomIn = function () {
canvasUtils.zoomCanvasViewIn();
// refresh the canvas
nf.Canvas.View.refresh({
transition: true
});
};
// hide the context menu
contextMenu.hide();
/**
* Zoom out on the canvas.
*/
this.zoomOut = function () {
nf.Canvas.View.zoomOut();
// refresh the canvas
canvasUtils.refreshCanvasView({
transition: true
});
};
// hide the context menu
nf.ContextMenu.hide();
/**
* Zoom out on the canvas.
*/
this.zoomOut = function () {
canvasUtils.zoomCanvasViewOut();
// refresh the canvas
nf.Canvas.View.refresh({
transition: true
});
};
// hide the context menu
contextMenu.hide();
/**
* Zoom fit on the canvas.
*/
this.zoomFit = function () {
nf.Canvas.View.fit();
// refresh the canvas
canvasUtils.refreshCanvasView({
transition: true
});
};
// hide the context menu
nf.ContextMenu.hide();
/**
* Zoom fit on the canvas.
*/
this.zoomFit = function () {
canvasUtils.fitCanvasView();
// refresh the canvas
nf.Canvas.View.refresh({
transition: true
});
};
// hide the context menu
contextMenu.hide();
/**
* Zoom actual size on the canvas.
*/
this.zoomActualSize = function () {
nf.Canvas.View.actualSize();
// refresh the canvas
canvasUtils.refreshCanvasView({
transition: true
});
};
// hide the context menu
nf.ContextMenu.hide();
/**
* Zoom actual size on the canvas.
*/
this.zoomActualSize = function () {
canvasUtils.actualSizeCanvasView();
// refresh the canvas
nf.Canvas.View.refresh({
transition: true
});
};
}
NavigateCtrl.prototype = {
constructor: NavigateCtrl
}
// hide the context menu
contextMenu.hide();
var navigateCtrl = new NavigateCtrl();
return navigateCtrl;
};
// refresh the canvas
canvasUtils.refreshCanvasView({
transition: true
});
};
}
NavigateCtrl.prototype = {
constructor: NavigateCtrl
}
var navigateCtrl = new NavigateCtrl();
return navigateCtrl;
};
}));

View File

@ -15,323 +15,207 @@
* limitations under the License.
*/
/* global nf, d3 */
/* global define, module, require, exports */
nf.ng.Canvas.OperateCtrl = function () {
(function (root, factory) {
if (typeof define === 'function' && define.amd) {
define(['jquery',
'd3',
'nf.Dialog',
'nf.Birdseye',
'nf.CanvasUtils',
'nf.Common',
'nf.Client',
'nf.Processor'],
function ($, d3, dialog, birdseye, canvasUtils, common, client, processor) {
return (nf.ng.Canvas.OperateCtrl = factory($, d3, dialog, birdseye, canvasUtils, common, client, processor));
});
} else if (typeof exports === 'object' && typeof module === 'object') {
module.exports = (nf.ng.Canvas.OperateCtrl =
factory(require('jquery'),
require('d3'),
require('nf.Dialog'),
require('nf.Birdseye'),
require('nf.CanvasUtils'),
require('nf.Common'),
require('nf.Client'),
require('nf.Processor')));
} else {
nf.ng.Canvas.OperateCtrl = factory(root.$,
root.d3,
root.nf.Dialog,
root.nf.Birdseye,
root.nf.CanvasUtils,
root.nf.Common,
root.nf.Client,
root.nf.Processor);
}
}(this, function ($, d3, dialog, birdseye, canvasUtils, common, client, processor) {
'use strict';
// updates the color if its a valid hex color string
var updateColor = function () {
var hex = $('#fill-color-value').val();
return function () {
'use strict';
// only update the fill color when its a valid hex color string
// #[six hex characters|three hex characters] case insensitive
if (/(^#[0-9A-F]{6}$)|(^#[0-9A-F]{3}$)/i.test(hex)) {
$('#fill-color').minicolors('value', hex);
}
};
// updates the color if its a valid hex color string
var updateColor = function () {
var hex = $('#fill-color-value').val();
function OperateCtrl() {
/**
* The canvas operator's create template component.
*/
this.template = {
/**
* The canvas operator's create template component's modal.
*/
modal: {
/**
* Gets the modal element.
*
* @returns {*|jQuery|HTMLElement}
*/
getElement: function () {
return $('#new-template-dialog');
},
/**
* Initialize the modal.
*/
init: function () {
// configure the create template dialog
this.getElement().modal({
scrollableContentStyle: 'scrollable',
headerText: 'Create Template'
});
},
/**
* Updates the modal config.
*
* @param {string} name The name of the property to update.
* @param {object|array} config The config for the `name`.
*/
update: function (name, config) {
this.getElement().modal(name, config);
},
/**
* Show the modal.
*/
show: function () {
this.getElement().modal('show');
},
/**
* Hide the modal.
*/
hide: function () {
this.getElement().modal('hide');
}
// only update the fill color when its a valid hex color string
// #[six hex characters|three hex characters] case insensitive
if (/(^#[0-9A-F]{6}$)|(^#[0-9A-F]{3}$)/i.test(hex)) {
$('#fill-color').minicolors('value', hex);
}
};
/**
* The canvas operator's create template component.
*/
this.templateUpload = {
function OperateCtrl() {
/**
* The canvas operator's create template component's modal.
* The canvas operator's create template component.
*/
modal: {
this.template = {
/**
* Gets the modal element.
*
* @returns {*|jQuery|HTMLElement}
* The canvas operator's create template component's modal.
*/
getElement: function () {
return $('#upload-template-dialog');
},
modal: {
/**
* Initialize the modal.
*/
init: function () {
// initialize the form
var templateForm = $('#template-upload-form').ajaxForm({
url: '../nifi-api/process-groups/',
dataType: 'xml',
beforeSubmit: function (formData, $form, options) {
// ensure uploading to the current process group
options.url += (encodeURIComponent(nf.Canvas.getGroupId()) + '/templates/upload');
},
success: function (response, statusText, xhr, form) {
// see if the import was successful and inform the user
if (response.documentElement.tagName === 'templateEntity') {
nf.Dialog.showOkDialog({
headerText: 'Success',
dialogContent: 'Template successfully imported.'
});
} else {
// import failed
var statusText = 'Unable to import template. Please check the log for errors.';
if (response.documentElement.tagName === 'errorResponse') {
// if a more specific error was given, use it
var errorMessage = response.documentElement.getAttribute('statusText');
if (!nf.Common.isBlank(errorMessage)) {
statusText = errorMessage;
}
}
/**
* Gets the modal element.
*
* @returns {*|jQuery|HTMLElement}
*/
getElement: function () {
return $('#new-template-dialog');
},
// show reason
nf.Dialog.showOkDialog({
headerText: 'Unable to Upload',
dialogContent: nf.Common.escapeHtml(statusText)
});
}
},
error: function (xhr, statusText, error) {
// request failed
nf.Dialog.showOkDialog({
headerText: 'Unable to Upload',
dialogContent: nf.Common.escapeHtml(xhr.responseText)
});
}
});
/**
* Initialize the modal.
*/
init: function () {
// configure the create template dialog
this.getElement().modal({
scrollableContentStyle: 'scrollable',
headerText: 'Create Template'
});
},
// configure the upload template dialog
this.getElement().modal({
headerText: 'Upload Template',
buttons: [{
buttonText: 'Upload',
color: {
base: '#728E9B',
hover: '#004849',
text: '#ffffff'
},
handler: {
click: function () {
var selectedTemplate = $('#selected-template-name').text();
/**
* Updates the modal config.
*
* @param {string} name The name of the property to update.
* @param {object|array} config The config for the `name`.
*/
update: function (name, config) {
this.getElement().modal(name, config);
},
// 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();
/**
* Show the modal.
*/
show: function () {
this.getElement().modal('show');
},
// hide the dialog
$('#upload-template-dialog').modal('hide');
}
}
}
}, {
buttonText: 'Cancel',
color: {
base: '#E3E8EB',
hover: '#C7D2D7',
text: '#004849'
},
handler: {
click: function () {
// hide the dialog
$('#upload-template-dialog').modal('hide');
}
}
}],
handler: {
close: 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();
}
}
});
// add a handler for the change file input chain event
$('#template-file-field').on('change', function (e) {
var filename = $(this).val();
if (!nf.Common.isBlank(filename)) {
filename = filename.replace(/^.*[\\\/]/, '');
}
// set the filename and clear any status
$('#selected-template-name').text(filename);
$('#upload-template-status').text('');
});
},
/**
* Updates the modal config.
*
* @param {string} name The name of the property to update.
* @param {object|array} config The config for the `name`.
*/
update: function (name, config) {
this.getElement().modal(name, config);
},
/**
* Show the modal.
*/
show: function () {
this.getElement().modal('show');
},
/**
* Hide the modal.
*/
hide: function () {
this.getElement().modal('hide');
/**
* Hide the modal.
*/
hide: function () {
this.getElement().modal('hide');
}
}
}
};
/**
* The canvas operator's fillcolor component.
*/
this.fillcolor = {
};
/**
* The canvas operator's fillcolor component's modal.
* The canvas operator's create template component.
*/
modal: {
this.templateUpload = {
/**
* Gets the modal element.
*
* @returns {*|jQuery|HTMLElement}
* The canvas operator's create template component's modal.
*/
getElement: function () {
return $('#fill-color-dialog');
},
modal: {
/**
* Initialize the modal.
*/
init: function () {
// configure the create fillcolor dialog
this.getElement().modal({
scrollableContentStyle: 'scrollable',
headerText: 'Change Color',
buttons: [{
buttonText: 'Apply',
color: {
base: '#728E9B',
hover: '#004849',
text: '#ffffff'
/**
* Gets the modal element.
*
* @returns {*|jQuery|HTMLElement}
*/
getElement: function () {
return $('#upload-template-dialog');
},
/**
* Initialize the modal.
*/
init: function () {
// initialize the form
var templateForm = $('#template-upload-form').ajaxForm({
url: '../nifi-api/process-groups/',
dataType: 'xml',
beforeSubmit: function (formData, $form, options) {
// ensure uploading to the current process group
options.url += (encodeURIComponent(canvasUtils.getGroupId()) + '/templates/upload');
},
handler: {
click: function () {
var selection = nf.CanvasUtils.getSelection();
// color the selected components
selection.each(function (d) {
var selected = d3.select(this);
var selectedData = selected.datum();
// get the color and update the styles
var color = $('#fill-color').minicolors('value');
// ensure the color actually changed
if (color !== selectedData.component.style['background-color']) {
// build the request entity
var entity = {
'revision': nf.Client.getRevision(selectedData),
'component': {
'id': selectedData.id,
'style': {
'background-color': color
}
}
};
// update the style for the specified component
$.ajax({
type: 'PUT',
url: selectedData.uri,
data: JSON.stringify(entity),
dataType: 'json',
contentType: 'application/json'
}).done(function (response) {
// update the component
nf[selectedData.type].set(response);
}).fail(function (xhr, status, error) {
if (xhr.status === 400 || xhr.status === 404 || xhr.status === 409) {
nf.Dialog.showOkDialog({
headerText: 'Error',
dialogContent: nf.Common.escapeHtml(xhr.responseText)
});
}
}).always(function(){
nf.Birdseye.refresh();
});
}
success: function (response, statusText, xhr, form) {
// see if the import was successful and inform the user
if (response.documentElement.tagName === 'templateEntity') {
dialog.showOkDialog({
headerText: 'Success',
dialogContent: 'Template successfully imported.'
});
} else {
// import failed
var statusText = 'Unable to import template. Please check the log for errors.';
if (response.documentElement.tagName === 'errorResponse') {
// if a more specific error was given, use it
var errorMessage = response.documentElement.getAttribute('statusText');
if (!common.isBlank(errorMessage)) {
statusText = errorMessage;
}
}
// close the dialog
$('#fill-color-dialog').modal('hide');
// show reason
dialog.showOkDialog({
headerText: 'Unable to Upload',
dialogContent: common.escapeHtml(statusText)
});
}
},
error: function (xhr, statusText, error) {
// request failed
dialog.showOkDialog({
headerText: 'Unable to Upload',
dialogContent: common.escapeHtml(xhr.responseText)
});
}
},
{
});
// configure the upload template dialog
this.getElement().modal({
headerText: 'Upload Template',
buttons: [{
buttonText: 'Upload',
color: {
base: '#728E9B',
hover: '#004849',
text: '#ffffff'
},
handler: {
click: function () {
var selectedTemplate = $('#selected-template-name').text();
// submit the template if necessary
if (common.isBlank(selectedTemplate)) {
$('#upload-template-status').text('No template selected. Please browse to select a template.');
} else {
templateForm.submit();
// hide the dialog
$('#upload-template-dialog').modal('hide');
}
}
}
}, {
buttonText: 'Cancel',
color: {
base: '#E3E8EB',
@ -340,130 +224,283 @@ nf.ng.Canvas.OperateCtrl = function () {
},
handler: {
click: function () {
// close the dialog
$('#fill-color-dialog').modal('hide');
// hide the dialog
$('#upload-template-dialog').modal('hide');
}
}
}],
handler: {
close: function () {
// clear the current color
$('#fill-color-value').val('');
$('#fill-color').minicolors('value', '');
handler: {
close: 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();
}
}
}
});
},
});
/**
* Updates the modal config.
*
* @param {string} name The name of the property to update.
* @param {object|array} config The config for the `name`.
*/
update: function (name, config) {
this.getElement().modal(name, config);
},
// add a handler for the change file input chain event
$('#template-file-field').on('change', function (e) {
var filename = $(this).val();
if (!common.isBlank(filename)) {
filename = filename.replace(/^.*[\\\/]/, '');
}
/**
* Show the modal.
*/
show: function () {
this.getElement().modal('show');
},
/**
* Hide the modal.
*/
hide: function () {
this.getElement().modal('hide');
},
/**
* The canvas operator's fillcolor component modal's minicolors.
*/
minicolors: {
// set the filename and clear any status
$('#selected-template-name').text(filename);
$('#upload-template-status').text('');
});
},
/**
* Gets the minicolors element.
* Updates the modal config.
*
* @param {string} name The name of the property to update.
* @param {object|array} config The config for the `name`.
*/
update: function (name, config) {
this.getElement().modal(name, config);
},
/**
* Show the modal.
*/
show: function () {
this.getElement().modal('show');
},
/**
* Hide the modal.
*/
hide: function () {
this.getElement().modal('hide');
}
}
};
/**
* The canvas operator's fillcolor component.
*/
this.fillcolor = {
/**
* The canvas operator's fillcolor component's modal.
*/
modal: {
/**
* Gets the modal element.
*
* @returns {*|jQuery|HTMLElement}
*/
getElement: function () {
return $('#fill-color');
return $('#fill-color-dialog');
},
/**
* Initialize the minicolors.
* Initialize the modal.
*/
init: function () {
// configure the minicolors
this.getElement().minicolors({
inline: true,
change: function (hex, opacity) {
// update the value
$('#fill-color-value').val(hex);
// configure the create fillcolor dialog
this.getElement().modal({
scrollableContentStyle: 'scrollable',
headerText: 'Change Color',
buttons: [{
buttonText: 'Apply',
color: {
base: '#728E9B',
hover: '#004849',
text: '#ffffff'
},
handler: {
click: function () {
var selection = canvasUtils.getSelection();
// always update the preview
if (hex.toLowerCase() === '#ffffff') {
//special case #ffffff implies default fill
$('#fill-color-processor-preview-icon').css({
'color': nf.Processor.defaultIconColor(),
'background-color': hex
});
} else {
$('#fill-color-processor-preview-icon').css({
'color': nf.Common.determineContrastColor(
nf.Common.substringAfterLast(
hex, '#')),
'background-color': hex
});
// color the selected components
selection.each(function (d) {
var selected = d3.select(this);
var selectedData = selected.datum();
// get the color and update the styles
var color = $('#fill-color').minicolors('value');
// ensure the color actually changed
if (color !== selectedData.component.style['background-color']) {
// build the request entity
var entity = {
'revision': client.getRevision(selectedData),
'component': {
'id': selectedData.id,
'style': {
'background-color': color
}
}
};
// update the style for the specified component
$.ajax({
type: 'PUT',
url: selectedData.uri,
data: JSON.stringify(entity),
dataType: 'json',
contentType: 'application/json'
}).done(function (response) {
// update the component
canvasUtils.getComponentByType(selectedData.type).set(response);
}).fail(function (xhr, status, error) {
if (xhr.status === 400 || xhr.status === 404 || xhr.status === 409) {
dialog.showOkDialog({
headerText: 'Error',
dialogContent: common.escapeHtml(xhr.responseText)
});
}
}).always(function () {
birdseye.refresh();
});
}
});
// close the dialog
$('#fill-color-dialog').modal('hide');
}
}
var borderColor = hex;
if (borderColor.toLowerCase() === '#ffffff') {
borderColor = 'rgba(0,0,0,0.25)';
},
{
buttonText: 'Cancel',
color: {
base: '#E3E8EB',
hover: '#C7D2D7',
text: '#004849'
},
handler: {
click: function () {
// close the dialog
$('#fill-color-dialog').modal('hide');
}
}
}],
handler: {
close: function () {
// clear the current color
$('#fill-color-value').val('');
$('#fill-color').minicolors('value', '');
}
$('#fill-color-processor-preview').css({
'border-color': borderColor
});
$('#fill-color-label-preview').css({
'background': hex
});
$('#fill-color-label-preview-value').css('color',
nf.Common.determineContrastColor(nf.Common.substringAfterLast(hex, '#'))
);
}
});
},
// apply fill color from field on blur and enter press
$('#fill-color-value').on('blur', updateColor).on('keyup', function (e) {
var code = e.keyCode ? e.keyCode : e.which;
if (code === $.ui.keyCode.ENTER) {
updateColor();
}
});
/**
* Updates the modal config.
*
* @param {string} name The name of the property to update.
* @param {object|array} config The config for the `name`.
*/
update: function (name, config) {
this.getElement().modal(name, config);
},
/**
* Show the modal.
*/
show: function () {
this.getElement().modal('show');
},
/**
* Hide the modal.
*/
hide: function () {
this.getElement().modal('hide');
},
/**
* The canvas operator's fillcolor component modal's minicolors.
*/
minicolors: {
/**
* Gets the minicolors element.
*
* @returns {*|jQuery|HTMLElement}
*/
getElement: function () {
return $('#fill-color');
},
/**
* Initialize the minicolors.
*/
init: function () {
// configure the minicolors
this.getElement().minicolors({
inline: true,
change: function (hex, opacity) {
// update the value
$('#fill-color-value').val(hex);
// always update the preview
if (hex.toLowerCase() === '#ffffff') {
//special case #ffffff implies default fill
$('#fill-color-processor-preview-icon').css({
'color': processor.defaultIconColor(),
'background-color': hex
});
} else {
$('#fill-color-processor-preview-icon').css({
'color': common.determineContrastColor(
common.substringAfterLast(
hex, '#')),
'background-color': hex
});
}
var borderColor = hex;
if (borderColor.toLowerCase() === '#ffffff') {
borderColor = 'rgba(0,0,0,0.25)';
}
$('#fill-color-processor-preview').css({
'border-color': borderColor
});
$('#fill-color-label-preview').css({
'background': hex
});
$('#fill-color-label-preview-value').css('color',
common.determineContrastColor(common.substringAfterLast(hex, '#'))
);
}
});
// apply fill color from field on blur and enter press
$('#fill-color-value').on('blur', updateColor).on('keyup', function (e) {
var code = e.keyCode ? e.keyCode : e.which;
if (code === $.ui.keyCode.ENTER) {
updateColor();
}
});
}
}
}
}
};
}
OperateCtrl.prototype = {
constructor: OperateCtrl,
/**
* Initializes the canvas operate controller.
*/
init: function () {
this.template.modal.init();
this.templateUpload.modal.init();
this.fillcolor.modal.init();
this.fillcolor.modal.minicolors.init();
};
}
}
var operateCtrl = new OperateCtrl();
return operateCtrl;
};
OperateCtrl.prototype = {
constructor: OperateCtrl,
/**
* Initializes the canvas operate controller.
*/
init: function () {
this.template.modal.init();
this.templateUpload.modal.init();
this.fillcolor.modal.init();
this.fillcolor.modal.minicolors.init();
}
}
var operateCtrl = new OperateCtrl();
return operateCtrl;
};
}));

View File

@ -15,134 +15,154 @@
* limitations under the License.
*/
/* global nf, d3 */
/* global define, module, require, exports */
nf.ng.Canvas.ToolboxCtrl = function (processorComponent,
inputPortComponent,
outputPortComponent,
groupComponent,
remoteGroupComponent,
funnelComponent,
templateComponent,
labelComponent) {
(function (root, factory) {
if (typeof define === 'function' && define.amd) {
define(['nf.CanvasUtils',
'nf.ContextMenu'],
function (canvasUtils, contextMenu) {
return (nf.ng.Canvas.ToolboxCtrl = factory(canvasUtils, contextMenu));
});
} else if (typeof exports === 'object' && typeof module === 'object') {
module.exports = (nf.ng.Canvas.ToolboxCtrl =
factory(require('nf.CanvasUtils'),
require('nf.ContextMenu')));
} else {
nf.ng.Canvas.ToolboxCtrl = factory(root.nf.CanvasUtils,
root.nf.ContextMenu);
}
}(this, function (canvasUtils, contextMenu) {
'use strict';
function ToolboxCtrl(processorComponent,
inputPortComponent,
outputPortComponent,
groupComponent,
remoteGroupComponent,
funnelComponent,
templateComponent,
labelComponent) {
this.processorComponent = processorComponent;
this.inputPortComponent = inputPortComponent;
this.outputPortComponent = outputPortComponent;
this.groupComponent = groupComponent;
this.remoteGroupComponent = remoteGroupComponent;
this.funnelComponent = funnelComponent;
this.templateComponent = templateComponent;
this.labelComponent = labelComponent;
return function (processorComponent,
inputPortComponent,
outputPortComponent,
groupComponent,
remoteGroupComponent,
funnelComponent,
templateComponent,
labelComponent) {
'use strict';
/**
* Config for the toolbox
*/
this.config = {
type: {
processor: 'Processor',
inputPort: 'Input Port',
outputPort: 'Output Port',
processGroup: 'Process Group',
remoteProcessGroup: 'Remote Process Group',
connection: 'Connection',
funnel: 'Funnel',
template: 'Template',
label: 'Label'
function ToolboxCtrl(processorComponent,
inputPortComponent,
outputPortComponent,
groupComponent,
remoteGroupComponent,
funnelComponent,
templateComponent,
labelComponent) {
this.processorComponent = processorComponent;
this.inputPortComponent = inputPortComponent;
this.outputPortComponent = outputPortComponent;
this.groupComponent = groupComponent;
this.remoteGroupComponent = remoteGroupComponent;
this.funnelComponent = funnelComponent;
this.templateComponent = templateComponent;
this.labelComponent = labelComponent;
/**
* Config for the toolbox
*/
this.config = {
type: {
processor: 'Processor',
inputPort: 'Input Port',
outputPort: 'Output Port',
processGroup: 'Process Group',
remoteProcessGroup: 'Remote Process Group',
connection: 'Connection',
funnel: 'Funnel',
template: 'Template',
label: 'Label'
},
urls: {
api: '../nifi-api',
controller: '../nifi-api/controller',
processorTypes: '../nifi-api/flow/processor-types'
}
};
}
ToolboxCtrl.prototype = {
constructor: ToolboxCtrl,
/**
* Initialize the toolbox controller.
*/
init: function () {
// initialize modal dialogs
processorComponent.modal.init();
inputPortComponent.modal.init();
outputPortComponent.modal.init();
groupComponent.modal.init();
remoteGroupComponent.modal.init();
templateComponent.modal.init();
},
urls: {
api: '../nifi-api',
controller: '../nifi-api/controller',
processorTypes: '../nifi-api/flow/processor-types'
}
};
}
ToolboxCtrl.prototype = {
constructor: ToolboxCtrl,
/**
* Initialize the toolbox controller.
*/
init: function() {
// initialize modal dialogs
processorComponent.modal.init();
inputPortComponent.modal.init();
outputPortComponent.modal.init();
groupComponent.modal.init();
remoteGroupComponent.modal.init();
templateComponent.modal.init();
},
/**
* Gets the draggable configuration for a toolbox component.
*
* @param {object} component The component responsible for handling the stop event.
* @returns {object} The draggable configuration.
*
* NOTE: The `component` must implement a dropHandler.
*/
draggableComponentConfig: function (component) {
/**
* Gets the draggable configuration for a toolbox component.
*
* @param {object} component The component responsible for handling the stop event.
* @returns {object} The draggable configuration.
*
* NOTE: The `component` must implement a dropHandler.
*/
draggableComponentConfig: function(component) {
//add hover effect
component.getElement().hover(function () {
component.getElement().removeClass(component.icon).addClass(component.hoverIcon);
}, function () {
component.getElement().removeClass(component.hoverIcon).addClass(component.icon);
})
//add hover effect
component.getElement().hover(function () {
component.getElement().removeClass(component.icon).addClass(component.hoverIcon);
}, function () {
component.getElement().removeClass(component.hoverIcon).addClass(component.icon);
})
return {
zIndex: 1011,
revert: true,
revertDuration: 0,
cancel: false,
containment: 'body',
cursor: '-webkit-grabbing',
start: function (e, ui) {
// hide the context menu if necessary
contextMenu.hide();
},
stop: function (e, ui) {
var translate = canvasUtils.translateCanvasView();
var scale = canvasUtils.scaleCanvasView();
return {
zIndex: 1011,
revert: true,
revertDuration: 0,
cancel: false,
containment: 'body',
cursor: '-webkit-grabbing',
start: function (e, ui) {
// hide the context menu if necessary
nf.ContextMenu.hide();
},
stop: function (e, ui) {
var translate = nf.Canvas.View.translate();
var scale = nf.Canvas.View.scale();
var mouseX = e.originalEvent.pageX;
var mouseY = e.originalEvent.pageY - canvasUtils.getCanvasOffset();
var mouseX = e.originalEvent.pageX;
var mouseY = e.originalEvent.pageY - nf.Canvas.CANVAS_OFFSET;
// invoke the drop handler if we're over the canvas
if (mouseX >= 0 && mouseY >= 0) {
// adjust the x and y coordinates accordingly
var x = (mouseX / scale) - (translate[0] / scale);
var y = (mouseY / scale) - (translate[1] / scale);
// invoke the drop handler if we're over the canvas
if (mouseX >= 0 && mouseY >= 0) {
// adjust the x and y coordinates accordingly
var x = (mouseX / scale) - (translate[0] / scale);
var y = (mouseY / scale) - (translate[1] / scale);
//each component must implement a dropHandler function
component.dropHandler.apply(component, [{
x: x,
y: y
}]);
}
},
helper: component.dragIcon
//each component must implement a dropHandler function
component.dropHandler.apply(component, [{
x: x,
y: y
}]);
}
},
helper: component.dragIcon
}
}
}
}
var toolboxCtrl =
new ToolboxCtrl(processorComponent,
inputPortComponent,
outputPortComponent,
groupComponent,
remoteGroupComponent,
funnelComponent,
templateComponent,
labelComponent);
return toolboxCtrl;
};
var toolboxCtrl =
new ToolboxCtrl(processorComponent,
inputPortComponent,
outputPortComponent,
groupComponent,
remoteGroupComponent,
funnelComponent,
templateComponent,
labelComponent);
return toolboxCtrl;
};
}));

View File

@ -15,20 +15,36 @@
* limitations under the License.
*/
/* global nf, d3 */
/* global define, module, require, exports */
nf.ng.BreadcrumbsDirective = function (breadcrumbsCtrl) {
return {
restrict: 'E',
templateUrl: 'views/nf-ng-breadcrumbs-directive-view.html',
scope: {
'breadcrumbs': '=',
'clickFunc': '=',
'highlightCrumbId': '=',
'separatorFunc': '='
},
link: function (scope, element, attrs) {
breadcrumbsCtrl.registerMouseWheelEvent(element);
}
(function (root, factory) {
if (typeof define === 'function' && define.amd) {
define([],
function () {
return (nf.ng.BreadcrumbsDirective = factory());
});
} else if (typeof exports === 'object' && typeof module === 'object') {
module.exports = (nf.ng.BreadcrumbsDirective =
factory());
} else {
nf.ng.BreadcrumbsDirective = factory();
}
}(this, function () {
'use strict';
return function (breadcrumbsCtrl) {
return {
restrict: 'E',
templateUrl: 'views/nf-ng-breadcrumbs-directive-view.html',
scope: {
'breadcrumbs': '=',
'clickFunc': '=',
'highlightCrumbId': '=',
'separatorFunc': '='
},
link: function (scope, element, attrs) {
breadcrumbsCtrl.registerMouseWheelEvent(element);
}
};
};
};
}));

View File

@ -15,13 +15,29 @@
* limitations under the License.
*/
/* global nf, d3 */
/* global define, module, require, exports */
nf.ng.DraggableDirective = function () {
return {
restrict: 'AE',
link: function (scope, element, attrs) {
element.draggable(scope.$eval(attrs.nfDraggable));
}
(function (root, factory) {
if (typeof define === 'function' && define.amd) {
define([],
function () {
return (nf.ng.DraggableDirective = factory());
});
} else if (typeof exports === 'object' && typeof module === 'object') {
module.exports = (nf.ng.DraggableDirective =
factory());
} else {
nf.ng.DraggableDirective = factory();
}
}(this, function () {
'use strict';
return function () {
return {
restrict: 'AE',
link: function (scope, element, attrs) {
element.draggable(scope.$eval(attrs.nfDraggable));
}
};
};
};
}));

View File

@ -15,102 +15,134 @@
* limitations under the License.
*/
/* global nf, d3 */
/* global define, module, require, exports */
nf.ng.FunnelComponent = function (serviceProvider) {
(function (root, factory) {
if (typeof define === 'function' && define.amd) {
define(['jquery',
'nf.Client',
'nf.Birdseye',
'nf.Graph',
'nf.CanvasUtils',
'nf.ErrorHandler'],
function ($, client, birdseye, graph, canvasUtils, errorHandler) {
return (nf.ng.FunnelComponent = factory($, client, birdseye, graph, canvasUtils, errorHandler));
});
} else if (typeof exports === 'object' && typeof module === 'object') {
module.exports = (nf.ng.FunnelComponent =
factory(require('jquery'),
require('nf.Client'),
require('nf.Birdseye'),
require('nf.Graph'),
require('nf.CanvasUtils'),
require('nf.ErrorHandler')));
} else {
nf.ng.FunnelComponent = factory(root.$,
root.nf.Client,
root.nf.Birdseye,
root.nf.Graph,
root.nf.CanvasUtils,
root.nf.ErrorHandler);
}
}(this, function ($, client, birdseye, graph, canvasUtils, errorHandler) {
'use strict';
function FunnelComponent() {
this.icon = 'icon icon-funnel';
return function (serviceProvider) {
'use strict';
this.hoverIcon = 'icon icon-funnel-add';
}
FunnelComponent.prototype = {
constructor: FunnelComponent,
function FunnelComponent() {
this.icon = 'icon icon-funnel';
/**
* Gets the component.
*
* @returns {*|jQuery|HTMLElement}
*/
getElement: function() {
return $('#funnel-component');
},
/**
* Enable the component.
*/
enabled: function() {
this.getElement().attr('disabled', false);
},
/**
* Disable the component.
*/
disabled: function() {
this.getElement().attr('disabled', true);
},
/**
* Handler function for when component is dropped on the canvas.
*
* @argument {object} pt The point that the component was dropped.
*/
dropHandler: function(pt) {
this.createFunnel(pt);
},
/**
* The drag icon for the toolbox component.
*
* @param event
* @returns {*|jQuery|HTMLElement}
*/
dragIcon: function (event) {
return $('<div class="icon icon-funnel-add"></div>');
},
/**
* Creates a new funnel at the specified point.
*
* @argument {object} pt The point that the funnel was dropped.
*/
createFunnel: function(pt) {
var outputPortEntity = {
'revision': nf.Client.getRevision({
'revision': {
'version': 0
}
}),
'component': {
'position': {
'x': pt.x,
'y': pt.y
}
}
};
// create a new funnel
$.ajax({
type: 'POST',
url: serviceProvider.headerCtrl.toolboxCtrl.config.urls.api + '/process-groups/' + encodeURIComponent(nf.Canvas.getGroupId()) + '/funnels',
data: JSON.stringify(outputPortEntity),
dataType: 'json',
contentType: 'application/json'
}).done(function (response) {
// add the funnel to the graph
nf.Graph.add({
'funnels': [response]
}, {
'selectAll': true
});
// update the birdseye
nf.Birdseye.refresh();
}).fail(nf.ErrorHandler.handleAjaxError);
this.hoverIcon = 'icon icon-funnel-add';
}
}
var funnelComponent = new FunnelComponent();
return funnelComponent;
};
FunnelComponent.prototype = {
constructor: FunnelComponent,
/**
* Gets the component.
*
* @returns {*|jQuery|HTMLElement}
*/
getElement: function () {
return $('#funnel-component');
},
/**
* Enable the component.
*/
enabled: function () {
this.getElement().attr('disabled', false);
},
/**
* Disable the component.
*/
disabled: function () {
this.getElement().attr('disabled', true);
},
/**
* Handler function for when component is dropped on the canvas.
*
* @argument {object} pt The point that the component was dropped.
*/
dropHandler: function (pt) {
this.createFunnel(pt);
},
/**
* The drag icon for the toolbox component.
*
* @param event
* @returns {*|jQuery|HTMLElement}
*/
dragIcon: function (event) {
return $('<div class="icon icon-funnel-add"></div>');
},
/**
* Creates a new funnel at the specified point.
*
* @argument {object} pt The point that the funnel was dropped.
*/
createFunnel: function (pt) {
var outputPortEntity = {
'revision': client.getRevision({
'revision': {
'version': 0
}
}),
'component': {
'position': {
'x': pt.x,
'y': pt.y
}
}
};
// create a new funnel
$.ajax({
type: 'POST',
url: serviceProvider.headerCtrl.toolboxCtrl.config.urls.api + '/process-groups/' + encodeURIComponent(canvasUtils.getGroupId()) + '/funnels',
data: JSON.stringify(outputPortEntity),
dataType: 'json',
contentType: 'application/json'
}).done(function (response) {
// add the funnel to the graph
graph.add({
'funnels': [response]
}, {
'selectAll': true
});
// update the birdseye
birdseye.refresh();
}).fail(errorHandler.handleAjaxError);
}
}
var funnelComponent = new FunnelComponent();
return funnelComponent;
};
}));

View File

@ -15,229 +15,260 @@
* limitations under the License.
*/
/* global nf, d3 */
/* global define, module, require, exports */
nf.ng.GroupComponent = function (serviceProvider) {
(function (root, factory) {
if (typeof define === 'function' && define.amd) {
define(['jquery',
'nf.Client',
'nf.Birdseye',
'nf.Graph',
'nf.CanvasUtils',
'nf.ErrorHandler'],
function ($, client, birdseye, graph, canvasUtils, errorHandler) {
return (nf.ng.GroupComponent = factory($, client, birdseye, graph, canvasUtils, errorHandler));
});
} else if (typeof exports === 'object' && typeof module === 'object') {
module.exports = (nf.ng.GroupComponent =
factory(require('jquery'),
require('nf.Client'),
require('nf.Birdseye'),
require('nf.Graph'),
require('nf.CanvasUtils'),
require('nf.ErrorHandler')));
} else {
nf.ng.GroupComponent = factory(root.$,
root.nf.Client,
root.nf.Birdseye,
root.nf.Graph,
root.nf.CanvasUtils,
root.nf.ErrorHandler);
}
}(this, function ($, client, birdseye, graph, canvasUtils, errorHandler) {
'use strict';
/**
* Create the group and add to the graph.
*
* @argument {string} groupName The name of the group.
* @argument {object} pt The point that the group was dropped.
*/
var createGroup = function (groupName, pt) {
var processGroupEntity = {
'revision': nf.Client.getRevision({
'revision': {
'version': 0
}
}),
'component': {
'name': groupName,
'position': {
'x': pt.x,
'y': pt.y
}
}
};
// create a new processor of the defined type
return $.ajax({
type: 'POST',
url: serviceProvider.headerCtrl.toolboxCtrl.config.urls.api + '/process-groups/' + encodeURIComponent(nf.Canvas.getGroupId()) + '/process-groups',
data: JSON.stringify(processGroupEntity),
dataType: 'json',
contentType: 'application/json'
}).done(function (response) {
// add the process group to the graph
nf.Graph.add({
'processGroups': [response]
}, {
'selectAll': true
});
// update component visibility
nf.Canvas.View.updateVisibility();
// update the birdseye
nf.Birdseye.refresh();
}).fail(nf.ErrorHandler.handleAjaxError);
};
function GroupComponent() {
this.icon = 'icon icon-group';
this.hoverIcon = 'icon icon-group-add';
return function (serviceProvider) {
'use strict';
/**
* The group component's modal.
* Create the group and add to the graph.
*
* @argument {string} groupName The name of the group.
* @argument {object} pt The point that the group was dropped.
*/
this.modal = {
var createGroup = function (groupName, pt) {
var processGroupEntity = {
'revision': client.getRevision({
'revision': {
'version': 0
}
}),
'component': {
'name': groupName,
'position': {
'x': pt.x,
'y': pt.y
}
}
};
// create a new processor of the defined type
return $.ajax({
type: 'POST',
url: serviceProvider.headerCtrl.toolboxCtrl.config.urls.api + '/process-groups/' + encodeURIComponent(canvasUtils.getGroupId()) + '/process-groups',
data: JSON.stringify(processGroupEntity),
dataType: 'json',
contentType: 'application/json'
}).done(function (response) {
// add the process group to the graph
graph.add({
'processGroups': [response]
}, {
'selectAll': true
});
// update component visibility
graph.updateVisibility();
// update the birdseye
birdseye.refresh();
}).fail(errorHandler.handleAjaxError);
};
function GroupComponent() {
this.icon = 'icon icon-group';
this.hoverIcon = 'icon icon-group-add';
/**
* Gets the modal element.
* The group component's modal.
*/
this.modal = {
/**
* Gets the modal element.
*
* @returns {*|jQuery|HTMLElement}
*/
getElement: function () {
return $('#new-process-group-dialog');
},
/**
* Initialize the modal.
*/
init: function () {
// configure the new process group dialog
this.getElement().modal({
scrollableContentStyle: 'scrollable',
headerText: 'Add Process Group',
handler: {
close: function () {
$('#new-process-group-name').val('');
}
}
});
},
/**
* Updates the modal config.
*
* @param {string} name The name of the property to update.
* @param {object|array} config The config for the `name`.
*/
update: function (name, config) {
this.getElement().modal(name, config);
},
/**
* Show the modal.
*/
show: function () {
this.getElement().modal('show');
},
/**
* Hide the modal.
*/
hide: function () {
this.getElement().modal('hide');
}
};
}
GroupComponent.prototype = {
constructor: GroupComponent,
/**
* Gets the component.
*
* @returns {*|jQuery|HTMLElement}
*/
getElement: function () {
return $('#new-process-group-dialog');
return $('#group-component');
},
/**
* Initialize the modal.
* Enable the component.
*/
init: function () {
// configure the new process group dialog
this.getElement().modal({
scrollableContentStyle: 'scrollable',
headerText: 'Add Process Group',
handler: {
close: function () {
$('#new-process-group-name').val('');
}
}
});
enabled: function () {
this.getElement().attr('disabled', false);
},
/**
* Updates the modal config.
* Disable the component.
*/
disabled: function () {
this.getElement().attr('disabled', true);
},
/**
* Handler function for when component is dropped on the canvas.
*
* @param {string} name The name of the property to update.
* @param {object|array} config The config for the `name`.
* @argument {object} pt The point that the component was dropped.
*/
update: function (name, config) {
this.getElement().modal(name, config);
dropHandler: function (pt) {
this.promptForGroupName(pt);
},
/**
* Show the modal.
* The drag icon for the toolbox component.
*
* @param event
* @returns {*|jQuery|HTMLElement}
*/
show: function () {
this.getElement().modal('show');
dragIcon: function (event) {
return $('<div class="icon icon-group-add"></div>');
},
/**
* Hide the modal.
* Prompts the user to enter the name for the group.
*
* @argument {object} pt The point that the group was dropped.
*/
hide: function () {
this.getElement().modal('hide');
}
};
}
promptForGroupName: function (pt) {
var groupComponent = this;
return $.Deferred(function (deferred) {
var addGroup = function () {
// get the name of the group and clear the textfield
var groupName = $('#new-process-group-name').val();
GroupComponent.prototype = {
constructor: GroupComponent,
// hide the dialog
groupComponent.modal.hide();
/**
* Gets the component.
*
* @returns {*|jQuery|HTMLElement}
*/
getElement: function () {
return $('#group-component');
},
// create the group and resolve the deferred accordingly
createGroup(groupName, pt).done(function (response) {
deferred.resolve(response.component);
}).fail(function () {
deferred.reject();
});
};
/**
* Enable the component.
*/
enabled: function () {
this.getElement().attr('disabled', false);
},
/**
* Disable the component.
*/
disabled: function () {
this.getElement().attr('disabled', true);
},
/**
* Handler function for when component is dropped on the canvas.
*
* @argument {object} pt The point that the component was dropped.
*/
dropHandler: function (pt) {
this.promptForGroupName(pt);
},
/**
* The drag icon for the toolbox component.
*
* @param event
* @returns {*|jQuery|HTMLElement}
*/
dragIcon: function (event) {
return $('<div class="icon icon-group-add"></div>');
},
/**
* Prompts the user to enter the name for the group.
*
* @argument {object} pt The point that the group was dropped.
*/
promptForGroupName: function (pt) {
var groupComponent = this;
return $.Deferred(function (deferred) {
var addGroup = function () {
// get the name of the group and clear the textfield
var groupName = $('#new-process-group-name').val();
// hide the dialog
groupComponent.modal.hide();
// create the group and resolve the deferred accordingly
createGroup(groupName, pt).done(function (response) {
deferred.resolve(response.component);
}).fail(function () {
deferred.reject();
});
};
groupComponent.modal.update('setButtonModel', [{
buttonText: 'Add',
color: {
base: '#728E9B',
hover: '#004849',
text: '#ffffff'
},
handler: {
click: addGroup
}
},
{
buttonText: 'Cancel',
groupComponent.modal.update('setButtonModel', [{
buttonText: 'Add',
color: {
base: '#E3E8EB',
hover: '#C7D2D7',
text: '#004849'
base: '#728E9B',
hover: '#004849',
text: '#ffffff'
},
handler: {
click: function () {
// reject the deferred
deferred.reject();
// close the dialog
groupComponent.modal.hide();
}
click: addGroup
}
}]);
},
{
buttonText: 'Cancel',
color: {
base: '#E3E8EB',
hover: '#C7D2D7',
text: '#004849'
},
handler: {
click: function () {
// reject the deferred
deferred.reject();
// show the dialog
groupComponent.modal.show();
// close the dialog
groupComponent.modal.hide();
}
}
}]);
// set up the focus and key handlers
$('#new-process-group-name').focus().off('keyup').on('keyup', function (e) {
var code = e.keyCode ? e.keyCode : e.which;
if (code === $.ui.keyCode.ENTER) {
addGroup();
}
});
}).promise();
// show the dialog
groupComponent.modal.show();
// set up the focus and key handlers
$('#new-process-group-name').focus().off('keyup').on('keyup', function (e) {
var code = e.keyCode ? e.keyCode : e.which;
if (code === $.ui.keyCode.ENTER) {
addGroup();
}
});
}).promise();
}
}
}
var groupComponent = new GroupComponent();
return groupComponent;
};
var groupComponent = new GroupComponent();
return groupComponent;
};
}));

View File

@ -15,222 +15,253 @@
* limitations under the License.
*/
/* global nf, d3 */
/* global define, module, require, exports */
nf.ng.InputPortComponent = function (serviceProvider) {
(function (root, factory) {
if (typeof define === 'function' && define.amd) {
define(['jquery',
'nf.Client',
'nf.Birdseye',
'nf.Graph',
'nf.CanvasUtils',
'nf.ErrorHandler'],
function ($, client, birdseye, graph, canvasUtils, errorHandler) {
return (nf.ng.InputPortComponent = factory($, client, birdseye, graph, canvasUtils, errorHandler));
});
} else if (typeof exports === 'object' && typeof module === 'object') {
module.exports = (nf.ng.InputPortComponent =
factory(require('jquery'),
require('nf.Client'),
require('nf.Birdseye'),
require('nf.Graph'),
require('nf.CanvasUtils'),
require('nf.ErrorHandler')));
} else {
nf.ng.InputPortComponent = factory(root.$,
root.nf.Client,
root.nf.Birdseye,
root.nf.Graph,
root.nf.CanvasUtils,
root.nf.ErrorHandler);
}
}(this, function ($, client, birdseye, graph, canvasUtils, errorHandler) {
'use strict';
/**
* Create the input port and add to the graph.
*
* @argument {string} portName The input port name.
* @argument {object} pt The point that the input port was dropped.
*/
var createInputPort = function (portName, pt) {
var inputPortEntity = {
'revision': nf.Client.getRevision({
'revision': {
'version': 0
}
}),
'component': {
'name': portName,
'position': {
'x': pt.x,
'y': pt.y
}
}
};
// create a new processor of the defined type
$.ajax({
type: 'POST',
url: serviceProvider.headerCtrl.toolboxCtrl.config.urls.api + '/process-groups/' + encodeURIComponent(nf.Canvas.getGroupId()) + '/input-ports',
data: JSON.stringify(inputPortEntity),
dataType: 'json',
contentType: 'application/json'
}).done(function (response) {
// add the port to the graph
nf.Graph.add({
'inputPorts': [response]
}, {
'selectAll': true
});
// update component visibility
nf.Canvas.View.updateVisibility();
// update the birdseye
nf.Birdseye.refresh();
}).fail(nf.ErrorHandler.handleAjaxError);
};
function InputPortComponent() {
this.icon = 'icon icon-port-in';
this.hoverIcon = 'icon icon-port-in-add';
return function (serviceProvider) {
'use strict';
/**
* The input port component's modal.
* Create the input port and add to the graph.
*
* @argument {string} portName The input port name.
* @argument {object} pt The point that the input port was dropped.
*/
this.modal = {
var createInputPort = function (portName, pt) {
var inputPortEntity = {
'revision': client.getRevision({
'revision': {
'version': 0
}
}),
'component': {
'name': portName,
'position': {
'x': pt.x,
'y': pt.y
}
}
};
// create a new processor of the defined type
$.ajax({
type: 'POST',
url: serviceProvider.headerCtrl.toolboxCtrl.config.urls.api + '/process-groups/' + encodeURIComponent(canvasUtils.getGroupId()) + '/input-ports',
data: JSON.stringify(inputPortEntity),
dataType: 'json',
contentType: 'application/json'
}).done(function (response) {
// add the port to the graph
graph.add({
'inputPorts': [response]
}, {
'selectAll': true
});
// update component visibility
graph.updateVisibility();
// update the birdseye
birdseye.refresh();
}).fail(errorHandler.handleAjaxError);
};
function InputPortComponent() {
this.icon = 'icon icon-port-in';
this.hoverIcon = 'icon icon-port-in-add';
/**
* Gets the modal element.
* The input port component's modal.
*/
this.modal = {
/**
* Gets the modal element.
*
* @returns {*|jQuery|HTMLElement}
*/
getElement: function () {
return $('#new-port-dialog');
},
/**
* Initialize the modal.
*/
init: function () {
// configure the new port dialog
this.getElement().modal({
scrollableContentStyle: 'scrollable',
headerText: 'Add Port',
handler: {
close: function () {
$('#new-port-name').val('');
}
}
});
},
/**
* Updates the modal config.
*
* @param {string} name The name of the property to update.
* @param {object|array} config The config for the `name`.
*/
update: function (name, config) {
this.getElement().modal(name, config);
},
/**
* Show the modal.
*/
show: function () {
this.getElement().modal('show');
},
/**
* Hide the modal.
*/
hide: function () {
this.getElement().modal('hide');
}
};
}
InputPortComponent.prototype = {
constructor: InputPortComponent,
/**
* Gets the component.
*
* @returns {*|jQuery|HTMLElement}
*/
getElement: function () {
return $('#new-port-dialog');
return $('#port-in-component');
},
/**
* Initialize the modal.
* Enable the component.
*/
init: function () {
// configure the new port dialog
this.getElement().modal({
scrollableContentStyle: 'scrollable',
headerText: 'Add Port',
handler: {
close: function () {
$('#new-port-name').val('');
}
}
});
enabled: function () {
this.getElement().attr('disabled', false);
},
/**
* Updates the modal config.
* Disable the component.
*/
disabled: function () {
this.getElement().attr('disabled', true);
},
/**
* Handler function for when component is dropped on the canvas.
*
* @param {string} name The name of the property to update.
* @param {object|array} config The config for the `name`.
* @argument {object} pt The point that the component was dropped.
*/
update: function (name, config) {
this.getElement().modal(name, config);
dropHandler: function (pt) {
this.promptForInputPortName(pt);
},
/**
* Show the modal.
* The drag icon for the toolbox component.
*
* @param event
* @returns {*|jQuery|HTMLElement}
*/
show: function () {
this.getElement().modal('show');
dragIcon: function (event) {
return $('<div class="icon icon-port-in-add"></div>');
},
/**
* Hide the modal.
* Prompts the user to enter the name for the input port.
*
* @argument {object} pt The point that the input port was dropped.
*/
hide: function () {
this.getElement().modal('hide');
}
};
}
promptForInputPortName: function (pt) {
var inputPortComponent = this;
var addInputPort = function () {
// get the name of the input port and clear the textfield
var portName = $('#new-port-name').val();
InputPortComponent.prototype = {
constructor: InputPortComponent,
// hide the dialog
inputPortComponent.modal.hide();
/**
* Gets the component.
*
* @returns {*|jQuery|HTMLElement}
*/
getElement: function () {
return $('#port-in-component');
},
// create the input port
createInputPort(portName, pt);
};
/**
* Enable the component.
*/
enabled: function () {
this.getElement().attr('disabled', false);
},
/**
* Disable the component.
*/
disabled: function () {
this.getElement().attr('disabled', true);
},
/**
* Handler function for when component is dropped on the canvas.
*
* @argument {object} pt The point that the component was dropped.
*/
dropHandler: function (pt) {
this.promptForInputPortName(pt);
},
/**
* The drag icon for the toolbox component.
*
* @param event
* @returns {*|jQuery|HTMLElement}
*/
dragIcon: function (event) {
return $('<div class="icon icon-port-in-add"></div>');
},
/**
* Prompts the user to enter the name for the input port.
*
* @argument {object} pt The point that the input port was dropped.
*/
promptForInputPortName: function (pt) {
var inputPortComponent = this;
var addInputPort = function () {
// get the name of the input port and clear the textfield
var portName = $('#new-port-name').val();
// hide the dialog
inputPortComponent.modal.hide();
// create the input port
createInputPort(portName, pt);
};
this.modal.update('setButtonModel', [{
buttonText: 'Add',
color: {
base: '#728E9B',
hover: '#004849',
text: '#ffffff'
},
handler: {
click: addInputPort
}
},
{
buttonText: 'Cancel',
this.modal.update('setButtonModel', [{
buttonText: 'Add',
color: {
base: '#E3E8EB',
hover: '#C7D2D7',
text: '#004849'
base: '#728E9B',
hover: '#004849',
text: '#ffffff'
},
handler: {
click: function () {
inputPortComponent.modal.hide();
}
click: addInputPort
}
}]);
},
{
buttonText: 'Cancel',
color: {
base: '#E3E8EB',
hover: '#C7D2D7',
text: '#004849'
},
handler: {
click: function () {
inputPortComponent.modal.hide();
}
}
}]);
// update the port type
$('#new-port-type').text('Input');
// update the port type
$('#new-port-type').text('Input');
// show the dialog
this.modal.show();
// show the dialog
this.modal.show();
// set up the focus and key handlers
$('#new-port-name').focus().off('keyup').on('keyup', function (e) {
var code = e.keyCode ? e.keyCode : e.which;
if (code === $.ui.keyCode.ENTER) {
addInputPort();
}
});
// set up the focus and key handlers
$('#new-port-name').focus().off('keyup').on('keyup', function (e) {
var code = e.keyCode ? e.keyCode : e.which;
if (code === $.ui.keyCode.ENTER) {
addInputPort();
}
});
}
}
}
var inputPortComponent = new InputPortComponent();
return inputPortComponent;
};
var inputPortComponent = new InputPortComponent();
return inputPortComponent;
};
}));

View File

@ -15,104 +15,139 @@
* limitations under the License.
*/
/* global nf, d3 */
/* global define, module, require, exports */
nf.ng.LabelComponent = function (serviceProvider) {
(function (root, factory) {
if (typeof define === 'function' && define.amd) {
define(['jquery',
'nf.Client',
'nf.Birdseye',
'nf.Graph',
'nf.CanvasUtils',
'nf.ErrorHandler',
'nf.Label'],
function ($, client, birdseye, graph, canvasUtils, errorHandler, label) {
return (nf.ng.LabelComponent = factory($, client, birdseye, graph, canvasUtils, errorHandler, label));
});
} else if (typeof exports === 'object' && typeof module === 'object') {
module.exports = (nf.ng.LabelComponent =
factory(require('jquery'),
require('nf.Client'),
require('nf.Birdseye'),
require('nf.Graph'),
require('nf.CanvasUtils'),
require('nf.ErrorHandler'),
require('nf.Label')));
} else {
nf.ng.LabelComponent = factory(root.$,
root.nf.Client,
root.nf.Birdseye,
root.nf.Graph,
root.nf.CanvasUtils,
root.nf.ErrorHandler,
root.nf.Label);
}
}(this, function ($, client, birdseye, graph, canvasUtils, errorHandler, label) {
'use strict';
function LabelComponent() {
this.icon = 'icon icon-label';
return function (serviceProvider) {
'use strict';
this.hoverIcon = 'icon icon-label-add';
}
LabelComponent.prototype = {
constructor: LabelComponent,
function LabelComponent() {
this.icon = 'icon icon-label';
/**
* Gets the component.
*
* @returns {*|jQuery|HTMLElement}
*/
getElement: function() {
return $('#label-component');
},
/**
* Enable the component.
*/
enabled: function() {
this.getElement().attr('disabled', false);
},
/**
* Disable the component.
*/
disabled: function() {
this.getElement().attr('disabled', true);
},
/**
* Handler function for when component is dropped on the canvas.
*
* @argument {object} pt The point that the component was dropped.
*/
dropHandler: function(pt) {
this.createLabel(pt);
},
/**
* The drag icon for the toolbox component.
*
* @param event
* @returns {*|jQuery|HTMLElement}
*/
dragIcon: function (event) {
return $('<div class="icon icon-label-add"></div>');
},
/**
* Create the label and add to the graph.
*
* @argument {object} pt The point that the label was dropped.
*/
createLabel: function(pt) {
var labelEntity = {
'revision': nf.Client.getRevision({
'revision': {
'version': 0
}
}),
'component': {
'width': nf.Label.config.width,
'height': nf.Label.config.height,
'position': {
'x': pt.x,
'y': pt.y
}
}
};
// create a new label
$.ajax({
type: 'POST',
url: serviceProvider.headerCtrl.toolboxCtrl.config.urls.api + '/process-groups/' + encodeURIComponent(nf.Canvas.getGroupId()) + '/labels',
data: JSON.stringify(labelEntity),
dataType: 'json',
contentType: 'application/json'
}).done(function (response) {
// add the label to the graph
nf.Graph.add({
'labels': [response]
}, {
'selectAll': true
});
// update the birdseye
nf.Birdseye.refresh();
}).fail(nf.ErrorHandler.handleAjaxError);
this.hoverIcon = 'icon icon-label-add';
}
}
var labelComponent = new LabelComponent();
return labelComponent;
};
LabelComponent.prototype = {
constructor: LabelComponent,
/**
* Gets the component.
*
* @returns {*|jQuery|HTMLElement}
*/
getElement: function () {
return $('#label-component');
},
/**
* Enable the component.
*/
enabled: function () {
this.getElement().attr('disabled', false);
},
/**
* Disable the component.
*/
disabled: function () {
this.getElement().attr('disabled', true);
},
/**
* Handler function for when component is dropped on the canvas.
*
* @argument {object} pt The point that the component was dropped.
*/
dropHandler: function (pt) {
this.createLabel(pt);
},
/**
* The drag icon for the toolbox component.
*
* @param event
* @returns {*|jQuery|HTMLElement}
*/
dragIcon: function (event) {
return $('<div class="icon icon-label-add"></div>');
},
/**
* Create the label and add to the graph.
*
* @argument {object} pt The point that the label was dropped.
*/
createLabel: function (pt) {
var labelEntity = {
'revision': client.getRevision({
'revision': {
'version': 0
}
}),
'component': {
'width': label.config.width,
'height': label.config.height,
'position': {
'x': pt.x,
'y': pt.y
}
}
};
// create a new label
$.ajax({
type: 'POST',
url: serviceProvider.headerCtrl.toolboxCtrl.config.urls.api + '/process-groups/' + encodeURIComponent(canvasUtils.getGroupId()) + '/labels',
data: JSON.stringify(labelEntity),
dataType: 'json',
contentType: 'application/json'
}).done(function (response) {
// add the label to the graph
graph.add({
'labels': [response]
}, {
'selectAll': true
});
// update the birdseye
birdseye.refresh();
}).fail(errorHandler.handleAjaxError);
}
}
var labelComponent = new LabelComponent();
return labelComponent;
};
}));

View File

@ -15,213 +15,244 @@
* limitations under the License.
*/
/* global nf, d3 */
/* global define, module, require, exports */
nf.ng.OutputPortComponent = function (serviceProvider) {
(function (root, factory) {
if (typeof define === 'function' && define.amd) {
define(['jquery',
'nf.Client',
'nf.Birdseye',
'nf.Graph',
'nf.CanvasUtils',
'nf.ErrorHandler'],
function ($, client, birdseye, graph, canvasUtils, errorHandler) {
return (nf.ng.OutputPortComponent = factory($, client, birdseye, graph, canvasUtils, errorHandler));
});
} else if (typeof exports === 'object' && typeof module === 'object') {
module.exports = (nf.ng.OutputPortComponent =
factory(require('jquery'),
require('nf.Client'),
require('nf.Birdseye'),
require('nf.Graph'),
require('nf.CanvasUtils'),
require('nf.ErrorHandler')));
} else {
nf.ng.OutputPortComponent = factory(root.$,
root.nf.Client,
root.nf.Birdseye,
root.nf.Graph,
root.nf.CanvasUtils,
root.nf.ErrorHandler);
}
}(this, function ($, client, birdseye, graph, canvasUtils, errorHandler) {
'use strict';
/**
* Create the input port and add to the graph.
*
* @argument {string} portName The output port name.
* @argument {object} pt The point that the output port was dropped.
*/
var createOutputPort = function (portName, pt) {
var outputPortEntity = {
'revision': nf.Client.getRevision({
'revision': {
'version': 0
}
}),
'component': {
'name': portName,
'position': {
'x': pt.x,
'y': pt.y
}
}
};
// create a new processor of the defined type
$.ajax({
type: 'POST',
url: serviceProvider.headerCtrl.toolboxCtrl.config.urls.api + '/process-groups/' + encodeURIComponent(nf.Canvas.getGroupId()) + '/output-ports',
data: JSON.stringify(outputPortEntity),
dataType: 'json',
contentType: 'application/json'
}).done(function (response) {
// add the port to the graph
nf.Graph.add({
'outputPorts': [response]
}, {
'selectAll': true
});
// update component visibility
nf.Canvas.View.updateVisibility();
// update the birdseye
nf.Birdseye.refresh();
}).fail(nf.ErrorHandler.handleAjaxError);
};
function OutputPortComponent() {
this.icon = 'icon icon-port-out';
this.hoverIcon = 'icon icon-port-out-add';
return function (serviceProvider) {
'use strict';
/**
* The output port component's modal.
* Create the input port and add to the graph.
*
* @argument {string} portName The output port name.
* @argument {object} pt The point that the output port was dropped.
*/
this.modal = {
var createOutputPort = function (portName, pt) {
var outputPortEntity = {
'revision': client.getRevision({
'revision': {
'version': 0
}
}),
'component': {
'name': portName,
'position': {
'x': pt.x,
'y': pt.y
}
}
};
// create a new processor of the defined type
$.ajax({
type: 'POST',
url: serviceProvider.headerCtrl.toolboxCtrl.config.urls.api + '/process-groups/' + encodeURIComponent(canvasUtils.getGroupId()) + '/output-ports',
data: JSON.stringify(outputPortEntity),
dataType: 'json',
contentType: 'application/json'
}).done(function (response) {
// add the port to the graph
graph.add({
'outputPorts': [response]
}, {
'selectAll': true
});
// update component visibility
graph.updateVisibility();
// update the birdseye
birdseye.refresh();
}).fail(errorHandler.handleAjaxError);
};
function OutputPortComponent() {
this.icon = 'icon icon-port-out';
this.hoverIcon = 'icon icon-port-out-add';
/**
* Gets the modal element.
* The output port component's modal.
*/
this.modal = {
/**
* Gets the modal element.
*
* @returns {*|jQuery|HTMLElement}
*/
getElement: function () {
return $('#new-port-dialog'); //Reuse the input port dialog....
},
/**
* Initialize the modal.
*/
init: function () {
//Reuse the input port dialog....
},
/**
* Updates the modal config.
*
* @param {string} name The name of the property to update.
* @param {object|array} config The config for the `name`.
*/
update: function (name, config) {
this.getElement().modal(name, config);
},
/**
* Show the modal.
*/
show: function () {
this.getElement().modal('show');
},
/**
* Hide the modal.
*/
hide: function () {
this.getElement().modal('hide');
}
};
}
OutputPortComponent.prototype = {
constructor: OutputPortComponent,
/**
* Gets the component.
*
* @returns {*|jQuery|HTMLElement}
*/
getElement: function () {
return $('#new-port-dialog'); //Reuse the input port dialog....
return $('#port-out-component');
},
/**
* Initialize the modal.
* Enable the component.
*/
init: function () {
//Reuse the input port dialog....
enabled: function () {
this.getElement().attr('disabled', false);
},
/**
* Updates the modal config.
* Disable the component.
*/
disabled: function () {
this.getElement().attr('disabled', true);
},
/**
* Handler function for when component is dropped on the canvas.
*
* @param {string} name The name of the property to update.
* @param {object|array} config The config for the `name`.
* @argument {object} pt The point that the component was dropped.
*/
update: function (name, config) {
this.getElement().modal(name, config);
dropHandler: function (pt) {
this.promptForOutputPortName(pt);
},
/**
* Show the modal.
* The drag icon for the toolbox component.
*
* @param event
* @returns {*|jQuery|HTMLElement}
*/
show: function () {
this.getElement().modal('show');
dragIcon: function (event) {
return $('<div class="icon icon-port-out-add"></div>');
},
/**
* Hide the modal.
* Prompts the user to enter the name for the output port.
*
* @argument {object} pt The point that the output port was dropped.
*/
hide: function () {
this.getElement().modal('hide');
}
};
}
promptForOutputPortName: function (pt) {
var outputPortComponent = this;
var addOutputPort = function () {
// get the name of the output port and clear the textfield
var portName = $('#new-port-name').val();
OutputPortComponent.prototype = {
constructor: OutputPortComponent,
// hide the dialog
outputPortComponent.modal.hide();
/**
* Gets the component.
*
* @returns {*|jQuery|HTMLElement}
*/
getElement: function () {
return $('#port-out-component');
},
// create the output port
createOutputPort(portName, pt);
};
/**
* Enable the component.
*/
enabled: function () {
this.getElement().attr('disabled', false);
},
/**
* Disable the component.
*/
disabled: function () {
this.getElement().attr('disabled', true);
},
/**
* Handler function for when component is dropped on the canvas.
*
* @argument {object} pt The point that the component was dropped.
*/
dropHandler: function (pt) {
this.promptForOutputPortName(pt);
},
/**
* The drag icon for the toolbox component.
*
* @param event
* @returns {*|jQuery|HTMLElement}
*/
dragIcon: function (event) {
return $('<div class="icon icon-port-out-add"></div>');
},
/**
* Prompts the user to enter the name for the output port.
*
* @argument {object} pt The point that the output port was dropped.
*/
promptForOutputPortName: function (pt) {
var outputPortComponent = this;
var addOutputPort = function () {
// get the name of the output port and clear the textfield
var portName = $('#new-port-name').val();
// hide the dialog
outputPortComponent.modal.hide();
// create the output port
createOutputPort(portName, pt);
};
this.modal.update('setButtonModel', [{
buttonText: 'Add',
color: {
base: '#728E9B',
hover: '#004849',
text: '#ffffff'
},
handler: {
click: addOutputPort
}
},
{
buttonText: 'Cancel',
this.modal.update('setButtonModel', [{
buttonText: 'Add',
color: {
base: '#E3E8EB',
hover: '#C7D2D7',
text: '#004849'
base: '#728E9B',
hover: '#004849',
text: '#ffffff'
},
handler: {
click: function () {
outputPortComponent.modal.hide();
}
click: addOutputPort
}
}]);
},
{
buttonText: 'Cancel',
color: {
base: '#E3E8EB',
hover: '#C7D2D7',
text: '#004849'
},
handler: {
click: function () {
outputPortComponent.modal.hide();
}
}
}]);
// update the port type
$('#new-port-type').text('Output');
// update the port type
$('#new-port-type').text('Output');
// set the focus and show the dialog
this.modal.show();
// set the focus and show the dialog
this.modal.show();
// set up the focus and key handlers
$('#new-port-name').focus().off('keyup').on('keyup', function (e) {
var code = e.keyCode ? e.keyCode : e.which;
if (code === $.ui.keyCode.ENTER) {
addOutputPort();
}
});
// set up the focus and key handlers
$('#new-port-name').focus().off('keyup').on('keyup', function (e) {
var code = e.keyCode ? e.keyCode : e.which;
if (code === $.ui.keyCode.ENTER) {
addOutputPort();
}
});
}
}
}
var outputPortComponent = new OutputPortComponent();
return outputPortComponent;
};
var outputPortComponent = new OutputPortComponent();
return outputPortComponent;
};
}));

View File

@ -15,265 +15,302 @@
* limitations under the License.
*/
/* global nf, d3 */
/* global define, module, require, exports */
nf.ng.RemoteProcessGroupComponent = function (serviceProvider) {
(function (root, factory) {
if (typeof define === 'function' && define.amd) {
define(['jquery',
'nf.Client',
'nf.Birdseye',
'nf.Graph',
'nf.CanvasUtils',
'nf.ErrorHandler',
'nf.Dialog',
'nf.Common'],
function ($, client, birdseye, graph, canvasUtils, errorHandler, dialog, common) {
return (nf.ng.RemoteProcessGroupComponent = factory($, client, birdseye, graph, canvasUtils, errorHandler, dialog, common));
});
} else if (typeof exports === 'object' && typeof module === 'object') {
module.exports = (nf.ng.RemoteProcessGroupComponent =
factory(require('jquery'),
require('nf.Client'),
require('nf.Birdseye'),
require('nf.Graph'),
require('nf.CanvasUtils'),
require('nf.ErrorHandler'),
require('nf.Dialog'),
require('nf.Common')));
} else {
nf.ng.RemoteProcessGroupComponent = factory(root.$,
root.nf.Client,
root.nf.Birdseye,
root.nf.Graph,
root.nf.CanvasUtils,
root.nf.ErrorHandler,
root.nf.Dialog,
root.nf.Common);
}
}(this, function ($, client, birdseye, graph, canvasUtils, errorHandler, dialog, common) {
'use strict';
/**
* Create the controller and add to the graph.
*
* @argument {object} pt The point that the remote group was dropped.
*/
var createRemoteProcessGroup = function (pt) {
var remoteProcessGroupEntity = {
'revision': nf.Client.getRevision({
'revision': {
'version': 0
}
}),
'component': {
'targetUris': $('#new-remote-process-group-uris').val(),
'position': {
'x': pt.x,
'y': pt.y
},
'communicationsTimeout': $('#new-remote-process-group-timeout').val(),
'yieldDuration': $('#new-remote-process-group-yield-duration').val(),
'transportProtocol': $('#new-remote-process-group-transport-protocol-combo').combo('getSelectedOption').value,
'proxyHost': $('#new-remote-process-group-proxy-host').val(),
'proxyPort': $('#new-remote-process-group-proxy-port').val(),
'proxyUser': $('#new-remote-process-group-proxy-user').val(),
'proxyPassword': $('#new-remote-process-group-proxy-password').val()
}
};
// create a new processor of the defined type
$.ajax({
type: 'POST',
url: serviceProvider.headerCtrl.toolboxCtrl.config.urls.api + '/process-groups/' + encodeURIComponent(nf.Canvas.getGroupId()) + '/remote-process-groups',
data: JSON.stringify(remoteProcessGroupEntity),
dataType: 'json',
contentType: 'application/json'
}).done(function (response) {
// add the processor to the graph
nf.Graph.add({
'remoteProcessGroups': [response]
}, {
'selectAll': true
});
// hide the dialog
$('#new-remote-process-group-dialog').modal('hide');
// update component visibility
nf.Canvas.View.updateVisibility();
// update the birdseye
nf.Birdseye.refresh();
}).fail(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,
headerText: 'Configuration Error'
});
} else {
nf.ErrorHandler.handleAjaxError(xhr, status, error);
}
});
};
function RemoteProcessGroupComponent() {
this.icon = 'icon icon-group-remote';
this.hoverIcon = 'icon icon-group-remote-add';
return function (serviceProvider) {
'use strict';
/**
* The remote group component's modal.
* Create the controller and add to the graph.
*
* @argument {object} pt The point that the remote group was dropped.
*/
this.modal = {
var createRemoteProcessGroup = function (pt) {
/**
* Gets the modal element.
*
* @returns {*|jQuery|HTMLElement}
*/
getElement: function () {
return $('#new-remote-process-group-dialog');
},
/**
* Initialize the modal.
*/
init: function () {
var defaultTimeout = "30 sec";
var defaultYieldDuration = "10 sec";
// configure the new remote process group dialog
this.getElement().modal({
scrollableContentStyle: 'scrollable',
headerText: 'Add Remote Process Group',
handler: {
close: function () {
$('#new-remote-process-group-uris').val('');
$('#new-remote-process-group-timeout').val(defaultTimeout);
$('#new-remote-process-group-yield-duration').val(defaultYieldDuration);
$('#new-remote-process-group-transport-protocol-combo').combo('setSelectedOption', {
value: 'RAW'
});
$('#new-remote-process-group-proxy-host').val('');
$('#new-remote-process-group-proxy-port').val('');
$('#new-remote-process-group-proxy-user').val('');
$('#new-remote-process-group-proxy-password').val('');
}
var remoteProcessGroupEntity = {
'revision': client.getRevision({
'revision': {
'version': 0
}
}),
'component': {
'targetUris': $('#new-remote-process-group-uris').val(),
'position': {
'x': pt.x,
'y': pt.y
},
'communicationsTimeout': $('#new-remote-process-group-timeout').val(),
'yieldDuration': $('#new-remote-process-group-yield-duration').val(),
'transportProtocol': $('#new-remote-process-group-transport-protocol-combo').combo('getSelectedOption').value,
'proxyHost': $('#new-remote-process-group-proxy-host').val(),
'proxyPort': $('#new-remote-process-group-proxy-port').val(),
'proxyUser': $('#new-remote-process-group-proxy-user').val(),
'proxyPassword': $('#new-remote-process-group-proxy-password').val()
}
};
// create a new processor of the defined type
$.ajax({
type: 'POST',
url: serviceProvider.headerCtrl.toolboxCtrl.config.urls.api + '/process-groups/' + encodeURIComponent(canvasUtils.getGroupId()) + '/remote-process-groups',
data: JSON.stringify(remoteProcessGroupEntity),
dataType: 'json',
contentType: 'application/json'
}).done(function (response) {
// add the processor to the graph
graph.add({
'remoteProcessGroups': [response]
}, {
'selectAll': true
});
// set default values
$('#new-remote-process-group-timeout').val(defaultTimeout);
$('#new-remote-process-group-yield-duration').val(defaultYieldDuration);
// initialize the transport protocol combo
$('#new-remote-process-group-transport-protocol-combo').combo({
options: [{
// hide the dialog
$('#new-remote-process-group-dialog').modal('hide');
// update component visibility
graph.updateVisibility();
// update the birdseye
birdseye.refresh();
}).fail(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 = common.formatUnorderedList(errors);
}
dialog.showOkDialog({
dialogContent: content,
headerText: 'Configuration Error'
});
} else {
errorHandler.handleAjaxError(xhr, status, error);
}
});
};
function RemoteProcessGroupComponent() {
this.icon = 'icon icon-group-remote';
this.hoverIcon = 'icon icon-group-remote-add';
/**
* The remote group component's modal.
*/
this.modal = {
/**
* Gets the modal element.
*
* @returns {*|jQuery|HTMLElement}
*/
getElement: function () {
return $('#new-remote-process-group-dialog');
},
/**
* Initialize the modal.
*/
init: function () {
var defaultTimeout = "30 sec";
var defaultYieldDuration = "10 sec";
// configure the new remote process group dialog
this.getElement().modal({
scrollableContentStyle: 'scrollable',
headerText: 'Add Remote Process Group',
handler: {
close: function () {
$('#new-remote-process-group-uris').val('');
$('#new-remote-process-group-timeout').val(defaultTimeout);
$('#new-remote-process-group-yield-duration').val(defaultYieldDuration);
$('#new-remote-process-group-transport-protocol-combo').combo('setSelectedOption', {
value: 'RAW'
});
$('#new-remote-process-group-proxy-host').val('');
$('#new-remote-process-group-proxy-port').val('');
$('#new-remote-process-group-proxy-user').val('');
$('#new-remote-process-group-proxy-password').val('');
}
}
});
// set default values
$('#new-remote-process-group-timeout').val(defaultTimeout);
$('#new-remote-process-group-yield-duration').val(defaultYieldDuration);
// initialize the transport protocol combo
$('#new-remote-process-group-transport-protocol-combo').combo({
options: [{
text: 'RAW',
value: 'RAW'
}, {
text: 'HTTP',
value: 'HTTP'
}]
});
},
/**
* Updates the modal config.
*
* @param {string} name The name of the property to update.
* @param {object|array} config The config for the `name`.
*/
update: function (name, config) {
this.getElement().modal(name, config);
},
/**
* Show the modal.
*/
show: function () {
this.getElement().modal('show');
},
/**
* Hide the modal.
*/
hide: function () {
this.getElement().modal('hide');
}
};
}
RemoteProcessGroupComponent.prototype = {
constructor: RemoteProcessGroupComponent,
/**
* Gets the component.
*
* @returns {*|jQuery|HTMLElement}
*/
getElement: function () {
return $('#group-remote-component');
},
/**
* Enable the component.
*/
enabled: function () {
this.getElement().attr('disabled', false);
},
/**
* Disable the component.
*/
disabled: function () {
this.getElement().attr('disabled', true);
},
/**
* Handler function for when component is dropped on the canvas.
*
* @argument {object} pt The point that the component was dropped.
*/
dropHandler: function (pt) {
this.promptForRemoteProcessGroupUri(pt);
},
/**
* The drag icon for the toolbox component.
*
* @param event
* @returns {*|jQuery|HTMLElement}
*/
dragIcon: function (event) {
return $('<div class="icon icon-group-remote-add"></div>');
},
/**
* Prompts the user to enter the URI for the remote process group.
*
* @argument {object} pt The point that the remote group was dropped.
*/
promptForRemoteProcessGroupUri: function (pt) {
var remoteProcessGroupComponent = this;
var addRemoteProcessGroup = function () {
// create the remote process group
createRemoteProcessGroup(pt);
};
this.modal.update('setButtonModel', [{
buttonText: 'Add',
color: {
base: '#728E9B',
hover: '#004849',
text: '#ffffff'
});
},
handler: {
click: addRemoteProcessGroup
/**
* Updates the modal config.
*
* @param {string} name The name of the property to update.
* @param {object|array} config The config for the `name`.
*/
update: function (name, config) {
this.getElement().modal(name, config);
},
/**
* Show the modal.
*/
show: function () {
this.getElement().modal('show');
},
/**
* Hide the modal.
*/
hide: function () {
this.getElement().modal('hide');
}
};
}
RemoteProcessGroupComponent.prototype = {
constructor: RemoteProcessGroupComponent,
/**
* Gets the component.
*
* @returns {*|jQuery|HTMLElement}
*/
getElement: function () {
return $('#group-remote-component');
},
{
buttonText: 'Cancel',
/**
* Enable the component.
*/
enabled: function () {
this.getElement().attr('disabled', false);
},
/**
* Disable the component.
*/
disabled: function () {
this.getElement().attr('disabled', true);
},
/**
* Handler function for when component is dropped on the canvas.
*
* @argument {object} pt The point that the component was dropped.
*/
dropHandler: function (pt) {
this.promptForRemoteProcessGroupUri(pt);
},
/**
* The drag icon for the toolbox component.
*
* @param event
* @returns {*|jQuery|HTMLElement}
*/
dragIcon: function (event) {
return $('<div class="icon icon-group-remote-add"></div>');
},
/**
* Prompts the user to enter the URI for the remote process group.
*
* @argument {object} pt The point that the remote group was dropped.
*/
promptForRemoteProcessGroupUri: function (pt) {
var remoteProcessGroupComponent = this;
var addRemoteProcessGroup = function () {
// create the remote process group
createRemoteProcessGroup(pt);
};
this.modal.update('setButtonModel', [{
buttonText: 'Add',
color: {
base: '#E3E8EB',
hover: '#C7D2D7',
text: '#004849'
base: '#728E9B',
hover: '#004849',
text: '#ffffff'
},
handler: {
click: function () {
remoteProcessGroupComponent.modal.hide();
}
click: addRemoteProcessGroup
}
}]);
},
{
buttonText: 'Cancel',
color: {
base: '#E3E8EB',
hover: '#C7D2D7',
text: '#004849'
},
handler: {
click: function () {
remoteProcessGroupComponent.modal.hide();
}
}
}]);
// show the dialog
this.modal.show();
// show the dialog
this.modal.show();
// set the focus and key handlers
$('#new-remote-process-group-uris').focus().off('keyup').on('keyup', function (e) {
var code = e.keyCode ? e.keyCode : e.which;
if (code === $.ui.keyCode.ENTER) {
addRemoteProcessGroup();
}
});
// set the focus and key handlers
$('#new-remote-process-group-uris').focus().off('keyup').on('keyup', function (e) {
var code = e.keyCode ? e.keyCode : e.which;
if (code === $.ui.keyCode.ENTER) {
addRemoteProcessGroup();
}
});
}
}
}
var remoteProcessGroupComponent = new RemoteProcessGroupComponent();
return remoteProcessGroupComponent;
};
var remoteProcessGroupComponent = new RemoteProcessGroupComponent();
return remoteProcessGroupComponent;
};
}));

View File

@ -15,236 +15,273 @@
* limitations under the License.
*/
/* global nf, d3 */
/* global define, module, require, exports */
nf.ng.TemplateComponent = function (serviceProvider) {
(function (root, factory) {
if (typeof define === 'function' && define.amd) {
define(['jquery',
'nf.Client',
'nf.Birdseye',
'nf.Graph',
'nf.CanvasUtils',
'nf.ErrorHandler',
'nf.Dialog',
'nf.Common'],
function ($, client, birdseye, graph, canvasUtils, errorHandler, dialog, common) {
return (nf.ng.TemplateComponent = factory($, client, birdseye, graph, canvasUtils, errorHandler, dialog, common));
});
} else if (typeof exports === 'object' && typeof module === 'object') {
module.exports = (nf.ng.TemplateComponent =
factory(require('jquery'),
require('nf.Client'),
require('nf.Birdseye'),
require('nf.Graph'),
require('nf.CanvasUtils'),
require('nf.ErrorHandler'),
require('nf.Dialog'),
require('nf.Common')));
} else {
nf.ng.TemplateComponent = factory(root.$,
root.nf.Client,
root.nf.Birdseye,
root.nf.Graph,
root.nf.CanvasUtils,
root.nf.ErrorHandler,
root.nf.Dialog,
root.nf.Common);
}
}(this, function ($, client, birdseye, graph, canvasUtils, errorHandler, dialog, common) {
'use strict';
/**
* Instantiates the specified template.
*
* @argument {string} templateId The template id.
* @argument {object} pt The point that the template was dropped.
*/
var createTemplate = function (templateId, pt) {
var instantiateTemplateInstance = {
'templateId': templateId,
'originX': pt.x,
'originY': pt.y
};
// create a new instance of the new template
$.ajax({
type: 'POST',
url: serviceProvider.headerCtrl.toolboxCtrl.config.urls.api + '/process-groups/' + encodeURIComponent(nf.Canvas.getGroupId()) + '/template-instance',
data: JSON.stringify(instantiateTemplateInstance),
dataType: 'json',
contentType: 'application/json'
}).done(function (response) {
// populate the graph accordingly
nf.Graph.add(response.flow, {
'selectAll': true
});
// update component visibility
nf.Canvas.View.updateVisibility();
// update the birdseye
nf.Birdseye.refresh();
}).fail(nf.ErrorHandler.handleAjaxError);
};
function TemplateComponent() {
this.icon = 'icon icon-template';
this.hoverIcon = 'icon icon-template-add';
return function (serviceProvider) {
'use strict';
/**
* The template component's modal.
* Instantiates the specified template.
*
* @argument {string} templateId The template id.
* @argument {object} pt The point that the template was dropped.
*/
this.modal = {
var createTemplate = function (templateId, pt) {
var instantiateTemplateInstance = {
'templateId': templateId,
'originX': pt.x,
'originY': pt.y
};
// create a new instance of the new template
$.ajax({
type: 'POST',
url: serviceProvider.headerCtrl.toolboxCtrl.config.urls.api + '/process-groups/' + encodeURIComponent(canvasUtils.getGroupId()) + '/template-instance',
data: JSON.stringify(instantiateTemplateInstance),
dataType: 'json',
contentType: 'application/json'
}).done(function (response) {
// populate the graph accordingly
graph.add(response.flow, {
'selectAll': true
});
// update component visibility
graph.updateVisibility();
// update the birdseye
birdseye.refresh();
}).fail(errorHandler.handleAjaxError);
};
function TemplateComponent() {
this.icon = 'icon icon-template';
this.hoverIcon = 'icon icon-template-add';
/**
* Gets the modal element.
* The template component's modal.
*/
this.modal = {
/**
* Gets the modal element.
*
* @returns {*|jQuery|HTMLElement}
*/
getElement: function () {
return $('#instantiate-template-dialog');
},
/**
* Initialize the modal.
*/
init: function () {
// configure the instantiate template dialog
this.getElement().modal({
scrollableContentStyle: 'scrollable',
headerText: 'Add Template'
});
},
/**
* Updates the modal config.
*
* @param {string} name The name of the property to update.
* @param {object|array} config The config for the `name`.
*/
update: function (name, config) {
this.getElement().modal(name, config);
},
/**
* Show the modal.
*/
show: function () {
this.getElement().modal('show');
},
/**
* Hide the modal.
*/
hide: function () {
this.getElement().modal('hide');
}
};
}
TemplateComponent.prototype = {
constructor: TemplateComponent,
/**
* Gets the component.
*
* @returns {*|jQuery|HTMLElement}
*/
getElement: function () {
return $('#instantiate-template-dialog');
return $('#template-component');
},
/**
* Initialize the modal.
* Enable the component.
*/
init: function () {
// configure the instantiate template dialog
this.getElement().modal({
scrollableContentStyle: 'scrollable',
headerText: 'Add Template'
});
enabled: function () {
this.getElement().attr('disabled', false);
},
/**
* Updates the modal config.
* Disable the component.
*/
disabled: function () {
this.getElement().attr('disabled', true);
},
/**
* Handler function for when component is dropped on the canvas.
*
* @param {string} name The name of the property to update.
* @param {object|array} config The config for the `name`.
* @argument {object} pt The point that the component was dropped.
*/
update: function (name, config) {
this.getElement().modal(name, config);
dropHandler: function (pt) {
this.promptForTemplate(pt);
},
/**
* Show the modal.
* The drag icon for the toolbox component.
*
* @param event
* @returns {*|jQuery|HTMLElement}
*/
show: function () {
this.getElement().modal('show');
dragIcon: function (event) {
return $('<div class="icon icon-template-add"></div>');
},
/**
* Hide the modal.
* Prompts the user to select a template.
*
* @argument {object} pt The point that the template was dropped.
*/
hide: function () {
this.getElement().modal('hide');
}
};
}
promptForTemplate: function (pt) {
var templateComponent = this;
$.ajax({
type: 'GET',
url: serviceProvider.headerCtrl.toolboxCtrl.config.urls.api + '/flow/templates',
dataType: 'json'
}).done(function (response) {
var templates = response.templates;
if (common.isDefinedAndNotNull(templates) && templates.length > 0) {
// sort the templates
templates = templates.sort(function (one, two) {
var oneDate = common.parseDateTime(one.template.timestamp);
var twoDate = common.parseDateTime(two.template.timestamp);
TemplateComponent.prototype = {
constructor: TemplateComponent,
// newest templates first
return twoDate.getTime() - oneDate.getTime();
});
/**
* Gets the component.
*
* @returns {*|jQuery|HTMLElement}
*/
getElement: function () {
return $('#template-component');
},
/**
* Enable the component.
*/
enabled: function () {
this.getElement().attr('disabled', false);
},
/**
* Disable the component.
*/
disabled: function () {
this.getElement().attr('disabled', true);
},
/**
* Handler function for when component is dropped on the canvas.
*
* @argument {object} pt The point that the component was dropped.
*/
dropHandler: function (pt) {
this.promptForTemplate(pt);
},
/**
* The drag icon for the toolbox component.
*
* @param event
* @returns {*|jQuery|HTMLElement}
*/
dragIcon: function (event) {
return $('<div class="icon icon-template-add"></div>');
},
/**
* Prompts the user to select a template.
*
* @argument {object} pt The point that the template was dropped.
*/
promptForTemplate: function (pt) {
var templateComponent = this;
$.ajax({
type: 'GET',
url: serviceProvider.headerCtrl.toolboxCtrl.config.urls.api + '/flow/templates',
dataType: 'json'
}).done(function (response) {
var templates = response.templates;
if (nf.Common.isDefinedAndNotNull(templates) && templates.length > 0) {
// sort the templates
templates = templates.sort(function (one, two) {
var oneDate = nf.Common.parseDateTime(one.template.timestamp);
var twoDate = nf.Common.parseDateTime(two.template.timestamp);
// newest templates first
return twoDate.getTime() - oneDate.getTime();
});
var options = [];
$.each(templates, function (_, templateEntity) {
if (templateEntity.permissions.canRead === true) {
options.push({
text: templateEntity.template.name,
value: templateEntity.id,
description: nf.Common.escapeHtml(templateEntity.template.description)
});
}
});
// configure the templates combo
$('#available-templates').combo({
maxHeight: 300,
options: options
});
// update the button model
templateComponent.modal.update('setButtonModel', [{
buttonText: 'Add',
color: {
base: '#728E9B',
hover: '#004849',
text: '#ffffff'
},
handler: {
click: function () {
// get the type of processor currently selected
var selectedOption = $('#available-templates').combo('getSelectedOption');
var templateId = selectedOption.value;
// hide the dialog
templateComponent.modal.hide();
// instantiate the specified template
createTemplate(templateId, pt);
var options = [];
$.each(templates, function (_, templateEntity) {
if (templateEntity.permissions.canRead === true) {
options.push({
text: templateEntity.template.name,
value: templateEntity.id,
description: common.escapeHtml(templateEntity.template.description)
});
}
}
},
{
buttonText: 'Cancel',
});
// configure the templates combo
$('#available-templates').combo({
maxHeight: 300,
options: options
});
// update the button model
templateComponent.modal.update('setButtonModel', [{
buttonText: 'Add',
color: {
base: '#E3E8EB',
hover: '#C7D2D7',
text: '#004849'
base: '#728E9B',
hover: '#004849',
text: '#ffffff'
},
handler: {
click: function () {
// get the type of processor currently selected
var selectedOption = $('#available-templates').combo('getSelectedOption');
var templateId = selectedOption.value;
// hide the dialog
templateComponent.modal.hide();
// instantiate the specified template
createTemplate(templateId, pt);
}
}
}]);
},
{
buttonText: 'Cancel',
color: {
base: '#E3E8EB',
hover: '#C7D2D7',
text: '#004849'
},
handler: {
click: function () {
templateComponent.modal.hide();
}
}
}]);
// show the dialog
templateComponent.modal.show();
} else {
nf.Dialog.showOkDialog({
headerText: 'Instantiate Template',
dialogContent: 'No templates have been loaded into this NiFi.'
});
}
// show the dialog
templateComponent.modal.show();
} else {
dialog.showOkDialog({
headerText: 'Instantiate Template',
dialogContent: 'No templates have been loaded into this NiFi.'
});
}
}).fail(nf.ErrorHandler.handleAjaxError);
}).fail(errorHandler.handleAjaxError);
}
}
}
var templateComponent = new TemplateComponent();
return templateComponent;
};
var templateComponent = new TemplateComponent();
return templateComponent;
};
}));

View File

@ -15,17 +15,49 @@
* limitations under the License.
*/
/* global nf, d3 */
/* global define, module, require, exports */
nf.Birdseye = (function () {
(function (root, factory) {
if (typeof define === 'function' && define.amd) {
define(['jquery',
'd3',
'nf.ErrorHandler',
'nf.Common',
'nf.CanvasUtils',
'nf.ContextMenu',
'nf.Label'],
function ($, d3, errorHandler, common, canvasUtils, contextMenu, label) {
return (nf.Birdseye = factory($, d3, errorHandler, common, canvasUtils, contextMenu, label));
});
} else if (typeof exports === 'object' && typeof module === 'object') {
module.exports = (nf.Birdseye =
factory(require('jquery'),
require('d3'),
require('nf.ErrorHandler'),
require('nf.Common'),
require('nf.CanvasUtils'),
require('nf.ContextMenu'),
require('nf.Label')));
} else {
nf.Birdseye = factory(root.$,
root.d3,
root.nf.ErrorHandler,
root.nf.Common,
root.nf.CanvasUtils,
root.nf.ContextMenu,
root.nf.Label);
}
}(this, function ($, d3, errorHandler, common, canvasUtils, contextMenu, label) {
'use strict';
var nfGraph;
var birdseyeGroup;
var componentGroup;
// refreshes the birdseye
var refresh = function (components) {
var translate = nf.Canvas.View.translate();
var scale = nf.Canvas.View.scale();
var translate = canvasUtils.translateCanvasView();
var scale = canvasUtils.scaleCanvasView();
// scale the translation
translate = [translate[0] / scale, translate[1] / scale];
@ -33,7 +65,7 @@ nf.Birdseye = (function () {
// get the bounding box for the graph and convert into canvas space
var graphBox = d3.select('#canvas').node().getBoundingClientRect();
var graphLeft = (graphBox.left / scale) - translate[0];
var graphTop = ((graphBox.top - nf.Canvas.CANVAS_OFFSET) / scale) - translate[1];
var graphTop = ((graphBox.top - canvasUtils.getCanvasOffset()) / scale) - translate[1];
var graphRight = (graphBox.right / scale) - translate[0];
var graphBottom = (graphBox.bottom / scale) - translate[1];
@ -149,11 +181,11 @@ nf.Birdseye = (function () {
// labels
$.each(components.labels, function (_, d) {
var color = nf.Label.defaultColor();
var color = label.defaultColor();
if (d.permissions.canRead) {
// use the specified color if appropriate
if (nf.Common.isDefinedAndNotNull(d.component.style['background-color'])) {
if (common.isDefinedAndNotNull(d.component.style['background-color'])) {
color = d.component.style['background-color'];
}
}
@ -192,7 +224,7 @@ nf.Birdseye = (function () {
if (d.permissions.canRead) {
// use the specified color if appropriate
if (nf.Common.isDefinedAndNotNull(d.component.style['background-color'])) {
if (common.isDefinedAndNotNull(d.component.style['background-color'])) {
color = d.component.style['background-color'];
//if the background color is #ffffff use the default instead
@ -212,8 +244,10 @@ nf.Birdseye = (function () {
// whether or not the birdseye is open, don't adjust unless necessary
var visible = true;
return {
init: function () {
var nfBirdseye = {
init: function (graph) {
nfGraph = graph;
var birdseye = $('#birdseye');
d3.select('#birdseye').append('canvas')
@ -244,7 +278,7 @@ nf.Birdseye = (function () {
})
.on('dragstart', function () {
// hide the context menu
nf.ContextMenu.hide();
contextMenu.hide();
})
.on('drag', function (d) {
d.x += d3.event.dx;
@ -255,17 +289,17 @@ nf.Birdseye = (function () {
return 'translate(' + d.x + ', ' + d.y + ')';
});
// get the current transformation
var scale = nf.Canvas.View.scale();
var translate = nf.Canvas.View.translate();
var scale = canvasUtils.scaleCanvasView();
var translate = canvasUtils.translateCanvasView();
// update the translation according to the delta
translate = [(-d3.event.dx * scale) + translate[0], (-d3.event.dy * scale) + translate[1]];
// record the current transforms
nf.Canvas.View.translate(translate);
canvasUtils.translateCanvasView(translate);
// refresh the canvas
nf.Canvas.View.refresh({
canvasUtils.refreshCanvasView({
persist: false,
transition: false,
refreshComponents: false,
@ -274,13 +308,13 @@ nf.Birdseye = (function () {
})
.on('dragend', function () {
// update component visibility
nf.Canvas.View.updateVisibility();
nfGraph.updateVisibility();
// persist the users view
nf.CanvasUtils.persistUserView();
canvasUtils.persistUserView();
// refresh the birdseye
nf.Birdseye.refresh();
nfBirdseye.refresh();
});
// context area
@ -303,7 +337,7 @@ nf.Birdseye = (function () {
*/
refresh: function () {
if (visible) {
refresh(nf.Graph.get());
refresh(nfGraph.get());
}
},
@ -322,7 +356,7 @@ nf.Birdseye = (function () {
visible = true;
// refresh the birdseye as it may have changed
refresh(nf.Graph.get());
refresh(nfGraph.get());
} else {
// hide the outline
birdseye.hide();
@ -330,4 +364,6 @@ nf.Birdseye = (function () {
}
}
};
}());
return nfBirdseye;
}));

View File

@ -0,0 +1,400 @@
/*
* 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.
*/
/* global define, module, require, exports */
(function (root, factory) {
if (typeof define === 'function' && define.amd) {
define(['jquery',
'angular',
'nf.Common',
'nf.CanvasUtils',
'nf.ErrorHandler',
'nf.Client',
'nf.ClusterSummary',
'nf.Dialog',
'nf.Storage',
'nf.Canvas',
'nf.Graph',
'nf.ContextMenu',
'nf.Shell',
'nf.Settings',
'nf.Snippet',
'nf.Actions',
'nf.QueueListing',
'nf.ComponentState',
'nf.Draggable',
'nf.Connectable',
'nf.StatusHistory',
'nf.Birdseye',
'nf.ConnectionConfiguration',
'nf.ControllerService',
'nf.ReportingTask',
'nf.PolicyManagement',
'nf.ProcessorConfiguration',
'nf.ProcessGroupConfiguration',
'nf.ControllerServices',
'nf.RemoteProcessGroupConfiguration',
'nf.RemoteProcessGroupPorts',
'nf.PortConfiguration',
'nf.LabelConfiguration',
'nf.ProcessorDetails',
'nf.PortDetails',
'nf.ConnectionDetails',
'nf.RemoteProcessGroupDetails',
'nf.GoTo',
'nf.ng.Bridge',
'nf.ng.AppCtrl',
'nf.ng.AppConfig',
'nf.ng.ServiceProvider',
'nf.ng.BreadcrumbsCtrl',
'nf.ng.Canvas.HeaderCtrl',
'nf.ng.Canvas.FlowStatusCtrl',
'nf.ng.Canvas.GlobalMenuCtrl',
'nf.ng.Canvas.ToolboxCtrl',
'nf.ng.ProcessorComponent',
'nf.ng.InputPortComponent',
'nf.ng.OutputPortComponent',
'nf.ng.GroupComponent',
'nf.ng.RemoteProcessGroupComponent',
'nf.ng.FunnelComponent',
'nf.ng.TemplateComponent',
'nf.ng.LabelComponent',
'nf.ng.Canvas.GraphControlsCtrl',
'nf.ng.Canvas.NavigateCtrl',
'nf.ng.Canvas.OperateCtrl',
'nf.ng.BreadcrumbsDirective',
'nf.ng.DraggableDirective'],
function ($, angular, common, canvasUtils, errorHandler, client, clusterSummary, dialog, storage, canvas, graph, contextMenu, shell, settings, actions, snippet, queueListing, componentState, draggable, connectable, statusHistory, birdseye, connectionConfiguration, controllerService, reportingTask, policyManagement, processorConfiguration, processGroupConfiguration, controllerServices, remoteProcessGroupConfiguration, remoteProcessGroupPorts, portConfiguration, labelConfiguration, processorDetails, portDetails, connectionDetails, remoteProcessGroupDetails, nfGoto, angularBridge, appCtrl, appConfig, serviceProvider, breadcrumbsCtrl, headerCtrl, flowStatusCtrl, globalMenuCtrl, toolboxCtrl, processorComponent, inputPortComponent, outputPortComponent, processGroupComponent, remoteProcessGroupComponent, funnelComponent, templateComponent, labelComponent, graphControlsCtrl, navigateCtrl, operateCtrl, breadcrumbsDirective, draggableDirective) {
return factory($, angular, common, canvasUtils, errorHandler, client, clusterSummary, dialog, storage, canvas, graph, contextMenu, shell, settings, actions, snippet, queueListing, componentState, draggable, connectable, statusHistory, birdseye, connectionConfiguration, controllerService, reportingTask, policyManagement, processorConfiguration, processGroupConfiguration, controllerServices, remoteProcessGroupConfiguration, remoteProcessGroupPorts, portConfiguration, labelConfiguration, processorDetails, portDetails, connectionDetails, remoteProcessGroupDetails, nfGoto, angularBridge, appCtrl, appConfig, serviceProvider, breadcrumbsCtrl, headerCtrl, flowStatusCtrl, globalMenuCtrl, toolboxCtrl, processorComponent, inputPortComponent, outputPortComponent, processGroupComponent, remoteProcessGroupComponent, funnelComponent, templateComponent, labelComponent, graphControlsCtrl, navigateCtrl, operateCtrl, breadcrumbsDirective, draggableDirective);
});
} else if (typeof exports === 'object' && typeof module === 'object') {
module.exports = factory(require('jquery'),
require('angular'),
require('nf.Common'),
require('nf.CanvasUtils'),
require('nf.ErrorHandler'),
require('nf.Client'),
require('nf.ClusterSummary'),
require('nf.Dialog'),
require('f.Storage'),
require('nf.Canvas'),
require('nf.Graph'),
require('nf.ContextMenu'),
require('nf.Shell'),
require('nf.Settings'),
require('nf.Actions'),
require('nf.Snippet'),
require('nf.QueueListing'),
require('nf.ComponentState'),
require('nf.Draggable'),
require('nf.Connectable'),
require('nf.StatusHistory'),
require('nf.Birdseye'),
require('nf.ConnectionConfiguration'),
require('nf.ControllerService'),
require('nf.ReportingTask'),
require('nf.PolicyManagement'),
require('nf.ProcessorConfiguration'),
require('nf.ProcessGroupConfiguration'),
require('nf.ControllerServices'),
require('nf.RemoteProcessGroupConfiguration'),
require('nf.RemoteProcessGroupPorts'),
require('nf.PortConfiguration'),
require('nf.LabelConfiguration'),
require('nf.ProcessorDetails'),
require('nf.PortDetails'),
require('nf.ConnectionDetails'),
require('nf.RemoteProcessGroupDetails'),
require('nf.GoTo'),
require('nf.ng.Bridge'),
require('nf.ng.AppCtrl'),
require('nf.ng.AppConfig'),
require('nf.ng.ServiceProvider'),
require('nf.ng.BreadcrumbsCtrl'),
require('nf.ng.Canvas.HeaderCtrl'),
require('nf.ng.Canvas.FlowStatusCtrl'),
require('nf.ng.Canvas.GlobalMenuCtrl'),
require('nf.ng.Canvas.ToolboxCtrl'),
require('nf.ng.ProcessorComponent'),
require('nf.ng.InputPortComponent'),
require('nf.ng.OutputPortComponent'),
require('nf.ng.GroupComponent'),
require('nf.ng.RemoteProcessGroupComponent'),
require('nf.ng.FunnelComponent'),
require('nf.ng.TemplateComponent'),
require('nf.ng.LabelComponent'),
require('nf.ng.Canvas.GraphControlsCtrl'),
require('nf.ng.Canvas.NavigateCtrl'),
require('nf.ng.Canvas.OperateCtrl'),
require('nf.ng.BreadcrumbsDirective'),
require('nf.ng.DraggableDirective'));
} else {
factory(root.$,
root.angular,
root.nf.Common,
root.nf.CanvasUtils,
root.nf.ErrorHandler,
root.nf.Client,
root.nf.ClusterSummary,
root.nf.Dialog,
root.nf.Storage,
root.nf.Canvas,
root.nf.Graph,
root.nf.ContextMenu,
root.nf.Shell,
root.nf.Settings,
root.nf.Actions,
root.nf.Snippet,
root.nf.QueueListing,
root.nf.ComponentState,
root.nf.Draggable,
root.nf.Connectable,
root.nf.StatusHistory,
root.nf.Birdseye,
root.nf.ConnectionConfiguration,
root.nf.ControllerService,
root.nf.ReportingTask,
root.nf.PolicyManagement,
root.nf.ProcessorConfiguration,
root.nf.ProcessGroupConfiguration,
root.nf.ControllerServices,
root.nf.RemoteProcessGroupConfiguration,
root.nf.RemoteProcessGroupPorts,
root.nf.PortConfiguration,
root.nf.LabelConfiguration,
root.nf.ProcessorDetails,
root.nf.PortDetails,
root.nf.ConnectionDetails,
root.nf.RemoteProcessGroupDetails,
root.nf.GoTo,
root.nf.ng.Bridge,
root.nf.ng.AppCtrl,
root.nf.ng.AppConfig,
root.nf.ng.ServiceProvider,
root.nf.ng.BreadcrumbsCtrl,
root.nf.ng.Canvas.HeaderCtrl,
root.nf.ng.Canvas.FlowStatusCtrl,
root.nf.ng.Canvas.GlobalMenuCtrl,
root.nf.ng.Canvas.ToolboxCtrl,
root.nf.ng.ProcessorComponent,
root.nf.ng.InputPortComponent,
root.nf.ng.OutputPortComponent,
root.nf.ng.GroupComponent,
root.nf.ng.RemoteProcessGroupComponent,
root.nf.ng.FunnelComponent,
root.nf.ng.TemplateComponent,
root.nf.ng.LabelComponent,
root.nf.ng.Canvas.GraphControlsCtrl,
root.nf.ng.Canvas.NavigateCtrl,
root.nf.ng.Canvas.OperateCtrl,
root.nf.ng.BreadcrumbsDirective,
root.nf.ng.DraggableDirective);
}
}(this, function ($, angular, common, canvasUtils, errorHandler, client, clusterSummary, dialog, storage, canvas, graph, contextMenu, shell, settings, actions, snippet, queueListing, componentState, draggable, connectable, statusHistory, birdseye, connectionConfiguration, controllerService, reportingTask, policyManagement, processorConfiguration, processGroupConfiguration, controllerServices, remoteProcessGroupConfiguration, remoteProcessGroupPorts, portConfiguration, labelConfiguration, processorDetails, portDetails, connectionDetails, remoteProcessGroupDetails, nfGoto, angularBridge, appCtrl, appConfig, serviceProvider, breadcrumbsCtrl, headerCtrl, flowStatusCtrl, globalMenuCtrl, toolboxCtrl, processorComponent, inputPortComponent, outputPortComponent, processGroupComponent, remoteProcessGroupComponent, funnelComponent, templateComponent, labelComponent, graphControlsCtrl, navigateCtrl, operateCtrl, breadcrumbsDirective, draggableDirective) {
var config = {
urls: {
flowConfig: '../nifi-api/flow/config'
}
};
/**
* Bootstrap the canvas application.
*/
$(document).ready(function () {
if (canvas.SUPPORTS_SVG) {
//Create Angular App
var app = angular.module('ngCanvasApp', ['ngResource', 'ngRoute', 'ngMaterial', 'ngMessages']);
//Define Dependency Injection Annotations
appConfig.$inject = ['$mdThemingProvider', '$compileProvider'];
appCtrl.$inject = ['$scope', 'serviceProvider', '$compile', 'headerCtrl', 'graphControlsCtrl'];
serviceProvider.$inject = [];
breadcrumbsCtrl.$inject = ['serviceProvider'];
headerCtrl.$inject = ['serviceProvider', 'toolboxCtrl', 'globalMenuCtrl', 'flowStatusCtrl'];
flowStatusCtrl.$inject = ['serviceProvider'];
globalMenuCtrl.$inject = ['serviceProvider'];
toolboxCtrl.$inject = ['processorComponent',
'inputPortComponent',
'outputPortComponent',
'groupComponent',
'remoteGroupComponent',
'funnelComponent',
'templateComponent',
'labelComponent'];
processorComponent.$inject = ['serviceProvider'];
inputPortComponent.$inject = ['serviceProvider'];
outputPortComponent.$inject = ['serviceProvider'];
processGroupComponent.$inject = ['serviceProvider'];
remoteProcessGroupComponent.$inject = ['serviceProvider'];
funnelComponent.$inject = ['serviceProvider'];
templateComponent.$inject = ['serviceProvider'];
labelComponent.$inject = ['serviceProvider'];
graphControlsCtrl.$inject = ['serviceProvider', 'navigateCtrl', 'operateCtrl'];
navigateCtrl.$inject = [];
operateCtrl.$inject = [];
breadcrumbsDirective.$inject = ['breadcrumbsCtrl'];
draggableDirective.$inject = [];
//Configure Angular App
app.config(appConfig);
//Define Angular App Controllers
app.controller('ngCanvasAppCtrl', appCtrl);
//Define Angular App Services
app.service('serviceProvider', serviceProvider);
app.service('breadcrumbsCtrl', breadcrumbsCtrl);
app.service('headerCtrl', headerCtrl);
app.service('flowStatusCtrl', flowStatusCtrl);
app.service('globalMenuCtrl', globalMenuCtrl);
app.service('toolboxCtrl', toolboxCtrl);
app.service('processorComponent', processorComponent);
app.service('inputPortComponent', inputPortComponent);
app.service('outputPortComponent', outputPortComponent);
app.service('groupComponent', processGroupComponent);
app.service('remoteGroupComponent', remoteProcessGroupComponent);
app.service('funnelComponent', funnelComponent);
app.service('templateComponent', templateComponent);
app.service('labelComponent', labelComponent);
app.service('graphControlsCtrl', graphControlsCtrl);
app.service('navigateCtrl', navigateCtrl);
app.service('operateCtrl', operateCtrl);
//Define Angular App Directives
app.directive('nfBreadcrumbs', breadcrumbsDirective);
app.directive('nfDraggable', draggableDirective);
// initialize the canvas utils and invert control of the canvas,
// actions, snippet, birdseye, and graph
canvasUtils.init(canvas, actions, snippet, birdseye, graph);
//Manually Boostrap Angular App
angularBridge.injector = angular.bootstrap($('body'), ['ngCanvasApp'], {strictDi: true});
// initialize the NiFi
var userXhr = canvas.init();
userXhr.done(function () {
// load the client id
var clientXhr = client.init();
// get the controller config to register the status poller
var configXhr = $.ajax({
type: 'GET',
url: config.urls.flowConfig,
dataType: 'json'
});
// ensure the config requests are loaded
$.when(configXhr, clusterSummary.loadClusterSummary(), userXhr, clientXhr).done(function (configResult) {
var configResponse = configResult[0];
// calculate the canvas offset
var canvasContainer = $('#canvas-container');
canvas.CANVAS_OFFSET = canvasContainer.offset().top;
// get the config details
var configDetails = configResponse.flowConfiguration;
// show disconnected message on load if necessary
if (clusterSummary.isClustered() && !clusterSummary.isConnectedToCluster()) {
dialog.showDisconnectedFromClusterMessage();
}
// get the auto refresh interval
var autoRefreshIntervalSeconds = parseInt(configDetails.autoRefreshIntervalSeconds, 10);
// record whether we can configure the authorizer
canvas.setConfigurableAuthorizer(configDetails.supportsConfigurableAuthorizer);
// init storage
storage.init();
// initialize the application
canvas.initCanvas();
canvas.View.init();
// initialize the context menu and invert control of the actions
contextMenu.init(actions);
// initialize the shell and invert control of the context menu
shell.init(contextMenu);
angularBridge.injector.get('headerCtrl').init();
settings.init();
actions.init();
queueListing.init();
componentState.init();
// initialize the component behaviors
draggable.init();
connectable.init();
// initialize the chart
statusHistory.init(configDetails.timeOffset);
// initialize the birdseye
birdseye.init(graph);
// initialize the connection config and invert control of the birdseye and graph
connectionConfiguration.init(birdseye, graph);
controllerService.init();
reportingTask.init(settings);
policyManagement.init();
processorConfiguration.init();
// initialize the PG config and invert control of the controllerServices
processGroupConfiguration.init(controllerServices);
remoteProcessGroupConfiguration.init();
remoteProcessGroupPorts.init();
portConfiguration.init();
labelConfiguration.init();
processorDetails.init(true);
portDetails.init();
connectionDetails.init();
remoteProcessGroupDetails.init();
nfGoto.init();
graph.init().done(function () {
angularBridge.injector.get('graphControlsCtrl').init();
// determine the split between the polling
var pollingSplit = autoRefreshIntervalSeconds / 2;
// register the polling
setTimeout(function () {
canvas.startPolling(autoRefreshIntervalSeconds);
}, pollingSplit * 1000);
// hide the splash screen
canvas.hideSplash();
}).fail(errorHandler.handleAjaxError);
}).fail(errorHandler.handleAjaxError);
}).fail(errorHandler.handleAjaxError);
//initialize toolbox components tooltips
$('.component-button').qtip($.extend({}, common.config.tooltipConfig));
} else {
$('#message-title').text('Unsupported Browser');
$('#message-content').text('Flow graphs are shown using SVG. Please use a browser that supports rendering SVG.');
// show the error pane
$('#message-pane').show();
// hide the splash screen
canvas.hideSplash();
}
});
}));

View File

@ -15,22 +15,34 @@
* limitations under the License.
*/
/* global nf, define, module, require, exports */
/* global define, module, require, exports */
(function (root, factory) {
if (typeof define === 'function' && define.amd) {
define(['nf.ErrorHandler', 'nf.Common', 'nf.Canvas', 'nf.ContextMenu'], function (ajaxErrorHandler, common, canvas, contextMenu) {
return (nf.ErrorHandler = factory(ajaxErrorHandler, common, canvas, contextMenu));
});
define(['nf.ErrorHandler',
'nf.Common',
'nf.Canvas',
'nf.ContextMenu'],
function (ajaxErrorHandler, common, canvas, contextMenu) {
return (nf.ErrorHandler = factory(ajaxErrorHandler, common, canvas, contextMenu));
});
} else if (typeof exports === 'object' && typeof module === 'object') {
module.exports = (nf.ErrorHandler = factory(require('nf.ErrorHandler'), require('nf.Common'), require('nf.Canvas'), require('nf.ContextMenu')));
module.exports = (nf.ErrorHandler =
factory(require('nf.ErrorHandler'),
require('nf.Common'),
require('nf.Canvas'),
require('nf.ContextMenu')));
} else {
nf.ErrorHandler = factory(root.nf.ErrorHandler, root.nf.Common, root.nf.Canvas, root.nf.ContextMenu);
nf.ErrorHandler = factory(root.nf.ErrorHandler,
root.nf.Common,
root.nf.Canvas,
root.nf.ContextMenu);
}
}(this, function (ajaxErrorHandler, common, canvas, contextMenu) {
'use strict';
return {
/**
* Method for handling ajax errors. This also closes the canvas.
*

View File

@ -15,12 +15,28 @@
* limitations under the License.
*/
/* global nf */
/* global define, module, require, exports */
/**
* Clipboard used for copying and pasting content.
*/
nf.Clipboard = (function () {
(function (root, factory) {
if (typeof define === 'function' && define.amd) {
define(['jquery',
'nf.Common'],
function ($, common) {
return (nf.Clipboard = factory($, common));
});
} else if (typeof exports === 'object' && typeof module === 'object') {
module.exports = (nf.Clipboard =
factory(require('jquery'),
require('nf.Common')));
} else {
nf.Clipboard = factory(root.$,
root.nf.Common);
}
}(this, function ($, common) {
'use strict';
var COPY = 'copy';
var PASTE = 'paste';
@ -30,28 +46,28 @@ nf.Clipboard = (function () {
return {
/**
* Add a listener to receive copy and paste events.
*
*
* @argument {object} listener A clipboard listener
* @argument {function} funct Callback when clipboard events occur
*/
addListener: function (listener, funct) {
listeners[listener] = funct;
},
/**
* Remove the specified listener.
*
*
* @argument {object} listener A clipboard listener
*/
removeListener: function (listener) {
if (nf.Common.isDefinedAndNotNull(listeners[listener])) {
if (common.isDefinedAndNotNull(listeners[listener])) {
delete listeners[listener];
}
},
/**
* Copy the specified data.
*
*
* @argument {object} d The data to copy to the clipboard
*/
copy: function (d) {
@ -62,14 +78,14 @@ nf.Clipboard = (function () {
listeners[listener].call(listener, COPY, data);
}
},
/**
* Checks to see if any data has been copied.
*/
isCopied: function () {
return nf.Common.isDefinedAndNotNull(data);
return common.isDefinedAndNotNull(data);
},
/**
* Gets the most recent data thats copied. This operation
* will remove the corresponding data from the clipboard.
@ -77,7 +93,7 @@ nf.Clipboard = (function () {
paste: function () {
return $.Deferred(function (deferred) {
// ensure there was data
if (nf.Common.isDefinedAndNotNull(data)) {
if (common.isDefinedAndNotNull(data)) {
var clipboardData = data;
// resolve the deferred
@ -96,4 +112,4 @@ nf.Clipboard = (function () {
}).promise();
}
};
}());
}));

View File

@ -15,12 +15,40 @@
* limitations under the License.
*/
/* global nf */
/* global define, module, require, exports */
/**
* Views state for a given component.
*/
nf.ComponentState = (function () {
(function (root, factory) {
if (typeof define === 'function' && define.amd) {
define(['jquery',
'Slick',
'nf.ClusterSummary',
'nf.ErrorHandler',
'nf.Dialog',
'nf.Common'],
function ($, Slick, clusterSummary, errorHandler, dialog, common) {
return (nf.ComponentState = factory($, Slick, clusterSummary, errorHandler, dialog, common));
});
} else if (typeof exports === 'object' && typeof module === 'object') {
module.exports = (nf.ComponentState =
factory(require('jquery'),
require('Slick'),
require('nf.ClusterSummary'),
require('nf.ErrorHandler'),
require('nf.Dialog'),
require('nf.Common')));
} else {
nf.ComponentState = factory(root.$,
root.Slick,
root.nf.ClusterSummary,
root.nf.ErrorHandler,
root.nf.Dialog,
root.nf.Common);
}
}(this, function ($, Slick, clusterSummary, errorHandler, dialog, common) {
'use strict';
/**
* Filters the component state table.
@ -30,7 +58,7 @@ nf.ComponentState = (function () {
var componentStateTable = $('#component-state-table').data('gridInstance');
// ensure the grid has been initialized
if (nf.Common.isDefinedAndNotNull(componentStateTable)) {
if (common.isDefinedAndNotNull(componentStateTable)) {
var componentStateData = componentStateTable.getData();
// update the search criteria
@ -67,7 +95,7 @@ nf.ComponentState = (function () {
// conditionally consider the scope
var matchesScope = false;
if (nf.Common.isDefinedAndNotNull(item['scope'])) {
if (common.isDefinedAndNotNull(item['scope'])) {
matchesScope = item['scope'].search(filterExp) >= 0;
}
@ -83,8 +111,8 @@ nf.ComponentState = (function () {
var sort = function (sortDetails, data) {
// defines a function for sorting
var comparer = function (a, b) {
var aString = nf.Common.isDefinedAndNotNull(a[sortDetails.columnId]) ? a[sortDetails.columnId] : '';
var bString = nf.Common.isDefinedAndNotNull(b[sortDetails.columnId]) ? b[sortDetails.columnId] : '';
var aString = common.isDefinedAndNotNull(a[sortDetails.columnId]) ? a[sortDetails.columnId] : '';
var bString = common.isDefinedAndNotNull(b[sortDetails.columnId]) ? b[sortDetails.columnId] : '';
return aString === bString ? 0 : aString > bString ? 1 : -1;
};
@ -134,7 +162,7 @@ nf.ComponentState = (function () {
componentStateData.beginUpdate();
// local state
if (nf.Common.isDefinedAndNotNull(localState)) {
if (common.isDefinedAndNotNull(localState)) {
$.each(localState.state, function (i, stateEntry) {
componentStateData.addItem($.extend({
id: count++,
@ -143,12 +171,12 @@ nf.ComponentState = (function () {
});
totalEntries += localState.totalEntryCount;
if (nf.Common.isDefinedAndNotNull(localState.state) && localState.totalEntryCount !== localState.state.length) {
if (common.isDefinedAndNotNull(localState.state) && localState.totalEntryCount !== localState.state.length) {
showPartialDetails = true;
}
}
if (nf.Common.isDefinedAndNotNull(clusterState)) {
if (common.isDefinedAndNotNull(clusterState)) {
$.each(clusterState.state, function (i, stateEntry) {
componentStateData.addItem($.extend({
id: count++,
@ -157,7 +185,7 @@ nf.ComponentState = (function () {
});
totalEntries += clusterState.totalEntryCount;
if (nf.Common.isDefinedAndNotNull(clusterState.state) && clusterState.totalEntryCount !== clusterState.state.length) {
if (common.isDefinedAndNotNull(clusterState.state) && clusterState.totalEntryCount !== clusterState.state.length) {
showPartialDetails = true;
}
}
@ -171,7 +199,7 @@ nf.ComponentState = (function () {
}
// update the total number of state entries
$('#total-component-state-entries').text(nf.Common.formatInteger(totalEntries));
$('#total-component-state-entries').text(common.formatInteger(totalEntries));
};
/**
@ -253,9 +281,9 @@ nf.ComponentState = (function () {
// reload the table with no state
loadComponentState()
}).fail(nf.ErrorHandler.handleAjaxError);
}).fail(errorHandler.handleAjaxError);
} else {
nf.Dialog.showOkDialog({
dialog.showOkDialog({
headerText: 'Component State',
dialogContent: 'This component has no state to clear.'
});
@ -282,7 +310,7 @@ nf.ComponentState = (function () {
];
// conditionally show the cluster node identifier
if (nf.ClusterSummary.isClustered()) {
if (clusterSummary.isClustered()) {
componentStateColumns.push({
id: 'scope',
field: 'scope',
@ -390,7 +418,7 @@ nf.ComponentState = (function () {
// reset the grid size
var componentStateGrid = componentStateTable.data('gridInstance');
componentStateGrid.resizeCanvas();
}).fail(nf.ErrorHandler.handleAjaxError);
}).fail(errorHandler.handleAjaxError);
}
};
}());
}));

View File

@ -15,9 +15,31 @@
* limitations under the License.
*/
/* global nf, d3 */
/* global define, module, require, exports */
nf.Connectable = (function () {
(function (root, factory) {
if (typeof define === 'function' && define.amd) {
define(['d3',
'nf.Connection',
'nf.ConnectionConfiguration',
'nf.CanvasUtils'],
function (d3, connection, connectionConfiguration, canvasUtils) {
return (nf.Connectable = factory(d3, connection, connectionConfiguration, canvasUtils));
});
} else if (typeof exports === 'object' && typeof module === 'object') {
module.exports = (nf.Connectable =
factory(require('d3'),
require('nf.Connection'),
require('nf.ConnectionConfiguration'),
require('nf.CanvasUtils')));
} else {
nf.Connectable = factory(root.d3,
root.nf.Connection,
root.nf.ConnectionConfiguration,
root.nf.CanvasUtils);
}
}(this, function (d3, connection, connectionConfiguration, canvasUtils) {
'use strict';
var connect;
var canvas;
@ -56,7 +78,7 @@ nf.Connectable = (function () {
d3.event.sourceEvent.stopPropagation();
// unselect the previous components
nf.CanvasUtils.getSelection().classed('selected', false);
canvasUtils.getSelection().classed('selected', false);
// mark the source component has selected
var source = d3.select(this.parentNode).classed('selected', true);
@ -106,7 +128,7 @@ nf.Connectable = (function () {
// component to itself. requiring the mouse to have actually moved before
// checking the eligiblity of the destination addresses the issue
return (Math.abs(origin[0] - d3.event.x) > 10 || Math.abs(origin[1] - d3.event.y) > 10) &&
nf.CanvasUtils.isValidConnectionDestination(d3.select(this));
canvasUtils.isValidConnectionDestination(d3.select(this));
});
// update the drag line
@ -126,12 +148,12 @@ nf.Connectable = (function () {
var x = pathDatum.x;
var y = pathDatum.y;
var componentOffset = pathDatum.sourceWidth / 2;
var xOffset = nf.Connection.config.selfLoopXOffset;
var yOffset = nf.Connection.config.selfLoopYOffset;
var xOffset = connection.config.selfLoopXOffset;
var yOffset = connection.config.selfLoopYOffset;
return 'M' + x + ' ' + y + 'L' + (x + componentOffset + xOffset) + ' ' + (y - yOffset) + 'L' + (x + componentOffset + xOffset) + ' ' + (y + yOffset) + 'Z';
} else {
// get the position on the destination perimeter
var end = nf.CanvasUtils.getPerimeterPoint(pathDatum, {
var end = canvasUtils.getPerimeterPoint(pathDatum, {
'x': destinationData.position.x,
'y': destinationData.position.y,
'width': destinationData.dimensions.width,
@ -190,11 +212,16 @@ nf.Connectable = (function () {
// create the connection
var destinationData = destination.datum();
nf.ConnectionConfiguration.createConnection(connectorData.sourceId, destinationData.id);
connectionConfiguration.createConnection(connectorData.sourceId, destinationData.id);
}
});
},
/**
* Activates the connect behavior for the components in the specified selection.
*
* @param {selection} components
*/
activate: function (components) {
components
.classed('connectable', true)
@ -203,7 +230,7 @@ nf.Connectable = (function () {
var selection = d3.select(this);
// ensure the current component supports connection source
if (nf.CanvasUtils.isValidConnectionSource(selection)) {
if (canvasUtils.isValidConnectionSource(selection)) {
// see if theres already a connector rendered
var addConnect = d3.select('text.add-connect');
if (addConnect.empty()) {
@ -245,6 +272,11 @@ nf.Connectable = (function () {
});
},
/**
* Deactivates the connect behavior for the components in the specified selection.
*
* @param {selection} components
*/
deactivate: function (components) {
components
.classed('connectable', false)
@ -254,4 +286,4 @@ nf.Connectable = (function () {
.on('mouseout.connectable', null);
}
};
}());
}));

View File

@ -15,9 +15,46 @@
* limitations under the License.
*/
/* global nf, d3 */
/* global define, module, require, exports */
nf.ConnectionConfiguration = (function () {
(function (root, factory) {
if (typeof define === 'function' && define.amd) {
define(['jquery',
'd3',
'nf.ErrorHandler',
'nf.Common',
'nf.Dialog',
'nf.Client',
'nf.CanvasUtils',
'nf.Connection'],
function ($, d3, errorHandler, common, dialog, client, canvasUtils, connection) {
return (nf.ConnectionConfiguration = factory($, d3, errorHandler, common, dialog, client, canvasUtils, connection));
});
} else if (typeof exports === 'object' && typeof module === 'object') {
module.exports = (nf.ConnectionConfiguration =
factory(require('jquery'),
require('d3'),
require('nf.ErrorHandler'),
require('nf.Common'),
require('nf.Dialog'),
require('nf.Client'),
require('nf.CanvasUtils'),
require('nf.Connection')));
} else {
nf.ConnectionConfiguration = factory(root.$,
root.d3,
root.nf.ErrorHandler,
root.nf.Common,
root.nf.Dialog,
root.nf.Client,
root.nf.CanvasUtils,
root.nf.Connection);
}
}(this, function ($, d3, errorHandler, common, dialog, client, canvasUtils, connection) {
'use strict';
var nfBirdseye;
var nfGraph;
var CONNECTION_OFFSET_Y_INCREMENT = 75;
var CONNECTION_OFFSET_X_INCREMENT = 200;
@ -43,11 +80,11 @@ nf.ConnectionConfiguration = (function () {
*/
var initializeSourceNewConnectionDialog = function (source) {
// handle the selected source
if (nf.CanvasUtils.isProcessor(source)) {
if (canvasUtils.isProcessor(source)) {
return $.Deferred(function (deferred) {
// initialize the source processor
initializeSourceProcessor(source).done(function (processor) {
if (!nf.Common.isEmpty(processor.relationships)) {
if (!common.isEmpty(processor.relationships)) {
// populate the available connections
$.each(processor.relationships, function (i, relationship) {
createRelationshipOption(relationship.name);
@ -77,7 +114,7 @@ nf.ConnectionConfiguration = (function () {
addConnection(selectedRelationships);
} else {
// inform users that no relationships were selected
nf.Dialog.showOkDialog({
dialog.showOkDialog({
headerText: 'Connection Configuration',
dialogContent: 'The connection must have at least one relationship selected.'
});
@ -106,9 +143,9 @@ nf.ConnectionConfiguration = (function () {
deferred.resolve();
} else {
// there are no relationships for this processor
nf.Dialog.showOkDialog({
dialog.showOkDialog({
headerText: 'Connection Configuration',
dialogContent: '\'' + nf.Common.escapeHtml(processor.name) + '\' does not support any relationships.'
dialogContent: '\'' + common.escapeHtml(processor.name) + '\' does not support any relationships.'
});
// reset the dialog
@ -124,11 +161,11 @@ nf.ConnectionConfiguration = (function () {
return $.Deferred(function (deferred) {
// determine how to initialize the source
var connectionSourceDeferred;
if (nf.CanvasUtils.isInputPort(source)) {
if (canvasUtils.isInputPort(source)) {
connectionSourceDeferred = initializeSourceInputPort(source);
} else if (nf.CanvasUtils.isRemoteProcessGroup(source)) {
} else if (canvasUtils.isRemoteProcessGroup(source)) {
connectionSourceDeferred = initializeSourceRemoteProcessGroup(source);
} else if (nf.CanvasUtils.isProcessGroup(source)) {
} else if (canvasUtils.isProcessGroup(source)) {
connectionSourceDeferred = initializeSourceProcessGroup(source);
} else {
connectionSourceDeferred = initializeSourceFunnel(source);
@ -196,8 +233,8 @@ nf.ConnectionConfiguration = (function () {
$('#connection-source-component-id').val(inputPortData.id);
// populate the group details
$('#connection-source-group-id').val(nf.Canvas.getGroupId());
$('#connection-source-group-name').text(nf.Canvas.getGroupName());
$('#connection-source-group-id').val(canvasUtils.getGroupId());
$('#connection-source-group-name').text(canvasUtils.getGroupName());
// resolve the deferred
deferred.resolve();
@ -222,8 +259,8 @@ nf.ConnectionConfiguration = (function () {
$('#connection-source-component-id').val(funnelData.id);
// populate the group details
$('#connection-source-group-id').val(nf.Canvas.getGroupId());
$('#connection-source-group-name').text(nf.Canvas.getGroupName());
$('#connection-source-group-id').val(canvasUtils.getGroupId());
$('#connection-source-group-name').text(canvasUtils.getGroupName());
// resolve the deferred
deferred.resolve();
@ -240,7 +277,7 @@ nf.ConnectionConfiguration = (function () {
// get the processor data
var processorData = source.datum();
var processorName = processorData.permissions.canRead ? processorData.component.name : processorData.id;
var processorType = processorData.permissions.canRead ? nf.Common.substringAfterLast(processorData.component.type, '.') : 'Processor';
var processorType = processorData.permissions.canRead ? common.substringAfterLast(processorData.component.type, '.') : 'Processor';
// populate the source processor information
$('#processor-source').show();
@ -252,8 +289,8 @@ nf.ConnectionConfiguration = (function () {
$('#connection-source-component-id').val(processorData.id);
// populate the group details
$('#connection-source-group-id').val(nf.Canvas.getGroupId());
$('#connection-source-group-name').text(nf.Canvas.getGroupName());
$('#connection-source-group-id').val(canvasUtils.getGroupId());
$('#connection-source-group-name').text(canvasUtils.getGroupName());
// show the available relationships
$('#relationship-names-container').show();
@ -290,13 +327,13 @@ nf.ConnectionConfiguration = (function () {
options.push({
text: component.name,
value: component.id,
description: nf.Common.escapeHtml(component.comments)
description: common.escapeHtml(component.comments)
});
}
});
// only proceed if there are output ports
if (!nf.Common.isEmpty(options)) {
if (!common.isEmpty(options)) {
$('#output-port-source').show();
// sort the options
@ -322,13 +359,13 @@ nf.ConnectionConfiguration = (function () {
deferred.resolve();
} else {
var message = '\'' + nf.Common.escapeHtml(processGroupName) + '\' does not have any output ports.';
if (nf.Common.isEmpty(processGroupContents.outputPorts) === false) {
message = 'Not authorized for any output ports in \'' + nf.Common.escapeHtml(processGroupName) + '\'.';
var message = '\'' + common.escapeHtml(processGroupName) + '\' does not have any output ports.';
if (common.isEmpty(processGroupContents.outputPorts) === false) {
message = 'Not authorized for any output ports in \'' + common.escapeHtml(processGroupName) + '\'.';
}
// there are no output ports for this process group
nf.Dialog.showOkDialog({
dialog.showOkDialog({
headerText: 'Connection Configuration',
dialogContent: message
});
@ -340,7 +377,7 @@ nf.ConnectionConfiguration = (function () {
}
}).fail(function (xhr, status, error) {
// handle the error
nf.ErrorHandler.handleAjaxError(xhr, status, error);
errorHandler.handleAjaxError(xhr, status, error);
deferred.reject();
});
@ -366,7 +403,7 @@ nf.ConnectionConfiguration = (function () {
var remoteProcessGroupContents = remoteProcessGroup.contents;
// only proceed if there are output ports
if (!nf.Common.isEmpty(remoteProcessGroupContents.outputPorts)) {
if (!common.isEmpty(remoteProcessGroupContents.outputPorts)) {
$('#output-port-source').show();
// show the output port options
@ -376,7 +413,7 @@ nf.ConnectionConfiguration = (function () {
text: outputPort.name,
value: outputPort.id,
disabled: outputPort.exists === false,
description: nf.Common.escapeHtml(outputPort.comments)
description: common.escapeHtml(outputPort.comments)
});
});
@ -404,9 +441,9 @@ nf.ConnectionConfiguration = (function () {
deferred.resolve();
} else {
// there are no relationships for this processor
nf.Dialog.showOkDialog({
dialog.showOkDialog({
headerText: 'Connection Configuration',
dialogContent: '\'' + nf.Common.escapeHtml(remoteProcessGroup.name) + '\' does not have any output ports.'
dialogContent: '\'' + common.escapeHtml(remoteProcessGroup.name) + '\' does not have any output ports.'
});
// reset the dialog
@ -416,7 +453,7 @@ nf.ConnectionConfiguration = (function () {
}
}).fail(function (xhr, status, error) {
// handle the error
nf.ErrorHandler.handleAjaxError(xhr, status, error);
errorHandler.handleAjaxError(xhr, status, error);
deferred.reject();
});
@ -424,13 +461,13 @@ nf.ConnectionConfiguration = (function () {
};
var initializeDestinationNewConnectionDialog = function (destination) {
if (nf.CanvasUtils.isOutputPort(destination)) {
if (canvasUtils.isOutputPort(destination)) {
return initializeDestinationOutputPort(destination);
} else if (nf.CanvasUtils.isProcessor(destination)) {
} else if (canvasUtils.isProcessor(destination)) {
return initializeDestinationProcessor(destination);
} else if (nf.CanvasUtils.isRemoteProcessGroup(destination)) {
} else if (canvasUtils.isRemoteProcessGroup(destination)) {
return initializeDestinationRemoteProcessGroup(destination);
} else if (nf.CanvasUtils.isFunnel(destination)) {
} else if (canvasUtils.isFunnel(destination)) {
return initializeDestinationFunnel(destination);
} else {
return initializeDestinationProcessGroup(destination);
@ -450,8 +487,8 @@ nf.ConnectionConfiguration = (function () {
$('#connection-destination-component-id').val(outputPortData.id);
// populate the group details
$('#connection-destination-group-id').val(nf.Canvas.getGroupId());
$('#connection-destination-group-name').text(nf.Canvas.getGroupName());
$('#connection-destination-group-id').val(canvasUtils.getGroupId());
$('#connection-destination-group-name').text(canvasUtils.getGroupName());
deferred.resolve();
}).promise();
@ -468,8 +505,8 @@ nf.ConnectionConfiguration = (function () {
$('#connection-destination-component-id').val(funnelData.id);
// populate the group details
$('#connection-destination-group-id').val(nf.Canvas.getGroupId());
$('#connection-destination-group-name').text(nf.Canvas.getGroupName());
$('#connection-destination-group-id').val(canvasUtils.getGroupId());
$('#connection-destination-group-name').text(canvasUtils.getGroupName());
deferred.resolve();
}).promise();
@ -479,7 +516,7 @@ nf.ConnectionConfiguration = (function () {
return $.Deferred(function (deferred) {
var processorData = destination.datum();
var processorName = processorData.permissions.canRead ? processorData.component.name : processorData.id;
var processorType = processorData.permissions.canRead ? nf.Common.substringAfterLast(processorData.component.type, '.') : 'Processor';
var processorType = processorData.permissions.canRead ? common.substringAfterLast(processorData.component.type, '.') : 'Processor';
$('#processor-destination').show();
$('#processor-destination-name').text(processorName).attr('title', processorName);
@ -490,8 +527,8 @@ nf.ConnectionConfiguration = (function () {
$('#connection-destination-component-id').val(processorData.id);
// populate the group details
$('#connection-destination-group-id').val(nf.Canvas.getGroupId());
$('#connection-destination-group-name').text(nf.Canvas.getGroupName());
$('#connection-destination-group-id').val(canvasUtils.getGroupId());
$('#connection-destination-group-name').text(canvasUtils.getGroupName());
deferred.resolve();
}).promise();
@ -521,12 +558,12 @@ nf.ConnectionConfiguration = (function () {
options.push({
text: inputPort.permissions.canRead ? inputPort.component.name : inputPort.id,
value: inputPort.id,
description: inputPort.permissions.canRead ? nf.Common.escapeHtml(inputPort.component.comments) : null
description: inputPort.permissions.canRead ? common.escapeHtml(inputPort.component.comments) : null
});
});
// only proceed if there are output ports
if (!nf.Common.isEmpty(options)) {
if (!common.isEmpty(options)) {
$('#input-port-destination').show();
// sort the options
@ -553,9 +590,9 @@ nf.ConnectionConfiguration = (function () {
deferred.resolve();
} else {
// there are no relationships for this processor
nf.Dialog.showOkDialog({
dialog.showOkDialog({
headerText: 'Connection Configuration',
dialogContent: '\'' + nf.Common.escapeHtml(processGroupName) + '\' does not have any input ports.'
dialogContent: '\'' + common.escapeHtml(processGroupName) + '\' does not have any input ports.'
});
// reset the dialog
@ -565,7 +602,7 @@ nf.ConnectionConfiguration = (function () {
}
}).fail(function (xhr, status, error) {
// handle the error
nf.ErrorHandler.handleAjaxError(xhr, status, error);
errorHandler.handleAjaxError(xhr, status, error);
deferred.reject();
});
@ -591,7 +628,7 @@ nf.ConnectionConfiguration = (function () {
var remoteProcessGroupContents = remoteProcessGroup.contents;
// only proceed if there are output ports
if (!nf.Common.isEmpty(remoteProcessGroupContents.inputPorts)) {
if (!common.isEmpty(remoteProcessGroupContents.inputPorts)) {
$('#input-port-destination').show();
// show the input port options
@ -601,7 +638,7 @@ nf.ConnectionConfiguration = (function () {
text: inputPort.name,
value: inputPort.id,
disabled: inputPort.exists === false,
description: nf.Common.escapeHtml(inputPort.comments)
description: common.escapeHtml(inputPort.comments)
});
});
@ -629,9 +666,9 @@ nf.ConnectionConfiguration = (function () {
deferred.resolve();
} else {
// there are no relationships for this processor
nf.Dialog.showOkDialog({
dialog.showOkDialog({
headerText: 'Connection Configuration',
dialogContent: '\'' + nf.Common.escapeHtml(remoteProcessGroup.name) + '\' does not have any input ports.'
dialogContent: '\'' + common.escapeHtml(remoteProcessGroup.name) + '\' does not have any input ports.'
});
// reset the dialog
@ -641,7 +678,7 @@ nf.ConnectionConfiguration = (function () {
}
}).fail(function (xhr, status, error) {
// handle the error
nf.ErrorHandler.handleAjaxError(xhr, status, error);
errorHandler.handleAjaxError(xhr, status, error);
deferred.reject();
});
@ -679,11 +716,11 @@ nf.ConnectionConfiguration = (function () {
* @argument {selection} source The source
*/
var initializeSourceEditConnectionDialog = function (source) {
if (nf.CanvasUtils.isProcessor(source)) {
if (canvasUtils.isProcessor(source)) {
return initializeSourceProcessor(source);
} else if (nf.CanvasUtils.isInputPort(source)) {
} else if (canvasUtils.isInputPort(source)) {
return initializeSourceInputPort(source);
} else if (nf.CanvasUtils.isFunnel(source)) {
} else if (canvasUtils.isFunnel(source)) {
return initializeSourceFunnel(source);
} else {
return initializeSourceReadOnlyGroup(source);
@ -697,13 +734,13 @@ nf.ConnectionConfiguration = (function () {
* @argument {object} connectionDestination The connection destination object
*/
var initializeDestinationEditConnectionDialog = function (destination, connectionDestination) {
if (nf.CanvasUtils.isProcessor(destination)) {
if (canvasUtils.isProcessor(destination)) {
return initializeDestinationProcessor(destination);
} else if (nf.CanvasUtils.isOutputPort(destination)) {
} else if (canvasUtils.isOutputPort(destination)) {
return initializeDestinationOutputPort(destination);
} else if (nf.CanvasUtils.isRemoteProcessGroup(destination)) {
} else if (canvasUtils.isRemoteProcessGroup(destination)) {
return initializeDestinationRemoteProcessGroup(destination, connectionDestination);
} else if (nf.CanvasUtils.isFunnel(destination)) {
} else if (canvasUtils.isFunnel(destination)) {
return initializeDestinationFunnel(destination);
} else {
return initializeDestinationProcessGroup(destination);
@ -750,8 +787,8 @@ nf.ConnectionConfiguration = (function () {
y: sourceData.position.y + (sourceData.dimensions.height / 2)
};
var xOffset = nf.Connection.config.selfLoopXOffset;
var yOffset = nf.Connection.config.selfLoopYOffset;
var xOffset = connection.config.selfLoopXOffset;
var yOffset = connection.config.selfLoopYOffset;
bends.push({
'x': (rightCenter.x + xOffset),
'y': (rightCenter.y - yOffset)
@ -764,11 +801,11 @@ nf.ConnectionConfiguration = (function () {
var existingConnections = [];
// get all connections for the source component
var connectionsForSourceComponent = nf.Connection.getComponentConnections(sourceComponentId);
var connectionsForSourceComponent = connection.getComponentConnections(sourceComponentId);
$.each(connectionsForSourceComponent, function (_, connectionForSourceComponent) {
// get the id for the source/destination component
var connectionSourceComponentId = nf.CanvasUtils.getConnectionSourceComponentId(connectionForSourceComponent);
var connectionDestinationComponentId = nf.CanvasUtils.getConnectionDestinationComponentId(connectionForSourceComponent);
var connectionSourceComponentId = canvasUtils.getConnectionSourceComponentId(connectionForSourceComponent);
var connectionDestinationComponentId = canvasUtils.getConnectionDestinationComponentId(connectionForSourceComponent);
// if the connection is between these same components, consider it for collisions
if ((connectionSourceComponentId === sourceComponentId && connectionDestinationComponentId === destinationComponentId) ||
@ -785,7 +822,7 @@ nf.ConnectionConfiguration = (function () {
$.each(existingConnections, function (_, existingConnection) {
// only consider multiple connections with no bend points a collision, the existance of
// bend points suggests that the user has placed the connection into a desired location
if (nf.Common.isEmpty(existingConnection.bends)) {
if (common.isEmpty(existingConnection.bends)) {
avoidCollision = true;
return false;
}
@ -805,7 +842,7 @@ nf.ConnectionConfiguration = (function () {
var collides = function (x, y) {
var collides = false;
$.each(existingConnections, function (_, existingConnection) {
if (!nf.Common.isEmpty(existingConnection.bends)) {
if (!common.isEmpty(existingConnection.bends)) {
if (isMoreHorizontal) {
// horizontal lines are adjusted in the y space
if (existingConnection.bends[0].y === y) {
@ -863,8 +900,8 @@ nf.ConnectionConfiguration = (function () {
var destinationGroupId = $('#connection-destination-group-id').val();
// determine the source and destination types
var sourceType = nf.CanvasUtils.getConnectableTypeForSource(source);
var destinationType = nf.CanvasUtils.getConnectableTypeForDestination(destination);
var sourceType = canvasUtils.getConnectableTypeForSource(source);
var destinationType = canvasUtils.getConnectableTypeForDestination(destination);
// get the settings
var connectionName = $('#connection-name').val();
@ -875,7 +912,7 @@ nf.ConnectionConfiguration = (function () {
if (validateSettings()) {
var connectionEntity = {
'revision': nf.Client.getRevision({
'revision': client.getRevision({
'revision': {
'version': 0
}
@ -904,29 +941,29 @@ nf.ConnectionConfiguration = (function () {
// create the new connection
$.ajax({
type: 'POST',
url: config.urls.api + '/process-groups/' + encodeURIComponent(nf.Canvas.getGroupId()) + '/connections',
url: config.urls.api + '/process-groups/' + encodeURIComponent(canvasUtils.getGroupId()) + '/connections',
data: JSON.stringify(connectionEntity),
dataType: 'json',
contentType: 'application/json'
}).done(function (response) {
// add the connection
nf.Graph.add({
nfGraph.add({
'connections': [response]
}, {
'selectAll': true
});
// reload the connections source/destination components
nf.CanvasUtils.reloadConnectionSourceAndDestination(sourceComponentId, destinationComponentId);
canvasUtils.reloadConnectionSourceAndDestination(sourceComponentId, destinationComponentId);
// update component visibility
nf.Canvas.View.updateVisibility();
nfGraph.updateVisibility();
// update the birdseye
nf.Birdseye.refresh();
nfBirdseye.refresh();
}).fail(function (xhr, status, error) {
// handle the error
nf.ErrorHandler.handleAjaxError(xhr, status, error);
errorHandler.handleAjaxError(xhr, status, error);
});
}
};
@ -947,7 +984,7 @@ nf.ConnectionConfiguration = (function () {
// get the destination details
var destinationComponentId = $('#connection-destination-component-id').val();
var destination = d3.select('#id-' + destinationComponentId);
var destinationType = nf.CanvasUtils.getConnectableTypeForDestination(destination);
var destinationType = canvasUtils.getConnectableTypeForDestination(destination);
// get the destination details
var destinationId = $('#connection-destination-id').val();
@ -961,9 +998,9 @@ nf.ConnectionConfiguration = (function () {
var prioritizers = $('#prioritizer-selected').sortable('toArray');
if (validateSettings()) {
var d = nf.Connection.get(connectionId);
var d = connection.get(connectionId);
var connectionEntity = {
'revision': nf.Client.getRevision(d),
'revision': client.getRevision(d),
'component': {
'id': connectionId,
'name': connectionName,
@ -989,18 +1026,18 @@ nf.ConnectionConfiguration = (function () {
contentType: 'application/json'
}).done(function (response) {
// update this connection
nf.Connection.set(response);
connection.set(response);
// reload the connections source/destination components
nf.CanvasUtils.reloadConnectionSourceAndDestination(sourceComponentId, destinationComponentId);
canvasUtils.reloadConnectionSourceAndDestination(sourceComponentId, destinationComponentId);
}).fail(function (xhr, status, error) {
if (xhr.status === 400 || xhr.status === 404 || xhr.status === 409) {
nf.Dialog.showOkDialog({
dialog.showOkDialog({
headerText: 'Connection Configuration',
dialogContent: nf.Common.escapeHtml(xhr.responseText),
dialogContent: common.escapeHtml(xhr.responseText),
});
} else {
nf.ErrorHandler.handleAjaxError(xhr, status, error);
errorHandler.handleAjaxError(xhr, status, error);
}
});
} else {
@ -1041,20 +1078,20 @@ nf.ConnectionConfiguration = (function () {
var errors = [];
// validate the settings
if (nf.Common.isBlank($('#flow-file-expiration').val())) {
if (common.isBlank($('#flow-file-expiration').val())) {
errors.push('File expiration must be specified');
}
if (!$.isNumeric($('#back-pressure-object-threshold').val())) {
errors.push('Back pressure object threshold must be an integer value');
}
if (nf.Common.isBlank($('#back-pressure-data-size-threshold').val())) {
if (common.isBlank($('#back-pressure-data-size-threshold').val())) {
errors.push('Back pressure data size threshold must be specified');
}
if (errors.length > 0) {
nf.Dialog.showOkDialog({
dialog.showOkDialog({
headerText: 'Connection Configuration',
dialogContent: nf.Common.formatUnorderedList(errors)
dialogContent: common.formatUnorderedList(errors)
});
return false;
} else {
@ -1093,7 +1130,7 @@ nf.ConnectionConfiguration = (function () {
$('#relationship-names-container').hide();
// clear the id field
nf.Common.clearField('connection-id');
common.clearField('connection-id');
// hide all the connection source panels
$('#processor-source').hide();
@ -1126,8 +1163,18 @@ nf.ConnectionConfiguration = (function () {
removeTempEdge();
};
return {
init: function () {
var nfConnectionConfiguration = {
/**
* Initialize the connection configuration.
*
* @param birdseye The reference to the birdseye controller.
* @param graph The reference to the graph controller.
*/
init: function (birdseye, graph) {
nfBirdseye = birdseye;
nfGraph = graph;
// initially hide the relationship names container
$('#relationship-names-container').hide();
@ -1141,7 +1188,7 @@ nf.ConnectionConfiguration = (function () {
resetDialog();
},
open: function () {
nf.Common.toggleScrollable($('#' + this.find('.tab-container').attr('id') + '-content').get(0));
common.toggleScrollable($('#' + this.find('.tab-container').attr('id') + '-content').get(0));
}
}
});
@ -1168,7 +1215,7 @@ nf.ConnectionConfiguration = (function () {
}).done(function (response) {
// create an element for each available prioritizer
$.each(response.prioritizerTypes, function (i, documentedType) {
nf.ConnectionConfiguration.addAvailablePrioritizer('#prioritizer-available', documentedType);
nfConnectionConfiguration.addAvailablePrioritizer('#prioritizer-available', documentedType);
});
// make the prioritizer containers sortable
@ -1179,7 +1226,7 @@ nf.ConnectionConfiguration = (function () {
opacity: 0.6
});
$('#prioritizer-available, #prioritizer-selected').disableSelection();
}).fail(nf.ErrorHandler.handleAjaxError);
}).fail(errorHandler.handleAjaxError);
},
/**
@ -1190,17 +1237,17 @@ nf.ConnectionConfiguration = (function () {
*/
addAvailablePrioritizer: function (prioritizerContainer, prioritizerType) {
var type = prioritizerType.type;
var name = nf.Common.substringAfterLast(type, '.');
var name = common.substringAfterLast(type, '.');
// add the prioritizers to the available list
var prioritizerList = $(prioritizerContainer);
var prioritizer = $('<li></li>').append($('<span style="float: left;"></span>').text(name)).attr('id', type).addClass('ui-state-default').appendTo(prioritizerList);
// add the description if applicable
if (nf.Common.isDefinedAndNotNull(prioritizerType.description)) {
if (common.isDefinedAndNotNull(prioritizerType.description)) {
$('<div class="fa fa-question-circle" style="float: right; margin-right: 5px;""></div>').appendTo(prioritizer).qtip($.extend({
content: nf.Common.escapeHtml(prioritizerType.description)
}, nf.Common.config.tooltipConfig));
content: common.escapeHtml(prioritizerType.description)
}, common.config.tooltipConfig));
}
},
@ -1236,7 +1283,7 @@ nf.ConnectionConfiguration = (function () {
$('#connection-configuration div.relationship-name').ellipsis();
// fill in the connection id
nf.Common.populateField('connection-id', null);
common.populateField('connection-id', null);
// show the border if necessary
var relationshipNames = $('#relationship-names');
@ -1262,12 +1309,12 @@ nf.ConnectionConfiguration = (function () {
var connection = connectionEntry.component;
// identify the source component
var sourceComponentId = nf.CanvasUtils.getConnectionSourceComponentId(connectionEntry);
var sourceComponentId = canvasUtils.getConnectionSourceComponentId(connectionEntry);
var source = d3.select('#id-' + sourceComponentId);
// identify the destination component
if (nf.Common.isUndefinedOrNull(destination)) {
var destinationComponentId = nf.CanvasUtils.getConnectionDestinationComponentId(connectionEntry);
if (common.isUndefinedOrNull(destination)) {
var destinationComponentId = canvasUtils.getConnectionDestinationComponentId(connectionEntry);
destination = d3.select('#id-' + destinationComponentId);
}
@ -1277,7 +1324,7 @@ nf.ConnectionConfiguration = (function () {
var selectedRelationships = connection.selectedRelationships;
// show the available relationship if applicable
if (nf.Common.isDefinedAndNotNull(availableRelationships) || nf.Common.isDefinedAndNotNull(selectedRelationships)) {
if (common.isDefinedAndNotNull(availableRelationships) || common.isDefinedAndNotNull(selectedRelationships)) {
// populate the available connections
$.each(availableRelationships, function (i, name) {
createRelationshipOption(name);
@ -1304,14 +1351,14 @@ nf.ConnectionConfiguration = (function () {
}
// if the source is a process group or remote process group, select the appropriate port if applicable
if (nf.CanvasUtils.isProcessGroup(source) || nf.CanvasUtils.isRemoteProcessGroup(source)) {
if (canvasUtils.isProcessGroup(source) || canvasUtils.isRemoteProcessGroup(source)) {
// populate the connection source details
$('#connection-source-id').val(connection.source.id);
$('#read-only-output-port-name').text(connection.source.name).attr('title', connection.source.name);
}
// if the destination is a process gorup or remote process group, select the appropriate port if applicable
if (nf.CanvasUtils.isProcessGroup(destination) || nf.CanvasUtils.isRemoteProcessGroup(destination)) {
if (canvasUtils.isProcessGroup(destination) || canvasUtils.isRemoteProcessGroup(destination)) {
var destinationData = destination.datum();
// when the group ids differ, its a new destination component so we don't want to preselect any port
@ -1329,7 +1376,7 @@ nf.ConnectionConfiguration = (function () {
$('#back-pressure-data-size-threshold').val(connection.backPressureDataSizeThreshold);
// format the connection id
nf.Common.populateField('connection-id', connection.id);
common.populateField('connection-id', connection.id);
// handle each prioritizer
$.each(connection.prioritizers, function (i, type) {
@ -1353,7 +1400,7 @@ nf.ConnectionConfiguration = (function () {
var selectedRelationships = getSelectedRelationships();
// see if we're working with a processor as the source
if (nf.CanvasUtils.isProcessor(source)) {
if (canvasUtils.isProcessor(source)) {
if (selectedRelationships.length > 0) {
// if there are relationships selected update
updateConnection(selectedRelationships).done(function () {
@ -1363,7 +1410,7 @@ nf.ConnectionConfiguration = (function () {
});
} else {
// inform users that no relationships were selected and the source is a processor
nf.Dialog.showOkDialog({
dialog.showOkDialog({
headerText: 'Connection Configuration',
dialogContent: 'The connection must have at least one relationship selected.'
});
@ -1423,4 +1470,6 @@ nf.ConnectionConfiguration = (function () {
}).promise();
}
};
}());
return nfConnectionConfiguration;
}));

View File

@ -15,9 +15,44 @@
* limitations under the License.
*/
/* global nf, d3 */
/* global define, module, require, exports */
nf.Connection = (function () {
(function (root, factory) {
if (typeof define === 'function' && define.amd) {
define(['jquery',
'd3',
'nf.Common',
'nf.Dialog',
'nf.ErrorHandler',
'nf.Client',
'nf.CanvasUtils'],
function ($, d3, common, dialog, errorHandler, client, canvasUtils) {
return (nf.Connection = factory($, d3, common, dialog, errorHandler, client, canvasUtils));
});
} else if (typeof exports === 'object' && typeof module === 'object') {
module.exports = (nf.Connection =
factory(require('jquery'),
require('d3'),
require('nf.Common'),
require('nf.Dialog'),
require('nf.ErrorHandler'),
require('nf.Client'),
require('nf.CanvasUtils')));
} else {
nf.Connection = factory(root.$,
root.d3,
root.nf.Common,
root.nf.Dialog,
root.nf.ErrorHandler,
root.nf.Client,
root.nf.CanvasUtils);
}
}(this, function ($, d3, common, dialog, errorHandler, client, canvasUtils) {
'use strict';
var nfCanvas;
var nfSelectable;
var nfContextMenu;
// the dimensions for the connection label
var dimensions = {
@ -162,7 +197,7 @@ nf.Connection = (function () {
for (var i = 0; i < line.length; i++) {
if (i + 1 < line.length) {
var distance = distanceToSegment(p, line[i], line[i + 1]);
if (nf.Common.isUndefined(minimumDistance) || distance < minimumDistance) {
if (common.isUndefined(minimumDistance) || distance < minimumDistance) {
minimumDistance = distance;
index = i;
}
@ -197,7 +232,7 @@ nf.Connection = (function () {
* @param {object} terminal
*/
var isGroup = function (terminal) {
return terminal.groupId !== nf.Canvas.getGroupId() && (isInputPortType(terminal.type) || isOutputPortType(terminal.type));
return terminal.groupId !== canvasUtils.getGroupId() && (isInputPortType(terminal.type) || isOutputPortType(terminal.type));
};
/**
@ -207,7 +242,7 @@ nf.Connection = (function () {
* @return {boolean} Whether expiration is configured
*/
var isExpirationConfigured = function (connection) {
if (nf.Common.isDefinedAndNotNull(connection.flowFileExpiration)) {
if (common.isDefinedAndNotNull(connection.flowFileExpiration)) {
var match = connection.flowFileExpiration.match(/^(\d+).*/);
if (match !== null && match.length > 0) {
if (parseInt(match[0], 10) > 0) {
@ -274,9 +309,9 @@ nf.Connection = (function () {
})
.on('mousedown.selection', function () {
// select the connection when clicking the selectable path
nf.Selectable.select(d3.select(this.parentNode));
nfSelectable.select(d3.select(this.parentNode));
})
.call(nf.ContextMenu.activate);
.call(nfContextMenu.activate);
};
// determines whether the specified connection contains an unsupported relationship
@ -284,7 +319,7 @@ nf.Connection = (function () {
var unavailable = false;
// verify each selected relationship is still available
if (nf.Common.isDefinedAndNotNull(d.component.selectedRelationships) && nf.Common.isDefinedAndNotNull(d.component.availableRelationships)) {
if (common.isDefinedAndNotNull(d.component.selectedRelationships) && common.isDefinedAndNotNull(d.component.availableRelationships)) {
$.each(d.component.selectedRelationships, function (_, selectedRelationship) {
if ($.inArray(selectedRelationship, d.component.availableRelationships) === -1) {
unavailable = true;
@ -331,7 +366,7 @@ nf.Connection = (function () {
// determines whether the connection is in warning based on the object count threshold
var isWarningCount = function (d) {
var percentUseCount = d.status.aggregateSnapshot.percentUseCount;
if (nf.Common.isDefinedAndNotNull(percentUseCount)) {
if (common.isDefinedAndNotNull(percentUseCount)) {
return percentUseCount >= 61 && percentUseCount <= 85;
}
@ -341,7 +376,7 @@ nf.Connection = (function () {
// determines whether the connection is in error based on the object count threshold
var isErrorCount = function (d) {
var percentUseCount = d.status.aggregateSnapshot.percentUseCount;
if (nf.Common.isDefinedAndNotNull(percentUseCount)) {
if (common.isDefinedAndNotNull(percentUseCount)) {
return percentUseCount > 85;
}
@ -356,7 +391,7 @@ nf.Connection = (function () {
// determines whether the connection is in warning based on the data size threshold
var isWarningBytes = function (d) {
var percentUseBytes = d.status.aggregateSnapshot.percentUseBytes;
if (nf.Common.isDefinedAndNotNull(percentUseBytes)) {
if (common.isDefinedAndNotNull(percentUseBytes)) {
return percentUseBytes >= 61 && percentUseBytes <= 85;
}
@ -366,7 +401,7 @@ nf.Connection = (function () {
// determines whether the connection is in error based on the data size threshold
var isErrorBytes = function (d) {
var percentUseBytes = d.status.aggregateSnapshot.percentUseBytes;
if (nf.Common.isDefinedAndNotNull(percentUseBytes)) {
if (common.isDefinedAndNotNull(percentUseBytes)) {
return percentUseBytes > 85;
}
@ -384,10 +419,10 @@ nf.Connection = (function () {
var transition = false;
// extract the options if specified
if (nf.Common.isDefinedAndNotNull(options)) {
updatePath = nf.Common.isDefinedAndNotNull(options.updatePath) ? options.updatePath : updatePath;
updateLabel = nf.Common.isDefinedAndNotNull(options.updateLabel) ? options.updateLabel : updateLabel;
transition = nf.Common.isDefinedAndNotNull(options.transition) ? options.transition : transition;
if (common.isDefinedAndNotNull(options)) {
updatePath = common.isDefinedAndNotNull(options.updatePath) ? options.updatePath : updatePath;
updateLabel = common.isDefinedAndNotNull(options.updateLabel) ? options.updateLabel : updateLabel;
transition = common.isDefinedAndNotNull(options.transition) ? options.transition : transition;
}
if (updatePath === true) {
@ -397,7 +432,7 @@ nf.Connection = (function () {
if (d.permissions.canRead) {
// if there are more than one selected relationship, mark this as grouped
if (nf.Common.isDefinedAndNotNull(d.component.selectedRelationships) && d.component.selectedRelationships.length > 1) {
if (common.isDefinedAndNotNull(d.component.selectedRelationships) && d.component.selectedRelationships.length > 1) {
grouped = true;
}
}
@ -472,7 +507,7 @@ nf.Connection = (function () {
if (updatePath === true) {
// calculate the start and end points
var sourceComponentId = nf.CanvasUtils.getConnectionSourceComponentId(d);
var sourceComponentId = canvasUtils.getConnectionSourceComponentId(d);
var sourceData = d3.select('#id-' + sourceComponentId).datum();
var end;
@ -487,9 +522,9 @@ nf.Connection = (function () {
};
}
// if we are currently dragging the endpoint to a new target, use that
// if we are currently dragging the endpoint to a new target, use that
// position, otherwise we need to calculate it for the current target
if (nf.Common.isDefinedAndNotNull(d.end) && d.end.dragging === true) {
if (common.isDefinedAndNotNull(d.end) && d.end.dragging === true) {
// since we're dragging, use the same object thats bound to the endpoint drag event
end = d.end;
@ -499,7 +534,7 @@ nf.Connection = (function () {
var newDestinationData = newDestination.datum();
// get the position on the new destination perimeter
var newEnd = nf.CanvasUtils.getPerimeterPoint(endAnchor, {
var newEnd = canvasUtils.getPerimeterPoint(endAnchor, {
'x': newDestinationData.position.x,
'y': newDestinationData.position.y,
'width': newDestinationData.dimensions.width,
@ -511,11 +546,11 @@ nf.Connection = (function () {
end.y = newEnd.y;
}
} else {
var destinationComponentId = nf.CanvasUtils.getConnectionDestinationComponentId(d);
var destinationComponentId = canvasUtils.getConnectionDestinationComponentId(d);
var destinationData = d3.select('#id-' + destinationComponentId).datum();
// get the position on the destination perimeter
end = nf.CanvasUtils.getPerimeterPoint(endAnchor, {
end = canvasUtils.getPerimeterPoint(endAnchor, {
'x': destinationData.position.x,
'y': destinationData.position.y,
'width': destinationData.dimensions.width,
@ -532,7 +567,7 @@ nf.Connection = (function () {
}
// get the position on the source perimeter
var start = nf.CanvasUtils.getPerimeterPoint(startAnchor, {
var start = canvasUtils.getPerimeterPoint(startAnchor, {
'x': sourceData.position.x,
'y': sourceData.position.y,
'width': sourceData.dimensions.width,
@ -544,21 +579,21 @@ nf.Connection = (function () {
d.end = end;
// update the connection paths
nf.CanvasUtils.transition(connection.select('path.connection-path'), transition)
canvasUtils.transition(connection.select('path.connection-path'), transition)
.attr({
'd': function () {
var datum = [d.start].concat(d.bends, [d.end]);
return lineGenerator(datum);
}
});
nf.CanvasUtils.transition(connection.select('path.connection-selection-path'), transition)
canvasUtils.transition(connection.select('path.connection-selection-path'), transition)
.attr({
'd': function () {
var datum = [d.start].concat(d.bends, [d.end]);
return lineGenerator(datum);
}
});
nf.CanvasUtils.transition(connection.select('path.connection-path-selectable'), transition)
canvasUtils.transition(connection.select('path.connection-path-selectable'), transition)
.attr({
'd': function () {
var datum = [d.start].concat(d.bends, [d.end]);
@ -594,12 +629,12 @@ nf.Connection = (function () {
})
.on('mousedown.selection', function () {
// select the connection when clicking the label
nf.Selectable.select(d3.select(this.parentNode));
nfSelectable.select(d3.select(this.parentNode));
})
.call(nf.ContextMenu.activate);
.call(nfContextMenu.activate);
// update the start point
nf.CanvasUtils.transition(startpoints, transition)
canvasUtils.transition(startpoints, transition)
.attr('transform', function (p) {
return 'translate(' + (p.x - 4) + ', ' + (p.y - 4) + ')';
});
@ -624,12 +659,12 @@ nf.Connection = (function () {
})
.on('mousedown.selection', function () {
// select the connection when clicking the label
nf.Selectable.select(d3.select(this.parentNode));
nfSelectable.select(d3.select(this.parentNode));
})
.call(nf.ContextMenu.activate);
.call(nfContextMenu.activate);
// update the end point
nf.CanvasUtils.transition(endpoints, transition)
canvasUtils.transition(endpoints, transition)
.attr('transform', function (p) {
return 'translate(' + (p.x - 4) + ', ' + (p.y - 4) + ')';
});
@ -660,10 +695,10 @@ nf.Connection = (function () {
var connectionData = connection.datum();
// if this is a self loop prevent removing the last two bends
var sourceComponentId = nf.CanvasUtils.getConnectionSourceComponentId(connectionData);
var destinationComponentId = nf.CanvasUtils.getConnectionDestinationComponentId(connectionData);
var sourceComponentId = canvasUtils.getConnectionSourceComponentId(connectionData);
var destinationComponentId = canvasUtils.getConnectionDestinationComponentId(connectionData);
if (sourceComponentId === destinationComponentId && d.component.bends.length <= 2) {
nf.Dialog.showOkDialog({
dialog.showOkDialog({
headerText: 'Connection',
dialogContent: 'Looping connections must have at least two bend points.'
});
@ -704,12 +739,12 @@ nf.Connection = (function () {
})
.on('mousedown.selection', function () {
// select the connection when clicking the label
nf.Selectable.select(d3.select(this.parentNode));
nfSelectable.select(d3.select(this.parentNode));
})
.call(nf.ContextMenu.activate);
.call(nfContextMenu.activate);
// update the midpoints
nf.CanvasUtils.transition(midpoints, transition)
canvasUtils.transition(midpoints, transition)
.attr('transform', function (p) {
return 'translate(' + (p.x - 4) + ', ' + (p.y - 4) + ')';
});
@ -730,7 +765,7 @@ nf.Connection = (function () {
// update visible connections
if (connection.classed('visible')) {
// if there is no connection label this connection is becoming
// if there is no connection label this connection is becoming
// visible so we need to render it
if (connectionLabelContainer.empty()) {
// connection label container
@ -741,9 +776,9 @@ nf.Connection = (function () {
})
.on('mousedown.selection', function () {
// select the connection when clicking the label
nf.Selectable.select(d3.select(this.parentNode));
nfSelectable.select(d3.select(this.parentNode));
})
.call(nf.ContextMenu.activate);
.call(nfContextMenu.activate);
// connection label
connectionLabelContainer.append('rect')
@ -846,7 +881,7 @@ nf.Connection = (function () {
connectionFromLabel.text(null).selectAll('title').remove();
// apply ellipsis to the label as necessary
nf.CanvasUtils.ellipsis(connectionFromLabel, d.component.source.name);
canvasUtils.ellipsis(connectionFromLabel, d.component.source.name);
}).append('title').text(function () {
return d.component.source.name;
});
@ -955,7 +990,7 @@ nf.Connection = (function () {
connectionToLabel.text(null).selectAll('title').remove();
// apply ellipsis to the label as necessary
nf.CanvasUtils.ellipsis(connectionToLabel, d.component.destination.name);
canvasUtils.ellipsis(connectionToLabel, d.component.destination.name);
}).append('title').text(function (d) {
return d.component.destination.name;
});
@ -998,10 +1033,10 @@ nf.Connection = (function () {
// -----------------------
// get the connection name
var connectionNameValue = nf.CanvasUtils.formatConnectionName(d.component);
var connectionNameValue = canvasUtils.formatConnectionName(d.component);
// is there a name to render
if (!nf.Common.isBlank(connectionNameValue)) {
if (!common.isBlank(connectionNameValue)) {
// see if the connection name label is already rendered
if (connectionName.empty()) {
connectionName = connectionLabelContainer.append('g')
@ -1060,7 +1095,7 @@ nf.Connection = (function () {
connectionToLabel.text(null).selectAll('title').remove();
// apply ellipsis to the label as necessary
nf.CanvasUtils.ellipsis(connectionToLabel, connectionNameValue);
canvasUtils.ellipsis(connectionToLabel, connectionNameValue);
}).append('title').text(function () {
return connectionNameValue;
});
@ -1288,31 +1323,31 @@ nf.Connection = (function () {
}
})
.select('title').text(function () {
if (d.permissions.canRead) {
return 'Expires FlowFiles older than ' + d.component.flowFileExpiration;
} else {
return '';
}
});
if (d.permissions.canRead) {
return 'Expires FlowFiles older than ' + d.component.flowFileExpiration;
} else {
return '';
}
});
// update backpressure object fill
connectionLabelContainer.select('rect.backpressure-object')
.classed('not-configured', function () {
return nf.Common.isUndefinedOrNull(d.status.aggregateSnapshot.percentUseCount);
return common.isUndefinedOrNull(d.status.aggregateSnapshot.percentUseCount);
});
connectionLabelContainer.selectAll('rect.backpressure-tick.object')
.classed('not-configured', function () {
return nf.Common.isUndefinedOrNull(d.status.aggregateSnapshot.percentUseCount);
return common.isUndefinedOrNull(d.status.aggregateSnapshot.percentUseCount);
});
// update backpressure data size fill
connectionLabelContainer.select('rect.backpressure-data-size')
.classed('not-configured', function () {
return nf.Common.isUndefinedOrNull(d.status.aggregateSnapshot.percentUseBytes);
return common.isUndefinedOrNull(d.status.aggregateSnapshot.percentUseBytes);
});
connectionLabelContainer.selectAll('rect.backpressure-tick.data-size')
.classed('not-configured', function () {
return nf.Common.isUndefinedOrNull(d.status.aggregateSnapshot.percentUseBytes);
return common.isUndefinedOrNull(d.status.aggregateSnapshot.percentUseBytes);
});
if (d.permissions.canWrite) {
@ -1330,7 +1365,7 @@ nf.Connection = (function () {
}
// update the position of the label if possible
nf.CanvasUtils.transition(connection.select('g.connection-label-container'), transition)
canvasUtils.transition(connection.select('g.connection-label-container'), transition)
.attr('transform', function () {
var label = d3.select(this).select('rect.body');
var position = getLabelPosition(label);
@ -1354,7 +1389,7 @@ nf.Connection = (function () {
// queued count value
updated.select('text.queued tspan.count')
.text(function (d) {
return nf.Common.substringBeforeFirst(d.status.aggregateSnapshot.queued, ' ');
return common.substringBeforeFirst(d.status.aggregateSnapshot.queued, ' ');
});
var backpressurePercentDataSize = updated.select('rect.backpressure-percent.data-size');
@ -1362,26 +1397,26 @@ nf.Connection = (function () {
.duration(400)
.attr({
'width': function (d) {
if (nf.Common.isDefinedAndNotNull(d.status.aggregateSnapshot.percentUseBytes)) {
if (common.isDefinedAndNotNull(d.status.aggregateSnapshot.percentUseBytes)) {
return (backpressureBarWidth * d.status.aggregateSnapshot.percentUseBytes) / 100;
} else {
return 0;
}
}
}).each('end', function () {
backpressurePercentDataSize
.classed('warning', function (d) {
return isWarningBytes(d);
})
.classed('error', function (d) {
return isErrorBytes(d);
});
backpressurePercentDataSize
.classed('warning', function (d) {
return isWarningBytes(d);
})
.classed('error', function (d) {
return isErrorBytes(d);
});
deferred.resolve();
});
deferred.resolve();
});
updated.select('rect.backpressure-data-size').select('title').text(function (d) {
if (nf.Common.isDefinedAndNotNull(d.status.aggregateSnapshot.percentUseBytes)) {
if (common.isDefinedAndNotNull(d.status.aggregateSnapshot.percentUseBytes)) {
return 'Queue is ' + d.status.aggregateSnapshot.percentUseBytes + '% full based on Back Pressure Data Size Threshold';
} else {
return 'Back Pressure Data Size Threshold is not configured';
@ -1394,7 +1429,7 @@ nf.Connection = (function () {
// queued size value
updated.select('text.queued tspan.size')
.text(function (d) {
return ' ' + nf.Common.substringAfterFirst(d.status.aggregateSnapshot.queued, ' ');
return ' ' + common.substringAfterFirst(d.status.aggregateSnapshot.queued, ' ');
});
var backpressurePercentObject = updated.select('rect.backpressure-percent.object');
@ -1402,26 +1437,26 @@ nf.Connection = (function () {
.duration(400)
.attr({
'width': function (d) {
if (nf.Common.isDefinedAndNotNull(d.status.aggregateSnapshot.percentUseCount)) {
if (common.isDefinedAndNotNull(d.status.aggregateSnapshot.percentUseCount)) {
return (backpressureBarWidth * d.status.aggregateSnapshot.percentUseCount) / 100;
} else {
return 0;
}
}
}).each('end', function () {
backpressurePercentObject
.classed('warning', function (d) {
return isWarningCount(d);
})
.classed('error', function (d) {
return isErrorCount(d);
});
backpressurePercentObject
.classed('warning', function (d) {
return isWarningCount(d);
})
.classed('error', function (d) {
return isErrorCount(d);
});
deferred.resolve();
});
deferred.resolve();
});
updated.select('rect.backpressure-object').select('title').text(function (d) {
if (nf.Common.isDefinedAndNotNull(d.status.aggregateSnapshot.percentUseCount)) {
if (common.isDefinedAndNotNull(d.status.aggregateSnapshot.percentUseCount)) {
return 'Queue is ' + d.status.aggregateSnapshot.percentUseCount + '% full based on Back Pressure Object Threshold';
} else {
return 'Back Pressure Object Threshold is not configured';
@ -1463,7 +1498,7 @@ nf.Connection = (function () {
*/
var save = function (d, connection) {
var entity = {
'revision': nf.Client.getRevision(d),
'revision': client.getRevision(d),
'component': connection
};
@ -1475,15 +1510,15 @@ nf.Connection = (function () {
contentType: 'application/json'
}).done(function (response) {
// request was successful, update the entry
nf.Connection.set(response);
nfConnection.set(response);
}).fail(function (xhr, status, error) {
if (xhr.status === 400 || xhr.status === 404 || xhr.status === 409) {
nf.Dialog.showOkDialog({
dialog.showOkDialog({
headerText: 'Connection',
dialogContent: nf.Common.escapeHtml(xhr.responseText)
dialogContent: common.escapeHtml(xhr.responseText)
});
} else {
nf.ErrorHandler.handleAjaxError(xhr, status, error);
errorHandler.handleAjaxError(xhr, status, error);
}
});
};
@ -1492,20 +1527,23 @@ nf.Connection = (function () {
var removeConnections = function (removed) {
// consider reloading source/destination of connection being removed
removed.each(function (d) {
nf.CanvasUtils.reloadConnectionSourceAndDestination(d.sourceId, d.destinationId);
canvasUtils.reloadConnectionSourceAndDestination(d.sourceId, d.destinationId);
});
// remove the connection
removed.remove();
};
return {
var nfConnection = {
config: {
selfLoopXOffset: (dimensions.width / 2) + 5,
selfLoopYOffset: 25
},
init: function () {
init: function (selectable, contextMenu) {
nfSelectable = selectable;
nfContextMenu = contextMenu;
connectionMap = d3.map();
removedCache = d3.map();
addedCache = d3.map();
@ -1600,7 +1638,7 @@ nf.Connection = (function () {
// ensure the new destination is valid
d3.select('g.hover').classed('connectable-destination', function () {
return nf.CanvasUtils.isValidConnectionDestination(d3.select(this));
return canvasUtils.isValidConnectionDestination(d3.select(this));
});
// redraw this connection
@ -1629,11 +1667,11 @@ nf.Connection = (function () {
});
} else {
// prompt for the new port if appropriate
if (nf.CanvasUtils.isProcessGroup(destination) || nf.CanvasUtils.isRemoteProcessGroup(destination)) {
if (canvasUtils.isProcessGroup(destination) || canvasUtils.isRemoteProcessGroup(destination)) {
// user will select new port and updated connect details will be set accordingly
nf.ConnectionConfiguration.showConfiguration(connection, destination).done(function () {
nfConnectionConfiguration.showConfiguration(connection, destination).done(function () {
// reload the previous destination
nf.CanvasUtils.reloadConnectionSourceAndDestination(null, previousDestinationId);
canvasUtils.reloadConnectionSourceAndDestination(null, previousDestinationId);
}).fail(function () {
// reset the connection
connection.call(updateConnections, {
@ -1644,15 +1682,15 @@ nf.Connection = (function () {
} else {
// get the destination details
var destinationData = destination.datum();
var destinationType = nf.CanvasUtils.getConnectableTypeForDestination(destination);
var destinationType = canvasUtils.getConnectableTypeForDestination(destination);
var connectionEntity = {
'revision': nf.Client.getRevision(connectionData),
'revision': client.getRevision(connectionData),
'component': {
'id': connectionData.id,
'destination': {
'id': destinationData.id,
'groupId': nf.Canvas.getGroupId(),
'groupId': canvasUtils.getGroupId(),
'type': destinationType
}
}
@ -1664,8 +1702,8 @@ nf.Connection = (function () {
x: destinationData.position.x + (destinationData.dimensions.width),
y: destinationData.position.y + (destinationData.dimensions.height / 2)
};
var xOffset = nf.Connection.config.selfLoopXOffset;
var yOffset = nf.Connection.config.selfLoopYOffset;
var xOffset = nfConnection.config.selfLoopXOffset;
var yOffset = nfConnection.config.selfLoopYOffset;
connectionEntity.component.bends = [];
connectionEntity.component.bends.push({
@ -1688,16 +1726,16 @@ nf.Connection = (function () {
var updatedConnectionData = response.component;
// refresh to update the label
nf.Connection.set(response);
nfConnection.set(response);
// reload the previous destination and the new source/destination
nf.CanvasUtils.reloadConnectionSourceAndDestination(null, previousDestinationId);
nf.CanvasUtils.reloadConnectionSourceAndDestination(response.sourceId, response.destinationId);
canvasUtils.reloadConnectionSourceAndDestination(null, previousDestinationId);
canvasUtils.reloadConnectionSourceAndDestination(response.sourceId, response.destinationId);
}).fail(function (xhr, status, error) {
if (xhr.status === 400 || xhr.status === 401 || xhr.status === 403 || xhr.status === 404 || xhr.status === 409) {
nf.Dialog.showOkDialog({
dialog.showOkDialog({
headerText: 'Connection',
dialogContent: nf.Common.escapeHtml(xhr.responseText)
dialogContent: common.escapeHtml(xhr.responseText)
});
// reset the connection
@ -1706,7 +1744,7 @@ nf.Connection = (function () {
'updateLabel': false
});
} else {
nf.ErrorHandler.handleAjaxError(xhr, status, error);
errorHandler.handleAjaxError(xhr, status, error);
}
});
}
@ -1743,10 +1781,10 @@ nf.Connection = (function () {
.attr('width', width)
.attr('height', height)
.attr('stroke-width', function () {
return 1 / nf.Canvas.View.scale();
return 1 / canvasUtils.scaleCanvasView();
})
.attr('stroke-dasharray', function () {
return 4 / nf.Canvas.View.scale();
return 4 / canvasUtils.scaleCanvasView();
})
.datum({
x: position.x,
@ -1847,8 +1885,8 @@ nf.Connection = (function () {
*/
add: function (connectionEntities, options) {
var selectAll = false;
if (nf.Common.isDefinedAndNotNull(options)) {
selectAll = nf.Common.isDefinedAndNotNull(options.selectAll) ? options.selectAll : selectAll;
if (common.isDefinedAndNotNull(options)) {
selectAll = common.isDefinedAndNotNull(options.selectAll) ? options.selectAll : selectAll;
}
// get the current time
@ -1868,7 +1906,7 @@ nf.Connection = (function () {
$.each(connectionEntities, function (_, connectionEntity) {
add(connectionEntity);
});
} else if (nf.Common.isDefinedAndNotNull(connectionEntities)) {
} else if (common.isDefinedAndNotNull(connectionEntities)) {
add(connectionEntities);
}
@ -1881,6 +1919,56 @@ nf.Connection = (function () {
}).call(sort);
},
/**
* Determines if the specified selection is disconnected from other nodes.
*
* @argument {selection} selection The selection
*/
isDisconnected: function (selection) {
// if nothing is selected return
if (selection.empty()) {
return false;
}
var connections = d3.map();
var components = d3.map();
var isDisconnected = true;
// include connections
selection.filter(function (d) {
return d.type === 'Connection';
}).each(function (d) {
connections.set(d.id, d);
});
// include components and ensure their connections are included
selection.filter(function (d) {
return d.type !== 'Connection';
}).each(function (d) {
components.set(d.id, d.component);
// check all connections of this component
$.each(nfConnection.getComponentConnections(d.id), function (_, connection) {
if (!connections.has(connection.id)) {
isDisconnected = false;
return false;
}
});
});
if (isDisconnected) {
// go through each connection to ensure its source and destination are included
connections.forEach(function (id, connection) {
if (isDisconnected) {
// determine whether this connection and its components are included within the selection
isDisconnected = components.has(canvasUtils.getConnectionSourceComponentId(connection)) && components.has(canvasUtils.getConnectionDestinationComponentId(connection));
}
});
}
return isDisconnected;
},
/**
* Populates the graph with the specified connections.
*
@ -1890,16 +1978,16 @@ nf.Connection = (function () {
set: function (connectionEntities, options) {
var selectAll = false;
var transition = false;
if (nf.Common.isDefinedAndNotNull(options)) {
selectAll = nf.Common.isDefinedAndNotNull(options.selectAll) ? options.selectAll : selectAll;
transition = nf.Common.isDefinedAndNotNull(options.transition) ? options.transition : transition;
if (common.isDefinedAndNotNull(options)) {
selectAll = common.isDefinedAndNotNull(options.selectAll) ? options.selectAll : selectAll;
transition = common.isDefinedAndNotNull(options.transition) ? options.transition : transition;
}
var set = function (proposedConnectionEntity) {
var currentConnectionEntity = connectionMap.get(proposedConnectionEntity.id);
// set the connection if appropriate due to revision and wasn't previously removed
if (nf.Client.isNewerRevision(currentConnectionEntity, proposedConnectionEntity) && !removedCache.has(proposedConnectionEntity.id)) {
if (client.isNewerRevision(currentConnectionEntity, proposedConnectionEntity) && !removedCache.has(proposedConnectionEntity.id)) {
connectionMap.set(proposedConnectionEntity.id, $.extend({
type: 'Connection'
}, proposedConnectionEntity));
@ -1922,7 +2010,7 @@ nf.Connection = (function () {
$.each(connectionEntities, function (_, connectionEntity) {
set(connectionEntity);
});
} else if (nf.Common.isDefinedAndNotNull(connectionEntities)) {
} else if (common.isDefinedAndNotNull(connectionEntities)) {
set(connectionEntities);
}
@ -1943,7 +2031,7 @@ nf.Connection = (function () {
* @param {string} connectionId
*/
refresh: function (connectionId) {
if (nf.Common.isDefinedAndNotNull(connectionId)) {
if (common.isDefinedAndNotNull(connectionId)) {
d3.select('#id-' + connectionId).call(updateConnections, {
'updatePath': true,
'updateLabel': true
@ -1992,7 +2080,7 @@ nf.Connection = (function () {
* Removes all processors.
*/
removeAll: function () {
nf.Connection.remove(connectionMap.keys());
nfConnection.remove(connectionMap.keys());
},
/**
@ -2008,7 +2096,7 @@ nf.Connection = (function () {
url: connectionEntity.uri,
dataType: 'json'
}).done(function (response) {
nf.Connection.set(response);
nfConnection.set(response);
});
}
},
@ -2046,7 +2134,7 @@ nf.Connection = (function () {
var connections = [];
connectionMap.forEach(function (_, entry) {
// see if this component is the source or destination of this connection
if (nf.CanvasUtils.getConnectionSourceComponentId(entry) === id || nf.CanvasUtils.getConnectionDestinationComponentId(entry) === id) {
if (canvasUtils.getConnectionSourceComponentId(entry) === id || canvasUtils.getConnectionDestinationComponentId(entry) === id) {
connections.push(entry);
}
});
@ -2060,7 +2148,7 @@ nf.Connection = (function () {
* @param {string} id
*/
get: function (id) {
if (nf.Common.isUndefined(id)) {
if (common.isUndefined(id)) {
return connectionMap.values();
} else {
return connectionMap.get(id);
@ -2085,4 +2173,6 @@ nf.Connection = (function () {
expire(removedCache);
}
};
}());
return nfConnection;
}));

View File

@ -15,9 +15,39 @@
* limitations under the License.
*/
/* global nf, d3 */
/* global define, module, require, exports */
nf.ContextMenu = (function () {
(function (root, factory) {
if (typeof define === 'function' && define.amd) {
define(['jquery',
'd3',
'nf.ErrorHandler',
'nf.Common',
'nf.CanvasUtils',
'nf.ng.Bridge'],
function ($, d3, errorHandler, common, canvasUtils, angularBridge) {
return (nf.ContextMenu = factory($, d3, errorHandler, common, canvasUtils, angularBridge));
});
} else if (typeof exports === 'object' && typeof module === 'object') {
module.exports = (nf.ContextMenu =
factory(require('jquery'),
require('d3'),
require('nf.ErrorHandler'),
require('nf.Common'),
require('nf.CanvasUtils'),
require('nf.ng.Bridge')));
} else {
nf.ContextMenu = factory(root.$,
root.d3,
root.nf.ErrorHandler,
root.nf.Common,
root.nf.CanvasUtils,
root.nf.ng.Bridge);
}
}(this, function ($, d3, errorHandler, common, canvasUtils, angularBridge) {
'use strict';
var nfActions;
/**
* Returns whether the current group is not the root group.
@ -25,57 +55,57 @@ nf.ContextMenu = (function () {
* @param {selection} selection The selection of currently selected components
*/
var isNotRootGroup = function (selection) {
return nf.Canvas.getParentGroupId() !== null && selection.empty();
return canvasUtils.getParentGroupId() !== null && selection.empty();
};
/**
* Determines whether the component in the specified selection is configurable.
*
*
* @param {selection} selection The selection of currently selected components
*/
var isConfigurable = function (selection) {
return nf.CanvasUtils.isConfigurable(selection);
return canvasUtils.isConfigurable(selection);
};
/**
* Determines whether the component in the specified selection has configuration details.
*
*
* @param {selection} selection The selection of currently selected components
*/
var hasDetails = function (selection) {
return nf.CanvasUtils.hasDetails(selection);
return canvasUtils.hasDetails(selection);
};
/**
* Determines whether the components in the specified selection are deletable.
*
* @param {selection} selection The selection of currently selected components
*
* @param {selection} selection The selection of currently selected components
*/
var isDeletable = function (selection) {
return nf.CanvasUtils.areDeletable(selection);
return canvasUtils.areDeletable(selection);
};
/**
* Determines whether the components in the specified selection are runnable.
*
* @param {selection} selection The selection of currently selected components
*
* @param {selection} selection The selection of currently selected components
*/
var isRunnable = function (selection) {
return nf.CanvasUtils.areRunnable(selection);
return canvasUtils.areRunnable(selection);
};
/**
* Determines whether the components in the specified selection are stoppable.
*
* @param {selection} selection The selection of currently selected components
*
* @param {selection} selection The selection of currently selected components
*/
var isStoppable = function (selection) {
return nf.CanvasUtils.areStoppable(selection);
return canvasUtils.areStoppable(selection);
};
/**
* Determines whether the components in the specified selection support stats.
*
*
* @param {selection} selection The selection of currently selected components
*/
var supportsStats = function (selection) {
@ -84,12 +114,12 @@ nf.ContextMenu = (function () {
return false;
}
return nf.CanvasUtils.isProcessor(selection) || nf.CanvasUtils.isProcessGroup(selection) || nf.CanvasUtils.isRemoteProcessGroup(selection) || nf.CanvasUtils.isConnection(selection);
return canvasUtils.isProcessor(selection) || canvasUtils.isProcessGroup(selection) || canvasUtils.isRemoteProcessGroup(selection) || canvasUtils.isConnection(selection);
};
/**
* Determines whether the components in the specified selection has usage documentation.
*
*
* @param {selection} selection The selection of currently selected components
*/
var hasUsage = function (selection) {
@ -97,43 +127,43 @@ nf.ContextMenu = (function () {
if (selection.size() !== 1) {
return false;
}
if (nf.CanvasUtils.canRead(selection) === false) {
if (canvasUtils.canRead(selection) === false) {
return false;
}
return nf.CanvasUtils.isProcessor(selection);
return canvasUtils.isProcessor(selection);
};
/**
* Determines whether there is one component selected.
*
*
* @param {selection} selection The selection of currently selected components
*/
var isNotConnection = function (selection) {
return selection.size() === 1 && !nf.CanvasUtils.isConnection(selection);
return selection.size() === 1 && !canvasUtils.isConnection(selection);
};
/**
* Determines whether the components in the specified selection are copyable.
*
*
* @param {selection} selection The selection of currently selected components
*/
var isCopyable = function (selection) {
return nf.CanvasUtils.isCopyable(selection);
return canvasUtils.isCopyable(selection);
};
/**
* Determines whether the components in the specified selection are pastable.
*
*
* @param {selection} selection The selection of currently selected components
*/
var isPastable = function (selection) {
return nf.CanvasUtils.isPastable();
return canvasUtils.isPastable();
};
/**
* Determines whether the specified selection is empty.
*
*
* @param {selection} selection The seleciton
*/
var emptySelection = function (selection) {
@ -142,7 +172,7 @@ nf.ContextMenu = (function () {
/**
* Determines whether the componets in the specified selection support being moved to the front.
*
*
* @param {selection} selection The selection
*/
var canMoveToFront = function (selection) {
@ -150,11 +180,11 @@ nf.ContextMenu = (function () {
if (selection.size() !== 1) {
return false;
}
if (nf.CanvasUtils.canModify(selection) === false) {
if (canvasUtils.canModify(selection) === false) {
return false;
}
return nf.CanvasUtils.isConnection(selection);
return canvasUtils.isConnection(selection);
};
/**
@ -163,7 +193,7 @@ nf.ContextMenu = (function () {
* @param {selection} selection The selection
*/
var canAlign = function (selection) {
return nf.CanvasUtils.canAlign(selection);
return canvasUtils.canAlign(selection);
};
/**
@ -172,12 +202,12 @@ nf.ContextMenu = (function () {
* @param {selection} selection The selection
*/
var isColorable = function (selection) {
return nf.CanvasUtils.isColorable(selection);
return canvasUtils.isColorable(selection);
};
/**
* Determines whether the component in the specified selection is a connection.
*
*
* @param {selection} selection The selection
*/
var isConnection = function (selection) {
@ -186,12 +216,12 @@ nf.ContextMenu = (function () {
return false;
}
return nf.CanvasUtils.isConnection(selection);
return canvasUtils.isConnection(selection);
};
/**
* Determines whether the component in the specified selection could possibly have downstream components.
*
*
* @param {selection} selection The selection
*/
var hasDownstream = function (selection) {
@ -200,14 +230,14 @@ nf.ContextMenu = (function () {
return false;
}
return nf.CanvasUtils.isFunnel(selection) || nf.CanvasUtils.isProcessor(selection) || nf.CanvasUtils.isProcessGroup(selection) ||
nf.CanvasUtils.isRemoteProcessGroup(selection) || nf.CanvasUtils.isInputPort(selection) ||
(nf.CanvasUtils.isOutputPort(selection) && nf.Canvas.getParentGroupId() !== null);
return canvasUtils.isFunnel(selection) || canvasUtils.isProcessor(selection) || canvasUtils.isProcessGroup(selection) ||
canvasUtils.isRemoteProcessGroup(selection) || canvasUtils.isInputPort(selection) ||
(canvasUtils.isOutputPort(selection) && canvasUtils.getParentGroupId() !== null);
};
/**
* Determines whether the component in the specified selection could possibly have upstream components.
*
*
* @param {selection} selection The selection
*/
var hasUpstream = function (selection) {
@ -216,9 +246,9 @@ nf.ContextMenu = (function () {
return false;
}
return nf.CanvasUtils.isFunnel(selection) || nf.CanvasUtils.isProcessor(selection) || nf.CanvasUtils.isProcessGroup(selection) ||
nf.CanvasUtils.isRemoteProcessGroup(selection) || nf.CanvasUtils.isOutputPort(selection) ||
(nf.CanvasUtils.isInputPort(selection) && nf.Canvas.getParentGroupId() !== null);
return canvasUtils.isFunnel(selection) || canvasUtils.isProcessor(selection) || canvasUtils.isProcessGroup(selection) ||
canvasUtils.isRemoteProcessGroup(selection) || canvasUtils.isOutputPort(selection) ||
(canvasUtils.isInputPort(selection) && canvasUtils.getParentGroupId() !== null);
};
/**
@ -231,11 +261,11 @@ nf.ContextMenu = (function () {
if (selection.size() !== 1) {
return false;
}
if (nf.CanvasUtils.canRead(selection) === false || nf.CanvasUtils.canModify(selection) === false) {
if (canvasUtils.canRead(selection) === false || canvasUtils.canModify(selection) === false) {
return false;
}
if (nf.CanvasUtils.isProcessor(selection)) {
if (canvasUtils.isProcessor(selection)) {
var processorData = selection.datum();
return processorData.component.persistsState === true;
} else {
@ -245,7 +275,7 @@ nf.ContextMenu = (function () {
/**
* Determines whether the current selection is a process group.
*
*
* @param {selection} selection
*/
var isProcessGroup = function (selection) {
@ -254,7 +284,7 @@ nf.ContextMenu = (function () {
return false;
}
return nf.CanvasUtils.isProcessGroup(selection);
return canvasUtils.isProcessGroup(selection);
};
/**
@ -268,56 +298,56 @@ nf.ContextMenu = (function () {
return false;
}
return !nf.CanvasUtils.isLabel(selection) && !nf.CanvasUtils.isConnection(selection) && !nf.CanvasUtils.isProcessGroup(selection)
&& !nf.CanvasUtils.isRemoteProcessGroup(selection) && nf.Common.canAccessProvenance();
return !canvasUtils.isLabel(selection) && !canvasUtils.isConnection(selection) && !canvasUtils.isProcessGroup(selection)
&& !canvasUtils.isRemoteProcessGroup(selection) && common.canAccessProvenance();
};
/**
* Determines whether the current selection is a remote process group.
*
* @param {selection} selection
*
* @param {selection} selection
*/
var isRemoteProcessGroup = function (selection) {
// ensure the correct number of components are selected
if (selection.size() !== 1) {
return false;
}
if (nf.CanvasUtils.canRead(selection) === false) {
if (canvasUtils.canRead(selection) === false) {
return false;
}
return nf.CanvasUtils.isRemoteProcessGroup(selection);
return canvasUtils.isRemoteProcessGroup(selection);
};
/**
* Determines if the components in the specified selection support starting transmission.
*
*
* @param {selection} selection
*/
var canStartTransmission = function (selection) {
if (nf.CanvasUtils.canModify(selection) === false) {
if (canvasUtils.canModify(selection) === false) {
return false;
}
return nf.CanvasUtils.canAllStartTransmitting(selection);
return canvasUtils.canAllStartTransmitting(selection);
};
/**
* Determines if the components in the specified selection support stopping transmission.
*
*
* @param {selection} selection
*/
var canStopTransmission = function (selection) {
if (nf.CanvasUtils.canModify(selection) === false) {
if (canvasUtils.canModify(selection) === false) {
return false;
}
return nf.CanvasUtils.canAllStopTransmitting(selection);
return canvasUtils.canAllStopTransmitting(selection);
};
/**
* Only DFMs can empty a queue.
*
*
* @param {selection} selection
*/
var canEmptyQueue = function (selection) {
@ -332,31 +362,31 @@ nf.ContextMenu = (function () {
var canListQueue = function (selection) {
return isConnection(selection);
};
/**
* Determines if the components in the specified selection can be moved into a parent group.
*
*
* @param {type} selection
*/
var canMoveToParent = function (selection) {
if (nf.CanvasUtils.canModify(selection) === false) {
if (canvasUtils.canModify(selection) === false) {
return false;
}
// TODO - also check can modify in parent
return !selection.empty() && nf.CanvasUtils.isDisconnected(selection) && nf.Canvas.getParentGroupId() !== null;
return !selection.empty() && canvasUtils.getComponentByType('Connection').isDisconnected(selection) && canvasUtils.getParentGroupId() !== null;
};
/**
* Adds a menu item to the context menu.
*
*
* {
* click: refresh (function),
* text: 'Start' (string),
* clazz: 'fa fa-refresh'
* }
*
*
* @param {jQuery} contextMenu The context menu
* @param {object} item The menu item configuration
*/
@ -377,10 +407,10 @@ nf.ContextMenu = (function () {
// create the img and conditionally add the style
var img = $('<div class="context-menu-item-img"></div>').addClass(item['clazz']).appendTo(menuItem);
if (nf.Common.isDefinedAndNotNull(item['imgStyle'])) {
if (common.isDefinedAndNotNull(item['imgStyle'])) {
img.addClass(item['imgStyle']);
}
$('<div class="context-menu-item-text"></div>').text(item['text']).appendTo(menuItem);
$('<div class="clear"></div>').appendTo(menuItem);
}
@ -388,7 +418,7 @@ nf.ContextMenu = (function () {
/**
* Positions and shows the context menu.
*
*
* @param {jQuery} contextMenu The context menu
* @param {object} options The context menu configuration
*/
@ -401,17 +431,17 @@ nf.ContextMenu = (function () {
/**
* Executes the specified action with the optional selection.
*
*
* @param {string} action
* @param {selection} selection
* @param {mouse event} evt
*/
var executeAction = function (action, selection, evt) {
// execute the action
nf.Actions[action](selection, evt);
nfActions[action](selection, evt);
// close the context menu
nf.ContextMenu.hide();
nfContextMenu.hide();
};
// defines the available actions and the conditions which they apply
@ -425,7 +455,7 @@ nf.ContextMenu = (function () {
{condition: isStoppable, menuItem: {clazz: 'fa fa-stop', text: 'Stop', action: 'stop'}},
{condition: isRemoteProcessGroup, menuItem: {clazz: 'fa fa-cloud', text: 'Remote ports', action: 'remotePorts'}},
{condition: canStartTransmission, menuItem: {clazz: 'fa fa-bullseye', text: 'Enable transmission', action: 'enableTransmission'}},
{condition: canStopTransmission, menuItem: {clazz: 'icon icon-transmit-false', text: 'Disable transmission', action: 'disableTransmission'}},
{condition: canStopTransmission, menuItem: { clazz: 'icon icon-transmit-false', text: 'Disable transmission', action: 'disableTransmission'}},
{condition: supportsStats, menuItem: {clazz: 'fa fa-area-chart', text: 'Status History', action: 'showStats'}},
{condition: canAccessProvenance, menuItem: {clazz: 'icon icon-provenance', imgStyle: 'context-menu-provenance', text: 'Data provenance', action: 'openProvenance'}},
{condition: isStatefulProcessor, menuItem: {clazz: 'fa fa-tasks', text: 'View state', action: 'viewState'}},
@ -446,20 +476,28 @@ nf.ContextMenu = (function () {
{condition: canEmptyQueue, menuItem: {clazz: 'fa fa-minus-circle', text: 'Empty queue', action: 'emptyQueue'}},
{condition: isDeletable, menuItem: {clazz: 'fa fa-trash', text: 'Delete', action: 'delete'}},
{condition: canAlign, menuItem: {clazz: 'fa fa-align-center', text: 'Align vertical', action: 'alignVertical'}},
{condition: canAlign, menuItem: {clazz: 'fa fa-align-center fa-rotate-90', text: 'Align horizontal', action: 'alignHorizontal'}}
{condition: canAlign, menuItem: { clazz: 'fa fa-align-center fa-rotate-90', text: 'Align horizontal', action: 'alignHorizontal'}}
];
return {
init: function () {
$('#context-menu').on('contextmenu', function(evt) {
var nfContextMenu = {
/**
* Initialize the context menu.
*
* @param actions The reference to the actions controller.
*/
init: function (actions) {
nfActions = actions;
$('#context-menu').on('contextmenu', function (evt) {
// stop propagation and prevent default
evt.preventDefault();
evt.stopPropagation();
});
},
/**
* Shows the context menu.
* Shows the context menu.
*/
show: function () {
var contextMenu = $('#context-menu').empty();
@ -468,17 +506,17 @@ nf.ContextMenu = (function () {
var breadCrumb = $('#breadcrumbs').get(0);
// get the current selection
var selection = nf.CanvasUtils.getSelection();
var selection = canvasUtils.getSelection();
// consider each component action for the current selection
$.each(actions, function (_, action) {
// determine if this action is application for this selection
if (action.condition(selection)) {
if (action.condition(selection, canvasUtils.getComponentByType('Connection'))) {
var menuItem = action.menuItem;
addMenuItem(contextMenu, {
clazz: menuItem.clazz,
imgStyle: menuItem.imgStyle,
imgStyle: menuItem.imgStyle,
text: menuItem.text,
click: function (evt) {
executeAction(menuItem.action, selection, evt);
@ -505,25 +543,25 @@ nf.ContextMenu = (function () {
});
// inform Angular app incase we've click on the canvas
nf.ng.Bridge.digest();
angularBridge.digest();
},
/**
* Hides the context menu.
*/
hide: function () {
$('#context-menu').hide();
},
/**
* Activates the context menu for the components in the specified selection.
*
*
* @param {selection} components The components to enable the context menu for
*/
activate: function (components) {
components.on('contextmenu.selection', function () {
// get the clicked component to update selection
nf.ContextMenu.show();
nfContextMenu.show();
// stop propagation and prevent default
d3.event.preventDefault();
@ -531,4 +569,6 @@ nf.ContextMenu = (function () {
});
}
};
}());
return nfContextMenu;
}));

View File

@ -15,9 +15,58 @@
* limitations under the License.
*/
/* global nf, d3 */
/* global define, module, require, exports */
nf.ControllerService = (function () {
(function (root, factory) {
if (typeof define === 'function' && define.amd) {
define(['jquery',
'd3',
'nf.ErrorHandler',
'nf.Common',
'nf.Dialog',
'nf.Client',
'nf.ControllerServices',
'nf.Settings',
'nf.UniversalCapture',
'nf.CustomUi',
'nf.CanvasUtils',
'nf.ReportingTask',
'nf.Processor'],
function ($, d3, errorHandler, common, dialog, client, controllerServices, settings, universalCapture, customUi, canvasUtils, reportingTask, processor) {
return (nf.ControllerService = factory($, d3, errorHandler, common, dialog, client, controllerServices, settings, universalCapture, customUi, canvasUtils, reportingTask, processor));
});
} else if (typeof exports === 'object' && typeof module === 'object') {
module.exports = (nf.ControllerService =
factory(require('jquery'),
require('d3'),
require('nf.ErrorHandler'),
require('nf.Common'),
require('nf.Dialog'),
require('nf.Client'),
require('nf.ControllerServices'),
require('nf.Settings'),
require('nf.UniversalCapture'),
require('nf.CustomUi'),
require('nf.CanvasUtils'),
require('nf.ReportingTask'),
require('nf.Processor')));
} else {
nf.ControllerService = factory(root.$,
root.d3,
root.nf.ErrorHandler,
root.nf.Common,
root.nf.Dialog,
root.nf.Client,
root.nf.ControllerServices,
root.nf.Settings,
root.nf.UniversalCapture,
root.nf.CustomUi,
root.nf.CanvasUtils,
root.nf.ReportingTask,
root.nf.Processor);
}
}(this, function ($, d3, errorHandler, common, dialog, client, controllerServices, settings, universalCapture, customUi, canvasUtils, reportingTask, processor) {
'use strict';
var config = {
edit: 'edit',
@ -44,15 +93,15 @@ nf.ControllerService = (function () {
if (errors.length === 1) {
content = $('<span></span>').text(errors[0]);
} else {
content = nf.Common.formatUnorderedList(errors);
content = common.formatUnorderedList(errors);
}
nf.Dialog.showOkDialog({
dialog.showOkDialog({
dialogContent: content,
headerText: 'Controller Service'
});
} else {
nf.ErrorHandler.handleAjaxError(xhr, status, error);
errorHandler.handleAjaxError(xhr, status, error);
}
};
@ -128,7 +177,7 @@ nf.ControllerService = (function () {
// service B that has been removed. attempting to enable/disable/remove A
// will attempt to reload B which is no longer a known service. also ensure
// we have permissions to reload the service
if (nf.Common.isUndefined(controllerServiceEntity) || controllerServiceEntity.permissions.canRead === false) {
if (common.isUndefined(controllerServiceEntity) || controllerServiceEntity.permissions.canRead === false) {
return $.Deferred(function (deferred) {
deferred.reject();
}).promise();
@ -140,7 +189,7 @@ nf.ControllerService = (function () {
dataType: 'json'
}).done(function (response) {
renderControllerService(serviceTable, response);
}).fail(nf.ErrorHandler.handleAjaxError);
}).fail(errorHandler.handleAjaxError);
};
/**
@ -167,7 +216,7 @@ nf.ControllerService = (function () {
* @param {type} controllerService
*/
var reloadControllerServiceAndReferencingComponents = function (serviceTable, controllerService) {
reloadControllerService(serviceTable, controllerService.id).done(function(response) {
reloadControllerService(serviceTable, controllerService.id).done(function (response) {
reloadControllerServiceReferences(serviceTable, response.component);
});
};
@ -190,8 +239,8 @@ nf.ControllerService = (function () {
var reference = referencingComponentEntity.component;
if (reference.referenceType === 'Processor') {
// reload the processor on the canvas if appropriate
if (nf.Canvas.getGroupId() === reference.groupId) {
nf.Processor.reload(reference.id);
if (canvasUtils.getGroupId() === reference.groupId) {
processor.reload(reference.id);
}
// update the current active thread count
@ -204,7 +253,7 @@ nf.ControllerService = (function () {
}
} else if (reference.referenceType === 'ReportingTask') {
// reload the referencing reporting tasks
nf.ReportingTask.reload(reference.id);
reportingTask.reload(reference.id);
// update the current active thread count
$('div.' + reference.id + '-active-threads').text(reference.activeThreadCount);
@ -217,7 +266,7 @@ nf.ControllerService = (function () {
} else {
// reload the referencing services
reloadControllerService(serviceTable, reference.id);
// update the current state of this service
var referencingComponentState = $('div.' + reference.id + '-state');
if (referencingComponentState.length) {
@ -233,9 +282,9 @@ nf.ControllerService = (function () {
// see if this controller service references another controller service
// in order to update the referenced service referencing components
nf.ControllerService.reloadReferencedServices(serviceTable, controllerService);
};
nfControllerService.reloadReferencedServices(serviceTable, controllerService);
};
/**
* Adds a border to the controller service referencing components if necessary.
*
@ -264,22 +313,22 @@ nf.ControllerService = (function () {
var currentBulletins = bulletinIcon.data('bulletins');
// update the bulletins if necessary
if (nf.Common.doBulletinsDiffer(currentBulletins, bulletins)) {
if (common.doBulletinsDiffer(currentBulletins, bulletins)) {
bulletinIcon.data('bulletins', bulletins);
// format the new bulletins
var formattedBulletins = nf.Common.getFormattedBulletins(bulletins);
var formattedBulletins = common.getFormattedBulletins(bulletins);
// if there are bulletins update them
if (bulletins.length > 0) {
var list = nf.Common.formatUnorderedList(formattedBulletins);
var list = common.formatUnorderedList(formattedBulletins);
// update existing tooltip or initialize a new one if appropriate
if (bulletinIcon.data('qtip')) {
bulletinIcon.qtip('option', 'content.text', list);
} else {
bulletinIcon.addClass('has-bulletins').show().qtip($.extend({},
nf.CanvasUtils.config.systemTooltipConfig,
canvasUtils.config.systemTooltipConfig,
{
content: list
}));
@ -301,16 +350,16 @@ nf.ControllerService = (function () {
var icon = $(this);
var state = referencingComponent.state.toLowerCase();
if (state === 'stopped' && !nf.Common.isEmpty(referencingComponent.validationErrors)) {
if (state === 'stopped' && !common.isEmpty(referencingComponent.validationErrors)) {
state = 'invalid';
// add tooltip for the warnings
var list = nf.Common.formatUnorderedList(referencingComponent.validationErrors);
var list = common.formatUnorderedList(referencingComponent.validationErrors);
if (icon.data('qtip')) {
icon.qtip('option', 'content.text', list);
} else {
icon.qtip($.extend({},
nf.CanvasUtils.config.systemTooltipConfig,
canvasUtils.config.systemTooltipConfig,
{
content: list
}));
@ -333,16 +382,16 @@ nf.ControllerService = (function () {
var icon = $(this);
var state = referencingService.state === 'ENABLED' ? 'enabled' : 'disabled';
if (state === 'disabled' && !nf.Common.isEmpty(referencingService.validationErrors)) {
if (state === 'disabled' && !common.isEmpty(referencingService.validationErrors)) {
state = 'invalid';
// add tooltip for the warnings
var list = nf.Common.formatUnorderedList(referencingService.validationErrors);
var list = common.formatUnorderedList(referencingService.validationErrors);
if (icon.data('qtip')) {
icon.qtip('option', 'content.text', list);
} else {
icon.qtip($.extend({},
nf.CanvasUtils.config.systemTooltipConfig,
canvasUtils.config.systemTooltipConfig,
{
content: list
}));
@ -377,11 +426,11 @@ nf.ControllerService = (function () {
* Adds the specified reference for this controller service.
*
* @param {jQuery} serviceTable
* @param {jQuery} referenceContainer
* @param {jQuery} referenceContainer
* @param {array} referencingComponents
*/
var createReferencingComponents = function (serviceTable, referenceContainer, referencingComponents) {
if (nf.Common.isEmpty(referencingComponents)) {
if (common.isEmpty(referencingComponents)) {
referenceContainer.append('<div class="unset">No referencing components.</div>');
return;
}
@ -414,7 +463,7 @@ nf.ControllerService = (function () {
if (referencingComponent.referenceType === 'Processor') {
var processorLink = $('<span class="referencing-component-name link"></span>').text(referencingComponent.name).on('click', function () {
// show the component
nf.CanvasUtils.showComponent(referencingComponent.groupId, referencingComponent.id);
canvasUtils.showComponent(referencingComponent.groupId, referencingComponent.id);
// close the dialog and shell
referenceContainer.closest('.dialog').modal('hide');
@ -429,11 +478,11 @@ nf.ControllerService = (function () {
var processorBulletins = $('<div class="referencing-component-bulletins"></div>').addClass(referencingComponent.id + '-bulletins');
// type
var processorType = $('<span class="referencing-component-type"></span>').text(nf.Common.substringAfterLast(referencingComponent.type, '.'));
var processorType = $('<span class="referencing-component-type"></span>').text(common.substringAfterLast(referencingComponent.type, '.'));
// active thread count
var processorActiveThreadCount = $('<span class="referencing-component-active-thread-count"></span>').addClass(referencingComponent.id + '-active-threads');
if (nf.Common.isDefinedAndNotNull(referencingComponent.activeThreadCount) && referencingComponent.activeThreadCount > 0) {
if (common.isDefinedAndNotNull(referencingComponent.activeThreadCount) && referencingComponent.activeThreadCount > 0) {
processorActiveThreadCount.text('(' + referencingComponent.activeThreadCount + ')');
}
@ -484,7 +533,7 @@ nf.ControllerService = (function () {
var serviceBulletins = $('<div class="referencing-component-bulletins"></div>').addClass(referencingComponent.id + '-bulletins');
// type
var serviceType = $('<span class="referencing-component-type"></span>').text(nf.Common.substringAfterLast(referencingComponent.type, '.'));
var serviceType = $('<span class="referencing-component-type"></span>').text(common.substringAfterLast(referencingComponent.type, '.'));
// service
var serviceItem = $('<li></li>').append(serviceTwist).append(serviceState).append(serviceBulletins).append(serviceLink).append(serviceType).append(referencingServiceReferencesContainer);
@ -515,11 +564,11 @@ nf.ControllerService = (function () {
var reportingTaskBulletins = $('<div class="referencing-component-bulletins"></div>').addClass(referencingComponent.id + '-bulletins');
// type
var reportingTaskType = $('<span class="referencing-component-type"></span>').text(nf.Common.substringAfterLast(referencingComponent.type, '.'));
var reportingTaskType = $('<span class="referencing-component-type"></span>').text(common.substringAfterLast(referencingComponent.type, '.'));
// active thread count
var reportingTaskActiveThreadCount = $('<span class="referencing-component-active-thread-count"></span>').addClass(referencingComponent.id + '-active-threads');
if (nf.Common.isDefinedAndNotNull(referencingComponent.activeThreadCount) && referencingComponent.activeThreadCount > 0) {
if (common.isDefinedAndNotNull(referencingComponent.activeThreadCount) && referencingComponent.activeThreadCount > 0) {
reportingTaskActiveThreadCount.text('(' + referencingComponent.activeThreadCount + ')');
}
@ -583,7 +632,7 @@ nf.ControllerService = (function () {
sourceId: ids
},
dataType: 'json'
}).fail(nf.ErrorHandler.handleAjaxError);
}).fail(errorHandler.handleAjaxError);
};
/**
@ -597,7 +646,7 @@ nf.ControllerService = (function () {
var setEnabled = function (serviceTable, controllerServiceEntity, enabled, pollCondition) {
// build the request entity
var updateControllerServiceEntity = {
'revision': nf.Client.getRevision(controllerServiceEntity),
'revision': client.getRevision(controllerServiceEntity),
'component': {
'id': controllerServiceEntity.id,
'state': enabled ? 'ENABLED' : 'DISABLED'
@ -612,7 +661,7 @@ nf.ControllerService = (function () {
contentType: 'application/json'
}).done(function (response) {
renderControllerService(serviceTable, response);
}).fail(nf.ErrorHandler.handleAjaxError);
}).fail(errorHandler.handleAjaxError);
// wait until the polling of each service finished
return $.Deferred(function (deferred) {
@ -691,11 +740,11 @@ nf.ControllerService = (function () {
if (serviceOnly) {
if (referencingComponent.referenceType === 'ControllerService') {
referencingComponentRevisions[referencingComponentEntity.id] = nf.Client.getRevision(referencingComponentEntity);
referencingComponentRevisions[referencingComponentEntity.id] = client.getRevision(referencingComponentEntity);
}
} else {
if (referencingComponent.referenceType !== 'ControllerService') {
referencingComponentRevisions[referencingComponentEntity.id] = nf.Client.getRevision(referencingComponentEntity);
referencingComponentRevisions[referencingComponentEntity.id] = client.getRevision(referencingComponentEntity);
}
}
@ -730,7 +779,7 @@ nf.ControllerService = (function () {
data: JSON.stringify(referenceEntity),
dataType: 'json',
contentType: 'application/json'
}).fail(nf.ErrorHandler.handleAjaxError);
}).fail(errorHandler.handleAjaxError);
// Note: updated revisions will be retrieved after updateReferencingSchedulableComponents is invoked
@ -810,7 +859,7 @@ nf.ControllerService = (function () {
conditionMet(serviceResponse.component, bulletinResponse.bulletinBoard.bulletins);
}).fail(function (xhr, status, error) {
deferred.reject();
nf.ErrorHandler.handleAjaxError(xhr, status, error);
errorHandler.handleAjaxError(xhr, status, error);
});
};
@ -832,7 +881,7 @@ nf.ControllerService = (function () {
conditionMet(controllerService, response.bulletinBoard.bulletins);
}).fail(function (xhr, status, error) {
deferred.reject();
nf.ErrorHandler.handleAjaxError(xhr, status, error);
errorHandler.handleAjaxError(xhr, status, error);
});
}).promise();
};
@ -1002,7 +1051,7 @@ nf.ControllerService = (function () {
data: JSON.stringify(referenceEntity),
dataType: 'json',
contentType: 'application/json'
}).fail(nf.ErrorHandler.handleAjaxError);
}).fail(errorHandler.handleAjaxError);
// Note: updated revisions will be retrieved after updateReferencingServices is invoked
@ -1135,7 +1184,7 @@ nf.ControllerService = (function () {
// show the dialog
$('#enable-controller-service-dialog').modal('setButtonModel', buttons).modal('show');
// load the bulletins
queryBulletins([controllerService.id]).done(function (response) {
updateBulletins(response.bulletinBoard.bulletins, $('#enable-controller-service-bulletins'));
@ -1157,7 +1206,7 @@ nf.ControllerService = (function () {
*
* @param {jQuery} serviceTable
*/
var disableHandler = function(serviceTable) {
var disableHandler = function (serviceTable) {
var disableDialog = $('#disable-controller-service-dialog');
var canceled = false;
@ -1214,7 +1263,7 @@ nf.ControllerService = (function () {
if (hasUnauthorizedReferencingComponent(controllerService.referencingComponents)) {
setCloseButton();
nf.Dialog.showOkDialog({
dialog.showOkDialog({
headerText: 'Controller Service',
dialogContent: 'Unable to disable due to unauthorized referencing components.'
});
@ -1263,7 +1312,7 @@ nf.ControllerService = (function () {
// inform the user if the action was canceled
if (canceled === true && $('#nf-ok-dialog').not(':visible')) {
nf.Dialog.showOkDialog({
dialog.showOkDialog({
headerText: 'Controller Service',
dialogContent: 'The request to disable has been canceled. Parts of this request may have already completed. Please verify the state of this service and all referencing components.'
});
@ -1301,7 +1350,7 @@ nf.ControllerService = (function () {
*
* @param {jQuery} serviceTable
*/
var enableHandler = function(serviceTable) {
var enableHandler = function (serviceTable) {
var enableDialog = $('#enable-controller-service-dialog');
var canceled = false;
@ -1367,7 +1416,7 @@ nf.ControllerService = (function () {
if (scope === config.serviceAndReferencingComponents && hasUnauthorizedReferencingComponent(controllerService.referencingComponents)) {
setCloseButton();
nf.Dialog.showOkDialog({
dialog.showOkDialog({
headerText: 'Controller Service',
dialogContent: 'Unable to enable due to unauthorized referencing components.'
});
@ -1396,7 +1445,7 @@ nf.ControllerService = (function () {
var enableReferencingSchedulable = $('#enable-referencing-schedulable').addClass('ajax-loading');
// start all referencing schedulable components
updateReferencingSchedulableComponents(serviceTable, controllerServiceEntity, true, continuePolling).done(function() {
updateReferencingSchedulableComponents(serviceTable, controllerServiceEntity, true, continuePolling).done(function () {
deferred.resolve();
enableReferencingSchedulable.removeClass('ajax-loading').addClass('ajax-complete');
}).fail(function () {
@ -1426,7 +1475,7 @@ nf.ControllerService = (function () {
// inform the user if the action was canceled
if (canceled === true && $('#nf-ok-dialog').not(':visible')) {
nf.Dialog.showOkDialog({
dialog.showOkDialog({
headerText: 'Controller Service',
dialogContent: 'The request to enable has been canceled. Parts of this request may have already completed. Please verify the state of this service and all referencing components.'
});
@ -1448,7 +1497,7 @@ nf.ControllerService = (function () {
propertyName: propertyName
},
dataType: 'json'
}).fail(nf.ErrorHandler.handleAjaxError);
}).fail(errorHandler.handleAjaxError);
};
/**
@ -1464,7 +1513,7 @@ nf.ControllerService = (function () {
// determine if changes have been made
if (isSaveRequired()) {
// see if those changes should be saved
nf.Dialog.showYesNoDialog({
dialog.showYesNoDialog({
headerText: 'Save',
dialogContent: 'Save changes before going to this Controller Service?',
noHandler: function () {
@ -1484,19 +1533,19 @@ nf.ControllerService = (function () {
}
}).promise();
};
var saveControllerService = function (serviceTable, controllerServiceEntity) {
// marshal the settings and properties and update the controller service
var updatedControllerService = marshalDetails();
// ensure details are valid as far as we can tell
if (validateDetails(updatedControllerService)) {
updatedControllerService['revision'] = nf.Client.getRevision(controllerServiceEntity);
updatedControllerService['revision'] = client.getRevision(controllerServiceEntity);
var previouslyReferencedServiceIds = [];
$.each(identifyReferencedServiceDescriptors(controllerServiceEntity.component), function (_, descriptor) {
var modifyingService = !nf.Common.isUndefined(updatedControllerService.component.properties) && !nf.Common.isUndefined(updatedControllerService.component.properties[descriptor.name]);
var isCurrentlyConfigured = nf.Common.isDefinedAndNotNull(controllerServiceEntity.component.properties[descriptor.name]);
var modifyingService = !common.isUndefined(updatedControllerService.component.properties) && !common.isUndefined(updatedControllerService.component.properties[descriptor.name]);
var isCurrentlyConfigured = common.isDefinedAndNotNull(controllerServiceEntity.component.properties[descriptor.name]);
// if we are attempting to update a controller service reference
if (modifyingService && isCurrentlyConfigured) {
@ -1516,9 +1565,9 @@ nf.ControllerService = (function () {
}).done(function (response) {
// reload the controller service
renderControllerService(serviceTable, response);
// reload all previously referenced controller services
$.each(previouslyReferencedServiceIds, function(_, oldServiceReferenceId) {
$.each(previouslyReferencedServiceIds, function (_, oldServiceReferenceId) {
reloadControllerService(serviceTable, oldServiceReferenceId);
});
}).fail(handleControllerServiceConfigurationError);
@ -1538,7 +1587,7 @@ nf.ControllerService = (function () {
var referencedServiceDescriptors = [];
$.each(component.descriptors, function (_, descriptor) {
if (nf.Common.isDefinedAndNotNull(descriptor.identifiesControllerService)) {
if (common.isDefinedAndNotNull(descriptor.identifiesControllerService)) {
referencedServiceDescriptors.push(descriptor);
}
});
@ -1558,7 +1607,7 @@ nf.ControllerService = (function () {
var referencedServiceId = component.properties[descriptor.name];
// ensure the property is configured
if (nf.Common.isDefinedAndNotNull(referencedServiceId) && $.trim(referencedServiceId).length > 0) {
if (common.isDefinedAndNotNull(referencedServiceId) && $.trim(referencedServiceId).length > 0) {
referencedServices.push(referencedServiceId);
}
});
@ -1571,7 +1620,7 @@ nf.ControllerService = (function () {
*/
var currentTable;
return {
var nfControllerService = {
/**
* Initializes the controller service configuration dialog.
*/
@ -1593,7 +1642,7 @@ nf.ControllerService = (function () {
}],
select: function () {
// remove all property detail dialogs
nf.UniversalCapture.removeAllPropertyDetailDialogs();
universalCapture.removeAllPropertyDetailDialogs();
// update the property table size in case this is the first time its rendered
if ($(this).text() === 'Properties') {
@ -1617,8 +1666,8 @@ nf.ControllerService = (function () {
close: function () {
// empty the referencing components list
var referencingComponents = $('#controller-service-referencing-components');
nf.Common.cleanUpTooltips(referencingComponents, 'div.referencing-component-state');
nf.Common.cleanUpTooltips(referencingComponents, 'div.referencing-component-bulletins');
common.cleanUpTooltips(referencingComponents, 'div.referencing-component-state');
common.cleanUpTooltips(referencingComponents, 'div.referencing-component-bulletins');
referencingComponents.css('border-width', '0').empty();
// cancel any active edits
@ -1628,13 +1677,13 @@ nf.ControllerService = (function () {
$('#controller-service-properties').propertytable('clear');
// clear the comments
nf.Common.clearField('read-only-controller-service-comments');
common.clearField('read-only-controller-service-comments');
// removed the cached controller service details
$('#controller-service-configuration').removeData('controllerServiceDetails');
},
open: function () {
nf.Common.toggleScrollable($('#' + this.find('.tab-container').attr('id') + '-content').get(0));
common.toggleScrollable($('#' + this.find('.tab-container').attr('id') + '-content').get(0));
}
}
});
@ -1657,15 +1706,15 @@ nf.ControllerService = (function () {
// bulletins
$('#disable-controller-service-bulletins').removeClass('has-bulletins').removeData('bulletins').hide();
nf.Common.cleanUpTooltips($('#disable-controller-service-service-container'), '#disable-controller-service-bulletins');
common.cleanUpTooltips($('#disable-controller-service-service-container'), '#disable-controller-service-bulletins');
// reset progress
$('div.disable-referencing-components').removeClass('ajax-loading ajax-complete ajax-error');
// referencing components
var referencingComponents = $('#disable-controller-service-referencing-components');
nf.Common.cleanUpTooltips(referencingComponents, 'div.referencing-component-state');
nf.Common.cleanUpTooltips(referencingComponents, 'div.referencing-component-bulletins');
common.cleanUpTooltips(referencingComponents, 'div.referencing-component-state');
common.cleanUpTooltips(referencingComponents, 'div.referencing-component-bulletins');
referencingComponents.css('border-width', '0').empty();
}
}
@ -1703,15 +1752,15 @@ nf.ControllerService = (function () {
// bulletins
$('#enable-controller-service-bulletins').removeClass('has-bulletins').removeData('bulletins').hide();
nf.Common.cleanUpTooltips($('#enable-controller-service-service-container'), '#enable-controller-service-bulletins');
common.cleanUpTooltips($('#enable-controller-service-service-container'), '#enable-controller-service-bulletins');
// reset progress
$('div.enable-referencing-components').removeClass('ajax-loading ajax-complete ajax-error');
// referencing components
var referencingComponents = $('#enable-controller-service-referencing-components');
nf.Common.cleanUpTooltips(referencingComponents, 'div.referencing-component-state');
nf.Common.cleanUpTooltips(referencingComponents, 'div.referencing-component-bulletins');
common.cleanUpTooltips(referencingComponents, 'div.referencing-component-state');
common.cleanUpTooltips(referencingComponents, 'div.referencing-component-bulletins');
referencingComponents.css('border-width', '0').empty();
}
}
@ -1725,7 +1774,7 @@ nf.ControllerService = (function () {
* @argument {object} controllerServiceEntity The controller service
*/
showConfiguration: function (serviceTable, controllerServiceEntity) {
if (nf.Common.isUndefined(currentTable)){
if (common.isUndefined(currentTable)) {
currentTable = serviceTable;
}
var controllerServiceDialog = $('#controller-service-configuration');
@ -1740,20 +1789,20 @@ nf.ControllerService = (function () {
supportsGoTo: true,
dialogContainer: '#new-controller-service-property-container',
descriptorDeferred: getControllerServicePropertyDescriptor,
controllerServiceCreatedDeferred: function(response) {
controllerServiceCreatedDeferred: function (response) {
var controllerServicesUri;
var createdControllerServicesTable;
// calculate the correct uri
var createdControllerService = response.component;
if (nf.Common.isDefinedAndNotNull(createdControllerService.parentGroupId)) {
if (common.isDefinedAndNotNull(createdControllerService.parentGroupId)) {
controllerServicesUri = config.urls.api + '/flow/process-groups/' + encodeURIComponent(createdControllerService.parentGroupId) + '/controller-services';
} else {
controllerServicesUri = config.urls.api + '/flow/controller/controller-services';
}
// load the controller services accordingly
return nf.ControllerServices.loadControllerServices(controllerServicesUri, serviceTable);
return controllerServices.loadControllerServices(controllerServicesUri, serviceTable);
},
goToServiceDeferred: function () {
return goToServiceFromProperty(serviceTable);
@ -1794,8 +1843,8 @@ nf.ControllerService = (function () {
controllerServiceDialog.data('controllerServiceDetails', controllerServiceEntity);
// populate the controller service settings
nf.Common.populateField('controller-service-id', controllerService['id']);
nf.Common.populateField('controller-service-type', nf.Common.substringAfterLast(controllerService['type'], '.'));
common.populateField('controller-service-id', controllerService['id']);
common.populateField('controller-service-type', common.substringAfterLast(controllerService['type'], '.'));
$('#controller-service-name').val(controllerService['name']);
$('#controller-service-comments').val(controllerService['comments']);
@ -1817,31 +1866,31 @@ nf.ControllerService = (function () {
// close all fields currently being edited
$('#controller-service-properties').propertytable('saveRow');
// save the controller service
saveControllerService(serviceTable, controllerServiceEntity).done(function (response) {
reloadControllerServiceReferences(serviceTable, response.component);
// close the details panel
controllerServiceDialog.modal('hide');
});
}
}
}, {
buttonText: 'Cancel',
color: {
base: '#E3E8EB',
hover: '#C7D2D7',
text: '#004849'
},
handler: {
click: function () {
// save the controller service
saveControllerService(serviceTable, controllerServiceEntity).done(function (response) {
reloadControllerServiceReferences(serviceTable, response.component);
// close the details panel
controllerServiceDialog.modal('hide');
}
});
}
}];
}
}, {
buttonText: 'Cancel',
color: {
base: '#E3E8EB',
hover: '#C7D2D7',
text: '#004849'
},
handler: {
click: function () {
controllerServiceDialog.modal('hide');
}
}
}];
// determine if we should show the advanced button
if (nf.Common.isDefinedAndNotNull(controllerService.customUiUrl) && controllerService.customUiUrl !== '') {
if (common.isDefinedAndNotNull(controllerService.customUiUrl) && controllerService.customUiUrl !== '') {
buttons.push({
buttonText: 'Advanced',
clazz: 'fa fa-cog button-icon',
@ -1860,12 +1909,12 @@ nf.ControllerService = (function () {
$('#shell-close-button').click();
// show the custom ui
nf.CustomUi.showCustomUi(controllerServiceEntity, controllerService.customUiUrl, true).done(function () {
customUi.showCustomUi(controllerServiceEntity, controllerService.customUiUrl, true).done(function () {
// once the custom ui is closed, reload the controller service
reloadControllerServiceAndReferencingComponents(serviceTable, controllerService);
// show the settings
nf.Settings.showSettings();
settings.showSettings();
});
};
@ -1875,7 +1924,7 @@ nf.ControllerService = (function () {
// determine if changes have been made
if (isSaveRequired()) {
// see if those changes should be saved
nf.Dialog.showYesNoDialog({
dialog.showYesNoDialog({
headerText: 'Save',
dialogContent: 'Save changes before opening the advanced configuration?',
noHandler: openCustomUi,
@ -1910,7 +1959,7 @@ nf.ControllerService = (function () {
updateReferencingComponentsBorder(referenceContainer);
$('#controller-service-properties').propertytable('resetTableSize');
}).fail(nf.ErrorHandler.handleAjaxError);
}).fail(errorHandler.handleAjaxError);
},
/**
@ -1919,7 +1968,7 @@ nf.ControllerService = (function () {
* @param {jQuery} serviceTable
* @param {object} controllerServiceEntity
*/
showDetails: function(serviceTable, controllerServiceEntity) {
showDetails: function (serviceTable, controllerServiceEntity) {
var controllerServiceDialog = $('#controller-service-configuration');
if (controllerServiceDialog.data('mode') !== config.readOnly) {
// update the visibility
@ -1963,17 +2012,17 @@ nf.ControllerService = (function () {
controllerServiceDialog.data('controllerServiceDetails', controllerServiceEntity);
// populate the controller service settings
nf.Common.populateField('controller-service-id', controllerService['id']);
nf.Common.populateField('controller-service-type', nf.Common.substringAfterLast(controllerService['type'], '.'));
nf.Common.populateField('read-only-controller-service-name', controllerService['name']);
nf.Common.populateField('read-only-controller-service-comments', controllerService['comments']);
common.populateField('controller-service-id', controllerService['id']);
common.populateField('controller-service-type', common.substringAfterLast(controllerService['type'], '.'));
common.populateField('read-only-controller-service-name', controllerService['name']);
common.populateField('read-only-controller-service-comments', controllerService['comments']);
// get the reference container
var referenceContainer = $('#controller-service-referencing-components');
// load the controller referencing components list
createReferencingComponents(serviceTable, referenceContainer, controllerService.referencingComponents);
var buttons = [{
buttonText: 'Ok',
color: {
@ -1990,7 +2039,7 @@ nf.ControllerService = (function () {
}];
// determine if we should show the advanced button
if (nf.Common.isDefinedAndNotNull(nf.CustomUi) && nf.Common.isDefinedAndNotNull(controllerService.customUiUrl) && controllerService.customUiUrl !== '') {
if (common.isDefinedAndNotNull(customUi) && common.isDefinedAndNotNull(controllerService.customUiUrl) && controllerService.customUiUrl !== '') {
buttons.push({
buttonText: 'Advanced',
clazz: 'fa fa-cog button-icon',
@ -2008,8 +2057,8 @@ nf.ControllerService = (function () {
$('#shell-close-button').click();
// show the custom ui
nf.CustomUi.showCustomUi(controllerServiceEntity, controllerService.customUiUrl, false).done(function () {
nf.Settings.showSettings();
customUi.showCustomUi(controllerServiceEntity, controllerService.customUiUrl, false).done(function () {
settings.showSettings();
});
}
}
@ -2038,7 +2087,7 @@ nf.ControllerService = (function () {
* @param {jQuery} serviceTable
* @param {object} controllerServiceEntity
*/
enable: function(serviceTable, controllerServiceEntity) {
enable: function (serviceTable, controllerServiceEntity) {
showEnableControllerServiceDialog(serviceTable, controllerServiceEntity.component);
},
@ -2048,7 +2097,7 @@ nf.ControllerService = (function () {
* @param {jQuery} serviceTable
* @param {object} controllerServiceEntity
*/
disable: function(serviceTable, controllerServiceEntity) {
disable: function (serviceTable, controllerServiceEntity) {
showDisableControllerServiceDialog(serviceTable, controllerServiceEntity.component);
},
@ -2060,12 +2109,12 @@ nf.ControllerService = (function () {
* @param {jQuery} serviceTable
* @param {object} component
*/
reloadReferencedServices: function(serviceTable, component) {
reloadReferencedServices: function (serviceTable, component) {
$.each(getReferencedServices(component), function (_, referencedServiceId) {
reloadControllerService(serviceTable, referencedServiceId);
});
},
/**
* Prompts the user before attempting to delete the specified controller service.
*
@ -2074,11 +2123,11 @@ nf.ControllerService = (function () {
*/
promptToDeleteController: function (serviceTable, controllerServiceEntity) {
// prompt for deletion
nf.Dialog.showYesNoDialog({
dialog.showYesNoDialog({
headerText: 'Delete Controller Service',
dialogContent: 'Delete controller service \'' + nf.Common.escapeHtml(controllerServiceEntity.component.name) + '\'?',
dialogContent: 'Delete controller service \'' + common.escapeHtml(controllerServiceEntity.component.name) + '\'?',
yesHandler: function () {
nf.ControllerService.remove(serviceTable, controllerServiceEntity);
nfControllerService.remove(serviceTable, controllerServiceEntity);
}
});
},
@ -2089,10 +2138,10 @@ nf.ControllerService = (function () {
* @param {jQuery} serviceTable
* @param {object} controllerServiceEntity
*/
remove: function(serviceTable, controllerServiceEntity) {
remove: function (serviceTable, controllerServiceEntity) {
// prompt for removal?
var revision = nf.Client.getRevision(controllerServiceEntity);
var revision = client.getRevision(controllerServiceEntity);
$.ajax({
type: 'DELETE',
url: controllerServiceEntity.uri + '?' + $.param({
@ -2110,7 +2159,9 @@ nf.ControllerService = (function () {
if (controllerServiceEntity.permissions.canRead) {
reloadControllerServiceReferences(serviceTable, controllerServiceEntity.component);
}
}).fail(nf.ErrorHandler.handleAjaxError);
}).fail(errorHandler.handleAjaxError);
}
};
}());
return nfControllerService;
}));

View File

@ -15,9 +15,64 @@
* limitations under the License.
*/
/* global nf, Slick, d3 */
/* global define, module, require, exports */
nf.ControllerServices = (function () {
(function (root, factory) {
if (typeof define === 'function' && define.amd) {
define(['jquery',
'd3',
'Slick',
'nf.Client',
'nf.Shell',
'nf.ProcessGroupConfiguration',
'nf.CanvasUtils',
'nf.ErrorHandler',
'nf.Dialog',
'nf.Common',
'nf.ControllerService',
'nf.ProcessGroup',
'nf.PolicyManagement',
'nf.ComponentState',
'nf.ng.Bridge'],
function ($, d3, Slick, client, shell, processGroupConfiguration, canvasUtils, errorHandler, dialog, common, controllerService, processGroup, policyManagement, componentState, angularBridge) {
return (nf.ControllerServices = factory($, d3, Slick, client, shell, processGroupConfiguration, canvasUtils, errorHandler, dialog, common, controllerService, processGroup, policyManagement, componentState, angularBridge));
});
} else if (typeof exports === 'object' && typeof module === 'object') {
module.exports = (nf.ControllerServices =
factory(require('jquery'),
require('d3'),
require('Slick'),
require('nf.Client'),
require('nf.Shell'),
require('nf.ProcessGroupConfiguration'),
require('nf.CanvasUtils'),
require('nf.ErrorHandler'),
require('nf.Dialog'),
require('nf.Common'),
require('nf.ControllerService'),
require('nf.ProcessGroup'),
require('nf.PolicyManagement'),
require('nf.ComponentState'),
require('nf.ng.Bridge')));
} else {
nf.ControllerServices = factory(root.$,
root.d3,
root.Slick,
root.nf.Client,
root.nf.Shell,
root.nf.ProcessGroupConfiguration,
root.nf.CanvasUtils,
root.nf.ErrorHandler,
root.nf.Dialog,
root.nf.Common,
root.nf.ControllerService,
root.nf.ProcessGroup,
root.nf.PolicyManagement,
root.nf.ComponentState,
root.nf.ng.Bridge);
}
}(this, function ($, d3, Slick, client, shell, processGroupConfiguration, canvasUtils, errorHandler, dialog, common, controllerService, processGroup, policyManagement, componentState, angularBridge) {
'use strict';
var dblClick = null;
var initialized = false;
@ -45,7 +100,7 @@ nf.ControllerServices = (function () {
* @param item controller service type
*/
var isSelectable = function (item) {
return nf.Common.isBlank(item.usageRestriction) || nf.Common.canAccessRestrictedComponents();
return common.isBlank(item.usageRestriction) || common.canAccessRestrictedComponents();
};
/**
@ -65,7 +120,7 @@ nf.ControllerServices = (function () {
var controllerServiceTypesGrid = $('#controller-service-types-table').data('gridInstance');
// ensure the grid has been initialized
if (nf.Common.isDefinedAndNotNull(controllerServiceTypesGrid)) {
if (common.isDefinedAndNotNull(controllerServiceTypesGrid)) {
var controllerServiceTypesData = controllerServiceTypesGrid.getData();
// update the search criteria
@ -202,7 +257,7 @@ nf.ControllerServices = (function () {
// ensure something was selected
if (selectedServiceType === '') {
nf.Dialog.showOkDialog({
dialog.showOkDialog({
headerText: 'Controller Service',
dialogContent: 'The type of controller service to create must be selected.'
});
@ -221,7 +276,7 @@ nf.ControllerServices = (function () {
var addControllerService = function (controllerServicesUri, serviceTable, controllerServiceType) {
// build the controller service entity
var controllerServiceEntity = {
'revision': nf.Client.getRevision({
'revision': client.getRevision({
'revision': {
'version': 0
}
@ -252,7 +307,7 @@ nf.ControllerServices = (function () {
var row = controllerServicesData.getRowById(controllerServiceEntity.id);
controllerServicesGrid.setSelectedRows([row]);
controllerServicesGrid.scrollRowIntoView(row);
}).fail(nf.ErrorHandler.handleAjaxError);
}).fail(errorHandler.handleAjaxError);
// hide the dialog
$('#new-controller-service-dialog').modal('hide');
@ -270,7 +325,7 @@ nf.ControllerServices = (function () {
id: 'type',
name: 'Type',
field: 'label',
formatter: nf.Common.typeFormatter,
formatter: common.typeFormatter,
sortable: false,
resizable: true
},
@ -304,11 +359,11 @@ nf.ControllerServices = (function () {
var controllerServiceType = controllerServiceTypesGrid.getDataItem(controllerServiceTypeIndex);
// set the controller service type description
if (nf.Common.isDefinedAndNotNull(controllerServiceType)) {
if (common.isDefinedAndNotNull(controllerServiceType)) {
// show the selected controller service
$('#controller-service-description-container').show();
if (nf.Common.isBlank(controllerServiceType.description)) {
if (common.isBlank(controllerServiceType.description)) {
$('#controller-service-type-description')
.attr('title', '')
.html('<span class="unset">No description specified</span>');
@ -330,7 +385,7 @@ nf.ControllerServices = (function () {
}
});
controllerServiceTypesGrid.onViewportChanged.subscribe(function (e, args) {
nf.Common.cleanUpTooltips($('#controller-service-types-table'), 'div.view-usage-restriction');
common.cleanUpTooltips($('#controller-service-types-table'), 'div.view-usage-restriction');
});
// wire up the dataview to the grid
@ -357,8 +412,8 @@ nf.ControllerServices = (function () {
var item = controllerServiceTypesData.getItemById(rowId);
// show the tooltip
if (nf.Common.isDefinedAndNotNull(item.usageRestriction)) {
usageRestriction.qtip($.extend({}, nf.Common.config.tooltipConfig, {
if (common.isDefinedAndNotNull(item.usageRestriction)) {
usageRestriction.qtip($.extend({}, common.config.tooltipConfig, {
content: item.usageRestriction,
position: {
container: $('#summary'),
@ -391,10 +446,10 @@ nf.ControllerServices = (function () {
// add the documented type
controllerServiceTypesData.addItem({
id: id++,
label: nf.Common.substringAfterLast(documentedType.type, '.'),
label: common.substringAfterLast(documentedType.type, '.'),
type: documentedType.type,
description: nf.Common.escapeHtml(documentedType.description),
usageRestriction: nf.Common.escapeHtml(documentedType.usageRestriction),
description: common.escapeHtml(documentedType.description),
usageRestriction: common.escapeHtml(documentedType.usageRestriction),
tags: documentedType.tags.join(', ')
});
@ -416,7 +471,7 @@ nf.ControllerServices = (function () {
select: applyControllerServiceTypeFilter,
remove: applyControllerServiceTypeFilter
});
}).fail(nf.ErrorHandler.handleAjaxError);
}).fail(errorHandler.handleAjaxError);
// initialize the controller service dialog
$('#new-controller-service-dialog').modal({
@ -484,7 +539,7 @@ nf.ControllerServices = (function () {
return '';
}
return nf.Common.substringAfterLast(dataContext.component.type, '.');
return common.substringAfterLast(dataContext.component.type, '.');
};
/**
@ -502,7 +557,7 @@ nf.ControllerServices = (function () {
return '';
}
if (nf.Common.isDefinedAndNotNull(dataContext.component.parentGroupId)) {
if (common.isDefinedAndNotNull(dataContext.component.parentGroupId)) {
return dataContext.component.parentGroupId;
} else {
return 'Controller';
@ -519,7 +574,7 @@ nf.ControllerServices = (function () {
// we know the process group for this controller service is part
// of the current breadcrumb trail
var canWriteProcessGroupParent = function (processGroupId) {
var breadcrumbs = nf.ng.Bridge.injector.get('breadcrumbsCtrl').getBreadcrumbs();
var breadcrumbs = angularBridge.injector.get('breadcrumbsCtrl').getBreadcrumbs();
var isAuthorized = false;
$.each(breadcrumbs, function (_, breadcrumbEntity) {
@ -532,10 +587,10 @@ nf.ControllerServices = (function () {
return isAuthorized;
};
if (nf.Common.isDefinedAndNotNull(dataContext.component.parentGroupId)) {
if (common.isDefinedAndNotNull(dataContext.component.parentGroupId)) {
return canWriteProcessGroupParent(dataContext.component.parentGroupId);
} else {
return nf.Common.canModifyController();
return common.canModifyController();
}
};
@ -551,31 +606,31 @@ nf.ControllerServices = (function () {
if(a.permissions.canRead && b.permissions.canRead) {
if (sortDetails.columnId === 'moreDetails') {
var aBulletins = 0;
if (!nf.Common.isEmpty(a.bulletins)) {
if (!common.isEmpty(a.bulletins)) {
aBulletins = a.bulletins.length;
}
var bBulletins = 0;
if (!nf.Common.isEmpty(b.bulletins)) {
if (!common.isEmpty(b.bulletins)) {
bBulletins = b.bulletins.length;
}
return aBulletins - bBulletins;
} else if (sortDetails.columnId === 'type') {
var aType = nf.Common.isDefinedAndNotNull(a.component[sortDetails.columnId]) ? nf.Common.substringAfterLast(a.component[sortDetails.columnId], '.') : '';
var bType = nf.Common.isDefinedAndNotNull(b.component[sortDetails.columnId]) ? nf.Common.substringAfterLast(b.component[sortDetails.columnId], '.') : '';
var aType = common.isDefinedAndNotNull(a.component[sortDetails.columnId]) ? common.substringAfterLast(a.component[sortDetails.columnId], '.') : '';
var bType = common.isDefinedAndNotNull(b.component[sortDetails.columnId]) ? common.substringAfterLast(b.component[sortDetails.columnId], '.') : '';
return aType === bType ? 0 : aType > bType ? 1 : -1;
} else if (sortDetails.columnId === 'state') {
var aState = 'Invalid';
if (nf.Common.isEmpty(a.component.validationErrors)) {
aState = nf.Common.isDefinedAndNotNull(a.component[sortDetails.columnId]) ? a.component[sortDetails.columnId] : '';
if (common.isEmpty(a.component.validationErrors)) {
aState = common.isDefinedAndNotNull(a.component[sortDetails.columnId]) ? a.component[sortDetails.columnId] : '';
}
var bState = 'Invalid';
if (nf.Common.isEmpty(b.component.validationErrors)) {
bState = nf.Common.isDefinedAndNotNull(b.component[sortDetails.columnId]) ? b.component[sortDetails.columnId] : '';
if (common.isEmpty(b.component.validationErrors)) {
bState = common.isDefinedAndNotNull(b.component[sortDetails.columnId]) ? b.component[sortDetails.columnId] : '';
}
return aState === bState ? 0 : aState > bState ? 1 : -1;
} else {
var aString = nf.Common.isDefinedAndNotNull(a.component[sortDetails.columnId]) ? a.component[sortDetails.columnId] : '';
var bString = nf.Common.isDefinedAndNotNull(b.component[sortDetails.columnId]) ? b.component[sortDetails.columnId] : '';
var aString = common.isDefinedAndNotNull(a.component[sortDetails.columnId]) ? a.component[sortDetails.columnId] : '';
var bString = common.isDefinedAndNotNull(b.component[sortDetails.columnId]) ? b.component[sortDetails.columnId] : '';
return aString === bString ? 0 : aString > bString ? 1 : -1;
}
} else {
@ -598,8 +653,9 @@ nf.ControllerServices = (function () {
* Initializes the controller services tab.
*
* @param {jQuery} serviceTable
* @param {function} showSettings
*/
var initControllerServices = function (serviceTable) {
var initControllerServices = function (serviceTable, showSettings) {
// more details formatter
var moreControllerServiceDetails = function (row, cell, value, columnDef, dataContext) {
if (!dataContext.permissions.canRead) {
@ -611,8 +667,8 @@ nf.ControllerServices = (function () {
// always include a button to view the usage
markup += '<div title="Usage" class="pointer controller-service-usage fa fa-book" style="margin-top: 5px; margin-right: 3px;" ></div>';
var hasErrors = !nf.Common.isEmpty(dataContext.component.validationErrors);
var hasBulletins = !nf.Common.isEmpty(dataContext.bulletins);
var hasErrors = !common.isEmpty(dataContext.component.validationErrors);
var hasBulletins = !common.isEmpty(dataContext.bulletins);
if (hasErrors) {
markup += '<div class="pointer has-errors fa fa-warning" style="margin-top: 4px; margin-right: 3px; float: left;" ></div>';
@ -623,7 +679,7 @@ nf.ControllerServices = (function () {
}
if (hasErrors || hasBulletins) {
markup += '<span class="hidden row-id">' + nf.Common.escapeHtml(dataContext.id) + '</span>';
markup += '<span class="hidden row-id">' + common.escapeHtml(dataContext.id) + '</span>';
}
return markup;
@ -636,7 +692,7 @@ nf.ControllerServices = (function () {
// determine the appropriate label
var icon = '', label = '';
if (!nf.Common.isEmpty(dataContext.component.validationErrors)) {
if (!common.isEmpty(dataContext.component.validationErrors)) {
icon = 'invalid fa fa-warning';
label = 'Invalid';
} else {
@ -670,7 +726,7 @@ nf.ControllerServices = (function () {
markup += '<div class="pointer edit-controller-service fa fa-pencil" title="Edit" style="margin-top: 2px; margin-right: 3px;" ></div>';
// if there are no validation errors allow enabling
if (nf.Common.isEmpty(dataContext.component.validationErrors)) {
if (common.isEmpty(dataContext.component.validationErrors)) {
markup += '<div class="pointer enable-controller-service fa fa-flash" title="Enable" style="margin-top: 2px; margin-right: 3px;"></div>';
}
}
@ -685,7 +741,7 @@ nf.ControllerServices = (function () {
}
// allow policy configuration conditionally
if (nf.Canvas.isConfigurableAuthorizer() && nf.Common.canAccessTenants()) {
if (canvasUtils.isConfigurableAuthorizer() && common.canAccessTenants()) {
markup += '<div title="Access Policies" class="pointer edit-access-policies fa fa-key" style="margin-top: 2px;"></div>';
}
@ -771,46 +827,46 @@ nf.ControllerServices = (function () {
// determine the desired action
if (controllerServicesGrid.getColumns()[args.cell].id === 'actions') {
if (target.hasClass('edit-controller-service')) {
nf.ControllerService.showConfiguration(serviceTable, controllerServiceEntity);
controllerService.showConfiguration(serviceTable, controllerServiceEntity);
} else if (target.hasClass('enable-controller-service')) {
nf.ControllerService.enable(serviceTable, controllerServiceEntity);
controllerService.enable(serviceTable, controllerServiceEntity);
} else if (target.hasClass('disable-controller-service')) {
nf.ControllerService.disable(serviceTable, controllerServiceEntity);
controllerService.disable(serviceTable, controllerServiceEntity);
} else if (target.hasClass('delete-controller-service')) {
nf.ControllerService.promptToDeleteController(serviceTable, controllerServiceEntity);
controllerService.promptToDeleteController(serviceTable, controllerServiceEntity);
} else if (target.hasClass('view-state-controller-service')) {
nf.ComponentState.showState(controllerServiceEntity, controllerServiceEntity.state === 'DISABLED');
componentState.showState(controllerServiceEntity, controllerServiceEntity.state === 'DISABLED');
} else if (target.hasClass('edit-access-policies')) {
// show the policies for this service
nf.PolicyManagement.showControllerServicePolicy(controllerServiceEntity);
policyManagement.showControllerServicePolicy(controllerServiceEntity);
// close the settings dialog
$('#shell-close-button').click();
}
} else if (controllerServicesGrid.getColumns()[args.cell].id === 'moreDetails') {
if (target.hasClass('view-controller-service')) {
nf.ControllerService.showDetails(serviceTable, controllerServiceEntity);
controllerService.showDetails(serviceTable, controllerServiceEntity);
} else if (target.hasClass('controller-service-usage')) {
// close the settings dialog
$('#shell-close-button').click();
// open the documentation for this controller service
nf.Shell.showPage('../nifi-docs/documentation?' + $.param({
select: nf.Common.substringAfterLast(controllerServiceEntity.component.type, '.')
shell.showPage('../nifi-docs/documentation?' + $.param({
select: common.substringAfterLast(controllerServiceEntity.component.type, '.')
})).done(function() {
if (nf.Common.isDefinedAndNotNull(controllerServiceEntity.component.parentGroupId)) {
if (common.isDefinedAndNotNull(controllerServiceEntity.component.parentGroupId)) {
var groupId;
var processGroup = nf.ProcessGroup.get(controllerServiceEntity.component.parentGroupId);
if (nf.Common.isDefinedAndNotNull(processGroup)) {
var processGroup = processGroup.get(controllerServiceEntity.component.parentGroupId);
if (common.isDefinedAndNotNull(processGroup)) {
groupId = processGroup.id;
} else {
groupId = nf.Canvas.getGroupId();
groupId = canvasUtils.getGroupId();
}
// reload the corresponding group
nf.ProcessGroupConfiguration.showConfiguration(groupId);
processGroupConfiguration.showConfiguration(groupId);
} else {
nf.Settings.showSettings();
showSettings();
}
});
}
@ -838,12 +894,12 @@ nf.ControllerServices = (function () {
var controllerServiceEntity = controllerServicesData.getItemById(serviceId);
// format the errors
var tooltip = nf.Common.formatUnorderedList(controllerServiceEntity.component.validationErrors);
var tooltip = common.formatUnorderedList(controllerServiceEntity.component.validationErrors);
// show the tooltip
if (nf.Common.isDefinedAndNotNull(tooltip)) {
if (common.isDefinedAndNotNull(tooltip)) {
errorIcon.qtip($.extend({},
nf.Common.config.tooltipConfig,
common.config.tooltipConfig,
{
content: tooltip,
position: {
@ -867,13 +923,13 @@ nf.ControllerServices = (function () {
var controllerServiceEntity = controllerServicesData.getItemById(taskId);
// format the tooltip
var bulletins = nf.Common.getFormattedBulletins(controllerServiceEntity.bulletins);
var tooltip = nf.Common.formatUnorderedList(bulletins);
var bulletins = common.getFormattedBulletins(controllerServiceEntity.bulletins);
var tooltip = common.formatUnorderedList(bulletins);
// show the tooltip
if (nf.Common.isDefinedAndNotNull(tooltip)) {
if (common.isDefinedAndNotNull(tooltip)) {
bulletinIcon.qtip($.extend({},
nf.Common.config.tooltipConfig,
common.config.tooltipConfig,
{
content: tooltip,
position: {
@ -910,8 +966,8 @@ nf.ControllerServices = (function () {
}, service));
});
nf.Common.cleanUpTooltips(serviceTable, 'div.has-errors');
nf.Common.cleanUpTooltips(serviceTable, 'div.has-bulletins');
common.cleanUpTooltips(serviceTable, 'div.has-errors');
common.cleanUpTooltips(serviceTable, 'div.has-bulletins');
var controllerServicesGrid = serviceTable.data('gridInstance');
var controllerServicesData = controllerServicesGrid.getData();
@ -927,10 +983,11 @@ nf.ControllerServices = (function () {
return {
/**
* Initializes the status page.
*
*
* @param {jQuery} serviceTable
* @param {function} showSettings
*/
init: function (serviceTable) {
init: function (serviceTable, showSettings) {
if (!initialized) {
// initialize the new controller service dialog
initNewControllerServiceDialog();
@ -940,7 +997,7 @@ nf.ControllerServices = (function () {
}
// initialize the controller service table
initControllerServices(serviceTable);
initControllerServices(serviceTable, showSettings);
},
/**
@ -1027,7 +1084,7 @@ nf.ControllerServices = (function () {
controllerServiceTypesGrid.onDblClick.subscribe(dblClick);
// reset the canvas size after the dialog is shown
if (nf.Common.isDefinedAndNotNull(controllerServiceTypesGrid)) {
if (common.isDefinedAndNotNull(controllerServiceTypesGrid)) {
controllerServiceTypesGrid.setSelectedRows([0]);
controllerServiceTypesGrid.resizeCanvas();
}
@ -1043,7 +1100,7 @@ nf.ControllerServices = (function () {
*/
resetTableSize: function (serviceTable) {
var controllerServicesGrid = serviceTable.data('gridInstance');
if (nf.Common.isDefinedAndNotNull(controllerServicesGrid)) {
if (common.isDefinedAndNotNull(controllerServicesGrid)) {
controllerServicesGrid.resizeCanvas();
}
},
@ -1071,14 +1128,14 @@ nf.ControllerServices = (function () {
controllerServicesData.beginUpdate();
// if there are some bulletins process them
if (!nf.Common.isEmpty(controllerServiceBulletins)) {
if (!common.isEmpty(controllerServiceBulletins)) {
var controllerServiceBulletinsBySource = d3.nest()
.key(function(d) { return d.sourceId; })
.map(controllerServiceBulletins, d3.map);
controllerServiceBulletinsBySource.forEach(function(sourceId, sourceBulletins) {
var controllerService = controllerServicesData.getItemById(sourceId);
if (nf.Common.isDefinedAndNotNull(controllerService)) {
if (common.isDefinedAndNotNull(controllerService)) {
controllerServicesData.updateItem(sourceId, $.extend(controllerService, {
bulletins: sourceBulletins
}));
@ -1096,4 +1153,4 @@ nf.ControllerServices = (function () {
controllerServicesData.endUpdate();
}
};
}());
}));

View File

@ -15,7 +15,7 @@
* limitations under the License.
*/
/* global nf, define, module, require, exports */
/* global define, module, require, exports */
(function (root, factory) {
if (typeof define === 'function' && define.amd) {

View File

@ -15,10 +15,48 @@
* limitations under the License.
*/
/* global nf, d3 */
/* global define, module, require, exports */
nf.Draggable = (function () {
(function (root, factory) {
if (typeof define === 'function' && define.amd) {
define(['jquery',
'd3',
'nf.Connection',
'nf.Birdseye',
'nf.CanvasUtils',
'nf.Common',
'nf.Dialog',
'nf.Client',
'nf.ErrorHandler'],
function ($, d3, connection, birdseye, canvasUtils, common, dialog, client, errorHandler) {
return (nf.Draggable = factory($, d3, connection, birdseye, canvasUtils, common, dialog, client, errorHandler));
});
} else if (typeof exports === 'object' && typeof module === 'object') {
module.exports = (nf.Draggable =
factory(require('jquery'),
require('d3'),
require('nf.Connection'),
require('nf.Birdseye'),
require('nf.CanvasUtils'),
require('nf.Common'),
require('nf.Dialog'),
require('nf.Client'),
require('nf.ErrorHandler')));
} else {
nf.Draggable = factory(root.$,
root.d3,
root.nf.Connection,
root.nf.Birdseye,
root.nf.CanvasUtils,
root.nf.Common,
root.nf.Dialog,
root.nf.Client,
root.nf.ErrorHandler);
}
}(this, function ($, d3, connection, birdseye, canvasUtils, common, dialog, client, errorHandler) {
'use strict';
var nfCanvas;
var drag;
/**
@ -45,8 +83,8 @@ nf.Draggable = (function () {
var selectedComponents = d3.selectAll('g.component.selected');
// ensure every component is writable
if (nf.CanvasUtils.canModify(selectedConnections) === false || nf.CanvasUtils.canModify(selectedComponents) === false) {
nf.Dialog.showOkDialog({
if (canvasUtils.canModify(selectedConnections) === false || canvasUtils.canModify(selectedComponents) === false) {
dialog.showOkDialog({
headerText: 'Component Position',
dialogContent: 'Must be authorized to modify every component selected.'
});
@ -55,7 +93,7 @@ nf.Draggable = (function () {
// go through each selected connection
selectedConnections.each(function (d) {
var connectionUpdate = nf.Draggable.updateConnectionPosition(d, delta);
var connectionUpdate = nfDraggable.updateConnectionPosition(d, delta);
if (connectionUpdate !== null) {
updates.set(d.id, connectionUpdate);
}
@ -64,10 +102,10 @@ nf.Draggable = (function () {
// go through each selected component
selectedComponents.each(function (d) {
// consider any self looping connections
var connections = nf.Connection.getComponentConnections(d.id);
$.each(connections, function(_, connection) {
if (!updates.has(connection.id) && nf.CanvasUtils.getConnectionSourceComponentId(connection) === nf.CanvasUtils.getConnectionDestinationComponentId(connection)) {
var connectionUpdate = nf.Draggable.updateConnectionPosition(nf.Connection.get(connection.id), delta);
var connections = connection.getComponentConnections(d.id);
$.each(connections, function (_, connection) {
if (!updates.has(connection.id) && canvasUtils.getConnectionSourceComponentId(connection) === canvasUtils.getConnectionDestinationComponentId(connection)) {
var connectionUpdate = nfDraggable.updateConnectionPosition(connection.get(connection.id), delta);
if (connectionUpdate !== null) {
updates.set(connection.id, connectionUpdate);
}
@ -75,10 +113,10 @@ nf.Draggable = (function () {
});
// consider the component itself
updates.set(d.id, nf.Draggable.updateComponentPosition(d, delta));
updates.set(d.id, nfDraggable.updateComponentPosition(d, delta));
});
nf.Draggable.refreshConnections(updates);
nfDraggable.refreshConnections(updates);
};
/**
@ -88,15 +126,15 @@ nf.Draggable = (function () {
var selection = d3.selectAll('g.component.selected, g.connection.selected');
var group = d3.select('g.drop');
if (nf.CanvasUtils.canModify(selection) === false) {
nf.Dialog.showOkDialog({
if (canvasUtils.canModify(selection) === false) {
dialog.showOkDialog({
headerText: 'Component Position',
dialogContent: 'Must be authorized to modify every component selected.'
});
return;
}
if (nf.CanvasUtils.canModify(group) === false) {
nf.Dialog.showOkDialog({
if (canvasUtils.canModify(group) === false) {
dialog.showOkDialog({
headerText: 'Component Position',
dialogContent: 'Not authorized to modify the destination group.'
});
@ -104,102 +142,104 @@ nf.Draggable = (function () {
}
// move the seleciton into the group
nf.CanvasUtils.moveComponents(selection, group);
canvasUtils.moveComponents(selection, group);
};
return {
init: function () {
var nfDraggable = {
init: function (canvas) {
nfCanvas = canvas;
// handle component drag events
drag = d3.behavior.drag()
.on('dragstart', function () {
// stop further propagation
d3.event.sourceEvent.stopPropagation();
})
.on('drag', function () {
var dragSelection = d3.select('rect.drag-selection');
.on('dragstart', function () {
// stop further propagation
d3.event.sourceEvent.stopPropagation();
})
.on('drag', function () {
var dragSelection = d3.select('rect.drag-selection');
// lazily create the drag selection box
if (dragSelection.empty()) {
// get the current selection
var selection = d3.selectAll('g.component.selected');
// lazily create the drag selection box
if (dragSelection.empty()) {
// get the current selection
var selection = d3.selectAll('g.component.selected');
// determine the appropriate bounding box
var minX = null, maxX = null, minY = null, maxY = null;
selection.each(function (d) {
if (minX === null || d.position.x < minX) {
minX = d.position.x;
}
if (minY === null || d.position.y < minY) {
minY = d.position.y;
}
var componentMaxX = d.position.x + d.dimensions.width;
var componentMaxY = d.position.y + d.dimensions.height;
if (maxX === null || componentMaxX > maxX) {
maxX = componentMaxX;
}
if (maxY === null || componentMaxY > maxY) {
maxY = componentMaxY;
}
// determine the appropriate bounding box
var minX = null, maxX = null, minY = null, maxY = null;
selection.each(function (d) {
if (minX === null || d.position.x < minX) {
minX = d.position.x;
}
if (minY === null || d.position.y < minY) {
minY = d.position.y;
}
var componentMaxX = d.position.x + d.dimensions.width;
var componentMaxY = d.position.y + d.dimensions.height;
if (maxX === null || componentMaxX > maxX) {
maxX = componentMaxX;
}
if (maxY === null || componentMaxY > maxY) {
maxY = componentMaxY;
}
});
// create a selection box for the move
d3.select('#canvas').append('rect')
.attr('rx', 6)
.attr('ry', 6)
.attr('x', minX)
.attr('y', minY)
.attr('class', 'drag-selection')
.attr('pointer-events', 'none')
.attr('width', maxX - minX)
.attr('height', maxY - minY)
.attr('stroke-width', function () {
return 1 / canvasUtils.scaleCanvasView();
})
.attr('stroke-dasharray', function () {
return 4 / canvasUtils.scaleCanvasView();
})
.datum({
original: {
x: minX,
y: minY
},
x: minX,
y: minY
});
} else {
// update the position of the drag selection
dragSelection.attr('x', function (d) {
d.x += d3.event.dx;
return d.x;
})
.attr('y', function (d) {
d.y += d3.event.dy;
return d.y;
});
}
})
.on('dragend', function () {
// stop further propagation
d3.event.sourceEvent.stopPropagation();
// create a selection box for the move
d3.select('#canvas').append('rect')
.attr('rx', 6)
.attr('ry', 6)
.attr('x', minX)
.attr('y', minY)
.attr('class', 'drag-selection')
.attr('pointer-events', 'none')
.attr('width', maxX - minX)
.attr('height', maxY - minY)
.attr('stroke-width', function () {
return 1 / nf.Canvas.View.scale();
})
.attr('stroke-dasharray', function () {
return 4 / nf.Canvas.View.scale();
})
.datum({
original: {
x: minX,
y: minY
},
x: minX,
y: minY
});
} else {
// update the position of the drag selection
dragSelection.attr('x', function (d) {
d.x += d3.event.dx;
return d.x;
})
.attr('y', function (d) {
d.y += d3.event.dy;
return d.y;
});
}
})
.on('dragend', function () {
// stop further propagation
d3.event.sourceEvent.stopPropagation();
// get the drag selection
var dragSelection = d3.select('rect.drag-selection');
// get the drag selection
var dragSelection = d3.select('rect.drag-selection');
// ensure we found a drag selection
if (dragSelection.empty()) {
return;
}
// ensure we found a drag selection
if (dragSelection.empty()) {
return;
}
// either move or update the selections group as appropriate
if (d3.select('g.drop').empty()) {
updateComponentsPosition(dragSelection);
} else {
updateComponentsGroup();
}
// either move or update the selections group as appropriate
if (d3.select('g.drop').empty()) {
updateComponentsPosition(dragSelection);
} else {
updateComponentsGroup();
}
// remove the drag selection
dragSelection.remove();
});
// remove the drag selection
dragSelection.remove();
});
},
/**
@ -209,7 +249,7 @@ nf.Draggable = (function () {
* @param delta The change in position
* @returns {*}
*/
updateComponentPosition: function(d, delta) {
updateComponentPosition: function (d, delta) {
var newPosition = {
'x': d.position.x + delta.x,
'y': d.position.y + delta.y
@ -217,7 +257,7 @@ nf.Draggable = (function () {
// build the entity
var entity = {
'revision': nf.Client.getRevision(d),
'revision': client.getRevision(d),
'component': {
'id': d.id,
'position': newPosition
@ -234,7 +274,7 @@ nf.Draggable = (function () {
contentType: 'application/json'
}).done(function (response) {
// update the component
nf[d.type].set(response);
canvasUtils.getComponentByType(d.type).set(response);
// resolve with an object so we can refresh when finished
deferred.resolve({
@ -243,12 +283,12 @@ nf.Draggable = (function () {
});
}).fail(function (xhr, status, error) {
if (xhr.status === 400 || xhr.status === 404 || xhr.status === 409) {
nf.Dialog.showOkDialog({
dialog.showOkDialog({
headerText: 'Component Position',
dialogContent: nf.Common.escapeHtml(xhr.responseText)
dialogContent: common.escapeHtml(xhr.responseText)
});
} else {
nf.ErrorHandler.handleAjaxError(xhr, status, error);
errorHandler.handleAjaxError(xhr, status, error);
}
deferred.reject();
@ -263,7 +303,7 @@ nf.Draggable = (function () {
* @param delta The change in position
* @returns {*}
*/
updateConnectionPosition: function(d, delta) {
updateConnectionPosition: function (d, delta) {
// only update if necessary
if (d.bends.length === 0) {
return null;
@ -278,7 +318,7 @@ nf.Draggable = (function () {
});
var entity = {
'revision': nf.Client.getRevision(d),
'revision': client.getRevision(d),
'component': {
id: d.id,
bends: newBends
@ -295,7 +335,7 @@ nf.Draggable = (function () {
contentType: 'application/json'
}).done(function (response) {
// update the component
nf.Connection.set(response);
connection.set(response);
// resolve with an object so we can refresh when finished
deferred.resolve({
@ -304,12 +344,12 @@ nf.Draggable = (function () {
});
}).fail(function (xhr, status, error) {
if (xhr.status === 400 || xhr.status === 404 || xhr.status === 409) {
nf.Dialog.showOkDialog({
dialog.showOkDialog({
headerText: 'Component Position',
dialogContent: nf.Common.escapeHtml(xhr.responseText)
dialogContent: common.escapeHtml(xhr.responseText)
});
} else {
nf.ErrorHandler.handleAjaxError(xhr, status, error);
errorHandler.handleAjaxError(xhr, status, error);
}
deferred.reject();
@ -322,7 +362,7 @@ nf.Draggable = (function () {
*
* @param updates
*/
refreshConnections: function(updates) {
refreshConnections: function (updates) {
// wait for all updates to complete
$.when.apply(window, updates.values()).done(function () {
var dragged = $.makeArray(arguments);
@ -335,7 +375,7 @@ nf.Draggable = (function () {
connections.add(component.id);
} else {
// get connections that need to be refreshed because its attached to this component
var componentConnections = nf.Connection.getComponentConnections(component.id);
var componentConnections = connection.getComponentConnections(component.id);
$.each(componentConnections, function (_, connection) {
connections.add(connection.id);
});
@ -344,10 +384,10 @@ nf.Draggable = (function () {
// refresh the connections
connections.forEach(function (connectionId) {
nf.Connection.refresh(connectionId);
connection.refresh(connectionId);
});
}).always(function(){
nf.Birdseye.refresh();
}).always(function () {
birdseye.refresh();
});
},
@ -369,4 +409,6 @@ nf.Draggable = (function () {
components.classed('moveable', false).on('.drag', null);
}
};
}());
return nfDraggable;
}));

View File

@ -15,9 +15,39 @@
* limitations under the License.
*/
/* global nf, d3 */
/* global define, module, require, exports */
nf.Funnel = (function () {
(function (root, factory) {
if (typeof define === 'function' && define.amd) {
define(['jquery',
'd3',
'nf.Common',
'nf.Client',
'nf.CanvasUtils'],
function ($, d3, common, client, canvasUtils) {
return (nf.Funnel = factory($, d3, common, client, canvasUtils));
});
} else if (typeof exports === 'object' && typeof module === 'object') {
module.exports = (nf.Funnel =
factory(require('jquery'),
require('d3'),
require('nf.Common'),
require('nf.Client'),
require('nf.CanvasUtils')));
} else {
nf.Funnel = factory(root.$,
root.d3,
root.nf.Common,
root.nf.Client,
root.nf.CanvasUtils);
}
}(this, function ($, d3, common, client, canvasUtils) {
'use strict';
var nfConnectable;
var nfDraggable;
var nfSelectable;
var nfContextMenu;
var dimensions = {
width: 48,
@ -75,7 +105,7 @@ nf.Funnel = (function () {
'class': 'funnel component'
})
.classed('selected', selected)
.call(nf.CanvasUtils.position);
.call(canvasUtils.position);
// funnel border
funnel.append('rect')
@ -119,7 +149,7 @@ nf.Funnel = (function () {
.text('\ue803');
// always support selection
funnel.call(nf.Selectable.activate).call(nf.ContextMenu.activate);
funnel.call(nfSelectable.activate).call(nfContextMenu.activate);
};
/**
@ -148,7 +178,7 @@ nf.Funnel = (function () {
var funnel = d3.select(this);
// update the component behavior as appropriate
nf.CanvasUtils.editable(funnel);
canvasUtils.editable(funnel, nfConnectable, nfDraggable);
});
};
@ -161,11 +191,16 @@ nf.Funnel = (function () {
removed.remove();
};
return {
var nfFunnel = {
/**
* Initializes of the Processor handler.
*/
init: function () {
init: function (connectable, draggable, selectable, contextMenu) {
nfConnectable = connectable;
nfDraggable = draggable;
nfSelectable = selectable;
nfContextMenu = contextMenu;
funnelMap = d3.map();
removedCache = d3.map();
addedCache = d3.map();
@ -186,8 +221,8 @@ nf.Funnel = (function () {
*/
add: function (funnelEntities, options) {
var selectAll = false;
if (nf.Common.isDefinedAndNotNull(options)) {
selectAll = nf.Common.isDefinedAndNotNull(options.selectAll) ? options.selectAll : selectAll;
if (common.isDefinedAndNotNull(options)) {
selectAll = common.isDefinedAndNotNull(options.selectAll) ? options.selectAll : selectAll;
}
// get the current time
@ -208,7 +243,7 @@ nf.Funnel = (function () {
$.each(funnelEntities, function (_, funnelEntity) {
add(funnelEntity);
});
} else if (nf.Common.isDefinedAndNotNull(funnelEntities)) {
} else if (common.isDefinedAndNotNull(funnelEntities)) {
add(funnelEntities);
}
@ -217,7 +252,7 @@ nf.Funnel = (function () {
selection.enter().call(renderFunnels, selectAll);
selection.call(updateFunnels);
},
/**
* Populates the graph with the specified funnels.
*
@ -227,16 +262,16 @@ nf.Funnel = (function () {
set: function (funnelEntities, options) {
var selectAll = false;
var transition = false;
if (nf.Common.isDefinedAndNotNull(options)) {
selectAll = nf.Common.isDefinedAndNotNull(options.selectAll) ? options.selectAll : selectAll;
transition = nf.Common.isDefinedAndNotNull(options.transition) ? options.transition : transition;
if (common.isDefinedAndNotNull(options)) {
selectAll = common.isDefinedAndNotNull(options.selectAll) ? options.selectAll : selectAll;
transition = common.isDefinedAndNotNull(options.transition) ? options.transition : transition;
}
var set = function (proposedFunnelEntity) {
var currentFunnelEntity = funnelMap.get(proposedFunnelEntity.id);
// set the funnel if appropriate due to revision and wasn't previously removed
if (nf.Client.isNewerRevision(currentFunnelEntity, proposedFunnelEntity) && !removedCache.has(proposedFunnelEntity.id)) {
if (client.isNewerRevision(currentFunnelEntity, proposedFunnelEntity) && !removedCache.has(proposedFunnelEntity.id)) {
funnelMap.set(proposedFunnelEntity.id, $.extend({
type: 'Funnel',
dimensions: dimensions
@ -259,14 +294,14 @@ nf.Funnel = (function () {
$.each(funnelEntities, function (_, funnelEntity) {
set(funnelEntity);
});
} else if (nf.Common.isDefinedAndNotNull(funnelEntities)) {
} else if (common.isDefinedAndNotNull(funnelEntities)) {
set(funnelEntities);
}
// apply the selection and handle all new processors
var selection = select();
selection.enter().call(renderFunnels, selectAll);
selection.call(updateFunnels).call(nf.CanvasUtils.position, transition);
selection.call(updateFunnels).call(canvasUtils.position, transition);
selection.exit().call(removeFunnels);
},
@ -277,7 +312,7 @@ nf.Funnel = (function () {
* @param {string} id
*/
get: function (id) {
if (nf.Common.isUndefined(id)) {
if (common.isUndefined(id)) {
return funnelMap.values();
} else {
return funnelMap.get(id);
@ -291,7 +326,7 @@ nf.Funnel = (function () {
* @param {string} id Optional
*/
refresh: function (id) {
if (nf.Common.isDefinedAndNotNull(id)) {
if (common.isDefinedAndNotNull(id)) {
d3.select('#id-' + id).call(updateFunnels);
} else {
d3.selectAll('g.funnel').call(updateFunnels);
@ -312,7 +347,7 @@ nf.Funnel = (function () {
url: funnelEntity.uri,
dataType: 'json'
}).done(function (response) {
nf.Funnel.set(response);
nfFunnel.set(response);
});
}
},
@ -323,7 +358,7 @@ nf.Funnel = (function () {
* @param {string} id The id
*/
position: function (id) {
d3.select('#id-' + id).call(nf.CanvasUtils.position);
d3.select('#id-' + id).call(canvasUtils.position);
},
/**
@ -352,7 +387,7 @@ nf.Funnel = (function () {
* Removes all processors.
*/
removeAll: function () {
nf.Funnel.remove(funnelMap.keys());
nfFunnel.remove(funnelMap.keys());
},
/**
@ -373,4 +408,6 @@ nf.Funnel = (function () {
expire(removedCache);
}
};
}());
return nfFunnel;
}));

View File

@ -15,12 +15,31 @@
* limitations under the License.
*/
/* global nf */
/* global define, module, require, exports */
/**
* Handles the upstream/downstream dialogs.
*/
nf.GoTo = (function () {
(function (root, factory) {
if (typeof define === 'function' && define.amd) {
define(['jquery',
'nf.ErrorHandler',
'nf.CanvasUtils'],
function ($, errorHandler, canvasUtils) {
return (nf.GoTo = factory($, errorHandler, canvasUtils));
});
} else if (typeof exports === 'object' && typeof module === 'object') {
module.exports = (nf.GoTo =
factory(require('jquery'),
require('nf.ErrorHandler'),
require('nf.CanvasUtils')));
} else {
nf.GoTo = factory(root.$,
root.nf.ErrorHandler,
root.nf.CanvasUtils);
}
}(this, function ($, errorHandler, canvasUtils) {
'use strict';
var config = {
urls: {
@ -57,7 +76,7 @@ nf.GoTo = (function () {
var connectionStyle = 'unset';
var connectionName = 'Connection';
if (connectionEntity.permissions.canRead === true) {
var formattedConnectionName = nf.CanvasUtils.formatConnectionName(connectionEntity.component);
var formattedConnectionName = canvasUtils.formatConnectionName(connectionEntity.component);
if (formattedConnectionName !== '') {
connectionStyle = '';
connectionName = formattedConnectionName;
@ -68,7 +87,7 @@ nf.GoTo = (function () {
$('<div class="search-result-icon icon-connect"></div>').appendTo(connectionEntry);
$('<div class="connection-entry-name go-to-link"></div>').attr('title', connectionName).addClass(connectionStyle).text(connectionName).on('click', function () {
// go to the connection
nf.CanvasUtils.showComponent(parentProcessGroupId, connectionEntity.id);
canvasUtils.showComponent(parentProcessGroupId, connectionEntity.id);
// close the dialog
$('#connections-dialog').modal('hide');
@ -117,7 +136,7 @@ nf.GoTo = (function () {
$('<div class="search-result-icon"></div>').addClass(smallIconClass).appendTo(downstreamComponent);
$('<div class="destination-component-name go-to-link"></div>').attr('title', destinationName).text(destinationName).on('click', function () {
// go to the component
nf.CanvasUtils.showComponent(connectionEntity.destinationGroupId, connectionEntity.destinationId);
canvasUtils.showComponent(connectionEntity.destinationGroupId, connectionEntity.destinationId);
// close the dialog
$('#connections-dialog').modal('hide');
@ -152,7 +171,7 @@ nf.GoTo = (function () {
$('<div class="search-result-icon icon-group"></div>').appendTo(downstreamComponent);
$('<div class="destination-component-name go-to-link"></div>').attr('title', groupLabel).text(groupLabel).on('click', function () {
// go to the remote process group
nf.CanvasUtils.showComponent(parentProcessGroupId, processGroupEntity.id);
canvasUtils.showComponent(parentProcessGroupId, processGroupEntity.id);
// close the dialog
$('#connections-dialog').modal('hide');
@ -174,7 +193,7 @@ nf.GoTo = (function () {
$('<div class="search-result-icon icon-port-in"></div>').appendTo(downstreamInputPort);
$('<div class="destination-input-port-name go-to-link"></div>').attr('title', portLabel).text(portLabel).on('click', function () {
// go to the remote process group
nf.CanvasUtils.showComponent(connectionEntity.destinationGroupId, connectionEntity.destinationId);
canvasUtils.showComponent(connectionEntity.destinationGroupId, connectionEntity.destinationId);
// close the dialog
$('#connections-dialog').modal('hide');
@ -209,7 +228,7 @@ nf.GoTo = (function () {
$('<div class="search-result-icon icon-group-remote"></div>').appendTo(downstreamComponent);
$('<div class="destination-component-name go-to-link"></div>').attr('title', remoteGroupLabel).text(remoteGroupLabel).on('click', function () {
// go to the remote process group
nf.CanvasUtils.showComponent(parentProcessGroupId, remoteProcessGroupEntity.id);
canvasUtils.showComponent(parentProcessGroupId, remoteProcessGroupEntity.id);
// close the dialog
$('#connections-dialog').modal('hide');
@ -263,7 +282,7 @@ nf.GoTo = (function () {
$('<div class="search-result-icon"></div>').addClass(smallIconClass).appendTo(sourceComponent);
$('<div class="source-component-name go-to-link"></div>').attr('title', sourceName).text(sourceName).on('click', function () {
// go to the component
nf.CanvasUtils.showComponent(connectionEntity.sourceGroupId, connectionEntity.sourceId);
canvasUtils.showComponent(connectionEntity.sourceGroupId, connectionEntity.sourceId);
// close the dialog
$('#connections-dialog').modal('hide');
@ -298,7 +317,7 @@ nf.GoTo = (function () {
$('<div class="search-result-icon icon-group"></div>').appendTo(sourceComponent);
$('<div class="source-component-name go-to-link"></div>').attr('title', groupLabel).text(groupLabel).on('click', function () {
// go to the process group
nf.CanvasUtils.showComponent(parentProcessGroupId, processGroupEntity.id);
canvasUtils.showComponent(parentProcessGroupId, processGroupEntity.id);
// close the dialog
$('#connections-dialog').modal('hide');
@ -319,7 +338,7 @@ nf.GoTo = (function () {
$('<div class="search-result-icon icon-port-out"></div>').appendTo(sourceOutputPort);
$('<div class="source-output-port-name go-to-link"></div>').attr('title', portLabel).text(portLabel).on('click', function () {
// go to the output port
nf.CanvasUtils.showComponent(connectionEntity.sourceGroupId, connectionEntity.sourceId);
canvasUtils.showComponent(connectionEntity.sourceGroupId, connectionEntity.sourceId);
// close the dialog
$('#connections-dialog').modal('hide');
@ -354,7 +373,7 @@ nf.GoTo = (function () {
$('<div class="search-result-icon icon-group-remote"></div>').appendTo(sourceComponent);
$('<div class="source-component-name go-to-link"></div>').attr('title', remoteGroupLabel).text(remoteGroupLabel).on('click', function () {
// go to the remote process group
nf.CanvasUtils.showComponent(parentProcessGroupId, remoteProcessGroupEntity.id);
canvasUtils.showComponent(parentProcessGroupId, remoteProcessGroupEntity.id);
// close the dialog
$('#connections-dialog').modal('hide');
@ -432,9 +451,9 @@ nf.GoTo = (function () {
*/
showDownstreamFromProcessor: function (selection) {
var processorEntity = selection.datum();
var connections = nf.Connection.get();
var processGroups = nf.ProcessGroup.get();
var remoteProcessGroups = nf.RemoteProcessGroup.get();
var connections = canvasUtils.getComponentByType('Connection').get();
var processGroups = canvasUtils.getComponentByType('ProcessGroup').get();
var remoteProcessGroups = canvasUtils.getComponentByType('RemoteProcessGroup').get();
var processorLabel = getDisplayName(processorEntity);
@ -452,7 +471,7 @@ nf.GoTo = (function () {
$.each(connections, function (_, connectionEntity) {
// only show connections for which this selection is the source
if (connectionEntity.sourceId === processorEntity.id) {
addConnection(nf.Canvas.getGroupId(), connectionEntity, processGroups, remoteProcessGroups);
addConnection(canvasUtils.getGroupId(), connectionEntity, processGroups, remoteProcessGroups);
}
});
@ -472,9 +491,9 @@ nf.GoTo = (function () {
*/
showUpstreamFromProcessor: function (selection) {
var processorEntity = selection.datum();
var connections = nf.Connection.get();
var processGroups = nf.ProcessGroup.get();
var remoteProcessGroups = nf.RemoteProcessGroup.get();
var connections = canvasUtils.getComponentByType('Connection').get();
var processGroups = canvasUtils.getComponentByType('ProcessGroup').get();
var remoteProcessGroups = canvasUtils.getComponentByType('RemoteProcessGroup').get();
var processorLabel = getDisplayName(processorEntity);
@ -492,7 +511,7 @@ nf.GoTo = (function () {
$.each(connections, function (_, connectionEntity) {
// only show connections for which this selection is the destination
if (connectionEntity.destinationId === processorEntity.id) {
addConnection(nf.Canvas.getGroupId(), connectionEntity, processGroups, remoteProcessGroups);
addConnection(canvasUtils.getGroupId(), connectionEntity, processGroups, remoteProcessGroups);
}
});
@ -512,12 +531,12 @@ nf.GoTo = (function () {
*/
showDownstreamFromGroup: function (selection) {
var groupEntity = selection.datum();
var connections = nf.Connection.get();
var processGroups = nf.ProcessGroup.get();
var remoteProcessGroups = nf.RemoteProcessGroup.get();
var connections = canvasUtils.getComponentByType('Connection').get();
var processGroups = canvasUtils.getComponentByType('ProcessGroup').get();
var remoteProcessGroups = canvasUtils.getComponentByType('RemoteProcessGroup').get();
var iconStyle = 'icon-group';
if (nf.CanvasUtils.isRemoteProcessGroup(selection)) {
if (canvasUtils.isRemoteProcessGroup(selection)) {
iconStyle = 'icon-group-remote';
}
@ -537,7 +556,7 @@ nf.GoTo = (function () {
$.each(connections, function (_, connectionEntity) {
// only show connections for which this selection is the source
if (connectionEntity.sourceGroupId === groupEntity.id) {
addConnection(nf.Canvas.getGroupId(), connectionEntity, processGroups, remoteProcessGroups);
addConnection(canvasUtils.getGroupId(), connectionEntity, processGroups, remoteProcessGroups);
}
});
@ -557,12 +576,12 @@ nf.GoTo = (function () {
*/
showUpstreamFromGroup: function (selection) {
var groupEntity = selection.datum();
var connections = nf.Connection.get();
var processGroups = nf.ProcessGroup.get();
var remoteProcessGroups = nf.RemoteProcessGroup.get();
var connections = canvasUtils.getComponentByType('Connection').get();
var processGroups = canvasUtils.getComponentByType('ProcessGroup').get();
var remoteProcessGroups = canvasUtils.getComponentByType('RemoteProcessGroup').get();
var iconStyle = 'icon-group';
if (nf.CanvasUtils.isRemoteProcessGroup(selection)) {
if (canvasUtils.isRemoteProcessGroup(selection)) {
iconStyle = 'icon-group-remote';
}
@ -582,7 +601,7 @@ nf.GoTo = (function () {
$.each(connections, function (_, connectionEntity) {
// only show connections for which this selection is the destination
if (connectionEntity.destinationGroupId === groupEntity.id) {
addConnection(nf.Canvas.getGroupId(), connectionEntity, processGroups, remoteProcessGroups);
addConnection(canvasUtils.getGroupId(), connectionEntity, processGroups, remoteProcessGroups);
}
});
@ -602,9 +621,9 @@ nf.GoTo = (function () {
*/
showDownstreamFromInputPort: function (selection) {
var portEntity = selection.datum();
var connections = nf.Connection.get();
var processGroups = nf.ProcessGroup.get();
var remoteProcessGroups = nf.RemoteProcessGroup.get();
var connections = canvasUtils.getComponentByType('Connection').get();
var processGroups = canvasUtils.getComponentByType('ProcessGroup').get();
var remoteProcessGroups = canvasUtils.getComponentByType('RemoteProcessGroup').get();
var portLabel = getDisplayName(portEntity);
@ -622,7 +641,7 @@ nf.GoTo = (function () {
$.each(connections, function (_, connectionEntity) {
// only show connections for which this selection is the source
if (connectionEntity.sourceId === portEntity.id) {
addConnection(nf.Canvas.getGroupId(), connectionEntity, processGroups, remoteProcessGroups);
addConnection(canvasUtils.getGroupId(), connectionEntity, processGroups, remoteProcessGroups);
}
});
@ -645,7 +664,7 @@ nf.GoTo = (function () {
$.ajax({
type: 'GET',
url: config.urls.processGroups + encodeURIComponent(nf.Canvas.getParentGroupId()),
url: config.urls.processGroups + encodeURIComponent(canvasUtils.getParentGroupId()),
dataType: 'json'
}).done(function (response) {
var flow = response.processGroupFlow.flow;
@ -662,7 +681,7 @@ nf.GoTo = (function () {
// populate the upstream dialog
$('#connections-context')
.append('<div class="search-result-icon icon-group"></div>')
.append($('<div class="connections-component-name"></div>').text(nf.Canvas.getGroupName()))
.append($('<div class="connections-component-name"></div>').text(canvasUtils.getGroupName()))
.append('<div class="clear"></div>')
.append('<div class="search-result-icon icon-port-in" style="margin-left: 20px;"></div>')
.append($('<div class="connections-component-name"></div>').text(portLabel))
@ -672,7 +691,7 @@ nf.GoTo = (function () {
$.each(connections, function (_, connectionEntity) {
// only show connections for which this selection is the destination
if (connectionEntity.destinationId === portEntity.id) {
addConnection(nf.Canvas.getParentGroupId(), connectionEntity, processGroups, remoteProcessGroups);
addConnection(canvasUtils.getParentGroupId(), connectionEntity, processGroups, remoteProcessGroups);
}
});
@ -683,7 +702,7 @@ nf.GoTo = (function () {
// show the upstream dialog
$('#connections-dialog').modal('setHeaderText', 'Upstream Connections').modal('show');
}).fail(nf.ErrorHandler.handleAjaxError);
}).fail(errorHandler.handleAjaxError);
},
/**
@ -696,7 +715,7 @@ nf.GoTo = (function () {
$.ajax({
type: 'GET',
url: config.urls.processGroups + encodeURIComponent(nf.Canvas.getParentGroupId()),
url: config.urls.processGroups + encodeURIComponent(canvasUtils.getParentGroupId()),
dataType: 'json'
}).done(function (response) {
var flow = response.processGroupFlow.flow;
@ -713,7 +732,7 @@ nf.GoTo = (function () {
// populate the downstream dialog
$('#connections-context')
.append('<div class="search-result-icon icon-group"></div>')
.append($('<div class="connections-component-name"></div>').text(nf.Canvas.getGroupName()))
.append($('<div class="connections-component-name"></div>').text(canvasUtils.getGroupName()))
.append('<div class="clear"></div>')
.append('<div class="search-result-icon icon-port-out" style="margin-left: 20px;"></div>')
.append($('<div class="connections-component-name"></div>').text(portLabel))
@ -723,7 +742,7 @@ nf.GoTo = (function () {
$.each(connections, function (_, connectionEntity) {
// only show connections for which this selection is the source
if (connectionEntity.sourceId === portEntity.id) {
addConnection(nf.Canvas.getParentGroupId(), connectionEntity, processGroups, remoteProcessGroups);
addConnection(canvasUtils.getParentGroupId(), connectionEntity, processGroups, remoteProcessGroups);
}
});
@ -734,7 +753,7 @@ nf.GoTo = (function () {
// show the downstream dialog
$('#connections-dialog').modal('setHeaderText', 'Downstream Connections').modal('show');
}).fail(nf.ErrorHandler.handleAjaxError);
}).fail(errorHandler.handleAjaxError);
},
/**
@ -744,9 +763,9 @@ nf.GoTo = (function () {
*/
showUpstreamFromOutputPort: function (selection) {
var portEntity = selection.datum();
var connections = nf.Connection.get();
var processGroups = nf.ProcessGroup.get();
var remoteProcessGroups = nf.RemoteProcessGroup.get();
var connections = canvasUtils.getComponentByType('Connection').get();
var processGroups = canvasUtils.getComponentByType('ProcessGroup').get();
var remoteProcessGroups = canvasUtils.getComponentByType('RemoteProcessGroup').get();
var portLabel = getDisplayName(portEntity);
@ -764,7 +783,7 @@ nf.GoTo = (function () {
$.each(connections, function (_, connectionEntity) {
// only show connections for which this selection is the destination
if (connectionEntity.destinationId === portEntity.id) {
addConnection(nf.Canvas.getGroupId(), connectionEntity, processGroups, remoteProcessGroups);
addConnection(canvasUtils.getGroupId(), connectionEntity, processGroups, remoteProcessGroups);
}
});
@ -784,9 +803,9 @@ nf.GoTo = (function () {
*/
showDownstreamFromFunnel: function (selection) {
var funnelEntity = selection.datum();
var connections = nf.Connection.get();
var processGroups = nf.ProcessGroup.get();
var remoteProcessGroups = nf.RemoteProcessGroup.get();
var connections = canvasUtils.getComponentByType('Connection').get();
var processGroups = canvasUtils.getComponentByType('ProcessGroup').get();
var remoteProcessGroups = canvasUtils.getComponentByType('RemoteProcessGroup').get();
// record details of the current component
currentComponentId = funnelEntity.id;
@ -802,7 +821,7 @@ nf.GoTo = (function () {
$.each(connections, function (_, connectionEntity) {
// only show connections for which this selection is the source
if (connectionEntity.sourceId === funnelEntity.id) {
addConnection(nf.Canvas.getGroupId(), connectionEntity, processGroups, remoteProcessGroups);
addConnection(canvasUtils.getGroupId(), connectionEntity, processGroups, remoteProcessGroups);
}
});
@ -822,9 +841,9 @@ nf.GoTo = (function () {
*/
showUpstreamFromFunnel: function (selection) {
var funnelEntity = selection.datum();
var connections = nf.Connection.get();
var processGroups = nf.ProcessGroup.get();
var remoteProcessGroups = nf.RemoteProcessGroup.get();
var connections = canvasUtils.getComponentByType('Connection').get();
var processGroups = canvasUtils.getComponentByType('ProcessGroup').get();
var remoteProcessGroups = canvasUtils.getComponentByType('RemoteProcessGroup').get();
// record details of the current component
currentComponentId = funnelEntity.id;
@ -840,7 +859,7 @@ nf.GoTo = (function () {
$.each(connections, function (_, connectionEntity) {
// only show connections for which this selection is the destination
if (connectionEntity.destinationId === funnelEntity.id) {
addConnection(nf.Canvas.getGroupId(), connectionEntity, processGroups, remoteProcessGroups);
addConnection(canvasUtils.getGroupId(), connectionEntity, processGroups, remoteProcessGroups);
}
});
@ -853,4 +872,4 @@ nf.GoTo = (function () {
$('#connections-dialog').modal('setHeaderText', 'Upstream Connections').modal('show');
}
};
}());
}));

View File

@ -15,16 +15,74 @@
* limitations under the License.
*/
/* global nf */
/* global define, module, require, exports */
nf.Graph = (function () {
(function (root, factory) {
if (typeof define === 'function' && define.amd) {
define(['jquery',
'd3',
'nf.Common',
'nf.ng.Bridge',
'nf.Label',
'nf.Funnel',
'nf.Port',
'nf.RemoteProcessGroup',
'nf.ProcessGroup',
'nf.Processor',
'nf.Connection',
'nf.CanvasUtils',
'nf.Connectable',
'nf.Draggable',
'nf.Selectable',
'nf.ContextMenu'],
function ($, d3, common, angularBridge, nfLabel, nfFunnel, nfPort, nfRemoteProcessGroup, nfProcessGroup, nfProcessor, nfConnection, canvasUtils, connectable, draggable, selectable, contextMenu) {
return (nf.Graph = factory($, d3, common, angularBridge, nfLabel, nfFunnel, nfPort, nfRemoteProcessGroup, nfProcessGroup, nfProcessor, nfConnection, canvasUtils, connectable, draggable, selectable, contextMenu));
});
} else if (typeof exports === 'object' && typeof module === 'object') {
module.exports = (nf.Graph =
factory(require('jquery'),
require('d3'),
require('nf.Common'),
require('nf.ng.Bridge'),
require('nf.Label'),
require('nf.Funnel'),
require('nf.Port'),
require('nf.RemoteProcessGroup'),
require('nf.ProcessGroup'),
require('nf.Processor'),
require('nf.Connection'),
require('nf.CanvasUtils'),
require('nf.Connectable'),
require('nf.Draggable'),
require('nf.Selectable'),
require('nf.ContextMenu')));
} else {
nf.Graph = factory(root.$,
root.d3,
root.nf.Common,
root.nf.ng.Bridge,
root.nf.Label,
root.nf.Funnel,
root.nf.Port,
root.nf.RemoteProcessGroup,
root.nf.ProcessGroup,
root.nf.Processor,
root.nf.Connection,
root.nf.CanvasUtils,
root.nf.Connectable,
root.nf.Draggable,
root.nf.Selectable,
root.nf.ContextMenu);
}
}(this, function ($, d3, common, angularBridge, nfLabel, nfFunnel, nfPort, nfRemoteProcessGroup, nfProcessGroup, nfProcessor, nfConnection, canvasUtils, connectable, draggable, selectable, contextMenu) {
'use strict';
var combinePorts = function (contents) {
if (nf.Common.isDefinedAndNotNull(contents.inputPorts) && nf.Common.isDefinedAndNotNull(contents.outputPorts)) {
if (common.isDefinedAndNotNull(contents.inputPorts) && common.isDefinedAndNotNull(contents.outputPorts)) {
return contents.inputPorts.concat(contents.outputPorts);
} else if (nf.Common.isDefinedAndNotNull(contents.inputPorts)) {
} else if (common.isDefinedAndNotNull(contents.inputPorts)) {
return contents.inputPorts;
} else if (nf.Common.isDefinedAndNotNull(contents.outputPorts)) {
} else if (common.isDefinedAndNotNull(contents.outputPorts)) {
return contents.outputPorts;
} else {
return [];
@ -32,31 +90,121 @@ nf.Graph = (function () {
};
var combinePortStatus = function (status) {
if (nf.Common.isDefinedAndNotNull(status.inputPortStatusSnapshots) && nf.Common.isDefinedAndNotNull(status.outputPortStatusSnapshots)) {
if (common.isDefinedAndNotNull(status.inputPortStatusSnapshots) && common.isDefinedAndNotNull(status.outputPortStatusSnapshots)) {
return status.inputPortStatusSnapshots.concat(status.outputPortStatusSnapshots);
} else if (nf.Common.isDefinedAndNotNull(status.inputPortStatusSnapshots)) {
} else if (common.isDefinedAndNotNull(status.inputPortStatusSnapshots)) {
return status.inputPortStatusSnapshots;
} else if (nf.Common.isDefinedAndNotNull(status.outputPortStatusSnapshots)) {
} else if (common.isDefinedAndNotNull(status.outputPortStatusSnapshots)) {
return status.outputPortStatusSnapshots;
} else {
return [];
}
};
return {
init: function () {
/**
* Updates component visibility based on their proximity to the screen's viewport.
*/
var updateComponentVisibility = function () {
var canvasContainer = $('#canvas-container');
var translate = canvasUtils.translateCanvasView();
var scale = canvasUtils.scaleCanvasView();
// scale the translation
translate = [translate[0] / scale, translate[1] / scale];
// get the normalized screen width and height
var screenWidth = canvasContainer.width() / scale;
var screenHeight = canvasContainer.height() / scale;
// calculate the screen bounds one screens worth in each direction
var screenLeft = -translate[0] - screenWidth;
var screenTop = -translate[1] - screenHeight;
var screenRight = screenLeft + (screenWidth * 3);
var screenBottom = screenTop + (screenHeight * 3);
// detects whether a component is visible and should be rendered
var isComponentVisible = function (d) {
if (!canvasUtils.shouldRenderPerScale()) {
return false;
}
var left = d.position.x;
var top = d.position.y;
var right = left + d.dimensions.width;
var bottom = top + d.dimensions.height;
// determine if the component is now visible
return screenLeft < right && screenRight > left && screenTop < bottom && screenBottom > top;
};
// detects whether a connection is visible and should be rendered
var isConnectionVisible = function (d) {
if (!canvasUtils.shouldRenderPerScale()) {
return false;
}
var x, y;
if (d.bends.length > 0) {
var i = Math.min(Math.max(0, d.labelIndex), d.bends.length - 1);
x = d.bends[i].x;
y = d.bends[i].y;
} else {
x = (d.start.x + d.end.x) / 2;
y = (d.start.y + d.end.y) / 2;
}
return screenLeft < x && screenRight > x && screenTop < y && screenBottom > y;
};
// marks the specific component as visible and determines if its entering or leaving visibility
var updateVisibility = function (d, isVisible) {
var selection = d3.select('#id-' + d.id);
var visible = isVisible(d);
var wasVisible = selection.classed('visible');
// mark the selection as appropriate
selection.classed('visible', visible)
.classed('entering', function () {
return visible && !wasVisible;
}).classed('leaving', function () {
return !visible && wasVisible;
});
};
// get the all components
var graph = nfGraph.get();
// update the visibility for each component
$.each(graph.processors, function (_, d) {
updateVisibility(d, isComponentVisible);
});
$.each(graph.ports, function (_, d) {
updateVisibility(d, isComponentVisible);
});
$.each(graph.processGroups, function (_, d) {
updateVisibility(d, isComponentVisible);
});
$.each(graph.remoteProcessGroups, function (_, d) {
updateVisibility(d, isComponentVisible);
});
$.each(graph.connections, function (_, d) {
updateVisibility(d, isConnectionVisible);
});
};
var nfGraph = {
init: function () {
// initialize the object responsible for each type of component
nf.Label.init();
nf.Funnel.init();
nf.Port.init();
nf.RemoteProcessGroup.init();
nf.ProcessGroup.init();
nf.Processor.init();
nf.Connection.init();
nfLabel.init(connectable, draggable, selectable, contextMenu);
nfFunnel.init(connectable, draggable, selectable, contextMenu);
nfPort.init(connectable, draggable, selectable, contextMenu);
nfRemoteProcessGroup.init(connectable, draggable, selectable, contextMenu);
nfProcessGroup.init(connectable, draggable, selectable, contextMenu);
nfProcessor.init(connectable, draggable, selectable, contextMenu);
nfConnection.init(selectable, contextMenu);
// load the graph
return nf.CanvasUtils.enterGroup(nf.Canvas.getGroupId());
return nfProcessGroup.enterGroup(canvasUtils.getGroupId());
},
/**
@ -67,65 +215,65 @@ nf.Graph = (function () {
*/
add: function (processGroupContents, options) {
var selectAll = false;
if (nf.Common.isDefinedAndNotNull(options)) {
selectAll = nf.Common.isDefinedAndNotNull(options.selectAll) ? options.selectAll : selectAll;
if (common.isDefinedAndNotNull(options)) {
selectAll = common.isDefinedAndNotNull(options.selectAll) ? options.selectAll : selectAll;
}
// if we are going to select the new components, deselect the previous selection
if (selectAll) {
nf.CanvasUtils.getSelection().classed('selected', false);
canvasUtils.getSelection().classed('selected', false);
}
// merge the ports together
var ports = combinePorts(processGroupContents);
// add the components to the responsible object
nf.Label.add(processGroupContents.labels, options);
nf.Funnel.add(processGroupContents.funnels, options);
nf.RemoteProcessGroup.add(processGroupContents.remoteProcessGroups, options);
nf.Port.add(ports, options);
nf.ProcessGroup.add(processGroupContents.processGroups, options);
nf.Processor.add(processGroupContents.processors, options);
nf.Connection.add(processGroupContents.connections, options);
nfLabel.add(processGroupContents.labels, options);
nfFunnel.add(processGroupContents.funnels, options);
nfRemoteProcessGroup.add(processGroupContents.remoteProcessGroups, options);
nfPort.add(ports, options);
nfProcessGroup.add(processGroupContents.processGroups, options);
nfProcessor.add(processGroupContents.processors, options);
nfConnection.add(processGroupContents.connections, options);
// inform Angular app if the selection is changing
if (selectAll) {
nf.ng.Bridge.digest();
angularBridge.digest();
}
},
/**
* Populates the graph with the resources defined in the response.
*
*
* @argument {object} processGroupContents The contents of the process group
* @argument {object} options Configuration options
*/
set: function (processGroupContents, options) {
var selectAll = false;
if (nf.Common.isDefinedAndNotNull(options)) {
selectAll = nf.Common.isDefinedAndNotNull(options.selectAll) ? options.selectAll : selectAll;
if (common.isDefinedAndNotNull(options)) {
selectAll = common.isDefinedAndNotNull(options.selectAll) ? options.selectAll : selectAll;
}
// if we are going to select the new components, deselect the previous selection
if (selectAll) {
nf.CanvasUtils.getSelection().classed('selected', false);
canvasUtils.getSelection().classed('selected', false);
}
// merge the ports together
var ports = combinePorts(processGroupContents);
// add the components to the responsible object
nf.Label.set(processGroupContents.labels, options);
nf.Funnel.set(processGroupContents.funnels, options);
nf.RemoteProcessGroup.set(processGroupContents.remoteProcessGroups, options);
nf.Port.set(ports, options);
nf.ProcessGroup.set(processGroupContents.processGroups, options);
nf.Processor.set(processGroupContents.processors, options);
nf.Connection.set(processGroupContents.connections, options);
nfLabel.set(processGroupContents.labels, options);
nfFunnel.set(processGroupContents.funnels, options);
nfRemoteProcessGroup.set(processGroupContents.remoteProcessGroups, options);
nfPort.set(ports, options);
nfProcessGroup.set(processGroupContents.processGroups, options);
nfProcessor.set(processGroupContents.processors, options);
nfConnection.set(processGroupContents.connections, options);
// inform Angular app if the selection is changing
if (selectAll) {
nf.ng.Bridge.digest();
angularBridge.digest();
}
},
@ -140,54 +288,133 @@ nf.Graph = (function () {
* @param timestamp expire caches before
*/
expireCaches: function (timestamp) {
nf.Label.expireCaches(timestamp);
nf.Funnel.expireCaches(timestamp);
nf.RemoteProcessGroup.expireCaches(timestamp);
nf.Port.expireCaches(timestamp);
nf.ProcessGroup.expireCaches(timestamp);
nf.Processor.expireCaches(timestamp);
nf.Connection.expireCaches(timestamp);
nfLabel.expireCaches(timestamp);
nfFunnel.expireCaches(timestamp);
nfRemoteProcessGroup.expireCaches(timestamp);
nfPort.expireCaches(timestamp);
nfProcessGroup.expireCaches(timestamp);
nfProcessor.expireCaches(timestamp);
nfConnection.expireCaches(timestamp);
},
/**
* Gets the components currently on the canvas.
*/
get: function () {
return {
labels: nf.Label.get(),
funnels: nf.Funnel.get(),
ports: nf.Port.get(),
remoteProcessGroups: nf.RemoteProcessGroup.get(),
processGroups: nf.ProcessGroup.get(),
processors: nf.Processor.get(),
connections: nf.Connection.get()
labels: nfLabel.get(),
funnels: nfFunnel.get(),
ports: nfPort.get(),
remoteProcessGroups: nfRemoteProcessGroup.get(),
processGroups: nfProcessGroup.get(),
processors: nfProcessor.get(),
connections: nfConnection.get()
};
},
/**
* Gets a graph component `type`.
*
* @param type The type of component.
*/
getComponentByType: function (type) {
switch (type)
{
case "Label":
return nfLabel;
break;
case "Funnel":
return nfFunnel;
break;
case "Port":
return nfPort;
break;
case "RemoteProcessGroup":
return nfRemoteProcessGroup;
break;
case "ProcessGroup":
return nfProcessGroup;
break;
case "Processor":
return nfProcessor;
break;
case "Connection":
return nfConnection;
break;
default:
throw new Error('Unknown component type.');
break;
}
},
/**
* Clears all the components currently on the canvas. This function does not automatically refresh.
*/
removeAll: function () {
// remove all the components
nf.Label.removeAll();
nf.Funnel.removeAll();
nf.Port.removeAll();
nf.RemoteProcessGroup.removeAll();
nf.ProcessGroup.removeAll();
nf.Processor.removeAll();
nf.Connection.removeAll();
nfLabel.removeAll();
nfFunnel.removeAll();
nfPort.removeAll();
nfRemoteProcessGroup.removeAll();
nfProcessGroup.removeAll();
nfProcessor.removeAll();
nfConnection.removeAll();
},
/**
* Refreshes all components currently on the canvas.
*/
pan: function () {
// refresh the components
nf.Port.pan();
nf.RemoteProcessGroup.pan();
nf.ProcessGroup.pan();
nf.Processor.pan();
nf.Connection.pan();
nfPort.pan();
nfRemoteProcessGroup.pan();
nfProcessGroup.pan();
nfProcessor.pan();
nfConnection.pan();
},
/**
* Updates component visibility based on the current translation/scale.
*/
updateVisibility: function () {
updateComponentVisibility();
nfGraph.pan();
},
/**
* Gets the currently selected components and connections.
*
* @returns {selection} The currently selected components and connections
*/
getSelection: function () {
return d3.selectAll('g.component.selected, g.connection.selected');
},
/**
* Reload the component on the canvas.
*
* @param component The component.
*/
reload: function (component) {
var componentData = component.datum();
if (componentData.permissions.canRead) {
if (canvasUtils.isProcessor(component)) {
nfProcessor.reload(componentData.id);
} else if (canvasUtils.isInputPort(component)) {
nfPort.reload(componentData.id);
} else if (canvasUtils.isRemoteProcessGroup(component)) {
nfRemoteProcessGroup.reload(componentData.id);
}
}
}
};
}());
return nfGraph;
}));

View File

@ -15,9 +15,43 @@
* limitations under the License.
*/
/* global nf */
/* global define, module, require, exports */
nf.LabelConfiguration = (function () {
(function (root, factory) {
if (typeof define === 'function' && define.amd) {
define(['jquery',
'd3',
'nf.ErrorHandler',
'nf.Common',
'nf.Client',
'nf.CanvasUtils',
'nf.ng.Bridge',
'nf.Label'],
function ($, d3, errorHandler, common, client, canvasUtils, angularBridge, label) {
return (nf.LabelConfiguration = factory($, d3, errorHandler, common, client, canvasUtils, angularBridge, label));
});
} else if (typeof exports === 'object' && typeof module === 'object') {
module.exports = (nf.LabelConfiguration =
factory(require('jquery'),
require('d3'),
require('nf.ErrorHandler'),
require('nf.Common'),
require('nf.Client'),
require('nf.CanvasUtils'),
require('nf.ng.Bridge'),
require('nf.Label')));
} else {
nf.LabelConfiguration = factory(root.$,
root.d3,
root.nf.ErrorHandler,
root.nf.Common,
root.nf.Client,
root.nf.CanvasUtils,
root.nf.ng.Bridge,
root.nf.Label);
}
}(this, function ($, d3, errorHandler, common, client, canvasUtils, angularBridge, label) {
'use strict';
var labelId = '';
@ -48,7 +82,7 @@ nf.LabelConfiguration = (function () {
// build the label entity
var labelEntity = {
'revision': nf.Client.getRevision(labelData),
'revision': client.getRevision(labelData),
'component': {
'id': labelId,
'label': labelValue,
@ -67,11 +101,11 @@ nf.LabelConfiguration = (function () {
contentType: 'application/json'
}).done(function (response) {
// get the label out of the response
nf.Label.set(response);
label.set(response);
// inform Angular app values have changed
nf.ng.Bridge.digest();
}).fail(nf.ErrorHandler.handleAjaxError);
angularBridge.digest();
}).fail(errorHandler.handleAjaxError);
// reset and hide the dialog
this.modal('hide');
@ -132,18 +166,18 @@ nf.LabelConfiguration = (function () {
* @argument {selection} selection The selection
*/
showConfiguration: function (selection) {
if (nf.CanvasUtils.isLabel(selection)) {
if (canvasUtils.isLabel(selection)) {
var selectionData = selection.datum();
// get the label value
var labelValue = '';
if (nf.Common.isDefinedAndNotNull(selectionData.component.label)) {
if (common.isDefinedAndNotNull(selectionData.component.label)) {
labelValue = selectionData.component.label;
}
// get the font size
var fontSize = '12px';
if (nf.Common.isDefinedAndNotNull(selectionData.component.style['font-size'])) {
if (common.isDefinedAndNotNull(selectionData.component.style['font-size'])) {
fontSize = selectionData.component.style['font-size'];
}
@ -161,4 +195,4 @@ nf.LabelConfiguration = (function () {
}
}
};
}());
}));

View File

@ -15,9 +15,39 @@
* limitations under the License.
*/
/* global nf, d3 */
/* global define, module, require, exports */
nf.Label = (function () {
(function (root, factory) {
if (typeof define === 'function' && define.amd) {
define(['jquery',
'd3',
'nf.Common',
'nf.Client',
'nf.CanvasUtils'],
function ($, d3, common, client, canvasUtils) {
return (nf.Label = factory($, d3, common, client, canvasUtils));
});
} else if (typeof exports === 'object' && typeof module === 'object') {
module.exports = (nf.Label =
factory(require('jquery'),
require('d3'),
require('nf.Common'),
require('nf.Client'),
require('nf.CanvasUtils')));
} else {
nf.Label = factory(root.$,
root.d3,
root.nf.Common,
root.nf.Client,
root.nf.CanvasUtils);
}
}(this, function ($, d3, common, client, canvasUtils) {
'use strict';
var nfConnectable;
var nfDraggable;
var nfSelectable;
var nfContextMenu;
var dimensions = {
width: 150,
@ -84,7 +114,7 @@ nf.Label = (function () {
'class': 'label component'
})
.classed('selected', selected)
.call(nf.CanvasUtils.position);
.call(canvasUtils.position);
// label border
label.append('rect')
@ -112,7 +142,7 @@ nf.Label = (function () {
});
// always support selecting
label.call(nf.Selectable.activate).call(nf.ContextMenu.activate);
label.call(nfSelectable.activate).call(nfContextMenu.activate);
};
/**
@ -154,10 +184,10 @@ nf.Label = (function () {
return null;
}
var color = nf.Label.defaultColor();
var color = nfLabel.defaultColor();
// use the specified color if appropriate
if (nf.Common.isDefinedAndNotNull(d.component.style['background-color'])) {
if (common.isDefinedAndNotNull(d.component.style['background-color'])) {
color = d.component.style['background-color'];
}
@ -172,7 +202,7 @@ nf.Label = (function () {
var label = d3.select(this);
// update the component behavior as appropriate
nf.CanvasUtils.editable(label);
canvasUtils.editable(label, nfConnectable, nfDraggable);
// update the label
var labelText = label.select('text.label-value');
@ -183,7 +213,7 @@ nf.Label = (function () {
var fontSize = '12px';
// use the specified color if appropriate
if (nf.Common.isDefinedAndNotNull(d.component.style['font-size'])) {
if (common.isDefinedAndNotNull(d.component.style['font-size'])) {
fontSize = d.component.style['font-size'];
}
@ -195,16 +225,16 @@ nf.Label = (function () {
// parse the lines in this label
var lines = [];
if (nf.Common.isDefinedAndNotNull(d.component.label)) {
if (common.isDefinedAndNotNull(d.component.label)) {
lines = d.component.label.split('\n');
} else {
lines.push('');
}
var color = nf.Label.defaultColor();
var color = nfLabel.defaultColor();
// use the specified color if appropriate
if (nf.Common.isDefinedAndNotNull(d.component.style['background-color'])) {
if (common.isDefinedAndNotNull(d.component.style['background-color'])) {
color = d.component.style['background-color'];
}
@ -217,8 +247,8 @@ nf.Label = (function () {
return line;
})
.style('fill', function (d) {
return nf.Common.determineContrastColor(
nf.Common.substringAfterLast(
return common.determineContrastColor(
common.substringAfterLast(
color, '#'));
});
});
@ -254,7 +284,7 @@ nf.Label = (function () {
} else {
// remove the previous label value
labelText.selectAll('tspan').remove();
// remove the label points
labelPoint.remove()
}
@ -270,7 +300,7 @@ nf.Label = (function () {
removed.remove();
};
return {
var nfLabel = {
config: {
width: dimensions.width,
height: dimensions.height
@ -279,7 +309,12 @@ nf.Label = (function () {
/**
* Initializes of the Processor handler.
*/
init: function () {
init: function (connectable, draggable, selectable, contextMenu) {
nfConnectable = connectable;
nfDraggable = draggable;
nfSelectable = selectable;
nfContextMenu = contextMenu;
labelMap = d3.map();
removedCache = d3.map();
addedCache = d3.map();
@ -314,19 +349,19 @@ nf.Label = (function () {
// determine if the width has changed
var different = false;
if (nf.Common.isDefinedAndNotNull(labelData.component.width) || labelData.dimensions.width !== labelData.component.width) {
if (common.isDefinedAndNotNull(labelData.component.width) || labelData.dimensions.width !== labelData.component.width) {
different = true;
}
// determine if the height has changed
if (!different && nf.Common.isDefinedAndNotNull(labelData.component.height) || labelData.dimensions.height !== labelData.component.height) {
if (!different && common.isDefinedAndNotNull(labelData.component.height) || labelData.dimensions.height !== labelData.component.height) {
different = true;
}
// only save the updated bends if necessary
if (different) {
var labelEntity = {
'revision': nf.Client.getRevision(labelData),
'revision': client.getRevision(labelData),
'component': {
'id': labelData.id,
'width': labelData.dimensions.width,
@ -342,17 +377,17 @@ nf.Label = (function () {
contentType: 'application/json'
}).done(function (response) {
// request was successful, update the entry
nf.Label.set(response);
nfLabel.set(response);
}).fail(function () {
// determine the previous width
var width = dimensions.width;
if (nf.Common.isDefinedAndNotNull(labelData.component.width)) {
if (common.isDefinedAndNotNull(labelData.component.width)) {
width = labelData.component.width;
}
// determine the previous height
var height = dimensions.height;
if (nf.Common.isDefinedAndNotNull(labelData.component.height)) {
if (common.isDefinedAndNotNull(labelData.component.height)) {
height = labelData.component.height;
}
@ -380,8 +415,8 @@ nf.Label = (function () {
*/
add: function (labelEntities, options) {
var selectAll = false;
if (nf.Common.isDefinedAndNotNull(options)) {
selectAll = nf.Common.isDefinedAndNotNull(options.selectAll) ? options.selectAll : selectAll;
if (common.isDefinedAndNotNull(options)) {
selectAll = common.isDefinedAndNotNull(options.selectAll) ? options.selectAll : selectAll;
}
// get the current time
@ -401,7 +436,7 @@ nf.Label = (function () {
$.each(labelEntities, function (_, labelEntity) {
add(labelEntity);
});
} else if (nf.Common.isDefinedAndNotNull(labelEntities)) {
} else if (common.isDefinedAndNotNull(labelEntities)) {
add(labelEntities);
}
@ -420,16 +455,16 @@ nf.Label = (function () {
set: function (labelEntities, options) {
var selectAll = false;
var transition = false;
if (nf.Common.isDefinedAndNotNull(options)) {
selectAll = nf.Common.isDefinedAndNotNull(options.selectAll) ? options.selectAll : selectAll;
transition = nf.Common.isDefinedAndNotNull(options.transition) ? options.transition : transition;
if (common.isDefinedAndNotNull(options)) {
selectAll = common.isDefinedAndNotNull(options.selectAll) ? options.selectAll : selectAll;
transition = common.isDefinedAndNotNull(options.transition) ? options.transition : transition;
}
var set = function (proposedLabelEntity) {
var currentLabelEntity = labelMap.get(proposedLabelEntity.id);
// set the processor if appropriate due to revision and wasn't previously removed
if (nf.Client.isNewerRevision(currentLabelEntity, proposedLabelEntity) && !removedCache.has(proposedLabelEntity.id)) {
if (client.isNewerRevision(currentLabelEntity, proposedLabelEntity) && !removedCache.has(proposedLabelEntity.id)) {
labelMap.set(proposedLabelEntity.id, $.extend({
type: 'Label'
}, proposedLabelEntity));
@ -451,14 +486,14 @@ nf.Label = (function () {
$.each(labelEntities, function (_, labelEntity) {
set(labelEntity);
});
} else if (nf.Common.isDefinedAndNotNull(labelEntities)) {
} else if (common.isDefinedAndNotNull(labelEntities)) {
set(labelEntities);
}
// apply the selection and handle all new labels
var selection = select();
selection.enter().call(renderLabels, selectAll);
selection.call(updateLabels).call(nf.CanvasUtils.position, transition);
selection.call(updateLabels).call(canvasUtils.position, transition);
selection.exit().call(removeLabels);
},
@ -469,7 +504,7 @@ nf.Label = (function () {
* @param {string} id
*/
get: function (id) {
if (nf.Common.isUndefined(id)) {
if (common.isUndefined(id)) {
return labelMap.values();
} else {
return labelMap.get(id);
@ -483,7 +518,7 @@ nf.Label = (function () {
* @param {string} id Optional
*/
refresh: function (id) {
if (nf.Common.isDefinedAndNotNull(id)) {
if (common.isDefinedAndNotNull(id)) {
d3.select('#id-' + id).call(updateLabels);
} else {
d3.selectAll('g.label').call(updateLabels);
@ -504,7 +539,7 @@ nf.Label = (function () {
url: labelEntity.uri,
dataType: 'json'
}).done(function (response) {
nf.Label.set(response);
nfLabel.set(response);
});
}
},
@ -515,7 +550,7 @@ nf.Label = (function () {
* @param {string} id The id
*/
position: function (id) {
d3.select('#id-' + id).call(nf.CanvasUtils.position);
d3.select('#id-' + id).call(canvasUtils.position);
},
/**
@ -544,7 +579,7 @@ nf.Label = (function () {
* Removes all label.
*/
removeAll: function () {
nf.Label.remove(labelMap.keys());
nfLabel.remove(labelMap.keys());
},
/**
@ -572,4 +607,6 @@ nf.Label = (function () {
return '#fff7d7';
}
};
}());
return nfLabel;
}));

View File

@ -15,9 +15,46 @@
* limitations under the License.
*/
/* global nf, d3 */
/* global define, module, require, exports */
nf.PolicyManagement = (function () {
(function (root, factory) {
if (typeof define === 'function' && define.amd) {
define(['jquery',
'Slick',
'nf.ErrorHandler',
'nf.Common',
'nf.Client',
'nf.CanvasUtils',
'nf.ng.Bridge',
'nf.Dialog',
'nf.Shell'],
function ($, Slick, errorHandler, common, client, canvasUtils, angularBridge, dialog, shell) {
return (nf.PolicyManagement = factory($, Slick, errorHandler, common, client, canvasUtils, angularBridge, dialog, shell));
});
} else if (typeof exports === 'object' && typeof module === 'object') {
module.exports = (nf.PolicyManagement =
factory(require('jquery'),
require('Slick'),
require('nf.ErrorHandler'),
require('nf.Common'),
require('nf.Client'),
require('nf.CanvasUtils'),
require('nf.ng.Bridge'),
require('nf.Dialog'),
require('nf.Shell')));
} else {
nf.PolicyManagement = factory(root.$,
root.Slick,
root.nf.ErrorHandler,
root.nf.Common,
root.nf.Client,
root.nf.CanvasUtils,
root.nf.ng.Bridge,
root.nf.Dialog,
root.nf.Shell);
}
}(this, function ($, Slick, errorHandler, common, client, canvasUtils, angularBridge, dialog, shell) {
'use strict';
var config = {
urls: {
@ -240,7 +277,7 @@ nf.PolicyManagement = (function () {
// also consider groups already selected in the search users dialog
container.children('li').each(function (_, allowedTenant) {
var tenant = $(allowedTenant).data('tenant');
if (nf.Common.isDefinedAndNotNull(tenant)) {
if (common.isDefinedAndNotNull(tenant)) {
tenants.push(tenant);
}
});
@ -344,16 +381,16 @@ nf.PolicyManagement = (function () {
// policy type listing
$('#policy-type-list').combo({
options: [
nf.Common.getPolicyTypeListing('flow'),
nf.Common.getPolicyTypeListing('controller'),
nf.Common.getPolicyTypeListing('provenance'),
nf.Common.getPolicyTypeListing('restricted-components'),
nf.Common.getPolicyTypeListing('policies'),
nf.Common.getPolicyTypeListing('tenants'),
nf.Common.getPolicyTypeListing('site-to-site'),
nf.Common.getPolicyTypeListing('system'),
nf.Common.getPolicyTypeListing('proxy'),
nf.Common.getPolicyTypeListing('counters')],
common.getPolicyTypeListing('flow'),
common.getPolicyTypeListing('controller'),
common.getPolicyTypeListing('provenance'),
common.getPolicyTypeListing('restricted-components'),
common.getPolicyTypeListing('policies'),
common.getPolicyTypeListing('tenants'),
common.getPolicyTypeListing('site-to-site'),
common.getPolicyTypeListing('system'),
common.getPolicyTypeListing('proxy'),
common.getPolicyTypeListing('counters')],
select: function (option) {
if (initialized) {
// record the policy type
@ -599,8 +636,8 @@ nf.PolicyManagement = (function () {
// defines a function for sorting
var comparer = function (a, b) {
if(a.permissions.canRead && b.permissions.canRead) {
var aString = nf.Common.isDefinedAndNotNull(a.component[sortDetails.columnId]) ? a.component[sortDetails.columnId] : '';
var bString = nf.Common.isDefinedAndNotNull(b.component[sortDetails.columnId]) ? b.component[sortDetails.columnId] : '';
var aString = common.isDefinedAndNotNull(a.component[sortDetails.columnId]) ? a.component[sortDetails.columnId] : '';
var bString = common.isDefinedAndNotNull(b.component[sortDetails.columnId]) ? b.component[sortDetails.columnId] : '';
return aString === bString ? 0 : aString > bString ? 1 : -1;
} else {
if (!a.permissions.canRead && !b.permissions.canRead){
@ -624,9 +661,9 @@ nf.PolicyManagement = (function () {
* @param item
*/
var promptToRemoveUserFromPolicy = function (item) {
nf.Dialog.showYesNoDialog({
dialog.showYesNoDialog({
headerText: 'Update Policy',
dialogContent: 'Remove \'' + nf.Common.escapeHtml(item.component.identity) + '\' from this policy?',
dialogContent: 'Remove \'' + common.escapeHtml(item.component.identity) + '\' from this policy?',
yesHandler: function () {
removeUserFromPolicy(item);
}
@ -659,7 +696,7 @@ nf.PolicyManagement = (function () {
* Prompts for the deletion of the selected policy.
*/
var promptToDeletePolicy = function () {
nf.Dialog.showYesNoDialog({
dialog.showYesNoDialog({
headerText: 'Delete Policy',
dialogContent: 'By deleting this policy, the permissions for this component will revert to the inherited policy if applicable.',
yesText: 'Delete',
@ -676,20 +713,20 @@ nf.PolicyManagement = (function () {
var deletePolicy = function () {
var currentEntity = $('#policy-table').data('policy');
if (nf.Common.isDefinedAndNotNull(currentEntity)) {
if (common.isDefinedAndNotNull(currentEntity)) {
$.ajax({
type: 'DELETE',
url: currentEntity.uri + '?' + $.param(nf.Client.getRevision(currentEntity)),
url: currentEntity.uri + '?' + $.param(client.getRevision(currentEntity)),
dataType: 'json'
}).done(function () {
loadPolicy();
}).fail(function (xhr, status, error) {
nf.ErrorHandler.handleAjaxError(xhr, status, error);
errorHandler.handleAjaxError(xhr, status, error);
resetPolicy();
loadPolicy();
});
} else {
nf.Dialog.showOkDialog({
dialog.showOkDialog({
headerText: 'Delete Policy',
dialogContent: 'No policy selected'
});
@ -765,11 +802,11 @@ nf.PolicyManagement = (function () {
return $('<span>Showing effective policy inherited from the controller.</span>');
} else {
// extract the group id
var processGroupId = nf.Common.substringAfterLast(resource, '/');
var processGroupId = common.substringAfterLast(resource, '/');
var processGroupName = processGroupId;
// attempt to resolve the group name
var breadcrumbs = nf.ng.Bridge.injector.get('breadcrumbsCtrl').getBreadcrumbs();
var breadcrumbs = angularBridge.injector.get('breadcrumbsCtrl').getBreadcrumbs();
$.each(breadcrumbs, function (_, breadcrumbEntity) {
if (breadcrumbEntity.id === processGroupId) {
processGroupName = breadcrumbEntity.label;
@ -787,11 +824,11 @@ nf.PolicyManagement = (function () {
$('#shell-close-button').click();
// load the correct group and unselect everything if necessary
nf.CanvasUtils.enterGroup(processGroupId).done(function () {
nf.CanvasUtils.getSelection().classed('selected', false);
canvasUtils.getComponentByType('ProcessGroup').enterGroup(processGroupId).done(function () {
canvasUtils.getSelection().classed('selected', false);
// inform Angular app that values have changed
nf.ng.Bridge.digest();
angularBridge.digest();
});
})
).append('<span>.</span>');
@ -911,7 +948,7 @@ nf.PolicyManagement = (function () {
resetPolicy();
deferred.reject();
nf.ErrorHandler.handleAjaxError(xhr, status, error);
errorHandler.handleAjaxError(xhr, status, error);
}
});
}).promise();
@ -969,7 +1006,7 @@ nf.PolicyManagement = (function () {
resetPolicy();
deferred.reject();
nf.ErrorHandler.handleAjaxError(xhr, status, error);
errorHandler.handleAjaxError(xhr, status, error);
}
});
}).promise();
@ -1008,7 +1045,7 @@ nf.PolicyManagement = (function () {
}
var entity = {
'revision': nf.Client.getRevision({
'revision': client.getRevision({
'revision': {
'version': 0
}
@ -1037,7 +1074,7 @@ nf.PolicyManagement = (function () {
resetPolicy();
loadPolicy();
}
}).fail(nf.ErrorHandler.handleAjaxError);
}).fail(errorHandler.handleAjaxError);
};
/**
@ -1065,9 +1102,9 @@ nf.PolicyManagement = (function () {
});
var currentEntity = $('#policy-table').data('policy');
if (nf.Common.isDefinedAndNotNull(currentEntity)) {
if (common.isDefinedAndNotNull(currentEntity)) {
var entity = {
'revision': nf.Client.getRevision(currentEntity),
'revision': client.getRevision(currentEntity),
'component': {
'id': currentEntity.id,
'users': users,
@ -1092,16 +1129,16 @@ nf.PolicyManagement = (function () {
loadPolicy();
}
}).fail(function (xhr, status, error) {
nf.ErrorHandler.handleAjaxError(xhr, status, error);
errorHandler.handleAjaxError(xhr, status, error);
resetPolicy();
loadPolicy();
}).always(function () {
nf.Canvas.reload({
canvasUtils.reload({
'transition': true
});
});
} else {
nf.Dialog.showOkDialog({
dialog.showOkDialog({
headerText: 'Update Policy',
dialogContent: 'No policy selected'
});
@ -1113,12 +1150,12 @@ nf.PolicyManagement = (function () {
*/
var showPolicy = function () {
// show the configuration dialog
nf.Shell.showContent('#policy-management').always(function () {
shell.showContent('#policy-management').always(function () {
reset();
});
// adjust the table size
nf.PolicyManagement.resetTableSize();
nfPolicyManagement.resetTableSize();
};
/**
@ -1164,7 +1201,7 @@ nf.PolicyManagement = (function () {
$('div.policy-selected-component-container').hide();
};
return {
var nfPolicyManagement = {
/**
* Initializes the settings page.
*/
@ -1190,7 +1227,7 @@ nf.PolicyManagement = (function () {
var policyTable = $('#policy-table');
if (policyTable.is(':visible')) {
var policyGrid = policyTable.data('gridInstance');
if (nf.Common.isDefinedAndNotNull(policyGrid)) {
if (common.isDefinedAndNotNull(policyGrid)) {
policyGrid.resizeCanvas();
}
}
@ -1344,7 +1381,7 @@ nf.PolicyManagement = (function () {
var resource;
if (selection.empty()) {
$('#selected-policy-component-id').text(nf.Canvas.getGroupId());
$('#selected-policy-component-id').text(canvasUtils.getGroupId());
resource = 'process-groups';
// disable site to site option
@ -1365,19 +1402,19 @@ nf.PolicyManagement = (function () {
var d = selection.datum();
$('#selected-policy-component-id').text(d.id);
if (nf.CanvasUtils.isProcessor(selection)) {
if (canvasUtils.isProcessor(selection)) {
resource = 'processors';
} else if (nf.CanvasUtils.isProcessGroup(selection)) {
} else if (canvasUtils.isProcessGroup(selection)) {
resource = 'process-groups';
} else if (nf.CanvasUtils.isInputPort(selection)) {
} else if (canvasUtils.isInputPort(selection)) {
resource = 'input-ports';
} else if (nf.CanvasUtils.isOutputPort(selection)) {
} else if (canvasUtils.isOutputPort(selection)) {
resource = 'output-ports';
} else if (nf.CanvasUtils.isRemoteProcessGroup(selection)) {
} else if (canvasUtils.isRemoteProcessGroup(selection)) {
resource = 'remote-process-groups';
} else if (nf.CanvasUtils.isLabel(selection)) {
} else if (canvasUtils.isLabel(selection)) {
resource = 'labels';
} else if (nf.CanvasUtils.isFunnel(selection)) {
} else if (canvasUtils.isFunnel(selection)) {
resource = 'funnels';
}
@ -1385,16 +1422,16 @@ nf.PolicyManagement = (function () {
$('#component-policy-target')
.combo('setOptionEnabled', {
value: 'write-receive-data'
}, nf.CanvasUtils.isInputPort(selection) && nf.Canvas.getParentGroupId() === null)
}, canvasUtils.isInputPort(selection) && canvasUtils.getParentGroupId() === null)
.combo('setOptionEnabled', {
value: 'write-send-data'
}, nf.CanvasUtils.isOutputPort(selection) && nf.Canvas.getParentGroupId() === null)
}, canvasUtils.isOutputPort(selection) && canvasUtils.getParentGroupId() === null)
.combo('setOptionEnabled', {
value: 'read-data'
}, !nf.CanvasUtils.isLabel(selection))
}, !canvasUtils.isLabel(selection))
.combo('setOptionEnabled', {
value: 'write-data'
}, !nf.CanvasUtils.isLabel(selection));
}, !canvasUtils.isLabel(selection));
}
// populate the initial resource
@ -1432,4 +1469,6 @@ nf.PolicyManagement = (function () {
return loadPolicy().always(showPolicy);
}
};
}());
return nfPolicyManagement;
}));

View File

@ -15,9 +15,46 @@
* limitations under the License.
*/
/* global nf, d3 */
/* global define, module, require, exports */
nf.PortConfiguration = (function () {
(function (root, factory) {
if (typeof define === 'function' && define.amd) {
define(['jquery',
'd3',
'nf.ErrorHandler',
'nf.Common',
'nf.Dialog',
'nf.Client',
'nf.CanvasUtils',
'nf.ng.Bridge',
'nf.Port'],
function ($, d3, errorHandler, common, dialog, client, canvasUtils, angularBridge, port) {
return (nf.PortConfiguration = factory($, d3, errorHandler, common, dialog, client, canvasUtils, angularBridge, port));
});
} else if (typeof exports === 'object' && typeof module === 'object') {
module.exports = (nf.PortConfiguration =
factory(require('jquery'),
require('d3'),
require('nf.ErrorHandler'),
require('nf.Common'),
require('nf.Dialog'),
require('nf.Client'),
require('nf.CanvasUtils'),
require('nf.ng.Bridge'),
require('nf.Port')));
} else {
nf.PortConfiguration = factory(root.$,
root.d3,
root.nf.ErrorHandler,
root.nf.Common,
root.nf.Dialog,
root.nf.Client,
root.nf.CanvasUtils,
root.nf.ng.Bridge,
root.nf.Port);
}
}(this, function ($, d3, errorHandler, common, dialog, client, canvasUtils, angularBridge, port) {
'use strict';
/**
* Initializes the port dialog.
@ -60,7 +97,7 @@ nf.PortConfiguration = (function () {
// build the port entity
var portEntity = {
'revision': nf.Client.getRevision(portData),
'revision': client.getRevision(portData),
'component': port
};
@ -73,11 +110,11 @@ nf.PortConfiguration = (function () {
contentType: 'application/json'
}).done(function (response) {
// refresh the port component
nf.Port.set(response);
port.set(response);
// inform Angular app values have changed
nf.ng.Bridge.digest();
angularBridge.digest();
// close the details panel
$('#port-configuration').modal('hide');
}).fail(function (xhr, status, error) {
@ -91,10 +128,10 @@ nf.PortConfiguration = (function () {
if (errors.length === 1) {
content = $('<span></span>').text(errors[0]);
} else {
content = nf.Common.formatUnorderedList(errors);
content = common.formatUnorderedList(errors);
}
nf.Dialog.showOkDialog({
dialog.showOkDialog({
dialogContent: content,
headerText: 'Port Configuration'
});
@ -103,7 +140,7 @@ nf.PortConfiguration = (function () {
$('#port-configuration').modal('hide');
// handle the error
nf.ErrorHandler.handleAjaxError(xhr, status, error);
errorHandler.handleAjaxError(xhr, status, error);
}
});
}
@ -147,7 +184,7 @@ nf.PortConfiguration = (function () {
*/
showConfiguration: function (selection) {
// if the specified component is a port, load its properties
if (nf.CanvasUtils.isInputPort(selection) || nf.CanvasUtils.isOutputPort(selection)) {
if (canvasUtils.isInputPort(selection) || canvasUtils.isOutputPort(selection)) {
var selectionData = selection.datum();
// determine if the enabled checkbox is checked or not
@ -157,7 +194,7 @@ nf.PortConfiguration = (function () {
}
// show concurrent tasks for root groups only
if (nf.Canvas.getParentGroupId() === null) {
if (canvasUtils.getParentGroupId() === null) {
$('#port-concurrent-task-container').show();
} else {
$('#port-concurrent-task-container').hide();
@ -175,4 +212,4 @@ nf.PortConfiguration = (function () {
}
}
};
}());
}));

View File

@ -15,9 +15,28 @@
* limitations under the License.
*/
/* global nf */
/* global define, module, require, exports */
nf.PortDetails = (function () {
(function (root, factory) {
if (typeof define === 'function' && define.amd) {
define(['jquery',
'nf.Common',
'nf.CanvasUtils'],
function ($, common, canvasUtils) {
return (nf.PortDetails = factory($, common, canvasUtils));
});
} else if (typeof exports === 'object' && typeof module === 'object') {
module.exports = (nf.PortDetails =
factory(require('jquery'),
require('nf.Common'),
require('nf.CanvasUtils')));
} else {
nf.PortDetails = factory(root.$,
root.nf.Common,
root.nf.CanvasUtils);
}
}(this, function ($, common, canvasUtils) {
'use strict';
return {
init: function () {
@ -42,9 +61,9 @@ nf.PortDetails = (function () {
handler: {
close: function () {
// clear the processor details
nf.Common.clearField('read-only-port-name');
nf.Common.clearField('read-only-port-id');
nf.Common.clearField('read-only-port-comments');
common.clearField('read-only-port-name');
common.clearField('read-only-port-id');
common.clearField('read-only-port-comments');
}
}
});
@ -52,17 +71,17 @@ nf.PortDetails = (function () {
showDetails: function (selection) {
// if the specified component is a processor, load its properties
if (nf.CanvasUtils.isInputPort(selection) || nf.CanvasUtils.isOutputPort(selection)) {
if (canvasUtils.isInputPort(selection) || canvasUtils.isOutputPort(selection)) {
var selectionData = selection.datum();
// populate the port settings
nf.Common.populateField('read-only-port-name', selectionData.component.name);
nf.Common.populateField('read-only-port-id', selectionData.id);
nf.Common.populateField('read-only-port-comments', selectionData.component.comments);
common.populateField('read-only-port-name', selectionData.component.name);
common.populateField('read-only-port-id', selectionData.id);
common.populateField('read-only-port-comments', selectionData.component.comments);
// show the details
$('#port-details').modal('show');
}
}
};
}());
}));

View File

@ -15,9 +15,39 @@
* limitations under the License.
*/
/* global nf, d3 */
/* global define, module, require, exports */
nf.Port = (function () {
(function (root, factory) {
if (typeof define === 'function' && define.amd) {
define(['jquery',
'd3',
'nf.Common',
'nf.Client',
'nf.CanvasUtils'],
function ($, d3, common, client, canvasUtils) {
return (nf.Port = factory($, d3, common, client, canvasUtils));
});
} else if (typeof exports === 'object' && typeof module === 'object') {
module.exports = (nf.Port =
factory(require('jquery'),
require('d3'),
require('nf.Common'),
require('nf.Client'),
require('nf.CanvasUtils')));
} else {
nf.Port = factory(root.$,
root.d3,
root.nf.Common,
root.nf.Client,
root.nf.CanvasUtils);
}
}(this, function ($, d3, common, client, canvasUtils) {
'use strict';
var nfConnectable;
var nfDraggable;
var nfSelectable;
var nfContextMenu;
var PREVIEW_NAME_LENGTH = 15;
var OFFSET_VALUE = 25;
@ -88,7 +118,7 @@ nf.Port = (function () {
}
})
.classed('selected', selected)
.call(nf.CanvasUtils.position);
.call(canvasUtils.position);
// port border
port.append('rect')
@ -121,7 +151,7 @@ nf.Port = (function () {
var offset = 0;
// conditionally render the remote banner
if (nf.Canvas.getParentGroupId() === null) {
if (canvasUtils.getParentGroupId() === null) {
offset = OFFSET_VALUE;
// port remote banner
@ -162,12 +192,12 @@ nf.Port = (function () {
});
// make ports selectable
port.call(nf.Selectable.activate).call(nf.ContextMenu.activate);
port.call(nfSelectable.activate).call(nfContextMenu.activate);
// only activate dragging and connecting if appropriate
port.filter(function (d) {
return d.permissions.canWrite && d.permissions.canRead;
}).call(nf.Draggable.activate).call(nf.Connectable.activate);
}).call(nfDraggable.activate).call(nfConnectable.activate);
};
/**
@ -197,7 +227,7 @@ nf.Port = (function () {
var details = port.select('g.port-details');
// update the component behavior as appropriate
nf.CanvasUtils.editable(port);
canvasUtils.editable(port, nfConnectable, nfDraggable);
// if this process group is visible, render everything
if (port.classed('visible')) {
@ -205,7 +235,7 @@ nf.Port = (function () {
details = port.append('g').attr('class', 'port-details');
var offset = 0;
if (nf.Canvas.getParentGroupId() === null) {
if (canvasUtils.getParentGroupId() === null) {
offset = OFFSET_VALUE;
// port transmitting icon
@ -252,7 +282,7 @@ nf.Port = (function () {
// -------------------
// active thread count
// -------------------
// active thread count
details.append('text')
.attr({
@ -283,9 +313,9 @@ nf.Port = (function () {
// handle based on the number of tokens in the port name
if (words.length === 1) {
// apply ellipsis to the port name as necessary
nf.CanvasUtils.ellipsis(portName, name);
canvasUtils.ellipsis(portName, name);
} else {
nf.CanvasUtils.multilineEllipsis(portName, 2, name);
canvasUtils.multilineEllipsis(portName, 2, name);
}
}).append('title').text(function (d) {
return d.component.name;
@ -341,7 +371,7 @@ nf.Port = (function () {
'fill': function (d) {
var fill = '#728e9b';
if (d.status.aggregateSnapshot.runStatus === 'Invalid') {
if (d.status.aggregateSnapshot.runStatus === 'Invalid') {
fill = '#cf9f5d';
} else if (d.status.aggregateSnapshot.runStatus === 'Running') {
fill = '#7dc7a0';
@ -377,7 +407,7 @@ nf.Port = (function () {
var tip = d3.select('#run-status-tip-' + d.id);
// if there are validation errors generate a tooltip
if (d.permissions.canRead && !nf.Common.isEmpty(d.component.validationErrors)) {
if (d.permissions.canRead && !common.isEmpty(d.component.validationErrors)) {
// create the tip if necessary
if (tip.empty()) {
tip = d3.select('#port-tooltips').append('div')
@ -389,16 +419,16 @@ nf.Port = (function () {
// update the tip
tip.html(function () {
var list = nf.Common.formatUnorderedList(d.component.validationErrors);
if (list === null || list.length === 0) {
return '';
} else {
return $('<div></div>').append(list).html();
}
});
var list = common.formatUnorderedList(d.component.validationErrors);
if (list === null || list.length === 0) {
return '';
} else {
return $('<div></div>').append(list).html();
}
});
// add the tooltip
nf.CanvasUtils.canvasTooltip(tip, d3.select(this));
canvasUtils.canvasTooltip(tip, d3.select(this));
} else {
// remove if necessary
if (!tip.empty()) {
@ -447,7 +477,7 @@ nf.Port = (function () {
// active thread count
// -------------------
nf.CanvasUtils.activeThreadCount(port, d, function (off) {
canvasUtils.activeThreadCount(port, d, function (off) {
offset = off;
});
@ -456,10 +486,10 @@ nf.Port = (function () {
// ---------
port.select('rect.bulletin-background').classed('has-bulletins', function () {
return !nf.Common.isEmpty(d.status.aggregateSnapshot.bulletins);
return !common.isEmpty(d.status.aggregateSnapshot.bulletins);
});
nf.CanvasUtils.bulletins(port, d, function () {
canvasUtils.bulletins(port, d, function () {
return d3.select('#port-tooltips');
}, offset);
});
@ -491,11 +521,16 @@ nf.Port = (function () {
});
};
return {
var nfPort = {
/**
* Initializes of the Port handler.
*/
init: function () {
init: function (connectable, draggable, selectable, contextMenu) {
nfConnectable = connectable;
nfDraggable = draggable;
nfSelectable = selectable;
nfContextMenu = contextMenu;
portMap = d3.map();
removedCache = d3.map();
addedCache = d3.map();
@ -516,13 +551,13 @@ nf.Port = (function () {
*/
add: function (portEntities, options) {
var selectAll = false;
if (nf.Common.isDefinedAndNotNull(options)) {
selectAll = nf.Common.isDefinedAndNotNull(options.selectAll) ? options.selectAll : selectAll;
if (common.isDefinedAndNotNull(options)) {
selectAll = common.isDefinedAndNotNull(options.selectAll) ? options.selectAll : selectAll;
}
// determine the appropriate dimensions for this port
var dimensions = portDimensions;
if (nf.Canvas.getParentGroupId() === null) {
if (canvasUtils.getParentGroupId() === null) {
dimensions = remotePortDimensions;
}
@ -547,7 +582,7 @@ nf.Port = (function () {
$.each(portEntities, function (_, portNode) {
add(portNode);
});
} else if (nf.Common.isDefinedAndNotNull(portEntities)) {
} else if (common.isDefinedAndNotNull(portEntities)) {
add(portEntities);
}
@ -556,7 +591,7 @@ nf.Port = (function () {
selection.enter().call(renderPorts, selectAll);
selection.call(updatePorts);
},
/**
* Populates the graph with the specified ports.
*
@ -566,14 +601,14 @@ nf.Port = (function () {
set: function (portEntities, options) {
var selectAll = false;
var transition = false;
if (nf.Common.isDefinedAndNotNull(options)) {
selectAll = nf.Common.isDefinedAndNotNull(options.selectAll) ? options.selectAll : selectAll;
transition = nf.Common.isDefinedAndNotNull(options.transition) ? options.transition : transition;
if (common.isDefinedAndNotNull(options)) {
selectAll = common.isDefinedAndNotNull(options.selectAll) ? options.selectAll : selectAll;
transition = common.isDefinedAndNotNull(options.transition) ? options.transition : transition;
}
// determine the appropriate dimensions for this port
var dimensions = portDimensions;
if (nf.Canvas.getParentGroupId() === null) {
if (canvasUtils.getParentGroupId() === null) {
dimensions = remotePortDimensions;
}
@ -581,7 +616,7 @@ nf.Port = (function () {
var currentPortEntity = portMap.get(proposedPortEntity.id);
// set the port if appropriate due to revision and wasn't previously removed
if (nf.Client.isNewerRevision(currentPortEntity, proposedPortEntity) && !removedCache.has(proposedPortEntity.id)) {
if (client.isNewerRevision(currentPortEntity, proposedPortEntity) && !removedCache.has(proposedPortEntity.id)) {
// add the port
portMap.set(proposedPortEntity.id, $.extend({
type: 'Port',
@ -609,14 +644,14 @@ nf.Port = (function () {
$.each(portEntities, function (_, portNode) {
set(portNode);
});
} else if (nf.Common.isDefinedAndNotNull(portEntities)) {
} else if (common.isDefinedAndNotNull(portEntities)) {
set(portEntities);
}
// apply the selection and handle all new ports
var selection = select();
selection.enter().call(renderPorts, selectAll);
selection.call(updatePorts).call(nf.CanvasUtils.position, transition);
selection.call(updatePorts).call(canvasUtils.position, transition);
selection.exit().call(removePorts);
},
@ -627,7 +662,7 @@ nf.Port = (function () {
* @param {string} id
*/
get: function (id) {
if (nf.Common.isUndefined(id)) {
if (common.isUndefined(id)) {
return portMap.values();
} else {
return portMap.get(id);
@ -641,7 +676,7 @@ nf.Port = (function () {
* @param {string} id Optional
*/
refresh: function (id) {
if (nf.Common.isDefinedAndNotNull(id)) {
if (common.isDefinedAndNotNull(id)) {
d3.select('#id-' + id).call(updatePorts);
} else {
d3.selectAll('g.input-port, g.output-port').call(updatePorts);
@ -669,7 +704,7 @@ nf.Port = (function () {
url: portEntity.uri,
dataType: 'json'
}).done(function (response) {
nf.Port.set(response);
nfPort.set(response);
});
}
},
@ -680,7 +715,7 @@ nf.Port = (function () {
* @param {string} id The id
*/
position: function (id) {
d3.select('#id-' + id).call(nf.CanvasUtils.position);
d3.select('#id-' + id).call(canvasUtils.position);
},
/**
@ -709,7 +744,7 @@ nf.Port = (function () {
* Removes all ports..
*/
removeAll: function () {
nf.Port.remove(portMap.keys());
nfPort.remove(portMap.keys());
},
/**
@ -730,4 +765,6 @@ nf.Port = (function () {
expire(removedCache);
}
};
}());
return nfPort;
}));

View File

@ -15,9 +15,48 @@
* limitations under the License.
*/
/* global nf, d3 */
/* global define, module, require, exports */
nf.ProcessGroupConfiguration = (function () {
(function (root, factory) {
if (typeof define === 'function' && define.amd) {
define(['jquery',
'd3',
'nf.ErrorHandler',
'nf.Common',
'nf.Dialog',
'nf.Client',
'nf.ProcessGroup',
'nf.Shell',
'nf.CanvasUtils'],
function ($, d3, errorHandler, common, dialog, client, processGroup, shell, canvasUtils) {
return (nf.ProcessGroupConfiguration = factory($, d3, errorHandler, common, dialog, client, processGroup, shell, canvasUtils));
});
} else if (typeof exports === 'object' && typeof module === 'object') {
module.exports = (nf.ProcessGroupConfiguration =
factory(require('jquery'),
require('d3'),
require('nf.ErrorHandler'),
require('nf.Common'),
require('nf.Dialog'),
require('nf.Client'),
require('nf.ProcessGroup'),
require('nf.Shell'),
require('nf.CanvasUtils')));
} else {
nf.ProcessGroupConfiguration = factory(root.$,
root.d3,
root.nf.ErrorHandler,
root.nf.Common,
root.nf.Dialog,
root.nf.Client,
root.nf.ProcessGroup,
root.nf.Shell,
root.nf.CanvasUtils);
}
}(this, function ($, d3, errorHandler, common, dialog, client, processGroup, shell, canvasUtils) {
'use strict';
var nfControllerServices;
var config = {
urls: {
@ -49,7 +88,7 @@ nf.ProcessGroupConfiguration = (function () {
var saveConfiguration = function (version, groupId) {
// build the entity
var entity = {
'revision': nf.Client.getRevision({
'revision': client.getRevision({
'revision': {
'version': version
}
@ -70,12 +109,12 @@ nf.ProcessGroupConfiguration = (function () {
contentType: 'application/json'
}).done(function (response) {
// refresh the process group if necessary
if (response.permissions.canRead && response.component.parentGroupId === nf.Canvas.getGroupId()) {
nf.ProcessGroup.set(response);
if (response.permissions.canRead && response.component.parentGroupId === canvasUtils.getGroupId()) {
processGroup.set(response);
}
// show the result dialog
nf.Dialog.showOkDialog({
dialog.showOkDialog({
headerText: 'Process Group Configuration',
dialogContent: 'Process group configuration successfully saved.'
});
@ -85,13 +124,13 @@ nf.ProcessGroupConfiguration = (function () {
saveConfiguration(response.revision.version, groupId);
});
nf.Canvas.reload();
}).fail(nf.ErrorHandler.handleAjaxError);
canvasUtils.reload();
}).fail(errorHandler.handleAjaxError);
};
/**
* Loads the configuration for the specified process group.
*
*
* @param {string} groupId
*/
var loadConfiguration = function (groupId) {
@ -149,15 +188,15 @@ nf.ProcessGroupConfiguration = (function () {
deferred.resolve();
}).fail(function (xhr, status, error) {
if (xhr.status === 403) {
if (groupId === nf.Canvas.getGroupId()) {
if (groupId === canvasUtils.getGroupId()) {
$('#process-group-configuration').data('process-group', {
'permissions': {
canRead: false,
canWrite: nf.Canvas.canWrite()
canWrite: canvasUtils.canWrite()
}
});
} else {
$('#process-group-configuration').data('process-group', nf.ProcessGroup.get(groupId));
$('#process-group-configuration').data('process-group', processGroup.get(groupId));
}
setUnauthorizedText();
@ -171,15 +210,15 @@ nf.ProcessGroupConfiguration = (function () {
// load the controller services
var controllerServicesUri = config.urls.api + '/flow/process-groups/' + encodeURIComponent(groupId) + '/controller-services';
var controllerServices = nf.ControllerServices.loadControllerServices(controllerServicesUri, getControllerServicesTable());
var controllerServices = nfControllerServices.loadControllerServices(controllerServicesUri, getControllerServicesTable());
// wait for everything to complete
return $.when(processGroup, controllerServices).done(function (processGroupResult, controllerServicesResult) {
var controllerServicesResponse = controllerServicesResult[0];
// update the current time
$('#process-group-configuration-last-refreshed').text(controllerServicesResponse.currentTime);
}).fail(nf.ErrorHandler.handleAjaxError);
}).fail(errorHandler.handleAjaxError);
};
/**
@ -187,7 +226,7 @@ nf.ProcessGroupConfiguration = (function () {
*/
var showConfiguration = function () {
// show the configuration dialog
nf.Shell.showContent('#process-group-configuration').done(function () {
shell.showContent('#process-group-configuration').done(function () {
reset();
});
@ -195,7 +234,7 @@ nf.ProcessGroupConfiguration = (function () {
$('#process-group-configuration-tabs').find('.selected-tab').click();
// adjust the table size
nf.ProcessGroupConfiguration.resetTableSize();
nfProcessGroupConfiguration.resetTableSize();
};
/**
@ -211,12 +250,17 @@ nf.ProcessGroupConfiguration = (function () {
$('#process-group-name').val('');
$('#process-group-comments').val('');
};
return {
var nfProcessGroupConfiguration = {
/**
* Initializes the settings page.
* Initialize the process group configuration.
*
* @param controllerServices The reference to the controllerServices controller.
*/
init: function () {
init: function (controllerServices) {
nfControllerServices = controllerServices;
// initialize the process group configuration tabs
$('#process-group-configuration-tabs').tabbs({
tabStyle: 'tab',
@ -231,7 +275,7 @@ nf.ProcessGroupConfiguration = (function () {
}],
select: function () {
var processGroup = $('#process-group-configuration').data('process-group');
var canWrite = nf.Common.isDefinedAndNotNull(processGroup) ? processGroup.permissions.canWrite : false;
var canWrite = common.isDefinedAndNotNull(processGroup) ? processGroup.permissions.canWrite : false;
var tab = $(this).text();
if (tab === 'General') {
@ -254,21 +298,21 @@ nf.ProcessGroupConfiguration = (function () {
}
// resize the table
nf.ProcessGroupConfiguration.resetTableSize();
nfProcessGroupConfiguration.resetTableSize();
}
}
});
// initialize each tab
initGeneral();
nf.ControllerServices.init(getControllerServicesTable());
nfControllerServices.init(getControllerServicesTable());
},
/**
* Update the size of the grid based on its container's current size.
*/
resetTableSize: function () {
nf.ControllerServices.resetTableSize(getControllerServicesTable());
nfControllerServices.resetTableSize(getControllerServicesTable());
},
/**
@ -285,7 +329,7 @@ nf.ProcessGroupConfiguration = (function () {
var selectedTab = $('#process-group-configuration-tabs li.selected-tab').text();
if (selectedTab === 'Controller Services') {
var controllerServicesUri = config.urls.api + '/process-groups/' + encodeURIComponent(groupId) + '/controller-services';
nf.ControllerServices.promptNewControllerService(controllerServicesUri, getControllerServicesTable());
nfControllerServices.promptNewControllerService(controllerServicesUri, getControllerServicesTable());
}
});
@ -320,4 +364,6 @@ nf.ProcessGroupConfiguration = (function () {
$('#process-group-configuration-tabs').find('li:eq(1)').click();
}
};
}());
return nfProcessGroupConfiguration;
}));

View File

@ -15,9 +15,45 @@
* limitations under the License.
*/
/* global nf, d3 */
/* global d3, define, module, require, exports */
nf.ProcessGroup = (function () {
(function (root, factory) {
if (typeof define === 'function' && define.amd) {
define(['jquery',
'd3',
'nf.Connection',
'nf.Common',
'nf.Client',
'nf.CanvasUtils',
'nf.Dialog'],
function ($, d3, connection, common, client, canvasUtils, dialog) {
return (nf.ProcessGroup = factory($, d3, connection, common, client, canvasUtils, dialog));
});
} else if (typeof exports === 'object' && typeof module === 'object') {
module.exports = (nf.ProcessGroup =
factory(require('jquery'),
require('d3'),
require('nf.Connection'),
require('nf.Common'),
require('nf.Client'),
require('nf.CanvasUtils'),
require('nf.Dialog')));
} else {
nf.ProcessGroup = factory(root.$,
root.d3,
root.nf.Connection,
root.nf.Common,
root.nf.Client,
root.nf.CanvasUtils,
root.nf.Dialog);
}
}(this, function ($, d3, connection, common, client, canvasUtils, dialog) {
'use strict';
var nfConnectable;
var nfDraggable;
var nfSelectable;
var nfContextMenu;
var PREVIEW_NAME_LENGTH = 30;
@ -55,7 +91,7 @@ nf.ProcessGroup = (function () {
* @param {object} d
*/
var getProcessGroupComments = function (d) {
if (nf.Common.isBlank(d.component.comments)) {
if (common.isBlank(d.component.comments)) {
return 'No comments specified';
} else {
return d.component.comments;
@ -90,7 +126,7 @@ nf.ProcessGroup = (function () {
'class': 'process-group component'
})
.classed('selected', selected)
.call(nf.CanvasUtils.position);
.call(canvasUtils.position);
// ----
// body
@ -146,15 +182,15 @@ nf.ProcessGroup = (function () {
// always support selecting and navigation
processGroup.on('dblclick', function (d) {
// enter this group on double click
nf.CanvasUtils.enterGroup(d.id);
})
.call(nf.Selectable.activate).call(nf.ContextMenu.activate);
// enter this group on double click
nfProcessGroup.enterGroup(d.id);
})
.call(nfSelectable.activate).call(nfContextMenu.activate);
// only support dragging, connection, and drag and drop if appropriate
processGroup.filter(function (d) {
return d.permissions.canWrite && d.permissions.canRead;
})
return d.permissions.canWrite && d.permissions.canRead;
})
.on('mouseover.drop', function (d) {
// Using mouseover/out to workaround chrome issue #122746
@ -167,7 +203,7 @@ nf.ProcessGroup = (function () {
var drag = d3.select('rect.drag-selection');
if (!drag.empty()) {
// filter the current selection by this group
var selection = nf.CanvasUtils.getSelection().filter(function (d) {
var selection = canvasUtils.getSelection().filter(function (d) {
return targetData.id === d.id;
});
@ -176,7 +212,7 @@ nf.ProcessGroup = (function () {
// mark that we are hovering over a drop area if appropriate
target.classed('drop', function () {
// get the current selection and ensure its disconnected
return nf.CanvasUtils.isDisconnected(nf.CanvasUtils.getSelection());
return connection.isDisconnected(canvasUtils.getSelection());
});
}
}
@ -186,8 +222,8 @@ nf.ProcessGroup = (function () {
// mark that we are no longer hovering over a drop area unconditionally
d3.select(this).classed('drop', false);
})
.call(nf.Draggable.activate)
.call(nf.Connectable.activate);
.call(nfDraggable.activate)
.call(nfConnectable.activate);
};
// attempt of space between component count and icon for process group contents
@ -221,7 +257,7 @@ nf.ProcessGroup = (function () {
var details = processGroup.select('g.process-group-details');
// update the component behavior as appropriate
nf.CanvasUtils.editable(processGroup);
canvasUtils.editable(processGroup, nfConnectable, nfDraggable);
// if this processor is visible, render everything
if (processGroup.classed('visible')) {
@ -812,9 +848,9 @@ nf.ProcessGroup = (function () {
processGroupComments.text(null).selectAll('tspan, title').remove();
// apply ellipsis to the port name as necessary
nf.CanvasUtils.ellipsis(processGroupComments, getProcessGroupComments(d));
canvasUtils.ellipsis(processGroupComments, getProcessGroupComments(d));
}).classed('unset', function (d) {
return nf.Common.isBlank(d.component.comments);
return common.isBlank(d.component.comments);
}).append('title').text(function (d) {
return getProcessGroupComments(d);
});
@ -828,7 +864,7 @@ nf.ProcessGroup = (function () {
processGroupName.text(null).selectAll('title').remove();
// apply ellipsis to the process group name as necessary
nf.CanvasUtils.ellipsis(processGroupName, d.component.name);
canvasUtils.ellipsis(processGroupName, d.component.name);
}).append('title').text(function (d) {
return d.component.name;
});
@ -883,25 +919,25 @@ nf.ProcessGroup = (function () {
// queued count value
updated.select('text.process-group-queued tspan.count')
.text(function (d) {
return nf.Common.substringBeforeFirst(d.status.aggregateSnapshot.queued, ' ');
return common.substringBeforeFirst(d.status.aggregateSnapshot.queued, ' ');
});
// queued size value
updated.select('text.process-group-queued tspan.size')
.text(function (d) {
return ' ' + nf.Common.substringAfterFirst(d.status.aggregateSnapshot.queued, ' ');
return ' ' + common.substringAfterFirst(d.status.aggregateSnapshot.queued, ' ');
});
// in count value
updated.select('text.process-group-in tspan.count')
.text(function (d) {
return nf.Common.substringBeforeFirst(d.status.aggregateSnapshot.input, ' ');
return common.substringBeforeFirst(d.status.aggregateSnapshot.input, ' ');
});
// in size value
updated.select('text.process-group-in tspan.size')
.text(function (d) {
return ' ' + nf.Common.substringAfterFirst(d.status.aggregateSnapshot.input, ' ');
return ' ' + common.substringAfterFirst(d.status.aggregateSnapshot.input, ' ');
});
// in ports value
@ -925,13 +961,13 @@ nf.ProcessGroup = (function () {
// out count value
updated.select('text.process-group-out tspan.count')
.text(function (d) {
return nf.Common.substringBeforeFirst(d.status.aggregateSnapshot.output, ' ');
return common.substringBeforeFirst(d.status.aggregateSnapshot.output, ' ');
});
// out size value
updated.select('text.process-group-out tspan.size')
.text(function (d) {
return ' ' + nf.Common.substringAfterFirst(d.status.aggregateSnapshot.output, ' ');
return ' ' + common.substringAfterFirst(d.status.aggregateSnapshot.output, ' ');
});
updated.each(function (d) {
@ -942,7 +978,7 @@ nf.ProcessGroup = (function () {
// active thread count
// -------------------
nf.CanvasUtils.activeThreadCount(processGroup, d, function (off) {
canvasUtils.activeThreadCount(processGroup, d, function (off) {
offset = off;
});
@ -951,10 +987,10 @@ nf.ProcessGroup = (function () {
// ---------
processGroup.select('rect.bulletin-background').classed('has-bulletins', function () {
return !nf.Common.isEmpty(d.status.aggregateSnapshot.bulletins);
return !common.isEmpty(d.status.aggregateSnapshot.bulletins);
});
nf.CanvasUtils.bulletins(processGroup, d, function () {
canvasUtils.bulletins(processGroup, d, function () {
return d3.select('#process-group-tooltips');
}, offset);
});
@ -985,11 +1021,16 @@ nf.ProcessGroup = (function () {
});
};
return {
var nfProcessGroup = {
/**
* Initializes of the Process Group handler.
*/
init: function () {
init: function (connectable, draggable, selectable, contextMenu) {
nfConnectable = connectable;
nfDraggable = draggable;
nfSelectable = selectable;
nfContextMenu = contextMenu;
processGroupMap = d3.map();
removedCache = d3.map();
addedCache = d3.map();
@ -1010,8 +1051,8 @@ nf.ProcessGroup = (function () {
*/
add: function (processGroupEntities, options) {
var selectAll = false;
if (nf.Common.isDefinedAndNotNull(options)) {
selectAll = nf.Common.isDefinedAndNotNull(options.selectAll) ? options.selectAll : selectAll;
if (common.isDefinedAndNotNull(options)) {
selectAll = common.isDefinedAndNotNull(options.selectAll) ? options.selectAll : selectAll;
}
// get the current time
@ -1032,7 +1073,7 @@ nf.ProcessGroup = (function () {
$.each(processGroupEntities, function (_, processGroupEntity) {
add(processGroupEntity);
});
} else if (nf.Common.isDefinedAndNotNull(processGroupEntities)) {
} else if (common.isDefinedAndNotNull(processGroupEntities)) {
add(processGroupEntities);
}
@ -1051,16 +1092,16 @@ nf.ProcessGroup = (function () {
set: function (processGroupEntities, options) {
var selectAll = false;
var transition = false;
if (nf.Common.isDefinedAndNotNull(options)) {
selectAll = nf.Common.isDefinedAndNotNull(options.selectAll) ? options.selectAll : selectAll;
transition = nf.Common.isDefinedAndNotNull(options.transition) ? options.transition : transition;
if (common.isDefinedAndNotNull(options)) {
selectAll = common.isDefinedAndNotNull(options.selectAll) ? options.selectAll : selectAll;
transition = common.isDefinedAndNotNull(options.transition) ? options.transition : transition;
}
var set = function (proposedProcessGroupEntity) {
var currentProcessGroupEntity = processGroupMap.get(proposedProcessGroupEntity.id);
// set the process group if appropriate due to revision and wasn't previously removed
if (nf.Client.isNewerRevision(currentProcessGroupEntity, proposedProcessGroupEntity) && !removedCache.has(proposedProcessGroupEntity.id)) {
if (client.isNewerRevision(currentProcessGroupEntity, proposedProcessGroupEntity) && !removedCache.has(proposedProcessGroupEntity.id)) {
processGroupMap.set(proposedProcessGroupEntity.id, $.extend({
type: 'ProcessGroup',
dimensions: dimensions
@ -1084,14 +1125,14 @@ nf.ProcessGroup = (function () {
$.each(processGroupEntities, function (_, processGroupEntity) {
set(processGroupEntity);
});
} else if (nf.Common.isDefinedAndNotNull(processGroupEntities)) {
} else if (common.isDefinedAndNotNull(processGroupEntities)) {
set(processGroupEntities);
}
// apply the selection and handle all new process group
var selection = select();
selection.enter().call(renderProcessGroups, selectAll);
selection.call(updateProcessGroups).call(nf.CanvasUtils.position, transition);
selection.call(updateProcessGroups).call(canvasUtils.position, transition);
selection.exit().call(removeProcessGroups);
},
@ -1102,7 +1143,7 @@ nf.ProcessGroup = (function () {
* @param {string} id
*/
get: function (id) {
if (nf.Common.isUndefined(id)) {
if (common.isUndefined(id)) {
return processGroupMap.values();
} else {
return processGroupMap.get(id);
@ -1116,7 +1157,7 @@ nf.ProcessGroup = (function () {
* @param {string} id Optional
*/
refresh: function (id) {
if (nf.Common.isDefinedAndNotNull(id)) {
if (common.isDefinedAndNotNull(id)) {
d3.select('#id-' + id).call(updateProcessGroups);
} else {
d3.selectAll('g.process-group').call(updateProcessGroups);
@ -1144,7 +1185,7 @@ nf.ProcessGroup = (function () {
url: processGroupEntity.uri,
dataType: 'json'
}).done(function (response) {
nf.ProcessGroup.set(response);
nfProcessGroup.set(response);
});
}
},
@ -1155,7 +1196,7 @@ nf.ProcessGroup = (function () {
* @param {string} id The id
*/
position: function (id) {
d3.select('#id-' + id).call(nf.CanvasUtils.position);
d3.select('#id-' + id).call(canvasUtils.position);
},
/**
@ -1184,7 +1225,7 @@ nf.ProcessGroup = (function () {
* Removes all process groups.
*/
removeAll: function () {
nf.ProcessGroup.remove(processGroupMap.keys());
nfProcessGroup.remove(processGroupMap.keys());
},
/**
@ -1203,6 +1244,44 @@ nf.ProcessGroup = (function () {
expire(addedCache);
expire(removedCache);
},
/**
* Enters the specified group.
*
* @param {string} groupId
*/
enterGroup: function (groupId) {
// hide the context menu
nfContextMenu.hide();
// set the new group id
canvasUtils.setGroupId(groupId);
// reload the graph
return canvasUtils.reload().done(function () {
// attempt to restore the view
var viewRestored = canvasUtils.restoreUserView();
// if the view was not restore attempt to fit
if (viewRestored === false) {
canvasUtils.fitCanvasView();
// refresh the canvas
canvasUtils.refreshCanvasView({
transition: true
});
}
}).fail(function () {
dialog.showOkDialog({
headerText: 'Process Group',
dialogContent: 'Unable to enter the selected group.'
});
});
}
};
}());
return nfProcessGroup;
}));

View File

@ -15,9 +15,55 @@
* limitations under the License.
*/
/* global nf */
/* global define, module, require, exports */
nf.ProcessorConfiguration = (function () {
(function (root, factory) {
if (typeof define === 'function' && define.amd) {
define(['jquery',
'nf.ErrorHandler',
'nf.Common',
'nf.Dialog',
'nf.Client',
'nf.CanvasUtils',
'nf.ng.Bridge',
'nf.Processor',
'nf.ClusterSummary',
'nf.CustomUi',
'nf.UniversalCapture',
'nf.Connection'],
function ($, errorHandler, common, dialog, client, canvasUtils, angularBridge, nfProcessor, clusterSummary, customUi, universalCapture, nfConnection) {
return (nf.ProcessorConfiguration = factory($, errorHandler, common, dialog, client, canvasUtils, angularBridge, nfProcessor, clusterSummary, customUi, universalCapture, nfConnection));
});
} else if (typeof exports === 'object' && typeof module === 'object') {
module.exports = (nf.ProcessorConfiguration =
factory(require('jquery'),
require('nf.ErrorHandler'),
require('nf.Common'),
require('nf.Dialog'),
require('nf.Client'),
require('nf.CanvasUtils'),
require('nf.ng.Bridge'),
require('nf.Processor'),
require('nf.ClusterSummary'),
require('nf.CustomUi'),
require('nf.UniversalCapture'),
require('nf.Connection')));
} else {
nf.ProcessorConfiguration = factory(root.$,
root.nf.ErrorHandler,
root.nf.Common,
root.nf.Dialog,
root.nf.Client,
root.nf.CanvasUtils,
root.nf.ng.Bridge,
root.nf.Processor,
root.nf.ClusterSummary,
root.nf.CustomUi,
root.nf.UniversalCapture,
root.nf.Connection);
}
}(this, function ($, errorHandler, common, dialog, client, canvasUtils, angularBridge, nfProcessor, clusterSummary, customUi, universalCapture, nfConnection) {
'use strict';
// possible values for a processor's run duration (in millis)
var RUN_DURATION_VALUES = [0, 25, 50, 100, 250, 500, 1000, 2000];
@ -87,7 +133,7 @@ nf.ProcessorConfiguration = (function () {
text: 'Primary node',
value: 'PRIMARY',
description: 'Processor will be scheduled to run only on the primary node',
disabled: !nf.ClusterSummary.isClustered() && processor.config['executionNode'] === 'PRIMARY'
disabled: !clusterSummary.isClustered() && processor.config['executionNode'] === 'PRIMARY'
}];
};
@ -106,15 +152,15 @@ nf.ProcessorConfiguration = (function () {
if (errors.length === 1) {
content = $('<span></span>').text(errors[0]);
} else {
content = nf.Common.formatUnorderedList(errors);
content = common.formatUnorderedList(errors);
}
nf.Dialog.showOkDialog({
dialog.showOkDialog({
dialogContent: content,
headerText: 'Processor Configuration'
});
} else {
nf.ErrorHandler.handleAjaxError(xhr, status, error);
errorHandler.handleAjaxError(xhr, status, error);
}
};
@ -137,7 +183,7 @@ nf.ProcessorConfiguration = (function () {
// build the relationship container element
var relationshipContainerElement = $('<div class="processor-relationship-container"></div>').append(relationshipCheckbox).append(relationshipLabel).append(relationshipValue).appendTo('#auto-terminate-relationship-names');
if (!nf.Common.isBlank(relationship.description)) {
if (!common.isBlank(relationship.description)) {
var relationshipDescription = $('<div class="relationship-description"></div>').text(relationship.description);
relationshipContainerElement.append(relationshipDescription);
}
@ -209,7 +255,7 @@ nf.ProcessorConfiguration = (function () {
}
// check the scheduling period
if (nf.Common.isDefinedAndNotNull(schedulingPeriod) && schedulingPeriod.val() !== (details.config['schedulingPeriod'] + '')) {
if (common.isDefinedAndNotNull(schedulingPeriod) && schedulingPeriod.val() !== (details.config['schedulingPeriod'] + '')) {
return true;
}
@ -275,7 +321,7 @@ nf.ProcessorConfiguration = (function () {
}
// get the scheduling period if appropriate
if (nf.Common.isDefinedAndNotNull(schedulingPeriod)) {
if (common.isDefinedAndNotNull(schedulingPeriod)) {
processorConfigDto['schedulingPeriod'] = schedulingPeriod.val();
}
@ -359,22 +405,22 @@ nf.ProcessorConfiguration = (function () {
var config = processor['config'];
// ensure numeric fields are specified correctly
if (nf.Common.isDefinedAndNotNull(config['concurrentlySchedulableTaskCount']) && !$.isNumeric(config['concurrentlySchedulableTaskCount'])) {
if (common.isDefinedAndNotNull(config['concurrentlySchedulableTaskCount']) && !$.isNumeric(config['concurrentlySchedulableTaskCount'])) {
errors.push('Concurrent tasks must be an integer value');
}
if (nf.Common.isDefinedAndNotNull(config['schedulingPeriod']) && nf.Common.isBlank(config['schedulingPeriod'])) {
if (common.isDefinedAndNotNull(config['schedulingPeriod']) && common.isBlank(config['schedulingPeriod'])) {
errors.push('Run schedule must be specified');
}
if (nf.Common.isBlank(config['penaltyDuration'])) {
if (common.isBlank(config['penaltyDuration'])) {
errors.push('Penalty duration must be specified');
}
if (nf.Common.isBlank(config['yieldDuration'])) {
if (common.isBlank(config['yieldDuration'])) {
errors.push('Yield duration must be specified');
}
if (errors.length > 0) {
nf.Dialog.showOkDialog({
dialogContent: nf.Common.formatUnorderedList(errors),
dialog.showOkDialog({
dialogContent: common.formatUnorderedList(errors),
headerText: 'Processor Configuration'
});
return false;
@ -389,11 +435,11 @@ nf.ProcessorConfiguration = (function () {
* @param {object} processor
*/
var reloadProcessorConnections = function (processor) {
var connections = nf.Connection.getComponentConnections(processor.id);
var connections = nfConnection.getComponentConnections(processor.id);
$.each(connections, function (_, connection) {
if (connection.permissions.canRead) {
if (connection.sourceId === processor.id) {
nf.Connection.reload(connection.id);
nfConnection.reload(connection.id);
}
}
});
@ -410,7 +456,7 @@ nf.ProcessorConfiguration = (function () {
// determine if changes have been made
if (isSaveRequired()) {
// see if those changes should be saved
nf.Dialog.showYesNoDialog({
dialog.showYesNoDialog({
headerText: 'Processor Configuration',
dialogContent: 'Save changes before going to this Controller Service?',
noHandler: function () {
@ -443,8 +489,8 @@ nf.ProcessorConfiguration = (function () {
// ensure details are valid as far as we can tell
if (validateDetails(updatedProcessor)) {
// set the revision
var d = nf.Processor.get(processor.id);
updatedProcessor['revision'] = nf.Client.getRevision(d);
var d = nfProcessor.get(processor.id);
updatedProcessor['revision'] = client.getRevision(d);
// update the selected component
return $.ajax({
@ -455,7 +501,7 @@ nf.ProcessorConfiguration = (function () {
contentType: 'application/json'
}).done(function (response) {
// set the new processor state based on the response
nf.Processor.set(response);
nfProcessor.set(response);
}).fail(handleProcessorConfigurationError);
} else {
return $.Deferred(function (deferred) {
@ -489,7 +535,7 @@ nf.ProcessorConfiguration = (function () {
}],
select: function () {
// remove all property detail dialogs
nf.UniversalCapture.removeAllPropertyDetailDialogs();
universalCapture.removeAllPropertyDetailDialogs();
// update the processor property table size in case this is the first time its rendered
if ($(this).text() === 'Properties') {
@ -523,7 +569,7 @@ nf.ProcessorConfiguration = (function () {
$('#processor-configuration').removeData('processorDetails');
},
open: function () {
nf.Common.toggleScrollable($('#' + this.find('.tab-container').attr('id') + '-content').get(0));
common.toggleScrollable($('#' + this.find('.tab-container').attr('id') + '-content').get(0));
}
}
});
@ -566,7 +612,7 @@ nf.ProcessorConfiguration = (function () {
dialogContainer: '#new-processor-property-container',
descriptorDeferred: function (propertyName) {
var processor = $('#processor-configuration').data('processorDetails');
var d = nf.Processor.get(processor.id);
var d = nfProcessor.get(processor.id);
return $.ajax({
type: 'GET',
url: d.uri + '/descriptors',
@ -574,7 +620,7 @@ nf.ProcessorConfiguration = (function () {
propertyName: propertyName
},
dataType: 'json'
}).fail(nf.ErrorHandler.handleAjaxError);
}).fail(errorHandler.handleAjaxError);
},
goToServiceDeferred: goToServiceFromProperty
});
@ -586,7 +632,7 @@ nf.ProcessorConfiguration = (function () {
* @argument {selection} selection The selection
*/
showConfiguration: function (selection) {
if (nf.CanvasUtils.isProcessor(selection)) {
if (canvasUtils.isProcessor(selection)) {
var selectionData = selection.datum();
// get the processor details
@ -595,7 +641,7 @@ nf.ProcessorConfiguration = (function () {
var requests = [];
// reload the processor in case an property descriptors have updated
requests.push(nf.Processor.reload(processor.id));
requests.push(nfProcessor.reload(processor.id));
// get the processor history
requests.push($.ajax({
@ -609,7 +655,7 @@ nf.ProcessorConfiguration = (function () {
// get the updated processor'
var processorResponse = processorResult[0];
processor = processorResponse.component;
// get the processor history
var processorHistory = historyResult[0].componentHistory;
@ -624,7 +670,7 @@ nf.ProcessorConfiguration = (function () {
// populate the processor settings
$('#processor-id').text(processor['id']);
$('#processor-type').text(nf.Common.substringAfterLast(processor['type'], '.'));
$('#processor-type').text(common.substringAfterLast(processor['type'], '.'));
$('#processor-name').val(processor['name']);
$('#processor-enabled').removeClass('checkbox-unchecked checkbox-checked').addClass(processorEnableStyle);
$('#penalty-duration').val(processor.config['penaltyDuration']);
@ -690,7 +736,7 @@ nf.ProcessorConfiguration = (function () {
});
// show the execution node option if we're cluster or we're currently configured to run on the primary node only
if (nf.ClusterSummary.isClustered() || executionNode === 'PRIMARY') {
if (clusterSummary.isClustered() || executionNode === 'PRIMARY') {
$('#execution-node-options').show();
} else {
$('#execution-node-options').hide();
@ -713,7 +759,7 @@ nf.ProcessorConfiguration = (function () {
}
// conditionally allow the user to specify the concurrent tasks
if (nf.Common.isDefinedAndNotNull(concurrentTasks)) {
if (common.isDefinedAndNotNull(concurrentTasks)) {
if (processor.supportsParallelProcessing === true) {
concurrentTasks.prop('disabled', false);
} else {
@ -734,7 +780,7 @@ nf.ProcessorConfiguration = (function () {
}
// load the relationship list
if (!nf.Common.isEmpty(processor.relationships)) {
if (!common.isEmpty(processor.relationships)) {
$.each(processor.relationships, function (i, relationship) {
createRelationshipOption(relationship);
});
@ -763,7 +809,7 @@ nf.ProcessorConfiguration = (function () {
$('#processor-configuration').modal('hide');
// inform Angular app values have changed
nf.ng.Bridge.digest();
angularBridge.digest();
});
}
}
@ -783,7 +829,7 @@ nf.ProcessorConfiguration = (function () {
}];
// determine if we should show the advanced button
if (nf.Common.isDefinedAndNotNull(processor.config.customUiUrl) && processor.config.customUiUrl !== '') {
if (common.isDefinedAndNotNull(processor.config.customUiUrl) && processor.config.customUiUrl !== '') {
buttons.push({
buttonText: 'Advanced',
clazz: 'fa fa-cog button-icon',
@ -799,9 +845,9 @@ nf.ProcessorConfiguration = (function () {
$('#processor-configuration').modal('hide');
// show the custom ui
nf.CustomUi.showCustomUi(processorResponse, processor.config.customUiUrl, true).done(function () {
customUi.showCustomUi(processorResponse, processor.config.customUiUrl, true).done(function () {
// once the custom ui is closed, reload the processor
nf.Processor.reload(processor.id);
nfProcessor.reload(processor.id);
// and reload the processor's outgoing connections
reloadProcessorConnections(processor);
@ -814,7 +860,7 @@ nf.ProcessorConfiguration = (function () {
// determine if changes have been made
if (isSaveRequired()) {
// see if those changes should be saved
nf.Dialog.showYesNoDialog({
dialog.showYesNoDialog({
headerText: 'Save',
dialogContent: 'Save changes before opening the advanced configuration?',
noHandler: openCustomUi,
@ -853,8 +899,8 @@ nf.ProcessorConfiguration = (function () {
if (processorRelationships.is(':visible') && processorRelationships.get(0).scrollHeight > Math.round(processorRelationships.innerHeight())) {
processorRelationships.css('border-width', '1px');
}
}).fail(nf.ErrorHandler.handleAjaxError);
}).fail(errorHandler.handleAjaxError);
}
}
};
}());
}));

View File

@ -15,9 +15,39 @@
* limitations under the License.
*/
/* global nf, d3 */
/* global define, module, require, exports */
nf.Processor = (function () {
(function (root, factory) {
if (typeof define === 'function' && define.amd) {
define(['jquery',
'd3',
'nf.Common',
'nf.Client',
'nf.CanvasUtils'],
function ($, d3, common, client, canvasUtils) {
return (nf.Processor = factory($, d3, common, client, canvasUtils));
});
} else if (typeof exports === 'object' && typeof module === 'object') {
module.exports = (nf.Processor =
factory(require('jquery'),
require('d3'),
require('nf.Common'),
require('nf.Client'),
require('nf.CanvasUtils')));
} else {
nf.Processor = factory(root.$,
root.d3,
root.nf.Common,
root.nf.Client,
root.nf.CanvasUtils);
}
}(this, function ($, d3, common, client, canvasUtils) {
'use strict';
var nfConnectable;
var nfDraggable;
var nfSelectable;
var nfContextMenu;
var PREVIEW_NAME_LENGTH = 25;
@ -73,7 +103,7 @@ nf.Processor = (function () {
'class': 'processor component'
})
.classed('selected', selected)
.call(nf.CanvasUtils.position);
.call(canvasUtils.position);
// processor border
processor.append('rect')
@ -151,7 +181,7 @@ nf.Processor = (function () {
.text('\uf132');
// make processors selectable
processor.call(nf.Selectable.activate).call(nf.ContextMenu.activate);
processor.call(nfSelectable.activate).call(nfContextMenu.activate);
};
/**
@ -181,7 +211,7 @@ nf.Processor = (function () {
var details = processor.select('g.processor-canvas-details');
// update the component behavior as appropriate
nf.CanvasUtils.editable(processor);
canvasUtils.editable(processor, nfConnectable, nfDraggable);
// if this processor is visible, render everything
if (processor.classed('visible')) {
@ -508,7 +538,7 @@ nf.Processor = (function () {
processorName.text(null).selectAll('title').remove();
// apply ellipsis to the processor name as necessary
nf.CanvasUtils.ellipsis(processorName, d.component.name);
canvasUtils.ellipsis(processorName, d.component.name);
}).append('title').text(function (d) {
return d.component.name;
});
@ -522,9 +552,9 @@ nf.Processor = (function () {
processorType.text(null).selectAll('title').remove();
// apply ellipsis to the processor type as necessary
nf.CanvasUtils.ellipsis(processorType, nf.Common.substringAfterLast(d.component.type, '.'));
canvasUtils.ellipsis(processorType, common.substringAfterLast(d.component.type, '.'));
}).append('title').text(function (d) {
return nf.Common.substringAfterLast(d.component.type, '.');
return common.substringAfterLast(d.component.type, '.');
});
} else {
// clear the processor name
@ -576,8 +606,8 @@ nf.Processor = (function () {
processor.select('rect.border').classed('unauthorized', !processorData.permissions.canRead);
// use the specified color if appropriate
if (processorData.permissions.canRead){
if (nf.Common.isDefinedAndNotNull(processorData.component.style['background-color'])) {
if (processorData.permissions.canRead) {
if (common.isDefinedAndNotNull(processorData.component.style['background-color'])) {
var color = processorData.component.style['background-color'];
//update the processor icon container
@ -599,22 +629,22 @@ nf.Processor = (function () {
.style('fill', function (d) {
// get the default color
var color = nf.Processor.defaultIconColor();
var color = nfProcessor.defaultIconColor();
if (!d.permissions.canRead) {
return color;
}
// use the specified color if appropriate
if (nf.Common.isDefinedAndNotNull(d.component.style['background-color'])) {
if (common.isDefinedAndNotNull(d.component.style['background-color'])) {
color = d.component.style['background-color'];
//special case #ffffff implies default fill
if (color.toLowerCase() === '#ffffff') {
color = nf.Processor.defaultIconColor();
color = nfProcessor.defaultIconColor();
} else {
color = nf.Common.determineContrastColor(
nf.Common.substringAfterLast(
color = common.determineContrastColor(
common.substringAfterLast(
color, '#'));
}
}
@ -657,7 +687,7 @@ nf.Processor = (function () {
'fill': function (d) {
var fill = '#728e9b';
if (d.status.aggregateSnapshot.runStatus === 'Invalid') {
if (d.status.aggregateSnapshot.runStatus === 'Invalid') {
fill = '#cf9f5d';
} else if (d.status.aggregateSnapshot.runStatus === 'Running') {
fill = '#7dc7a0';
@ -693,7 +723,7 @@ nf.Processor = (function () {
var tip = d3.select('#run-status-tip-' + d.id);
// if there are validation errors generate a tooltip
if (d.permissions.canRead && !nf.Common.isEmpty(d.component.validationErrors)) {
if (d.permissions.canRead && !common.isEmpty(d.component.validationErrors)) {
// create the tip if necessary
if (tip.empty()) {
tip = d3.select('#processor-tooltips').append('div')
@ -705,16 +735,16 @@ nf.Processor = (function () {
// update the tip
tip.html(function () {
var list = nf.Common.formatUnorderedList(d.component.validationErrors);
if (list === null || list.length === 0) {
return '';
} else {
return $('<div></div>').append(list).html();
}
});
var list = common.formatUnorderedList(d.component.validationErrors);
if (list === null || list.length === 0) {
return '';
} else {
return $('<div></div>').append(list).html();
}
});
// add the tooltip
nf.CanvasUtils.canvasTooltip(tip, d3.select(this));
canvasUtils.canvasTooltip(tip, d3.select(this));
} else {
// remove the tip if necessary
if (!tip.empty()) {
@ -726,13 +756,13 @@ nf.Processor = (function () {
// in count value
updated.select('text.processor-in tspan.count')
.text(function (d) {
return nf.Common.substringBeforeFirst(d.status.aggregateSnapshot.input, ' ');
return common.substringBeforeFirst(d.status.aggregateSnapshot.input, ' ');
});
// in size value
updated.select('text.processor-in tspan.size')
.text(function (d) {
return ' ' + nf.Common.substringAfterFirst(d.status.aggregateSnapshot.input, ' ');
return ' ' + common.substringAfterFirst(d.status.aggregateSnapshot.input, ' ');
});
// read/write value
@ -744,13 +774,13 @@ nf.Processor = (function () {
// out count value
updated.select('text.processor-out tspan.count')
.text(function (d) {
return nf.Common.substringBeforeFirst(d.status.aggregateSnapshot.output, ' ');
return common.substringBeforeFirst(d.status.aggregateSnapshot.output, ' ');
});
// out size value
updated.select('text.processor-out tspan.size')
.text(function (d) {
return ' ' + nf.Common.substringAfterFirst(d.status.aggregateSnapshot.output, ' ');
return ' ' + common.substringAfterFirst(d.status.aggregateSnapshot.output, ' ');
});
// tasks/time value
@ -766,17 +796,17 @@ nf.Processor = (function () {
// active thread count
// -------------------
nf.CanvasUtils.activeThreadCount(processor, d);
canvasUtils.activeThreadCount(processor, d);
// ---------
// bulletins
// ---------
processor.select('rect.bulletin-background').classed('has-bulletins', function () {
return !nf.Common.isEmpty(d.status.aggregateSnapshot.bulletins);
return !common.isEmpty(d.status.aggregateSnapshot.bulletins);
});
nf.CanvasUtils.bulletins(processor, d, function () {
canvasUtils.bulletins(processor, d, function () {
return d3.select('#processor-tooltips');
}, 286);
});
@ -808,11 +838,16 @@ nf.Processor = (function () {
});
};
return {
var nfProcessor = {
/**
* Initializes of the Processor handler.
*/
init: function () {
init: function (connectable, draggable, selectable, contextMenu) {
nfConnectable = connectable;
nfDraggable = draggable;
nfSelectable = selectable;
nfContextMenu = contextMenu;
processorMap = d3.map();
removedCache = d3.map();
addedCache = d3.map();
@ -833,8 +868,8 @@ nf.Processor = (function () {
*/
add: function (processorEntities, options) {
var selectAll = false;
if (nf.Common.isDefinedAndNotNull(options)) {
selectAll = nf.Common.isDefinedAndNotNull(options.selectAll) ? options.selectAll : selectAll;
if (common.isDefinedAndNotNull(options)) {
selectAll = common.isDefinedAndNotNull(options.selectAll) ? options.selectAll : selectAll;
}
// get the current time
@ -855,7 +890,7 @@ nf.Processor = (function () {
$.each(processorEntities, function (_, processorEntity) {
add(processorEntity);
});
} else if (nf.Common.isDefinedAndNotNull(processorEntities)) {
} else if (common.isDefinedAndNotNull(processorEntities)) {
add(processorEntities);
}
@ -874,16 +909,16 @@ nf.Processor = (function () {
set: function (processorEntities, options) {
var selectAll = false;
var transition = false;
if (nf.Common.isDefinedAndNotNull(options)) {
selectAll = nf.Common.isDefinedAndNotNull(options.selectAll) ? options.selectAll : selectAll;
transition = nf.Common.isDefinedAndNotNull(options.transition) ? options.transition : transition;
if (common.isDefinedAndNotNull(options)) {
selectAll = common.isDefinedAndNotNull(options.selectAll) ? options.selectAll : selectAll;
transition = common.isDefinedAndNotNull(options.transition) ? options.transition : transition;
}
var set = function (proposedProcessorEntity) {
var currentProcessorEntity = processorMap.get(proposedProcessorEntity.id);
// set the processor if appropriate due to revision and wasn't previously removed
if (nf.Client.isNewerRevision(currentProcessorEntity, proposedProcessorEntity) && !removedCache.has(proposedProcessorEntity.id)) {
if (client.isNewerRevision(currentProcessorEntity, proposedProcessorEntity) && !removedCache.has(proposedProcessorEntity.id)) {
processorMap.set(proposedProcessorEntity.id, $.extend({
type: 'Processor',
dimensions: dimensions
@ -907,14 +942,14 @@ nf.Processor = (function () {
$.each(processorEntities, function (_, processorEntity) {
set(processorEntity);
});
} else if (nf.Common.isDefinedAndNotNull(processorEntities)) {
} else if (common.isDefinedAndNotNull(processorEntities)) {
set(processorEntities);
}
// apply the selection and handle all new processors
var selection = select();
selection.enter().call(renderProcessors, selectAll);
selection.call(updateProcessors).call(nf.CanvasUtils.position, transition);
selection.call(updateProcessors).call(canvasUtils.position, transition);
selection.exit().call(removeProcessors);
},
@ -925,7 +960,7 @@ nf.Processor = (function () {
* @param {string} id
*/
get: function (id) {
if (nf.Common.isUndefined(id)) {
if (common.isUndefined(id)) {
return processorMap.values();
} else {
return processorMap.get(id);
@ -939,7 +974,7 @@ nf.Processor = (function () {
* @param {string} id Optional
*/
refresh: function (id) {
if (nf.Common.isDefinedAndNotNull(id)) {
if (common.isDefinedAndNotNull(id)) {
d3.select('#id-' + id).call(updateProcessors);
} else {
d3.selectAll('g.processor').call(updateProcessors);
@ -952,7 +987,7 @@ nf.Processor = (function () {
* @param {string} id The id
*/
position: function (id) {
d3.select('#id-' + id).call(nf.CanvasUtils.position);
d3.select('#id-' + id).call(canvasUtils.position);
},
/**
@ -976,7 +1011,7 @@ nf.Processor = (function () {
url: processorEntity.uri,
dataType: 'json'
}).done(function (response) {
nf.Processor.set(response);
nfProcessor.set(response);
});
}
},
@ -1007,7 +1042,7 @@ nf.Processor = (function () {
* Removes all processors.
*/
removeAll: function () {
nf.Processor.remove(processorMap.keys());
nfProcessor.remove(processorMap.keys());
},
/**
@ -1042,4 +1077,6 @@ nf.Processor = (function () {
return '#ad9897';
}
};
}());
return nfProcessor;
}));

View File

@ -15,12 +15,52 @@
* limitations under the License.
*/
/* global nf */
/* global define, module, require, exports */
/**
* Lists FlowFiles from a given connection.
*/
nf.QueueListing = (function () {
(function (root, factory) {
if (typeof define === 'function' && define.amd) {
define(['jquery',
'Slick',
'nf.Common',
'nf.Dialog',
'nf.Shell',
'nf.ng.Bridge',
'nf.ClusterSummary',
'nf.ErrorHandler',
'nf.Storage',
'nf.CanvasUtils'],
function ($, Slick, common, dialog, shell, angularBridge, clusterSummary, errorHandler, storage, canvasUtils) {
return (nf.QueueListing = factory($, Slick, common, dialog, shell, angularBridge, clusterSummary, errorHandler, storage, canvasUtils));
});
} else if (typeof exports === 'object' && typeof module === 'object') {
module.exports = (nf.QueueListing =
factory(require('jquery'),
require('Slick'),
require('nf.Common'),
require('nf.Dialog'),
require('nf.Shell'),
require('nf.ng.Bridge'),
require('nf.ClusterSummary'),
require('nf.ErrorHandler'),
require('nf.Storage'),
require('nf.CanvasUtils')));
} else {
nf.QueueListing = factory(root.$,
root.Slick,
root.nf.Common,
root.nf.Dialog,
root.nf.Shell,
root.nf.ng.Bridge,
root.nf.ClusterSummary,
root.nf.ErrorHandler,
root.nf.Storage,
root.nf.CanvasUtils);
}
}(this, function ($, Slick, common, dialog, shell, angularBridge, clusterSummary, errorHandler, storage, canvasUtils) {
'use strict';
/**
* Configuration object used to hold a number of configuration items.
@ -56,17 +96,17 @@ nf.QueueListing = (function () {
var dataUri = $('#flowfile-uri').text() + '/content';
// perform the request once we've received a token
nf.Common.getAccessToken(config.urls.downloadToken).done(function (downloadToken) {
common.getAccessToken(config.urls.downloadToken).done(function (downloadToken) {
var parameters = {};
// conditionally include the ui extension token
if (!nf.Common.isBlank(downloadToken)) {
if (!common.isBlank(downloadToken)) {
parameters['access_token'] = downloadToken;
}
// conditionally include the cluster node id
var clusterNodeId = $('#flowfile-cluster-node-id').text();
if (!nf.Common.isBlank(clusterNodeId)) {
if (!common.isBlank(clusterNodeId)) {
parameters['clusterNodeId'] = clusterNodeId;
}
@ -77,7 +117,7 @@ nf.QueueListing = (function () {
window.open(dataUri + '?' + $.param(parameters));
}
}).fail(function () {
nf.Dialog.showOkDialog({
dialog.showOkDialog({
headerText: 'Queue Listing',
dialogContent: 'Unable to generate access token for downloading content.'
});
@ -92,7 +132,7 @@ nf.QueueListing = (function () {
// generate tokens as necessary
var getAccessTokens = $.Deferred(function (deferred) {
if (nf.Storage.hasItem('jwt')) {
if (storage.hasItem('jwt')) {
// generate a token for the ui extension and another for the callback
var uiExtensionToken = $.ajax({
type: 'POST',
@ -109,7 +149,7 @@ nf.QueueListing = (function () {
var downloadToken = downloadTokenResult[0];
deferred.resolve(uiExtensionToken, downloadToken);
}).fail(function () {
nf.Dialog.showOkDialog({
dialog.showOkDialog({
headerText: 'Queue Listing',
dialogContent: 'Unable to generate access token for viewing content.'
});
@ -126,12 +166,12 @@ nf.QueueListing = (function () {
// conditionally include the cluster node id
var clusterNodeId = $('#flowfile-cluster-node-id').text();
if (!nf.Common.isBlank(clusterNodeId)) {
if (!common.isBlank(clusterNodeId)) {
dataUriParameters['clusterNodeId'] = clusterNodeId;
}
// include the download token if applicable
if (!nf.Common.isBlank(downloadToken)) {
if (!common.isBlank(downloadToken)) {
dataUriParameters['access_token'] = downloadToken;
}
@ -157,7 +197,7 @@ nf.QueueListing = (function () {
};
// include the download token if applicable
if (!nf.Common.isBlank(uiExtensionToken)) {
if (!common.isBlank(uiExtensionToken)) {
contentViewerParameters['access_token'] = uiExtensionToken;
}
@ -187,7 +227,7 @@ nf.QueueListing = (function () {
// update the progress
var label = $('<div class="progress-label"></div>').text(percentComplete + '%');
(nf.ng.Bridge.injector.get('$compile')($('<md-progress-linear ng-cloak ng-value="' + percentComplete + '" class="md-hue-2" md-mode="determinate" aria-label="Searching Queue"></md-progress-linear>'))(nf.ng.Bridge.rootScope)).appendTo(progressBar);
(angularBridge.injector.get('$compile')($('<md-progress-linear ng-cloak ng-value="' + percentComplete + '" class="md-hue-2" md-mode="determinate" aria-label="Searching Queue"></md-progress-linear>'))(angularBridge.rootScope)).appendTo(progressBar);
progressBar.append(label);
};
@ -223,7 +263,7 @@ nf.QueueListing = (function () {
var reject = cancelled;
// ensure the listing requests are present
if (nf.Common.isDefinedAndNotNull(listingRequest)) {
if (common.isDefinedAndNotNull(listingRequest)) {
$.ajax({
type: 'DELETE',
url: listingRequest.uri,
@ -231,20 +271,20 @@ nf.QueueListing = (function () {
});
// use the listing request from when the listing completed
if (nf.Common.isEmpty(listingRequest.flowFileSummaries)) {
if (common.isEmpty(listingRequest.flowFileSummaries)) {
if (cancelled === false) {
reject = true;
// show the dialog
nf.Dialog.showOkDialog({
dialog.showOkDialog({
headerText: 'Queue Listing',
dialogContent: 'The queue has no FlowFiles.'
});
}
} else {
// update the queue size
$('#total-flowfiles-count').text(nf.Common.formatInteger(listingRequest.queueSize.objectCount));
$('#total-flowfiles-size').text(nf.Common.formatDataSize(listingRequest.queueSize.byteCount));
$('#total-flowfiles-count').text(common.formatInteger(listingRequest.queueSize.objectCount));
$('#total-flowfiles-size').text(common.formatDataSize(listingRequest.queueSize.byteCount));
// update the last updated time
$('#queue-listing-last-refreshed').text(listingRequest.lastUpdated);
@ -316,7 +356,7 @@ nf.QueueListing = (function () {
}).done(function (response) {
listingRequest = response.listingRequest;
processListingRequest(nextDelay);
}).fail(completeListingRequest).fail(nf.ErrorHandler.handleAjaxError);
}).fail(completeListingRequest).fail(errorHandler.handleAjaxError);
};
// issue the request to list the flow files
@ -335,7 +375,7 @@ nf.QueueListing = (function () {
// process the drop request
listingRequest = response.listingRequest;
processListingRequest(1);
}).fail(completeListingRequest).fail(nf.ErrorHandler.handleAjaxError);
}).fail(completeListingRequest).fail(errorHandler.handleAjaxError);
}).promise();
};
@ -349,13 +389,13 @@ nf.QueueListing = (function () {
var formatFlowFileDetail = function (label, value) {
$('<div class="flowfile-detail"></div>').append(
$('<div class="detail-name"></div>').text(label)).append(
$('<div class="detail-value">' + nf.Common.formatValue(value) + '</div>').ellipsis()).append(
$('<div class="detail-value">' + common.formatValue(value) + '</div>').ellipsis()).append(
$('<div class="clear"></div>')).appendTo('#additional-flowfile-details');
};
// formats the content value
var formatContentValue = function (element, value) {
if (nf.Common.isDefinedAndNotNull(value)) {
if (common.isDefinedAndNotNull(value)) {
element.removeClass('unset').text(value);
} else {
element.addClass('unset').text('No value set');
@ -363,7 +403,7 @@ nf.QueueListing = (function () {
};
var params = {};
if (nf.Common.isDefinedAndNotNull(flowFileSummary.clusterNodeId)) {
if (common.isDefinedAndNotNull(flowFileSummary.clusterNodeId)) {
params['clusterNodeId'] = flowFileSummary.clusterNodeId;
}
@ -379,16 +419,16 @@ nf.QueueListing = (function () {
$('#flowfile-uri').text(flowFile.uri);
// show the flowfile details dialog
$('#flowfile-uuid').html(nf.Common.formatValue(flowFile.uuid));
$('#flowfile-filename').html(nf.Common.formatValue(flowFile.filename));
$('#flowfile-queue-position').html(nf.Common.formatValue(flowFile.position));
$('#flowfile-file-size').html(nf.Common.formatValue(flowFile.contentClaimFileSize));
$('#flowfile-queued-duration').text(nf.Common.formatDuration(flowFile.queuedDuration));
$('#flowfile-lineage-duration').text(nf.Common.formatDuration(flowFile.lineageDuration));
$('#flowfile-uuid').html(common.formatValue(flowFile.uuid));
$('#flowfile-filename').html(common.formatValue(flowFile.filename));
$('#flowfile-queue-position').html(common.formatValue(flowFile.position));
$('#flowfile-file-size').html(common.formatValue(flowFile.contentClaimFileSize));
$('#flowfile-queued-duration').text(common.formatDuration(flowFile.queuedDuration));
$('#flowfile-lineage-duration').text(common.formatDuration(flowFile.lineageDuration));
$('#flowfile-penalized').text(flowFile.penalized === true ? 'Yes' : 'No');
// conditionally show the cluster node identifier
if (nf.Common.isDefinedAndNotNull(flowFileSummary.clusterNodeId)) {
if (common.isDefinedAndNotNull(flowFileSummary.clusterNodeId)) {
// save the cluster node id
$('#flowfile-cluster-node-id').text(flowFileSummary.clusterNodeId);
@ -396,7 +436,7 @@ nf.QueueListing = (function () {
formatFlowFileDetail('Node Address', flowFileSummary.clusterNodeAddress);
}
if (nf.Common.isDefinedAndNotNull(flowFile.contentClaimContainer)) {
if (common.isDefinedAndNotNull(flowFile.contentClaimContainer)) {
// content claim
formatContentValue($('#content-container'), flowFile.contentClaimContainer);
formatContentValue($('#content-section'), flowFile.contentClaimSection);
@ -407,9 +447,9 @@ nf.QueueListing = (function () {
// input content file size
var contentSize = $('#content-size');
formatContentValue(contentSize, flowFile.contentClaimFileSize);
if (nf.Common.isDefinedAndNotNull(flowFile.contentClaimFileSize)) {
if (common.isDefinedAndNotNull(flowFile.contentClaimFileSize)) {
// over the default tooltip with the actual byte count
contentSize.attr('title', nf.Common.formatInteger(flowFile.contentClaimFileSizeBytes) + ' bytes');
contentSize.attr('title', common.formatInteger(flowFile.contentClaimFileSizeBytes) + ' bytes');
}
// show the content details
@ -425,21 +465,21 @@ nf.QueueListing = (function () {
$.each(flowFile.attributes, function (attributeName, attributeValue) {
// create the attribute record
var attributeRecord = $('<div class="attribute-detail"></div>')
.append($('<div class="attribute-name">' + nf.Common.formatValue(attributeName) + '</div>').ellipsis())
.append($('<div class="attribute-name">' + common.formatValue(attributeName) + '</div>').ellipsis())
.appendTo(attributesContainer);
// add the current value
attributeRecord
.append($('<div class="attribute-value">' + nf.Common.formatValue(attributeValue) + '</div>').ellipsis())
.append($('<div class="attribute-value">' + common.formatValue(attributeValue) + '</div>').ellipsis())
.append('<div class="clear"></div>');
});
// show the dialog
$('#flowfile-details-dialog').modal('show');
}).fail(nf.ErrorHandler.handleAjaxError);
}).fail(errorHandler.handleAjaxError);
};
return {
var nfQueueListing = {
init: function () {
initializeListingRequestStatusDialog();
@ -456,12 +496,12 @@ nf.QueueListing = (function () {
// function for formatting data sizes
var dataSizeFormatter = function (row, cell, value, columnDef, dataContext) {
return nf.Common.formatDataSize(value);
return common.formatDataSize(value);
};
// function for formatting durations
var durationFormatter = function (row, cell, value, columnDef, dataContext) {
return nf.Common.formatDuration(value);
return common.formatDuration(value);
};
// function for formatting penalization
@ -548,7 +588,7 @@ nf.QueueListing = (function () {
];
// conditionally show the cluster node identifier
if (nf.ClusterSummary.isClustered()) {
if (clusterSummary.isClustered()) {
queueListingColumns.push({
id: 'clusterNodeAddress',
name: 'Node',
@ -559,7 +599,7 @@ nf.QueueListing = (function () {
}
// add an actions column when the user can access provenance
if (nf.Common.canAccessProvenance()) {
if (common.canAccessProvenance()) {
// function for formatting actions
var actionsFormatter = function () {
return '<div title="Provenance" class="pointer icon icon-provenance view-provenance"></div>';
@ -614,7 +654,7 @@ nf.QueueListing = (function () {
$('#shell-close-button').click();
// open the provenance page with the specified component
nf.Shell.showPage('provenance?' + $.param({
shell.showPage('provenance?' + $.param({
flowFileUuid: item.uuid
}));
}
@ -648,7 +688,7 @@ nf.QueueListing = (function () {
$('#content-download').on('click', downloadContent);
// only show if content viewer is configured
if (nf.Common.isContentViewConfigured()) {
if (common.isContentViewConfigured()) {
$('#content-view').show();
$('#content-view').on('click', viewContent);
}
@ -690,7 +730,7 @@ nf.QueueListing = (function () {
$('#additional-flowfile-details').empty();
},
open: function () {
nf.Common.toggleScrollable($('#' + this.find('.tab-container').attr('id') + '-content').get(0));
common.toggleScrollable($('#' + this.find('.tab-container').attr('id') + '-content').get(0));
}
}
});
@ -701,7 +741,7 @@ nf.QueueListing = (function () {
*/
resetTableSize: function () {
var queueListingGrid = $('#queue-listing-table').data('gridInstance');
if (nf.Common.isDefinedAndNotNull(queueListingGrid)) {
if (common.isDefinedAndNotNull(queueListingGrid)) {
queueListingGrid.resizeCanvas();
}
},
@ -717,7 +757,7 @@ nf.QueueListing = (function () {
// update the connection name
var connectionName = '';
if (connection.permissions.canRead) {
connectionName = nf.CanvasUtils.formatConnectionName(connection.component);
connectionName = canvasUtils.formatConnectionName(connection.component);
}
if (connectionName === '') {
connectionName = 'Connection';
@ -725,7 +765,7 @@ nf.QueueListing = (function () {
$('#queue-listing-header-text').text(connectionName);
// show the listing container
nf.Shell.showContent('#queue-listing-container').done(function () {
shell.showContent('#queue-listing-container').done(function () {
$('#queue-listing-table').removeData('connection');
// clear the table
@ -739,15 +779,17 @@ nf.QueueListing = (function () {
// reset stats
$('#displayed-flowfiles, #total-flowfiles-count').text('0');
$('#total-flowfiles-size').text(nf.Common.formatDataSize(0));
$('#total-flowfiles-size').text(common.formatDataSize(0));
});
// adjust the table size
nf.QueueListing.resetTableSize();
nfQueueListing.resetTableSize();
// store the connection for access later
$('#queue-listing-table').data('connection', connection);
});
}
};
}());
return nfQueueListing;
}));

View File

@ -15,9 +15,47 @@
* limitations under the License.
*/
/* global nf, d3 */
/* global define, module, require, exports */
(function (root, factory) {
if (typeof define === 'function' && define.amd) {
define(['jquery',
'd3',
'nf.ErrorHandler',
'nf.Common',
'nf.Dialog',
'nf.Client',
'nf.CanvasUtils',
'nf.ng.Bridge',
'nf.RemoteProcessGroup'],
function ($, d3, errorHandler, common, dialog, client, canvasUtils, angularBridge, nfRemoteProcessGroup) {
return (nf.RemoteProcessGroupConfiguration = factory($, d3, errorHandler, common, dialog, client, canvasUtils, angularBridge, nfRemoteProcessGroup));
});
} else if (typeof exports === 'object' && typeof module === 'object') {
module.exports = (nf.RemoteProcessGroupConfiguration =
factory(require('jquery'),
require('d3'),
require('nf.ErrorHandler'),
require('nf.Common'),
require('nf.Dialog'),
require('nf.Client'),
require('nf.CanvasUtils'),
require('nf.ng.Bridge'),
require('nf.RemoteProcessGroup')));
} else {
nf.RemoteProcessGroupConfiguration = factory(root.$,
root.d3,
root.nf.ErrorHandler,
root.nf.Common,
root.nf.Dialog,
root.nf.Client,
root.nf.CanvasUtils,
root.nf.ng.Bridge,
root.nf.RemoteProcessGroup);
}
}(this, function ($, d3, errorHandler, common, dialog, client, canvasUtils, angularBridge, nfRemoteProcessGroup) {
'use strict';
nf.RemoteProcessGroupConfiguration = (function () {
return {
init: function () {
$('#remote-process-group-configuration').modal({
@ -35,20 +73,20 @@ nf.RemoteProcessGroupConfiguration = (function () {
var remoteProcessGroupId = $('#remote-process-group-id').text();
var remoteProcessGroupData = d3.select('#id-' + remoteProcessGroupId).datum();
// create the remote process group details
var remoteProcessGroupEntity = {
'revision': nf.Client.getRevision(remoteProcessGroupData),
'component': {
id: remoteProcessGroupId,
communicationsTimeout: $('#remote-process-group-timeout').val(),
yieldDuration: $('#remote-process-group-yield-duration').val(),
transportProtocol: $('#remote-process-group-transport-protocol-combo').combo('getSelectedOption').value,
proxyHost: $('#remote-process-group-proxy-host').val(),
proxyPort: $('#remote-process-group-proxy-port').val(),
proxyUser: $('#remote-process-group-proxy-user').val(),
proxyPassword: $('#remote-process-group-proxy-password').val()
}
};
// create the remote process group details
var remoteProcessGroupEntity = {
'revision': client.getRevision(remoteProcessGroupData),
'component': {
id: remoteProcessGroupId,
communicationsTimeout: $('#remote-process-group-timeout').val(),
yieldDuration: $('#remote-process-group-yield-duration').val(),
transportProtocol: $('#remote-process-group-transport-protocol-combo').combo('getSelectedOption').value,
proxyHost: $('#remote-process-group-proxy-host').val(),
proxyPort: $('#remote-process-group-proxy-port').val(),
proxyUser: $('#remote-process-group-proxy-user').val(),
proxyPassword: $('#remote-process-group-proxy-password').val()
}
};
// update the selected component
$.ajax({
@ -59,11 +97,11 @@ nf.RemoteProcessGroupConfiguration = (function () {
contentType: 'application/json'
}).done(function (response) {
// refresh the remote process group component
nf.RemoteProcessGroup.set(response);
nfRemoteProcessGroup.set(response);
// inform Angular app values have changed
nf.ng.Bridge.digest();
angularBridge.digest();
// close the details panel
$('#remote-process-group-configuration').modal('hide');
}).fail(function (xhr, status, error) {
@ -74,15 +112,15 @@ nf.RemoteProcessGroupConfiguration = (function () {
if (errors.length === 1) {
content = $('<span></span>').text(errors[0]);
} else {
content = nf.Common.formatUnorderedList(errors);
content = common.formatUnorderedList(errors);
}
nf.Dialog.showOkDialog({
dialog.showOkDialog({
dialogContent: content,
headerText: 'Remote Process Group Configuration'
});
} else {
nf.ErrorHandler.handleAjaxError(xhr, status, error);
errorHandler.handleAjaxError(xhr, status, error);
}
});
}
@ -122,12 +160,12 @@ nf.RemoteProcessGroupConfiguration = (function () {
// initialize the transport protocol combo
$('#remote-process-group-transport-protocol-combo').combo({
options: [{
text: 'RAW',
value: 'RAW'
}, {
text: 'HTTP',
value: 'HTTP'
}]
text: 'RAW',
value: 'RAW'
}, {
text: 'HTTP',
value: 'HTTP'
}]
});
},
@ -138,7 +176,7 @@ nf.RemoteProcessGroupConfiguration = (function () {
*/
showConfiguration: function (selection) {
// if the specified component is a remote process group, load its properties
if (nf.CanvasUtils.isRemoteProcessGroup(selection)) {
if (canvasUtils.isRemoteProcessGroup(selection)) {
var selectionData = selection.datum();
// populate the port settings
@ -164,4 +202,4 @@ nf.RemoteProcessGroupConfiguration = (function () {
}
}
};
}());
}));

View File

@ -15,9 +15,29 @@
* limitations under the License.
*/
/* global nf */
/* global define, module, require, exports */
(function (root, factory) {
if (typeof define === 'function' && define.amd) {
define(['jquery',
'nf.Common',
'nf.CanvasUtils'],
function ($, common, canvasUtils) {
return (nf.RemoteProcessGroupDetails = factory($, common, canvasUtils));
});
} else if (typeof exports === 'object' && typeof module === 'object') {
module.exports = (nf.RemoteProcessGroupDetails =
factory(require('jquery'),
require('nf.Common'),
require('nf.CanvasUtils')));
} else {
nf.RemoteProcessGroupDetails = factory(root.$,
root.nf.Common,
root.nf.CanvasUtils);
}
}(this, function ($, common, canvasUtils) {
'use strict';
nf.RemoteProcessGroupDetails = (function () {
return {
init: function () {
$('#remote-process-group-details').modal({
@ -39,16 +59,16 @@ nf.RemoteProcessGroupDetails = (function () {
handler: {
close: function () {
// clear the remote process group details
nf.Common.clearField('read-only-remote-process-group-id');
nf.Common.clearField('read-only-remote-process-group-name');
nf.Common.clearField('read-only-remote-process-group-urls');
nf.Common.clearField('read-only-remote-process-group-timeout');
nf.Common.clearField('read-only-remote-process-group-yield-duration');
nf.Common.clearField('read-only-remote-process-group-transport-protocol');
nf.Common.clearField('read-only-remote-process-group-proxy-host');
nf.Common.clearField('read-only-remote-process-group-proxy-port');
nf.Common.clearField('read-only-remote-process-group-proxy-user');
nf.Common.clearField('read-only-remote-process-group-proxy-password');
common.clearField('read-only-remote-process-group-id');
common.clearField('read-only-remote-process-group-name');
common.clearField('read-only-remote-process-group-urls');
common.clearField('read-only-remote-process-group-timeout');
common.clearField('read-only-remote-process-group-yield-duration');
common.clearField('read-only-remote-process-group-transport-protocol');
common.clearField('read-only-remote-process-group-proxy-host');
common.clearField('read-only-remote-process-group-proxy-port');
common.clearField('read-only-remote-process-group-proxy-user');
common.clearField('read-only-remote-process-group-proxy-password');
}
}
});
@ -61,24 +81,24 @@ nf.RemoteProcessGroupDetails = (function () {
*/
showDetails: function (selection) {
// if the specified component is a remote process group, load its properties
if (nf.CanvasUtils.isRemoteProcessGroup(selection)) {
if (canvasUtils.isRemoteProcessGroup(selection)) {
var selectionData = selection.datum();
// populate the port settings
nf.Common.populateField('read-only-remote-process-group-id', selectionData.id);
nf.Common.populateField('read-only-remote-process-group-name', selectionData.component.name);
nf.Common.populateField('read-only-remote-process-group-urls', selectionData.component.targetUris);
nf.Common.populateField('read-only-remote-process-group-timeout', selectionData.component.communicationsTimeout);
nf.Common.populateField('read-only-remote-process-group-yield-duration', selectionData.component.yieldDuration);
nf.Common.populateField('read-only-remote-process-group-transport-protocol', selectionData.component.transportProtocol);
nf.Common.populateField('read-only-remote-process-group-proxy-host', selectionData.component.proxyHost);
nf.Common.populateField('read-only-remote-process-group-proxy-port', selectionData.component.proxyPort);
nf.Common.populateField('read-only-remote-process-group-proxy-user', selectionData.component.proxyUser);
nf.Common.populateField('read-only-remote-process-group-proxy-password', selectionData.component.proxyPassword);
common.populateField('read-only-remote-process-group-id', selectionData.id);
common.populateField('read-only-remote-process-group-name', selectionData.component.name);
common.populateField('read-only-remote-process-group-urls', selectionData.component.targetUris);
common.populateField('read-only-remote-process-group-timeout', selectionData.component.communicationsTimeout);
common.populateField('read-only-remote-process-group-yield-duration', selectionData.component.yieldDuration);
common.populateField('read-only-remote-process-group-transport-protocol', selectionData.component.transportProtocol);
common.populateField('read-only-remote-process-group-proxy-host', selectionData.component.proxyHost);
common.populateField('read-only-remote-process-group-proxy-port', selectionData.component.proxyPort);
common.populateField('read-only-remote-process-group-proxy-user', selectionData.component.proxyUser);
common.populateField('read-only-remote-process-group-proxy-password', selectionData.component.proxyPassword);
// show the details
$('#remote-process-group-details').modal('show');
}
}
};
}());
}));

View File

@ -15,9 +15,46 @@
* limitations under the License.
*/
/* global nf, d3 */
/* global define, module, require, exports */
nf.RemoteProcessGroupPorts = (function () {
(function (root, factory) {
if (typeof define === 'function' && define.amd) {
define(['jquery',
'd3',
'nf.ErrorHandler',
'nf.Common',
'nf.Dialog',
'nf.Client',
'nf.CanvasUtils',
'nf.ng.Bridge',
'nf.RemoteProcessGroup'],
function ($, d3, errorHandler, common, dialog, client, canvasUtils, angularBridge, nfRemoteProcessGroup) {
return (nf.RemoteProcessGroupPorts = factory($, d3, errorHandler, common, dialog, client, canvasUtils, angularBridge, nfRemoteProcessGroup));
});
} else if (typeof exports === 'object' && typeof module === 'object') {
module.exports = (nf.RemoteProcessGroupPorts =
factory(require('jquery'),
require('d3'),
require('nf.ErrorHandler'),
require('nf.Common'),
require('nf.Dialog'),
require('nf.Client'),
require('nf.CanvasUtils'),
require('nf.ng.Bridge'),
require('nf.RemoteProcessGroup')));
} else {
nf.RemoteProcessGroupPorts = factory(root.$,
root.d3,
root.nf.ErrorHandler,
root.nf.Common,
root.nf.Dialog,
root.nf.Client,
root.nf.CanvasUtils,
root.nf.ng.Bridge,
root.nf.RemoteProcessGroup);
}
}(this, function ($, d3, errorHandler, common, dialog, client, canvasUtils, angularBridge, nfRemoteProcessGroup) {
'use strict';
/**
* Initializes the remote port configuration dialog.
@ -45,7 +82,7 @@ nf.RemoteProcessGroupPorts = (function () {
// create the remote process group details
var remoteProcessGroupPortEntity = {
'revision': nf.Client.getRevision(remoteProcessGroupData),
'revision': client.getRevision(remoteProcessGroupData),
'remoteProcessGroupPort': {
id: remotePortId,
groupId: remoteProcessGroupId,
@ -92,22 +129,22 @@ nf.RemoteProcessGroupPorts = (function () {
if (errors.length === 1) {
content = $('<span></span>').text(errors[0]);
} else {
content = nf.Common.formatUnorderedList(errors);
content = common.formatUnorderedList(errors);
}
nf.Dialog.showOkDialog({
dialog.showOkDialog({
dialogContent: content,
headerText: 'Remote Process Group Ports'
});
} else {
nf.ErrorHandler.handleAjaxError(xhr, status, error);
errorHandler.handleAjaxError(xhr, status, error);
}
}).always(function () {
// close the dialog
$('#remote-port-configuration').modal('hide');
});
} else {
nf.Dialog.showOkDialog({
dialog.showOkDialog({
headerText: 'Remote Process Group Ports',
dialogContent: 'Concurrent tasks must be an integer value.'
});
@ -165,9 +202,9 @@ nf.RemoteProcessGroupPorts = (function () {
var remoteProcessGroupData = remoteProcessGroup.datum();
// if can modify, the over status of this node may have changed
if (nf.CanvasUtils.canModify(remoteProcessGroup)) {
if (canvasUtils.canModify(remoteProcessGroup)) {
// reload the remote process group
nf.RemoteProcessGroup.reload(remoteProcessGroupData.id);
nfRemoteProcessGroup.reload(remoteProcessGroupData.id);
}
// hide the dialog
@ -184,8 +221,8 @@ nf.RemoteProcessGroupPorts = (function () {
// clear any tooltips
var dialog = $('#remote-process-group-ports');
nf.Common.cleanUpTooltips(dialog, 'div.remote-port-removed');
nf.Common.cleanUpTooltips(dialog, 'div.concurrent-tasks-info');
common.cleanUpTooltips(dialog, 'div.remote-port-removed');
common.cleanUpTooltips(dialog, 'div.concurrent-tasks-info');
// clear the input and output ports
$('#remote-process-group-input-ports-container').empty();
@ -203,7 +240,7 @@ nf.RemoteProcessGroupPorts = (function () {
* @argument {string} portType The type of port
*/
var createPortOption = function (container, port, portType) {
var portId = nf.Common.escapeHtml(port.id);
var portId = common.escapeHtml(port.id);
var portContainer = $('<div class="remote-port-container"></div>').appendTo(container);
var portContainerEditContainer = $('<div class="remote-port-edit-container"></div>').appendTo(portContainer);
var portContainerDetailsContainer = $('<div class="remote-port-details-container"></div>').appendTo(portContainer);
@ -213,25 +250,25 @@ nf.RemoteProcessGroupPorts = (function () {
var remoteProcessGroup = d3.select('#id-' + remoteProcessGroupId);
// if can modify, support updating the remote group port
if (nf.CanvasUtils.canModify(remoteProcessGroup)) {
if (canvasUtils.canModify(remoteProcessGroup)) {
// show the enabled transmission switch
var transmissionSwitch;
if (port.connected === true) {
if (port.transmitting === true) {
transmissionSwitch = (nf.ng.Bridge.injector.get('$compile')($('<md-switch style="margin:0px" class="md-primary enabled-active-transmission" aria-label="Toggle port transmission"></md-switch>'))(nf.ng.Bridge.rootScope)).appendTo(portContainerEditContainer);
transmissionSwitch = (angularBridge.injector.get('$compile')($('<md-switch style="margin:0px" class="md-primary enabled-active-transmission" aria-label="Toggle port transmission"></md-switch>'))(angularBridge.rootScope)).appendTo(portContainerEditContainer);
transmissionSwitch.click();
} else {
if (port.exists === true) {
transmissionSwitch = (nf.ng.Bridge.injector.get('$compile')($('<md-switch style="margin:0px" class="md-primary enabled-inactive-transmission" aria-label="Toggle port transmission"></md-switch>'))(nf.ng.Bridge.rootScope)).appendTo(portContainerEditContainer);
transmissionSwitch = (angularBridge.injector.get('$compile')($('<md-switch style="margin:0px" class="md-primary enabled-inactive-transmission" aria-label="Toggle port transmission"></md-switch>'))(angularBridge.rootScope)).appendTo(portContainerEditContainer);
} else {
(nf.ng.Bridge.injector.get('$compile')($('<md-switch ng-disabled="true" style="margin:0px" class="md-primary disabled-inactive-transmission" aria-label="Toggle port transmission"></md-switch>'))(nf.ng.Bridge.rootScope)).appendTo(portContainerEditContainer);
(angularBridge.injector.get('$compile')($('<md-switch ng-disabled="true" style="margin:0px" class="md-primary disabled-inactive-transmission" aria-label="Toggle port transmission"></md-switch>'))(angularBridge.rootScope)).appendTo(portContainerEditContainer);
}
}
} else {
if (port.transmitting === true) {
(nf.ng.Bridge.injector.get('$compile')($('<md-switch style="margin:0px" class="md-primary disabled-active-transmission" aria-label="Toggle port transmission"></md-switch>'))(nf.ng.Bridge.rootScope)).appendTo(portContainerEditContainer);
(angularBridge.injector.get('$compile')($('<md-switch style="margin:0px" class="md-primary disabled-active-transmission" aria-label="Toggle port transmission"></md-switch>'))(angularBridge.rootScope)).appendTo(portContainerEditContainer);
} else {
(nf.ng.Bridge.injector.get('$compile')($('<md-switch ng-disabled="true" style="margin:0px" class="md-primary disabled-inactive-transmission" aria-label="Toggle port transmission"></md-switch>'))(nf.ng.Bridge.rootScope)).appendTo(portContainerEditContainer);
(angularBridge.injector.get('$compile')($('<md-switch ng-disabled="true" style="margin:0px" class="md-primary disabled-inactive-transmission" aria-label="Toggle port transmission"></md-switch>'))(angularBridge.rootScope)).appendTo(portContainerEditContainer);
}
}
@ -255,14 +292,14 @@ nf.RemoteProcessGroupPorts = (function () {
}
} else if (port.exists === false) {
$('<div class="remote-port-removed"/>').appendTo(portContainerEditContainer).qtip($.extend({},
nf.Common.config.tooltipConfig,
common.config.tooltipConfig,
{
content: 'This port has been removed.'
}));
}
// only allow modifications to transmission when the swtich is defined
if (nf.Common.isDefinedAndNotNull(transmissionSwitch)) {
if (common.isDefinedAndNotNull(transmissionSwitch)) {
// create toggle for changing transmission state
transmissionSwitch.click(function () {
// get the component being edited
@ -277,7 +314,7 @@ nf.RemoteProcessGroupPorts = (function () {
// create the remote process group details
var remoteProcessGroupPortEntity = {
'revision': nf.Client.getRevision(remoteProcessGroupData),
'revision': client.getRevision(remoteProcessGroupData),
'remoteProcessGroupPort': {
id: port.id,
groupId: remoteProcessGroupId,
@ -312,7 +349,7 @@ nf.RemoteProcessGroupPorts = (function () {
transmissionSwitch.removeClass('enabled-active-transmission enabled-inactive-transmission').addClass('disabled-inactive-transmission').off('click');
// hide the edit button
if (nf.Common.isDefinedAndNotNull(editRemotePort)) {
if (common.isDefinedAndNotNull(editRemotePort)) {
editRemotePort.hide();
}
} else {
@ -322,7 +359,7 @@ nf.RemoteProcessGroupPorts = (function () {
transmissionSwitch.removeClass('enabled-active-transmission enabled-inactive-transmission').addClass('enabled-active-transmission');
// hide the edit button
if (nf.Common.isDefinedAndNotNull(editRemotePort)) {
if (common.isDefinedAndNotNull(editRemotePort)) {
editRemotePort.hide();
}
} else {
@ -330,7 +367,7 @@ nf.RemoteProcessGroupPorts = (function () {
transmissionSwitch.removeClass('enabled-active-transmission enabled-inactive-transmission').addClass('enabled-inactive-transmission');
// show the edit button
if (nf.Common.isDefinedAndNotNull(editRemotePort)) {
if (common.isDefinedAndNotNull(editRemotePort)) {
editRemotePort.show();
}
}
@ -343,15 +380,15 @@ nf.RemoteProcessGroupPorts = (function () {
if (errors.length === 1) {
content = $('<span></span>').text(errors[0]);
} else {
content = nf.Common.formatUnorderedList(errors);
content = common.formatUnorderedList(errors);
}
nf.Dialog.showOkDialog({
dialog.showOkDialog({
headerText: 'Remote Process Group Ports',
dialogContent: content
});
} else {
nf.ErrorHandler.handleAjaxError(xhr, status, error);
errorHandler.handleAjaxError(xhr, status, error);
}
});
});
@ -359,9 +396,9 @@ nf.RemoteProcessGroupPorts = (function () {
} else {
// show the disabled transmission switch
if (port.transmitting === true) {
(nf.ng.Bridge.injector.get('$compile')($('<md-switch style="margin:0px" class="md-primary disabled-active-transmission" aria-label="Toggle port transmission"></md-switch>'))(nf.ng.Bridge.rootScope)).appendTo(portContainerEditContainer);
(angularBridge.injector.get('$compile')($('<md-switch style="margin:0px" class="md-primary disabled-active-transmission" aria-label="Toggle port transmission"></md-switch>'))(angularBridge.rootScope)).appendTo(portContainerEditContainer);
} else {
(nf.ng.Bridge.injector.get('$compile')($('<md-switch ng-disabled="true" style="margin:0px" class="md-primary disabled-inactive-transmission" aria-label="Toggle port transmission"></md-switch>'))(nf.ng.Bridge.rootScope)).appendTo(portContainerEditContainer);
(angularBridge.injector.get('$compile')($('<md-switch ng-disabled="true" style="margin:0px" class="md-primary disabled-inactive-transmission" aria-label="Toggle port transmission"></md-switch>'))(angularBridge.rootScope)).appendTo(portContainerEditContainer);
}
}
@ -373,7 +410,7 @@ nf.RemoteProcessGroupPorts = (function () {
$('<div class="clear"></div>').appendTo(portContainerDetailsContainer);
// add the comments for this port
if (nf.Common.isBlank(port.comments)) {
if (common.isBlank(port.comments)) {
$('<div class="remote-port-description unset">No description specified.</div>').appendTo(portContainerDetailsContainer);
} else {
$('<div class="remote-port-description"></div>').text(port.comments).appendTo(portContainerDetailsContainer);
@ -394,7 +431,7 @@ nf.RemoteProcessGroupPorts = (function () {
'<div class="processor-setting concurrent-tasks-info fa fa-question-circle"></div>' +
'</div>' +
'</div>').append(concurrentTasks).appendTo(concurrentTasksContainer).find('div.concurrent-tasks-info').qtip($.extend({},
nf.Common.config.tooltipConfig,
common.config.tooltipConfig,
{
content: 'The number of tasks that should be concurrently scheduled for this port.'
}));
@ -424,7 +461,7 @@ nf.RemoteProcessGroupPorts = (function () {
portContainer.find('.ellipsis').ellipsis();
// inform Angular app values have changed
nf.ng.Bridge.digest();
angularBridge.digest();
};
/**
@ -469,7 +506,7 @@ nf.RemoteProcessGroupPorts = (function () {
*/
showPorts: function (selection) {
// if the specified component is a remote process group, load its properties
if (nf.CanvasUtils.isRemoteProcessGroup(selection)) {
if (canvasUtils.isRemoteProcessGroup(selection)) {
var selectionData = selection.datum();
// load the properties for the specified component
@ -481,7 +518,7 @@ nf.RemoteProcessGroupPorts = (function () {
var remoteProcessGroup = response.component;
// set the model locally
nf.RemoteProcessGroup.set(response);
nfRemoteProcessGroup.set(response);
// populate the port settings
$('#remote-process-group-ports-id').text(remoteProcessGroup.id);
@ -490,7 +527,7 @@ nf.RemoteProcessGroupPorts = (function () {
// get the contents
var remoteProcessGroupContents = remoteProcessGroup.contents;
if (nf.Common.isDefinedAndNotNull(remoteProcessGroupContents)) {
if (common.isDefinedAndNotNull(remoteProcessGroupContents)) {
var connectedInputPorts = [];
var disconnectedInputPorts = [];
@ -514,7 +551,7 @@ nf.RemoteProcessGroupPorts = (function () {
createPortOption(inputPortContainer, inputPort, 'input');
});
if (nf.Common.isEmpty(connectedInputPorts) && nf.Common.isEmpty(disconnectedInputPorts)) {
if (common.isEmpty(connectedInputPorts) && common.isEmpty(disconnectedInputPorts)) {
$('<div class="unset"></div>').text("No ports to display").appendTo(inputPortContainer);
}
@ -541,15 +578,15 @@ nf.RemoteProcessGroupPorts = (function () {
createPortOption(outputPortContainer, outputPort, 'output');
});
if (nf.Common.isEmpty(connectedOutputPorts) && nf.Common.isEmpty(disconnectedOutputPorts)) {
if (common.isEmpty(connectedOutputPorts) && common.isEmpty(disconnectedOutputPorts)) {
$('<div class="unset"></div>').text("No ports to display").appendTo(outputPortContainer);
}
}
// show the details
$('#remote-process-group-ports').modal('show');
}).fail(nf.ErrorHandler.handleAjaxError);
}).fail(errorHandler.handleAjaxError);
}
}
};
}());
}));

View File

@ -15,9 +15,42 @@
* limitations under the License.
*/
/* global nf, d3 */
/* global define, module, require, exports */
nf.RemoteProcessGroup = (function () {
(function (root, factory) {
if (typeof define === 'function' && define.amd) {
define(['jquery',
'd3',
'nf.Connection',
'nf.Common',
'nf.Client',
'nf.CanvasUtils'],
function ($, d3, connection, common, client, canvasUtils) {
return (nf.RemoteProcessGroup = factory($, d3, connection, common, client, canvasUtils));
});
} else if (typeof exports === 'object' && typeof module === 'object') {
module.exports = (nf.RemoteProcessGroup =
factory(require('jquery'),
require('d3'),
require('nf.Connection'),
require('nf.Common'),
require('nf.Client'),
require('nf.CanvasUtils')));
} else {
nf.RemoteProcessGroup = factory(root.$,
root.d3,
root.nf.Connection,
root.nf.Common,
root.nf.Client,
root.nf.CanvasUtils);
}
}(this, function ($, d3, connection, common, client, canvasUtils) {
'use strict';
var nfConnectable;
var nfDraggable;
var nfSelectable;
var nfContextMenu;
var PREVIEW_NAME_LENGTH = 30;
@ -55,7 +88,7 @@ nf.RemoteProcessGroup = (function () {
* @param {object} d
*/
var getProcessGroupComments = function (d) {
if (nf.Common.isBlank(d.component.comments)) {
if (common.isBlank(d.component.comments)) {
return 'No comments specified';
} else {
return d.component.comments;
@ -90,7 +123,7 @@ nf.RemoteProcessGroup = (function () {
'class': 'remote-process-group component'
})
.classed('selected', selected)
.call(nf.CanvasUtils.position);
.call(canvasUtils.position);
// ----
// body
@ -145,7 +178,7 @@ nf.RemoteProcessGroup = (function () {
});
// always support selection
remoteProcessGroup.call(nf.Selectable.activate).call(nf.ContextMenu.activate);
remoteProcessGroup.call(nfSelectable.activate).call(nfContextMenu.activate);
};
// attempt of space between component count and icon for process group contents
@ -178,7 +211,7 @@ nf.RemoteProcessGroup = (function () {
var details = remoteProcessGroup.select('g.remote-process-group-details');
// update the component behavior as appropriate
nf.CanvasUtils.editable(remoteProcessGroup);
canvasUtils.editable(remoteProcessGroup, nfConnectable, nfDraggable);
// if this processor is visible, render everything
if (remoteProcessGroup.classed('visible')) {
@ -499,7 +532,7 @@ nf.RemoteProcessGroup = (function () {
remoteProcessGroupUri.text(null).selectAll('title').remove();
// apply ellipsis to the remote process group name as necessary
nf.CanvasUtils.ellipsis(remoteProcessGroupUri, d.component.targetUris);
canvasUtils.ellipsis(remoteProcessGroupUri, d.component.targetUris);
}).append('title').text(function (d) {
return d.component.name;
});
@ -530,15 +563,15 @@ nf.RemoteProcessGroup = (function () {
// update the tip
tip.text(function () {
if (d.component.targetSecure === true) {
return 'Site-to-Site is secure.';
} else {
return 'Site-to-Site is NOT secure.';
}
});
if (d.component.targetSecure === true) {
return 'Site-to-Site is secure.';
} else {
return 'Site-to-Site is NOT secure.';
}
});
// add the tooltip
nf.CanvasUtils.canvasTooltip(tip, d3.select(this));
canvasUtils.canvasTooltip(tip, d3.select(this));
});
// ---------------
@ -554,9 +587,9 @@ nf.RemoteProcessGroup = (function () {
remoteProcessGroupComments.text(null).selectAll('tspan, title').remove();
// apply ellipsis to the port name as necessary
nf.CanvasUtils.ellipsis(remoteProcessGroupComments, getProcessGroupComments(d));
canvasUtils.ellipsis(remoteProcessGroupComments, getProcessGroupComments(d));
}).classed('unset', function (d) {
return nf.Common.isBlank(d.component.comments);
return common.isBlank(d.component.comments);
}).append('title').text(function (d) {
return getProcessGroupComments(d);
});
@ -567,7 +600,7 @@ nf.RemoteProcessGroup = (function () {
details.select('text.remote-process-group-last-refresh')
.text(function (d) {
if (nf.Common.isDefinedAndNotNull(d.component.flowRefreshed)) {
if (common.isDefinedAndNotNull(d.component.flowRefreshed)) {
return d.component.flowRefreshed;
} else {
return 'Remote flow not current';
@ -583,7 +616,7 @@ nf.RemoteProcessGroup = (function () {
remoteProcessGroupName.text(null).selectAll('title').remove();
// apply ellipsis to the remote process group name as necessary
nf.CanvasUtils.ellipsis(remoteProcessGroupName, d.component.name);
canvasUtils.ellipsis(remoteProcessGroupName, d.component.name);
}).append('title').text(function (d) {
return d.component.name;
});
@ -647,13 +680,13 @@ nf.RemoteProcessGroup = (function () {
// sent count value
updated.select('text.remote-process-group-sent tspan.count')
.text(function (d) {
return nf.Common.substringBeforeFirst(d.status.aggregateSnapshot.sent, ' ');
return common.substringBeforeFirst(d.status.aggregateSnapshot.sent, ' ');
});
// sent size value
updated.select('text.remote-process-group-sent tspan.size')
.text(function (d) {
return ' ' + nf.Common.substringAfterFirst(d.status.aggregateSnapshot.sent, ' ');
return ' ' + common.substringAfterFirst(d.status.aggregateSnapshot.sent, ' ');
});
// sent ports value
@ -671,13 +704,13 @@ nf.RemoteProcessGroup = (function () {
// received count value
updated.select('text.remote-process-group-received tspan.count')
.text(function (d) {
return nf.Common.substringBeforeFirst(d.status.aggregateSnapshot.received, ' ');
return common.substringBeforeFirst(d.status.aggregateSnapshot.received, ' ');
});
// received size value
updated.select('text.remote-process-group-received tspan.size')
.text(function (d) {
return ' ' + nf.Common.substringAfterFirst(d.status.aggregateSnapshot.received, ' ');
return ' ' + common.substringAfterFirst(d.status.aggregateSnapshot.received, ' ');
});
// --------------------
@ -690,7 +723,7 @@ nf.RemoteProcessGroup = (function () {
.text(function (d) {
var icon = '';
if (d.permissions.canRead) {
if (!nf.Common.isEmpty(d.component.authorizationIssues)) {
if (!common.isEmpty(d.component.authorizationIssues)) {
icon = '\uf071';
} else if (d.component.transmitting === true) {
icon = '\uf140';
@ -703,7 +736,7 @@ nf.RemoteProcessGroup = (function () {
.attr('font-family', function (d) {
var family = '';
if (d.permissions.canRead) {
if (!nf.Common.isEmpty(d.component.authorizationIssues) || d.component.transmitting) {
if (!common.isEmpty(d.component.authorizationIssues) || d.component.transmitting) {
family = 'FontAwesome';
} else {
family = 'flowfont';
@ -712,20 +745,20 @@ nf.RemoteProcessGroup = (function () {
return family;
})
.classed('invalid', function (d) {
return d.permissions.canRead && !nf.Common.isEmpty(d.component.authorizationIssues);
return d.permissions.canRead && !common.isEmpty(d.component.authorizationIssues);
})
.classed('transmitting', function (d) {
return d.permissions.canRead && nf.Common.isEmpty(d.component.authorizationIssues) && d.component.transmitting === true;
return d.permissions.canRead && common.isEmpty(d.component.authorizationIssues) && d.component.transmitting === true;
})
.classed('not-transmitting', function (d) {
return d.permissions.canRead && nf.Common.isEmpty(d.component.authorizationIssues) && d.component.transmitting === false;
return d.permissions.canRead && common.isEmpty(d.component.authorizationIssues) && d.component.transmitting === false;
})
.each(function (d) {
// get the tip
var tip = d3.select('#authorization-issues-' + d.id);
// if there are validation errors generate a tooltip
if (d.permissions.canRead && !nf.Common.isEmpty(d.component.authorizationIssues)) {
if (d.permissions.canRead && !common.isEmpty(d.component.authorizationIssues)) {
// create the tip if necessary
if (tip.empty()) {
tip = d3.select('#remote-process-group-tooltips').append('div')
@ -737,16 +770,16 @@ nf.RemoteProcessGroup = (function () {
// update the tip
tip.html(function () {
var list = nf.Common.formatUnorderedList(d.component.authorizationIssues);
if (list === null || list.length === 0) {
return '';
} else {
return $('<div></div>').append(list).html();
}
});
var list = common.formatUnorderedList(d.component.authorizationIssues);
if (list === null || list.length === 0) {
return '';
} else {
return $('<div></div>').append(list).html();
}
});
// add the tooltip
nf.CanvasUtils.canvasTooltip(tip, d3.select(this));
canvasUtils.canvasTooltip(tip, d3.select(this));
} else {
if (!tip.empty()) {
tip.remove();
@ -762,7 +795,7 @@ nf.RemoteProcessGroup = (function () {
// active thread count
// -------------------
nf.CanvasUtils.activeThreadCount(remoteProcessGroup, d, function (off) {
canvasUtils.activeThreadCount(remoteProcessGroup, d, function (off) {
offset = off;
});
@ -771,10 +804,10 @@ nf.RemoteProcessGroup = (function () {
// ---------
remoteProcessGroup.select('rect.bulletin-background').classed('has-bulletins', function () {
return !nf.Common.isEmpty(d.status.aggregateSnapshot.bulletins);
return !common.isEmpty(d.status.aggregateSnapshot.bulletins);
});
nf.CanvasUtils.bulletins(remoteProcessGroup, d, function () {
canvasUtils.bulletins(remoteProcessGroup, d, function () {
return d3.select('#remote-process-group-tooltips');
}, offset);
});
@ -807,11 +840,16 @@ nf.RemoteProcessGroup = (function () {
});
};
return {
var nfRemoteProcessGroup = {
/**
* Initializes of the Process Group handler.
*/
init: function () {
init: function (connectable, draggable, selectable, contextMenu) {
nfConnectable = connectable;
nfDraggable = draggable;
nfSelectable = selectable;
nfContextMenu = contextMenu;
remoteProcessGroupMap = d3.map();
removedCache = d3.map();
addedCache = d3.map();
@ -832,8 +870,8 @@ nf.RemoteProcessGroup = (function () {
*/
add: function (remoteProcessGroupEntities, options) {
var selectAll = false;
if (nf.Common.isDefinedAndNotNull(options)) {
selectAll = nf.Common.isDefinedAndNotNull(options.selectAll) ? options.selectAll : selectAll;
if (common.isDefinedAndNotNull(options)) {
selectAll = common.isDefinedAndNotNull(options.selectAll) ? options.selectAll : selectAll;
}
// get the current time
@ -854,7 +892,7 @@ nf.RemoteProcessGroup = (function () {
$.each(remoteProcessGroupEntities, function (_, remoteProcessGroupEntity) {
add(remoteProcessGroupEntity);
});
} else if (nf.Common.isDefinedAndNotNull(remoteProcessGroupEntities)) {
} else if (common.isDefinedAndNotNull(remoteProcessGroupEntities)) {
add(remoteProcessGroupEntities);
}
@ -863,7 +901,7 @@ nf.RemoteProcessGroup = (function () {
selection.enter().call(renderRemoteProcessGroups, selectAll);
selection.call(updateRemoteProcessGroups);
},
/**
* Populates the graph with the specified remote process groups.
*
@ -873,16 +911,16 @@ nf.RemoteProcessGroup = (function () {
set: function (remoteProcessGroupEntities, options) {
var selectAll = false;
var transition = false;
if (nf.Common.isDefinedAndNotNull(options)) {
selectAll = nf.Common.isDefinedAndNotNull(options.selectAll) ? options.selectAll : selectAll;
transition = nf.Common.isDefinedAndNotNull(options.transition) ? options.transition : transition;
if (common.isDefinedAndNotNull(options)) {
selectAll = common.isDefinedAndNotNull(options.selectAll) ? options.selectAll : selectAll;
transition = common.isDefinedAndNotNull(options.transition) ? options.transition : transition;
}
var set = function (proposedRemoteProcessGroupEntity) {
var currentRemoteProcessGroupEntity = remoteProcessGroupMap.get(proposedRemoteProcessGroupEntity.id);
// set the remote process group if appropriate due to revision and wasn't previously removed
if (nf.Client.isNewerRevision(currentRemoteProcessGroupEntity, proposedRemoteProcessGroupEntity) && !removedCache.has(proposedRemoteProcessGroupEntity.id)) {
if (client.isNewerRevision(currentRemoteProcessGroupEntity, proposedRemoteProcessGroupEntity) && !removedCache.has(proposedRemoteProcessGroupEntity.id)) {
remoteProcessGroupMap.set(proposedRemoteProcessGroupEntity.id, $.extend({
type: 'RemoteProcessGroup',
dimensions: dimensions
@ -906,14 +944,14 @@ nf.RemoteProcessGroup = (function () {
$.each(remoteProcessGroupEntities, function (_, remoteProcessGroupEntity) {
set(remoteProcessGroupEntity);
});
} else if (nf.Common.isDefinedAndNotNull(remoteProcessGroupEntities)) {
} else if (common.isDefinedAndNotNull(remoteProcessGroupEntities)) {
set(remoteProcessGroupEntities);
}
// apply the selection and handle all new remote process groups
var selection = select();
selection.enter().call(renderRemoteProcessGroups, selectAll);
selection.call(updateRemoteProcessGroups).call(nf.CanvasUtils.position, transition);
selection.call(updateRemoteProcessGroups).call(canvasUtils.position, transition);
selection.exit().call(removeRemoteProcessGroups);
},
@ -924,7 +962,7 @@ nf.RemoteProcessGroup = (function () {
* @param {string} id
*/
get: function (id) {
if (nf.Common.isUndefined(id)) {
if (common.isUndefined(id)) {
return remoteProcessGroupMap.values();
} else {
return remoteProcessGroupMap.get(id);
@ -938,7 +976,7 @@ nf.RemoteProcessGroup = (function () {
* @param {string} id Optional
*/
refresh: function (id) {
if (nf.Common.isDefinedAndNotNull(id)) {
if (common.isDefinedAndNotNull(id)) {
d3.select('#id-' + id).call(updateRemoteProcessGroups);
} else {
d3.selectAll('g.remote-process-group').call(updateRemoteProcessGroups);
@ -966,13 +1004,13 @@ nf.RemoteProcessGroup = (function () {
url: remoteProcessGroupEntity.uri,
dataType: 'json'
}).done(function (response) {
nf.RemoteProcessGroup.set(response);
nfRemoteProcessGroup.set(response);
// reload the group's connections
var connections = nf.Connection.getComponentConnections(id);
var connections = connection.getComponentConnections(id);
$.each(connections, function (_, connection) {
if (connection.permissions.canRead) {
nf.Connection.reload(connection.id);
connection.reload(connection.id);
}
});
});
@ -985,7 +1023,7 @@ nf.RemoteProcessGroup = (function () {
* @param {string} id The id
*/
position: function (id) {
d3.select('#id-' + id).call(nf.CanvasUtils.position);
d3.select('#id-' + id).call(canvasUtils.position);
},
/**
@ -1014,7 +1052,7 @@ nf.RemoteProcessGroup = (function () {
* Removes all remote process groups.
*/
removeAll: function () {
nf.RemoteProcessGroup.remove(remoteProcessGroupMap.keys());
nfRemoteProcessGroup.remove(remoteProcessGroupMap.keys());
},
/**
@ -1035,4 +1073,6 @@ nf.RemoteProcessGroup = (function () {
expire(removedCache);
}
};
}());
return nfRemoteProcessGroup;
}));

View File

@ -15,9 +15,48 @@
* limitations under the License.
*/
/* global nf */
/* global define, module, require, exports */
nf.ReportingTask = (function () {
(function (root, factory) {
if (typeof define === 'function' && define.amd) {
define(['jquery',
'nf.ErrorHandler',
'nf.Common',
'nf.Dialog',
'nf.Client',
'nf.ControllerService',
'nf.ControllerServices',
'nf.UniversalCapture',
'nf.CustomUi'],
function ($, errorHandler, common, dialog, client, controllerService, controllerServices, universalCapture, customUi) {
return (nf.ReportingTask = factory($, errorHandler, common, dialog, client, controllerService, controllerServices, universalCapture, customUi));
});
} else if (typeof exports === 'object' && typeof module === 'object') {
module.exports = (nf.ReportingTask =
factory(require('jquery'),
require('nf.ErrorHandler'),
require('nf.Common'),
require('nf.Dialog'),
require('nf.Client'),
require('nf.ControllerService'),
require('nf.ControllerServices'),
require('nf.UniversalCapture'),
require('nf.CustomUi')));
} else {
nf.ReportingTask = factory(root.$,
root.nf.ErrorHandler,
root.nf.Common,
root.nf.Dialog,
root.nf.Client,
root.nf.ControllerService,
root.nf.ControllerServices,
root.nf.UniversalCapture,
root.nf.CustomUi);
}
}(this, function ($, errorHandler, common, dialog, client, controllerService, controllerServices, universalCapture, customUi) {
'use strict';
var nfSettings;
var config = {
edit: 'edit',
@ -38,7 +77,7 @@ nf.ReportingTask = (function () {
var getControllerServicesTable = function () {
return $('#controller-services-table');
};
/**
* Handle any expected reporting task configuration errors.
*
@ -54,15 +93,15 @@ nf.ReportingTask = (function () {
if (errors.length === 1) {
content = $('<span></span>').text(errors[0]);
} else {
content = nf.Common.formatUnorderedList(errors);
content = common.formatUnorderedList(errors);
}
nf.Dialog.showOkDialog({
dialog.showOkDialog({
dialogContent: content,
headerText: 'Reporting Task'
});
} else {
nf.ErrorHandler.handleAjaxError(xhr, status, error);
errorHandler.handleAjaxError(xhr, status, error);
}
};
@ -102,7 +141,7 @@ nf.ReportingTask = (function () {
}
// check the scheduling period
if (nf.Common.isDefinedAndNotNull(schedulingPeriod) && schedulingPeriod.val() !== (entity.component['schedulingPeriod'] + '')) {
if (common.isDefinedAndNotNull(schedulingPeriod) && schedulingPeriod.val() !== (entity.component['schedulingPeriod'] + '')) {
return true;
}
@ -165,13 +204,13 @@ nf.ReportingTask = (function () {
var errors = [];
var reportingTask = details['component'];
if (nf.Common.isBlank(reportingTask['schedulingPeriod'])) {
if (common.isBlank(reportingTask['schedulingPeriod'])) {
errors.push('Run schedule must be specified');
}
if (errors.length > 0) {
nf.Dialog.showOkDialog({
dialogContent: nf.Common.formatUnorderedList(errors),
dialog.showOkDialog({
dialogContent: common.formatUnorderedList(errors),
headerText: 'Reporting Task'
});
return false;
@ -202,7 +241,7 @@ nf.ReportingTask = (function () {
*/
var setRunning = function (reportingTaskEntity, running) {
var entity = {
'revision': nf.Client.getRevision(reportingTaskEntity),
'revision': client.getRevision(reportingTaskEntity),
'component': {
'id': reportingTaskEntity.id,
'state': running === true ? 'RUNNING' : 'STOPPED'
@ -218,8 +257,8 @@ nf.ReportingTask = (function () {
}).done(function (response) {
// update the task
renderReportingTask(response);
nf.ControllerService.reloadReferencedServices(getControllerServicesTable(), response.component);
}).fail(nf.ErrorHandler.handleAjaxError);
controllerService.reloadReferencedServices(getControllerServicesTable(), response.component);
}).fail(errorHandler.handleAjaxError);
};
/**
@ -233,7 +272,7 @@ nf.ReportingTask = (function () {
// determine if changes have been made
if (isSaveRequired()) {
// see if those changes should be saved
nf.Dialog.showYesNoDialog({
dialog.showYesNoDialog({
headerText: 'Save',
dialogContent: 'Save changes before going to this Controller Service?',
noHandler: function () {
@ -265,7 +304,7 @@ nf.ReportingTask = (function () {
// ensure details are valid as far as we can tell
if (validateDetails(updatedReportingTask)) {
updatedReportingTask['revision'] = nf.Client.getRevision(reportingTaskEntity);
updatedReportingTask['revision'] = client.getRevision(reportingTaskEntity);
// update the selected component
return $.ajax({
@ -299,14 +338,16 @@ nf.ReportingTask = (function () {
propertyName: propertyName
},
dataType: 'json'
}).fail(nf.ErrorHandler.handleAjaxError);
}).fail(errorHandler.handleAjaxError);
};
return {
var nfReportingTask = {
/**
* Initializes the reporting task configuration dialog.
*/
init: function () {
init: function (settings) {
nfSettings = settings;
// initialize the configuration dialog tabs
$('#reporting-task-configuration-tabs').tabbs({
tabStyle: 'tab',
@ -324,7 +365,7 @@ nf.ReportingTask = (function () {
}],
select: function () {
// remove all property detail dialogs
nf.UniversalCapture.removeAllPropertyDetailDialogs();
universalCapture.removeAllPropertyDetailDialogs();
// update the property table size in case this is the first time its rendered
if ($(this).text() === 'Properties') {
@ -349,13 +390,13 @@ nf.ReportingTask = (function () {
$('#reporting-task-properties').propertytable('clear');
// clear the comments
nf.Common.clearField('read-only-reporting-task-comments');
common.clearField('read-only-reporting-task-comments');
// removed the cached reporting task details
$('#reporting-task-configuration').removeData('reportingTaskDetails');
},
open: function () {
nf.Common.toggleScrollable($('#' + this.find('.tab-container').attr('id') + '-content').get(0));
common.toggleScrollable($('#' + this.find('.tab-container').attr('id') + '-content').get(0));
}
}
});
@ -366,8 +407,8 @@ nf.ReportingTask = (function () {
supportsGoTo: true,
dialogContainer: '#new-reporting-task-property-container',
descriptorDeferred: getReportingTaskPropertyDescriptor,
controllerServiceCreatedDeferred: function(response){
return nf.ControllerServices.loadControllerServices(controllerServicesUri, $('#controller-services-table'));
controllerServiceCreatedDeferred: function (response) {
return controllerServices.loadControllerServices(controllerServicesUri, $('#controller-services-table'));
},
goToServiceDeferred: goToServiceFromProperty
});
@ -391,8 +432,8 @@ nf.ReportingTask = (function () {
supportsGoTo: true,
dialogContainer: '#new-reporting-task-property-container',
descriptorDeferred: getReportingTaskPropertyDescriptor,
controllerServiceCreatedDeferred: function(response){
return nf.ControllerServices.loadControllerServices(controllerServicesUri, $('#controller-services-table'));
controllerServiceCreatedDeferred: function (response) {
return controllerServices.loadControllerServices(controllerServicesUri, $('#controller-services-table'));
},
goToServiceDeferred: goToServiceFromProperty
});
@ -434,8 +475,8 @@ nf.ReportingTask = (function () {
}
// populate the reporting task settings
nf.Common.populateField('reporting-task-id', reportingTask['id']);
nf.Common.populateField('reporting-task-type', nf.Common.substringAfterLast(reportingTask['type'], '.'));
common.populateField('reporting-task-id', reportingTask['id']);
common.populateField('reporting-task-type', common.substringAfterLast(reportingTask['type'], '.'));
$('#reporting-task-name').val(reportingTask['name']);
$('#reporting-task-enabled').removeClass('checkbox-unchecked checkbox-checked').addClass(reportingTaskEnableStyle);
$('#reporting-task-comments').val(reportingTask['comments']);
@ -489,10 +530,10 @@ nf.ReportingTask = (function () {
// close all fields currently being edited
$('#reporting-task-properties').propertytable('saveRow');
// save the reporting task
saveReportingTask(reportingTaskEntity).done(function (response) {
// reload the reporting task
nf.ControllerService.reloadReferencedServices(getControllerServicesTable(), response.component);
// save the reporting task
saveReportingTask(reportingTaskEntity).done(function (response) {
// reload the reporting task
controllerService.reloadReferencedServices(getControllerServicesTable(), response.component);
// close the details panel
$('#reporting-task-configuration').modal('hide');
@ -515,7 +556,7 @@ nf.ReportingTask = (function () {
}];
// determine if we should show the advanced button
if (nf.Common.isDefinedAndNotNull(reportingTask.customUiUrl) && reportingTask.customUiUrl !== '') {
if (common.isDefinedAndNotNull(reportingTask.customUiUrl) && reportingTask.customUiUrl !== '') {
buttons.push({
buttonText: 'Advanced',
clazz: 'fa fa-cog button-icon',
@ -534,14 +575,14 @@ nf.ReportingTask = (function () {
$('#shell-close-button').click();
// show the custom ui
nf.CustomUi.showCustomUi(reportingTaskEntity, reportingTask.customUiUrl, true).done(function () {
customUi.showCustomUi(reportingTaskEntity, reportingTask.customUiUrl, true).done(function () {
// once the custom ui is closed, reload the reporting task
nf.ReportingTask.reload(reportingTaskEntity.id).done(function (response) {
nf.ControllerService.reloadReferencedServices(getControllerServicesTable(), response.reportingTask);
nfReportingTask.reload(reportingTaskEntity.id).done(function (response) {
controllerService.reloadReferencedServices(getControllerServicesTable(), response.reportingTask);
});
// show the settings
nf.Settings.showSettings();
nfSettings.showSettings();
});
};
@ -551,7 +592,7 @@ nf.ReportingTask = (function () {
// determine if changes have been made
if (isSaveRequired()) {
// see if those changes should be saved
nf.Dialog.showYesNoDialog({
dialog.showYesNoDialog({
headerText: 'Save',
dialogContent: 'Save changes before opening the advanced configuration?',
noHandler: openCustomUi,
@ -583,7 +624,7 @@ nf.ReportingTask = (function () {
$('#reporting-task-configuration').modal('show');
$('#reporting-task-properties').propertytable('resetTableSize');
}).fail(nf.ErrorHandler.handleAjaxError);
}).fail(errorHandler.handleAjaxError);
},
/**
@ -632,10 +673,10 @@ nf.ReportingTask = (function () {
var reportingTaskHistory = historyResponse[0].componentHistory;
// populate the reporting task settings
nf.Common.populateField('reporting-task-id', reportingTask['id']);
nf.Common.populateField('reporting-task-type', nf.Common.substringAfterLast(reportingTask['type'], '.'));
nf.Common.populateField('read-only-reporting-task-name', reportingTask['name']);
nf.Common.populateField('read-only-reporting-task-comments', reportingTask['comments']);
common.populateField('reporting-task-id', reportingTask['id']);
common.populateField('reporting-task-type', common.substringAfterLast(reportingTask['type'], '.'));
common.populateField('read-only-reporting-task-name', reportingTask['name']);
common.populateField('read-only-reporting-task-comments', reportingTask['comments']);
// make the scheduling strategy human readable
var schedulingStrategy = reportingTask['schedulingStrategy'];
@ -644,8 +685,8 @@ nf.ReportingTask = (function () {
} else {
schedulingStrategy = "Timer driven";
}
nf.Common.populateField('read-only-reporting-task-scheduling-strategy', schedulingStrategy);
nf.Common.populateField('read-only-reporting-task-scheduling-period', reportingTask['schedulingPeriod']);
common.populateField('read-only-reporting-task-scheduling-strategy', schedulingStrategy);
common.populateField('read-only-reporting-task-scheduling-period', reportingTask['schedulingPeriod']);
var buttons = [{
buttonText: 'Ok',
@ -663,7 +704,7 @@ nf.ReportingTask = (function () {
}];
// determine if we should show the advanced button
if (nf.Common.isDefinedAndNotNull(nf.CustomUi) && nf.Common.isDefinedAndNotNull(reportingTask.customUiUrl) && reportingTask.customUiUrl !== '') {
if (common.isDefinedAndNotNull(customUi) && common.isDefinedAndNotNull(reportingTask.customUiUrl) && reportingTask.customUiUrl !== '') {
buttons.push({
buttonText: 'Advanced',
clazz: 'fa fa-cog button-icon',
@ -681,8 +722,8 @@ nf.ReportingTask = (function () {
$('#shell-close-button').click();
// show the custom ui
nf.CustomUi.showCustomUi(reportingTaskEntity, reportingTask.customUiUrl, false).done(function() {
nf.Settings.showSettings();
customUi.showCustomUi(reportingTaskEntity, reportingTask.customUiUrl, false).done(function () {
nfSettings.showSettings();
});
}
}
@ -736,9 +777,9 @@ nf.ReportingTask = (function () {
dataType: 'json'
}).done(function (response) {
renderReportingTask(response);
}).fail(nf.ErrorHandler.handleAjaxError);
}).fail(errorHandler.handleAjaxError);
},
/**
* Prompts the user before attempting to delete the specified reporting task.
*
@ -746,11 +787,11 @@ nf.ReportingTask = (function () {
*/
promptToDeleteReportingTask: function (reportingTaskEntity) {
// prompt for deletion
nf.Dialog.showYesNoDialog({
dialog.showYesNoDialog({
headerText: 'Delete Reporting Task',
dialogContent: 'Delete reporting task \'' + nf.Common.escapeHtml(reportingTaskEntity.component.name) + '\'?',
dialogContent: 'Delete reporting task \'' + common.escapeHtml(reportingTaskEntity.component.name) + '\'?',
yesHandler: function () {
nf.ReportingTask.remove(reportingTaskEntity);
nfReportingTask.remove(reportingTaskEntity);
}
});
},
@ -763,7 +804,7 @@ nf.ReportingTask = (function () {
remove: function (reportingTaskEntity) {
// prompt for removal?
var revision = nf.Client.getRevision(reportingTaskEntity);
var revision = client.getRevision(reportingTaskEntity);
$.ajax({
type: 'DELETE',
url: reportingTaskEntity.uri + '?' + $.param({
@ -776,7 +817,9 @@ nf.ReportingTask = (function () {
var reportingTaskGrid = $('#reporting-tasks-table').data('gridInstance');
var reportingTaskData = reportingTaskGrid.getData();
reportingTaskData.deleteItem(reportingTaskEntity.id);
}).fail(nf.ErrorHandler.handleAjaxError);
}).fail(errorHandler.handleAjaxError);
}
};
}());
return nfReportingTask;
}));

View File

@ -15,18 +15,34 @@
* limitations under the License.
*/
/* global nf, d3 */
/* global define, module, require, exports */
nf.Selectable = (function () {
(function (root, factory) {
if (typeof define === 'function' && define.amd) {
define(['d3',
'nf.ng.Bridge',
'nf.ContextMenu'],
function (d3, angularBridge, contextMenu) {
return (nf.Selectable = factory(d3, angularBridge, contextMenu));
});
} else if (typeof exports === 'object' && typeof module === 'object') {
module.exports = (nf.Selectable =
factory(require('d3'),
require('nf.ng.Bridge'),
require('nf.ContextMenu')));
} else {
nf.Selectable = factory(root.d3,
root.nf.ng.Bridge,
root.nf.ContextMenu);
}
}(this, function (d3, angularBridge, contextMenu) {
'use strict';
return {
init: function () {
var nfSelectable = {
},
select: function (g) {
// hide any context menus as necessary
nf.ContextMenu.hide();
contextMenu.hide();
// only need to update selection if necessary
if (!g.classed('selected')) {
@ -44,18 +60,26 @@ nf.Selectable = (function () {
}
}
// inform Angular app that values have changed
nf.ng.Bridge.digest();
// inform Angular app that values have changed since the
// enabled operate palette buttons are based off of the selection
angularBridge.digest();
// stop propagation
d3.event.stopPropagation();
},
/**
* Activates the select behavior for the components in the specified selection.
*
* @param {selection} components
*/
activate: function (components) {
components.on('mousedown.selection', function () {
// get the clicked component to update selection
nf.Selectable.select(d3.select(this));
nfSelectable.select(d3.select(this));
});
}
};
}());
return nfSelectable;
}));

View File

@ -15,9 +15,59 @@
* limitations under the License.
*/
/* global nf, Slick, d3 */
/* global define, module, require, exports */
(function (root, factory) {
if (typeof define === 'function' && define.amd) {
define(['jquery',
'Slick',
'd3',
'nf.Client',
'nf.Dialog',
'nf.Common',
'nf.CanvasUtils',
'nf.ControllerServices',
'nf.ErrorHandler',
'nf.ReportingTask',
'nf.Shell',
'nf.ComponentState',
'nf.PolicyManagement'],
function ($, Slick, d3, client, dialog, common, canvasUtils, controllerServices, errorHandler, reportingTask, shell, componentState, policyManagement) {
return (nf.Settings = factory($, Slick, d3, client, dialog, common, canvasUtils, controllerServices, errorHandler, reportingTask, shell, componentState, policyManagement));
});
} else if (typeof exports === 'object' && typeof module === 'object') {
module.exports = (nf.Settings =
factory(require('jquery'),
require('Slick'),
require('d3'),
require('nf.Client'),
require('nf.Dialog'),
require('nf.Common'),
require('nf.CanvasUtils'),
require('nf.ControllerServices'),
require('nf.ErrorHandler'),
require('nf.ReportingTask'),
require('nf.Shell'),
require('nf.ComponentState'),
require('nf.PolicyManagement')));
} else {
nf.Settings = factory(root.$,
root.Slick,
root.d3,
root.nf.Client,
root.nf.Dialog,
root.nf.Common,
root.nf.CanvasUtils,
root.nf.ControllerServices,
root.nf.ErrorHandler,
root.nf.ReportingTask,
root.nf.Shell,
root.nf.ComponentState,
root.nf.PolicyManagement);
}
}(this, function ($, Slick, d3, client, dialog, common, canvasUtils, controllerServices, errorHandler, reportingTask, shell, componentState, policyManagement) {
'use strict';
nf.Settings = (function () {
var config = {
urls: {
@ -57,7 +107,7 @@ nf.Settings = (function () {
// marshal the configuration details
var configuration = marshalConfiguration();
var entity = {
'revision': nf.Client.getRevision({
'revision': client.getRevision({
'revision': {
'version': version
}
@ -74,7 +124,7 @@ nf.Settings = (function () {
contentType: 'application/json'
}).done(function (response) {
// close the settings dialog
nf.Dialog.showOkDialog({
dialog.showOkDialog({
headerText: 'Settings',
dialogContent: 'Settings successfully applied.'
});
@ -83,7 +133,7 @@ nf.Settings = (function () {
$('#settings-save').off('click').on('click', function () {
saveSettings(response.revision.version);
});
}).fail(nf.ErrorHandler.handleAjaxError);
}).fail(errorHandler.handleAjaxError);
}
/**
@ -161,7 +211,7 @@ nf.Settings = (function () {
* @param item reporting task type
*/
var isSelectable = function (item) {
return nf.Common.isBlank(item.usageRestriction) || nf.Common.canAccessRestrictedComponents();
return common.isBlank(item.usageRestriction) || common.canAccessRestrictedComponents();
};
/**
@ -197,7 +247,7 @@ nf.Settings = (function () {
return '';
}
return nf.Common.substringAfterLast(dataContext.component.type, '.');
return common.substringAfterLast(dataContext.component.type, '.');
};
/**
@ -209,41 +259,41 @@ nf.Settings = (function () {
var sort = function (sortDetails, data) {
// defines a function for sorting
var comparer = function (a, b) {
if(a.permissions.canRead && b.permissions.canRead) {
if (a.permissions.canRead && b.permissions.canRead) {
if (sortDetails.columnId === 'moreDetails') {
var aBulletins = 0;
if (!nf.Common.isEmpty(a.bulletins)) {
if (!common.isEmpty(a.bulletins)) {
aBulletins = a.bulletins.length;
}
var bBulletins = 0;
if (!nf.Common.isEmpty(b.bulletins)) {
if (!common.isEmpty(b.bulletins)) {
bBulletins = b.bulletins.length;
}
return aBulletins - bBulletins;
} else if (sortDetails.columnId === 'type') {
var aType = nf.Common.isDefinedAndNotNull(a.component[sortDetails.columnId]) ? nf.Common.substringAfterLast(a.component[sortDetails.columnId], '.') : '';
var bType = nf.Common.isDefinedAndNotNull(b.component[sortDetails.columnId]) ? nf.Common.substringAfterLast(b.component[sortDetails.columnId], '.') : '';
var aType = common.isDefinedAndNotNull(a.component[sortDetails.columnId]) ? common.substringAfterLast(a.component[sortDetails.columnId], '.') : '';
var bType = common.isDefinedAndNotNull(b.component[sortDetails.columnId]) ? common.substringAfterLast(b.component[sortDetails.columnId], '.') : '';
return aType === bType ? 0 : aType > bType ? 1 : -1;
} else if (sortDetails.columnId === 'state') {
var aState = 'Invalid';
if (nf.Common.isEmpty(a.component.validationErrors)) {
aState = nf.Common.isDefinedAndNotNull(a.component[sortDetails.columnId]) ? a.component[sortDetails.columnId] : '';
if (common.isEmpty(a.component.validationErrors)) {
aState = common.isDefinedAndNotNull(a.component[sortDetails.columnId]) ? a.component[sortDetails.columnId] : '';
}
var bState = 'Invalid';
if (nf.Common.isEmpty(b.component.validationErrors)) {
bState = nf.Common.isDefinedAndNotNull(b.component[sortDetails.columnId]) ? b.component[sortDetails.columnId] : '';
if (common.isEmpty(b.component.validationErrors)) {
bState = common.isDefinedAndNotNull(b.component[sortDetails.columnId]) ? b.component[sortDetails.columnId] : '';
}
return aState === bState ? 0 : aState > bState ? 1 : -1;
} else {
var aString = nf.Common.isDefinedAndNotNull(a.component[sortDetails.columnId]) ? a.component[sortDetails.columnId] : '';
var bString = nf.Common.isDefinedAndNotNull(b.component[sortDetails.columnId]) ? b.component[sortDetails.columnId] : '';
var aString = common.isDefinedAndNotNull(a.component[sortDetails.columnId]) ? a.component[sortDetails.columnId] : '';
var bString = common.isDefinedAndNotNull(b.component[sortDetails.columnId]) ? b.component[sortDetails.columnId] : '';
return aString === bString ? 0 : aString > bString ? 1 : -1;
}
} else {
if (!a.permissions.canRead && !b.permissions.canRead){
if (!a.permissions.canRead && !b.permissions.canRead) {
return 0;
}
if(a.permissions.canRead){
if (a.permissions.canRead) {
return 1;
} else {
return -1;
@ -272,7 +322,7 @@ nf.Settings = (function () {
var reportingTaskTypesGrid = $('#reporting-task-types-table').data('gridInstance');
// ensure the grid has been initialized
if (nf.Common.isDefinedAndNotNull(reportingTaskTypesGrid)) {
if (common.isDefinedAndNotNull(reportingTaskTypesGrid)) {
var reportingTaskTypesData = reportingTaskTypesGrid.getData();
// update the search criteria
@ -354,7 +404,7 @@ nf.Settings = (function () {
// ensure something was selected
if (selectedTaskType === '') {
nf.Dialog.showOkDialog({
dialog.showOkDialog({
headerText: 'Settings',
dialogContent: 'The type of reporting task to create must be selected.'
});
@ -371,7 +421,7 @@ nf.Settings = (function () {
var addReportingTask = function (reportingTaskType) {
// build the reporting task entity
var reportingTaskEntity = {
'revision': nf.Client.getRevision({
'revision': client.getRevision({
'revision': {
'version': 0
}
@ -402,7 +452,7 @@ nf.Settings = (function () {
var row = reportingTaskData.getRowById(reportingTaskEntity.id);
reportingTaskGrid.setSelectedRows([row]);
reportingTaskGrid.scrollRowIntoView(row);
}).fail(nf.ErrorHandler.handleAjaxError);
}).fail(errorHandler.handleAjaxError);
// hide the dialog
$('#new-reporting-task-dialog').modal('hide');
@ -440,7 +490,7 @@ nf.Settings = (function () {
id: 'type',
name: 'Type',
field: 'label',
formatter: nf.Common.typeFormatter,
formatter: common.typeFormatter,
sortable: false,
resizable: true
},
@ -474,11 +524,11 @@ nf.Settings = (function () {
var reportingTaskType = reportingTaskTypesGrid.getDataItem(reportingTaskTypeIndex);
// set the reporting task type description
if (nf.Common.isDefinedAndNotNull(reportingTaskType)) {
if (common.isDefinedAndNotNull(reportingTaskType)) {
// show the selected reporting task
$('#reporting-task-description-container').show();
if (nf.Common.isBlank(reportingTaskType.description)) {
if (common.isBlank(reportingTaskType.description)) {
$('#reporting-task-type-description')
.attr('title', '')
.html('<span class="unset">No description specified</span>');
@ -507,7 +557,7 @@ nf.Settings = (function () {
}
});
reportingTaskTypesGrid.onViewportChanged.subscribe(function (e, args) {
nf.Common.cleanUpTooltips($('#reporting-task-types-table'), 'div.view-usage-restriction');
common.cleanUpTooltips($('#reporting-task-types-table'), 'div.view-usage-restriction');
});
// wire up the dataview to the grid
@ -534,8 +584,8 @@ nf.Settings = (function () {
var item = reportingTaskTypesData.getItemById(rowId);
// show the tooltip
if (nf.Common.isDefinedAndNotNull(item.usageRestriction)) {
usageRestriction.qtip($.extend({}, nf.Common.config.tooltipConfig, {
if (common.isDefinedAndNotNull(item.usageRestriction)) {
usageRestriction.qtip($.extend({}, common.config.tooltipConfig, {
content: item.usageRestriction,
position: {
container: $('#summary'),
@ -568,10 +618,10 @@ nf.Settings = (function () {
// add the documented type
reportingTaskTypesData.addItem({
id: id++,
label: nf.Common.substringAfterLast(documentedType.type, '.'),
label: common.substringAfterLast(documentedType.type, '.'),
type: documentedType.type,
description: nf.Common.escapeHtml(documentedType.description),
usageRestriction: nf.Common.escapeHtml(documentedType.usageRestriction),
description: common.escapeHtml(documentedType.description),
usageRestriction: common.escapeHtml(documentedType.usageRestriction),
tags: documentedType.tags.join(', ')
});
@ -593,36 +643,36 @@ nf.Settings = (function () {
select: applyReportingTaskTypeFilter,
remove: applyReportingTaskTypeFilter
});
}).fail(nf.ErrorHandler.handleAjaxError);
}).fail(errorHandler.handleAjaxError);
// initialize the reporting task dialog
$('#new-reporting-task-dialog').modal({
scrollableContentStyle: 'scrollable',
headerText: 'Add Reporting Task',
buttons: [{
buttonText: 'Add',
color: {
base: '#728E9B',
hover: '#004849',
text: '#ffffff'
},
disabled: function () {
var selected = reportingTaskTypesGrid.getSelectedRows();
buttonText: 'Add',
color: {
base: '#728E9B',
hover: '#004849',
text: '#ffffff'
},
disabled: function () {
var selected = reportingTaskTypesGrid.getSelectedRows();
if (selected.length > 0) {
// grid configured with multi-select = false
var item = reportingTaskTypesGrid.getDataItem(selected[0]);
return isSelectable(item) === false;
} else {
return reportingTaskTypesGrid.getData().getLength() === 0;
}
},
handler: {
click: function () {
addSelectedReportingTask();
}
if (selected.length > 0) {
// grid configured with multi-select = false
var item = reportingTaskTypesGrid.getDataItem(selected[0]);
return isSelectable(item) === false;
} else {
return reportingTaskTypesGrid.getData().getLength() === 0;
}
},
handler: {
click: function () {
addSelectedReportingTask();
}
}
},
{
buttonText: 'Cancel',
color: {
@ -682,8 +732,8 @@ nf.Settings = (function () {
// always include a button to view the usage
markup += '<div title="Usage" class="pointer reporting-task-usage fa fa-book"></div>';
var hasErrors = !nf.Common.isEmpty(dataContext.component.validationErrors);
var hasBulletins = !nf.Common.isEmpty(dataContext.bulletins);
var hasErrors = !common.isEmpty(dataContext.component.validationErrors);
var hasBulletins = !common.isEmpty(dataContext.bulletins);
if (hasErrors) {
markup += '<div class="pointer has-errors fa fa-warning" ></div>';
@ -694,7 +744,7 @@ nf.Settings = (function () {
}
if (hasErrors || hasBulletins) {
markup += '<span class="hidden row-id">' + nf.Common.escapeHtml(dataContext.component.id) + '</span>';
markup += '<span class="hidden row-id">' + common.escapeHtml(dataContext.component.id) + '</span>';
}
return markup;
@ -707,7 +757,7 @@ nf.Settings = (function () {
// determine the appropriate label
var icon = '', label = '';
if (!nf.Common.isEmpty(dataContext.component.validationErrors)) {
if (!common.isEmpty(dataContext.component.validationErrors)) {
label = 'Invalid';
icon = 'invalid fa fa-warning';
} else {
@ -725,13 +775,13 @@ nf.Settings = (function () {
// include the active thread count if appropriate
var activeThreadCount = '';
if (nf.Common.isDefinedAndNotNull(dataContext.component.activeThreadCount) && dataContext.component.activeThreadCount > 0) {
if (common.isDefinedAndNotNull(dataContext.component.activeThreadCount) && dataContext.component.activeThreadCount > 0) {
activeThreadCount = '(' + dataContext.component.activeThreadCount + ')';
}
// format the markup
var formattedValue = '<div layout="row"><div class="' + icon + '" style="margin-top: 3px;"></div>';
return formattedValue + '<div class="status-text" style="margin-top: 4px;">' + nf.Common.escapeHtml(label) + '</div><div style="float: left; margin-left: 4px;">' + nf.Common.escapeHtml(activeThreadCount) + '</div></div>';
return formattedValue + '<div class="status-text" style="margin-top: 4px;">' + common.escapeHtml(label) + '</div><div style="float: left; margin-left: 4px;">' + common.escapeHtml(activeThreadCount) + '</div></div>';
};
var reportingTaskActionFormatter = function (row, cell, value, columnDef, dataContext) {
@ -744,7 +794,7 @@ nf.Settings = (function () {
markup += '<div title="Edit" class="pointer edit-reporting-task fa fa-pencil" style="margin-top: 2px; margin-right: 3px;" ></div>';
// support starting when stopped and no validation errors
if (dataContext.component.state === 'STOPPED' && nf.Common.isEmpty(dataContext.component.validationErrors)) {
if (dataContext.component.state === 'STOPPED' && common.isEmpty(dataContext.component.validationErrors)) {
markup += '<div title="Start" class="pointer start-reporting-task fa fa-play" style="margin-top: 2px; margin-right: 3px;"></div>';
}
}
@ -754,12 +804,12 @@ nf.Settings = (function () {
}
}
if (dataContext.permissions.canWrite && nf.Common.canModifyController()) {
if (dataContext.permissions.canWrite && common.canModifyController()) {
markup += '<div title="Remove" class="pointer delete-reporting-task fa fa-trash" style="margin-top: 2px; margin-right: 3px;" ></div>';
}
// allow policy configuration conditionally
if (nf.Canvas.isConfigurableAuthorizer() && nf.Common.canAccessTenants()) {
if (canvasUtils.isConfigurableAuthorizer() && common.canAccessTenants()) {
markup += '<div title="Access Policies" class="pointer edit-access-policies fa fa-key" style="margin-top: 2px;"></div>';
}
@ -768,14 +818,37 @@ nf.Settings = (function () {
// define the column model for the reporting tasks table
var reportingTasksColumnModel = [
{id: 'moreDetails', name: '&nbsp;', resizable: false, formatter: moreReportingTaskDetails, sortable: true, width: 90, maxWidth: 90, toolTip: 'Sorts based on presence of bulletins'},
{
id: 'moreDetails',
name: '&nbsp;',
resizable: false,
formatter: moreReportingTaskDetails,
sortable: true,
width: 90,
maxWidth: 90,
toolTip: 'Sorts based on presence of bulletins'
},
{id: 'name', name: 'Name', sortable: true, resizable: true, formatter: nameFormatter},
{id: 'type', name: 'Type', sortable: true, resizable: true, formatter: typeFormatter},
{id: 'state', name: 'Run Status', sortable: true, resizeable: true, formatter: reportingTaskRunStatusFormatter}
{
id: 'state',
name: 'Run Status',
sortable: true,
resizeable: true,
formatter: reportingTaskRunStatusFormatter
}
];
// action column should always be last
reportingTasksColumnModel.push({id: 'actions', name: '&nbsp;', resizable: false, formatter: reportingTaskActionFormatter, sortable: false, width: 90, maxWidth: 90});
reportingTasksColumnModel.push({
id: 'actions',
name: '&nbsp;',
resizable: false,
formatter: reportingTaskActionFormatter,
sortable: false,
width: 90,
maxWidth: 90
});
// initialize the dataview
var reportingTasksData = new Slick.Data.DataView({
@ -811,35 +884,35 @@ nf.Settings = (function () {
// determine the desired action
if (reportingTasksGrid.getColumns()[args.cell].id === 'actions') {
if (target.hasClass('edit-reporting-task')) {
nf.ReportingTask.showConfiguration(reportingTaskEntity);
reportingTask.showConfiguration(reportingTaskEntity);
} else if (target.hasClass('start-reporting-task')) {
nf.ReportingTask.start(reportingTaskEntity);
reportingTask.start(reportingTaskEntity);
} else if (target.hasClass('stop-reporting-task')) {
nf.ReportingTask.stop(reportingTaskEntity);
reportingTask.stop(reportingTaskEntity);
} else if (target.hasClass('delete-reporting-task')) {
nf.ReportingTask.promptToDeleteReportingTask(reportingTaskEntity);
reportingTask.promptToDeleteReportingTask(reportingTaskEntity);
} else if (target.hasClass('view-state-reporting-task')) {
var canClear = reportingTaskEntity.component.state === 'STOPPED' && reportingTaskEntity.component.activeThreadCount === 0;
nf.ComponentState.showState(reportingTaskEntity, canClear);
componentState.showState(reportingTaskEntity, canClear);
} else if (target.hasClass('edit-access-policies')) {
// show the policies for this service
nf.PolicyManagement.showReportingTaskPolicy(reportingTaskEntity);
policyManagement.showReportingTaskPolicy(reportingTaskEntity);
// close the settings dialog
$('#shell-close-button').click();
}
} else if (reportingTasksGrid.getColumns()[args.cell].id === 'moreDetails') {
if (target.hasClass('view-reporting-task')) {
nf.ReportingTask.showDetails(reportingTaskEntity);
reportingTask.showDetails(reportingTaskEntity);
} else if (target.hasClass('reporting-task-usage')) {
// close the settings dialog
$('#shell-close-button').click();
// open the documentation for this reporting task
nf.Shell.showPage('../nifi-docs/documentation?' + $.param({
select: nf.Common.substringAfterLast(reportingTaskEntity.component.type, '.')
shell.showPage('../nifi-docs/documentation?' + $.param({
select: common.substringAfterLast(reportingTaskEntity.component.type, '.')
})).done(function () {
nf.Settings.showSettings();
nfSettings.showSettings();
});
}
}
@ -866,12 +939,12 @@ nf.Settings = (function () {
var reportingTaskEntity = reportingTasksData.getItemById(taskId);
// format the errors
var tooltip = nf.Common.formatUnorderedList(reportingTaskEntity.component.validationErrors);
var tooltip = common.formatUnorderedList(reportingTaskEntity.component.validationErrors);
// show the tooltip
if (nf.Common.isDefinedAndNotNull(tooltip)) {
if (common.isDefinedAndNotNull(tooltip)) {
errorIcon.qtip($.extend({},
nf.Common.config.tooltipConfig,
common.config.tooltipConfig,
{
content: tooltip,
position: {
@ -895,13 +968,13 @@ nf.Settings = (function () {
var reportingTaskEntity = reportingTasksData.getItemById(taskId);
// format the tooltip
var bulletins = nf.Common.getFormattedBulletins(reportingTaskEntity.bulletins);
var tooltip = nf.Common.formatUnorderedList(bulletins);
var bulletins = common.getFormattedBulletins(reportingTaskEntity.bulletins);
var tooltip = common.formatUnorderedList(bulletins);
// show the tooltip
if (nf.Common.isDefinedAndNotNull(tooltip)) {
if (common.isDefinedAndNotNull(tooltip)) {
bulletinIcon.qtip($.extend({},
nf.Common.config.tooltipConfig,
common.config.tooltipConfig,
{
content: tooltip,
position: {
@ -927,7 +1000,7 @@ nf.Settings = (function () {
$('#read-only-maximum-timer-driven-thread-count-field').addClass('unset').text('Unauthorized');
$('#read-only-maximum-event-driven-thread-count-field').addClass('unset').text('Unauthorized');
};
var setEditable = function (editable) {
if (editable) {
$('#general-settings div.editable').show();
@ -939,7 +1012,7 @@ nf.Settings = (function () {
$('#settings-save').hide();
}
};
var settings = $.Deferred(function (deferred) {
$.ajax({
type: 'GET',
@ -979,21 +1052,21 @@ nf.Settings = (function () {
}
});
}).promise();
// load the controller services
var controllerServicesUri = config.urls.api + '/flow/controller/controller-services';
var controllerServices = nf.ControllerServices.loadControllerServices(controllerServicesUri, getControllerServicesTable());
var controllerServicesXhr = controllerServices.loadControllerServices(controllerServicesUri, getControllerServicesTable());
// load the reporting tasks
var reportingTasks = loadReportingTasks();
// return a deferred for all parts of the settings
return $.when(settings, controllerServices, reportingTasks).done(function (settingsResult, controllerServicesResult) {
return $.when(settings, controllerServicesXhr, reportingTasks).done(function (settingsResult, controllerServicesResult) {
var controllerServicesResponse = controllerServicesResult[0];
// update the current time
$('#settings-last-refreshed').text(controllerServicesResponse.currentTime);
}).fail(nf.ErrorHandler.handleAjaxError);
}).fail(errorHandler.handleAjaxError);
};
/**
@ -1013,8 +1086,8 @@ nf.Settings = (function () {
});
var reportingTasksElement = $('#reporting-tasks-table');
nf.Common.cleanUpTooltips(reportingTasksElement, 'div.has-errors');
nf.Common.cleanUpTooltips(reportingTasksElement, 'div.has-bulletins');
common.cleanUpTooltips(reportingTasksElement, 'div.has-errors');
common.cleanUpTooltips(reportingTasksElement, 'div.has-bulletins');
var reportingTasksGrid = reportingTasksElement.data('gridInstance');
var reportingTasksData = reportingTasksGrid.getData();
@ -1031,7 +1104,7 @@ nf.Settings = (function () {
*/
var showSettings = function () {
// show the settings dialog
nf.Shell.showContent('#settings').done(function () {
shell.showContent('#settings').done(function () {
reset();
});
@ -1039,7 +1112,7 @@ nf.Settings = (function () {
$('#settings-tabs').find('.selected-tab').click();
// adjust the table size
nf.Settings.resetTableSize();
nfSettings.resetTableSize();
};
/**
@ -1050,7 +1123,7 @@ nf.Settings = (function () {
$('#settings-save').mouseout();
};
return {
var nfSettings = {
/**
* Initializes the settings page.
*/
@ -1077,9 +1150,9 @@ nf.Settings = (function () {
$('#settings-save').show();
} else {
var canModifyController = false;
if (nf.Common.isDefinedAndNotNull(nf.Common.currentUser)) {
if (common.isDefinedAndNotNull(common.currentUser)) {
// only consider write permissions for creating new controller services/reporting tasks
canModifyController = nf.Common.currentUser.controllerPermissions.canWrite === true;
canModifyController = common.currentUser.controllerPermissions.canWrite === true;
}
if (canModifyController) {
@ -1102,7 +1175,7 @@ nf.Settings = (function () {
}
// resize the table
nf.Settings.resetTableSize();
nfSettings.resetTableSize();
}
}
});
@ -1117,13 +1190,13 @@ nf.Settings = (function () {
var selectedTab = $('#settings-tabs li.selected-tab').text();
if (selectedTab === 'Controller Services') {
var controllerServicesUri = config.urls.api + '/controller/controller-services';
nf.ControllerServices.promptNewControllerService(controllerServicesUri, getControllerServicesTable());
controllerServices.promptNewControllerService(controllerServicesUri, getControllerServicesTable());
} else if (selectedTab === 'Reporting Tasks') {
$('#new-reporting-task-dialog').modal('show');
// reset the canvas size after the dialog is shown
var reportingTaskTypesGrid = $('#reporting-task-types-table').data('gridInstance');
if (nf.Common.isDefinedAndNotNull(reportingTaskTypesGrid)) {
if (common.isDefinedAndNotNull(reportingTaskTypesGrid)) {
reportingTaskTypesGrid.setSelectedRows([0]);
reportingTaskTypesGrid.resizeCanvas();
}
@ -1132,10 +1205,10 @@ nf.Settings = (function () {
$('#reporting-task-type-filter').focus();
}
});
// initialize each tab
initGeneral();
nf.ControllerServices.init(getControllerServicesTable());
controllerServices.init(getControllerServicesTable(), nfSettings.showSettings);
initReportingTasks();
},
@ -1143,10 +1216,10 @@ nf.Settings = (function () {
* Update the size of the grid based on its container's current size.
*/
resetTableSize: function () {
nf.ControllerServices.resetTableSize(getControllerServicesTable());
controllerServices.resetTableSize(getControllerServicesTable());
var reportingTasksGrid = $('#reporting-tasks-table').data('gridInstance');
if (nf.Common.isDefinedAndNotNull(reportingTasksGrid)) {
if (common.isDefinedAndNotNull(reportingTasksGrid)) {
reportingTasksGrid.resizeCanvas();
}
},
@ -1167,7 +1240,7 @@ nf.Settings = (function () {
/**
* Selects the specified controller service.
*
*
* @param {string} controllerServiceId
*/
selectControllerService: function (controllerServiceId) {
@ -1180,7 +1253,7 @@ nf.Settings = (function () {
controllerServiceGrid.scrollRowIntoView(row);
// select the controller services tab
$('#settings-tabs').find('li:eq(1)').click();
$('#settings-tabs').find('li:eq(1)').click();
},
/**
@ -1189,9 +1262,9 @@ nf.Settings = (function () {
* @param {object} controllerServiceBulletins
* @param {object} reportingTaskBulletins
*/
setBulletins: function(controllerServiceBulletins, reportingTaskBulletins) {
setBulletins: function (controllerServiceBulletins, reportingTaskBulletins) {
if ($('#controller-services-table').data('gridInstance')) {
nf.ControllerServices.setBulletins(getControllerServicesTable(), controllerServiceBulletins);
controllerServices.setBulletins(getControllerServicesTable(), controllerServiceBulletins);
}
// reporting tasks
@ -1200,7 +1273,7 @@ nf.Settings = (function () {
reportingTasksData.beginUpdate();
// if there are some bulletins process them
if (!nf.Common.isEmpty(reportingTaskBulletins)) {
if (!common.isEmpty(reportingTaskBulletins)) {
var reportingTaskBulletinsBySource = d3.nest()
.key(function (d) {
return d.sourceId;
@ -1209,7 +1282,7 @@ nf.Settings = (function () {
reportingTaskBulletinsBySource.forEach(function (sourceId, sourceBulletins) {
var reportingTask = reportingTasksData.getItemById(sourceId);
if (nf.Common.isDefinedAndNotNull(reportingTask)) {
if (common.isDefinedAndNotNull(reportingTask)) {
reportingTasksData.updateItem(sourceId, $.extend(reportingTask, {
bulletins: sourceBulletins
}));
@ -1227,4 +1300,6 @@ nf.Settings = (function () {
reportingTasksData.endUpdate();
}
};
}());
return nfSettings;
}));

View File

@ -15,9 +15,31 @@
* limitations under the License.
*/
/* global nf, d3 */
/* global define, module, require, exports */
nf.Snippet = (function () {
(function (root, factory) {
if (typeof define === 'function' && define.amd) {
define(['jquery',
'd3',
'nf.CanvasUtils',
'nf.Client'],
function ($, d3, canvasUtils, client) {
return (nf.Snippet = factory($, d3, canvasUtils, client));
});
} else if (typeof exports === 'object' && typeof module === 'object') {
module.exports = (nf.Snippet =
factory(require('jquery'),
require('d3'),
require('nf.CanvasUtils'),
require('nf.Client')));
} else {
nf.Snippet = factory(root.$,
root.d3,
root.nf.CanvasUtils,
root.nf.Client);
}
}(this, function ($, d3, canvasUtils, client) {
'use strict';
var config = {
urls: {
@ -27,14 +49,15 @@ nf.Snippet = (function () {
};
return {
/**
* Marshals snippet from the specified selection.
*
*
* @argument {selection} selection The selection to marshal
*/
marshal: function (selection) {
var snippet = {
parentGroupId: nf.Canvas.getGroupId(),
parentGroupId: canvasUtils.getGroupId(),
processors: {},
funnels: {},
inputPorts: {},
@ -49,31 +72,31 @@ nf.Snippet = (function () {
selection.each(function (d) {
var selected = d3.select(this);
if (nf.CanvasUtils.isProcessor(selected)) {
snippet.processors[d.id] = nf.Client.getRevision(selected.datum());
} else if (nf.CanvasUtils.isFunnel(selected)) {
snippet.funnels[d.id] = nf.Client.getRevision(selected.datum());
} else if (nf.CanvasUtils.isLabel(selected)) {
snippet.labels[d.id] = nf.Client.getRevision(selected.datum());
} else if (nf.CanvasUtils.isInputPort(selected)) {
snippet.inputPorts[d.id] = nf.Client.getRevision(selected.datum());
} else if (nf.CanvasUtils.isOutputPort(selected)) {
snippet.outputPorts[d.id] = nf.Client.getRevision(selected.datum());
} else if (nf.CanvasUtils.isProcessGroup(selected)) {
snippet.processGroups[d.id] = nf.Client.getRevision(selected.datum());
} else if (nf.CanvasUtils.isRemoteProcessGroup(selected)) {
snippet.remoteProcessGroups[d.id] = nf.Client.getRevision(selected.datum());
} else if (nf.CanvasUtils.isConnection(selected)) {
snippet.connections[d.id] = nf.Client.getRevision(selected.datum());
if (canvasUtils.isProcessor(selected)) {
snippet.processors[d.id] = client.getRevision(selected.datum());
} else if (canvasUtils.isFunnel(selected)) {
snippet.funnels[d.id] = client.getRevision(selected.datum());
} else if (canvasUtils.isLabel(selected)) {
snippet.labels[d.id] = client.getRevision(selected.datum());
} else if (canvasUtils.isInputPort(selected)) {
snippet.inputPorts[d.id] = client.getRevision(selected.datum());
} else if (canvasUtils.isOutputPort(selected)) {
snippet.outputPorts[d.id] = client.getRevision(selected.datum());
} else if (canvasUtils.isProcessGroup(selected)) {
snippet.processGroups[d.id] = client.getRevision(selected.datum());
} else if (canvasUtils.isRemoteProcessGroup(selected)) {
snippet.remoteProcessGroups[d.id] = client.getRevision(selected.datum());
} else if (canvasUtils.isConnection(selected)) {
snippet.connections[d.id] = client.getRevision(selected.datum());
}
});
return snippet;
},
/**
* Creates a snippet.
*
*
* @argument {object} snippet The snippet
*/
create: function (snippet) {
@ -89,10 +112,10 @@ nf.Snippet = (function () {
contentType: 'application/json'
});
},
/**
* Copies the snippet to the specified group and origin.
*
*
* @argument {string} snippetId The snippet id
* @argument {object} origin The origin
*/
@ -105,16 +128,16 @@ nf.Snippet = (function () {
return $.ajax({
type: 'POST',
url: config.urls.processGroups + '/' + encodeURIComponent(nf.Canvas.getGroupId()) + '/snippet-instance',
url: config.urls.processGroups + '/' + encodeURIComponent(canvasUtils.getGroupId()) + '/snippet-instance',
data: JSON.stringify(copySnippetRequestEntity),
dataType: 'json',
contentType: 'application/json'
});
},
/**
* Removes the specified snippet.
*
*
* @argument {string} snippetId The snippet id
*/
remove: function (snippetId) {
@ -123,10 +146,10 @@ nf.Snippet = (function () {
url: config.urls.snippets + '/' + encodeURIComponent(snippetId)
});
},
/**
* Moves the snippet into the specified group.
*
*
* @argument {string} snippetId The snippet id
* @argument {string} newGroupId The new group id
*/
@ -147,4 +170,4 @@ nf.Snippet = (function () {
});
}
};
}());
}));

View File

@ -15,7 +15,7 @@
* limitations under the License.
*/
/* global nf, define, module, require, exports */
/* global define, module, require, exports */
(function (root, factory) {
if (typeof define === 'function' && define.amd) {

View File

@ -15,7 +15,7 @@
* limitations under the License.
*/
/* global nf, top, define, module, require, exports */
/* global top, define, module, require, exports */
(function (root, factory) {
if (typeof define === 'function' && define.amd) {

View File

@ -15,7 +15,7 @@
* limitations under the License.
*/
/* global nf, define, module, require, exports */
/* global define, module, require, exports */
(function (root, factory) {
if (typeof define === 'function' && define.amd) {

View File

@ -15,7 +15,7 @@
* limitations under the License.
*/
/* global nf, top, define, module, require, exports */
/* global top, define, module, require, exports */
(function (root, factory) {
if (typeof define === 'function' && define.amd) {

View File

@ -15,7 +15,7 @@
* limitations under the License.
*/
/* global nf, define, module, require, exports */
/* global define, module, require, exports */
(function (root, factory) {
if (typeof define === 'function' && define.amd) {

View File

@ -15,7 +15,7 @@
* limitations under the License.
*/
/* global nf, top, define, module, require, exports */
/* global top, define, module, require, exports */
(function (root, factory) {
if (typeof define === 'function' && define.amd) {

View File

@ -15,7 +15,7 @@
* limitations under the License.
*/
/* global nf, top, define, module, require, exports */
/* global top, define, module, require, exports */
(function (root, factory) {
if (typeof define === 'function' && define.amd) {

View File

@ -15,7 +15,7 @@
* limitations under the License.
*/
/* global nf, top, define, module, require, exports */
/* global top, define, module, require, exports */
(function (root, factory) {
if (typeof define === 'function' && define.amd) {
@ -33,7 +33,10 @@
require('nf.Dialog'),
require('nf.Storage')));
} else {
nf.Login = factory(root.$, root.nf.Common, root.nf.Dialog, root.nf.Storage);
nf.Login = factory(root.$,
root.nf.Common,
root.nf.Dialog,
root.nf.Storage);
}
}(this, function ($, common, dialog, storage) {
'use strict';

View File

@ -15,7 +15,7 @@
* limitations under the License.
*/
/* global nf, define, module, require, exports */
/* global define, module, require, exports */
(function (root, factory) {
if (typeof define === 'function' && define.amd) {

View File

@ -15,7 +15,7 @@
* limitations under the License.
*/
/* global nf, define, module, require, exports */
/* global define, module, require, exports */
(function (root, factory) {
if (typeof define === 'function' && define.amd) {

View File

@ -15,7 +15,7 @@
* limitations under the License.
*/
/* global nf, define, module, require, exports */
/* global define, module, require, exports */
(function (root, factory) {
if (typeof define === 'function' && define.amd) {

View File

@ -15,24 +15,27 @@
* limitations under the License.
*/
/* global nf, define, module, require, exports, parseFloat */
/* global define, module, require, exports, parseFloat */
// Define a common utility class used across the entire application.
(function (root, factory) {
if (typeof define === 'function' && define.amd) {
define(['jquery',
'd3',
'nf.Storage'],
function ($, storage) {
return (nf.Common = factory($, storage));
function ($, d3, storage) {
return (nf.Common = factory($, d3, storage));
});
} else if (typeof exports === 'object' && typeof module === 'object') {
module.exports = (nf.Common = factory(require('jquery'),
require('d3'),
require('nf.Storage')));
} else {
nf.Common = factory(root.$,
root.d3,
root.nf.Storage);
}
}(this, function ($, storage) {
}(this, function ($, d3, storage) {
'use strict';
$(document).ready(function () {

View File

@ -15,7 +15,7 @@
* limitations under the License.
*/
/* global nf, define, module, require, exports */
/* global define, module, require, exports */
(function (root, factory) {
if (typeof define === 'function' && define.amd) {

View File

@ -15,7 +15,7 @@
* limitations under the License.
*/
/* global nf, define, module, require, exports */
/* global define, module, require, exports */
(function (root, factory) {
if (typeof define === 'function' && define.amd) {

View File

@ -15,7 +15,7 @@
* limitations under the License.
*/
/* global nf, define, module, require, exports */
/* global define, module, require, exports */
(function (root, factory) {
if (typeof define === 'function' && define.amd) {

View File

@ -15,7 +15,7 @@
* limitations under the License.
*/
/* global nf, define, module, require, exports */
/* global define, module, require, exports */
(function (root, factory) {
if (typeof define === 'function' && define.amd) {

View File

@ -15,28 +15,47 @@
* limitations under the License.
*/
/* global nf, define, module, require, exports */
/* global define, module, require, exports */
(function (root, factory) {
if (typeof define === 'function' && define.amd) {
define(['nf.ng.Bridge'],
function (angularBridge) {
return (nf.ng.AppCtrl = factory(angularBridge));
define(['nf.ng.Bridge',
'nf.Common',
'nf.CanvasUtils',
'nf.ClusterSummary',
'nf.Actions'],
function (angularBridge, canvasUtils, common, clusterSummary, actions) {
return (nf.ng.AppCtrl = factory(angularBridge, canvasUtils, common, clusterSummary, actions));
});
} else if (typeof exports === 'object' && typeof module === 'object') {
module.exports = (nf.ng.AppCtrl = factory(require('nf.ng.Bridge')));
module.exports = (nf.ng.AppCtrl =
factory(require('nf.ng.Bridge'),
require('nf.CanvasUtils'),
require('nf.Common'),
require('nf.ClusterSummary'),
require('nf.Actions')));
} else {
nf.ng.AppCtrl = factory(root.nf.ng.Bridge);
nf.ng.AppCtrl = factory(root.nf.ng.Bridge,
root.nf.CanvasUtils,
root.nf.Common,
root.nf.ClusterSummary,
root.nf.Actions);
}
}(this, function (angularBridge) {
}(this, function (angularBridge, canvasUtils, common, clusterSummary, actions) {
'use strict';
return function ($scope, serviceProvider) {
'use strict';
function AppCtrl(serviceProvider) {
//global nf namespace for reference throughout angular app
this.nf = nf;
//add essential modules to the scope for availability throughout the angular container
this.nf = {
"Common": common,
"ClusterSummary": clusterSummary,
"Actions": actions,
"CanvasUtils": canvasUtils,
};
//any registered angular service is available through the serviceProvider
this.serviceProvider = serviceProvider;
}

View File

@ -15,7 +15,7 @@
* limitations under the License.
*/
/* global nf, define, module, require, exports */
/* global define, module, require, exports */
(function (root, factory) {
if (typeof define === 'function' && define.amd) {

View File

@ -15,7 +15,7 @@
* limitations under the License.
*/
/* global nf, define, module, require, exports */
/* global define, module, require, exports */
(function (root, factory) {
if (typeof define === 'function' && define.amd) {

View File

@ -15,7 +15,7 @@
* limitations under the License.
*/
/* global nf, define, module, require, exports */
/* global define, module, require, exports */
(function (root, factory) {
if (typeof define === 'function' && define.amd) {

View File

@ -15,26 +15,23 @@
* limitations under the License.
*/
/* global nf, define, module, require, exports */
/* global define, module, require, exports */
(function (root, factory) {
if (typeof define === 'function' && define.amd) {
define(['jquery',
'nf.Common',
'nf.ContextMenu'],
function ($, common, contextMenu) {
return (nf.Shell = factory($, common, contextMenu));
'nf.Common'],
function ($, common) {
return (nf.Shell = factory($, common));
});
} else if (typeof exports === 'object' && typeof module === 'object') {
module.exports = (nf.Shell = factory(require('jquery'),
require('nf.Common'),
require('nf.ContextMenu')));
require('nf.Common')));
} else {
nf.Shell = factory(root.$,
root.nf.Common,
root.nf.ContextMenu);
root.nf.Common);
}
}(this, function ($, common, contextMenu) {
}(this, function ($, common) {
'use strict';
$(document).ready(function () {
@ -70,9 +67,19 @@
var showPageResize = null;
var showContentResize = null;
var nfContextMenu = null;
return {
/**
* Initialize the shell.
*
* @param contextMenu The reference to the contextMenu controller.
*/
init: function (contextMenu) {
nfContextMenu = contextMenu;
},
resizeContent: function (shell) {
var contentContainer = shell.find('.shell-content-container');
contentContainer.css({
@ -100,8 +107,8 @@
*/
showPage: function (uri, canUndock) {
// if the context menu is on this page, attempt to close
if (common.isDefinedAndNotNull(contextMenu)) {
contextMenu.hide();
if (common.isDefinedAndNotNull(nfContextMenu)) {
nfContextMenu.hide();
}
return $.Deferred(function (deferred) {
@ -154,8 +161,8 @@
*/
showContent: function (domId) {
// if the context menu is on this page, attempt to close
if (common.isDefinedAndNotNull(contextMenu)) {
contextMenu.hide();
if (common.isDefinedAndNotNull(nfContextMenu)) {
nfContextMenu.hide();
}
return $.Deferred(function (deferred) {

View File

@ -15,7 +15,7 @@
* limitations under the License.
*/
/* global nf, define, module, require, exports */
/* global define, module, require, exports */
(function (root, factory) {
if (typeof define === 'function' && define.amd) {

View File

@ -15,7 +15,7 @@
* limitations under the License.
*/
/* global nf, define, module, require, exports */
/* global define, module, require, exports */
(function (root, factory) {
if (typeof define === 'function' && define.amd) {

View File

@ -15,7 +15,7 @@
* limitations under the License.
*/
/* global nf, define, module, require, exports */
/* global define, module, require, exports */
(function (root, factory) {
if (typeof define === 'function' && define.amd) {

View File

@ -15,7 +15,7 @@
* limitations under the License.
*/
/* global nf, top, define, module, require, exports */
/* global top, define, module, require, exports */
(function (root, factory) {
if (typeof define === 'function' && define.amd) {

View File

@ -15,7 +15,7 @@
* limitations under the License.
*/
/* global nf, top, define, module, require, exports */
/* global top, define, module, require, exports */
(function (root, factory) {
if (typeof define === 'function' && define.amd) {
@ -1270,7 +1270,7 @@
*/
getEventDetails: function (eventId, clusterNodeId) {
var url;
if (nf.Common.isDefinedAndNotNull(clusterNodeId)) {
if (common.isDefinedAndNotNull(clusterNodeId)) {
url = config.urls.provenanceEvents + encodeURIComponent(eventId) + '?' + $.param({
clusterNodeId: clusterNodeId
});
@ -1282,7 +1282,7 @@
type: 'GET',
url: url,
dataType: 'json'
}).fail(nf.Common.handleAjaxError);
}).fail(errorHandler.handleAjaxError);
},
/**

View File

@ -15,7 +15,7 @@
* limitations under the License.
*/
/* global nf, top, define, module, require, exports */
/* global top, define, module, require, exports */
(function (root, factory) {
if (typeof define === 'function' && define.amd) {

View File

@ -15,7 +15,7 @@
* limitations under the License.
*/
/* global nf, define, module, require, exports */
/* global define, module, require, exports */
(function (root, factory) {
if (typeof define === 'function' && define.amd) {

View File

@ -14,7 +14,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/* global nf, top, define, module, require, exports */
/* global top, define, module, require, exports */
(function (root, factory) {
if (typeof define === 'function' && define.amd) {
@ -1065,8 +1065,8 @@
// determine the desired action
if (processGroupsGrid.getColumns()[args.cell].id === 'actions') {
if (target.hasClass('go-to')) {
if (common.isDefinedAndNotNull(parent.nf) && common.isDefinedAndNotNull(parent.nf.CanvasUtils) && common.isDefinedAndNotNull(parent.nf.Shell)) {
parent.nf.CanvasUtils.enterGroup(item.id);
if (common.isDefinedAndNotNull(parent.nf) && common.isDefinedAndNotNull(parent.nf.ProcessGroup) && common.isDefinedAndNotNull(parent.nf.Shell)) {
parent.nf.ProcessGroup.enterGroup(item.id);
parent.$('#shell-close-button').click();
}
} else if (target.hasClass('show-process-group-status-history')) {

View File

@ -15,7 +15,7 @@
* limitations under the License.
*/
/* global nf, define, module, require, exports */
/* global define, module, require, exports */
(function (root, factory) {
if (typeof define === 'function' && define.amd) {

View File

@ -15,7 +15,7 @@
* limitations under the License.
*/
/* global nf, define, module, require, exports */
/* global define, module, require, exports */
(function (root, factory) {
if (typeof define === 'function' && define.amd) {
@ -293,7 +293,7 @@
// allow policy configuration conditionally if embedded in
if (top !== window && common.canAccessTenants()) {
if (common.isDefinedAndNotNull(parent.nf) && common.isDefinedAndNotNull(parent.nf.Canvas) && parent.nf.Canvas.isConfigurableAuthorizer()) {
if (common.isDefinedAndNotNull(parent.nf) && common.isDefinedAndNotNull(parent.nf.CanvasUtils) && parent.nf.CanvasUtils.isConfigurableAuthorizer()) {
markup += '<div title="Access Policies" class="pointer edit-access-policies fa fa-key" style="margin-top: 2px;"></div>';
}
}

View File

@ -15,7 +15,7 @@
* limitations under the License.
*/
/* global nf, top, define, module, require, exports */
/* global top, define, module, require, exports */
(function (root, factory) {
if (typeof define === 'function' && define.amd) {

View File

@ -15,7 +15,7 @@
* limitations under the License.
*/
/* global nf, define, module, require, exports */
/* global define, module, require, exports */
(function (root, factory) {
if (typeof define === 'function' && define.amd) {
@ -79,7 +79,7 @@
url: user.uri + '?' + $.param(client.getRevision(user)),
dataType: 'json'
}).done(function () {
self.loadUsersTable();
nfUsersTable.loadUsersTable();
}).fail(errorHandler.handleAjaxError);
// hide the dialog
@ -252,7 +252,7 @@
});
$.when.apply(window, xhrs).always(function () {
self.loadUsersTable().done(function () {
nfUsersTable.loadUsersTable().done(function () {
// select the new user
var row = usersData.getRowById(userEntity.id);
usersGrid.setSelectedRows([row]);
@ -330,7 +330,7 @@
});
$.when.apply(window, xhrs).always(function () {
self.loadUsersTable();
nfUsersTable.loadUsersTable();
}).fail(errorHandler.handleAjaxError);
}).fail(errorHandler.handleAjaxError);
};
@ -349,7 +349,7 @@
dataType: 'json',
contentType: 'application/json'
}).done(function (groupEntity) {
self.loadUsersTable().done(function () {
nfUsersTable.loadUsersTable().done(function () {
// add the user
var usersGrid = $('#users-table').data('gridInstance');
var usersData = usersGrid.getData();
@ -385,7 +385,7 @@
dataType: 'json',
contentType: 'application/json'
}).done(function (groupEntity) {
self.loadUsersTable();
nfUsersTable.loadUsersTable();
}).fail(errorHandler.handleAjaxError);
};

View File

@ -15,7 +15,7 @@
* limitations under the License.
*/
/* global nf, top, define, module, require, exports */
/* global top, define, module, require, exports */
(function (root, factory) {
if (typeof define === 'function' && define.amd) {