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/01/28 14:35:53 UTC

[2/2] incubator-nifi git commit: NIFI-250: - Wiring up updating and deleting controller services. - Ensuring the new property dialog is closed when clearing the grid.

NIFI-250:
- Wiring up updating and deleting controller services.
- Ensuring the new property dialog is closed when clearing the grid.

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

Branch: refs/heads/NIFI-250
Commit: 5d5cb8f106c630e92852cf0fdefdad1c602c4520
Parents: 2303570
Author: Matt Gilman <ma...@gmail.com>
Authored: Wed Jan 28 08:35:17 2015 -0500
Committer: Matt Gilman <ma...@gmail.com>
Committed: Wed Jan 28 08:35:17 2015 -0500

----------------------------------------------------------------------
 .../css/new-controller-service-dialog.css       |  5 +-
 .../propertytable/jquery.propertytable.js       |  3 +
 .../nf-controller-service-configuration.js      | 79 +++++++++++++-------
 .../js/nf/canvas/nf-processor-configuration.js  | 10 +--
 .../src/main/webapp/js/nf/canvas/nf-settings.js | 52 +++++++++----
 5 files changed, 98 insertions(+), 51 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-nifi/blob/5d5cb8f1/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/css/new-controller-service-dialog.css
----------------------------------------------------------------------
diff --git a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/css/new-controller-service-dialog.css b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/css/new-controller-service-dialog.css
index 9a9a199..c28a253 100644
--- a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/css/new-controller-service-dialog.css
+++ b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/css/new-controller-service-dialog.css
@@ -23,7 +23,7 @@
     z-index: 1301;
     display: none;
     width: 800px;
-    height: 500px;
+    height: 450px;
     border: 1px solid #eee;
     line-height: normal;
 }
@@ -42,7 +42,7 @@
 
 #controller-service-description-container {
     width: 588px;
-    height: 150px;
+    height: 100px;
     margin-top: 10px;
 }
 
@@ -57,7 +57,6 @@
 #controller-service-type-description {
     width: 588px;
     height: 60px;
-    margin-bottom: 8px;
 }
 
 #controller-service-types-table {

http://git-wip-us.apache.org/repos/asf/incubator-nifi/blob/5d5cb8f1/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/js/jquery/propertytable/jquery.propertytable.js
----------------------------------------------------------------------
diff --git a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/js/jquery/propertytable/jquery.propertytable.js b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/js/jquery/propertytable/jquery.propertytable.js
index 9b68f06..1e325f4 100644
--- a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/js/jquery/propertytable/jquery.propertytable.js
+++ b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/js/jquery/propertytable/jquery.propertytable.js
@@ -1211,8 +1211,11 @@
                 var options = $(this).data('options');
                 if (options.readOnly === true) {
                     removeAllPropertyDetailDialogs();
+                } else {
+                    $(this).find('div.new-property-dialog').hide();
                 }
                 
+                // clean up data
                 var table = $(this).find('div.property-table');
                 table.removeData('descriptors history');
             

