adarmiento commented on a change in pull request #3700: NIFI-6638: Empty 
multiple queues at once at different flow levels
URL: https://github.com/apache/nifi/pull/3700#discussion_r322241414
 
 

 ##########
 File path: 
nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/js/nf/canvas/nf-actions.js
 ##########
 @@ -1086,183 +1497,173 @@
         },
 
         /**
-         * Deletes the flow files in the specified connection.
+         * Deletes the flow files inside the selected connections.
          *
          * @param {type} selection
          */
-        emptyQueue: function (selection) {
-            if (selection.size() !== 1 || 
!nfCanvasUtils.isConnection(selection)) {
-                return;
-            }
+        emptySelectedQueues: function (selection) {
+            var connections = selection.filter(function (d) {
+                var selectionItem = d3.select(this);
+                return nfCanvasUtils.isConnection(selectionItem);
+            });
+
+            var actionName = selection.size() > 1 ? 'Empty Selected Queues' : 
'Empty Selected Queue';
+
+            var dialogContent = selection.size() > 1
+                ? 'Are you sure you want to empty the selected queues? All 
FlowFiles waiting at the time of the request will be removed.'
+                : 'Are you sure you want to empty the selected queue? All 
FlowFiles waiting at the time of the request will be removed.';
 
             // prompt the user before emptying the queue
             nfDialog.showYesNoDialog({
-                headerText: 'Empty Queue',
-                dialogContent: 'Are you sure you want to empty this queue? All 
FlowFiles waiting at the time of the request will be removed.',
+                headerText: actionName,
+                dialogContent: dialogContent,
                 noText: 'Cancel',
                 yesText: 'Empty',
                 yesHandler: function () {
-                    // get the connection data
-                    var connection = selection.datum();
-
-                    var MAX_DELAY = 4;
-                    var cancelled = false;
-                    var dropRequest = null;
-                    var dropRequestTimer = null;
-
-                    // updates the progress bar
-                    var updateProgress = function (percentComplete) {
-                        // remove existing labels
-                        var progressBar = $('#drop-request-percent-complete');
-                        progressBar.find('div.progress-label').remove();
-                        progressBar.find('md-progress-linear').remove();
-
-                        // update the progress bar
-                        var label = $('<div 
class="progress-label"></div>').text(percentComplete + '%');
-                        
(nfNgBridge.injector.get('$compile')($('<md-progress-linear ng-cloak 
ng-value="' + percentComplete + '" class="md-hue-2" md-mode="determinate" 
aria-label="Drop request percent 
complete"></md-progress-linear>'))(nfNgBridge.rootScope)).appendTo(progressBar);
-                        progressBar.append(label);
-                    };
+                    emptyQueues(actionName,connections.data(),undefined);
+                }
+            });
+        },
 
-                    // update the button model of the drop request status 
dialog
-                    $('#drop-request-status-dialog').modal('setButtonModel', [{
-                        buttonText: 'Stop',
-                        color: {
-                            base: '#728E9B',
-                            hover: '#004849',
-                            text: '#ffffff'
-                        },
-                        handler: {
-                            click: function () {
-                                cancelled = true;
-
-                                // we are waiting for the next poll attempt
-                                if (dropRequestTimer !== null) {
-                                    // cancel it
-                                    clearTimeout(dropRequestTimer);
-
-                                    // cancel the drop request
-                                    completeDropRequest();
-                                }
-                            }
-                        }
-                    }]);
+        /**
+         * Empty all the queues inside the selected process groups.
+         *
+         * @param {type} selection
+         */
+        emptyProcessGroupsQueues: function (selection) {
+            var selectionSize = selection.size();
+            var connections = [];
+            var errors = [];
+            var actionName = '';
+            var dialogContent = '';
+
+            if(selectionSize === 0) {
+                actionName = 'Empty Current Process Group Queues';
+                dialogContent = 'Are you sure you want to empty all queues 
inside the current process group? All FlowFiles waiting at the time of the 
request will be removed.';
+                connections = d3.selectAll('g.connection').data();
+
+                if(connections.length === 0) {
+                    // display the "no queues to empty" dialog
+                    nfDialog.showOkDialog({
+                        headerText: actionName,
+                        dialogContent: 'No queues to empty.'
+                    });
+                    return;
+                }
+            }
+            else if(selectionSize === 1) {
 
 Review comment:
   ```suggestion
               else if (selectionSize === 1) {
   ```

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
[email protected]


With regards,
Apache Git Services

Reply via email to