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/04/07 20:03:10 UTC

[3/3] incubator-nifi git commit: NIFI-475: - Removing the type hierarchies from the new controller service dialog.

NIFI-475:
- Removing the type hierarchies from the new 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/74844d74
Tree: http://git-wip-us.apache.org/repos/asf/incubator-nifi/tree/74844d74
Diff: http://git-wip-us.apache.org/repos/asf/incubator-nifi/diff/74844d74

Branch: refs/heads/NIFI-475
Commit: 74844d7418f07ff09851139d46919811da28ee03
Parents: ea39eac
Author: Matt Gilman <ma...@gmail.com>
Authored: Tue Apr 7 13:58:51 2015 -0400
Committer: Matt Gilman <ma...@gmail.com>
Committed: Tue Apr 7 13:58:51 2015 -0400

----------------------------------------------------------------------
 .../src/main/webapp/css/settings.css            |  15 --
 .../src/main/webapp/js/nf/canvas/nf-settings.js | 225 ++-----------------
 2 files changed, 22 insertions(+), 218 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-nifi/blob/74844d74/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/css/settings.css
----------------------------------------------------------------------
diff --git a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/css/settings.css b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/css/settings.css
index 91805e1..ae93bcc 100644
--- a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/css/settings.css
+++ b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/css/settings.css
@@ -43,21 +43,6 @@
     cursor: pointer;
 }
 
-span.expansion-button {
-    width: 10px;
-    height: 10px;
-    float: left;
-}
-
-span.ancestor-type {
-    font-weight: bold;
-}
-
-span.ancestor-type-rollup {
-    margin-left: 3px;
-    color: #aaa;
-}
-
 /* settings tabs */
 
 #settings-tabs-container {

