From issues-return-84531-archive-asf-public=cust-asf.ponee.io@nifi.apache.org Mon Sep 9 13:30:43 2019 Return-Path: X-Original-To: archive-asf-public@cust-asf.ponee.io Delivered-To: archive-asf-public@cust-asf.ponee.io Received: from mail.apache.org (hermes.apache.org [207.244.88.153]) by mx-eu-01.ponee.io (Postfix) with SMTP id 1D817180670 for ; Mon, 9 Sep 2019 15:30:43 +0200 (CEST) Received: (qmail 4246 invoked by uid 500); 9 Sep 2019 13:30:41 -0000 Mailing-List: contact issues-help@nifi.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@nifi.apache.org Delivered-To: mailing list issues@nifi.apache.org Received: (qmail 4020 invoked by uid 99); 9 Sep 2019 13:30:40 -0000 Received: from ec2-52-202-80-70.compute-1.amazonaws.com (HELO gitbox.apache.org) (52.202.80.70) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 09 Sep 2019 13:30:40 +0000 From: GitBox To: issues@nifi.apache.org Subject: [GitHub] [nifi] adarmiento commented on a change in pull request #3700: NIFI-6638: Empty multiple queues at once at different flow levels Message-ID: <156803584052.21038.9548442550143367449.gitbox@gitbox.apache.org> Date: Mon, 09 Sep 2019 13:30:40 -0000 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit 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_r322242248 ########## 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 = $('
').text(percentComplete + '%'); - (nfNgBridge.injector.get('$compile')($(''))(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) { + actionName = 'Empty Selected Process Group Queues'; + dialogContent = 'Are you sure you want to empty all queues inside the selected process group? All FlowFiles waiting at the time of the request will be removed.'; + } + else { + actionName = 'Empty Selected Process Groups Queues'; + dialogContent = 'Are you sure you want to empty all queues inside the selected process groups? All FlowFiles waiting at the time of the request will be removed.'; + } - // completes the drop request by removing it and showing how many flowfiles were deleted - var completeDropRequest = function () { - // reload the connection status - nfConnection.reloadStatus(connection.id); + // prompt the user before emptying the queue + nfDialog.showYesNoDialog({ + headerText: actionName, + dialogContent: dialogContent, + noText: 'Cancel', + yesText: 'Empty', + yesHandler: function () { + if(selectionSize === 0) { + emptyQueues(actionName,connections,undefined); + } + else { + var processGroupIDs = selection.filter(function (d) { + var selectionItem = d3.select(this); + return nfCanvasUtils.isProcessGroup(selectionItem); + }).data().map(function (selectedProcessGroup) { + return selectedProcessGroup.id; + }); - // clean up as appropriate - if (nfCommon.isDefinedAndNotNull(dropRequest)) { - $.ajax({ - type: 'DELETE', - url: dropRequest.uri, - dataType: 'json' - }).done(function (response) { - // report the results of this drop request - dropRequest = response.dropRequest; - - // build the results - var droppedTokens = dropRequest.dropped.split(/ \/ /); - var results = $('
'); - $('').text(droppedTokens[0]).appendTo(results); - $('').text(' FlowFiles (' + droppedTokens[1] + ')').appendTo(results); - - // if the request did not complete, include the original - if (dropRequest.percentCompleted < 100) { - var originalTokens = dropRequest.original.split(/ \/ /); - $('').text(' out of ' + originalTokens[0]).appendTo(results); - $('').text(' (' + originalTokens[1] + ')').appendTo(results); - } - $('').text(' were removed from the queue.').appendTo(results); + getProcessGroupsConnections(processGroupIDs, false).then(function (response) { + response.connections.forEach(function (connection) { + connections.push(connection); + }); - // if this request failed so the error - if (nfCommon.isDefinedAndNotNull(dropRequest.failureReason)) { - $('

').text(dropRequest.failureReason).appendTo(results); - } + response.errorMessages.forEach(function (errorMessage) { + errors.push(errorMessage); + }); - // display the results + if(connections.length === 0 && errors.length === 0) { + // display the "no queues to empty" dialog nfDialog.showOkDialog({ - headerText: 'Empty Queue', - dialogContent: results + headerText: actionName, + dialogContent: 'No queues to empty.' }); - }).always(function () { - $('#drop-request-status-dialog').modal('hide'); - }); - } else { - // nothing was removed - nfDialog.showOkDialog({ - headerText: 'Empty Queue', - dialogContent: 'No FlowFiles were removed.' - }); - - // close the dialog - $('#drop-request-status-dialog').modal('hide'); - } - }; + } + else { + emptyQueues(actionName,connections,errors); + } + }); + } + } + }); + }, - // process the drop request - var processDropRequest = function (delay) { - // update the percent complete - updateProgress(dropRequest.percentCompleted); + emptyProcessGroupsQueuesRecursive: function (selection) { + var selectionSize = selection.size(); + var connections = []; + var errors = []; + var actionName = ''; + var dialogContent = ''; + + if(selectionSize === 0) { + actionName = 'Empty Current Process Group Queues (Recursive)'; + dialogContent = 'Are you sure you want to empty all queues inside the current process group and all its sub process groups (recursive)? All FlowFiles waiting at the time of the request will be removed.'; + connections = d3.selectAll('g.connection').data(); + } + else if(selectionSize === 1) { + actionName = 'Empty Selected Process Group Queues (Recursive)'; + dialogContent = 'Are you sure you want to empty all queues inside the selected process group and all its sub process groups (recursive)? All FlowFiles waiting at the time of the request will be removed.'; + } + else { + actionName = 'Empty Selected Process Groups Queues (Recursive)'; + dialogContent = 'Are you sure you want to empty all queues inside the selected process groups and all their sub process groups (recursive)? All FlowFiles waiting at the time of the request will be removed.'; + } - // update the status of the drop request - $('#drop-request-status-message').text(dropRequest.state); + // prompt the user before emptying the queue + nfDialog.showYesNoDialog({ + headerText: actionName, + dialogContent: dialogContent, + noText: 'Cancel', + yesText: 'Empty', + yesHandler: function () { + var processGroupIDs = selectionSize === 0 + ? + d3.selectAll('g.process-group') + .data() + .map(function (processGroup) { + return processGroup.id; + }) + : Review comment: nit ---------------------------------------------------------------- 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: users@infra.apache.org With regards, Apache Git Services