You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@nifi.apache.org by mc...@apache.org on 2015/02/11 22:17:13 UTC

incubator-nifi git commit: NIFI-250: - Adding an enable controller service dialog.

Repository: incubator-nifi
Updated Branches:
  refs/heads/NIFI-250 62b0669e1 -> 2769db7b4


NIFI-250:
- Adding an enable controller service dialog.

Project: http://git-wip-us.apache.org/repos/asf/incubator-nifi/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-nifi/commit/2769db7b
Tree: http://git-wip-us.apache.org/repos/asf/incubator-nifi/tree/2769db7b
Diff: http://git-wip-us.apache.org/repos/asf/incubator-nifi/diff/2769db7b

Branch: refs/heads/NIFI-250
Commit: 2769db7b4e783540b03bf2fee800a56d86e79d4d
Parents: 62b0669
Author: Matt Gilman <ma...@gmail.com>
Authored: Wed Feb 11 16:17:03 2015 -0500
Committer: Matt Gilman <ma...@gmail.com>
Committed: Wed Feb 11 16:17:03 2015 -0500

----------------------------------------------------------------------
 .../src/main/webapp/WEB-INF/pages/canvas.jsp    |   1 +
 .../disable-controller-service-dialog.jsp       |   1 +
 .../canvas/enable-controller-service-dialog.jsp |  40 ++++++
 .../src/main/webapp/css/controller-service.css  |  28 ++++
 .../js/nf/canvas/nf-controller-service.js       | 135 ++++++++++++++++---
 5 files changed, 187 insertions(+), 18 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-nifi/blob/2769db7b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/WEB-INF/pages/canvas.jsp
----------------------------------------------------------------------
diff --git a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/WEB-INF/pages/canvas.jsp b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/WEB-INF/pages/canvas.jsp
index d306368..3f361ce 100644
--- a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/WEB-INF/pages/canvas.jsp
+++ b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/WEB-INF/pages/canvas.jsp
@@ -81,6 +81,7 @@
         <jsp:include page="/WEB-INF/partials/yes-no-dialog.jsp"/>
         <jsp:include page="/WEB-INF/partials/status-history-dialog.jsp"/>
         <jsp:include page="/WEB-INF/partials/canvas/disable-controller-service-dialog.jsp"/>
+        <jsp:include page="/WEB-INF/partials/canvas/enable-controller-service-dialog.jsp"/>
         <jsp:include page="/WEB-INF/partials/canvas/new-controller-service-dialog.jsp"/>
         <jsp:include page="/WEB-INF/partials/canvas/new-processor-dialog.jsp"/>
         <jsp:include page="/WEB-INF/partials/canvas/new-port-dialog.jsp"/>

http://git-wip-us.apache.org/repos/asf/incubator-nifi/blob/2769db7b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/WEB-INF/partials/canvas/disable-controller-service-dialog.jsp
----------------------------------------------------------------------
diff --git a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/WEB-INF/partials/canvas/disable-controller-service-dialog.jsp b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/WEB-INF/partials/canvas/disable-controller-service-dialog.jsp
index 0b432af..fb2eea0 100644
--- a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/WEB-INF/partials/canvas/disable-controller-service-dialog.jsp
+++ b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/WEB-INF/partials/canvas/disable-controller-service-dialog.jsp
@@ -20,6 +20,7 @@
         <div class="setting">
             <div class="setting-name">Service</div>
             <div class="setting-field">
+                <span id="disable-controller-service-id" class="hidden"></span>
                 <span id="disable-controller-service-name"></span>
             </div>
         </div>

http://git-wip-us.apache.org/repos/asf/incubator-nifi/blob/2769db7b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/WEB-INF/partials/canvas/enable-controller-service-dialog.jsp
----------------------------------------------------------------------
diff --git a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/WEB-INF/partials/canvas/enable-controller-service-dialog.jsp b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/WEB-INF/partials/canvas/enable-controller-service-dialog.jsp
new file mode 100644
index 0000000..d3fd00c
--- /dev/null
+++ b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/WEB-INF/partials/canvas/enable-controller-service-dialog.jsp
@@ -0,0 +1,40 @@
+<%--
+ Licensed to the Apache Software Foundation (ASF) under one or more
+  contributor license agreements.  See the NOTICE file distributed with
+  this work for additional information regarding copyright ownership.
+  The ASF licenses this file to You under the Apache License, Version 2.0
+  (the "License"); you may not use this file except in compliance with
+  the License.  You may obtain a copy of the License at
+
+      http://www.apache.org/licenses/LICENSE-2.0
+
+  Unless required by applicable law or agreed to in writing, software
+  distributed under the License is distributed on an "AS IS" BASIS,
+  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  See the License for the specific language governing permissions and
+  limitations under the License.
+--%>
+<%@ page contentType="text/html" pageEncoding="UTF-8" session="false" %>
+<div id="enable-controller-service-dialog">
+    <div class="dialog-content">
+        <div class="setting">
+            <div class="setting-name">Service</div>
+            <div class="setting-field">
+                <span id="enable-controller-service-id" class="hidden"></span>
+                <span id="enable-controller-service-name"></span>
+            </div>
+        </div>
+        <div class="setting">
+            <div class="setting-name">Scope</div>
+            <div class="setting-field">
+                <div id="enable-controller-service-scope"></div>
+            </div>
+        </div>
+        <div class="setting">
+            <div class="setting-name">Referencing Components</div>
+            <div class="setting-field">
+                <div id="enable-controller-service-referencing-components"></div>
+            </div>
+        </div>
+    </div>
+</div>