http://git-wip-us.apache.org/repos/asf/incubator-nifi/blob/74844d74/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 6e8c94e..c7b2b65 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
@@ -168,34 +168,6 @@ nf.Settings = (function () {
     };
 
     /**
-     * Determines if all of the ancestors of the specified item are expanded.
-     * 
-     * @param {type} item
-     * @returns {Boolean}
-     */
-    var areAncestorsExpanded = function (item) {
-        var documentedType = item;
-        while (documentedType.parent !== null) {
-            if (documentedType.parent.collapsed === true) {
-                return false;
-            }
-            documentedType = documentedType.parent;
-        }
-
-        return true;
-    };
-
-    /**
-     * Determines if the specified item is an ancestor.
-     * 
-     * @param {type} item
-     * @returns {Boolean}
-     */
-    var isAncestor = function (item) {
-        return item.children.length > 0;
-    };
-
-    /**
      * Hides the selected controller service.
      */
     var clearSelectedControllerService = function () {
@@ -232,27 +204,6 @@ nf.Settings = (function () {
      * @returns {Boolean}       Whether or not to include the item
      */
     var filterControllerServiceTypes = function (item, args) {
-        if (!areAncestorsExpanded(item)) {
-            // if this item is currently selected and its parent is not collapsed
-            if ($('#selected-controller-service-type').text() === item['type']) {
-                clearControllerServiceSelection();
-            }
-
-            // update visibility flag
-            item.visible = false;
-
-            return false;
-        }
-
-        // don't allow ancestors to be filtered out (unless any of their ancestors
-        // are collapsed)
-        if (isAncestor(item)) {
-            // update visibility flag
-            item.visible = false;
-
-            return true;
-        }
-
         // determine if the item matches the filter
         var matchesFilter = matchesRegex(item, args);
 
@@ -274,9 +225,6 @@ nf.Settings = (function () {
             clearControllerServiceSelection();
         }
 
-        // update visibility flag
-        item.visible = matches;
-
         return matches;
     };
 
@@ -331,64 +279,6 @@ nf.Settings = (function () {
     };
 
     /**
-     * Formats the type by introducing expand/collapse where appropriate.
-     * 
-     * @param {type} row
-     * @param {type} cell
-     * @param {type} value
-     * @param {type} columnDef
-     * @param {type} dataContext
-     */
-    var expandableTypeFormatter = function (row, cell, value, columnDef, dataContext) {
-        var markup = '';
-
-        var indent = 0;
-        var documentedType = dataContext;
-        while (documentedType.parent !== null) {
-            indent += 20;
-            documentedType = documentedType.parent;
-        }
-
-        var padding = 3;
-
-        // create the markup for the row
-        if (dataContext.children.length > 0) {
-            // determine how to render the expansion button
-            var expansionStyle = 'expanded';
-            if (dataContext.collapsed === true) {
-                expansionStyle = 'collapsed';
-            }
-
-            // calculate the number of visible/total children
-            var visibleChildren = 0;
-            var totalChildren = 0;
-            var countChildren = function (item) {
-                $.each(item.children, function (_, child) {
-                    if (child.children.length > 0) {
-                        countChildren(child);
-                    } else {
-                        if (child.visible) {
-                            visibleChildren++;
-                        }
-                        totalChildren++;
-                    }
-                });
-            };
-            countChildren(dataContext);
-
-            markup += ('<span style="margin-top: 5px; margin-left: ' + indent + 'px;" class="expansion-button ' + expansionStyle + '"></span><span class="ancestor-type" style="margin-left: ' + padding + 'px;">' + value + '</span><span class="ancestor-type-rollup">(' + visibleChildren + ' of ' + totalChildren + ')</span>');
-        } else {
-            if (dataContext.parent === null) {
-                padding = 0;
-            }
-
-            markup += ('<span style="margin-left: ' + (indent + padding) + 'px;">' + value + '</span>');
-        }
-
-        return markup;
-    };
-
-    /**
      * Adds a new controller service of the specified type.
      * 
      * @param {string} controllerServiceType
@@ -489,7 +379,7 @@ nf.Settings = (function () {
 
         // initialize the processor type table
         var controllerServiceTypesColumns = [
-            {id: 'type', name: 'Type', field: 'label', formatter: expandableTypeFormatter, sortable: false, resizable: true},
+            {id: 'type', name: 'Type', field: 'label', sortable: false, resizable: true},
             {id: 'tags', name: 'Tags', field: 'tags', sortable: false, resizable: true}
         ];
 
@@ -503,32 +393,6 @@ nf.Settings = (function () {
             property: $('#controller-service-type-filter-options').combo('getSelectedOption').value
         });
         controllerServiceTypesData.setFilter(filterControllerServiceTypes);
-        controllerServiceTypesData.getItemMetadata = function (index) {
-            var item = controllerServiceTypesData.getItem(index);
-            if (item && item.children.length > 0) {
-                return {
-                    selectable: false,
-                    columns: {
-                        0: {
-                            colspan: '*'
-                        }
-                    }
-                };
-            } else {
-                return {};
-            }
-        };
-
-        var getVisibleControllerServiceCount = function () {
-            var count = 0;
-            for (var i = 0; i < controllerServiceTypesData.getLength(); i++) {
-                var item = controllerServiceTypesData.getItem(i);
-                if (item.children.length === 0) {
-                    count++;
-                }
-            }
-            return count;
-        };
 
         // initialize the grid
         var controllerServiceTypesGrid = new Slick.Grid('#controller-service-types-table', controllerServiceTypesData, controllerServiceTypesColumns, gridOptions);
@@ -540,41 +404,20 @@ nf.Settings = (function () {
                 var controllerServiceTypeIndex = args.rows[0];
                 var controllerServiceType = controllerServiceTypesGrid.getDataItem(controllerServiceTypeIndex);
 
-                // only allow selection of service implementations
-                if (controllerServiceType.children.length === 0) {
-                    // set the controller service type description
-                    if (nf.Common.isBlank(controllerServiceType.description)) {
-                        $('#controller-service-type-description').attr('title', '').html('<span class="unset">No description specified</span>');
-                    } else {
-                        $('#controller-service-type-description').html(controllerServiceType.description).ellipsis();
-                    }
-
-                    // populate the dom
-                    $('#controller-service-type-name').text(controllerServiceType.label).ellipsis();
-                    $('#selected-controller-service-name').text(controllerServiceType.label);
-                    $('#selected-controller-service-type').text(controllerServiceType.type);
-
-                    // show the selected controller service
-                    $('#controller-service-description-container').show();
-                }
-            }
-        });
-        controllerServiceTypesGrid.onClick.subscribe(function (e, args) {
-            var item = controllerServiceTypesData.getItem(args.row);
-            if (item && item.children.length > 0) {
-                // update the grid
-                item.collapsed = !item.collapsed;
-                controllerServiceTypesData.updateItem(item.id, item);
-
-                // update any affected ancestors
-                var parent = item.parent;
-                while (parent !== null) {
-                    controllerServiceTypesData.updateItem(parent.id, parent);
-                    parent = parent.parent;
+                // set the controller service type description
+                if (nf.Common.isBlank(controllerServiceType.description)) {
+                    $('#controller-service-type-description').attr('title', '').html('<span class="unset">No description specified</span>');
+                } else {
+                    $('#controller-service-type-description').html(controllerServiceType.description).ellipsis();
                 }
 
-                // prevent selection within slickgrid
-                e.stopImmediatePropagation();
+                // populate the dom
+                $('#controller-service-type-name').text(controllerServiceType.label).ellipsis();
+                $('#selected-controller-service-name').text(controllerServiceType.label);
+                $('#selected-controller-service-type').text(controllerServiceType.type);
+
+                // show the selected controller service
+                $('#controller-service-description-container').show();
             }
         });
         controllerServiceTypesGrid.onDblClick.subscribe(function (e, args) {
@@ -588,7 +431,7 @@ nf.Settings = (function () {
             controllerServiceTypesGrid.render();
 
             // update the total number of displayed processors
-            $('#displayed-controller-service-types').text(getVisibleControllerServiceCount());
+            $('#displayed-controller-service-types').text(args.current);
         });
         controllerServiceTypesData.onRowsChanged.subscribe(function (e, args) {
             controllerServiceTypesGrid.invalidateRows(args.rows);
@@ -611,46 +454,28 @@ nf.Settings = (function () {
             // begin the update
             controllerServiceTypesData.beginUpdate();
 
-            var addType = function (parentItem, documentedType) {
-                var item = {
+            // go through each controller service type
+            $.each(response.controllerServiceTypes, function (i, documentedType) {
+                // add the documented type
+                controllerServiceTypesData.addItem({
                     id: id++,
                     label: nf.Common.substringAfterLast(documentedType.type, '.'),
                     type: documentedType.type,
                     description: nf.Common.escapeHtml(documentedType.description),
-                    tags: documentedType.tags.join(', '),
-                    parent: parentItem,
-                    children: [],
-                    collapsed: false,
-                    visible: true
-                };
-
-                // add the documented type
-                controllerServiceTypesData.addItem(item);
+                    tags: documentedType.tags.join(', ')
+                });
 
                 // count the frequency of each tag for this type
                 $.each(documentedType.tags, function (i, tag) {
                     tags.push(tag.toLowerCase());
                 });
-
-                // add each of its children
-                $.each(documentedType.childTypes, function (_, documentedChildType) {
-                    var childItem = addType(item, documentedChildType);
-                    item.children.push(childItem);
-                });
-
-                return item;
-            };
-
-            // go through each controller service type
-            $.each(response.controllerServiceTypes, function (i, documentedType) {
-                addType(null, documentedType);
             });
 
             // end the udpate
             controllerServiceTypesData.endUpdate();
             
             // set the total number of processors
-            $('#total-controller-service-types, #displayed-controller-service-types').text(getVisibleControllerServiceCount());
+            $('#total-controller-service-types, #displayed-controller-service-types').text(response.controllerServiceTypes.length);
 
             // create the tag cloud
             $('#controller-service-tag-cloud').tagcloud({
@@ -1099,9 +924,6 @@ nf.Settings = (function () {
             clearReportingTaskSelection();
         }
 
-        // update visibility flag
-        item.visible = matches;
-
         return matches;
     };
 
@@ -1289,10 +1111,7 @@ nf.Settings = (function () {
                     label: nf.Common.substringAfterLast(documentedType.type, '.'),
                     type: documentedType.type,
                     description: nf.Common.escapeHtml(documentedType.description),
-                    tags: documentedType.tags.join(', '),
-                    children: [],
-                    collapsed: false,
-                    visible: true
+                    tags: documentedType.tags.join(', ')
                 });
 
                 // count the frequency of each tag for this type