mcgilman commented on a change in pull request #5247:
URL: https://github.com/apache/nifi/pull/5247#discussion_r812285773
##########
File path:
nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/js/nf/canvas/nf-actions.js
##########
@@ -845,6 +845,116 @@
}
},
+ /**
+ * Enable all controller services in the specified ProcessGroup.
+ *
+ * @argument {selection} selection The selection
+ * @argument {cb} callback The function to call when
request is processed
+ */
+ enableAllControllerServices: function (selection,cb) {
+ if (selection.empty()) {
+ // build the entity
+ var entity = {
+ 'id': nfCanvasUtils.getGroupId(),
+ 'state': 'ENABLED'
+ };
+ updateResource(config.urls.api + '/flow/process-groups/' +
encodeURIComponent(nfCanvasUtils.getGroupId()) + '/controller-services',
entity).done(updateProcessGroup);
+ } else {
+ var componentsToStart = selection.filter(function (d) {
+ return nfCanvasUtils.isProcessGroup(d3.select(this));
+ });
+
+ // ensure there are some component to start
+ if (!componentsToStart.empty()) {
+ var startRequests = [];
+
+ // start each selected component
+ componentsToStart.each(function (d) {
+ var selected = d3.select(this);
+
+ // prepare the request
+ var uri, entity;
+ uri = config.urls.api + '/flow/process-groups/' +
encodeURIComponent(d.id) + '/controller-services';
+ entity = {
+ 'id': d.id,
+ 'state': 'ENABLED'
+ };
+
+ startRequests.push(updateResource(uri,
entity).done(function (response) {
+
nfCanvasUtils.getComponentByType('ProcessGroup').reload(d.id);
+ }));
+ });
+
+ // inform Angular app once the updates have completed
+ if (startRequests.length > 0) {
+ $.when.apply(window, startRequests).always(function ()
{
+ nfNgBridge.digest();
+ if(typeof cb == 'function'){
+ cb();
+ }
+ });
+ } else if(typeof cb == 'function'){
+ cb();
+ }
+ }
+ }
+ },
+
+ /**
+ * Disable all controller services in the specified ProcessGroup.
+ *
+ * @argument {selection} selection The selection
+ * @argument {cb} callback The function to call when
request is processed
+ */
+ disableAllControllerServices: function (selection,cb) {
Review comment:
Same comment as above regarding the `cb`.
##########
File path:
nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/js/nf/canvas/nf-actions.js
##########
@@ -845,6 +845,116 @@
}
},
+ /**
+ * Enable all controller services in the specified ProcessGroup.
+ *
+ * @argument {selection} selection The selection
+ * @argument {cb} callback The function to call when
request is processed
+ */
+ enableAllControllerServices: function (selection,cb) {
+ if (selection.empty()) {
+ // build the entity
+ var entity = {
+ 'id': nfCanvasUtils.getGroupId(),
+ 'state': 'ENABLED'
+ };
+ updateResource(config.urls.api + '/flow/process-groups/' +
encodeURIComponent(nfCanvasUtils.getGroupId()) + '/controller-services',
entity).done(updateProcessGroup);
+ } else {
+ var componentsToStart = selection.filter(function (d) {
+ return nfCanvasUtils.isProcessGroup(d3.select(this));
+ });
+
+ // ensure there are some component to start
+ if (!componentsToStart.empty()) {
+ var startRequests = [];
+
+ // start each selected component
+ componentsToStart.each(function (d) {
+ var selected = d3.select(this);
+
+ // prepare the request
+ var uri, entity;
+ uri = config.urls.api + '/flow/process-groups/' +
encodeURIComponent(d.id) + '/controller-services';
+ entity = {
+ 'id': d.id,
+ 'state': 'ENABLED'
+ };
+
+ startRequests.push(updateResource(uri,
entity).done(function (response) {
+
nfCanvasUtils.getComponentByType('ProcessGroup').reload(d.id);
+ }));
+ });
+
+ // inform Angular app once the updates have completed
+ if (startRequests.length > 0) {
+ $.when.apply(window, startRequests).always(function ()
{
+ nfNgBridge.digest();
+ if(typeof cb == 'function'){
+ cb();
+ }
+ });
+ } else if(typeof cb == 'function'){
+ cb();
+ }
+ }
+ }
+ },
+
+ /**
+ * Disable all controller services in the specified ProcessGroup.
+ *
+ * @argument {selection} selection The selection
+ * @argument {cb} callback The function to call when
request is processed
+ */
+ disableAllControllerServices: function (selection,cb) {
+ if (selection.empty()) {
+ // build the entity
+ var entity = {
+ 'id': nfCanvasUtils.getGroupId(),
+ 'state': 'DISABLED'
+ };
+ updateResource(config.urls.api + '/flow/process-groups/' +
encodeURIComponent(nfCanvasUtils.getGroupId()) + '/controller-services',
entity).done(updateProcessGroup);
+ } else {
+ var componentsToStop = selection.filter(function (d) {
Review comment:
Same comment as above regarding the selection.
##########
File path:
nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/js/nf/canvas/nf-actions.js
##########
@@ -845,6 +845,116 @@
}
},
+ /**
+ * Enable all controller services in the specified ProcessGroup.
+ *
+ * @argument {selection} selection The selection
+ * @argument {cb} callback The function to call when
request is processed
+ */
+ enableAllControllerServices: function (selection,cb) {
+ if (selection.empty()) {
+ // build the entity
+ var entity = {
+ 'id': nfCanvasUtils.getGroupId(),
+ 'state': 'ENABLED'
+ };
+ updateResource(config.urls.api + '/flow/process-groups/' +
encodeURIComponent(nfCanvasUtils.getGroupId()) + '/controller-services',
entity).done(updateProcessGroup);
+ } else {
+ var componentsToStart = selection.filter(function (d) {
Review comment:
The conditions on menu-items that could invoke this function guarantee
that the selection is either empty or a single Process Group. Unless this is
being invoked in a different context, we should update this to work with a
single element.
##########
File path:
nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/js/nf/canvas/nf-actions.js
##########
@@ -845,6 +845,116 @@
}
},
+ /**
+ * Enable all controller services in the specified ProcessGroup.
+ *
+ * @argument {selection} selection The selection
+ * @argument {cb} callback The function to call when
request is processed
+ */
+ enableAllControllerServices: function (selection,cb) {
Review comment:
What is `cb` used for in this case? Other actions (like `stop` and
`terminate`) had a callback introduced when we introduced the ability to stop a
running Processor from the details dialog and subsequently open the
configuration dialog (NIFI-5986). I don't see a similar capability here with
enabling a Controller Service.
##########
File path:
nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/js/nf/canvas/nf-actions.js
##########
@@ -845,6 +845,116 @@
}
},
+ /**
+ * Enable all controller services in the specified ProcessGroup.
+ *
+ * @argument {selection} selection The selection
+ * @argument {cb} callback The function to call when
request is processed
+ */
+ enableAllControllerServices: function (selection,cb) {
+ if (selection.empty()) {
+ // build the entity
+ var entity = {
+ 'id': nfCanvasUtils.getGroupId(),
+ 'state': 'ENABLED'
+ };
+ updateResource(config.urls.api + '/flow/process-groups/' +
encodeURIComponent(nfCanvasUtils.getGroupId()) + '/controller-services',
entity).done(updateProcessGroup);
+ } else {
+ var componentsToStart = selection.filter(function (d) {
+ return nfCanvasUtils.isProcessGroup(d3.select(this));
+ });
+
+ // ensure there are some component to start
+ if (!componentsToStart.empty()) {
+ var startRequests = [];
+
+ // start each selected component
+ componentsToStart.each(function (d) {
+ var selected = d3.select(this);
+
+ // prepare the request
+ var uri, entity;
+ uri = config.urls.api + '/flow/process-groups/' +
encodeURIComponent(d.id) + '/controller-services';
+ entity = {
+ 'id': d.id,
+ 'state': 'ENABLED'
+ };
+
+ startRequests.push(updateResource(uri,
entity).done(function (response) {
+
nfCanvasUtils.getComponentByType('ProcessGroup').reload(d.id);
+ }));
+ });
+
+ // inform Angular app once the updates have completed
+ if (startRequests.length > 0) {
+ $.when.apply(window, startRequests).always(function ()
{
+ nfNgBridge.digest();
+ if(typeof cb == 'function'){
+ cb();
+ }
+ });
+ } else if(typeof cb == 'function'){
+ cb();
+ }
+ }
+ }
+ },
+
+ /**
+ * Disable all controller services in the specified ProcessGroup.
+ *
+ * @argument {selection} selection The selection
+ * @argument {cb} callback The function to call when
request is processed
+ */
+ disableAllControllerServices: function (selection,cb) {
+ if (selection.empty()) {
+ // build the entity
+ var entity = {
+ 'id': nfCanvasUtils.getGroupId(),
+ 'state': 'DISABLED'
+ };
+ updateResource(config.urls.api + '/flow/process-groups/' +
encodeURIComponent(nfCanvasUtils.getGroupId()) + '/controller-services',
entity).done(updateProcessGroup);
+ } else {
+ var componentsToStop = selection.filter(function (d) {
+ return nfCanvasUtils.isProcessGroup(d3.select(this));
+ });
+
+ // ensure there are some component to stop
+ if (!componentsToStop.empty()) {
Review comment:
Same comment as above regarding the verb used here.
##########
File path:
nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/js/nf/canvas/nf-actions.js
##########
@@ -845,6 +845,116 @@
}
},
+ /**
+ * Enable all controller services in the specified ProcessGroup.
+ *
+ * @argument {selection} selection The selection
+ * @argument {cb} callback The function to call when
request is processed
+ */
+ enableAllControllerServices: function (selection,cb) {
+ if (selection.empty()) {
+ // build the entity
+ var entity = {
+ 'id': nfCanvasUtils.getGroupId(),
+ 'state': 'ENABLED'
+ };
+ updateResource(config.urls.api + '/flow/process-groups/' +
encodeURIComponent(nfCanvasUtils.getGroupId()) + '/controller-services',
entity).done(updateProcessGroup);
+ } else {
+ var componentsToStart = selection.filter(function (d) {
+ return nfCanvasUtils.isProcessGroup(d3.select(this));
+ });
+
+ // ensure there are some component to start
+ if (!componentsToStart.empty()) {
Review comment:
Controller Services are not started/stopped. They are enabled/disabled.
Can we update the names/comments to reflect this?
##########
File path:
nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/js/nf/canvas/nf-actions.js
##########
@@ -845,6 +845,116 @@
}
},
+ /**
+ * Enable all controller services in the specified ProcessGroup.
+ *
+ * @argument {selection} selection The selection
+ * @argument {cb} callback The function to call when
request is processed
+ */
+ enableAllControllerServices: function (selection,cb) {
+ if (selection.empty()) {
+ // build the entity
+ var entity = {
+ 'id': nfCanvasUtils.getGroupId(),
+ 'state': 'ENABLED'
+ };
+ updateResource(config.urls.api + '/flow/process-groups/' +
encodeURIComponent(nfCanvasUtils.getGroupId()) + '/controller-services',
entity).done(updateProcessGroup);
+ } else {
+ var componentsToStart = selection.filter(function (d) {
+ return nfCanvasUtils.isProcessGroup(d3.select(this));
+ });
+
+ // ensure there are some component to start
+ if (!componentsToStart.empty()) {
+ var startRequests = [];
+
+ // start each selected component
+ componentsToStart.each(function (d) {
+ var selected = d3.select(this);
+
+ // prepare the request
+ var uri, entity;
+ uri = config.urls.api + '/flow/process-groups/' +
encodeURIComponent(d.id) + '/controller-services';
+ entity = {
+ 'id': d.id,
+ 'state': 'ENABLED'
+ };
+
+ startRequests.push(updateResource(uri,
entity).done(function (response) {
+
nfCanvasUtils.getComponentByType('ProcessGroup').reload(d.id);
Review comment:
In the context of starting a Processor, this reload call was necessary
to update the Process Group node on the canvas. There currently are no
Controller Service statuses rendered on the Process Group node. I don't believe
this call is necessary here.
##########
File path:
nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/js/nf/canvas/nf-actions.js
##########
@@ -845,6 +845,116 @@
}
},
+ /**
+ * Enable all controller services in the specified ProcessGroup.
+ *
+ * @argument {selection} selection The selection
+ * @argument {cb} callback The function to call when
request is processed
+ */
+ enableAllControllerServices: function (selection,cb) {
+ if (selection.empty()) {
+ // build the entity
+ var entity = {
+ 'id': nfCanvasUtils.getGroupId(),
+ 'state': 'ENABLED'
+ };
+ updateResource(config.urls.api + '/flow/process-groups/' +
encodeURIComponent(nfCanvasUtils.getGroupId()) + '/controller-services',
entity).done(updateProcessGroup);
+ } else {
+ var componentsToStart = selection.filter(function (d) {
+ return nfCanvasUtils.isProcessGroup(d3.select(this));
+ });
+
+ // ensure there are some component to start
+ if (!componentsToStart.empty()) {
+ var startRequests = [];
+
+ // start each selected component
+ componentsToStart.each(function (d) {
+ var selected = d3.select(this);
+
+ // prepare the request
+ var uri, entity;
+ uri = config.urls.api + '/flow/process-groups/' +
encodeURIComponent(d.id) + '/controller-services';
+ entity = {
+ 'id': d.id,
+ 'state': 'ENABLED'
+ };
+
+ startRequests.push(updateResource(uri,
entity).done(function (response) {
+
nfCanvasUtils.getComponentByType('ProcessGroup').reload(d.id);
+ }));
+ });
+
+ // inform Angular app once the updates have completed
+ if (startRequests.length > 0) {
+ $.when.apply(window, startRequests).always(function ()
{
+ nfNgBridge.digest();
+ if(typeof cb == 'function'){
+ cb();
+ }
+ });
+ } else if(typeof cb == 'function'){
+ cb();
+ }
+ }
+ }
+ },
+
+ /**
+ * Disable all controller services in the specified ProcessGroup.
+ *
+ * @argument {selection} selection The selection
+ * @argument {cb} callback The function to call when
request is processed
+ */
+ disableAllControllerServices: function (selection,cb) {
+ if (selection.empty()) {
+ // build the entity
+ var entity = {
+ 'id': nfCanvasUtils.getGroupId(),
+ 'state': 'DISABLED'
+ };
+ updateResource(config.urls.api + '/flow/process-groups/' +
encodeURIComponent(nfCanvasUtils.getGroupId()) + '/controller-services',
entity).done(updateProcessGroup);
+ } else {
+ var componentsToStop = selection.filter(function (d) {
+ return nfCanvasUtils.isProcessGroup(d3.select(this));
+ });
+
+ // ensure there are some component to stop
+ if (!componentsToStop.empty()) {
+ var stopRequests = [];
+
+ // stop each selected component
+ componentsToStop.each(function (d) {
+ var selected = d3.select(this);
+
+ // prepare the request
+ var uri, entity;
+ uri = config.urls.api + '/flow/process-groups/' +
encodeURIComponent(d.id) + '/controller-services';
+ entity = {
+ 'id': d.id,
+ 'state': 'DISABLED'
+ };
+
+ stopRequests.push(updateResource(uri,
entity).done(function (response) {
+
nfCanvasUtils.getComponentByType('ProcessGroup').reload(d.id);
Review comment:
Same comment as above regarding the `reload` call.
--
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.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]