http://git-wip-us.apache.org/repos/asf/incubator-nifi/blob/5d5cb8f1/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/js/nf/canvas/nf-controller-service-configuration.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-configuration.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-configuration.js
index 79af834..5d6a496 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-configuration.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-configuration.js
@@ -59,6 +59,12 @@ nf.ControllerServiceConfiguration = (function () {
         if ($('#controller-service-comments').val() !== details.comments) {
             return true;
         }
+        
+        if ($('#controller-service-enabled').hasClass('checkbox-checked') && details['enabled'] === false) {
+            return true;
+        } else if ($('#controller-service-enabled').hasClass('checkbox-unchecked') && details['enabled'] === true) {
+            return true;
+        }
 
         // defer to the properties
         return $('#controller-service-properties').propertytable('isSaveRequired');
@@ -107,6 +113,36 @@ nf.ControllerServiceConfiguration = (function () {
     };
     
     /**
+     * Reloads the specified controller service.
+     * 
+     * @param {object} controllerService
+     */
+    var reloadControllerService = function (controllerService) {
+        return $.ajax({
+            type: 'GET',
+            url: controllerService.uri,
+            dataType: 'json'
+        }).done(function (response) {
+            renderControllerService(response.controllerService);
+        }).fail(nf.Common.handleAjaxError);
+    };
+    
+    /**
+     * Reloads the specified controller service.
+     * 
+     * @param {object} controllerService
+     */
+    var renderControllerService = function (controllerService) {
+        // get the table and update the row accordingly
+        var controllerServiceGrid = $('#controller-services-table').data('gridInstance');
+        var controllerServiceData = controllerServiceGrid.getData();
+        controllerServiceData.updateItem(controllerService.id, controllerService);
+
+        // reload the controller service references
+        reloadControllerServiceReferences(controllerService);
+    };
+    
+    /**
      * Reloads components that reference this controller service.
      * 
      * @param {object} controllerService
@@ -135,7 +171,7 @@ nf.ControllerServiceConfiguration = (function () {
                         tabContentId: 'controller-service-comments-tab-content'
                     }],
                 select: function () {
-                    // update the processor property table size in case this is the first time its rendered
+                    // update the property table size in case this is the first time its rendered
                     if ($(this).text() === 'Properties') {
                         $('#controller-service-properties').propertytable('resetTableSize');
                     }
@@ -151,7 +187,7 @@ nf.ControllerServiceConfiguration = (function () {
                 }
             });
 
-            // initialize the processor configuration dialog
+            // initialize the conroller service configuration dialog
             $('#controller-service-configuration').modal({
                 headerText: 'Configure Controller Service',
                 overlayBackground: false,
@@ -160,9 +196,6 @@ nf.ControllerServiceConfiguration = (function () {
 //                        // empty the relationship list
 //                        $('#auto-terminate-relationship-names').css('border-width', '0').empty();
 
-                        // close the new property dialog if necessary
-                        $('#processor-property-dialog').hide();
-
                         // cancel any active edits
                         $('#controller-service-properties').propertytable('cancelEdit');
 
@@ -170,7 +203,7 @@ nf.ControllerServiceConfiguration = (function () {
                         $('#controller-service-properties').propertytable('clear');
 
                         // removed the cached controller service details
-//                        $('#controller-service-configuration').removeData('processorDetails');
+                        $('#controller-service-configuration').removeData('controllerServiceDetails');
 //                        $('#controller-service-configuration').removeData('processorHistory');
                     }
                 }
@@ -189,7 +222,7 @@ nf.ControllerServiceConfiguration = (function () {
          * @argument {controllerService} controllerService      The controller service
          */
         showConfiguration: function (controllerService) {
-            // record the processor details
+            // record the controller service details
             $('#controller-service-configuration').data('controllerServiceDetails', controllerService);
 
             // determine if the enabled checkbox is checked or not
@@ -198,7 +231,7 @@ nf.ControllerServiceConfiguration = (function () {
                 controllerServiceEnableStyle = 'checkbox-unchecked';
             }
 
-            // populate the processor settings
+            // populate the controller service settings
             $('#controller-service-id').text(controllerService['id']);
             $('#controller-service-type').text(nf.Common.substringAfterLast(controllerService['type'], '.'));
             $('#controller-service-name').val(controllerService['name']);
@@ -229,19 +262,16 @@ nf.ControllerServiceConfiguration = (function () {
                                     processData: false,
                                     contentType: 'application/json'
                                 }).done(function (response) {
-//                                    if (nf.Common.isDefinedAndNotNull(response.processor)) {
-//                                        // update the revision
-//                                        nf.Client.setRevision(response.revision);
-//
-//                                        // set the new processor state based on the response
-//                                        nf.Processor.set(response.processor);
-//
-//                                        // reload the processor's outgoing connections
-//                                        reloadProcessorConnections(processor);
-//
-//                                        // close the details panel
-//                                        $('#processor-configuration').modal('hide');
-//                                    }
+                                    if (nf.Common.isDefinedAndNotNull(response.controllerService)) {
+                                        // update the revision
+                                        nf.Client.setRevision(response.revision);
+
+                                        // reload the controller service
+                                        renderControllerService(response.controllerService);
+
+                                        // close the details panel
+                                        $('#controller-service-configuration').modal('hide');
+                                    }
                                 }).fail(handleControllerServiceConfigurationError);
                             }
                         }
@@ -267,11 +297,8 @@ nf.ControllerServiceConfiguration = (function () {
 
                                 // show the custom ui
                                 nf.CustomProcessorUi.showCustomUi($('#controller-service-id').text(), controllerService.customUiUrl, true).done(function () {
-//                                    // once the custom ui is closed, reload the processor
-//                                    nf.Processor.reload(processor);
-//
-//                                    // and reload the processor's outgoing connections
-//                                    reloadProcessorConnections(processor);
+                                    // once the custom ui is closed, reload the controller service
+                                    reloadControllerService(controllerService);
                                 });
                             };
 

http://git-wip-us.apache.org/repos/asf/incubator-nifi/blob/5d5cb8f1/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/js/nf/canvas/nf-processor-configuration.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-processor-configuration.js b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/js/nf/canvas/nf-processor-configuration.js
index 106542f..aa8980b 100644
--- a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/js/nf/canvas/nf-processor-configuration.js
+++ b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/js/nf/canvas/nf-processor-configuration.js
@@ -426,14 +426,8 @@ nf.ProcessorConfiguration = (function () {
                         // empty the relationship list
                         $('#auto-terminate-relationship-names').css('border-width', '0').empty();
 
-                        // close the new property dialog if necessary
-                        $('#processor-property-dialog').hide();
-
-                        // cancel any active edits
-                        $('#processor-properties').propertytable('cancelEdit');
-
-                        // clear the tables
-                        $('#processor-properties').propertytable('clear');
+                        // cancel any active edits and clear the table
+                        $('#processor-properties').propertytable('cancelEdit').propertytable('clear');
 
                         // removed the cached processor details
                         $('#processor-configuration').removeData('processorDetails');

http://git-wip-us.apache.org/repos/asf/incubator-nifi/blob/5d5cb8f1/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/js/nf/canvas/nf-settings.js
----------------------------------------------------------------------
diff --git a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/js/nf/canvas/nf-settings.js b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/js/nf/canvas/nf-settings.js
index f70ed72..37f218b 100644
--- a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/js/nf/canvas/nf-settings.js
+++ b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/js/nf/canvas/nf-settings.js
@@ -369,12 +369,12 @@ nf.Settings = (function () {
             },
             dataType: 'json'
         }).done(function (response) {
-            var controllerService = response.controllerService;
-            if (nf.Common.isDefinedAndNotNull(controllerService)) {
-                var controllerServicesGrid = $('#controller-services-table').data('gridInstance');
-                var controllerServicesData = controllerServicesGrid.getData();
-                controllerServicesData.addItem(controllerService);
-            }
+            // update the revision
+            nf.Client.setRevision(response.revision);
+
+            var controllerServicesGrid = $('#controller-services-table').data('gridInstance');
+            var controllerServicesData = controllerServicesGrid.getData();
+            controllerServicesData.addItem(response.controllerService);
         });
         
         // hide the dialog
@@ -497,12 +497,6 @@ nf.Settings = (function () {
         controllerServiceTypesGrid.onClick.subscribe(function (e, args) {
             var item = controllerServiceTypesData.getItem(args.row);
             if (item && item.children.length > 0) {
-                // determine if there are rows currectly selected
-                var selectedIndex = controllerServiceTypesGrid.getSelectedRows();
-                if ($.isArray(selectedIndex) && selectedIndex.length === 1) {
-                    
-                }
-
                 // update the grid
                 item.collapsed = !item.collapsed;
                 controllerServiceTypesData.updateItem(item.id, item);
@@ -711,9 +705,39 @@ nf.Settings = (function () {
                 if (target.hasClass('edit-controller-service')) {
                     nf.ControllerServiceConfiguration.showConfiguration(controllerService);
                 } else if (target.hasClass('enable-controller-service')) {
-                    
+                    var revision = nf.Client.getRevision();
+                    return $.ajax({
+                        type: 'PUT',
+                        url: controllerService.uri,
+                        data: {
+                            clientId: revision.clientId,
+                            version: revision.version,
+                            enabled: true
+                        },
+                        dataType: 'json'
+                    }).done(function (response) {
+                        // update the revision
+                        nf.Client.setRevision(response.revision);
+                        
+                        // update the service
+                        controllerServicesData.updateItem(controllerService.id, response.controllerService);
+                    }).fail(nf.Common.handleAjaxError);
                 } else if (target.hasClass('delete-controller-service')) {
-                    
+                    var revision = nf.Client.getRevision();
+                    return $.ajax({
+                        type: 'DELETE',
+                        url: controllerService.uri + '?' + $.param({
+                            version: revision.version,
+                            clientId: revision.clientId
+                        }),
+                        dataType: 'json'
+                    }).done(function (response) {
+                        // update the revision
+                        nf.Client.setRevision(response.revision);
+                        
+                        // remove the service
+                        controllerServicesData.deleteItem(controllerService.id);
+                    }).fail(nf.Common.handleAjaxError);
                 }
             } else if (controllerServicesGrid.getColumns()[args.cell].id === 'moreDetails') {
                 if (target.hasClass('view-controller-service')) {