http://git-wip-us.apache.org/repos/asf/incubator-nifi/blob/2769db7b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/css/controller-service.css
----------------------------------------------------------------------
diff --git a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/css/controller-service.css b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/css/controller-service.css
index 09be3c4..54168f1 100644
--- a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/css/controller-service.css
+++ b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/css/controller-service.css
@@ -197,4 +197,32 @@ div.referencing-component-references {
     height: 290px;
     overflow: auto;
     white-space: nowrap;
+}
+
+/*
+    Enable dialog
+*/
+
+#enable-controller-service-dialog {
+    z-index: 1301;
+    display: none;
+    width: 500px;
+    height: 450px;
+    line-height: normal;
+}
+
+#enable-controller-service-scope {
+    float: left;
+    width: 225px;
+    height: 18px;
+    line-height: 18px;
+}
+
+#enable-controller-service-referencing-components {
+    border: 0 solid #CCCCCC;
+    padding: 2px;
+    width: 474px;
+    height: 290px;
+    overflow: auto;
+    white-space: nowrap;
 }
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-nifi/blob/2769db7b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/js/nf/canvas/nf-controller-service.js
----------------------------------------------------------------------
diff --git a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/js/nf/canvas/nf-controller-service.js b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/js/nf/canvas/nf-controller-service.js
index 230eeb4..aa62f79 100644
--- a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/js/nf/canvas/nf-controller-service.js
+++ b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/js/nf/canvas/nf-controller-service.js
@@ -16,6 +16,11 @@
  */
 nf.ControllerService = (function () {
 
+    var config = {
+        serviceOnly: 'SERVICE_ONLY',
+        serviceAndReferencingComponents: 'SERVICE_AND_REFERENCING_COMPONENTS'
+    };
+
     /**
      * Handle any expected controller service configuration errors.
      * 
@@ -204,6 +209,11 @@ nf.ControllerService = (function () {
      * @param {array} referencingComponents
      */
     var createReferencingComponents = function (referenceContainer, referencingComponents) {
+        if (nf.Common.isEmpty(referencingComponents)) {
+            referenceContainer.append('<div class="unset">No referencing components.</div>');
+            return;
+        }
+        
         // toggles the visibility of a container
         var toggle = function (twist, container) {
             if (twist.hasClass('expanded')) {
@@ -259,11 +269,7 @@ nf.ControllerService = (function () {
                         var referencingService = controllerServiceData.getItemById(referencingComponent.id);
                         
                         // create the markup for the references
-                        if (!nf.Common.isEmpty(referencingService.referencingComponents)) {
-                            createReferencingComponents(referencingServiceReferencesContainer, referencingService.referencingComponents);
-                        } else {
-                            referencingServiceReferencesContainer.append('<div class="unset">This service has no components referencing it.</div>');
-                        }
+                        createReferencingComponents(referencingServiceReferencesContainer, referencingService.referencingComponents);
                     } else {
                         referencingServiceReferencesContainer.empty();
                     }
@@ -341,6 +347,11 @@ nf.ControllerService = (function () {
         }).fail(nf.Common.handleAjaxError);
     };
     
+    // updates the referencing components with the specified state
+    var updateReferencingComponents = function (controllerService, state) {
+        
+    };
+    
     /**
      * Shows the dialog for disabling a controller service.
      * 
@@ -348,19 +359,36 @@ nf.ControllerService = (function () {
      */
     var showDisableControllerServiceDialog = function (controllerService) {
         // populate the disable controller service dialog
+        $('#disable-controller-service-id').text(controllerService.id);
         $('#disable-controller-service-name').text(controllerService.name);
         
+        // load the controller referencing components list
         var referencingComponentsContainer = $('#disable-controller-service-referencing-components');
+        createReferencingComponents(referencingComponentsContainer, controllerService.referencingComponents);
+        
+        // show the dialog
+        $('#disable-controller-service-dialog').modal('show');
+        
+        // update the border if necessary
+        updateReferencingComponentsBorder(referencingComponentsContainer);
+    };
+    
+    /**
+     * Shows the dialog for enabling a controller service.
+     * 
+     * @param {object} controllerService
+     */
+    var showEnableControllerServiceDialog = function (controllerService) {
+        // populate the disable controller service dialog
+        $('#enable-controller-service-id').text(controllerService.id);
+        $('#enable-controller-service-name').text(controllerService.name);
         
         // load the controller referencing components list
-        if (!nf.Common.isEmpty(controllerService.referencingComponents)) {
-            createReferencingComponents(referencingComponentsContainer, controllerService.referencingComponents);
-        } else {
-            referencingComponentsContainer.append('<div class="unset">This service has no components referencing it.</div>');
-        }
+        var referencingComponentsContainer = $('#enable-controller-service-referencing-components');
+        createReferencingComponents(referencingComponentsContainer, controllerService.referencingComponents);
         
         // show the dialog
-        $('#disable-controller-service-dialog').modal('show');
+        $('#enable-controller-service-dialog').modal('show');
         
         // update the border if necessary
         updateReferencingComponentsBorder(referencingComponentsContainer);
@@ -443,7 +471,18 @@ nf.ControllerService = (function () {
                     buttonText: 'Disable',
                     handler: {
                         click: function () {
-
+                            var controllerServiceId = $('#disable-controller-service-id').text();
+                            
+                            // get the controller service
+                            var controllerServiceGrid = $('#controller-services-table').data('gridInstance');
+                            var controllerServiceData = controllerServiceGrid.getData();
+                            var controllerService = controllerServiceData.getItemById(controllerServiceId);
+                            
+                            // disable all referencing components
+                            updateReferencingComponents(controllerService, false);
+                            
+                            // enable this controller service
+                            setEnabled(controllerService, false);
                         }
                     }
                 }, {
@@ -456,6 +495,8 @@ nf.ControllerService = (function () {
                 }],
                 handler: {
                     close: function() {
+                        // clear the dialog
+                        $('#disable-controller-service-id').text('');
                         $('#disable-controller-service-name').text('');
                         $('#disable-controller-service-referencing-components').css('border-width', '0').empty();
                     }
@@ -464,6 +505,64 @@ nf.ControllerService = (function () {
                 containment: 'parent',
                 handle: '.dialog-header'
             });
+            
+            // initialize the enable scope combo
+            $('#enable-controller-service-scope').combo({
+                options: [{
+                        text: 'Service only',
+                        value: config.serviceOnly,
+                        description: 'Enable only this controller service'
+                    }, {
+                        text: 'Service and referencing components',
+                        value: config.serviceAndReferencingComponents,
+                        description: 'Enable this controller service and enable/start all referencing components'
+                    }]
+            });
+            
+            // initialize the enable service dialog
+            $('#enable-controller-service-dialog').modal({
+                headerText: 'Enable Controller Service',
+                overlayBackground: false,
+                buttons: [{
+                    buttonText: 'Enable',
+                    handler: {
+                        click: function () {
+                            var controllerServiceId = $('#enable-controller-service-id').text();
+                            
+                            // get the controller service
+                            var controllerServiceGrid = $('#controller-services-table').data('gridInstance');
+                            var controllerServiceData = controllerServiceGrid.getData();
+                            var controllerService = controllerServiceData.getItemById(controllerServiceId);
+                            
+                            var scope = $('#enable-controller-service-scope').combo('getSelectedOption').value;
+                            if (scope === config.serviceAndReferencingComponents) {
+                                updateReferencingComponents(controllerService, true);
+                            }
+                            
+                            // enable this controller service
+                            setEnabled(controllerService, true);
+                        }
+                    }
+                }, {
+                    buttonText: 'Cancel',
+                    handler: {
+                        click: function () {
+                            $(this).modal('hide');
+                        }
+                    }
+                }],
+                handler: {
+                    close: function() {
+                        // clear the dialog
+                        $('#enable-controller-service-id').text('');
+                        $('#enable-controller-service-name').text('');
+                        $('#enable-controller-service-referencing-components').css('border-width', '0').empty();
+                    }
+                }
+            }).draggable({
+                containment: 'parent',
+                handle: '.dialog-header'
+            });
         },
         
         /**
@@ -523,11 +622,7 @@ nf.ControllerService = (function () {
                 var referenceContainer = $('#controller-service-referencing-components');
 
                 // load the controller referencing components list
-                if (!nf.Common.isEmpty(controllerService.referencingComponents)) {
-                    createReferencingComponents(referenceContainer, controllerService.referencingComponents);
-                } else {
-                    referenceContainer.append('<div class="unset">This service has no components referencing it.</div>');
-                }
+                createReferencingComponents(referenceContainer, controllerService.referencingComponents);
 
                 var buttons = [{
                         buttonText: 'Apply',
@@ -659,7 +754,11 @@ nf.ControllerService = (function () {
          * @param {object} controllerService
          */
         enable: function(controllerService) {
-            setEnabled(controllerService, true);
+            if (nf.Common.isEmpty(controllerService.referencingComponents)) {
+                setEnabled(controllerService, true);
+            } else {
+                showEnableControllerServiceDialog(controllerService);
+            }
         },
         
         /**