http://git-wip-us.apache.org/repos/asf/nifi/blob/dc934cbb/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/js/jquery/propertytable/jquery.propertytable.js ---------------------------------------------------------------------- diff --git a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/js/jquery/propertytable/jquery.propertytable.js b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/js/jquery/propertytable/jquery.propertytable.js index 006a41b..dacd8a0 100644 --- a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/js/jquery/propertytable/jquery.propertytable.js +++ b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/js/jquery/propertytable/jquery.propertytable.js @@ -15,34 +15,71 @@ * limitations under the License. */ -/* global nf, Slick */ - -/** - * Create a property table. The options are specified in the following - * format: - * - * { - * readOnly: true, - * dialogContainer: 'body', - * descriptorDeferred: function () { - * return $.Deferred(function (deferred) { - * deferred.resolve(); - * }).promise; - * }, - * goToServiceDeferred: function () { - * return $.Deferred(function (deferred) { - * deferred.resolve(); - * }).promise; - * } - * } - */ +/* global define, module, require, exports */ + +/* requires modal, combo, qtip, and nfeditor plugins to be loaded first*/ + +(function (root, factory) { + if (typeof define === 'function' && define.amd) { + define(['jquery', + 'Slick', + 'nf.Common', + 'nf.UniversalCapture', + 'nf.Dialog', + 'nf.Client', + 'nf.ErrorHandler', + 'nf.ProcessGroupConfiguration', + 'nf.Settings'], + function ($, + Slick, + common, + universalCapture, + dialog, + client, + errorHandler, + processGroupConfiguration, + settings) { + factory($, + Slick, + common, + universalCapture, + dialog, + client, + errorHandler, + processGroupConfiguration, + settings); + }); + } else if (typeof exports === 'object' && typeof module === 'object') { + factory(require('jquery'), + require('Slick'), + require('nf.Common'), + require('nf.UniversalCapture'), + require('nf.Dialog'), + require('nf.Client'), + require('nf.ErrorHandler'), + require('nf.ProcessGroupConfiguration'), + require('nf.Settings')); + } else { + factory(root.$, + root.Slick, + root.nf.Common, + root.nf.UniversalCapture, + root.nf.Dialog, + root.nf.Client, + root.nf.ErrorHandler, + root.nf.ProcessGroupConfiguration, + root.nf.Settings); + } +}(this, function ($, + Slick, + common, + universalCapture, + dialog, + client, + errorHandler, + processGroupConfiguration, + settings) { -/** - * jQuery plugin for a property table. - * - * @param {type} $ - */ -(function ($) { var languageId = 'nfel'; var editorClass = languageId + '-editor'; var groupId = null; @@ -182,12 +219,12 @@ this.loadValue = function (item) { // determine if this is a sensitive property var isEmptyChecked = false; - var sensitive = nf.Common.isSensitiveProperty(propertyDescriptor); + var sensitive = common.isSensitiveProperty(propertyDescriptor); // determine the value to use when populating the text field - if (nf.Common.isDefinedAndNotNull(item[args.column.field])) { + if (common.isDefinedAndNotNull(item[args.column.field])) { if (sensitive) { - initialValue = nf.Common.config.sensitiveText; + initialValue = common.config.sensitiveText; } else { initialValue = item[args.column.field]; isEmptyChecked = initialValue === ''; @@ -204,7 +241,7 @@ var sensitiveInput = $(this); if (sensitiveInput.hasClass('sensitive')) { sensitiveInput.removeClass('sensitive'); - if (sensitiveInput.val() === nf.Common.config.sensitiveText) { + if (sensitiveInput.val() === common.config.sensitiveText) { sensitiveInput.val(''); } } @@ -223,8 +260,8 @@ return ''; } else { // otherwise if the property is required - if (nf.Common.isRequiredProperty(propertyDescriptor)) { - if (nf.Common.isBlank(propertyDescriptor.defaultValue)) { + if (common.isRequiredProperty(propertyDescriptor)) { + if (common.isBlank(propertyDescriptor.defaultValue)) { return previousValue; } else { return propertyDescriptor.defaultValue; @@ -285,7 +322,7 @@ propertyDescriptor = descriptors[args.item.property]; // determine if this is a sensitive property - var sensitive = nf.Common.isSensitiveProperty(propertyDescriptor); + var sensitive = common.isSensitiveProperty(propertyDescriptor); // record the previous value previousValue = args.item[args.column.field]; @@ -402,12 +439,12 @@ this.loadValue = function (item) { // determine if this is a sensitive property var isEmptyChecked = false; - var sensitive = nf.Common.isSensitiveProperty(propertyDescriptor); + var sensitive = common.isSensitiveProperty(propertyDescriptor); // determine the value to use when populating the text field - if (nf.Common.isDefinedAndNotNull(item[args.column.field])) { + if (common.isDefinedAndNotNull(item[args.column.field])) { if (sensitive) { - initialValue = nf.Common.config.sensitiveText; + initialValue = common.config.sensitiveText; } else { initialValue = item[args.column.field]; isEmptyChecked = initialValue === ''; @@ -431,8 +468,8 @@ return ''; } else { // otherwise if the property is required - if (nf.Common.isRequiredProperty(propertyDescriptor)) { - if (nf.Common.isBlank(propertyDescriptor.defaultValue)) { + if (common.isRequiredProperty(propertyDescriptor)) { + if (common.isBlank(propertyDescriptor.defaultValue)) { return previousValue; } else { return propertyDescriptor.defaultValue; @@ -516,7 +553,7 @@ }).appendTo(container); // check for allowable values which will drive which editor to use - var allowableValues = nf.Common.getAllowableValues(propertyDescriptor); + var allowableValues = common.getAllowableValues(propertyDescriptor); // show the output port options var options = []; @@ -534,7 +571,7 @@ text: allowableValue.displayName, value: allowableValue.value, disabled: allowableValueEntity.canRead === false && allowableValue.value !== args.item['previousValue'], - description: nf.Common.escapeHtml(allowableValue.description) + description: common.escapeHtml(allowableValue.description) }); }); } @@ -550,7 +587,7 @@ } // if this descriptor identifies a controller service, provide a way to create one - if (nf.Common.isDefinedAndNotNull(propertyDescriptor.identifiesControllerService)) { + if (common.isDefinedAndNotNull(propertyDescriptor.identifiesControllerService)) { options.push({ text: 'Create new service...', value: undefined, @@ -579,7 +616,8 @@ }).css({ 'margin-top': '10px', 'margin-bottom': '10px', - 'width': ((position.width - 16) < 212) ? 212 : (position.width - 16) + 'px'}).appendTo(wrapper); + 'width': ((position.width - 16) < 212) ? 212 : (position.width - 16) + 'px' + }).appendTo(wrapper); // add buttons for handling user input var cancel = $('<div class="secondary-button">Cancel</div>').css({ @@ -647,13 +685,13 @@ this.loadValue = function (item) { // select as appropriate - if (!nf.Common.isUndefined(item.value)) { + if (!common.isUndefined(item.value)) { initialValue = item.value; combo.combo('setSelectedOption', { value: item.value }); - } else if (nf.Common.isDefinedAndNotNull(propertyDescriptor.defaultValue)) { + } else if (common.isDefinedAndNotNull(propertyDescriptor.defaultValue)) { initialValue = propertyDescriptor.defaultValue; combo.combo('setSelectedOption', { @@ -697,20 +735,20 @@ */ var showPropertyValue = function (propertyGrid, descriptors, row, cell) { // remove any currently open detail dialogs - nf.UniversalCapture.removeAllPropertyDetailDialogs(); + universalCapture.removeAllPropertyDetailDialogs(); // get the property in question var propertyData = propertyGrid.getData(); var property = propertyData.getItem(row); // ensure there is a value - if (nf.Common.isDefinedAndNotNull(property.value)) { + if (common.isDefinedAndNotNull(property.value)) { // get the descriptor to insert the description tooltip var propertyDescriptor = descriptors[property.property]; // ensure we're not dealing with a sensitive property - if (!nf.Common.isSensitiveProperty(propertyDescriptor)) { + if (!common.isSensitiveProperty(propertyDescriptor)) { // get details about the location of the cell var cellNode = $(propertyGrid.getCellNode(row, cell)); @@ -731,7 +769,7 @@ 'left': offset.left - 20 }).appendTo('body'); - var allowableValues = nf.Common.getAllowableValues(propertyDescriptor); + var allowableValues = common.getAllowableValues(propertyDescriptor); if ($.isArray(allowableValues)) { // prevent dragging over the combo wrapper.draggable({ @@ -746,7 +784,7 @@ options.push({ text: allowableValue.displayName, value: allowableValue.value, - description: nf.Common.escapeHtml(allowableValue.description), + description: common.escapeHtml(allowableValue.description), disabled: true }); }); @@ -795,7 +833,7 @@ var editor = null; // so the nfel editor is appropriate - if (nf.Common.supportsEl(propertyDescriptor)) { + if (common.supportsEl(propertyDescriptor)) { var languageId = 'nfel'; var editorClass = languageId + '-editor'; @@ -919,41 +957,41 @@ var options = []; $.each(response.controllerServiceTypes, function (i, controllerServiceType) { options.push({ - text: nf.Common.substringAfterLast(controllerServiceType.type, '.'), + text: common.substringAfterLast(controllerServiceType.type, '.'), value: controllerServiceType.type, - description: nf.Common.escapeHtml(controllerServiceType.description) + description: common.escapeHtml(controllerServiceType.description) }); }); // ensure there are some applicable controller services if (options.length === 0) { - nf.Dialog.showOkDialog({ + dialog.showOkDialog({ headerText: 'Controller Service', dialogContent: 'No controller service types found that are applicable for this property.' }); } else { var newControllerServiceDialogMarkup = '<div id="new-inline-controller-service-dialog" class="hidden dialog medium-dialog cancellable">' + - '<div class="dialog-content">' + - '<div>' + - '<div class="setting-name">Controller Service</div>' + - '<div class="setting-field">' + - '<div class="new-inline-controller-service-combo"></div>' + - '</div>' + - '</div>' + - '<div>' + - '<div class="setting-name">Tags</div>' + - '<div class="setting-field">' + - '<div class="new-inline-controller-service-tags"></div>' + - '</div>' + - '</div>' + - '<div>' + - '<div class="setting-name">Description</div>' + - '<div class="setting-field">' + - '<div class="new-inline-controller-service-description"></div>' + - '</div>' + - '</div>' + - '</div>' + + '<div class="dialog-content">' + + '<div>' + + '<div class="setting-name">Controller Service</div>' + + '<div class="setting-field">' + + '<div class="new-inline-controller-service-combo"></div>' + + '</div>' + + '</div>' + + '<div>' + + '<div class="setting-name">Tags</div>' + + '<div class="setting-field">' + + '<div class="new-inline-controller-service-tags"></div>' + + '</div>' + + '</div>' + + '<div>' + + '<div class="setting-name">Description</div>' + + '<div class="setting-field">' + + '<div class="new-inline-controller-service-description"></div>' + + '</div>' + + '</div>' + + '</div>' + '</div>'; var newControllerServiceDialog = $(newControllerServiceDialogMarkup).appendTo(configurationOptions.dialogContainer); @@ -1015,7 +1053,7 @@ // build the controller service entity var controllerServiceEntity = { - 'revision': nf.Client.getRevision({ + 'revision': client.getRevision({ 'revision': { 'version': 0, } @@ -1027,7 +1065,7 @@ // determine the appropriate uri for creating the controller service var uri = '../nifi-api/controller/controller-services'; - if (nf.Common.isDefinedAndNotNull(groupId)) { + if (common.isDefinedAndNotNull(groupId)) { uri = '../nifi-api/process-groups/' + encodeURIComponent(groupId) + '/controller-services'; } @@ -1045,7 +1083,7 @@ // store the descriptor for use later var descriptors = gridContainer.data('descriptors'); - if (!nf.Common.isUndefined(descriptors)) { + if (!common.isUndefined(descriptors)) { descriptors[descriptor.name] = descriptor; } @@ -1054,7 +1092,7 @@ data.updateItem(item.id, $.extend(item, { value: response.component.id })); - + // close the dialog newControllerServiceDialog.modal('hide'); }); @@ -1063,7 +1101,7 @@ if (typeof configurationOptions.controllerServiceCreatedDeferred === 'function') { configurationOptions.controllerServiceCreatedDeferred(response); } - }).fail(nf.Common.handleAjaxError); + }).fail(errorHandler.handleAjaxError); }; var cancel = function () { @@ -1072,7 +1110,7 @@ newControllerServiceDialog.modal('show'); } - }).fail(nf.Common.handleAjaxError); + }).fail(errorHandler.handleAjaxError); }; var initPropertiesTable = function (table, options) { @@ -1092,8 +1130,8 @@ var propertyDescriptor = descriptors[dataContext.property]; // show the property description if applicable - if (nf.Common.isDefinedAndNotNull(propertyDescriptor)) { - if (!nf.Common.isBlank(propertyDescriptor.description) || !nf.Common.isBlank(propertyDescriptor.defaultValue) || !nf.Common.isBlank(propertyDescriptor.supportsEl)) { + if (common.isDefinedAndNotNull(propertyDescriptor)) { + if (!common.isBlank(propertyDescriptor.description) || !common.isBlank(propertyDescriptor.defaultValue) || !common.isBlank(propertyDescriptor.supportsEl)) { $('<div class="fa fa-question-circle" alt="Info" style="float: right; margin-right: 6px; margin-top: 4px;"></div>').appendTo(cellContent); $('<span class="hidden property-descriptor-name"></span>').text(dataContext.property).appendTo(cellContent); nameWidthOffset = 46; // 10 + icon width (10) + icon margin (6) + padding (20) @@ -1110,17 +1148,17 @@ // function for formatting the property value var valueFormatter = function (row, cell, value, columnDef, dataContext) { var valueMarkup; - if (nf.Common.isDefinedAndNotNull(value)) { + if (common.isDefinedAndNotNull(value)) { // get the property descriptor var descriptors = table.data('descriptors'); var propertyDescriptor = descriptors[dataContext.property]; // determine if the property is sensitive - if (nf.Common.isSensitiveProperty(propertyDescriptor)) { + if (common.isSensitiveProperty(propertyDescriptor)) { valueMarkup = '<span class="table-cell sensitive">Sensitive value set</span>'; } else { // if there are allowable values, attempt to swap out for the display name - var allowableValues = nf.Common.getAllowableValues(propertyDescriptor); + var allowableValues = common.getAllowableValues(propertyDescriptor); if ($.isArray(allowableValues)) { $.each(allowableValues, function (_, allowableValueEntity) { var allowableValue = allowableValueEntity.allowableValue; @@ -1134,7 +1172,7 @@ if (value === '') { valueMarkup = '<span class="table-cell blank">Empty string set</span>'; } else { - valueMarkup = '<div class="table-cell value"><pre class="ellipsis">' + nf.Common.escapeHtml(value) + '</pre></div>'; + valueMarkup = '<div class="table-cell value"><pre class="ellipsis">' + common.escapeHtml(value) + '</pre></div>'; } } } else { @@ -1182,12 +1220,11 @@ var descriptors = table.data('descriptors'); var propertyDescriptor = descriptors[dataContext.property]; - var identifiesControllerService = nf.Common.isDefinedAndNotNull(propertyDescriptor.identifiesControllerService); - var isConfigured = nf.Common.isDefinedAndNotNull(dataContext.value); - var isOnCanvas = nf.Common.isDefinedAndNotNull(nf.Canvas); + var identifiesControllerService = common.isDefinedAndNotNull(propertyDescriptor.identifiesControllerService); + var isConfigured = common.isDefinedAndNotNull(dataContext.value); // check to see if we should provide a button for going to a controller service - if (identifiesControllerService && isConfigured && isOnCanvas) { + if (identifiesControllerService && isConfigured && (options.supportsGoTo === true)) { // ensure the configured value is referencing a valid service $.each(propertyDescriptor.allowableValues, function (_, allowableValueEntity) { var allowableValue = allowableValueEntity.allowableValue; @@ -1236,7 +1273,7 @@ var propertyDescriptor = descriptors[item.property]; // support el if specified or unsure yet (likely a dynamic property) - if (nf.Common.isUndefinedOrNull(propertyDescriptor) || nf.Common.supportsEl(propertyDescriptor)) { + if (common.isUndefinedOrNull(propertyDescriptor) || common.supportsEl(propertyDescriptor)) { return { columns: { value: { @@ -1246,7 +1283,7 @@ }; } else { // check for allowable values which will drive which editor to use - var allowableValues = nf.Common.getAllowableValues(propertyDescriptor); + var allowableValues = common.getAllowableValues(propertyDescriptor); if ($.isArray(allowableValues)) { return { columns: { @@ -1283,37 +1320,37 @@ var controllerService = controllerServiceEntity.component; $.Deferred(function (deferred) { - if (nf.Common.isDefinedAndNotNull(controllerService.parentGroupId)) { + if (common.isDefinedAndNotNull(controllerService.parentGroupId)) { if ($('#process-group-configuration').is(':visible')) { - nf.ProcessGroupConfiguration.loadConfiguration(controllerService.parentGroupId).done(function () { + processGroupConfiguration.loadConfiguration(controllerService.parentGroupId).done(function () { deferred.resolve(); }); } else { - nf.ProcessGroupConfiguration.showConfiguration(controllerService.parentGroupId).done(function () { + processGroupConfiguration.showConfiguration(controllerService.parentGroupId).done(function () { deferred.resolve(); }); } } else { if ($('#settings').is(':visible')) { // reload the settings - nf.Settings.loadSettings().done(function () { + settings.loadSettings().done(function () { deferred.resolve(); }); } else { // reload the settings and show - nf.Settings.showSettings().done(function () { + settings.showSettings().done(function () { deferred.resolve(); }); } } }).done(function () { - if (nf.Common.isDefinedAndNotNull(controllerService.parentGroupId)) { - nf.ProcessGroupConfiguration.selectControllerService(property.value); + if (common.isDefinedAndNotNull(controllerService.parentGroupId)) { + processGroupConfiguration.selectControllerService(property.value); } else { - nf.Settings.selectControllerService(property.value); + settings.selectControllerService(property.value); } }); - }).fail(nf.Common.handleAjaxError); + }).fail(errorHandler.handleAjaxError); }; // initialize the grid @@ -1396,11 +1433,11 @@ var propertyHistory = history[property]; // format the tooltip - var tooltip = nf.Common.formatPropertyTooltip(propertyDescriptor, propertyHistory); + var tooltip = common.formatPropertyTooltip(propertyDescriptor, propertyHistory); - if (nf.Common.isDefinedAndNotNull(tooltip)) { + if (common.isDefinedAndNotNull(tooltip)) { infoIcon.qtip($.extend({}, - nf.Common.config.tooltipConfig, + common.config.tooltipConfig, { content: tooltip })); @@ -1412,7 +1449,7 @@ var saveRow = function (table) { // get the property grid to commit the current edit var propertyGrid = table.data('gridInstance'); - if (nf.Common.isDefinedAndNotNull(propertyGrid)) { + if (common.isDefinedAndNotNull(propertyGrid)) { var editController = propertyGrid.getEditController(); editController.commitCurrentEdit(); } @@ -1449,7 +1486,7 @@ var propertyData = propertyGrid.getData(); // generate the properties - if (nf.Common.isDefinedAndNotNull(properties)) { + if (common.isDefinedAndNotNull(properties)) { propertyData.beginUpdate(); var i = 0; @@ -1460,10 +1497,10 @@ // determine the property type var type = 'userDefined'; var displayName = name; - if (nf.Common.isDefinedAndNotNull(descriptor)) { - if (nf.Common.isRequiredProperty(descriptor)) { + if (common.isDefinedAndNotNull(descriptor)) { + if (common.isRequiredProperty(descriptor)) { type = 'required'; - } else if (nf.Common.isDynamicProperty(descriptor)) { + } else if (common.isDynamicProperty(descriptor)) { type = 'userDefined'; } else { type = 'optional'; @@ -1473,7 +1510,7 @@ displayName = descriptor.displayName; // determine the value - if (nf.Common.isNull(value) && nf.Common.isDefinedAndNotNull(descriptor.defaultValue)) { + if (common.isNull(value) && common.isDefinedAndNotNull(descriptor.defaultValue)) { value = descriptor.defaultValue; } } @@ -1502,10 +1539,10 @@ var clear = function (propertyTableContainer) { var options = propertyTableContainer.data('options'); if (options.readOnly === true) { - nf.UniversalCapture.removeAllPropertyDetailDialogs(); + universalCapture.removeAllPropertyDetailDialogs(); } else { // clear any existing new property dialogs - if (nf.Common.isDefinedAndNotNull(options.dialogContainer)) { + if (common.isDefinedAndNotNull(options.dialogContainer)) { $('#new-property-dialog').modal("hide"); } } @@ -1515,7 +1552,7 @@ table.removeData('descriptors history'); // clean up any tooltips that may have been generated - nf.Common.cleanUpTooltips(table, 'div.fa-question-circle'); + common.cleanUpTooltips(table, 'div.fa-question-circle'); // clear the data in the grid var propertyGrid = table.data('gridInstance'); @@ -1525,14 +1562,31 @@ var methods = { /** - * Initializes the tag cloud. + * Create a property table. The options are specified in the following + * format: + * + * { + * readOnly: true, + * dialogContainer: 'body', + * descriptorDeferred: function () { + * return $.Deferred(function (deferred) { + * deferred.resolve(); + * }).promise; + * }, + * supportsGoTo: true, + * goToServiceDeferred: function () { + * return $.Deferred(function (deferred) { + * deferred.resolve(); + * }).promise; + * } + * } * * @argument {object} options The options for the tag cloud */ init: function (options) { return this.each(function () { // ensure the options have been properly specified - if (nf.Common.isDefinedAndNotNull(options)) { + if (common.isDefinedAndNotNull(options)) { // get the tag cloud var propertyTableContainer = $(this); @@ -1547,18 +1601,18 @@ var table = $('<div class="property-table"></div>').appendTo(propertyTableContainer); // optionally add a add new property button - if (options.readOnly !== true && nf.Common.isDefinedAndNotNull(options.dialogContainer)) { + if (options.readOnly !== true && common.isDefinedAndNotNull(options.dialogContainer)) { // build the new property dialog var newPropertyDialogMarkup = '<div id="new-property-dialog" class="dialog cancellable small-dialog hidden">' + - '<div class="dialog-content">' + - '<div>' + - '<div class="setting-name">Property name</div>' + - '<div class="setting-field new-property-name-container">' + - '<input class="new-property-name" type="text"/>' + - '</div>' + - '</div>' + - '</div>' + + '<div class="dialog-content">' + + '<div>' + + '<div class="setting-name">Property name</div>' + + '<div class="setting-field new-property-name-container">' + + '<input class="new-property-name" type="text"/>' + + '</div>' + + '</div>' + + '</div>' + '</div>'; var newPropertyDialog = $(newPropertyDialogMarkup).appendTo(options.dialogContainer); @@ -1619,7 +1673,7 @@ // store the descriptor for use later var descriptors = table.data('descriptors'); - if (!nf.Common.isUndefined(descriptors)) { + if (!common.isUndefined(descriptors)) { descriptors[descriptor.name] = descriptor; } @@ -1654,7 +1708,7 @@ propertyGrid.setActiveCell(row, propertyGrid.getColumnIndex('value')); propertyGrid.editActiveCell(); } else { - nf.Dialog.showOkDialog({ + dialog.showOkDialog({ headerText: 'Property Exists', dialogContent: 'A property with this name already exists.' }); @@ -1666,7 +1720,7 @@ } } } else { - nf.Dialog.showOkDialog({ + dialog.showOkDialog({ headerText: 'Property Name', dialogContent: 'Property name must be specified.' }); @@ -1749,7 +1803,7 @@ return this.each(function () { var table = $(this).find('div.property-table'); var propertyGrid = table.data('gridInstance'); - if (nf.Common.isDefinedAndNotNull(propertyGrid)) { + if (common.isDefinedAndNotNull(propertyGrid)) { propertyGrid.resizeCanvas(); } }); @@ -1762,7 +1816,7 @@ return this.each(function () { var table = $(this).find('div.property-table'); var propertyGrid = table.data('gridInstance'); - if (nf.Common.isDefinedAndNotNull(propertyGrid)) { + if (common.isDefinedAndNotNull(propertyGrid)) { var editController = propertyGrid.getEditController(); editController.cancelCurrentEdit(); } @@ -1777,12 +1831,12 @@ var propertyTableContainer = $(this); var options = propertyTableContainer.data('options'); - if (nf.Common.isDefinedAndNotNull(options)) { + if (common.isDefinedAndNotNull(options)) { // clear the property table container clear(propertyTableContainer); // clear any existing new property dialogs - if (nf.Common.isDefinedAndNotNull(options.dialogContainer)) { + if (common.isDefinedAndNotNull(options.dialogContainer)) { $('#new-property-dialog').modal("hide"); $(options.dialogContainer).children('div.new-inline-controller-service-dialog').remove(); } @@ -1870,4 +1924,4 @@ return methods.init.apply(this, arguments); } }; -})(jQuery); +})); \ No newline at end of file
http://git-wip-us.apache.org/repos/asf/nifi/blob/dc934cbb/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/js/jquery/tagcloud/jquery.tagcloud.js ---------------------------------------------------------------------- diff --git a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/js/jquery/tagcloud/jquery.tagcloud.js b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/js/jquery/tagcloud/jquery.tagcloud.js index 2eb551c..526a64c 100644 --- a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/js/jquery/tagcloud/jquery.tagcloud.js +++ b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/js/jquery/tagcloud/jquery.tagcloud.js @@ -127,7 +127,7 @@ $.each(options.tags, function (i, tag) { var normalizedTagName = tag.toLowerCase(); - if (nf.Common.isDefinedAndNotNull(tagCloud[normalizedTagName])) { + if (isDefinedAndNotNull(tagCloud[normalizedTagName])) { tagCloud[normalizedTagName].count = tagCloud[normalizedTagName].count + 1; } else { var tagCloudEntry = { http://git-wip-us.apache.org/repos/asf/nifi/blob/dc934cbb/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/js/nf/bulletin-board/nf-bulletin-board.js ---------------------------------------------------------------------- diff --git a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/js/nf/bulletin-board/nf-bulletin-board.js b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/js/nf/bulletin-board/nf-bulletin-board.js index 58d8f79..c36296b 100644 --- a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/js/nf/bulletin-board/nf-bulletin-board.js +++ b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/js/nf/bulletin-board/nf-bulletin-board.js @@ -15,421 +15,480 @@ * limitations under the License. */ -/* global nf, top */ - -$(document).ready(function () { +/* global nf, define, module, require, exports */ + +(function (root, factory) { + if (typeof define === 'function' && define.amd) { + define(['jquery', + 'angular', + 'nf.Common', + 'nf.ng.AppConfig', + 'nf.ng.AppCtrl', + 'nf.ng.ServiceProvider', + 'nf.ng.Bridge', + 'nf.ErrorHandler', + 'nf.Storage'], + function ($, + angular, + common, + appConfig, + appCtrl, + serviceProvider, + angularBridge, + errorHandler, + storage) { + return (nf.ng.BulletinBoardCtrl = + factory($, + angular, + common, + appConfig, + appCtrl, + serviceProvider, + angularBridge, + errorHandler, + storage)); + }); + } else if (typeof exports === 'object' && typeof module === 'object') { + module.exports = (nf.ng.BulletinBoardCtrl = + factory(require('jquery'), + require('angular'), + require('nf.Common'), + require('nf.ng.AppConfig'), + require('nf.ng.AppCtrl'), + require('nf.ng.ServiceProvider'), + require('nf.ng.Bridge'), + require('nf.ErrorHandler'), + require('nf.Storage'))); + } else { + nf.ng.BulletinBoardCtrl = factory(root.$, + root.angular, + root.nf.Common, + root.nf.ng.AppConfig, + root.nf.ng.AppCtrl, + root.nf.ng.ServiceProvider, + root.nf.ng.Bridge, + root.nf.ErrorHandler, + root.nf.Storage); + } +}(this, function ($, angular, common, appConfig, appCtrl, serviceProvider, angularBridge, errorHandler, storage) { + 'use strict'; - //Create Angular App - var app = angular.module('ngBulletinBoardApp', ['ngResource', 'ngRoute', 'ngMaterial', 'ngMessages']); + $(document).ready(function () { - //Define Dependency Injection Annotations - nf.ng.AppConfig.$inject = ['$mdThemingProvider', '$compileProvider']; - nf.ng.AppCtrl.$inject = ['$scope', 'serviceProvider', 'bulletinBoardCtrl']; - nf.ng.BulletinBoardCtrl.$inject = ['serviceProvider']; - nf.ng.ServiceProvider.$inject = []; + //Create Angular App + var app = angular.module('ngBulletinBoardApp', ['ngResource', 'ngRoute', 'ngMaterial', 'ngMessages']); - //Configure Angular App - app.config(nf.ng.AppConfig); + //Define Dependency Injection Annotations + appConfig.$inject = ['$mdThemingProvider', '$compileProvider']; + appCtrl.$inject = ['$scope', 'serviceProvider', 'bulletinBoardCtrl']; + nfBulletinBoard.$inject = ['serviceProvider']; + serviceProvider.$inject = []; - //Define Angular App Controllers - app.controller('ngBulletinBoardAppCtrl', nf.ng.AppCtrl); + //Configure Angular App + app.config(appConfig); - //Define Angular App Services - app.service('serviceProvider', nf.ng.ServiceProvider); - app.service('bulletinBoardCtrl', nf.ng.BulletinBoardCtrl); + //Define Angular App Controllers + app.controller('ngBulletinBoardAppCtrl', appCtrl); - //Manually Boostrap Angular App - nf.ng.Bridge.injector = angular.bootstrap($('body'), ['ngBulletinBoardApp'], { strictDi: true }); + //Define Angular App Services + app.service('serviceProvider', serviceProvider); + app.service('bulletinBoardCtrl', nfBulletinBoard); - // initialize the bulletin board - nf.ng.Bridge.injector.get('bulletinBoardCtrl').init(); -}); + //Manually Boostrap Angular App + angularBridge.injector = angular.bootstrap($('body'), ['ngBulletinBoardApp'], {strictDi: true}); -nf.ng.BulletinBoardCtrl = function (serviceProvider) { - 'use strict'; + // initialize the bulletin board + angularBridge.injector.get('bulletinBoardCtrl').init(); + }); - /** - * Configuration object used to hold a number of configuration items. - */ - var config = { - pollInterval: 3, - maxBulletins: 1000, - urls: { - banners: '../nifi-api/flow/banners', - about: '../nifi-api/flow/about', - bulletinBoard: '../nifi-api/flow/bulletin-board' - } - }; + var nfBulletinBoard = function (serviceProvider) { - var lastBulletin = null; - var filterText = null; - var filterType = null; - - /** - * Initializes the bulletin board. - */ - var initializePage = function () { - // add hover effect and click handler for clearing the bulletins - $('#clear-bulletins-button').click(function () { - $('#bulletin-board-container').empty(); - }); - - // filter type - $('#bulletin-board-filter-type').combo({ - options: [{ - text: 'by message', - value: 'message' - }, { - text: 'by name', - value: 'sourceName' - }, { - text: 'by id', - value: 'sourceId' - }, { - text: 'by group id', - value: 'groupId' - }] - }); - - // get the about details - var getTitle = $.ajax({ - type: 'GET', - url: config.urls.about, - dataType: 'json' - }).done(function (response) { - var aboutDetails = response.about; - var bulletinBoardTitle = aboutDetails.title + ' Bulletin Board'; - - // set the document title and the about title - document.title = bulletinBoardTitle; - $('#bulletin-board-header-text').text(bulletinBoardTitle); - }).fail(nf.Common.handleAjaxError); - - // get the banners if we're not in the shell - var loadBanners = $.Deferred(function (deferred) { - if (top === window) { - $.ajax({ - type: 'GET', - url: config.urls.banners, - dataType: 'json' - }).done(function (response) { - // ensure the banners response is specified - if (nf.Common.isDefinedAndNotNull(response.banners)) { - if (nf.Common.isDefinedAndNotNull(response.banners.headerText) && response.banners.headerText !== '') { - // update the header text - var bannerHeader = $('#banner-header').text(response.banners.headerText).show(); - - // show the banner - var updateTop = function (elementId) { - var element = $('#' + elementId); - element.css('top', (parseInt(bannerHeader.css('height'), 10) + parseInt(element.css('top'), 10)) + 'px'); - }; - - // update the position of elements affected by top banners - updateTop('bulletin-board'); - } - - if (nf.Common.isDefinedAndNotNull(response.banners.footerText) && response.banners.footerText !== '') { - // update the footer text and show it - var bannerFooter = $('#banner-footer').text(response.banners.footerText).show(); - - var updateBottom = function (elementId) { - var element = $('#' + elementId); - element.css('bottom', parseInt(bannerFooter.css('height'), 10) + 'px'); - }; - - // update the position of elements affected by bottom banners - updateBottom('bulletin-board'); - } - } - - deferred.resolve(); - }).fail(function (xhr, status, error) { - nf.Common.handleAjaxError(xhr, status, error); - deferred.reject(); - }); - } else { - deferred.resolve(); + /** + * Configuration object used to hold a number of configuration items. + */ + var config = { + pollInterval: 3, + maxBulletins: 1000, + urls: { + banners: '../nifi-api/flow/banners', + about: '../nifi-api/flow/about', + bulletinBoard: '../nifi-api/flow/bulletin-board' } - }); - - return $.Deferred(function (deferred) { - $.when(getTitle, loadBanners).done(function () { - deferred.resolve(); - }).fail(function () { - deferred.reject(); - }); - }).promise(); - }; + }; - /** - * Starts polling for new bulletins. - */ - var start = function () { - var refreshButton = $('#refresh-button'); - var bulletinContainer = $('#bulletin-board-container'); + var lastBulletin = null; + var filterText = null; + var filterType = null; - appendAndScroll(bulletinContainer, '<div class="bulletin-action">Auto refresh started</div>'); + /** + * Initializes the bulletin board. + */ + var initializePage = function () { + // add hover effect and click handler for clearing the bulletins + $('#clear-bulletins-button').click(function () { + $('#bulletin-board-container').empty(); + }); - // clear any error messages - $('#bulletin-error-message').text('').hide(); - poll(); - }; + // filter type + $('#bulletin-board-filter-type').combo({ + options: [{ + text: 'by message', + value: 'message' + }, { + text: 'by name', + value: 'sourceName' + }, { + text: 'by id', + value: 'sourceId' + }, { + text: 'by group id', + value: 'groupId' + }] + }); - /** - * Stops polling for new bulletins. - */ - var stop = function () { - var refreshButton = $('#refresh-button'); - var bulletinContainer = $('#bulletin-board-container'); + // get the about details + var getTitle = $.ajax({ + type: 'GET', + url: config.urls.about, + dataType: 'json' + }).done(function (response) { + var aboutDetails = response.about; + var bulletinBoardTitle = aboutDetails.title + ' Bulletin Board'; + + // set the document title and the about title + document.title = bulletinBoardTitle; + $('#bulletin-board-header-text').text(bulletinBoardTitle); + }).fail(errorHandler.handleAjaxError); + + // get the banners if we're not in the shell + var loadBanners = $.Deferred(function (deferred) { + if (top === window) { + $.ajax({ + type: 'GET', + url: config.urls.banners, + dataType: 'json' + }).done(function (response) { + // ensure the banners response is specified + if (common.isDefinedAndNotNull(response.banners)) { + if (common.isDefinedAndNotNull(response.banners.headerText) && response.banners.headerText !== '') { + // update the header text + var bannerHeader = $('#banner-header').text(response.banners.headerText).show(); + + // show the banner + var updateTop = function (elementId) { + var element = $('#' + elementId); + element.css('top', (parseInt(bannerHeader.css('height'), 10) + parseInt(element.css('top'), 10)) + 'px'); + }; + + // update the position of elements affected by top banners + updateTop('bulletin-board'); + } - appendAndScroll(bulletinContainer, '<div class="bulletin-action">Auto refresh stopped</div>'); + if (common.isDefinedAndNotNull(response.banners.footerText) && response.banners.footerText !== '') { + // update the footer text and show it + var bannerFooter = $('#banner-footer').text(response.banners.footerText).show(); - // reset state - lastBulletin = null; - filterText = null; - filterType = null; - }; + var updateBottom = function (elementId) { + var element = $('#' + elementId); + element.css('bottom', parseInt(bannerFooter.css('height'), 10) + 'px'); + }; - /** - * Polls for new bulletins - */ - var poll = function () { - // if the page is no longer open, stop polling - var isOpen = $('#bulletin-board').is(':visible'); - if (!isOpen) { - bulletinBoardCtrl.polling = false; - } + // update the position of elements affected by bottom banners + updateBottom('bulletin-board'); + } + } - // if polling, reload the bulletins - if (bulletinBoardCtrl.polling) { - bulletinBoardCtrl.loadBulletins().done(function () { - if (bulletinBoardCtrl.polling) { - setTimeout(poll, config.pollInterval * 1000); + deferred.resolve(); + }).fail(function (xhr, status, error) { + errorHandler.handleAjaxError(xhr, status, error); + deferred.reject(); + }); + } else { + deferred.resolve(); } }); - } - }; - - /** - * Appends the specified string to the specified container and scrolls to the bottom. - * - * @argument {jQuery} bulletinContainer The container for the bulletins - * @argument {string} content The content to added to the bulletin container - */ - var appendAndScroll = function (bulletinContainer, content) { - bulletinContainer.append(content).animate({scrollTop: bulletinContainer[0].scrollHeight}, 'slow'); - }; - /** - * Goes to the specified source on the graph. - * - * @argument {string} groupId The id of the group - * @argument {string} sourceId The id of the source component - */ - var goToSource = function (groupId, sourceId) { - // only attempt this if we're within a frame - if (top !== window) { - // and our parent has canvas utils and shell defined - if (nf.Common.isDefinedAndNotNull(parent.nf) && nf.Common.isDefinedAndNotNull(parent.nf.CanvasUtils) && nf.Common.isDefinedAndNotNull(parent.nf.Shell)) { - parent.nf.CanvasUtils.showComponent(groupId, sourceId); - parent.$('#shell-close-button').click(); - } - } - }; + return $.Deferred(function (deferred) { + $.when(getTitle, loadBanners).done(function () { + deferred.resolve(); + }).fail(function () { + deferred.reject(); + }); + }).promise(); + }; - function BulletinBoardCtrl() { /** - * Toggle state + * Starts polling for new bulletins. */ - this.polling = true; - } - BulletinBoardCtrl.prototype = { - constructor: BulletinBoardCtrl, + var start = function () { + var refreshButton = $('#refresh-button'); + var bulletinContainer = $('#bulletin-board-container'); + + appendAndScroll(bulletinContainer, '<div class="bulletin-action">Auto refresh started</div>'); + + // clear any error messages + $('#bulletin-error-message').text('').hide(); + poll(); + }; /** - * Register the bulletin board controller. + * Stops polling for new bulletins. */ - register: function() { - if (serviceProvider.bulletinBoardCtrl === undefined) { - serviceProvider.register('bulletinBoardCtrl', bulletinBoardCtrl); - } - }, + var stop = function () { + var refreshButton = $('#refresh-button'); + var bulletinContainer = $('#bulletin-board-container'); + + appendAndScroll(bulletinContainer, '<div class="bulletin-action">Auto refresh stopped</div>'); + + // reset state + lastBulletin = null; + filterText = null; + filterType = null; + }; /** - * Initializes the bulletin board page. + * Polls for new bulletins */ - init: function () { - //alter styles if we're not in the shell - if (top === window) { - $('#bulletin-board').css({ - "position": "absolute", - "bottom": "40px", - "left": "40px", - "right": "40px", - "top": "40px" - }); - $('#bulletin-board-refresh-container').css({ - "position": "absolute", - "bottom": "40px", - "left": "40px", - "right": "40px" + var poll = function () { + // if the page is no longer open, stop polling + var isOpen = $('#bulletin-board').is(':visible'); + if (!isOpen) { + bulletinBoardCtrl.polling = false; + } + + // if polling, reload the bulletins + if (bulletinBoardCtrl.polling) { + bulletinBoardCtrl.loadBulletins().done(function () { + if (bulletinBoardCtrl.polling) { + setTimeout(poll, config.pollInterval * 1000); + } }); } - - nf.Storage.init(); + }; - initializePage().done(function () { - start(); - }); - }, + /** + * Appends the specified string to the specified container and scrolls to the bottom. + * + * @argument {jQuery} bulletinContainer The container for the bulletins + * @argument {string} content The content to added to the bulletin container + */ + var appendAndScroll = function (bulletinContainer, content) { + bulletinContainer.append(content).animate({scrollTop: bulletinContainer[0].scrollHeight}, 'slow'); + }; /** - * Loads the bulletins since the last refresh. + * Goes to the specified source on the graph. + * + * @argument {string} groupId The id of the group + * @argument {string} sourceId The id of the source component */ - loadBulletins: function () { - var data = {}; - - // include the timestamp if appropriate - if (nf.Common.isDefinedAndNotNull(lastBulletin)) { - data['after'] = lastBulletin; - } else { - data['limit'] = 10; + var goToSource = function (groupId, sourceId) { + // only attempt this if we're within a frame + if (top !== window) { + // and our parent has canvas utils and shell defined + if (common.isDefinedAndNotNull(parent.nf) && common.isDefinedAndNotNull(parent.nf.CanvasUtils) && common.isDefinedAndNotNull(parent.nf.Shell)) { + parent.nf.CanvasUtils.showComponent(groupId, sourceId); + parent.$('#shell-close-button').click(); + } } + }; - var bulletinContainer = $('#bulletin-board-container'); + function BulletinBoardCtrl() { + /** + * Toggle state + */ + this.polling = true; + } + + BulletinBoardCtrl.prototype = { + constructor: BulletinBoardCtrl, - // get the filter text - var filter = $('#bulletin-board-filter').val(); - if (filter !== '') { - // determine which field to filter on - var filterOption = $('#bulletin-board-filter-type').combo('getSelectedOption'); - data[filterOption.value] = filter; - - // append filtering message if necessary - if (filterText !== filter || filterType !== filterOption.text) { - var filterContent = $('<div class="bulletin-action"></div>').text('Filter ' + filterOption.text + ' matching \'' + filter + '\''); - appendAndScroll(bulletinContainer, filterContent.get(0)); - filterText = filter; - filterType = filterOption.text; + /** + * Register the bulletin board controller. + */ + register: function () { + if (serviceProvider.bulletinBoardCtrl === undefined) { + serviceProvider.register('bulletinBoardCtrl', bulletinBoardCtrl); + } + }, + + /** + * Initializes the bulletin board page. + */ + init: function () { + //alter styles if we're not in the shell + if (top === window) { + $('#bulletin-board').css({ + "position": "absolute", + "bottom": "40px", + "left": "40px", + "right": "40px", + "top": "40px" + }); + $('#bulletin-board-refresh-container').css({ + "position": "absolute", + "bottom": "40px", + "left": "40px", + "right": "40px" + }); } - } else if (filterText !== null) { - appendAndScroll(bulletinContainer, '<div class="bulletin-action">Filter removed</div>'); - filterText = null; - filterType = null; - } - return $.ajax({ - type: 'GET', - url: config.urls.bulletinBoard, - data: data, - dataType: 'json' - }).done(function (response) { - // ensure the bulletin board was specified - if (nf.Common.isDefinedAndNotNull(response.bulletinBoard)) { - var bulletinBoard = response.bulletinBoard; - - // update the stats last refreshed timestamp - $('#bulletin-board-last-refreshed').text(bulletinBoard.generated); - - // process the bulletins - var bulletinEntities = response.bulletinBoard.bulletins; - var content = []; - - // append each bulletin - $.each(bulletinEntities, function (i, bulletinEntity) { - if (bulletinEntity.canRead === true) { - var bulletin = bulletinEntity.bulletin; - - // format the severity - var severityStyle = 'bulletin-normal'; - if (bulletin.level === 'ERROR') { - severityStyle = 'bulletin-error'; - } else if (bulletin.level === 'WARN' || bulletin.level === 'WARNING') { - severityStyle = 'bulletin-warn'; - } + storage.init(); - // format the source id - var source; - if (nf.Common.isDefinedAndNotNull(bulletin.sourceId) && nf.Common.isDefinedAndNotNull(bulletin.groupId) && top !== window) { - source = $('<div class="bulletin-source bulletin-link"></div>').text(bulletin.sourceId).on('click', function () { - goToSource(bulletin.groupId, bulletin.sourceId); - }); - } else { - var sourceId = bulletin.sourceId; - if (nf.Common.isUndefined(sourceId) || nf.Common.isNull(sourceId)) { - sourceId = ''; + initializePage().done(function () { + start(); + }); + }, + + /** + * Loads the bulletins since the last refresh. + */ + loadBulletins: function () { + var data = {}; + + // include the timestamp if appropriate + if (common.isDefinedAndNotNull(lastBulletin)) { + data['after'] = lastBulletin; + } else { + data['limit'] = 10; + } + + var bulletinContainer = $('#bulletin-board-container'); + + // get the filter text + var filter = $('#bulletin-board-filter').val(); + if (filter !== '') { + // determine which field to filter on + var filterOption = $('#bulletin-board-filter-type').combo('getSelectedOption'); + data[filterOption.value] = filter; + + // append filtering message if necessary + if (filterText !== filter || filterType !== filterOption.text) { + var filterContent = $('<div class="bulletin-action"></div>').text('Filter ' + filterOption.text + ' matching \'' + filter + '\''); + appendAndScroll(bulletinContainer, filterContent.get(0)); + filterText = filter; + filterType = filterOption.text; + } + } else if (filterText !== null) { + appendAndScroll(bulletinContainer, '<div class="bulletin-action">Filter removed</div>'); + filterText = null; + filterType = null; + } + + return $.ajax({ + type: 'GET', + url: config.urls.bulletinBoard, + data: data, + dataType: 'json' + }).done(function (response) { + // ensure the bulletin board was specified + if (common.isDefinedAndNotNull(response.bulletinBoard)) { + var bulletinBoard = response.bulletinBoard; + + // update the stats last refreshed timestamp + $('#bulletin-board-last-refreshed').text(bulletinBoard.generated); + + // process the bulletins + var bulletinEntities = response.bulletinBoard.bulletins; + var content = []; + + // append each bulletin + $.each(bulletinEntities, function (i, bulletinEntity) { + if (bulletinEntity.canRead === true) { + var bulletin = bulletinEntity.bulletin; + + // format the severity + var severityStyle = 'bulletin-normal'; + if (bulletin.level === 'ERROR') { + severityStyle = 'bulletin-error'; + } else if (bulletin.level === 'WARN' || bulletin.level === 'WARNING') { + severityStyle = 'bulletin-warn'; + } + + // format the source id + var source; + if (common.isDefinedAndNotNull(bulletin.sourceId) && common.isDefinedAndNotNull(bulletin.groupId) && top !== window) { + source = $('<div class="bulletin-source bulletin-link"></div>').text(bulletin.sourceId).on('click', function () { + goToSource(bulletin.groupId, bulletin.sourceId); + }); + } else { + var sourceId = bulletin.sourceId; + if (common.isUndefined(sourceId) || common.isNull(sourceId)) { + sourceId = ''; + } + source = $('<div class="bulletin-source"></div>').text(sourceId); } - source = $('<div class="bulletin-source"></div>').text(sourceId); - } - // build the markup for this bulletin - var bulletinMarkup = $('<div class="bulletin"></div>'); + // build the markup for this bulletin + var bulletinMarkup = $('<div class="bulletin"></div>'); - // build the markup for this bulletins info - var bulletinInfoMarkup = $('<div class="bulletin-info"></div>').appendTo(bulletinMarkup); - $('<div class="bulletin-timestamp"></div>').text(bulletin.timestamp).appendTo(bulletinInfoMarkup); - $('<div class="bulletin-severity"></div>').addClass(severityStyle).text(bulletin.level).appendTo(bulletinInfoMarkup); - source.appendTo(bulletinInfoMarkup); - $('<div class="clear"></div>').appendTo(bulletinInfoMarkup); + // build the markup for this bulletins info + var bulletinInfoMarkup = $('<div class="bulletin-info"></div>').appendTo(bulletinMarkup); + $('<div class="bulletin-timestamp"></div>').text(bulletin.timestamp).appendTo(bulletinInfoMarkup); + $('<div class="bulletin-severity"></div>').addClass(severityStyle).text(bulletin.level).appendTo(bulletinInfoMarkup); + source.appendTo(bulletinInfoMarkup); + $('<div class="clear"></div>').appendTo(bulletinInfoMarkup); - // format the node address if applicable - if (nf.Common.isDefinedAndNotNull(bulletin.nodeAddress)) { - $('<div class="bulletin-node"></div>').text(bulletin.nodeAddress).appendTo(bulletinMarkup); - } + // format the node address if applicable + if (common.isDefinedAndNotNull(bulletin.nodeAddress)) { + $('<div class="bulletin-node"></div>').text(bulletin.nodeAddress).appendTo(bulletinMarkup); + } - // add the bulletin message (treat as text) - $('<pre class="bulletin-message"></pre>').text(bulletin.message).appendTo(bulletinMarkup); - $('<div class="clear"></div>').appendTo(bulletinMarkup); + // add the bulletin message (treat as text) + $('<pre class="bulletin-message"></pre>').text(bulletin.message).appendTo(bulletinMarkup); + $('<div class="clear"></div>').appendTo(bulletinMarkup); - // append the content - content.push(bulletinMarkup.get(0)); - } + // append the content + content.push(bulletinMarkup.get(0)); + } - // record the id of the last bulletin in this request - if (i + 1 === bulletinEntities.length) { - lastBulletin = bulletinEntity.id; - } - }); + // record the id of the last bulletin in this request + if (i + 1 === bulletinEntities.length) { + lastBulletin = bulletinEntity.id; + } + }); - // add the content to the scroll pane - appendAndScroll(bulletinContainer, content); + // add the content to the scroll pane + appendAndScroll(bulletinContainer, content); - // trim the container as necessary - var contents = bulletinContainer.contents(); - var length = contents.length; - if (length > config.maxBulletins) { - contents.slice(0, length - config.maxBulletins).remove(); - bulletinContainer.prepend('<div class="bulletin-action">…</div>'); + // trim the container as necessary + var contents = bulletinContainer.contents(); + var length = contents.length; + if (length > config.maxBulletins) { + contents.slice(0, length - config.maxBulletins).remove(); + bulletinContainer.prepend('<div class="bulletin-action">…</div>'); + } } - } - }).fail(function (xhr, status, error) { - // likely caused by a invalid regex - if (xhr.status === 404) { - $('#bulletin-error-message').text(xhr.responseText).show(); - - // stop future polling - togglePolling(); + }).fail(function (xhr, status, error) { + // likely caused by a invalid regex + if (xhr.status === 404) { + $('#bulletin-error-message').text(xhr.responseText).show(); + + // stop future polling + bulletinBoardCtrl.togglePolling(); + } else { + errorHandler.handleAjaxError(xhr, status, error); + } + }); + }, + + /** + * Toggles whether the page is actively polling for new bulletins. + */ + togglePolling: function () { + // conditionally start or stop + if (bulletinBoardCtrl.polling === true) { + start(); } else { - nf.Common.handleAjaxError(xhr, status, error); + stop(); } - }); - }, - - /** - * Toggles whether the page is actively polling for new bulletins. - */ - togglePolling: function () { - // conditionally start or stop - if (bulletinBoardCtrl.polling === true) { - start(); - } else { - stop(); } } - } - var bulletinBoardCtrl = new BulletinBoardCtrl(); - bulletinBoardCtrl.register(); - return bulletinBoardCtrl; -}; \ No newline at end of file + var bulletinBoardCtrl = new BulletinBoardCtrl(); + bulletinBoardCtrl.register(); + return bulletinBoardCtrl; + }; + + return nfBulletinBoard; +})); \ No newline at end of file http://git-wip-us.apache.org/repos/asf/nifi/blob/dc934cbb/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 0db667c..95b6ac0 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 @@ -71,7 +71,7 @@ nf.ng.Canvas.FlowStatusCtrl = function (serviceProvider) { */ init: function () { - var self = this; + var searchCtrl = this; // Create new jQuery UI widget $.widget('nf.searchAutocomplete', $.ui.autocomplete, { @@ -92,7 +92,7 @@ nf.ng.Canvas.FlowStatusCtrl = function (serviceProvider) { return items; }, _renderMenu: function (ul, items) { - var self = this; + var nfSearchAutocomplete = this; // the object that holds the search results is normalized into a single element array var searchResults = items[0]; @@ -101,7 +101,7 @@ nf.ng.Canvas.FlowStatusCtrl = function (serviceProvider) { 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) { - self._renderItem(ul, processorMatch); + nfSearchAutocomplete._renderItem(ul, processorMatch); }); } @@ -109,7 +109,7 @@ nf.ng.Canvas.FlowStatusCtrl = function (serviceProvider) { 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) { - self._renderItem(ul, processGroupMatch); + nfSearchAutocomplete._renderItem(ul, processGroupMatch); }); } @@ -117,7 +117,7 @@ nf.ng.Canvas.FlowStatusCtrl = function (serviceProvider) { 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) { - self._renderItem(ul, remoteProcessGroupMatch); + nfSearchAutocomplete._renderItem(ul, remoteProcessGroupMatch); }); } @@ -125,7 +125,7 @@ nf.ng.Canvas.FlowStatusCtrl = function (serviceProvider) { 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) { - self._renderItem(ul, connectionMatch); + nfSearchAutocomplete._renderItem(ul, connectionMatch); }); } @@ -133,7 +133,7 @@ nf.ng.Canvas.FlowStatusCtrl = function (serviceProvider) { 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) { - self._renderItem(ul, inputPortMatch); + nfSearchAutocomplete._renderItem(ul, inputPortMatch); }); } @@ -141,7 +141,7 @@ nf.ng.Canvas.FlowStatusCtrl = function (serviceProvider) { 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) { - self._renderItem(ul, outputPortMatch); + nfSearchAutocomplete._renderItem(ul, outputPortMatch); }); } @@ -149,7 +149,7 @@ nf.ng.Canvas.FlowStatusCtrl = function (serviceProvider) { 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) { - self._renderItem(ul, funnelMatch); + nfSearchAutocomplete._renderItem(ul, funnelMatch); }); } @@ -194,7 +194,7 @@ nf.ng.Canvas.FlowStatusCtrl = function (serviceProvider) { // show the selected component nf.CanvasUtils.showComponent(item.groupId, item.id); - self.getInputElement().val('').blur(); + searchCtrl.getInputElement().val('').blur(); // stop event propagation return false; @@ -208,7 +208,7 @@ nf.ng.Canvas.FlowStatusCtrl = function (serviceProvider) { close: function (event, ui) { // set the input text to '' and reset the cached term $(this).searchAutocomplete('reset'); - self.getInputElement().val(''); + searchCtrl.getInputElement().val(''); // remove the glass pane $('div.search-glass-pane').remove(); @@ -216,38 +216,38 @@ nf.ng.Canvas.FlowStatusCtrl = function (serviceProvider) { }); // hide the search input - self.toggleSearchField(); + searchCtrl.toggleSearchField(); }, /** * Toggle/Slide the search field open/closed. */ toggleSearchField: function () { - var self = this; + var searchCtrl = this; // hide the context menu if necessary nf.ContextMenu.hide(); - var isVisible = self.getInputElement().is(':visible'); + var isVisible = searchCtrl.getInputElement().is(':visible'); var display = 'none'; var class1 = 'search-container-opened'; var class2 = 'search-container-closed'; if (!isVisible) { - self.getButtonElement().css('background-color', '#FFFFFF'); + searchCtrl.getButtonElement().css('background-color', '#FFFFFF'); display = 'inline-block'; class1 = 'search-container-closed'; class2 = 'search-container-opened'; } else { - self.getInputElement().css('display', display); + searchCtrl.getInputElement().css('display', display); } this.getSearchContainerElement().switchClass(class1, class2, 500, function () { - self.getInputElement().css('display', display); + searchCtrl.getInputElement().css('display', display); if (!isVisible) { - self.getButtonElement().css('background-color', '#FFFFFF'); - self.getInputElement().focus(); + searchCtrl.getButtonElement().css('background-color', '#FFFFFF'); + searchCtrl.getInputElement().focus(); } else { - self.getButtonElement().css('background-color', '#E3E8EB'); + searchCtrl.getButtonElement().css('background-color', '#E3E8EB'); } }); } @@ -327,7 +327,7 @@ nf.ng.Canvas.FlowStatusCtrl = function (serviceProvider) { * Reloads the current status of the flow. */ reloadFlowStatus: function () { - var self = this; + var flowStatusCtrl = this; return $.ajax({ type: 'GET', @@ -336,9 +336,9 @@ nf.ng.Canvas.FlowStatusCtrl = function (serviceProvider) { }).done(function (response) { // report the updated status if (nf.Common.isDefinedAndNotNull(response.controllerStatus)) { - self.update(response.controllerStatus); + flowStatusCtrl.update(response.controllerStatus); } - }).fail(nf.Common.handleAjaxError); + }).fail(nf.ErrorHandler.handleAjaxError); }, /** @@ -348,11 +348,11 @@ nf.ng.Canvas.FlowStatusCtrl = function (serviceProvider) { */ updateClusterSummary: function (clusterSummary) { // see if this node has been (dis)connected - if (nf.Canvas.isConnectedToCluster() !== clusterSummary.connectedToCluster) { + if (nf.ClusterSummary.isConnectedToCluster() !== clusterSummary.connectedToCluster) { if (clusterSummary.connectedToCluster) { - nf.Canvas.showConnectedToClusterMessage(); + nf.Dialog.showConnectedToClusterMessage(); } else { - nf.Canvas.showDisconnectedFromClusterMessage(); + nf.Dialog.showDisconnectedFromClusterMessage(); } } http://git-wip-us.apache.org/repos/asf/nifi/blob/dc934cbb/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 9981a32..6d0a304 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 @@ -139,7 +139,7 @@ nf.ng.Canvas.GlobalMenuCtrl = function (serviceProvider) { * @returns {*|boolean} */ visible: function () { - return nf.Canvas.isConnectedToCluster(); + return nf.ClusterSummary.isConnectedToCluster(); }, /** @@ -304,7 +304,7 @@ nf.ng.Canvas.GlobalMenuCtrl = function (serviceProvider) { $('#nifi-content-viewer-url').text(aboutDetails.contentViewerUrl); nf.QueueListing.initFlowFileDetailsDialog(); } - }).fail(nf.Common.handleAjaxError); + }).fail(nf.ErrorHandler.handleAjaxError); this.modal.init(); }, @@ -327,7 +327,7 @@ nf.ng.Canvas.GlobalMenuCtrl = function (serviceProvider) { * Initialize the modal. */ init: function () { - var self = this; + var aboutModal = this; var resizeAbout = function(){ var dialog = $(this); @@ -350,7 +350,7 @@ nf.ng.Canvas.GlobalMenuCtrl = function (serviceProvider) { }, handler: { click: function () { - self.hide(); + aboutModal.hide(); } } }]
