NIFI-259: - Code clean up. - Adding component state actions to the controller service and reporting task tables.
Project: http://git-wip-us.apache.org/repos/asf/nifi/repo Commit: http://git-wip-us.apache.org/repos/asf/nifi/commit/ae6f6153 Tree: http://git-wip-us.apache.org/repos/asf/nifi/tree/ae6f6153 Diff: http://git-wip-us.apache.org/repos/asf/nifi/diff/ae6f6153 Branch: refs/heads/master Commit: ae6f615365210ed2063871e78ad62da6d59a15ea Parents: 65dfcd0 Author: Matt Gilman <matt.c.gil...@gmail.com> Authored: Thu Jan 14 13:09:39 2016 -0500 Committer: Matt Gilman <matt.c.gil...@gmail.com> Committed: Thu Jan 14 13:09:39 2016 -0500 ---------------------------------------------------------------------- .../nifi/web/api/ControllerServiceResource.java | 4 +- .../apache/nifi/web/api/ProcessorResource.java | 4 +- .../nifi/web/api/ReportingTaskResource.java | 4 +- .../webapp/js/nf/canvas/nf-component-state.js | 10 ++- .../src/main/webapp/js/nf/canvas/nf-settings.js | 81 ++++++++++++-------- 5 files changed, 62 insertions(+), 41 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/nifi/blob/ae6f6153/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/src/main/java/org/apache/nifi/web/api/ControllerServiceResource.java ---------------------------------------------------------------------- diff --git a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/src/main/java/org/apache/nifi/web/api/ControllerServiceResource.java b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/src/main/java/org/apache/nifi/web/api/ControllerServiceResource.java index 07ce412..c28e951 100644 --- a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/src/main/java/org/apache/nifi/web/api/ControllerServiceResource.java +++ b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/src/main/java/org/apache/nifi/web/api/ControllerServiceResource.java @@ -596,7 +596,7 @@ public class ControllerServiceResource extends ApplicationResource { } // get the component state - final ComponentStateDTO descriptor = serviceFacade.getControllerServiceState(id); + final ComponentStateDTO state = serviceFacade.getControllerServiceState(id); // create the revision final RevisionDTO revision = new RevisionDTO(); @@ -605,7 +605,7 @@ public class ControllerServiceResource extends ApplicationResource { // generate the response entity final ComponentStateEntity entity = new ComponentStateEntity(); entity.setRevision(revision); - entity.setComponentState(descriptor); + entity.setComponentState(state); // generate the response return clusterContext(generateOkResponse(entity)).build(); http://git-wip-us.apache.org/repos/asf/nifi/blob/ae6f6153/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/src/main/java/org/apache/nifi/web/api/ProcessorResource.java ---------------------------------------------------------------------- diff --git a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/src/main/java/org/apache/nifi/web/api/ProcessorResource.java b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/src/main/java/org/apache/nifi/web/api/ProcessorResource.java index 778c9bf..9916535 100644 --- a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/src/main/java/org/apache/nifi/web/api/ProcessorResource.java +++ b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/src/main/java/org/apache/nifi/web/api/ProcessorResource.java @@ -606,7 +606,7 @@ public class ProcessorResource extends ApplicationResource { } // get the component state - final ComponentStateDTO descriptor = serviceFacade.getProcessorState(groupId, id); + final ComponentStateDTO state = serviceFacade.getProcessorState(groupId, id); // create the revision final RevisionDTO revision = new RevisionDTO(); @@ -615,7 +615,7 @@ public class ProcessorResource extends ApplicationResource { // generate the response entity final ComponentStateEntity entity = new ComponentStateEntity(); entity.setRevision(revision); - entity.setComponentState(descriptor); + entity.setComponentState(state); // generate the response return clusterContext(generateOkResponse(entity)).build(); http://git-wip-us.apache.org/repos/asf/nifi/blob/ae6f6153/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/src/main/java/org/apache/nifi/web/api/ReportingTaskResource.java ---------------------------------------------------------------------- diff --git a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/src/main/java/org/apache/nifi/web/api/ReportingTaskResource.java b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/src/main/java/org/apache/nifi/web/api/ReportingTaskResource.java index aee76cd..5b1fa2f 100644 --- a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/src/main/java/org/apache/nifi/web/api/ReportingTaskResource.java +++ b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/src/main/java/org/apache/nifi/web/api/ReportingTaskResource.java @@ -589,7 +589,7 @@ public class ReportingTaskResource extends ApplicationResource { } // get the component state - final ComponentStateDTO descriptor = serviceFacade.getReportingTaskState(id); + final ComponentStateDTO state = serviceFacade.getReportingTaskState(id); // create the revision final RevisionDTO revision = new RevisionDTO(); @@ -598,7 +598,7 @@ public class ReportingTaskResource extends ApplicationResource { // generate the response entity final ComponentStateEntity entity = new ComponentStateEntity(); entity.setRevision(revision); - entity.setComponentState(descriptor); + entity.setComponentState(state); // generate the response return clusterContext(generateOkResponse(entity)).build(); http://git-wip-us.apache.org/repos/asf/nifi/blob/ae6f6153/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/js/nf/canvas/nf-component-state.js ---------------------------------------------------------------------- diff --git a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/js/nf/canvas/nf-component-state.js b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/js/nf/canvas/nf-component-state.js index fb4ae51..78a36bf 100644 --- a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/js/nf/canvas/nf-component-state.js +++ b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/js/nf/canvas/nf-component-state.js @@ -120,6 +120,10 @@ nf.ComponentState = (function () { var componentStateGrid = $('#component-state-table').data('gridInstance'); var componentStateData = componentStateGrid.getData(); componentStateData.setItems([]); + + // clear the total number entries + $('#displayed-component-state-entries').text('0'); + $('#total-component-state-entries').text('0'); }; /** @@ -169,7 +173,6 @@ nf.ComponentState = (function () { // clear the fields $('#component-state-name').text(''); $('#component-state-description').text(''); - $('#total-component-state-entries').text(''); // clear any filter strings $('#component-state-filter').addClass(config.styles.filterList).val(config.filterText); @@ -202,9 +205,9 @@ nf.ComponentState = (function () { // initialize the processor configuration dialog $('#component-state-dialog').modal({ headerText: 'Component State', - overlayBackground: true, + overlayBackground: false, buttons: [{ - buttonText: 'Ok', + buttonText: 'Close', handler: { click: function () { $(this).modal('hide'); @@ -327,6 +330,7 @@ nf.ComponentState = (function () { // initialize the number of display items $('#displayed-component-state-entries').text('0'); + $('#total-component-state-entries').text('0'); }, /** http://git-wip-us.apache.org/repos/asf/nifi/blob/ae6f6153/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/js/nf/canvas/nf-settings.js ---------------------------------------------------------------------- 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 f6ff3ea..994d78c 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 @@ -601,11 +601,15 @@ nf.Settings = (function () { // more details formatter var moreControllerServiceDetails = function (row, cell, value, columnDef, dataContext) { var markup = '<img src="images/iconDetails.png" title="View Details" class="pointer view-controller-service" style="margin-top: 5px; float: left;" />'; + + // always include a button to view the usage + markup += '<img src="images/iconUsage.png" title="Usage" class="pointer controller-service-usage" style="margin-left: 6px; margin-top: 3px; float: left;" />'; + var hasErrors = !nf.Common.isEmpty(dataContext.validationErrors); var hasBulletins = !nf.Common.isEmpty(dataContext.bulletins); if (hasErrors) { - markup += '<img src="images/iconAlert.png" class="has-errors" style="margin-top: 4px; margin-left: 1px; float: left;" />'; + markup += '<img src="images/iconAlert.png" class="has-errors" style="margin-top: 4px; margin-left: 3px; float: left;" />'; } if (hasBulletins) { @@ -649,31 +653,33 @@ nf.Settings = (function () { var controllerServiceActionFormatter = function (row, cell, value, columnDef, dataContext) { var markup = ''; - // only DFMs can edit a controller service + // only DFMs can edit a controller service and view state if (nf.Common.isDFM()) { if (dataContext.state === 'ENABLED' || dataContext.state === 'ENABLING') { - markup += '<img src="images/iconDisable.png" title="Disable" class="pointer disable-controller-service" style="margin-top: 2px;" /> '; + markup += '<img src="images/iconDisable.png" title="Disable" class="pointer disable-controller-service" style="margin-top: 2px;" />'; } else if (dataContext.state === 'DISABLED') { - markup += '<img src="images/iconEdit.png" title="Edit" class="pointer edit-controller-service" style="margin-top: 2px;" /> '; + markup += '<img src="images/iconEdit.png" title="Edit" class="pointer edit-controller-service" style="margin-top: 2px;" />'; // if there are no validation errors allow enabling if (nf.Common.isEmpty(dataContext.validationErrors)) { - markup += '<img src="images/iconEnable.png" title="Enable" class="pointer enable-controller-service" style="margin-top: 2px;"/> '; + markup += '<img src="images/iconEnable.png" title="Enable" class="pointer enable-controller-service" style="margin-top: 2px; margin-left: 3px;"/>'; } - markup += '<img src="images/iconDelete.png" title="Remove" class="pointer delete-controller-service" style="margin-top: 2px;" /> '; + markup += '<img src="images/iconDelete.png" title="Remove" class="pointer delete-controller-service" style="margin-top: 2px; margin-left: 3px;" />'; + } + + if (dataContext.persistsState === true) { + markup += '<img src="images/iconViewState.png" title="View State" class="pointer view-state-controller-service" style="margin-top: 2px; margin-left: 3px;" />'; } } - // always include a button to view the usage - markup += '<img src="images/iconUsage.png" title="Usage" class="pointer controller-service-usage" style="margin-top: 2px;"/> '; return markup; }; // define the column model for the controller services table var controllerServicesColumns = [ - {id: 'moreDetails', name: ' ', resizable: false, formatter: moreControllerServiceDetails, sortable: false, width: 65, maxWidth: 65}, + {id: 'moreDetails', name: ' ', resizable: false, formatter: moreControllerServiceDetails, sortable: false, width: 90, maxWidth: 90}, {id: 'name', field: 'name', name: 'Name', sortable: true, resizable: true}, {id: 'type', field: 'type', name: 'Type', formatter: typeFormatter, sortable: true, resizable: true}, {id: 'state', field: 'state', name: 'State', formatter: controllerServiceStateFormatter, sortable: true, resizeable: true} @@ -728,21 +734,23 @@ nf.Settings = (function () { nf.ControllerService.disable(controllerService); } else if (target.hasClass('delete-controller-service')) { nf.ControllerService.remove(controllerService); + } else if (target.hasClass('view-state-controller-service')) { + nf.ComponentState.showState(controllerService, controllerService.state === 'DISABLED'); + } + } else if (controllerServicesGrid.getColumns()[args.cell].id === 'moreDetails') { + if (target.hasClass('view-controller-service')) { + nf.ControllerService.showDetails(controllerService); } else if (target.hasClass('controller-service-usage')) { // close the settings dialog $('#shell-close-button').click(); - + // open the documentation for this reporting task nf.Shell.showPage('../nifi-docs/documentation?' + $.param({ - select: nf.Common.substringAfterLast(controllerService.type, '.') - })).done(function() { + select: nf.Common.substringAfterLast(controllerService.type, '.') + })).done(function() { nf.Settings.showSettings(); }); } - } else if (controllerServicesGrid.getColumns()[args.cell].id === 'moreDetails') { - if (target.hasClass('view-controller-service')) { - nf.ControllerService.showDetails(controllerService); - } } }); @@ -1248,11 +1256,15 @@ nf.Settings = (function () { var moreReportingTaskDetails = function (row, cell, value, columnDef, dataContext) { var markup = '<img src="images/iconDetails.png" title="View Details" class="pointer view-reporting-task" style="margin-top: 5px; float: left;" />'; + + // always include a button to view the usage + markup += '<img src="images/iconUsage.png" title="Usage" class="pointer reporting-task-usage" style="margin-left: 6px; margin-top: 3px;"/>'; + var hasErrors = !nf.Common.isEmpty(dataContext.validationErrors); var hasBulletins = !nf.Common.isEmpty(dataContext.bulletins); if (hasErrors) { - markup += '<img src="images/iconAlert.png" class="has-errors" style="margin-top: 4px; margin-left: 1px; float: left;" />'; + markup += '<img src="images/iconAlert.png" class="has-errors" style="margin-top: 4px; margin-left: 3px; float: left;" />'; } if (hasBulletins) { @@ -1295,31 +1307,33 @@ nf.Settings = (function () { var reportingTaskActionFormatter = function (row, cell, value, columnDef, dataContext) { var markup = ''; - // only DFMs can edit reporting tasks + // only DFMs can edit reporting tasks and view state if (nf.Common.isDFM()) { if (dataContext.state === 'RUNNING') { - markup += '<img src="images/iconStop.png" title="Stop" class="pointer stop-reporting-task" style="margin-top: 2px;" /> '; + markup += '<img src="images/iconStop.png" title="Stop" class="pointer stop-reporting-task" style="margin-top: 2px;" />'; } else if (dataContext.state === 'STOPPED' || dataContext.state === 'DISABLED') { - markup += '<img src="images/iconEdit.png" title="Edit" class="pointer edit-reporting-task" style="margin-top: 2px;" /> '; + markup += '<img src="images/iconEdit.png" title="Edit" class="pointer edit-reporting-task" style="margin-top: 2px;" />'; // support starting when stopped and no validation errors if (dataContext.state === 'STOPPED' && nf.Common.isEmpty(dataContext.validationErrors)) { - markup += '<img src="images/iconRun.png" title="Start" class="pointer start-reporting-task" style="margin-top: 2px;"/> '; + markup += '<img src="images/iconRun.png" title="Start" class="pointer start-reporting-task" style="margin-top: 2px; margin-left: 3px;"/>'; } - markup += '<img src="images/iconDelete.png" title="Remove" class="pointer delete-reporting-task" style="margin-top: 2px;" /> '; + markup += '<img src="images/iconDelete.png" title="Remove" class="pointer delete-reporting-task" style="margin-top: 2px; margin-left: 3px;" />'; + } + + if (dataContext.persistsState === true) { + markup += '<img src="images/iconViewState.png" title="View State" class="pointer view-state-reporting-task" style="margin-top: 2px; margin-left: 3px;" />'; } } - // always include a button to view the usage - markup += '<img src="images/iconUsage.png" title="Usage" class="pointer reporting-task-usage" style="margin-top: 2px;"/> '; return markup; }; // define the column model for the reporting tasks table var reportingTasksColumnModel = [ - {id: 'moreDetails', field: 'moreDetails', name: ' ', resizable: false, formatter: moreReportingTaskDetails, sortable: true, width: 65, maxWidth: 65}, + {id: 'moreDetails', field: 'moreDetails', name: ' ', resizable: false, formatter: moreReportingTaskDetails, sortable: true, width: 90, maxWidth: 90}, {id: 'name', field: 'name', name: 'Name', sortable: true, resizable: true}, {id: 'type', field: 'type', name: 'Type', sortable: true, resizable: true, formatter: typeFormatter}, {id: 'state', field: 'state', name: 'Run Status', sortable: true, resizeable: true, formatter: reportingTaskRunStatusFormatter} @@ -1374,21 +1388,24 @@ nf.Settings = (function () { nf.ReportingTask.stop(reportingTask); } else if (target.hasClass('delete-reporting-task')) { nf.ReportingTask.remove(reportingTask); + } else if (target.hasClass('view-state-reporting-task')) { + var canClear = reportingTask.state === 'STOPPED' && reportingTask.activeThreadCount === 0; + nf.ComponentState.showState(reportingTask, canClear); + } + } else if (reportingTasksGrid.getColumns()[args.cell].id === 'moreDetails') { + if (target.hasClass('view-reporting-task')) { + nf.ReportingTask.showDetails(reportingTask); } else if (target.hasClass('reporting-task-usage')) { // close the settings dialog $('#shell-close-button').click(); - + // open the documentation for this reporting task nf.Shell.showPage('../nifi-docs/documentation?' + $.param({ - select: nf.Common.substringAfterLast(reportingTask.type, '.') - })).done(function() { + select: nf.Common.substringAfterLast(reportingTask.type, '.') + })).done(function() { nf.Settings.showSettings(); }); } - } else if (reportingTasksGrid.getColumns()[args.cell].id === 'moreDetails') { - if (target.hasClass('view-reporting-task')) { - nf.ReportingTask.showDetails(reportingTask); - } } });