From 387504b66f199ba8c0195a0f16152345b03766d2 Mon Sep 17 00:00:00 2001 From: Scott Aslan Date: Tue, 25 Apr 2023 13:43:45 -0400 Subject: [PATCH] NIFI-11433 - use .add() for set instead of .push() (#7193) * replace d3.nest, use add instead of push for Set, use forEach to loop over Set * es5 function syntax Merged #7193 into main. --- .../webapp/js/nf/canvas/nf-controller-service.js | 16 ++++++---------- .../js/nf/canvas/nf-controller-services.js | 6 ++---- .../src/main/webapp/js/nf/canvas/nf-settings.js | 6 +----- 3 files changed, 9 insertions(+), 19 deletions(-) diff --git a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/js/nf/canvas/nf-controller-service.js b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/js/nf/canvas/nf-controller-service.js index 9c09beb398..b705e98adf 100644 --- a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/js/nf/canvas/nf-controller-service.js +++ b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/js/nf/canvas/nf-controller-service.js @@ -450,13 +450,9 @@ * @param {array} bulletins */ var updateReferencingComponentBulletins = function (bulletins) { - var bulletinsBySource = d3.nest() - .key(function (d) { - return d.sourceId; - }) - .map(bulletins, d3.map); + var bulletinsBySource = new Map(bulletins.map(function(d) { return [d.sourceId, d]; })); - bulletinsBySource.each(function (sourceBulletins, sourceId) { + bulletinsBySource.forEach(function (sourceBulletins, sourceId) { $('div.' + sourceId + '-bulletins').each(function () { updateBulletins(sourceBulletins, $(this)); }); @@ -830,14 +826,14 @@ */ var getReferencingControllerServiceIds = function (controllerService) { var ids = new Set(); - ids.push(controllerService.id); + ids.add(controllerService.id); var checkReferencingServices = function (referencingComponents) { $.each(referencingComponents, function (_, referencingComponentEntity) { var referencingComponent = referencingComponentEntity.component; if (referencingComponent.referenceType === 'ControllerService') { // add the id - ids.push(referencingComponent.id); + ids.add(referencingComponent.id); // consider it's referencing components if appropriate if (referencingComponent.referenceCycle === false) { @@ -930,7 +926,7 @@ // start polling for each controller service var polling = []; - services.each(function (controllerServiceId) { + services.forEach(function (controllerServiceId) { getControllerService(controllerServiceId, controllerServiceData).done(function(controllerServiceEntity) { polling.push(stopReferencingSchedulableComponents(controllerServiceEntity, pollCondition)); }); @@ -1229,7 +1225,7 @@ // start polling for each controller service var polling = []; - services.each(function (controllerServiceId) { + services.forEach(function (controllerServiceId) { getControllerService(controllerServiceId, controllerServiceData).done(function(controllerServiceEntity) { if (enabled) { polling.push(enableReferencingServices(controllerServiceEntity, pollCondition)); diff --git a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/js/nf/canvas/nf-controller-services.js b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/js/nf/canvas/nf-controller-services.js index 1c8b1995ec..3742830bcc 100644 --- a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/js/nf/canvas/nf-controller-services.js +++ b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/js/nf/canvas/nf-controller-services.js @@ -1452,11 +1452,9 @@ // if there are some bulletins process them if (!nfCommon.isEmpty(controllerServiceBulletins)) { - var controllerServiceBulletinsBySource = d3.nest() - .key(function(d) { return d.sourceId; }) - .map(controllerServiceBulletins, d3.map); + var controllerServiceBulletinsBySource = new Map(controllerServiceBulletins.map(function(d) { return [d.sourceId, d]; })); - controllerServiceBulletinsBySource.each(function(sourceBulletins, sourceId) { + controllerServiceBulletinsBySource.forEach(function(sourceBulletins, sourceId) { var controllerService = controllerServicesData.getItemById(sourceId); if (nfCommon.isDefinedAndNotNull(controllerService)) { controllerServicesData.updateItem(sourceId, $.extend(controllerService, { diff --git a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/js/nf/canvas/nf-settings.js b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/js/nf/canvas/nf-settings.js index 45a35bc274..54177e4f1f 100644 --- a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/js/nf/canvas/nf-settings.js +++ b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/js/nf/canvas/nf-settings.js @@ -3069,11 +3069,7 @@ // if there are some bulletins process them if (!nfCommon.isEmpty(reportingTaskBulletins)) { - var reportingTaskBulletinsBySource = d3.nest() - .key(function (d) { - return d.sourceId; - }) - .map(reportingTaskBulletins, d3.map); + var reportingTaskBulletinsBySource = new Map(reportingTaskBulletins.map(function(d) { return [d.sourceId, d]; })); reportingTaskBulletinsBySource.each(function (sourceBulletins, sourceId) { var reportingTask = reportingTasksData.getItemById(sourceId);