NIFI-694: - Showing bulletins for services and referencing components when enabling and disabling.
Project: http://git-wip-us.apache.org/repos/asf/incubator-nifi/repo Commit: http://git-wip-us.apache.org/repos/asf/incubator-nifi/commit/7a289034 Tree: http://git-wip-us.apache.org/repos/asf/incubator-nifi/tree/7a289034 Diff: http://git-wip-us.apache.org/repos/asf/incubator-nifi/diff/7a289034 Branch: refs/heads/develop Commit: 7a28903402192819accaded9a90adfdfad852776 Parents: 0a7ab1a Author: Matt Gilman <matt.c.gil...@gmail.com> Authored: Thu Jun 25 14:38:47 2015 -0400 Committer: Matt Gilman <matt.c.gil...@gmail.com> Committed: Thu Jun 25 14:38:47 2015 -0400 ---------------------------------------------------------------------- .../disable-controller-service-dialog.jsp | 4 +- .../canvas/enable-controller-service-dialog.jsp | 4 +- .../src/main/webapp/css/controller-service.css | 35 +++ .../js/nf/canvas/nf-controller-service.js | 222 ++++++++++++++++--- 4 files changed, 230 insertions(+), 35 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/incubator-nifi/blob/7a289034/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/WEB-INF/partials/canvas/disable-controller-service-dialog.jsp ---------------------------------------------------------------------- diff --git a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/WEB-INF/partials/canvas/disable-controller-service-dialog.jsp b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/WEB-INF/partials/canvas/disable-controller-service-dialog.jsp index dc76282..1ecb730 100644 --- a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/WEB-INF/partials/canvas/disable-controller-service-dialog.jsp +++ b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/WEB-INF/partials/canvas/disable-controller-service-dialog.jsp @@ -22,7 +22,9 @@ <div class="setting-name">Service</div> <div class="setting-field"> <span id="disable-controller-service-id" class="hidden"></span> - <span id="disable-controller-service-name"></span> + <div id="disable-controller-service-name"></div> + <div id="disable-controller-service-bulletins"></div> + <div class="clear"></div> </div> </div> <div id="disable-controller-service-scope-container" class="setting"> http://git-wip-us.apache.org/repos/asf/incubator-nifi/blob/7a289034/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/WEB-INF/partials/canvas/enable-controller-service-dialog.jsp ---------------------------------------------------------------------- diff --git a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/WEB-INF/partials/canvas/enable-controller-service-dialog.jsp b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/WEB-INF/partials/canvas/enable-controller-service-dialog.jsp index 14fe658..6613a04 100644 --- a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/WEB-INF/partials/canvas/enable-controller-service-dialog.jsp +++ b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/WEB-INF/partials/canvas/enable-controller-service-dialog.jsp @@ -22,7 +22,9 @@ <div class="setting-name">Service</div> <div class="setting-field"> <span id="enable-controller-service-id" class="hidden"></span> - <span id="enable-controller-service-name"></span> + <div id="enable-controller-service-name"></div> + <div id="enable-controller-service-bulletins"></div> + <div class="clear"></div> </div> </div> <div id="enable-controller-service-scope-container" class="setting"> http://git-wip-us.apache.org/repos/asf/incubator-nifi/blob/7a289034/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/css/controller-service.css ---------------------------------------------------------------------- diff --git a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/css/controller-service.css b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/css/controller-service.css index 3d722cd..4a82810 100644 --- a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/css/controller-service.css +++ b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/css/controller-service.css @@ -124,6 +124,15 @@ div.referencing-component-state { margin-top: -2px; } +div.referencing-component-bulletins { + float: left; + margin-left: 5px; + width: 12px; + height: 12px; + background-color: transparent; + display: none; +} + span.service.expansion-button { margin-right: 4px; margin-top: 2px; @@ -186,6 +195,19 @@ div.referencing-component-references { margin-right: 40px; } +#disable-controller-service-name { + float: left; +} + +#disable-controller-service-bulletins { + float: left; + margin-left: 5px; + width: 12px; + height: 12px; + background-color: transparent; + display: none; +} + #disable-controller-service-referencing-components { border: 0 solid #CCCCCC; padding: 2px; @@ -222,6 +244,19 @@ div.referencing-component-references { margin-right: 40px; } +#enable-controller-service-name { + float: left; +} + +#enable-controller-service-bulletins { + float: left; + margin-left: 5px; + width: 12px; + height: 12px; + background-color: transparent; + display: none; +} + #enable-controller-service-scope { float: left; width: 225px; http://git-wip-us.apache.org/repos/asf/incubator-nifi/blob/7a289034/nifi/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/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/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/js/nf/canvas/nf-controller-service.js index e8a111d..baa9edc 100644 --- a/nifi/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/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/js/nf/canvas/nf-controller-service.js @@ -241,6 +241,40 @@ nf.ControllerService = (function () { }; /** + * Updates the specified bulletinIcon with the specified bulletins if necessary. + * + * @param {array} bulletins + * @param {jQuery} bulletinIcon + */ + var updateBulletins = function (bulletins, bulletinIcon) { + var currentBulletins = bulletinIcon.data('bulletins'); + + // update the bulletins if necessary + if (nf.Common.doBulletinsDiffer(currentBulletins, bulletins)) { + bulletinIcon.data('bulletins', bulletins); + + // format the new bulletins + var formattedBulletins = nf.Common.getFormattedBulletins(bulletins); + + // if there are bulletins update them + if (bulletins.length > 0) { + var list = nf.Common.formatUnorderedList(formattedBulletins); + + // update existing tooltip or initialize a new one if appropriate + if (bulletinIcon.data('qtip')) { + bulletinIcon.qtip('option', 'content.text', list); + } else { + bulletinIcon.addClass('has-bulletins').show().qtip($.extend({ + content: list + }, nf.CanvasUtils.config.systemTooltipConfig)); + } + } else if (bulletinIcon.data('qtip')) { + bulletinIcon.removeClass('has-bulletins').removeData('bulletins').hide().qtip('api').destroy(true); + } + } + }; + + /** * Updates the referencingComponentState using the specified referencingComponent. * * @param {jQuery} referencingComponentState @@ -301,6 +335,23 @@ nf.ControllerService = (function () { }; /** + * Updates the bulletins for all referencing components. + * + * @param {array} bulletins + */ + var updateReferencingComponentBulletins = function(bulletins) { + var bulletinsBySource = d3.nest() + .key(function(d) { return d.sourceId; }) + .map(bulletins, d3.map); + + bulletinsBySource.forEach(function(sourceId, sourceBulletins) { + $('div.' + sourceId + '-bulletins').each(function() { + updateBulletins(sourceBulletins, $(this)); + }); + }); + }; + + /** * Adds the specified reference for this controller service. * * @param {jQuery} referenceContainer @@ -323,10 +374,13 @@ nf.ControllerService = (function () { } }; + var referencingComponentIds = []; 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>'); $.each(referencingComponents, function (_, referencingComponent) { + 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 @@ -340,6 +394,9 @@ nf.ControllerService = (function () { // 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, '.')); @@ -351,7 +408,7 @@ nf.ControllerService = (function () { } // processor - var processorItem = $('<li></li>').append(processorState).append(processorLink).append(processorType).append(processorActiveThreadCount); + 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 () { @@ -392,11 +449,14 @@ nf.ControllerService = (function () { 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(serviceLink).append(serviceType).append(referencingServiceReferencesContainer); + var serviceItem = $('<li></li>').append(serviceTwist).append(serviceState).append(serviceBulletins).append(serviceLink).append(serviceType).append(referencingServiceReferencesContainer); services.append(serviceItem); } else if (referencingComponent.referenceType === 'ReportingTask') { @@ -420,6 +480,9 @@ nf.ControllerService = (function () { 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, '.')); @@ -430,11 +493,17 @@ nf.ControllerService = (function () { } // reporting task - var reportingTaskItem = $('<li></li>').append(reportingTaskState).append(reportingTaskLink).append(reportingTaskType).append(reportingTaskActiveThreadCount); + var reportingTaskItem = $('<li></li>').append(reportingTaskState).append(reportingTaskBulletins).append(reportingTaskLink).append(reportingTaskType).append(reportingTaskActiveThreadCount); tasks.append(reportingTaskItem); } }); + // query for the bulletins + queryBulletins(referencingComponentIds).done(function(response) { + var bulletins = response.bulletinBoard.bulletins; + updateReferencingComponentBulletins(bulletins); + }); + // create the collapsable listing for each type var createReferenceBlock = function (titleText, list) { if (list.is(':empty')) { @@ -466,6 +535,25 @@ nf.ControllerService = (function () { }; /** + * Queries for bulletins for the specified components. + * + * @param {array} componentIds + * @returns {deferred} + */ + var queryBulletins = function(componentIds) { + var ids = componentIds.join('|'); + + return $.ajax({ + type: 'GET', + url: '../nifi-api/controller/bulletin-board', + data: { + sourceId: ids + }, + dataType: 'json' + }).fail(nf.Common.handleAjaxError); + }; + + /** * Sets whether the specified controller service is enabled. * * @param {object} controllerService @@ -491,13 +579,23 @@ nf.ControllerService = (function () { // wait unil the polling of each service finished return $.Deferred(function(deferred) { updated.done(function() { - var serviceUpdated = pollService(controllerService, function (service) { + var serviceUpdated = pollService(controllerService, function (service, bulletins) { + if ($.isArray(bulletins)) { + if (enabled) { + updateBulletins(bulletins, $('#enable-controller-service-bulletins')); + } else { + updateBulletins(bulletins, $('#disable-controller-service-bulletins')); + } + } + // the condition is met once the service is ENABLED/DISABLED if (enabled) { return service.state === 'ENABLED'; } else { return service.state === 'DISABLED'; } + }, function(service) { + return queryBulletins([service.id]); }, pollCondition); // once the service has updated, resolve and render the updated service @@ -608,9 +706,10 @@ nf.ControllerService = (function () { * * @param {object} controllerService * @param {function} completeCondition + * @param {function} bulletinDeferred * @param {function} pollCondition */ - var pollService = function (controllerService, completeCondition, pollCondition) { + var pollService = function (controllerService, completeCondition, bulletinDeferred, pollCondition) { // we want to keep polling until the condition is met return $.Deferred(function(deferred) { var current = 2; @@ -618,19 +717,24 @@ nf.ControllerService = (function () { var val = current; // update the current timeout for the next time - current = Math.max(current * 2, 8); + current = Math.min(current * 2, 4); return val * 1000; }; // polls for the current status of the referencing components var poll = function() { - $.ajax({ + var bulletins = bulletinDeferred(controllerService); + var service = $.ajax({ type: 'GET', url: controllerService.uri, dataType: 'json' - }).done(function (response) { - conditionMet(response.controllerService); + }); + + $.when(bulletins, service).done(function (bulletinResult, serviceResult) { + var bulletinResponse = bulletinResult[0]; + var serviceResponse = serviceResult[0]; + conditionMet(serviceResponse.controllerService, bulletinResponse.bulletinBoard.bulletins); }).fail(function (xhr, status, error) { deferred.reject(); nf.Common.handleAjaxError(xhr, status, error); @@ -638,8 +742,8 @@ nf.ControllerService = (function () { }; // tests to if the condition has been met - var conditionMet = function (service) { - if (completeCondition(service)) { + var conditionMet = function (service, bulletins) { + if (completeCondition(service, bulletins)) { deferred.resolve(); } else { if (typeof pollCondition === 'function' && pollCondition()) { @@ -651,7 +755,12 @@ nf.ControllerService = (function () { }; // poll for the status of the referencing components - conditionMet(controllerService); + bulletinDeferred(controllerService).done(function(response) { + conditionMet(controllerService, response.bulletinBoard.bulletins); + }).fail(function (xhr, status, error) { + deferred.reject(); + nf.Common.handleAjaxError(xhr, status, error); + }); }).promise(); }; @@ -664,7 +773,7 @@ nf.ControllerService = (function () { */ var stopReferencingSchedulableComponents = function (controllerService, pollCondition) { // continue to poll the service until all schedulable components have stopped - return pollService(controllerService, function (service) { + return pollService(controllerService, function (service, bulletins) { var referencingComponents = service.referencingComponents; var stillRunning = false; @@ -682,9 +791,23 @@ nf.ControllerService = (function () { updateReferencingSchedulableComponentState(referencingComponentState, referencingComponent); } }); + + // query for the bulletins + updateReferencingComponentBulletins(bulletins); // condition is met once all referencing are not running return stillRunning === false; + }, function(service) { + var referencingSchedulableComponents = []; + + var referencingComponents = service.referencingComponents; + $.each(referencingComponents, function(_, referencingComponent) { + if (referencingComponent.referenceType === 'Processor' || referencingComponent.referenceType === 'ReportingTask') { + referencingSchedulableComponents.push(referencingComponent.id); + } + }); + + return queryBulletins(referencingSchedulableComponents); }, pollCondition); }; @@ -696,7 +819,7 @@ nf.ControllerService = (function () { */ var enableReferencingServices = function (controllerService, pollCondition) { // continue to poll the service until all referencing services are enabled - return pollService(controllerService, function (service) { + return pollService(controllerService, function (service, bulletins) { var referencingComponents = service.referencingComponents; var notEnabled = false; @@ -711,9 +834,23 @@ nf.ControllerService = (function () { updateReferencingServiceState(referencingServiceState, referencingComponent); } }); + + // query for the bulletins + updateReferencingComponentBulletins(bulletins); // condition is met once all referencing are not disabled return notEnabled === false; + }, function(service) { + var referencingSchedulableComponents = []; + + var referencingComponents = service.referencingComponents; + $.each(referencingComponents, function(_, referencingComponent) { + if (referencingComponent.referenceType === 'ControllerService') { + referencingSchedulableComponents.push(referencingComponent.id); + } + }); + + return queryBulletins(referencingSchedulableComponents); }, pollCondition); }; @@ -725,7 +862,7 @@ nf.ControllerService = (function () { */ var disableReferencingServices = function (controllerService, pollCondition) { // continue to poll the service until all referencing services are disabled - return pollService(controllerService, function (service) { + return pollService(controllerService, function (service, bulletins) { var referencingComponents = service.referencingComponents; var notDisabled = false; @@ -740,9 +877,23 @@ nf.ControllerService = (function () { updateReferencingServiceState(referencingServiceState, referencingComponent); } }); + + // query for the bulletins + updateReferencingComponentBulletins(bulletins); // condition is met once all referencing are not enabled return notDisabled === false; + }, function(service) { + var referencingSchedulableComponents = []; + + var referencingComponents = service.referencingComponents; + $.each(referencingComponents, function(_, referencingComponent) { + if (referencingComponent.referenceType === 'ControllerService') { + referencingSchedulableComponents.push(referencingComponent.id); + } + }); + + return queryBulletins(referencingSchedulableComponents); }, pollCondition); }; @@ -823,6 +974,11 @@ nf.ControllerService = (function () { // show the dialog $('#disable-controller-service-dialog').modal('show'); + // load the bulletins + queryBulletins([controllerService.id]).done(function(response) { + updateBulletins(response.bulletinBoard.bulletins, $('#disable-controller-service-bulletins')); + }); + // update the border if necessary updateReferencingComponentsBorder(referencingComponentsContainer); }; @@ -844,6 +1000,11 @@ nf.ControllerService = (function () { // show the dialog $('#enable-controller-service-dialog').modal('show'); + // load the bulletins + queryBulletins([controllerService.id]).done(function(response) { + updateBulletins(response.bulletinBoard.bulletins, $('#enable-controller-service-bulletins')); + }); + // update the border if necessary updateReferencingComponentsBorder(referencingComponentsContainer); }; @@ -873,7 +1034,6 @@ nf.ControllerService = (function () { }]); // show the progress - $('#disable-controller-service-service-container').hide(); $('#disable-controller-service-scope-container').hide(); $('#disable-controller-service-progress-container').show(); @@ -964,7 +1124,6 @@ nf.ControllerService = (function () { } // show the progress - $('#enable-controller-service-service-container').hide(); $('#enable-controller-service-scope-container').hide(); $('#enable-controller-service-progress-container').show(); @@ -1223,6 +1382,7 @@ nf.ControllerService = (function () { // empty the referencing components list var referencingComponents = $('#controller-service-referencing-components'); nf.Common.cleanUpTooltips(referencingComponents, 'div.referencing-component-state'); + nf.Common.cleanUpTooltips(referencingComponents, 'div.referencing-component-bulletins'); referencingComponents.css('border-width', '0').empty(); // cancel any active edits @@ -1271,7 +1431,6 @@ nf.ControllerService = (function () { var disableDialog = $(this); // reset visibility - $('#disable-controller-service-service-container').show(); $('#disable-controller-service-scope-container').show(); $('#disable-controller-service-progress-container').hide(); @@ -1279,12 +1438,17 @@ nf.ControllerService = (function () { $('#disable-controller-service-id').text(''); $('#disable-controller-service-name').text(''); + // bulletins + $('#disable-controller-service-bulletins').removeClass('has-bulletins').removeData('bulletins').hide(); + nf.Common.cleanUpTooltips($('#disable-controller-service-service-container'), '#disable-controller-service-bulletins'); + // reset progress $('div.disable-referencing-components').removeClass('ajax-loading ajax-complete ajax-error'); // referencing components var referencingComponents = $('#disable-controller-service-referencing-components'); nf.Common.cleanUpTooltips(referencingComponents, 'div.referencing-component-state'); + nf.Common.cleanUpTooltips(referencingComponents, 'div.referencing-component-bulletins'); referencingComponents.css('border-width', '0').empty(); // reset dialog @@ -1339,7 +1503,6 @@ nf.ControllerService = (function () { var enableDialog = $(this); // reset visibility - $('#enable-controller-service-service-container').show(); $('#enable-controller-service-scope-container').show(); $('#enable-controller-service-progress-container').hide(); $('#enable-controller-service-progress li.referencing-component').show(); @@ -1348,12 +1511,17 @@ nf.ControllerService = (function () { $('#enable-controller-service-id').text(''); $('#enable-controller-service-name').text(''); + // bulletins + $('#enable-controller-service-bulletins').removeClass('has-bulletins').removeData('bulletins').hide(); + nf.Common.cleanUpTooltips($('#enable-controller-service-service-container'), '#enable-controller-service-bulletins'); + // reset progress $('div.enable-referencing-components').removeClass('ajax-loading ajax-complete ajax-error'); // referencing components var referencingComponents = $('#enable-controller-service-referencing-components'); nf.Common.cleanUpTooltips(referencingComponents, 'div.referencing-component-state'); + nf.Common.cleanUpTooltips(referencingComponents, 'div.referencing-component-bulletins'); referencingComponents.css('border-width', '0').empty(); // reset dialog @@ -1654,13 +1822,7 @@ nf.ControllerService = (function () { * @param {object} controllerService */ enable: function(controllerService) { - if (nf.Common.isEmpty(controllerService.referencingComponents)) { - setEnabled(controllerService, true).always(function () { - reloadControllerServiceAndReferencingComponents(controllerService); - }); - } else { - showEnableControllerServiceDialog(controllerService); - } + showEnableControllerServiceDialog(controllerService); }, /** @@ -1669,13 +1831,7 @@ nf.ControllerService = (function () { * @param {object} controllerService */ disable: function(controllerService) { - if (nf.Common.isEmpty(controllerService.referencingComponents)) { - setEnabled(controllerService, false).always(function () { - reloadControllerServiceAndReferencingComponents(controllerService); - }); - } else { - showDisableControllerServiceDialog(controllerService); - } + showDisableControllerServiceDialog(controllerService); }, /**