You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@nifi.apache.org by mc...@apache.org on 2016/05/17 14:33:52 UTC
[2/7] nifi git commit: NIFI-1554: - Introducing ControllerService and
ReportingTask authorization and revision. - Removing the revision where
appropriate. NIFI-1883 - Restoring referencing components automatically. -
This closes #448
http://git-wip-us.apache.org/repos/asf/nifi/blob/8bb56fca/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/js/nf/canvas/nf-controller-service.js
----------------------------------------------------------------------
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 5484187..294a0a0 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
@@ -94,8 +94,7 @@ nf.ControllerService = (function () {
// create the controller service entity
var controllerServiceEntity = {};
- controllerServiceEntity['revision'] = nf.Client.getRevision();
- controllerServiceEntity['controllerService'] = controllerServiceDto;
+ controllerServiceEntity['component'] = controllerServiceDto;
// return the marshaled details
return controllerServiceEntity;
@@ -120,12 +119,12 @@ nf.ControllerService = (function () {
// get the table and update the row accordingly
var controllerServiceGrid = $('#controller-services-table').data('gridInstance');
var controllerServiceData = controllerServiceGrid.getData();
- var controllerService = controllerServiceData.getItemById(id);
+ var controllerServiceEntity = controllerServiceData.getItemById(id);
// this may happen if controller service A references another controller
// service B that has been removed. attempting to enable/disable/remove A
// will attempt to reload B which is no longer a known service
- if (nf.Common.isUndefined(controllerService)) {
+ if (nf.Common.isUndefined(controllerServiceEntity)) {
return $.Deferred(function (deferred) {
deferred.reject();
}).promise();
@@ -133,26 +132,26 @@ nf.ControllerService = (function () {
return $.ajax({
type: 'GET',
- url: controllerService.uri,
+ url: controllerServiceEntity.component.uri,
dataType: 'json'
}).done(function (response) {
- renderControllerService(response.controllerService);
+ renderControllerService(response);
}).fail(nf.Common.handleAjaxError);
};
/**
* Renders the specified controller service.
*
- * @param {object} controllerService
+ * @param {object} controllerServiceEntity
*/
- var renderControllerService = function (controllerService) {
+ var renderControllerService = function (controllerServiceEntity) {
// get the table and update the row accordingly
var controllerServiceGrid = $('#controller-services-table').data('gridInstance');
var controllerServiceData = controllerServiceGrid.getData();
- var currentControllerService = controllerServiceData.getItemById(controllerService.id);
- controllerServiceData.updateItem(controllerService.id, $.extend({
- bulletins: currentControllerService.bulletins
- }, controllerService));
+ var currentControllerServiceEntity = controllerServiceData.getItemById(controllerServiceEntity.id);
+ controllerServiceData.updateItem(controllerServiceEntity.id, $.extend({
+ bulletins: currentControllerServiceEntity.bulletins
+ }, controllerServiceEntity));
};
/**
@@ -163,7 +162,7 @@ nf.ControllerService = (function () {
*/
var reloadControllerServiceAndReferencingComponents = function (controllerService) {
reloadControllerService(controllerService.id).done(function(response) {
- reloadControllerServiceReferences(response.controllerService);
+ reloadControllerServiceReferences(response.component);
});
};
@@ -176,7 +175,12 @@ nf.ControllerService = (function () {
var reloadControllerServiceReferences = function (controllerService) {
// reload all dependent processors if they are currently visible
$.each(controllerService.referencingComponents, function (_, referencingComponentEntity) {
- var reference = referencingComponentEntity.controllerServiceReferencingComponent;
+ // ensure we can read the referencing component prior to reloading
+ if (referencingComponentEntity.accessPolicy.canRead === false) {
+ return;
+ }
+
+ var reference = referencingComponentEntity.component;
if (reference.referenceType === 'Processor') {
// reload the processor on the canvas if appropriate
if (nf.Canvas.getGroupId() === reference.groupId) {
@@ -382,124 +386,131 @@ nf.ControllerService = (function () {
var processors = $('<ul class="referencing-component-listing clear"></ul>');
var services = $('<ul class="referencing-component-listing clear"></ul>');
var tasks = $('<ul class="referencing-component-listing clear"></ul>');
+ var unauthorized = $('<ul class="referencing-component-listing clear"></ul>');
$.each(referencingComponents, function (_, referencingComponentEntity) {
- var referencingComponent = referencingComponentEntity.controllerServiceReferencingComponent;
- referencingComponentIds.push(referencingComponent.id);
-
- if (referencingComponent.referenceType === 'Processor') {
- var processorLink = $('<span class="referencing-component-name link"></span>').text(referencingComponent.name).on('click', function () {
- // show the component
- nf.CanvasUtils.showComponent(referencingComponent.groupId, referencingComponent.id);
-
- // close the dialog and shell
- referenceContainer.closest('.dialog').modal('hide');
- $('#shell-close-button').click();
- });
+ // check the access policy for this referencing component
+ if (referencingComponentEntity.accessPolicy.canRead === false || referencingComponentEntity.accessPolicy.canWrite === false) {
+ var unauthorizedReferencingComponent = $('<div class="unset"></div>').text(referencingComponentEntity.id);
+ unauthorized.append(unauthorizedReferencingComponent);
+ } else {
+ var referencingComponent = referencingComponentEntity.component;
+ referencingComponentIds.push(referencingComponent.id);
- // state
- var processorState = $('<div class="referencing-component-state"></div>').addClass(referencingComponent.id + '-state');
- updateReferencingSchedulableComponentState(processorState, referencingComponent);
+ if (referencingComponent.referenceType === 'Processor') {
+ var processorLink = $('<span class="referencing-component-name link"></span>').text(referencingComponent.name).on('click', function () {
+ // show the component
+ nf.CanvasUtils.showComponent(referencingComponent.groupId, referencingComponent.id);
- // bulletin
- var processorBulletins = $('<div class="referencing-component-bulletins"></div>').addClass(referencingComponent.id + '-bulletins');
-
- // type
- var processorType = $('<span class="referencing-component-type"></span>').text(nf.Common.substringAfterLast(referencingComponent.type, '.'));
-
- // active thread count
- var processorActiveThreadCount = $('<span class="referencing-component-active-thread-count"></span>').addClass(referencingComponent.id + '-active-threads');
- if (nf.Common.isDefinedAndNotNull(referencingComponent.activeThreadCount) && referencingComponent.activeThreadCount > 0) {
- processorActiveThreadCount.text('(' + referencingComponent.activeThreadCount + ')');
- }
-
- // processor
- var processorItem = $('<li></li>').append(processorState).append(processorBulletins).append(processorLink).append(processorType).append(processorActiveThreadCount);
- processors.append(processorItem);
- } else if (referencingComponent.referenceType === 'ControllerService') {
- var serviceLink = $('<span class="referencing-component-name link"></span>').text(referencingComponent.name).on('click', function () {
- var controllerServiceGrid = $('#controller-services-table').data('gridInstance');
- var controllerServiceData = controllerServiceGrid.getData();
-
- // select the selected row
- var row = controllerServiceData.getRowById(referencingComponent.id);
- controllerServiceGrid.setSelectedRows([row]);
- controllerServiceGrid.scrollRowIntoView(row);
-
- // close the dialog and shell
- referenceContainer.closest('.dialog').modal('hide');
- });
-
- // container for this service's references
- var referencingServiceReferencesContainer = $('<div class="referencing-component-references hidden"></div>');
- var serviceTwist = $('<div class="service expansion-button collapsed pointer"></div>').on('click', function() {
- if (serviceTwist.hasClass('collapsed')) {
+ // close the dialog and shell
+ referenceContainer.closest('.dialog').modal('hide');
+ $('#shell-close-button').click();
+ });
+
+ // state
+ var processorState = $('<div class="referencing-component-state"></div>').addClass(referencingComponent.id + '-state');
+ updateReferencingSchedulableComponentState(processorState, referencingComponent);
+
+ // bulletin
+ var processorBulletins = $('<div class="referencing-component-bulletins"></div>').addClass(referencingComponent.id + '-bulletins');
+
+ // type
+ var processorType = $('<span class="referencing-component-type"></span>').text(nf.Common.substringAfterLast(referencingComponent.type, '.'));
+
+ // active thread count
+ var processorActiveThreadCount = $('<span class="referencing-component-active-thread-count"></span>').addClass(referencingComponent.id + '-active-threads');
+ if (nf.Common.isDefinedAndNotNull(referencingComponent.activeThreadCount) && referencingComponent.activeThreadCount > 0) {
+ processorActiveThreadCount.text('(' + referencingComponent.activeThreadCount + ')');
+ }
+
+ // processor
+ var processorItem = $('<li></li>').append(processorState).append(processorBulletins).append(processorLink).append(processorType).append(processorActiveThreadCount);
+ processors.append(processorItem);
+ } else if (referencingComponent.referenceType === 'ControllerService') {
+ var serviceLink = $('<span class="referencing-component-name link"></span>').text(referencingComponent.name).on('click', function () {
var controllerServiceGrid = $('#controller-services-table').data('gridInstance');
var controllerServiceData = controllerServiceGrid.getData();
- var referencingService = controllerServiceData.getItemById(referencingComponent.id);
-
- // create the markup for the references
- createReferencingComponents(referencingServiceReferencesContainer, referencingService.referencingComponents);
- } else {
- referencingServiceReferencesContainer.empty();
+
+ // select the selected row
+ var row = controllerServiceData.getRowById(referencingComponent.id);
+ controllerServiceGrid.setSelectedRows([row]);
+ controllerServiceGrid.scrollRowIntoView(row);
+
+ // close the dialog and shell
+ referenceContainer.closest('.dialog').modal('hide');
+ });
+
+ // container for this service's references
+ var referencingServiceReferencesContainer = $('<div class="referencing-component-references hidden"></div>');
+ var serviceTwist = $('<div class="service expansion-button collapsed pointer"></div>').on('click', function() {
+ if (serviceTwist.hasClass('collapsed')) {
+ var controllerServiceGrid = $('#controller-services-table').data('gridInstance');
+ var controllerServiceData = controllerServiceGrid.getData();
+ var referencingService = controllerServiceData.getItemById(referencingComponent.id);
+
+ // create the markup for the references
+ createReferencingComponents(referencingServiceReferencesContainer, referencingService.referencingComponents);
+ } else {
+ referencingServiceReferencesContainer.empty();
+ }
+
+ // toggle visibility
+ toggle(serviceTwist, referencingServiceReferencesContainer);
+
+ // update borders as necessary
+ updateReferencingComponentsBorder(referenceContainer);
+ });
+
+ // state
+ var serviceState = $('<div class="referencing-component-state"></div>').addClass(referencingComponent.id + '-state');
+ updateReferencingServiceState(serviceState, referencingComponent);
+
+ // bulletin
+ var serviceBulletins = $('<div class="referencing-component-bulletins"></div>').addClass(referencingComponent.id + '-bulletins');
+
+ // type
+ var serviceType = $('<span class="referencing-component-type"></span>').text(nf.Common.substringAfterLast(referencingComponent.type, '.'));
+
+ // service
+ var serviceItem = $('<li></li>').append(serviceTwist).append(serviceState).append(serviceBulletins).append(serviceLink).append(serviceType).append(referencingServiceReferencesContainer);
+
+ services.append(serviceItem);
+ } else if (referencingComponent.referenceType === 'ReportingTask') {
+ var reportingTaskLink = $('<span class="referencing-component-name link"></span>').text(referencingComponent.name).on('click', function () {
+ var reportingTaskGrid = $('#reporting-tasks-table').data('gridInstance');
+ var reportingTaskData = reportingTaskGrid.getData();
+
+ // select the selected row
+ var row = reportingTaskData.getRowById(referencingComponent.id);
+ reportingTaskGrid.setSelectedRows([row]);
+ reportingTaskGrid.scrollRowIntoView(row);
+
+ // select the reporting task tab
+ $('#settings-tabs').find('li:last').click();
+
+ // close the dialog and shell
+ referenceContainer.closest('.dialog').modal('hide');
+ });
+
+ // state
+ var reportingTaskState = $('<div class="referencing-component-state"></div>').addClass(referencingComponent.id + '-state');
+ updateReferencingSchedulableComponentState(reportingTaskState, referencingComponent);
+
+ // bulletins
+ var reportingTaskBulletins = $('<div class="referencing-component-bulletins"></div>').addClass(referencingComponent.id + '-bulletins');
+
+ // type
+ var reportingTaskType = $('<span class="referencing-component-type"></span>').text(nf.Common.substringAfterLast(referencingComponent.type, '.'));
+
+ // active thread count
+ var reportingTaskActiveThreadCount = $('<span class="referencing-component-active-thread-count"></span>').addClass(referencingComponent.id + '-active-threads');
+ if (nf.Common.isDefinedAndNotNull(referencingComponent.activeThreadCount) && referencingComponent.activeThreadCount > 0) {
+ reportingTaskActiveThreadCount.text('(' + referencingComponent.activeThreadCount + ')');
}
-
- // toggle visibility
- toggle(serviceTwist, referencingServiceReferencesContainer);
-
- // update borders as necessary
- updateReferencingComponentsBorder(referenceContainer);
- });
-
- // state
- var serviceState = $('<div class="referencing-component-state"></div>').addClass(referencingComponent.id + '-state');
- updateReferencingServiceState(serviceState, referencingComponent);
-
- // bulletin
- var serviceBulletins = $('<div class="referencing-component-bulletins"></div>').addClass(referencingComponent.id + '-bulletins');
-
- // type
- var serviceType = $('<span class="referencing-component-type"></span>').text(nf.Common.substringAfterLast(referencingComponent.type, '.'));
-
- // service
- var serviceItem = $('<li></li>').append(serviceTwist).append(serviceState).append(serviceBulletins).append(serviceLink).append(serviceType).append(referencingServiceReferencesContainer);
-
- services.append(serviceItem);
- } else if (referencingComponent.referenceType === 'ReportingTask') {
- var reportingTaskLink = $('<span class="referencing-component-name link"></span>').text(referencingComponent.name).on('click', function () {
- var reportingTaskGrid = $('#reporting-tasks-table').data('gridInstance');
- var reportingTaskData = reportingTaskGrid.getData();
-
- // select the selected row
- var row = reportingTaskData.getRowById(referencingComponent.id);
- reportingTaskGrid.setSelectedRows([row]);
- reportingTaskGrid.scrollRowIntoView(row);
-
- // select the reporting task tab
- $('#settings-tabs').find('li:last').click();
-
- // close the dialog and shell
- referenceContainer.closest('.dialog').modal('hide');
- });
-
- // state
- var reportingTaskState = $('<div class="referencing-component-state"></div>').addClass(referencingComponent.id + '-state');
- updateReferencingSchedulableComponentState(reportingTaskState, referencingComponent);
-
- // bulletins
- var reportingTaskBulletins = $('<div class="referencing-component-bulletins"></div>').addClass(referencingComponent.id + '-bulletins');
-
- // type
- var reportingTaskType = $('<span class="referencing-component-type"></span>').text(nf.Common.substringAfterLast(referencingComponent.type, '.'));
-
- // active thread count
- var reportingTaskActiveThreadCount = $('<span class="referencing-component-active-thread-count"></span>').addClass(referencingComponent.id + '-active-threads');
- if (nf.Common.isDefinedAndNotNull(referencingComponent.activeThreadCount) && referencingComponent.activeThreadCount > 0) {
- reportingTaskActiveThreadCount.text('(' + referencingComponent.activeThreadCount + ')');
+
+ // reporting task
+ var reportingTaskItem = $('<li></li>').append(reportingTaskState).append(reportingTaskBulletins).append(reportingTaskLink).append(reportingTaskType).append(reportingTaskActiveThreadCount);
+ tasks.append(reportingTaskItem);
}
-
- // reporting task
- var reportingTaskItem = $('<li></li>').append(reportingTaskState).append(reportingTaskBulletins).append(reportingTaskLink).append(reportingTaskType).append(reportingTaskActiveThreadCount);
- tasks.append(reportingTaskItem);
}
});
@@ -537,6 +548,7 @@ nf.ControllerService = (function () {
createReferenceBlock('Processors', processors);
createReferenceBlock('Reporting Tasks', tasks);
createReferenceBlock('Controller Services', services);
+ createReferenceBlock('Unauthorized', unauthorized);
};
/**
@@ -561,35 +573,34 @@ nf.ControllerService = (function () {
/**
* Sets whether the specified controller service is enabled.
*
- * @param {object} controllerService
+ * @param {object} controllerServiceEntity
* @param {boolean} enabled
* @param {function} pollCondition
*/
- var setEnabled = function (controllerService, enabled, pollCondition) {
+ var setEnabled = function (controllerServiceEntity, enabled, pollCondition) {
// build the request entity
- var controllerServiceEntity = {
- 'revision': nf.Client.getRevision(),
- 'controllerService': {
- 'id': controllerService.id,
+ var updateControllerServiceEntity = {
+ 'revision': nf.Client.getRevision(controllerServiceEntity),
+ 'component': {
+ 'id': controllerServiceEntity.id,
'state': enabled ? 'ENABLED' : 'DISABLED'
}
};
var updated = $.ajax({
type: 'PUT',
- url: controllerService.uri,
- data: JSON.stringify(controllerServiceEntity),
+ url: controllerServiceEntity.component.uri,
+ data: JSON.stringify(updateControllerServiceEntity),
dataType: 'json',
contentType: 'application/json'
}).done(function (response) {
- // TODO
- // nf.Client.setRevision(response.revision);
+ renderControllerService(response);
}).fail(nf.Common.handleAjaxError);
// wait until the polling of each service finished
return $.Deferred(function(deferred) {
updated.done(function() {
- var serviceUpdated = pollService(controllerService, function (service, bulletins) {
+ var serviceUpdated = pollService(controllerServiceEntity.component, function (service, bulletins) {
if ($.isArray(bulletins)) {
if (enabled) {
updateBulletins(bulletins, $('#enable-controller-service-bulletins'));
@@ -631,7 +642,7 @@ nf.ControllerService = (function () {
var checkReferencingServices = function (referencingComponents) {
$.each(referencingComponents, function (_, referencingComponentEntity) {
- var referencingComponent = referencingComponentEntity.controllerServiceReferencingComponent;
+ var referencingComponent = referencingComponentEntity.component;
if (referencingComponent.referenceType === 'ControllerService') {
// add the id
ids.add(referencingComponent.id);
@@ -653,41 +664,45 @@ nf.ControllerService = (function () {
* Updates the scheduled state of the processors/reporting tasks referencing
* the specified controller service.
*
- * @param {object} controllerService
+ * @param {object} controllerServiceEntity
* @param {boolean} running
* @param {function} pollCondition
*/
- var updateReferencingSchedulableComponents = function (controllerService, running, pollCondition) {
+ var updateReferencingSchedulableComponents = function (controllerServiceEntity, running, pollCondition) {
var referenceEntity = {
- 'revision': nf.Client.getRevision(),
- 'id': controllerService.id,
- 'state': running ? 'RUNNING' : 'STOPPED'
+ 'id': controllerServiceEntity.id,
+ 'state': running ? 'RUNNING' : 'STOPPED',
+ 'referencingComponentRevisions': {}
};
+ // include the revision of each referencing component
+ $.each(controllerServiceEntity.component.referencingComponents, function(_, referencingComponent) {
+ referenceEntity.referencingComponentRevisions[referencingComponent.id] = nf.Client.getRevision(referencingComponent);
+ });
+
// issue the request to update the referencing components
var updated = $.ajax({
type: 'PUT',
- url: controllerService.uri + '/references',
+ url: controllerServiceEntity.component.uri + '/references',
data: JSON.stringify(referenceEntity),
dataType: 'json',
contentType: 'application/json'
- }).done(function (response) {
- // TODO
- // nf.Client.setRevision(response.revision);
}).fail(nf.Common.handleAjaxError);
+
+ // Note: updated revisions will be retrieved after updateReferencingSchedulableComponents is invoked
// wait unil the polling of each service finished
return $.Deferred(function(deferred) {
updated.done(function(response) {
// update the controller service
- controllerService.referencingComponents = response.controllerServiceReferencingComponents;
+ controllerServiceEntity.component.referencingComponents = response.controllerServiceReferencingComponents;
// if we're just starting schedulable components we're done when the update is finished
if (running) {
deferred.resolve();
} else {
// identify all referencing services
- var services = getReferencingControllerServiceIds(controllerService);
+ var services = getReferencingControllerServiceIds(controllerServiceEntity.component);
// get the controller service grid
var controllerServiceGrid = $('#controller-services-table').data('gridInstance');
@@ -747,7 +762,7 @@ nf.ControllerService = (function () {
$.when(bulletins, service).done(function (bulletinResult, serviceResult) {
var bulletinResponse = bulletinResult[0];
var serviceResponse = serviceResult[0];
- conditionMet(serviceResponse.controllerService, bulletinResponse.bulletinBoard.bulletins);
+ conditionMet(serviceResponse.component, bulletinResponse.bulletinBoard.bulletins);
}).fail(function (xhr, status, error) {
deferred.reject();
nf.Common.handleAjaxError(xhr, status, error);
@@ -791,7 +806,7 @@ nf.ControllerService = (function () {
var stillRunning = false;
$.each(referencingComponents, function(_, referencingComponentEntity) {
- var referencingComponent = referencingComponentEntity.controllerServiceReferencingComponent;
+ var referencingComponent = referencingComponentEntity.component;
if (referencingComponent.referenceType === 'Processor' || referencingComponent.referenceType === 'ReportingTask') {
if (referencingComponent.state === 'RUNNING' || referencingComponent.activeThreadCount > 0) {
stillRunning = true;
@@ -816,7 +831,7 @@ nf.ControllerService = (function () {
var referencingComponents = service.referencingComponents;
$.each(referencingComponents, function(_, referencingComponentEntity) {
- var referencingComponent = referencingComponentEntity.controllerServiceReferencingComponent;
+ var referencingComponent = referencingComponentEntity.component;
if (referencingComponent.referenceType === 'Processor' || referencingComponent.referenceType === 'ReportingTask') {
referencingSchedulableComponents.push(referencingComponent.id);
}
@@ -839,7 +854,7 @@ nf.ControllerService = (function () {
var notEnabled = false;
$.each(referencingComponents, function(_, referencingComponentEntity) {
- var referencingComponent = referencingComponentEntity.controllerServiceReferencingComponent;
+ var referencingComponent = referencingComponentEntity.component;
if (referencingComponent.referenceType === 'ControllerService') {
if (referencingComponent.state !== 'ENABLING' && referencingComponent.state !== 'ENABLED') {
notEnabled = true;
@@ -861,7 +876,7 @@ nf.ControllerService = (function () {
var referencingComponents = service.referencingComponents;
$.each(referencingComponents, function(_, referencingComponentEntity) {
- var referencingComponent = referencingComponentEntity.controllerServiceReferencingComponent;
+ var referencingComponent = referencingComponentEntity.component;
if (referencingComponent.referenceType === 'ControllerService') {
referencingSchedulableComponents.push(referencingComponent.id);
}
@@ -884,7 +899,7 @@ nf.ControllerService = (function () {
var notDisabled = false;
$.each(referencingComponents, function(_, referencingComponentEntity) {
- var referencingComponent = referencingComponentEntity.controllerServiceReferencingComponent;
+ var referencingComponent = referencingComponentEntity.component;
if (referencingComponent.referenceType === 'ControllerService') {
if (referencingComponent.state !== 'DISABLED') {
notDisabled = true;
@@ -906,7 +921,7 @@ nf.ControllerService = (function () {
var referencingComponents = service.referencingComponents;
$.each(referencingComponents, function(_, referencingComponentEntity) {
- var referencingComponent = referencingComponentEntity.controllerServiceReferencingComponent;
+ var referencingComponent = referencingComponentEntity.component;
if (referencingComponent.referenceType === 'ControllerService') {
referencingSchedulableComponents.push(referencingComponent.id);
}
@@ -919,38 +934,42 @@ nf.ControllerService = (function () {
/**
* Updates the referencing services with the specified state.
*
- * @param {object} controllerService
+ * @param {object} controllerServiceEntity
* @param {boolean} enabled
* @param {function} pollCondition
*/
- var updateReferencingServices = function (controllerService, enabled, pollCondition) {
+ var updateReferencingServices = function (controllerServiceEntity, enabled, pollCondition) {
// build the reference entity
var referenceEntity = {
- 'revision': nf.Client.getRevision(),
- 'id': controllerService.id,
- 'state': enabled ? 'ENABLED' : 'DISABLED'
+ 'id': controllerServiceEntity.id,
+ 'state': enabled ? 'ENABLED' : 'DISABLED',
+ 'referencingComponentRevisions': {}
};
+
+ // include the revision of each referencing component
+ $.each(controllerServiceEntity.component.referencingComponents, function(_, referencingComponent) {
+ referenceEntity.referencingComponentRevisions[referencingComponent.id] = nf.Client.getRevision(referencingComponent);
+ });
// issue the request to update the referencing components
var updated = $.ajax({
type: 'PUT',
- url: controllerService.uri + '/references',
+ url: controllerServiceEntity.component.uri + '/references',
data: JSON.stringify(referenceEntity),
dataType: 'json',
contentType: 'application/json'
- }).done(function (response) {
- // TODO
- // nf.Client.setRevision(response.revision);
}).fail(nf.Common.handleAjaxError);
+ // Note: updated revisions will be retrieved after updateReferencingServices is invoked
+
// wait unil the polling of each service finished
return $.Deferred(function(deferred) {
updated.done(function(response) {
// update the controller service
- controllerService.referencingComponents = response.controllerServiceReferencingComponents;
+ controllerServiceEntity.component.referencingComponents = response.controllerServiceReferencingComponents;
// identify all referencing services
- var services = getReferencingControllerServiceIds(controllerService);
+ var services = getReferencingControllerServiceIds(controllerServiceEntity.component);
// get the controller service grid
var controllerServiceGrid = $('#controller-services-table').data('gridInstance');
@@ -992,9 +1011,34 @@ nf.ControllerService = (function () {
// load the controller referencing components list
var referencingComponentsContainer = $('#disable-controller-service-referencing-components');
createReferencingComponents(referencingComponentsContainer, controllerService.referencingComponents);
-
+
+ var hasUnauthorized = false;
+ $.each(controllerService.referencingComponents, function (_, referencingComponent) {
+ if (referencingComponent.accessPolicy.canRead === false || referencingComponent.accessPolicy.canWrite === false) {
+ hasUnauthorized = true;
+ return false;
+ }
+ });
+
+ // build the button model
+ var buttons = [];
+ if (hasUnauthorized === false) {
+ buttons.push({
+ buttonText: 'Disable',
+ handler: {
+ click: disableHandler
+ }
+ });
+ }
+ buttons.push({
+ buttonText: 'Cancel',
+ handler: {
+ click: closeModal
+ }
+ });
+
// show the dialog
- $('#disable-controller-service-dialog').modal('show');
+ $('#disable-controller-service-dialog').modal('setButtonModel', buttons).modal('show');
// load the bulletins
queryBulletins([controllerService.id]).done(function(response) {
@@ -1018,7 +1062,7 @@ nf.ControllerService = (function () {
// load the controller referencing components list
var referencingComponentsContainer = $('#enable-controller-service-referencing-components');
createReferencingComponents(referencingComponentsContainer, controllerService.referencingComponents);
-
+
// show the dialog
$('#enable-controller-service-dialog').modal('show');
@@ -1065,7 +1109,8 @@ nf.ControllerService = (function () {
var controllerServiceId = $('#disable-controller-service-id').text();
var controllerServiceGrid = $('#controller-services-table').data('gridInstance');
var controllerServiceData = controllerServiceGrid.getData();
- var controllerService = controllerServiceData.getItemById(controllerServiceId);
+ var controllerServiceEntity = controllerServiceData.getItemById(controllerServiceId);
+ var controllerService = controllerServiceEntity.component;
// whether or not to continue polling
var continuePolling = function () {
@@ -1088,7 +1133,7 @@ nf.ControllerService = (function () {
$.Deferred(function (deferred) {
// stop all referencing schedulable components
- var stopped = updateReferencingSchedulableComponents(controllerService, false, continuePolling);
+ var stopped = updateReferencingSchedulableComponents(controllerServiceEntity, false, continuePolling);
// once everything has stopped
stopped.done(function () {
@@ -1096,7 +1141,7 @@ nf.ControllerService = (function () {
var disableReferencingServices = $('#disable-referencing-services').addClass('ajax-loading');
// disable all referencing services
- var disabled = updateReferencingServices(controllerService, false, continuePolling);
+ var disabled = updateReferencingServices(controllerServiceEntity, false, continuePolling);
// everything is disabled
disabled.done(function () {
@@ -1104,7 +1149,7 @@ nf.ControllerService = (function () {
var disableControllerService = $('#disable-controller-service').addClass('ajax-loading');
// disable this service
- setEnabled(controllerService, false, continuePolling).done(function () {
+ setEnabled(controllerServiceEntity, false, continuePolling).done(function () {
deferred.resolve();
disableControllerService.removeClass('ajax-loading').addClass('ajax-complete');
}).fail(function () {
@@ -1141,6 +1186,38 @@ nf.ControllerService = (function () {
var enableDialog = $(this);
var canceled = false;
+ // get the controller service
+ var controllerServiceId = $('#enable-controller-service-id').text();
+ var controllerServiceGrid = $('#controller-services-table').data('gridInstance');
+ var controllerServiceData = controllerServiceGrid.getData();
+ var controllerServiceEntity = controllerServiceData.getItemById(controllerServiceId);
+ var controllerService = controllerServiceEntity.component;
+
+ var hasUnauthorized = false;
+ $.each(controllerService.referencingComponents, function (_, referencingComponent) {
+ if (referencingComponent.accessPolicy.canRead === false || referencingComponent.accessPolicy.canWrite === false) {
+ hasUnauthorized = true;
+ return false;
+ }
+ });
+
+ // determine if we want to also activate referencing components
+ var scope = $('#enable-controller-service-scope').combo('getSelectedOption').value;
+
+ // ensure appropriate access
+ if (scope === config.serviceAndReferencingComponents && hasUnauthorized) {
+ nf.Dialog.showOkDialog({
+ overlayBackground: false,
+ dialogContent: 'Unable to enable due to unauthorized referencing components.'
+ });
+ return;
+ }
+
+ // update visibility
+ if (scope === config.serviceOnly) {
+ $('#enable-controller-service-progress li.referencing-component').hide();
+ }
+
// only provide a cancel option
enableDialog.modal('setButtonModel', [{
buttonText: 'Cancel',
@@ -1153,21 +1230,10 @@ nf.ControllerService = (function () {
}
}]);
- // determine if we want to also activate referencing components
- var scope = $('#enable-controller-service-scope').combo('getSelectedOption').value;
- if (scope === config.serviceOnly) {
- $('#enable-controller-service-progress li.referencing-component').hide();
- }
-
// show the progress
$('#enable-controller-service-scope-container').hide();
$('#enable-controller-service-progress-container').show();
- // get the controller service
- var controllerServiceId = $('#enable-controller-service-id').text();
- var controllerServiceGrid = $('#controller-services-table').data('gridInstance');
- var controllerServiceData = controllerServiceGrid.getData();
- var controllerService = controllerServiceData.getItemById(controllerServiceId);
// whether or not to continue polling
var continuePolling = function () {
@@ -1190,7 +1256,7 @@ nf.ControllerService = (function () {
$.Deferred(function (deferred) {
// enable this controller service
- var enable = setEnabled(controllerService, true, continuePolling);
+ var enable = setEnabled(controllerServiceEntity, true, continuePolling);
if (scope === config.serviceAndReferencingComponents) {
// once the service is enabled, activate all referencing components
@@ -1199,7 +1265,7 @@ nf.ControllerService = (function () {
var enableReferencingServices = $('#enable-referencing-services').addClass('ajax-loading');
// enable the referencing services
- var servicesEnabled = updateReferencingServices(controllerService, true, continuePolling);
+ var servicesEnabled = updateReferencingServices(controllerServiceEntity, true, continuePolling);
// once all the referencing services are enbled
servicesEnabled.done(function () {
@@ -1207,7 +1273,7 @@ nf.ControllerService = (function () {
var enableReferencingSchedulable = $('#enable-referencing-schedulable').addClass('ajax-loading');
// start all referencing schedulable components
- updateReferencingSchedulableComponents(controllerService, true, continuePolling).done(function() {
+ updateReferencingSchedulableComponents(controllerServiceEntity, true, continuePolling).done(function() {
deferred.resolve();
enableReferencingSchedulable.removeClass('ajax-loading').addClass('ajax-complete');
}).fail(function () {
@@ -1281,8 +1347,8 @@ nf.ControllerService = (function () {
deferred.resolve();
},
yesHandler: function () {
- var controllerService = $('#controller-service-configuration').data('controllerServiceDetails');
- saveControllerService(controllerService).done(function () {
+ var controllerServiceEntity = $('#controller-service-configuration').data('controllerServiceDetails');
+ saveControllerService(controllerServiceEntity).done(function () {
deferred.resolve();
}).fail(function () {
deferred.reject();
@@ -1295,22 +1361,24 @@ nf.ControllerService = (function () {
}).promise();
};
- var saveControllerService = function (controllerService) {
+ var saveControllerService = function (controllerServiceEntity) {
// marshal the settings and properties and update the controller service
var updatedControllerService = marshalDetails();
// ensure details are valid as far as we can tell
if (validateDetails(updatedControllerService)) {
+ updatedControllerService['revision'] = nf.Client.getRevision(controllerServiceEntity);
+
var previouslyReferencedServiceIds = [];
- $.each(identifyReferencedServiceDescriptors(controllerService), function (_, descriptor) {
- var modifyingService = !nf.Common.isUndefined(updatedControllerService.controllerService.properties) && !nf.Common.isUndefined(updatedControllerService.controllerService.properties[descriptor.name]);
- var isCurrentlyConfigured = nf.Common.isDefinedAndNotNull(controllerService.properties[descriptor.name]);
+ $.each(identifyReferencedServiceDescriptors(controllerServiceEntity.component), function (_, descriptor) {
+ var modifyingService = !nf.Common.isUndefined(updatedControllerService.component.properties) && !nf.Common.isUndefined(updatedControllerService.component.properties[descriptor.name]);
+ var isCurrentlyConfigured = nf.Common.isDefinedAndNotNull(controllerServiceEntity.component.properties[descriptor.name]);
// if we are attempting to update a controller service reference
if (modifyingService && isCurrentlyConfigured) {
// record the current value if set
- previouslyReferencedServiceIds.push(controllerService.properties[descriptor.name]);
+ previouslyReferencedServiceIds.push(controllerServiceEntity.component.properties[descriptor.name]);
}
});
@@ -1318,19 +1386,17 @@ nf.ControllerService = (function () {
return $.ajax({
type: 'PUT',
data: JSON.stringify(updatedControllerService),
- url: controllerService.uri,
+ url: controllerServiceEntity.component.uri,
dataType: 'json',
contentType: 'application/json'
}).done(function (response) {
- if (nf.Common.isDefinedAndNotNull(response.controllerService)) {
- // TODO - update the revision
- // nf.Client.setRevision(response.revision);
-
- // reload all previously referenced controller services
- $.each(previouslyReferencedServiceIds, function(_, oldServiceReferenceId) {
- reloadControllerService(oldServiceReferenceId);
- });
- }
+ // reload the controller service
+ renderControllerService(response);
+
+ // reload all previously referenced controller services
+ $.each(previouslyReferencedServiceIds, function(_, oldServiceReferenceId) {
+ reloadControllerService(oldServiceReferenceId);
+ });
}).fail(handleControllerServiceConfigurationError);
} else {
return $.Deferred(function (deferred) {
@@ -1413,11 +1479,6 @@ nf.ControllerService = (function () {
}
});
- // we clustered we need to show the controls for editing the availability
- if (nf.Canvas.isClustered()) {
- $('#controller-service-availability-setting-container').show();
- }
-
// initialize the conroller service configuration dialog
$('#controller-service-configuration').data('mode', config.edit).modal({
headerText: 'Configure Controller Service',
@@ -1458,17 +1519,6 @@ nf.ControllerService = (function () {
$('#disable-controller-service-dialog').modal({
headerText: 'Disable Controller Service',
overlayBackground: false,
- buttons: [{
- buttonText: 'Disable',
- handler: {
- click: disableHandler
- }
- }, {
- buttonText: 'Cancel',
- handler: {
- click: closeModal
- }
- }],
handler: {
close: function() {
var disableDialog = $(this);
@@ -1584,9 +1634,9 @@ nf.ControllerService = (function () {
/**
* Shows the configuration dialog for the specified controller service.
*
- * @argument {object} controllerService The controller service
+ * @argument {object} controllerServiceEntity The controller service
*/
- showConfiguration: function (controllerService) {
+ showConfiguration: function (controllerServiceEntity) {
var controllerServiceDialog = $('#controller-service-configuration');
if (controllerServiceDialog.data('mode') === config.readOnly) {
// update the visibility
@@ -1609,27 +1659,28 @@ nf.ControllerService = (function () {
// reload the service in case the property descriptors have changed
var reloadService = $.ajax({
type: 'GET',
- url: controllerService.uri,
+ url: controllerServiceEntity.component.uri,
dataType: 'json'
});
// get the controller service history
var loadHistory = $.ajax({
type: 'GET',
- url: '../nifi-api/history/controller-services/' + encodeURIComponent(controllerService.id),
+ url: '../nifi-api/history/controller-services/' + encodeURIComponent(controllerServiceEntity.id),
dataType: 'json'
});
// once everything is loaded, show the dialog
$.when(reloadService, loadHistory).done(function (serviceResponse, historyResponse) {
// get the updated controller service
- controllerService = serviceResponse[0].controllerService;
+ controllerServiceEntity = serviceResponse[0];
+ var controllerService = controllerServiceEntity.component;
// get the controller service history
var controllerServiceHistory = historyResponse[0].componentHistory;
// record the controller service details
- controllerServiceDialog.data('controllerServiceDetails', controllerService);
+ controllerServiceDialog.data('controllerServiceDetails', controllerServiceEntity);
// populate the controller service settings
nf.Common.populateField('controller-service-id', controllerService['id']);
@@ -1637,15 +1688,6 @@ nf.ControllerService = (function () {
$('#controller-service-name').val(controllerService['name']);
$('#controller-service-comments').val(controllerService['comments']);
- // select the availability when appropriate
- if (nf.Canvas.isClustered()) {
- if (controllerService['availability'] === 'node') {
- $('#controller-service-availability').text('Node');
- } else {
- $('#controller-service-availability').text('Cluster Manager');
- }
- }
-
// get the reference container
var referenceContainer = $('#controller-service-referencing-components');
@@ -1660,10 +1702,8 @@ nf.ControllerService = (function () {
$('#controller-service-properties').propertytable('saveRow');
// save the controller service
- saveControllerService(controllerService).done(function (response) {
- // reload the controller service
- renderControllerService(response.controllerService);
- reloadControllerServiceReferences(response.controllerService);
+ saveControllerService(controllerServiceEntity).done(function (response) {
+ reloadControllerServiceReferences(response.component);
// close the details panel
controllerServiceDialog.modal('hide');
@@ -1713,7 +1753,7 @@ nf.ControllerService = (function () {
overlayBackground: false,
noHandler: openCustomUi,
yesHandler: function () {
- saveControllerService(controllerService).done(function () {
+ saveControllerService(controllerServiceEntity).done(function () {
// open the custom ui
openCustomUi();
});
@@ -1745,9 +1785,9 @@ nf.ControllerService = (function () {
/**
* Shows the controller service details in a read only dialog.
*
- * @param {object} controllerService
+ * @param {object} controllerServiceEntity
*/
- showDetails: function(controllerService) {
+ showDetails: function(controllerServiceEntity) {
var controllerServiceDialog = $('#controller-service-configuration');
if (controllerServiceDialog.data('mode') === config.edit) {
// update the visibility
@@ -1766,27 +1806,28 @@ nf.ControllerService = (function () {
// reload the service in case the property descriptors have changed
var reloadService = $.ajax({
type: 'GET',
- url: controllerService.uri,
+ url: controllerServiceEntity.component.uri,
dataType: 'json'
});
// get the controller service history
var loadHistory = $.ajax({
type: 'GET',
- url: '../nifi-api/history/controller-services/' + encodeURIComponent(controllerService.id),
+ url: '../nifi-api/history/controller-services/' + encodeURIComponent(controllerServiceEntity.id),
dataType: 'json'
});
// once everything is loaded, show the dialog
$.when(reloadService, loadHistory).done(function (serviceResponse, historyResponse) {
// get the updated controller service
- controllerService = serviceResponse[0].controllerService;
+ controllerServiceEntity = serviceResponse[0];
+ var controllerService = controllerServiceEntity.component;
// get the controller service history
var controllerServiceHistory = historyResponse[0].componentHistory;
// record the controller service details
- controllerServiceDialog.data('controllerServiceDetails', controllerService);
+ controllerServiceDialog.data('controllerServiceDetails', controllerServiceEntity);
// populate the controller service settings
nf.Common.populateField('controller-service-id', controllerService['id']);
@@ -1794,15 +1835,6 @@ nf.ControllerService = (function () {
nf.Common.populateField('read-only-controller-service-name', controllerService['name']);
nf.Common.populateField('read-only-controller-service-comments', controllerService['comments']);
- // select the availability when appropriate
- if (nf.Canvas.isClustered()) {
- if (controllerService['availability'] === 'node') {
- $('#controller-service-availability').text('Node');
- } else {
- $('#controller-service-availability').text('Cluster Manager');
- }
- }
-
// get the reference container
var referenceContainer = $('#controller-service-referencing-components');
@@ -1857,19 +1889,19 @@ nf.ControllerService = (function () {
/**
* Enables the specified controller service.
*
- * @param {object} controllerService
+ * @param {object} controllerServiceEntity
*/
- enable: function(controllerService) {
- showEnableControllerServiceDialog(controllerService);
+ enable: function(controllerServiceEntity) {
+ showEnableControllerServiceDialog(controllerServiceEntity.component);
},
/**
* Disables the specified controller service.
*
- * @param {object} controllerService
+ * @param {object} controllerServiceEntity
*/
- disable: function(controllerService) {
- showDisableControllerServiceDialog(controllerService);
+ disable: function(controllerServiceEntity) {
+ showDisableControllerServiceDialog(controllerServiceEntity.component);
},
/**
@@ -1888,30 +1920,27 @@ nf.ControllerService = (function () {
/**
* Deletes the specified controller service.
*
- * @param {object} controllerService
+ * @param {object} controllerServiceEntity
*/
- remove: function(controllerService) {
+ remove: function(controllerServiceEntity) {
// prompt for removal?
- var revision = nf.Client.getRevision();
+ var revision = nf.Client.getRevision(controllerServiceEntity);
$.ajax({
type: 'DELETE',
- url: controllerService.uri + '?' + $.param({
+ url: controllerServiceEntity.component.uri + '?' + $.param({
version: revision.version,
clientId: revision.clientId
}),
dataType: 'json'
}).done(function (response) {
- // TODO
- // nf.Client.setRevision(response.revision);
-
// remove the service
var controllerServiceGrid = $('#controller-services-table').data('gridInstance');
var controllerServiceData = controllerServiceGrid.getData();
- controllerServiceData.deleteItem(controllerService.id);
+ controllerServiceData.deleteItem(controllerServiceEntity.id);
// reload the as necessary
- reloadControllerServiceReferences(controllerService);
+ reloadControllerServiceReferences(controllerServiceEntity.component);
}).fail(nf.Common.handleAjaxError);
}
};
http://git-wip-us.apache.org/repos/asf/nifi/blob/8bb56fca/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/js/nf/canvas/nf-processor-configuration.js
----------------------------------------------------------------------
diff --git a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/js/nf/canvas/nf-processor-configuration.js b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/js/nf/canvas/nf-processor-configuration.js
index ea762d4..e2ea1da 100644
--- a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/js/nf/canvas/nf-processor-configuration.js
+++ b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/js/nf/canvas/nf-processor-configuration.js
@@ -437,8 +437,10 @@ nf.ProcessorConfiguration = (function () {
data: JSON.stringify(updatedProcessor),
url: processor.uri,
dataType: 'json',
- processData: false,
contentType: 'application/json'
+ }).done(function (response) {
+ // set the new processor state based on the response
+ nf.Processor.set(response);
}).fail(handleProcessorConfigurationError);
} else {
return $.Deferred(function (deferred) {
@@ -714,9 +716,6 @@ nf.ProcessorConfiguration = (function () {
// save the processor
saveProcessor(processor).done(function (response) {
- // set the new processor state based on the response
- nf.Processor.set(response);
-
// reload the processor's outgoing connections
reloadProcessorConnections(processor);
http://git-wip-us.apache.org/repos/asf/nifi/blob/8bb56fca/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/js/nf/canvas/nf-reporting-task.js
----------------------------------------------------------------------
diff --git a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/js/nf/canvas/nf-reporting-task.js b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/js/nf/canvas/nf-reporting-task.js
index 4d2fbd4..9555163 100644
--- a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/js/nf/canvas/nf-reporting-task.js
+++ b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/js/nf/canvas/nf-reporting-task.js
@@ -136,8 +136,7 @@ nf.ReportingTask = (function () {
// create the reporting task entity
var reportingTaskEntity = {};
- reportingTaskEntity['revision'] = nf.Client.getRevision();
- reportingTaskEntity['reportingTask'] = reportingTaskDto;
+ reportingTaskEntity['component'] = reportingTaskDto;
// return the marshaled details
return reportingTaskEntity;
@@ -150,7 +149,7 @@ nf.ReportingTask = (function () {
*/
var validateDetails = function (details) {
var errors = [];
- var reportingTask = details['reportingTask'];
+ var reportingTask = details['component'];
if (nf.Common.isBlank(reportingTask['schedulingPeriod'])) {
errors.push('Run schedule must be specified');
@@ -173,43 +172,40 @@ nf.ReportingTask = (function () {
*
* @param {object} reportingTask
*/
- var renderReportingTask = function (reportingTask) {
+ var renderReportingTask = function (reportingTaskEntity) {
// get the table and update the row accordingly
var reportingTaskGrid = $('#reporting-tasks-table').data('gridInstance');
var reportingTaskData = reportingTaskGrid.getData();
- var currentReportingTask = reportingTaskData.getItemById(reportingTask.id);
- reportingTaskData.updateItem(reportingTask.id, $.extend({
+ var currentReportingTask = reportingTaskData.getItemById(reportingTaskEntity.id);
+ reportingTaskData.updateItem(reportingTaskEntity.id, $.extend({
bulletins: currentReportingTask.bulletins
- }, reportingTask));
+ }, reportingTaskEntity));
};
/**
*
- * @param {object} reportingTask
+ * @param {object} reportingTaskEntity
* @param {boolean} running
*/
- var setRunning = function (reportingTask, running) {
+ var setRunning = function (reportingTaskEntity, running) {
var entity = {
- 'revision': nf.Client.getRevision(),
- 'reportingTask': {
- 'id': reportingTask.id,
+ 'revision': nf.Client.getRevision(reportingTaskEntity),
+ 'component': {
+ 'id': reportingTaskEntity.id,
'state': running === true ? 'RUNNING' : 'STOPPED'
}
};
return $.ajax({
type: 'PUT',
- url: reportingTask.uri,
+ url: reportingTaskEntity.component.uri,
data: JSON.stringify(entity),
dataType: 'json',
contentType: 'application/json'
}).done(function (response) {
- // TODO - update the revision
- // nf.Client.setRevision(response.revision);
-
// update the task
- renderReportingTask(response.reportingTask);
- nf.ControllerService.reloadReferencedServices(response.reportingTask);
+ renderReportingTask(response);
+ nf.ControllerService.reloadReferencedServices(response.component);
}).fail(nf.Common.handleAjaxError);
};
@@ -250,24 +246,24 @@ nf.ReportingTask = (function () {
*
* @param {type} reportingTask
*/
- var saveReportingTask = function (reportingTask) {
+ var saveReportingTask = function (reportingTaskEntity) {
// marshal the settings and properties and update the reporting task
var updatedReportingTask = marshalDetails();
// ensure details are valid as far as we can tell
if (validateDetails(updatedReportingTask)) {
+ updatedReportingTask['revision'] = nf.Client.getRevision(reportingTaskEntity);
+
// update the selected component
return $.ajax({
type: 'PUT',
data: JSON.stringify(updatedReportingTask),
- url: reportingTask.uri,
+ url: reportingTaskEntity.component.uri,
dataType: 'json',
contentType: 'application/json'
}).done(function (response) {
- if (nf.Common.isDefinedAndNotNull(response.reportingTask)) {
- // TODO - update the revision
- // nf.Client.setRevision(response.revision);
- }
+ // update the reporting task
+ renderReportingTask(response);
}).fail(handleReportingTaskConfigurationError);
} else {
return $.Deferred(function (deferred) {
@@ -326,11 +322,6 @@ nf.ReportingTask = (function () {
}
});
- // we clustered we need to show the controls for editing the availability
- if (nf.Canvas.isClustered()) {
- $('#reporting-task-availability-setting-container').show();
- }
-
// initialize the reporting task configuration dialog
$('#reporting-task-configuration').data('mode', config.edit).modal({
headerText: 'Configure Reporting Task',
@@ -365,9 +356,9 @@ nf.ReportingTask = (function () {
/**
* Shows the configuration dialog for the specified reporting task.
*
- * @argument {reportingTask} reportingTask The reporting task
+ * @argument {reportingTask} reportingTaskEntity The reporting task
*/
- showConfiguration: function (reportingTask) {
+ showConfiguration: function (reportingTaskEntity) {
var reportingTaskDialog = $('#reporting-task-configuration');
if (reportingTaskDialog.data('mode') === config.readOnly) {
// update the visibility
@@ -390,27 +381,28 @@ nf.ReportingTask = (function () {
// reload the task in case the property descriptors have changed
var reloadTask = $.ajax({
type: 'GET',
- url: reportingTask.uri,
+ url: reportingTaskEntity.component.uri,
dataType: 'json'
});
// get the reporting task history
var loadHistory = $.ajax({
type: 'GET',
- url: '../nifi-api/history/reporting-tasks/' + encodeURIComponent(reportingTask.id),
+ url: '../nifi-api/history/reporting-tasks/' + encodeURIComponent(reportingTaskEntity.id),
dataType: 'json'
});
// once everything is loaded, show the dialog
$.when(reloadTask, loadHistory).done(function (taskResponse, historyResponse) {
// get the updated reporting task
- reportingTask = taskResponse[0].reportingTask;
+ reportingTaskEntity = taskResponse[0];
+ var reportingTask = reportingTaskEntity.component;
// get the reporting task history
var reportingTaskHistory = historyResponse[0].componentHistory;
// record the reporting task details
- $('#reporting-task-configuration').data('reportingTaskDetails', reportingTask);
+ $('#reporting-task-configuration').data('reportingTaskDetails', reportingTaskEntity);
// determine if the enabled checkbox is checked or not
var reportingTaskEnableStyle = 'checkbox-checked';
@@ -425,15 +417,6 @@ nf.ReportingTask = (function () {
$('#reporting-task-enabled').removeClass('checkbox-unchecked checkbox-checked').addClass(reportingTaskEnableStyle);
$('#reporting-task-comments').val(reportingTask['comments']);
- // select the availability when appropriate
- if (nf.Canvas.isClustered()) {
- if (reportingTask['availability'] === 'node') {
- $('#reporting-task-availability').text('Node');
- } else {
- $('#reporting-task-availability').text('Cluster Manager');
- }
- }
-
// get the default schedule period
var defaultSchedulingPeriod = reportingTask['defaultSchedulingPeriod'];
var cronSchedulingPeriod = $('#reporting-task-cron-driven-scheduling-period').val(defaultSchedulingPeriod['CRON_DRIVEN']);
@@ -479,10 +462,9 @@ nf.ReportingTask = (function () {
$('#reporting-task-properties').propertytable('saveRow');
// save the reporting task
- saveReportingTask(reportingTask).done(function (response) {
+ saveReportingTask(reportingTaskEntity).done(function (response) {
// reload the reporting task
- renderReportingTask(response.reportingTask);
- nf.ControllerService.reloadReferencedServices(response.reportingTask);
+ nf.ControllerService.reloadReferencedServices(response.component);
// close the details panel
$('#reporting-task-configuration').modal('hide');
@@ -514,7 +496,7 @@ nf.ReportingTask = (function () {
// show the custom ui
nf.CustomUi.showCustomUi($('#reporting-task-id').text(), reportingTask.customUiUrl, true).done(function () {
// once the custom ui is closed, reload the reporting task
- nf.ReportingTask.reload(reportingTask.id).done(function (response) {
+ nf.ReportingTask.reload(reportingTaskEntity.id).done(function (response) {
nf.ControllerService.reloadReferencedServices(response.reportingTask);
});
@@ -534,7 +516,7 @@ nf.ReportingTask = (function () {
overlayBackground: false,
noHandler: openCustomUi,
yesHandler: function () {
- saveReportingTask(reportingTask).done(function () {
+ saveReportingTask(reportingTaskEntity).done(function () {
// open the custom ui
openCustomUi();
});
@@ -563,9 +545,9 @@ nf.ReportingTask = (function () {
/**
* Shows the reporting task details in a read only dialog.
*
- * @param {object} reportingTask
+ * @param {object} reportingTaskEntity
*/
- showDetails: function(reportingTask) {
+ showDetails: function(reportingTaskEntity) {
var reportingTaskDialog = $('#reporting-task-configuration');
if (reportingTaskDialog.data('mode') === config.edit) {
// update the visibility
@@ -584,21 +566,22 @@ nf.ReportingTask = (function () {
// reload the task in case the property descriptors have changed
var reloadTask = $.ajax({
type: 'GET',
- url: reportingTask.uri,
+ url: reportingTaskEntity.component.uri,
dataType: 'json'
});
// get the reporting task history
var loadHistory = $.ajax({
type: 'GET',
- url: '../nifi-api/history/reporting-tasks/' + encodeURIComponent(reportingTask.id),
+ url: '../nifi-api/history/reporting-tasks/' + encodeURIComponent(reportingTaskEntity.id),
dataType: 'json'
});
// once everything is loaded, show the dialog
$.when(reloadTask, loadHistory).done(function (taskResponse, historyResponse) {
// get the updated reporting task
- reportingTask = taskResponse[0].reportingTask;
+ reportingTaskEntity = taskResponse[0];
+ var reportingTask = reportingTaskEntity.component;
// get the reporting task history
var reportingTaskHistory = historyResponse[0].componentHistory;
@@ -609,15 +592,6 @@ nf.ReportingTask = (function () {
nf.Common.populateField('read-only-reporting-task-name', reportingTask['name']);
nf.Common.populateField('read-only-reporting-task-comments', reportingTask['comments']);
- // select the availability when appropriate
- if (nf.Canvas.isClustered()) {
- if (reportingTask['availability'] === 'node') {
- $('#reporting-task-availability').text('Node');
- } else {
- $('#reporting-task-availability').text('Cluster Manager');
- }
- }
-
// make the scheduling strategy human readable
var schedulingStrategy = reportingTask['schedulingStrategy'];
if (schedulingStrategy === 'CRON_DRIVEN') {
@@ -673,19 +647,19 @@ nf.ReportingTask = (function () {
/**
* Starts the specified reporting task.
*
- * @param {object} reportingTask
+ * @param {object} reportingTaskEntity
*/
- start: function(reportingTask) {
- setRunning(reportingTask, true);
+ start: function(reportingTaskEntity) {
+ setRunning(reportingTaskEntity, true);
},
/**
* Stops the specified reporting task.
*
- * @param {object} reportingTask
+ * @param {object} reportingTaskEntity
*/
- stop: function(reportingTask) {
- setRunning(reportingTask, false);
+ stop: function(reportingTaskEntity) {
+ setRunning(reportingTaskEntity, false);
},
/**
@@ -696,41 +670,38 @@ nf.ReportingTask = (function () {
reload: function (id) {
var reportingTaskGrid = $('#reporting-tasks-table').data('gridInstance');
var reportingTaskData = reportingTaskGrid.getData();
- var reportingTask = reportingTaskData.getItemById(id);
+ var reportingTaskEntity = reportingTaskData.getItemById(id);
return $.ajax({
type: 'GET',
- url: reportingTask.uri,
+ url: reportingTaskEntity.component.uri,
dataType: 'json'
}).done(function (response) {
- renderReportingTask(response.reportingTask);
+ renderReportingTask(response);
}).fail(nf.Common.handleAjaxError);
},
/**
* Deletes the specified reporting task.
*
- * @param {object} reportingTask
+ * @param {object} reportingTaskEntity
*/
- remove: function(reportingTask) {
+ remove: function(reportingTaskEntity) {
// prompt for removal?
- var revision = nf.Client.getRevision();
+ var revision = nf.Client.getRevision(reportingTaskEntity);
$.ajax({
type: 'DELETE',
- url: reportingTask.uri + '?' + $.param({
+ url: reportingTaskEntity.component.uri + '?' + $.param({
version: revision.version,
clientId: revision.clientId
}),
dataType: 'json'
}).done(function (response) {
- // TODO - update the revision
- // nf.Client.setRevision(response.revision);
-
// remove the task
var reportingTaskGrid = $('#reporting-tasks-table').data('gridInstance');
var reportingTaskData = reportingTaskGrid.getData();
- reportingTaskData.deleteItem(reportingTask.id);
+ reportingTaskData.deleteItem(reportingTaskEntity.id);
}).fail(nf.Common.handleAjaxError);
}
};