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_r322234640
 
 

 ##########
 File path: 
nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/js/nf/canvas/nf-actions.js
 ##########
 @@ -212,6 +212,417 @@
             }).size() > 0;
     };
 
+    /**
+     * Empty all the queues inside the array of connections.
+     *
+     * @Param {string} actionName
+     * @param {Array} connections
+     * @Param {Array} errors
+     *
+     */
+    var emptyQueues = function (actionName, connections, errors) {
+        var cancelled = false;
+        var finished = false;
+        var progressBarRefreshingDelay = 100; //millis
+
+        var dropRequests = [];
+        var dropRequestTimers = [];
+        var progressBarRefreshTimer = null;
+        var singleEmptyQueuePromises = [];
+
+        var createFailedResponse = function (xhr, status, error) {
+            return {
+                success: false,
+                xhr: xhr,
+                status: status,
+                error: error
+            };
+        };
+
+        var createSuccessResponse = function () {
+            return {
+                success: true
+            };
+        };
+
+        // set the progress bar to a certain percentage
+        var setProgressBar = function (percentComplete) {
+            if($("#drop-request-percent-complete .progress-label").length) {
+                //set the request status text
+                $('#drop-request-status-message').text('');
+
+                //set progress bar
+                $('#drop-request-percent-complete .md-hue-2 
.md-container.md-mode-determinate .md-bar.md-bar2:first')
+                    .attr('style','transform: translateX(' + ((percentComplete 
- 100) / 2) + '%) scale(' + (percentComplete * 0.01) + ', 1);');
+
+                //set percentage
+                $("#drop-request-percent-complete 
.progress-label:first").text(percentComplete.toFixed(2) + '%');
+            }
+            else {
+                var progressBar = $('#drop-request-percent-complete');
+
+                (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($('<div 
class="progress-label"></div>').text(percentComplete + '%'));
+            }
+        };
+
+        // process the drop request
+        var refreshProgressBar = function () {
+            // update the completed percentage
+            var percentCompleted = 0;
+            var droppedFlowfiles = 0;
+            var totalFlowfilesToDrop = 0;
+
+            dropRequests.forEach(function (dropRequest) {
+                if( nfCommon.isDefinedAndNotNull(dropRequest) &&
+                    nfCommon.isDefinedAndNotNull(dropRequest.droppedCount) &&
+                    nfCommon.isDefinedAndNotNull(dropRequest.originalCount) ) {
+                    droppedFlowfiles += dropRequest.droppedCount;
+                    totalFlowfilesToDrop += dropRequest.originalCount;
+                }
+            });
+
+            if(totalFlowfilesToDrop !== 0) {
 
 Review comment:
   ```suggestion
               if (totalFlowfilesToDrop !== 0) {
   ```

----------------------------------------------------------------
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