Repository: incubator-nifi Updated Branches: refs/heads/NIFI-250 ea17dbec6 -> 2d7c700d1
http://git-wip-us.apache.org/repos/asf/incubator-nifi/blob/ec082f1e/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/js/nf/canvas/nf-processor-configuration.js ---------------------------------------------------------------------- diff --git a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/js/nf/canvas/nf-processor-configuration.js b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/js/nf/canvas/nf-processor-configuration.js index 14ffa95..106542f 100644 --- a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/js/nf/canvas/nf-processor-configuration.js +++ b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/js/nf/canvas/nf-processor-configuration.js @@ -220,7 +220,7 @@ nf.ProcessorConfiguration = (function () { } // defer to the property and relationship grids - return nf.ProcessorPropertyTable.isSaveRequired(); + return $('#processor-properties').propertytable('isSaveRequired'); }; /** @@ -275,7 +275,7 @@ nf.ProcessorConfiguration = (function () { processorConfigDto['autoTerminatedRelationships'] = marshalRelationships(); // properties - var properties = nf.ProcessorPropertyTable.marshalProperties(); + var properties = $('#processor-properties').propertytable('marshalProperties'); // set the properties if ($.isEmptyObject(properties) === false) { @@ -389,25 +389,25 @@ nf.ProcessorConfiguration = (function () { selectedTabStyle: 'selected-tab', tabs: [{ name: 'Settings', - tabContentId: 'configuration-standard-settings-tab-content' + tabContentId: 'processor-standard-settings-tab-content' }, { name: 'Scheduling', - tabContentId: 'configuration-scheduling-tab-content' + tabContentId: 'processor-scheduling-tab-content' }, { name: 'Properties', - tabContentId: 'configuration-processor-properties-tab-content' + tabContentId: 'processor-properties-tab-content' }, { name: 'Comments', - tabContentId: 'configuration-comments-tab-content' + tabContentId: 'processor-comments-tab-content' }], select: function () { // update the processor property table size in case this is the first time its rendered if ($(this).text() === 'Properties') { - nf.ProcessorPropertyTable.resetTableSize(); + $('#processor-properties').propertytable('resetTableSize'); } // close all fields currently being edited - nf.ProcessorPropertyTable.saveRow(); + $('#processor-properties').propertytable('saveRow'); // show the border around the processor relationships if necessary var processorRelationships = $('#auto-terminate-relationship-names'); @@ -430,10 +430,10 @@ nf.ProcessorConfiguration = (function () { $('#processor-property-dialog').hide(); // cancel any active edits - nf.ProcessorPropertyTable.cancelEdit(); + $('#processor-properties').propertytable('cancelEdit'); // clear the tables - nf.ProcessorPropertyTable.clear(); + $('#processor-properties').propertytable('clear'); // removed the cached processor details $('#processor-configuration').removeData('processorDetails'); @@ -469,7 +469,10 @@ nf.ProcessorConfiguration = (function () { }); // initialize the property table - nf.ProcessorPropertyTable.init(); + $('#processor-properties').propertytable({ + readOnly: false, + newPropertyDialogContainer: 'body' + }); }, /** @@ -578,9 +581,33 @@ nf.ProcessorConfiguration = (function () { $('#timer-driven-scheduling-period').val(processor.config['schedulingPeriod']); } - // load the property table - nf.ProcessorPropertyTable.loadProperties(processor.config.properties, processor.config.descriptors); + // get the processor history + $.ajax({ + type: 'GET', + url: '../nifi-api/controller/history/processors/' + encodeURIComponent(processor.id), + dataType: 'json' + }).done(function (response) { + var processorHistory = response.processorHistory; + + // record the processor history + $('#processor-configuration').data('processorHistory', processorHistory); + + // load the property table + $('#processor-properties').propertytable('loadProperties', processor.config.properties, processor.config.descriptors, processorHistory.propertyHistory); + // show the details + $('#processor-configuration').modal('show'); + + // add ellipsis if necessary + $('#processor-configuration div.relationship-name').ellipsis(); + + // show the border if necessary + var processorRelationships = $('#auto-terminate-relationship-names'); + if (processorRelationships.is(':visible') && processorRelationships.get(0).scrollHeight > processorRelationships.innerHeight()) { + processorRelationships.css('border-width', '1px'); + } + }).fail(nf.Common.handleAjaxError); + // load the relationship list if (!nf.Common.isEmpty(processor.relationships)) { $.each(processor.relationships, function (i, relationship) { @@ -595,7 +622,7 @@ nf.ProcessorConfiguration = (function () { handler: { click: function () { // close all fields currently being edited - nf.ProcessorPropertyTable.saveRow(); + $('#processor-properties').propertytable('saveRow'); // marshal the settings and properties and update the processor var updatedProcessor = marshalDetails(); @@ -658,7 +685,7 @@ nf.ProcessorConfiguration = (function () { }; // close all fields currently being edited - nf.ProcessorPropertyTable.saveRow(); + $('#processor-properties').propertytable('saveRow'); // determine if changes have been made if (isSaveRequired()) { @@ -704,30 +731,6 @@ nf.ProcessorConfiguration = (function () { // set the button model $('#processor-configuration').modal('setButtonModel', buttons); - - // get the processor history - $.ajax({ - type: 'GET', - url: '../nifi-api/controller/history/processors/' + encodeURIComponent(processor.id), - dataType: 'json' - }).done(function (response) { - var processorHistory = response.processorHistory; - - // record the processor history - $('#processor-configuration').data('processorHistory', processorHistory); - - // show the details - $('#processor-configuration').modal('show'); - - // add ellipsis if necessary - $('#processor-configuration div.relationship-name').ellipsis(); - - // show the border if necessary - var processorRelationships = $('#auto-terminate-relationship-names'); - if (processorRelationships.is(':visible') && processorRelationships.get(0).scrollHeight > processorRelationships.innerHeight()) { - processorRelationships.css('border-width', '1px'); - } - }).fail(nf.Common.handleAjaxError); } } }; http://git-wip-us.apache.org/repos/asf/incubator-nifi/blob/ec082f1e/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/js/nf/canvas/nf-processor-property-combo-editor.js ---------------------------------------------------------------------- diff --git a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/js/nf/canvas/nf-processor-property-combo-editor.js b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/js/nf/canvas/nf-processor-property-combo-editor.js index e777293..590550a 100644 --- a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/js/nf/canvas/nf-processor-property-combo-editor.js +++ b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/js/nf/canvas/nf-processor-property-combo-editor.js @@ -19,10 +19,16 @@ nf.ProcessorPropertyComboEditor = function (args) { var initialValue = null; var wrapper; var combo; - + var propertyDescriptor; + this.init = function () { var container = $('body'); + // get the property descriptor + var gridContainer = $(args.grid.getContainerNode()); + var descriptors = gridContainer.data('descriptors'); + propertyDescriptor = descriptors[args.item.property]; + // create the wrapper wrapper = $('<div></div>').css({ 'z-index': 1999, @@ -38,13 +44,8 @@ nf.ProcessorPropertyComboEditor = function (args) { containment: 'parent' }).appendTo(container); - // identify the property descriptor - property descriptor is never null/undefined here... in order - // to use this editor, the property descriptor would have had to indicate a set of allowable values - var processorDetails = $('#processor-configuration').data('processorDetails'); - var propertyDescriptor = processorDetails.config.descriptors[args.item.property]; - // check for allowable values which will drive which editor to use - var allowableValues = nf.ProcessorPropertyTable.getAllowableValues(propertyDescriptor); + var allowableValues = nf.Common.getAllowableValues(propertyDescriptor); // show the output port options var options = []; @@ -131,10 +132,6 @@ nf.ProcessorPropertyComboEditor = function (args) { }; this.loadValue = function (item) { - // identify the property descriptor - var processorDetails = $('#processor-configuration').data('processorDetails'); - var propertyDescriptor = processorDetails.config.descriptors[item.property]; - // select as appropriate if (!nf.Common.isUndefined(item.value)) { initialValue = item.value; http://git-wip-us.apache.org/repos/asf/incubator-nifi/blob/ec082f1e/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/js/nf/canvas/nf-processor-property-nfel-editor.js ---------------------------------------------------------------------- diff --git a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/js/nf/canvas/nf-processor-property-nfel-editor.js b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/js/nf/canvas/nf-processor-property-nfel-editor.js index dc369ac..91498c3 100644 --- a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/js/nf/canvas/nf-processor-property-nfel-editor.js +++ b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/js/nf/canvas/nf-processor-property-nfel-editor.js @@ -23,15 +23,17 @@ nf.ProcessorPropertyNfelEditor = function (args) { var wrapper; var editor; + this.init = function () { var container = $('body'); - - // get the property descriptor for this property - var details = $('#processor-configuration').data('processorDetails'); - propertyDescriptor = details.config.descriptors[args.item.property]; + + // get the property descriptor + var gridContainer = $(args.grid.getContainerNode()); + var descriptors = gridContainer.data('descriptors'); + propertyDescriptor = descriptors[args.item.property]; // determine if this is a sensitive property - var sensitive = nf.ProcessorPropertyTable.isSensitiveProperty(propertyDescriptor); + var sensitive = nf.Common.isSensitiveProperty(propertyDescriptor); // record the previous value previousValue = args.item[args.column.field]; @@ -129,12 +131,12 @@ nf.ProcessorPropertyNfelEditor = function (args) { this.loadValue = function (item) { // determine if this is a sensitive property var isEmptyChecked = false; - var sensitive = nf.ProcessorPropertyTable.isSensitiveProperty(propertyDescriptor); + var sensitive = nf.Common.isSensitiveProperty(propertyDescriptor); // determine the value to use when populating the text field if (nf.Common.isDefinedAndNotNull(item[args.column.field])) { if (sensitive) { - initialValue = nf.ProcessorPropertyTable.config.sensitiveText; + initialValue = nf.Common.config.sensitiveText; } else { initialValue = item[args.column.field]; isEmptyChecked = initialValue === ''; @@ -158,7 +160,7 @@ nf.ProcessorPropertyNfelEditor = function (args) { return ''; } else { // otherwise if the property is required - if (nf.ProcessorPropertyTable.isRequiredProperty(propertyDescriptor)) { + if (nf.Common.isRequiredProperty(propertyDescriptor)) { if (nf.Common.isBlank(propertyDescriptor.defaultValue)) { return previousValue; } else { http://git-wip-us.apache.org/repos/asf/incubator-nifi/blob/ec082f1e/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/js/nf/canvas/nf-processor-property-table.js ---------------------------------------------------------------------- diff --git a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/js/nf/canvas/nf-processor-property-table.js b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/js/nf/canvas/nf-processor-property-table.js deleted file mode 100644 index 4c04702..0000000 --- a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/js/nf/canvas/nf-processor-property-table.js +++ /dev/null @@ -1,567 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -nf.ProcessorPropertyTable = (function () { - - /** - * Initialize the new property dialog. - */ - var initNewPropertyDialog = function () { - var languageId = 'nfel'; - var editorClass = languageId + '-editor'; - - // add the over state for the new property button - nf.Common.addHoverEffect('#add-property-icon', 'add-icon-bg', 'add-icon-bg-hover'); - - var add = function () { - var propertyName = $.trim($('#new-property-name').val()); - var propertyValue = $('#new-property-value').nfeditor('getValue'); - - // ensure the property name and value is specified - if (propertyName !== '') { - // add a row for the new property - var propertyGrid = $('#processor-properties').data('gridInstance'); - var propertyData = propertyGrid.getData(); - propertyData.addItem({ - id: propertyData.getLength(), - hidden: false, - property: propertyName, - displayName: propertyName, - previousValue: null, - value: propertyValue, - type: 'userDefined' - }); - } else { - nf.Dialog.showOkDialog({ - dialogContent: 'Property name must be specified.', - overlayBackground: false - }); - } - - // close the dialog - $('#processor-property-dialog').hide(); - }; - - var cancel = function () { - $('#processor-property-dialog').hide(); - }; - - // create the editor - $('#new-property-value').addClass(editorClass).nfeditor({ - languageId: languageId, - width: 318, - minWidth: 318, - height: 106, - minHeight: 106, - resizable: true, - escape: cancel, - enter: add - }); - - // add a click listener to display the new property dialog - $('#add-property-icon').on('click', function () { - // close all fields currently being edited - nf.ProcessorPropertyTable.saveRow(); - - // clear the dialog - $('#new-property-name').val(''); - $('#new-property-value').nfeditor('setValue', ''); - - // reset the add property dialog position/size - $('#new-property-value').nfeditor('setSize', 318, 106); - - // open the new property dialog - $('#processor-property-dialog').center().show(); - - // give the property name focus - $('#new-property-value').nfeditor('refresh'); - $('#new-property-name').focus(); - }); - - // make the new property dialog draggable - $('#processor-property-dialog').draggable({ - cancel: 'input, textarea, pre, .button, .' + editorClass, - containment: 'parent' - }).on('click', '#new-property-ok', add).on('click', '#new-property-cancel', cancel); - - // enable tabs in the property value - $('#new-property-name').on('keydown', function (e) { - if (e.which === $.ui.keyCode.ENTER && !e.shiftKey) { - add(); - } else if (e.which === $.ui.keyCode.ESCAPE) { - e.preventDefault(); - cancel(); - } - }); - }; - - /** - * Initializes the processor property table. - */ - var initProcessorPropertiesTable = function () { - // function for formatting the property name - var nameFormatter = function (row, cell, value, columnDef, dataContext) { - var nameWidthOffset = 10; - var cellContent = $('<div></div>'); - - // format the contents - var formattedValue = $('<span/>').addClass('table-cell').text(value).appendTo(cellContent); - if (dataContext.type === 'required') { - formattedValue.addClass('required'); - } - - // get the processor details to insert the description tooltip - var details = $('#processor-configuration').data('processorDetails'); - var propertyDescriptor = details.config.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)) { - $('<img class="icon-info" src="images/iconInfo.png" alt="Info" title="" style="float: right; margin-right: 6px; margin-top: 4px;" />').appendTo(cellContent); - $('<span class="hidden property-descriptor-name"></span>').text(dataContext.property).appendTo(cellContent); - nameWidthOffset = 26; // 10 + icon width (10) + icon margin (6) - } - } - - // adjust the width accordingly - formattedValue.width(columnDef.width - nameWidthOffset).ellipsis(); - - // return the cell content - return cellContent.html(); - }; - - // function for formatting the property value - var valueFormatter = function (row, cell, value, columnDef, dataContext) { - var valueMarkup; - if (nf.Common.isDefinedAndNotNull(value)) { - // identify the property descriptor - var processorDetails = $('#processor-configuration').data('processorDetails'); - var propertyDescriptor = processorDetails.config.descriptors[dataContext.property]; - - // determine if the property is sensitive - if (nf.ProcessorPropertyTable.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.ProcessorPropertyTable.getAllowableValues(propertyDescriptor); - if ($.isArray(allowableValues)) { - $.each(allowableValues, function (_, allowableValue) { - if (value === allowableValue.value) { - value = allowableValue.displayName; - return false; - } - }); - } - - 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>'; - } - } - } else { - valueMarkup = '<span class="unset">No value set</span>'; - } - - // format the contents - var content = $(valueMarkup); - if (dataContext.type === 'required') { - content.addClass('required'); - } - content.find('.ellipsis').width(columnDef.width - 10).ellipsis(); - - // return the appropriate markup - return $('<div/>').append(content).html(); - }; - - // custom formatter for the actions column - var actionFormatter = function (row, cell, value, columnDef, dataContext) { - var markup = ''; - - // allow user defined properties to be removed - if (dataContext.type === 'userDefined') { - markup = '<img src="images/iconDelete.png" title="Delete" class="pointer" style="margin-top: 2px" onclick="javascript:nf.ProcessorPropertyTable.deleteProperty(\'' + row + '\');"/>'; - } - - return markup; - }; - - var processorConfigurationColumns = [ - {id: 'property', field: 'displayName', name: 'Property', sortable: false, resizable: true, rerenderOnResize: true, formatter: nameFormatter}, - {id: 'value', field: 'value', name: 'Value', sortable: false, resizable: true, cssClass: 'pointer', rerenderOnResize: true, formatter: valueFormatter}, - {id: "actions", name: " ", minWidth: 20, width: 20, formatter: actionFormatter} - ]; - var processorConfigurationOptions = { - forceFitColumns: true, - enableTextSelectionOnCells: true, - enableCellNavigation: true, - enableColumnReorder: false, - editable: true, - enableAddRow: false, - autoEdit: false - }; - - // initialize the dataview - var processorConfigurationData = new Slick.Data.DataView({ - inlineFilters: false - }); - processorConfigurationData.setItems([]); - processorConfigurationData.setFilterArgs({ - searchString: '', - property: 'hidden' - }); - processorConfigurationData.setFilter(filter); - processorConfigurationData.getItemMetadata = function (index) { - var item = processorConfigurationData.getItem(index); - - // identify the property descriptor - var processorDetails = $('#processor-configuration').data('processorDetails'); - var propertyDescriptor = processorDetails.config.descriptors[item.property]; - - // support el if specified or unsure yet (likely a dynamic property) - if (nf.Common.isUndefinedOrNull(propertyDescriptor) || nf.ProcessorPropertyTable.supportsEl(propertyDescriptor)) { - return { - columns: { - value: { - editor: nf.ProcessorPropertyNfelEditor - } - } - }; - } else { - // check for allowable values which will drive which editor to use - var allowableValues = nf.ProcessorPropertyTable.getAllowableValues(propertyDescriptor); - if ($.isArray(allowableValues)) { - return { - columns: { - value: { - editor: nf.ProcessorPropertyComboEditor - } - } - }; - } else { - return { - columns: { - value: { - editor: nf.ProcessorPropertyTextEditor - } - } - }; - } - } - }; - - // initialize the grid - var processorConfigurationGrid = new Slick.Grid('#processor-properties', processorConfigurationData, processorConfigurationColumns, processorConfigurationOptions); - processorConfigurationGrid.setSelectionModel(new Slick.RowSelectionModel()); - processorConfigurationGrid.onClick.subscribe(function (e, args) { - // edits the clicked cell - processorConfigurationGrid.gotoCell(args.row, args.cell, true); - - // prevents standard edit logic - e.stopImmediatePropagation(); - }); - - // wire up the dataview to the grid - processorConfigurationData.onRowCountChanged.subscribe(function (e, args) { - processorConfigurationGrid.updateRowCount(); - processorConfigurationGrid.render(); - }); - processorConfigurationData.onRowsChanged.subscribe(function (e, args) { - processorConfigurationGrid.invalidateRows(args.rows); - processorConfigurationGrid.render(); - }); - - // hold onto an instance of the grid and listen for mouse events to add tooltips where appropriate - $('#processor-properties').data('gridInstance', processorConfigurationGrid).on('mouseenter', 'div.slick-cell', function (e) { - var infoIcon = $(this).find('img.icon-info'); - if (infoIcon.length && !infoIcon.data('qtip')) { - var property = $(this).find('span.property-descriptor-name').text(); - - // get the processor details to insert the description tooltip - var details = $('#processor-configuration').data('processorDetails'); - var propertyDescriptor = details.config.descriptors[property]; - - // get the processor history - var processorHistory = $('#processor-configuration').data('processorHistory'); - var propertyHistory = processorHistory.propertyHistory[property]; - - // format the tooltip - var tooltip = nf.Common.formatPropertyTooltip(propertyDescriptor, propertyHistory); - - if (nf.Common.isDefinedAndNotNull(tooltip)) { - infoIcon.qtip($.extend({ - content: tooltip - }, nf.Common.config.tooltipConfig)); - } - } - }); - }; - - /** - * Performs the filtering. - * - * @param {object} item The item subject to filtering - * @param {object} args Filter arguments - * @returns {Boolean} Whether or not to include the item - */ - var filter = function (item, args) { - return item.hidden === false; - }; - - return { - config: { - sensitiveText: 'Sensitive value set' - }, - - /** - * Initializes the property table. - */ - init: function () { - initNewPropertyDialog(); - initProcessorPropertiesTable(); - }, - - /** - * Determines if the specified property is sensitive. - * - * @argument {object} propertyDescriptor The property descriptor - */ - isSensitiveProperty: function (propertyDescriptor) { - if (nf.Common.isDefinedAndNotNull(propertyDescriptor)) { - return propertyDescriptor.sensitive === true; - } else { - return false; - } - }, - - /** - * Determines if the specified property is required. - * - * @param {object} propertyDescriptor The property descriptor - */ - isRequiredProperty: function (propertyDescriptor) { - if (nf.Common.isDefinedAndNotNull(propertyDescriptor)) { - return propertyDescriptor.required === true; - } else { - return false; - } - }, - - /** - * Determines if the specified property is required. - * - * @param {object} propertyDescriptor The property descriptor - */ - isDynamicProperty: function (propertyDescriptor) { - if (nf.Common.isDefinedAndNotNull(propertyDescriptor)) { - return propertyDescriptor.dynamic === true; - } else { - return false; - } - }, - - /** - * Gets the allowable values for the specified property. - * - * @argument {object} propertyDescriptor The property descriptor - */ - getAllowableValues: function (propertyDescriptor) { - if (nf.Common.isDefinedAndNotNull(propertyDescriptor)) { - return propertyDescriptor.allowableValues; - } else { - return null; - } - }, - - /** - * Returns whether the specified property supports EL. - * - * @param {object} propertyDescriptor The property descriptor - */ - supportsEl: function (propertyDescriptor) { - if (nf.Common.isDefinedAndNotNull(propertyDescriptor)) { - return propertyDescriptor.supportsEl === true; - } else { - return false; - } - }, - - /** - * Saves the last edited row in the specified grid. - */ - saveRow: function () { - // get the property grid to commit the current edit - var propertyGrid = $('#processor-properties').data('gridInstance'); - if (nf.Common.isDefinedAndNotNull(propertyGrid)) { - var editController = propertyGrid.getEditController(); - editController.commitCurrentEdit(); - } - }, - - /** - * Cancels the edit in the specified row. - */ - cancelEdit: function () { - // get the property grid to reset the current edit - var propertyGrid = $('#processor-properties').data('gridInstance'); - if (nf.Common.isDefinedAndNotNull(propertyGrid)) { - var editController = propertyGrid.getEditController(); - editController.cancelCurrentEdit(); - } - }, - - /** - * Deletes the property in the specified row. - * - * @argument {string} row The row - */ - deleteProperty: function (row) { - var propertyGrid = $('#processor-properties').data('gridInstance'); - if (nf.Common.isDefinedAndNotNull(propertyGrid)) { - var propertyData = propertyGrid.getData(); - - // update the property in question - var property = propertyData.getItem(row); - property.hidden = true; - - // refresh the table - propertyData.updateItem(property.id, property); - } - }, - - /** - * Update the size of the grid based on its container's current size. - */ - resetTableSize: function () { - var propertyGrid = $('#processor-properties').data('gridInstance'); - if (nf.Common.isDefinedAndNotNull(propertyGrid)) { - propertyGrid.resizeCanvas(); - } - }, - - /** - * Loads the specified properties. - * - * @argument {object} properties The properties - * @argument {map} descriptors The property descriptors (property name -> property descriptor) - */ - loadProperties: function (properties, descriptors) { - // get the property grid - var propertyGrid = $('#processor-properties').data('gridInstance'); - var propertyData = propertyGrid.getData(); - - // generate the processor properties - if (nf.Common.isDefinedAndNotNull(properties)) { - propertyData.beginUpdate(); - - var i = 0; - $.each(properties, function (name, value) { - // get the property descriptor - var descriptor = descriptors[name]; - - // determine the property type - var type = 'userDefined'; - var displayName = name; - if (nf.Common.isDefinedAndNotNull(descriptor)) { - if (nf.ProcessorPropertyTable.isRequiredProperty(descriptor)) { - type = 'required'; - } else if (nf.ProcessorPropertyTable.isDynamicProperty(descriptor)) { - type = 'userDefined'; - } else { - type = 'optional'; - } - - // use the display name if possible - displayName = descriptor.displayName; - - // determine the value - if (nf.Common.isNull(value) && nf.Common.isDefinedAndNotNull(descriptor.defaultValue)) { - value = descriptor.defaultValue; - } - } - - // add the row - propertyData.addItem({ - id: i++, - hidden: false, - property: name, - displayName: displayName, - previousValue: value, - value: value, - type: type - }); - }); - - propertyData.endUpdate(); - } - }, - - /** - * Determines if a save is required. - */ - isSaveRequired: function () { - // get the property grid - var propertyGrid = $('#processor-properties').data('gridInstance'); - var propertyData = propertyGrid.getData(); - - // determine if any of the processor properties have changed - var isSaveRequired = false; - $.each(propertyData.getItems(), function () { - if (this.value !== this.previousValue) { - isSaveRequired = true; - return false; - } - }); - return isSaveRequired; - }, - - /** - * Marshal's the properties to send to the server. - */ - marshalProperties: function () { - // properties - var properties = {}; - - // get the property grid data - var propertyGrid = $('#processor-properties').data('gridInstance'); - var propertyData = propertyGrid.getData(); - $.each(propertyData.getItems(), function () { - if (this.hidden === true) { - properties[this.property] = null; - } else if (this.value !== this.previousValue) { - properties[this.property] = this.value; - } - }); - - return properties; - }, - - /** - * Clears the property table. - */ - clear: function () { - var propertyGridElement = $('#processor-properties'); - - // clean up any tooltips that may have been generated - nf.Common.cleanUpTooltips(propertyGridElement, 'img.icon-info'); - - // clear the data in the grid - var propertyGrid = propertyGridElement.data('gridInstance'); - var propertyData = propertyGrid.getData(); - propertyData.setItems([]); - } - }; -}()); \ No newline at end of file http://git-wip-us.apache.org/repos/asf/incubator-nifi/blob/ec082f1e/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/js/nf/canvas/nf-processor-property-text-editor.js ---------------------------------------------------------------------- diff --git a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/js/nf/canvas/nf-processor-property-text-editor.js b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/js/nf/canvas/nf-processor-property-text-editor.js index 8b65b3f..6f84a7a 100644 --- a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/js/nf/canvas/nf-processor-property-text-editor.js +++ b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/js/nf/canvas/nf-processor-property-text-editor.js @@ -22,13 +22,15 @@ nf.ProcessorPropertyTextEditor = function (args) { var wrapper; var isEmpty; var input; + this.init = function () { var container = $('body'); - // get the property descriptor for this property - var details = $('#processor-configuration').data('processorDetails'); - propertyDescriptor = details.config.descriptors[args.item.property]; + // get the property descriptor + var gridContainer = $(args.grid.getContainerNode()); + var descriptors = gridContainer.data('descriptors'); + propertyDescriptor = descriptors[args.item.property]; // record the previous value previousValue = args.item[args.column.field]; @@ -127,12 +129,12 @@ nf.ProcessorPropertyTextEditor = function (args) { this.loadValue = function (item) { // determine if this is a sensitive property var isEmptyChecked = false; - var sensitive = nf.ProcessorPropertyTable.isSensitiveProperty(propertyDescriptor); + var sensitive = nf.Common.isSensitiveProperty(propertyDescriptor); // determine the value to use when populating the text field if (nf.Common.isDefinedAndNotNull(item[args.column.field])) { if (sensitive) { - initialValue = nf.ProcessorPropertyTable.config.sensitiveText; + initialValue = nf.Common.config.sensitiveText; } else { initialValue = item[args.column.field]; isEmptyChecked = initialValue === ''; @@ -149,7 +151,7 @@ nf.ProcessorPropertyTextEditor = function (args) { var sensitiveInput = $(this); if (sensitiveInput.hasClass('sensitive')) { sensitiveInput.removeClass('sensitive'); - if (sensitiveInput.val() === nf.ProcessorPropertyTable.config.sensitiveText) { + if (sensitiveInput.val() === nf.Common.config.sensitiveText) { sensitiveInput.val(''); } } @@ -168,7 +170,7 @@ nf.ProcessorPropertyTextEditor = function (args) { return ''; } else { // otherwise if the property is required - if (nf.ProcessorPropertyTable.isRequiredProperty(propertyDescriptor)) { + if (nf.Common.isRequiredProperty(propertyDescriptor)) { if (nf.Common.isBlank(propertyDescriptor.defaultValue)) { return previousValue; } else { http://git-wip-us.apache.org/repos/asf/incubator-nifi/blob/ec082f1e/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/js/nf/canvas/nf-settings.js ---------------------------------------------------------------------- diff --git a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/js/nf/canvas/nf-settings.js b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/js/nf/canvas/nf-settings.js index c797429..9917270 100644 --- a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/js/nf/canvas/nf-settings.js +++ b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/js/nf/canvas/nf-settings.js @@ -178,7 +178,6 @@ nf.Settings = (function () { var clearSelectedControllerService = function () { $('#controller-service-type-description').text(''); $('#controller-service-type-name').text(''); - $('#controller-service-name-field').val(''); $('#selected-controller-service-name').text(''); $('#selected-controller-service-type').text(''); $('#controller-service-description-container').hide(); @@ -350,6 +349,39 @@ nf.Settings = (function () { return markup; }; + + /** + * Adds a new controller service of the specified type. + * + * @param {string} controllerServiceType + */ + var addControllerService = function (controllerServiceType) { + var revision = nf.Client.getRevision(); + + // add the new controller service + var addService = $.ajax({ + type: 'POST', + url: config.urls.controllerServices, + data: { + version: revision.version, + clientId: revision.clientId, + type: controllerServiceType + }, + dataType: 'json' + }).done(function (response) { + var controllerService = response.controllerService; + if (nf.Common.isDefinedAndNotNull(controllerService)) { + var controllerServicesGrid = $('#controller-services-table').data('gridInstance'); + var controllerServicesData = controllerServicesGrid.getData(); + controllerServicesData.addItem(controllerService); + } + }); + + // hide the dialog + $('#new-controller-service-dialog').modal('hide'); + + return addService; + }; /** * Initializes the new controller service dialog. @@ -454,7 +486,6 @@ nf.Settings = (function () { // populate the dom $('#controller-service-type-name').text(controllerServiceType.label).ellipsis(); - $('#controller-service-name-field').val(controllerServiceType.label); $('#selected-controller-service-name').text(controllerServiceType.label); $('#selected-controller-service-type').text(controllerServiceType.type); @@ -480,6 +511,10 @@ nf.Settings = (function () { e.stopImmediatePropagation(); } }); + controllerServiceTypesGrid.onDblClick.subscribe(function (e, args) { + var controllerServiceType = controllerServiceTypesGrid.getDataItem(args.row); + addControllerService(controllerServiceType.type); + }); // wire up the dataview to the grid controllerServiceTypesData.onRowCountChanged.subscribe(function (e, args) { @@ -567,15 +602,8 @@ nf.Settings = (function () { buttonText: 'Add', handler: { click: function () { - // add the new controller service - var selectedServiceName = $('#controller-service-name-field').val(); var selectedServiceType = $('#selected-controller-service-type').text(); - - $.ajax({ - - }).done(function () { - - }); + addControllerService(selectedServiceType); } } }, { @@ -615,12 +643,43 @@ nf.Settings = (function () { return '<img src="images/iconDetails.png" title="View Details" class="pointer" style="margin-top: 5px; float: left;" onclick="javascript:nf.Settings.showControllerServiceDetails(\'' + row + '\');"/>'; }; + var typeFormatter = function (row, cell, value, columnDef, dataContext) { + return nf.Common.substringAfterLast(value, '.'); + }; + + var enabledFormatter = function (row, cell, value, columnDef, dataContext) { + if (dataContext.enabled === true) { + return 'Enabled'; + } else { + return 'Disabled'; + } + }; + // define the column model for the controller services table var controllerServicesColumns = [ - {id: 'moreDetails', field: 'moreDetails', name: ' ', resizable: false, formatter: moreControllerServiceDetails, sortable: true, width: 50, maxWidth: 50}, + {id: 'moreDetails', name: ' ', resizable: false, formatter: moreControllerServiceDetails, sortable: false, width: 50, maxWidth: 50}, {id: 'name', field: 'name', name: 'Name', sortable: true, resizable: true}, - {id: 'type', field: 'type', name: 'Type', sortable: true, resizable: true} + {id: 'type', field: 'type', name: 'Type', formatter: typeFormatter, sortable: true, resizable: true}, + {id: 'enabled', field: 'enabled', name: 'State', formatter: enabledFormatter, sortable: true, resizeable: true} ]; + + // only DFM can edit controller services + if (nf.Common.isDFM()) { + var controllerServiceActionFormatter = function (row, cell, value, columnDef, dataContext) { + var markup = ''; + + if (dataContext.enabled === true) { + markup += '<img src="images/iconDisable.png" title="Disable" class="pointer" style="margin-top: 2px;" onclick="javascript:nf.Settings.disableControllerService(\'' + row + '\');"/> '; + } else { + markup += '<img src="images/iconEdit.png" title="Edit" class="pointer" style="margin-top: 2px;" onclick="javascript:nf.Settings.editControllerService(\'' + row + '\');"/> <img src="images/iconRun.png" title="Enable" class="pointer" style="margin-top: 2px;" onclick="javascript:nf.Settings.enableControllerService(\'' + row + '\');"/> <img src="images/iconDelete.png" title="Remove" class="pointer" style="margin-top: 2px;" onclick="javascript:nf.Settings.removeControllerService(\'' + row + '\');"/> '; + } + + return markup; + }; + + controllerServicesColumns.push({id: 'actions', name: ' ', resizable: false, formatter: controllerServiceActionFormatter, sortable: false, width: 75, maxWidth: 75}); + } + var controllerServicesOptions = { forceFitColumns: true, enableTextSelectionOnCells: true, @@ -635,11 +694,6 @@ nf.Settings = (function () { inlineFilters: false }); controllerServicesData.setItems([]); -// controllerServicesData.setFilterArgs({ -// searchString: getControllerServiceTypeFilterText(), -// property: $('#controller-service-type-filter-options').combo('getSelectedOption').value -// }); - controllerServicesData.setFilter(filterControllerServiceTypes); // initialize the grid var controllerServicesGrid = new Slick.Grid('#controller-services-table', controllerServicesData, controllerServicesColumns, controllerServicesOptions); @@ -651,9 +705,6 @@ nf.Settings = (function () { controllerServicesData.onRowCountChanged.subscribe(function (e, args) { controllerServicesGrid.updateRowCount(); controllerServicesGrid.render(); - - // update the total number of displayed processors -// $('#displayed-controller-service-types').text(getVisibleControllerServiceCount()); }); controllerServicesData.onRowsChanged.subscribe(function (e, args) { controllerServicesGrid.invalidateRows(args.rows); @@ -808,6 +859,47 @@ nf.Settings = (function () { }, /** + * Edits the controller service at the specified row. + * + * @param {type} row + */ + editControllerService: function (row) { + var grid = $('#controller-services-table').data('gridInstance'); + if (nf.Common.isDefinedAndNotNull(grid)) { + var data = grid.getData(); + var item = data.getItem(row); + nf.ControllerServiceConfiguration.showConfiguration(item); + } + }, + + /** + * Enables the controller service at the specified row. + * + * @param {type} row + */ + enableControllerService: function (row) { + + }, + + /** + * Disables the controller service at the specified row. + * + * @param {type} row + */ + disableControllerService: function (row) { + + }, + + /** + * Removes the controller service at the specified row. + * + * @param {type} row + */ + removeControllerService: function (row) { + + }, + + /** * Shows the details of the reporting task at the specified row. * * @param {documentedType} row http://git-wip-us.apache.org/repos/asf/incubator-nifi/blob/ec082f1e/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/js/nf/nf-common.js ---------------------------------------------------------------------- diff --git a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/js/nf/nf-common.js b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/js/nf/nf-common.js index 171b96f..53ea076 100644 --- a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/js/nf/nf-common.js +++ b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/js/nf/nf-common.js @@ -55,6 +55,7 @@ $(document).ready(function () { // Define a common utility class used across the entire application. nf.Common = { config: { + sensitiveText: 'Sensitive value set', tooltipConfig: { style: { classes: 'nifi-tooltip' @@ -406,6 +407,71 @@ nf.Common = { }()), /** + * Determines if the specified property is sensitive. + * + * @argument {object} propertyDescriptor The property descriptor + */ + isSensitiveProperty: function (propertyDescriptor) { + if (nf.Common.isDefinedAndNotNull(propertyDescriptor)) { + return propertyDescriptor.sensitive === true; + } else { + return false; + } + }, + + /** + * Determines if the specified property is required. + * + * @param {object} propertyDescriptor The property descriptor + */ + isRequiredProperty: function (propertyDescriptor) { + if (nf.Common.isDefinedAndNotNull(propertyDescriptor)) { + return propertyDescriptor.required === true; + } else { + return false; + } + }, + + /** + * Determines if the specified property is required. + * + * @param {object} propertyDescriptor The property descriptor + */ + isDynamicProperty: function (propertyDescriptor) { + if (nf.Common.isDefinedAndNotNull(propertyDescriptor)) { + return propertyDescriptor.dynamic === true; + } else { + return false; + } + }, + + /** + * Gets the allowable values for the specified property. + * + * @argument {object} propertyDescriptor The property descriptor + */ + getAllowableValues: function (propertyDescriptor) { + if (nf.Common.isDefinedAndNotNull(propertyDescriptor)) { + return propertyDescriptor.allowableValues; + } else { + return null; + } + }, + + /** + * Returns whether the specified property supports EL. + * + * @param {object} propertyDescriptor The property descriptor + */ + supportsEl: function (propertyDescriptor) { + if (nf.Common.isDefinedAndNotNull(propertyDescriptor)) { + return propertyDescriptor.supportsEl === true; + } else { + return false; + } + }, + + /** * Creates a form inline in order to submit the specified params to the specified URL * using the specified method. * http://git-wip-us.apache.org/repos/asf/incubator-nifi/blob/ec082f1e/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/js/nf/nf-processor-details.js ---------------------------------------------------------------------- diff --git a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/js/nf/nf-processor-details.js b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/js/nf/nf-processor-details.js index a3a2589..16dd95a 100644 --- a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/js/nf/nf-processor-details.js +++ b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/js/nf/nf-processor-details.js @@ -39,7 +39,7 @@ nf.ProcessorDetails = (function () { var propertyDescriptor = details.config.descriptors[property.property]; // ensure we're not dealing with a sensitive property - if (!isSensitiveProperty(propertyDescriptor)) { + if (!nf.Common.isSensitiveProperty(propertyDescriptor)) { // get details about the location of the cell var cellNode = $(propertyGrid.getCellNode(row, cell)); @@ -130,19 +130,6 @@ nf.ProcessorDetails = (function () { }; /** - * Determines if the specified property is sensitive. - * - * @argument {object} propertyDescriptor The property descriptor - */ - var isSensitiveProperty = function (propertyDescriptor) { - if (nf.Common.isDefinedAndNotNull(propertyDescriptor)) { - return propertyDescriptor.sensitive === true; - } else { - return false; - } - }; - - /** * Returns whether the specified property supports EL. * * @param {object} propertyDescriptor The property descriptor @@ -310,7 +297,7 @@ nf.ProcessorDetails = (function () { var propertyDescriptor = processorDetails.config.descriptors[dataContext.property]; // determine if the property is sensitive - if (isSensitiveProperty(propertyDescriptor)) { + if (nf.Common.isSensitiveProperty(propertyDescriptor)) { valueMarkup = '<span class="table-cell sensitive">Sensitive value set</span>'; } else { if (value === '') {
