http://git-wip-us.apache.org/repos/asf/nifi/blob/bf3b1640/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/js/nf/canvas/controllers/nf-ng-canvas-flow-status-controller.js ---------------------------------------------------------------------- diff --git a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/js/nf/canvas/controllers/nf-ng-canvas-flow-status-controller.js b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/js/nf/canvas/controllers/nf-ng-canvas-flow-status-controller.js index 95b6ac0..8e2b520 100644 --- a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/js/nf/canvas/controllers/nf-ng-canvas-flow-status-controller.js +++ b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/js/nf/canvas/controllers/nf-ng-canvas-flow-status-controller.js @@ -15,469 +15,506 @@ * limitations under the License. */ -/* global nf, d3 */ - -nf.ng.Canvas.FlowStatusCtrl = function (serviceProvider) { +/* global define, module, require, exports */ + +(function (root, factory) { + if (typeof define === 'function' && define.amd) { + define(['jquery', + 'nf.Common', + 'nf.Dialog', + 'nf.CanvasUtils', + 'nf.ContextMenu', + 'nf.ClusterSummary', + 'nf.ErrorHandler', + 'nf.Settings'], + function ($, common, dialog, canvasUtils, contextMenu, clusterSummary, errorHandler, settings) { + return (nf.ng.Canvas.FlowStatusCtrl = factory($, common, dialog, canvasUtils, contextMenu, clusterSummary, errorHandler, settings)); + }); + } else if (typeof exports === 'object' && typeof module === 'object') { + module.exports = (nf.ng.Canvas.FlowStatusCtrl = + factory(require('jquery'), + require('nf.Common'), + require('nf.Dialog'), + require('nf.CanvasUtils'), + require('nf.ContextMenu'), + require('nf.ClusterSummary'), + require('nf.ErrorHandler'), + require('nf.Settings'))); + } else { + nf.ng.Canvas.FlowStatusCtrl = factory(root.$, + root.nf.Common, + root.nf.Dialog, + root.nf.CanvasUtils, + root.nf.ContextMenu, + root.nf.ClusterSummary, + root.nf.ErrorHandler, + root.nf.Settings); + } +}(this, function ($, common, dialog, canvasUtils, contextMenu, clusterSummary, errorHandler, settings) { 'use strict'; - var config = { - search: 'Search', - urls: { - search: '../nifi-api/flow/search-results', - status: '../nifi-api/flow/status' - } - }; - - function FlowStatusCtrl() { - this.connectedNodesCount = "-"; - this.activeThreadCount = "-"; - this.totalQueued = "-"; - this.controllerTransmittingCount = "-"; - this.controllerNotTransmittingCount = "-"; - this.controllerRunningCount = "-"; - this.controllerStoppedCount = "-"; - this.controllerInvalidCount = "-"; - this.controllerDisabledCount = "-"; - this.statsLastRefreshed = "-"; - - /** - * The search controller. - */ - this.search = { + return function (serviceProvider) { + 'use strict'; - /** - * Get the search input element. - */ - getInputElement: function () { - return $('#search-field'); - }, - - /** - * Get the search button element. - */ - getButtonElement: function () { - return $('#search-button'); - }, - - /** - * Get the search container element. - */ - getSearchContainerElement: function () { - return $('#search-container'); - }, + var config = { + search: 'Search', + urls: { + search: '../nifi-api/flow/search-results', + status: '../nifi-api/flow/status' + } + }; + + function FlowStatusCtrl() { + this.connectedNodesCount = "-"; + this.activeThreadCount = "-"; + this.totalQueued = "-"; + this.controllerTransmittingCount = "-"; + this.controllerNotTransmittingCount = "-"; + this.controllerRunningCount = "-"; + this.controllerStoppedCount = "-"; + this.controllerInvalidCount = "-"; + this.controllerDisabledCount = "-"; + this.statsLastRefreshed = "-"; /** - * Initialize the search controller. + * The search controller. */ - init: function () { - - var searchCtrl = this; - - // Create new jQuery UI widget - $.widget('nf.searchAutocomplete', $.ui.autocomplete, { - reset: function () { - this.term = null; - }, - _create: function() { - this._super(); - this.widget().menu('option', 'items', '> :not(.search-header, .search-no-matches)' ); - }, - _resizeMenu: function () { - var ul = this.menu.element; - ul.width(400); - }, - _normalize: function (searchResults) { - var items = []; - items.push(searchResults); - return items; - }, - _renderMenu: function (ul, items) { - var nfSearchAutocomplete = this; - - // the object that holds the search results is normalized into a single element array - var searchResults = items[0]; - - // show all processors - if (!nf.Common.isEmpty(searchResults.processorResults)) { - ul.append('<li class="search-header"><div class="search-result-icon icon icon-processor"></div>Processors</li>'); - $.each(searchResults.processorResults, function (i, processorMatch) { - nfSearchAutocomplete._renderItem(ul, processorMatch); + this.search = { + + /** + * Get the search input element. + */ + getInputElement: function () { + return $('#search-field'); + }, + + /** + * Get the search button element. + */ + getButtonElement: function () { + return $('#search-button'); + }, + + /** + * Get the search container element. + */ + getSearchContainerElement: function () { + return $('#search-container'); + }, + + /** + * Initialize the search controller. + */ + init: function () { + + var searchCtrl = this; + + // Create new jQuery UI widget + $.widget('nf.searchAutocomplete', $.ui.autocomplete, { + reset: function () { + this.term = null; + }, + _create: function () { + this._super(); + this.widget().menu('option', 'items', '> :not(.search-header, .search-no-matches)'); + }, + _resizeMenu: function () { + var ul = this.menu.element; + ul.width(400); + }, + _normalize: function (searchResults) { + var items = []; + items.push(searchResults); + return items; + }, + _renderMenu: function (ul, items) { + var nfSearchAutocomplete = this; + + // the object that holds the search results is normalized into a single element array + var searchResults = items[0]; + + // show all processors + if (!common.isEmpty(searchResults.processorResults)) { + ul.append('<li class="search-header"><div class="search-result-icon icon icon-processor"></div>Processors</li>'); + $.each(searchResults.processorResults, function (i, processorMatch) { + nfSearchAutocomplete._renderItem(ul, processorMatch); + }); + } + + // show all process groups + if (!common.isEmpty(searchResults.processGroupResults)) { + ul.append('<li class="search-header"><div class="search-result-icon icon icon-group"></div>Process Groups</li>'); + $.each(searchResults.processGroupResults, function (i, processGroupMatch) { + nfSearchAutocomplete._renderItem(ul, processGroupMatch); + }); + } + + // show all remote process groups + if (!common.isEmpty(searchResults.remoteProcessGroupResults)) { + ul.append('<li class="search-header"><div class="search-result-icon icon icon-group-remote"></div>Remote Process Groups</li>'); + $.each(searchResults.remoteProcessGroupResults, function (i, remoteProcessGroupMatch) { + nfSearchAutocomplete._renderItem(ul, remoteProcessGroupMatch); + }); + } + + // show all connections + if (!common.isEmpty(searchResults.connectionResults)) { + ul.append('<li class="search-header"><div class="search-result-icon icon icon-connect"></div>Connections</li>'); + $.each(searchResults.connectionResults, function (i, connectionMatch) { + nfSearchAutocomplete._renderItem(ul, connectionMatch); + }); + } + + // show all input ports + if (!common.isEmpty(searchResults.inputPortResults)) { + ul.append('<li class="search-header"><div class="search-result-icon icon icon-port-in"></div>Input Ports</li>'); + $.each(searchResults.inputPortResults, function (i, inputPortMatch) { + nfSearchAutocomplete._renderItem(ul, inputPortMatch); + }); + } + + // show all output ports + if (!common.isEmpty(searchResults.outputPortResults)) { + ul.append('<li class="search-header"><div class="search-result-icon icon icon-port-out"></div>Output Ports</li>'); + $.each(searchResults.outputPortResults, function (i, outputPortMatch) { + nfSearchAutocomplete._renderItem(ul, outputPortMatch); + }); + } + + // show all funnels + if (!common.isEmpty(searchResults.funnelResults)) { + ul.append('<li class="search-header"><div class="search-result-icon icon icon-funnel"></div>Funnels</li>'); + $.each(searchResults.funnelResults, function (i, funnelMatch) { + nfSearchAutocomplete._renderItem(ul, funnelMatch); + }); + } + + // ensure there were some results + if (ul.children().length === 0) { + ul.append('<li class="unset search-no-matches">No results matched the search terms</li>'); + } + }, + _renderItem: function (ul, match) { + var itemContent = $('<a></a>').append($('<div class="search-match-header"></div>').text(match.name)); + $.each(match.matches, function (i, match) { + itemContent.append($('<div class="search-match"></div>').text(match)); }); + return $('<li></li>').data('ui-autocomplete-item', match).append(itemContent).appendTo(ul); } - - // show all process groups - if (!nf.Common.isEmpty(searchResults.processGroupResults)) { - ul.append('<li class="search-header"><div class="search-result-icon icon icon-group"></div>Process Groups</li>'); - $.each(searchResults.processGroupResults, function (i, processGroupMatch) { - nfSearchAutocomplete._renderItem(ul, processGroupMatch); + }); + + // configure the new searchAutocomplete jQuery UI widget + this.getInputElement().searchAutocomplete({ + appendTo: '#search-flow-results', + position: { + my: 'right top', + at: 'right bottom', + offset: '1 1' + }, + source: function (request, response) { + // create the search request + $.ajax({ + type: 'GET', + data: { + q: request.term + }, + dataType: 'json', + url: config.urls.search + }).done(function (searchResponse) { + response(searchResponse.searchResultsDTO); }); + }, + select: function (event, ui) { + var item = ui.item; + + // show the selected component + canvasUtils.showComponent(item.groupId, item.id); + + searchCtrl.getInputElement().val('').blur(); + + // stop event propagation + return false; + }, + open: function (event, ui) { + // show the glass pane + var searchField = $(this); + $('<div class="search-glass-pane"></div>').one('click', function () { + }).appendTo('body'); + }, + close: function (event, ui) { + // set the input text to '' and reset the cached term + $(this).searchAutocomplete('reset'); + searchCtrl.getInputElement().val(''); + + // remove the glass pane + $('div.search-glass-pane').remove(); } + }); - // show all remote process groups - if (!nf.Common.isEmpty(searchResults.remoteProcessGroupResults)) { - ul.append('<li class="search-header"><div class="search-result-icon icon icon-group-remote"></div>Remote Process Groups</li>'); - $.each(searchResults.remoteProcessGroupResults, function (i, remoteProcessGroupMatch) { - nfSearchAutocomplete._renderItem(ul, remoteProcessGroupMatch); - }); - } + // hide the search input + searchCtrl.toggleSearchField(); + }, - // show all connections - if (!nf.Common.isEmpty(searchResults.connectionResults)) { - ul.append('<li class="search-header"><div class="search-result-icon icon icon-connect"></div>Connections</li>'); - $.each(searchResults.connectionResults, function (i, connectionMatch) { - nfSearchAutocomplete._renderItem(ul, connectionMatch); - }); - } + /** + * Toggle/Slide the search field open/closed. + */ + toggleSearchField: function () { + var searchCtrl = this; - // show all input ports - if (!nf.Common.isEmpty(searchResults.inputPortResults)) { - ul.append('<li class="search-header"><div class="search-result-icon icon icon-port-in"></div>Input Ports</li>'); - $.each(searchResults.inputPortResults, function (i, inputPortMatch) { - nfSearchAutocomplete._renderItem(ul, inputPortMatch); - }); - } + // hide the context menu if necessary + contextMenu.hide(); - // show all output ports - if (!nf.Common.isEmpty(searchResults.outputPortResults)) { - ul.append('<li class="search-header"><div class="search-result-icon icon icon-port-out"></div>Output Ports</li>'); - $.each(searchResults.outputPortResults, function (i, outputPortMatch) { - nfSearchAutocomplete._renderItem(ul, outputPortMatch); - }); - } + var isVisible = searchCtrl.getInputElement().is(':visible'); + var display = 'none'; + var class1 = 'search-container-opened'; + var class2 = 'search-container-closed'; + if (!isVisible) { + searchCtrl.getButtonElement().css('background-color', '#FFFFFF'); + display = 'inline-block'; + class1 = 'search-container-closed'; + class2 = 'search-container-opened'; + } else { + searchCtrl.getInputElement().css('display', display); + } - // show all funnels - if (!nf.Common.isEmpty(searchResults.funnelResults)) { - ul.append('<li class="search-header"><div class="search-result-icon icon icon-funnel"></div>Funnels</li>'); - $.each(searchResults.funnelResults, function (i, funnelMatch) { - nfSearchAutocomplete._renderItem(ul, funnelMatch); - }); + this.getSearchContainerElement().switchClass(class1, class2, 500, function () { + searchCtrl.getInputElement().css('display', display); + if (!isVisible) { + searchCtrl.getButtonElement().css('background-color', '#FFFFFF'); + searchCtrl.getInputElement().focus(); + } else { + searchCtrl.getButtonElement().css('background-color', '#E3E8EB'); } + }); + } + } - // ensure there were some results - if (ul.children().length === 0) { - ul.append('<li class="unset search-no-matches">No results matched the search terms</li>'); + /** + * The bulletins controller. + */ + this.bulletins = { + + /** + * Update the bulletins. + * + * @param response The controller bulletins returned from the `../nifi-api/controller/bulletins` endpoint. + */ + update: function (response) { + + // icon for system bulletins + var bulletinIcon = $('#bulletin-button'); + var currentBulletins = bulletinIcon.data('bulletins'); + + // update the bulletins if necessary + if (common.doBulletinsDiffer(currentBulletins, response.bulletins)) { + bulletinIcon.data('bulletins', response.bulletins); + + // get the formatted the bulletins + var bulletins = common.getFormattedBulletins(response.bulletins); + + // bulletins for this processor are now gone + if (bulletins.length === 0) { + if (bulletinIcon.data('qtip')) { + bulletinIcon.removeClass('has-bulletins').qtip('api').destroy(true); + } + } else { + var newBulletins = common.formatUnorderedList(bulletins); + + // different bulletins, refresh + if (bulletinIcon.data('qtip')) { + bulletinIcon.qtip('option', 'content.text', newBulletins); + } else { + // no bulletins before, show icon and tips + bulletinIcon.addClass('has-bulletins').qtip($.extend({}, + canvasUtils.config.systemTooltipConfig, + { + content: newBulletins, + position: { + at: 'bottom left', + my: 'top right', + adjust: { + x: 4 + } + } + } + )); + } } - }, - _renderItem: function (ul, match) { - var itemContent = $('<a></a>').append($('<div class="search-match-header"></div>').text(match.name)); - $.each(match.matches, function (i, match) { - itemContent.append($('<div class="search-match"></div>').text(match)); - }); - return $('<li></li>').data('ui-autocomplete-item', match).append(itemContent).appendTo(ul); - } - }); - - // configure the new searchAutocomplete jQuery UI widget - this.getInputElement().searchAutocomplete({ - appendTo: '#search-flow-results', - position: { - my: 'right top', - at: 'right bottom', - offset: '1 1' - }, - source: function (request, response) { - // create the search request - $.ajax({ - type: 'GET', - data: { - q: request.term - }, - dataType: 'json', - url: config.urls.search - }).done(function (searchResponse) { - response(searchResponse.searchResultsDTO); - }); - }, - select: function (event, ui) { - var item = ui.item; - - // show the selected component - nf.CanvasUtils.showComponent(item.groupId, item.id); - - searchCtrl.getInputElement().val('').blur(); - - // stop event propagation - return false; - }, - open: function (event, ui) { - // show the glass pane - var searchField = $(this); - $('<div class="search-glass-pane"></div>').one('click', function () { - }).appendTo('body'); - }, - close: function (event, ui) { - // set the input text to '' and reset the cached term - $(this).searchAutocomplete('reset'); - searchCtrl.getInputElement().val(''); - - // remove the glass pane - $('div.search-glass-pane').remove(); } - }); - - // hide the search input - searchCtrl.toggleSearchField(); - }, - /** - * Toggle/Slide the search field open/closed. - */ - toggleSearchField: function () { - var searchCtrl = this; - - // hide the context menu if necessary - nf.ContextMenu.hide(); - - var isVisible = searchCtrl.getInputElement().is(':visible'); - var display = 'none'; - var class1 = 'search-container-opened'; - var class2 = 'search-container-closed'; - if (!isVisible) { - searchCtrl.getButtonElement().css('background-color', '#FFFFFF'); - display = 'inline-block'; - class1 = 'search-container-closed'; - class2 = 'search-container-opened'; - } else { - searchCtrl.getInputElement().css('display', display); + // update controller service and reporting task bulletins + settings.setBulletins(response.controllerServiceBulletins, response.reportingTaskBulletins); } - this.getSearchContainerElement().switchClass(class1, class2, 500, function () { - searchCtrl.getInputElement().css('display', display); - if (!isVisible) { - searchCtrl.getButtonElement().css('background-color', '#FFFFFF'); - searchCtrl.getInputElement().focus(); - } else { - searchCtrl.getButtonElement().css('background-color', '#E3E8EB'); - } - }); } } - /** - * The bulletins controller. - */ - this.bulletins = { + FlowStatusCtrl.prototype = { + constructor: FlowStatusCtrl, /** - * Update the bulletins. - * - * @param response The controller bulletins returned from the `../nifi-api/controller/bulletins` endpoint. + * Initialize the flow status controller. */ - update: function (response) { - - // icon for system bulletins - var bulletinIcon = $('#bulletin-button'); - var currentBulletins = bulletinIcon.data('bulletins'); - - // update the bulletins if necessary - if (nf.Common.doBulletinsDiffer(currentBulletins, response.bulletins)) { - bulletinIcon.data('bulletins', response.bulletins); + init: function () { + this.search.init(); + }, - // get the formatted the bulletins - var bulletins = nf.Common.getFormattedBulletins(response.bulletins); + /** + * Reloads the current status of the flow. + */ + reloadFlowStatus: function () { + var flowStatusCtrl = this; + + return $.ajax({ + type: 'GET', + url: config.urls.status, + dataType: 'json' + }).done(function (response) { + // report the updated status + if (common.isDefinedAndNotNull(response.controllerStatus)) { + flowStatusCtrl.update(response.controllerStatus); + } + }).fail(errorHandler.handleAjaxError); + }, - // bulletins for this processor are now gone - if (bulletins.length === 0) { - if (bulletinIcon.data('qtip')) { - bulletinIcon.removeClass('has-bulletins').qtip('api').destroy(true); - } + /** + * Updates the cluster summary. + * + * @param summary + */ + updateClusterSummary: function (summary) { + // see if this node has been (dis)connected + if (clusterSummary.isConnectedToCluster() !== summary.connectedToCluster) { + if (summary.connectedToCluster) { + dialog.showConnectedToClusterMessage(); } else { - var newBulletins = nf.Common.formatUnorderedList(bulletins); + dialog.showDisconnectedFromClusterMessage(); + } + } - // different bulletins, refresh - if (bulletinIcon.data('qtip')) { - bulletinIcon.qtip('option', 'content.text', newBulletins); - } else { - // no bulletins before, show icon and tips - bulletinIcon.addClass('has-bulletins').qtip($.extend({}, - nf.CanvasUtils.config.systemTooltipConfig, - { - content: newBulletins, - position: { - at: 'bottom left', - my: 'top right', - adjust: { - x: 4 - } - } - } - )); + var color = '#728E9B'; + + // update the connection state + if (summary.connectedToCluster) { + if (common.isDefinedAndNotNull(summary.connectedNodes)) { + var connectedNodes = summary.connectedNodes.split(' / '); + if (connectedNodes.length === 2 && connectedNodes[0] !== connectedNodes[1]) { + this.clusterConnectionWarning = true; + color = '#BA554A'; } } + this.connectedNodesCount = + common.isDefinedAndNotNull(summary.connectedNodes) ? summary.connectedNodes : '-'; + } else { + this.connectedNodesCount = 'Disconnected'; + color = '#BA554A'; } - // update controller service and reporting task bulletins - nf.Settings.setBulletins(response.controllerServiceBulletins, response.reportingTaskBulletins); - } + // update the color + $('#connected-nodes-count').closest('div.fa-cubes').css('color', color); + }, - } - } + /** + * Update the flow status counts. + * + * @param status The controller status returned from the `../nifi-api/flow/status` endpoint. + */ + update: function (status) { + var controllerInvalidCount = (common.isDefinedAndNotNull(status.invalidCount)) ? status.invalidCount : 0; - FlowStatusCtrl.prototype = { - constructor: FlowStatusCtrl, - - /** - * Initialize the flow status controller. - */ - init: function () { - this.search.init(); - }, - - /** - * Reloads the current status of the flow. - */ - reloadFlowStatus: function () { - var flowStatusCtrl = this; - - return $.ajax({ - type: 'GET', - url: config.urls.status, - dataType: 'json' - }).done(function (response) { - // report the updated status - if (nf.Common.isDefinedAndNotNull(response.controllerStatus)) { - flowStatusCtrl.update(response.controllerStatus); - } - }).fail(nf.ErrorHandler.handleAjaxError); - }, - - /** - * Updates the cluster summary. - * - * @param clusterSummary - */ - updateClusterSummary: function (clusterSummary) { - // see if this node has been (dis)connected - if (nf.ClusterSummary.isConnectedToCluster() !== clusterSummary.connectedToCluster) { - if (clusterSummary.connectedToCluster) { - nf.Dialog.showConnectedToClusterMessage(); + if (this.controllerInvalidCount > 0) { + $('#controller-invalid-count').parent().removeClass('zero').addClass('invalid'); } else { - nf.Dialog.showDisconnectedFromClusterMessage(); + $('#controller-invalid-count').parent().removeClass('invalid').addClass('zero'); } - } - var color = '#728E9B'; + // update the report values + this.activeThreadCount = status.activeThreadCount; - // update the connection state - if (clusterSummary.connectedToCluster) { - if (nf.Common.isDefinedAndNotNull(clusterSummary.connectedNodes)) { - var connectedNodes = clusterSummary.connectedNodes.split(' / '); - if (connectedNodes.length === 2 && connectedNodes[0] !== connectedNodes[1]) { - this.clusterConnectionWarning = true; - color = '#BA554A'; - } + if (this.activeThreadCount > 0) { + $('#flow-status-container').find('.icon-threads').removeClass('zero'); + } else { + $('#flow-status-container').find('.icon-threads').addClass('zero'); } - this.connectedNodesCount = - nf.Common.isDefinedAndNotNull(clusterSummary.connectedNodes) ? clusterSummary.connectedNodes : '-'; - } else { - this.connectedNodesCount = 'Disconnected'; - color = '#BA554A'; - } - // update the color - $('#connected-nodes-count').closest('div.fa-cubes').css('color', color); - }, - - /** - * Update the flow status counts. - * - * @param status The controller status returned from the `../nifi-api/flow/status` endpoint. - */ - update: function (status) { - var controllerInvalidCount = (nf.Common.isDefinedAndNotNull(status.invalidCount)) ? status.invalidCount : 0; - - if (this.controllerInvalidCount > 0) { - $('#controller-invalid-count').parent().removeClass('zero').addClass('invalid'); - } else { - $('#controller-invalid-count').parent().removeClass('invalid').addClass('zero'); - } - - // update the report values - this.activeThreadCount = status.activeThreadCount; + this.totalQueued = status.queued; - if (this.activeThreadCount > 0) { - $('#flow-status-container').find('.icon-threads').removeClass('zero'); - } else { - $('#flow-status-container').find('.icon-threads').addClass('zero'); - } + if (this.totalQueued.indexOf('0 / 0') >= 0) { + $('#flow-status-container').find('.fa-list').addClass('zero'); + } else { + $('#flow-status-container').find('.fa-list').removeClass('zero'); + } - this.totalQueued = status.queued; + // update the component counts + this.controllerTransmittingCount = + common.isDefinedAndNotNull(status.activeRemotePortCount) ? + status.activeRemotePortCount : '-'; - if (this.totalQueued.indexOf('0 / 0') >= 0) { - $('#flow-status-container').find('.fa-list').addClass('zero'); - } else { - $('#flow-status-container').find('.fa-list').removeClass('zero'); - } + if (this.controllerTransmittingCount > 0) { + $('#flow-status-container').find('.fa-bullseye').removeClass('zero').addClass('transmitting'); + } else { + $('#flow-status-container').find('.fa-bullseye').removeClass('transmitting').addClass('zero'); + } - // update the component counts - this.controllerTransmittingCount = - nf.Common.isDefinedAndNotNull(status.activeRemotePortCount) ? - status.activeRemotePortCount : '-'; + this.controllerNotTransmittingCount = + common.isDefinedAndNotNull(status.inactiveRemotePortCount) ? + status.inactiveRemotePortCount : '-'; - if (this.controllerTransmittingCount > 0) { - $('#flow-status-container').find('.fa-bullseye').removeClass('zero').addClass('transmitting'); - } else { - $('#flow-status-container').find('.fa-bullseye').removeClass('transmitting').addClass('zero'); - } + if (this.controllerNotTransmittingCount > 0) { + $('#flow-status-container').find('.icon-transmit-false').removeClass('zero').addClass('not-transmitting'); + } else { + $('#flow-status-container').find('.icon-transmit-false').removeClass('not-transmitting').addClass('zero'); + } - this.controllerNotTransmittingCount = - nf.Common.isDefinedAndNotNull(status.inactiveRemotePortCount) ? - status.inactiveRemotePortCount : '-'; + this.controllerRunningCount = + common.isDefinedAndNotNull(status.runningCount) ? status.runningCount : '-'; - if (this.controllerNotTransmittingCount > 0) { - $('#flow-status-container').find('.icon-transmit-false').removeClass('zero').addClass('not-transmitting'); - } else { - $('#flow-status-container').find('.icon-transmit-false').removeClass('not-transmitting').addClass('zero'); - } + if (this.controllerRunningCount > 0) { + $('#flow-status-container').find('.fa-play').removeClass('zero').addClass('running'); + } else { + $('#flow-status-container').find('.fa-play').removeClass('running').addClass('zero'); + } - this.controllerRunningCount = - nf.Common.isDefinedAndNotNull(status.runningCount) ? status.runningCount : '-'; + this.controllerStoppedCount = + common.isDefinedAndNotNull(status.stoppedCount) ? status.stoppedCount : '-'; - if (this.controllerRunningCount > 0) { - $('#flow-status-container').find('.fa-play').removeClass('zero').addClass('running'); - } else { - $('#flow-status-container').find('.fa-play').removeClass('running').addClass('zero'); - } + if (this.controllerStoppedCount > 0) { + $('#flow-status-container').find('.fa-stop').removeClass('zero').addClass('stopped'); + } else { + $('#flow-status-container').find('.fa-stop').removeClass('stopped').addClass('zero'); + } - this.controllerStoppedCount = - nf.Common.isDefinedAndNotNull(status.stoppedCount) ? status.stoppedCount : '-'; + this.controllerInvalidCount = + common.isDefinedAndNotNull(status.invalidCount) ? status.invalidCount : '-'; - if (this.controllerStoppedCount > 0) { - $('#flow-status-container').find('.fa-stop').removeClass('zero').addClass('stopped'); - } else { - $('#flow-status-container').find('.fa-stop').removeClass('stopped').addClass('zero'); - } + if (this.controllerInvalidCount > 0) { + $('#flow-status-container').find('.fa-warning').removeClass('zero').addClass('invalid'); + } else { + $('#flow-status-container').find('.fa-warning').removeClass('invalid').addClass('zero'); + } - this.controllerInvalidCount = - nf.Common.isDefinedAndNotNull(status.invalidCount) ? status.invalidCount : '-'; + this.controllerDisabledCount = + common.isDefinedAndNotNull(status.disabledCount) ? status.disabledCount : '-'; - if (this.controllerInvalidCount > 0) { - $('#flow-status-container').find('.fa-warning').removeClass('zero').addClass('invalid'); - } else { - $('#flow-status-container').find('.fa-warning').removeClass('invalid').addClass('zero'); - } + if (this.controllerDisabledCount > 0) { + $('#flow-status-container').find('.icon-enable-false').removeClass('zero').addClass('disabled'); + } else { + $('#flow-status-container').find('.icon-enable-false').removeClass('disabled').addClass('zero'); + } - this.controllerDisabledCount = - nf.Common.isDefinedAndNotNull(status.disabledCount) ? status.disabledCount : '-'; + }, - if (this.controllerDisabledCount > 0) { - $('#flow-status-container').find('.icon-enable-false').removeClass('zero').addClass('disabled'); - } else { - $('#flow-status-container').find('.icon-enable-false').removeClass('disabled').addClass('zero'); + /** + * Updates the controller level bulletins + * + * @param response + */ + updateBulletins: function (response) { + this.bulletins.update(response); } - - }, - - /** - * Updates the controller level bulletins - * - * @param response - */ - updateBulletins: function (response) { - this.bulletins.update(response); } - } - var flowStatusCtrl = new FlowStatusCtrl(); - return flowStatusCtrl; -}; \ No newline at end of file + var flowStatusCtrl = new FlowStatusCtrl(); + return flowStatusCtrl; + }; +})); \ No newline at end of file
http://git-wip-us.apache.org/repos/asf/nifi/blob/bf3b1640/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/js/nf/canvas/controllers/nf-ng-canvas-global-menu-controller.js ---------------------------------------------------------------------- diff --git a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/js/nf/canvas/controllers/nf-ng-canvas-global-menu-controller.js b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/js/nf/canvas/controllers/nf-ng-canvas-global-menu-controller.js index 6d0a304..b28d5b1 100644 --- a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/js/nf/canvas/controllers/nf-ng-canvas-global-menu-controller.js +++ b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/js/nf/canvas/controllers/nf-ng-canvas-global-menu-controller.js @@ -15,386 +15,426 @@ * limitations under the License. */ -/* global nf, d3 */ - -nf.ng.Canvas.GlobalMenuCtrl = function (serviceProvider) { +/* global define, module, require, exports */ + +(function (root, factory) { + if (typeof define === 'function' && define.amd) { + define(['jquery', + 'nf.Common', + 'nf.QueueListing', + 'nf.Shell', + 'nf.PolicyManagement', + 'nf.ClusterSummary', + 'nf.ErrorHandler', + 'nf.Settings', + 'nf.CanvasUtils'], + function ($, common, queueListing, shell, policyManagement, clusterSummary, errorHandler, settings, canvasUtils) { + return (nf.ng.Canvas.GlobalMenuCtrl = factory($, common, queueListing, shell, policyManagement, clusterSummary, errorHandler, settings, canvasUtils)); + }); + } else if (typeof exports === 'object' && typeof module === 'object') { + module.exports = (nf.ng.Canvas.GlobalMenuCtrl = + factory(require('jquery'), + require('nf.Common'), + require('nf.QueueListing'), + require('nf.Shell'), + require('nf.PolicyManagement'), + require('nf.ClusterSummary'), + require('nf.ErrorHandler'), + require('nf.Settings'), + require('nf.CanvasUtils'))); + } else { + nf.ng.Canvas.GlobalMenuCtrl = factory(root.$, + root.nf.Common, + root.nf.QueueListing, + root.nf.Shell, + root.nf.PolicyManagement, + root.nf.ClusterSummary, + root.nf.ErrorHandler, + root.nf.Settings, + root.nf.CanvasUtils); + } +}(this, function ($, common, queueListing, shell, policyManagement, clusterSummary, errorHandler, settings, canvasUtils) { 'use strict'; - var config = { - urls: { - helpDocument: '../nifi-docs/documentation', - controllerAbout: '../nifi-api/flow/about' - } - }; + return function (serviceProvider) { + 'use strict'; - function GlobalMenuCtrl(serviceProvider) { + var config = { + urls: { + helpDocument: '../nifi-docs/documentation', + controllerAbout: '../nifi-api/flow/about' + } + }; - /** - * The summary menu item controller. - */ - this.summary = { + function GlobalMenuCtrl(serviceProvider) { /** - * The summary menu item's shell controller. + * The summary menu item controller. */ - shell: { + this.summary = { /** - * Launch the summary shell. + * The summary menu item's shell controller. */ - launch: function () { - nf.Shell.showPage('summary'); - } - } - }; + shell: { - /** - * The counters menu item controller. - */ - this.counters = { + /** + * Launch the summary shell. + */ + launch: function () { + shell.showPage('summary'); + } + } + }; /** - * The counters menu item's shell controller. + * The counters menu item controller. */ - shell: { + this.counters = { /** - * Launch the counters shell. + * The counters menu item's shell controller. */ - launch: function () { - if (nf.Common.canAccessCounters()) { - nf.Shell.showPage('counters'); + shell: { + + /** + * Launch the counters shell. + */ + launch: function () { + if (common.canAccessCounters()) { + shell.showPage('counters'); + } } } - } - }; - - /** - * The bulletin board menu item controller. - */ - this.bulletinBoard = { + }; /** - * The bulletin board menu item's shell controller. + * The bulletin board menu item controller. */ - shell: { + this.bulletinBoard = { /** - * Launch the bulletin board shell. + * The bulletin board menu item's shell controller. */ - launch: function () { - nf.Shell.showPage('bulletin-board'); - } - } - }; + shell: { - /** - * The data provenance menu item controller. - */ - this.dataProvenance = { + /** + * Launch the bulletin board shell. + */ + launch: function () { + shell.showPage('bulletin-board'); + } + } + }; /** - * The data provenance menu item's shell controller. + * The data provenance menu item controller. */ - shell: { + this.dataProvenance = { /** - * Launch the data provenance shell. + * The data provenance menu item's shell controller. */ - launch: function () { - if (nf.Common.canAccessProvenance()) { - nf.Shell.showPage('provenance'); + shell: { + + /** + * Launch the data provenance shell. + */ + launch: function () { + if (common.canAccessProvenance()) { + shell.showPage('provenance'); + } } } - } - }; - - /** - * The controller settings menu item controller. - */ - this.controllerSettings = { + }; /** - * The controller settings menu item's shell controller. + * The controller settings menu item controller. */ - shell: { + this.controllerSettings = { /** - * Launch the settings shell. + * The controller settings menu item's shell controller. */ - launch: function () { - nf.Settings.showSettings(); - } - } - }; + shell: { - /** - * The cluster menu item controller. - */ - this.cluster = { + /** + * Launch the settings shell. + */ + launch: function () { + settings.showSettings(); + } + } + }; /** - * Determines if the cluster menu item is enabled. - * - * @returns {*|boolean} + * The cluster menu item controller. */ - visible: function () { - return nf.ClusterSummary.isConnectedToCluster(); - }, + this.cluster = { - /** - * The cluster menu item's shell controller. - */ - shell: { + /** + * Determines if the cluster menu item is enabled. + * + * @returns {*|boolean} + */ + visible: function () { + return clusterSummary.isConnectedToCluster(); + }, /** - * Launch the cluster shell. + * The cluster menu item's shell controller. */ - launch: function () { - if (nf.Common.canAccessController()) { - nf.Shell.showPage('cluster'); + shell: { + + /** + * Launch the cluster shell. + */ + launch: function () { + if (common.canAccessController()) { + shell.showPage('cluster'); + } } } - } - }; - - /** - * The flow config history menu item controller. - */ - this.flowConfigHistory = { + }; /** - * The flow config history menu item's shell controller. + * The flow config history menu item controller. */ - shell: { + this.flowConfigHistory = { /** - * Launch the history shell. + * The flow config history menu item's shell controller. */ - launch: function () { - nf.Shell.showPage('history'); - } - } - }; + shell: { - /** - * The users menu item controller. - */ - this.users = { + /** + * Launch the history shell. + */ + launch: function () { + shell.showPage('history'); + } + } + }; /** - * The users menu item's shell controller. + * The users menu item controller. */ - shell: { + this.users = { /** - * Launch the users shell. + * The users menu item's shell controller. */ - launch: function () { - if (nf.Common.canAccessTenants()) { - nf.Shell.showPage('users'); + shell: { + + /** + * Launch the users shell. + */ + launch: function () { + if (common.canAccessTenants()) { + shell.showPage('users'); + } } } - } - }; - - /** - * The policies menu item controller. - */ - this.policies = { + }; /** - * The policies menu item's shell controller. + * The policies menu item controller. */ - shell: { + this.policies = { /** - * Launch the policies shell. + * The policies menu item's shell controller. */ - launch: function () { - if (nf.Common.canModifyPolicies() && nf.Common.canAccessTenants()) { - nf.PolicyManagement.showGlobalPolicies(); + shell: { + + /** + * Launch the policies shell. + */ + launch: function () { + if (common.canModifyPolicies() && common.canAccessTenants()) { + policyManagement.showGlobalPolicies(); + } } } - } - }; - - /** - * The templates menu item controller. - */ - this.templates = { + }; /** - * The templates menu item's shell controller. + * The templates menu item controller. */ - shell: { + this.templates = { /** - * Launch the templates shell. + * The templates menu item's shell controller. */ - launch: function () { - nf.Shell.showPage('templates?' + $.param({ - groupId: nf.Canvas.getGroupId() - })); + shell: { + + /** + * Launch the templates shell. + */ + launch: function () { + shell.showPage('templates?' + $.param({ + groupId: canvasUtils.getGroupId() + })); + } } - } - }; - - /** - * The help menu item controller. - */ - this.help = { + }; /** - * The help menu item's shell controller. + * The help menu item controller. */ - shell: { + this.help = { /** - * Launch the help documentation shell. + * The help menu item's shell controller. */ - launch: function () { - nf.Shell.showPage(config.urls.helpDocument); - } - } - }; - - /** - * The about menu item controller. - */ - this.about = { + shell: { - /** - * Initialize the about details. - */ - init: function () { - // get the about details - $.ajax({ - type: 'GET', - url: config.urls.controllerAbout, - dataType: 'json' - }).done(function (response) { - var aboutDetails = response.about; - // set the document title and the about title - document.title = aboutDetails.title; - $('#nf-version').text(aboutDetails.version); - var showVersionDetail = false; - if (aboutDetails.buildTag && aboutDetails.buildTag !== 'HEAD') { - $('#nf-about-build-tag').text(aboutDetails.buildTag); - $('#nf-version-detail-tag').show(); - showVersionDetail = true; + /** + * Launch the help documentation shell. + */ + launch: function () { + shell.showPage(config.urls.helpDocument); } - if (aboutDetails.buildRevision) { - $('#nf-about-build-revision').text(aboutDetails.buildRevision); - $('#nf-about-build-branch').text(aboutDetails.buildBranch); - $('#nf-version-detail-commit').show(); - showVersionDetail = true - } - if (aboutDetails.buildTimestamp) { - $('#nf-about-build-timestamp').text(aboutDetails.buildTimestamp); - $('#nf-version-detail-timestamp').show(); - showVersionDetail = true; - } - if (showVersionDetail) { - $('#nf-version-detail').show(); - } - - // store the content viewer url if available - if (!nf.Common.isBlank(aboutDetails.contentViewerUrl)) { - $('#nifi-content-viewer-url').text(aboutDetails.contentViewerUrl); - nf.QueueListing.initFlowFileDetailsDialog(); - } - }).fail(nf.ErrorHandler.handleAjaxError); - - this.modal.init(); - }, + } + }; /** - * The about menu item's modal controller. + * The about menu item controller. */ - modal: { + this.about = { /** - * Gets the modal element. - * - * @returns {*|jQuery|HTMLElement} + * Initialize the about details. */ - getElement: function () { - return $('#nf-about'); + init: function () { + // get the about details + $.ajax({ + type: 'GET', + url: config.urls.controllerAbout, + dataType: 'json' + }).done(function (response) { + var aboutDetails = response.about; + // set the document title and the about title + document.title = aboutDetails.title; + $('#nf-version').text(aboutDetails.version); + var showVersionDetail = false; + if (aboutDetails.buildTag && aboutDetails.buildTag !== 'HEAD') { + $('#nf-about-build-tag').text(aboutDetails.buildTag); + $('#nf-version-detail-tag').show(); + showVersionDetail = true; + } + if (aboutDetails.buildRevision) { + $('#nf-about-build-revision').text(aboutDetails.buildRevision); + $('#nf-about-build-branch').text(aboutDetails.buildBranch); + $('#nf-version-detail-commit').show(); + showVersionDetail = true + } + if (aboutDetails.buildTimestamp) { + $('#nf-about-build-timestamp').text(aboutDetails.buildTimestamp); + $('#nf-version-detail-timestamp').show(); + showVersionDetail = true; + } + if (showVersionDetail) { + $('#nf-version-detail').show(); + } + + // store the content viewer url if available + if (!common.isBlank(aboutDetails.contentViewerUrl)) { + $('#nifi-content-viewer-url').text(aboutDetails.contentViewerUrl); + queueListing.initFlowFileDetailsDialog(); + } + }).fail(errorHandler.handleAjaxError); + + this.modal.init(); }, /** - * Initialize the modal. + * The about menu item's modal controller. */ - init: function () { - var aboutModal = this; - - var resizeAbout = function(){ - var dialog = $(this); - var top = $('#nf-about-pic-container').height() + $('.dialog-header').height() + 10; //10 for padding-top - dialog.find('.dialog-content').css('top', top); - }; - - this.getElement().modal({ - scrollableContentStyle: 'scrollable', - headerText: 'About Apache NiFi', - handler: { - resize: resizeAbout - }, - buttons: [{ - buttonText: 'Ok', - color: { - base: '#728E9B', - hover: '#004849', - text: '#ffffff' - }, + modal: { + + /** + * Gets the modal element. + * + * @returns {*|jQuery|HTMLElement} + */ + getElement: function () { + return $('#nf-about'); + }, + + /** + * Initialize the modal. + */ + init: function () { + var aboutModal = this; + + var resizeAbout = function () { + var dialog = $(this); + var top = $('#nf-about-pic-container').height() + $('.dialog-header').height() + 10; //10 for padding-top + dialog.find('.dialog-content').css('top', top); + }; + + this.getElement().modal({ + scrollableContentStyle: 'scrollable', + headerText: 'About Apache NiFi', handler: { - click: function () { - aboutModal.hide(); + resize: resizeAbout + }, + buttons: [{ + buttonText: 'Ok', + color: { + base: '#728E9B', + hover: '#004849', + text: '#ffffff' + }, + handler: { + click: function () { + aboutModal.hide(); + } } - } - }] - }); - }, - - /** - * Updates the modal config. - * - * @param {string} name The name of the property to update. - * @param {object|array} config The config for the `name`. - */ - update: function (name, config) { - this.getElement().modal(name, config); - }, - - /** - * Show the modal - */ - show: function () { - this.getElement().modal('show'); - }, - - /** - * Hide the modal - */ - hide: function () { - this.getElement().modal('hide'); + }] + }); + }, + + /** + * Updates the modal config. + * + * @param {string} name The name of the property to update. + * @param {object|array} config The config for the `name`. + */ + update: function (name, config) { + this.getElement().modal(name, config); + }, + + /** + * Show the modal + */ + show: function () { + this.getElement().modal('show'); + }, + + /** + * Hide the modal + */ + hide: function () { + this.getElement().modal('hide'); + } } } } - } - GlobalMenuCtrl.prototype = { - constructor: GlobalMenuCtrl, + GlobalMenuCtrl.prototype = { + constructor: GlobalMenuCtrl, - /** - * Initialize the global menu controls. - */ - init: function () { - this.about.init(); + /** + * Initialize the global menu controls. + */ + init: function () { + this.about.init(); + } } - } - var globalMenuCtrl = new GlobalMenuCtrl(); - return globalMenuCtrl; -}; \ No newline at end of file + var globalMenuCtrl = new GlobalMenuCtrl(); + return globalMenuCtrl; + }; +})); \ No newline at end of file
