Best JavaScript code snippet using wpt
nf-processor-configuration.js
Source:nf-processor-configuration.js
1/*2 * Licensed to the Apache Software Foundation (ASF) under one or more3 * contributor license agreements. See the NOTICE file distributed with4 * this work for additional information regarding copyright ownership.5 * The ASF licenses this file to You under the Apache License, Version 2.06 * (the "License"); you may not use this file except in compliance with7 * the License. You may obtain a copy of the License at8 *9 * http://www.apache.org/licenses/LICENSE-2.010 *11 * Unless required by applicable law or agreed to in writing, software12 * distributed under the License is distributed on an "AS IS" BASIS,13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.14 * See the License for the specific language governing permissions and15 * limitations under the License.16 */17/* global nf */18nf.ProcessorConfiguration = (function () {19 // possible values for a processor's run duration (in millis)20 var RUN_DURATION_VALUES = [0, 25, 50, 100, 250, 500, 1000, 2000];21 /**22 * Gets the available scheduling strategies based on the specified processor.23 * 24 * @param {type} processor25 * @returns {Array}26 */27 var getSchedulingStrategies = function (processor) {28 var strategies = [{29 text: 'Timer driven',30 value: 'TIMER_DRIVEN',31 description: 'Processor will be scheduled to run on an interval defined by the run schedule.'32 }];33 // conditionally support event driven based on processor34 if (processor.supportsEventDriven === true) {35 strategies.push({36 text: 'Event driven',37 value: 'EVENT_DRIVEN',38 description: 'Processor will be scheduled to run when triggered by an event (e.g. a FlowFile enters an incoming queue). This scheduling strategy is experimental.'39 });40 } else if (processor.config['schedulingStrategy'] === 'EVENT_DRIVEN') {41 // the processor was once configured for event driven but no longer supports it42 strategies.push({43 text: 'Event driven',44 value: 'EVENT_DRIVEN',45 description: 'Processor will be scheduled to run when triggered by an event (e.g. a FlowFile enters an incoming queue). This scheduling strategy is experimental.',46 disabled: true47 });48 }49 // conditionally support event driven50 if (nf.Canvas.isClustered()) {51 strategies.push({52 text: 'On primary node',53 value: 'PRIMARY_NODE_ONLY',54 description: 'Processor will be scheduled on the primary node on an interval defined by the run schedule.'55 });56 } else if (processor.config['schedulingStrategy'] === 'PRIMARY_NODE_ONLY') {57 strategies.push({58 text: 'On primary node',59 value: 'PRIMARY_NODE_ONLY',60 description: 'Processor will be scheduled on the primary node on an interval defined by the run schedule.',61 disabled: true62 });63 }64 // add an option for cron driven65 strategies.push({66 text: 'CRON driven',67 value: 'CRON_DRIVEN',68 description: 'Processor will be scheduled to run on at specific times based on the specified CRON string.'69 });70 return strategies;71 };72 /**73 * Handle any expected processor configuration errors.74 * 75 * @argument {object} xhr The XmlHttpRequest76 * @argument {string} status The status of the request77 * @argument {string} error The error78 */79 var handleProcessorConfigurationError = function (xhr, status, error) {80 if (xhr.status === 400) {81 var errors = xhr.responseText.split('\n');82 var content;83 if (errors.length === 1) {84 content = $('<span></span>').text(errors[0]);85 } else {86 content = nf.Common.formatUnorderedList(errors);87 }88 nf.Dialog.showOkDialog({89 dialogContent: content,90 overlayBackground: false,91 headerText: 'Configuration Error'92 });93 } else {94 nf.Common.handleAjaxError(xhr, status, error);95 }96 };97 /**98 * Creates an option for the specified relationship name.99 * 100 * @argument {object} relationship The relationship101 */102 var createRelationshipOption = function (relationship) {103 var relationshipLabel = $('<div class="relationship-name ellipsis"></div>').text(relationship.name);104 var relationshipValue = $('<span class="relationship-name-value hidden"></span>').text(relationship.name);105 // build the relationship checkbox element106 var relationshipCheckbox = $('<div class="processor-relationship nf-checkbox"></div>');107 if (relationship.autoTerminate === true) {108 relationshipCheckbox.addClass('checkbox-checked');109 } else {110 relationshipCheckbox.addClass('checkbox-unchecked');111 }112 // build the relationship container element113 var relationshipContainerElement = $('<div class="processor-relationship-container"></div>').append(relationshipCheckbox).append(relationshipLabel).append(relationshipValue).appendTo('#auto-terminate-relationship-names');114 if (!nf.Common.isBlank(relationship.description)) {115 var relationshipDescription = $('<div class="relationship-description"></div>').text(relationship.description);116 relationshipContainerElement.append(relationshipDescription);117 }118 return relationshipContainerElement;119 };120 /**121 * Determines whether the user has made any changes to the processor configuration122 * that needs to be saved.123 */124 var isSaveRequired = function () {125 var details = $('#processor-configuration').data('processorDetails');126 // determine if any processor settings have changed127 // consider auto terminated relationships128 var autoTerminatedChanged = false;129 var autoTerminated = marshalRelationships();130 $.each(details.relationships, function (i, relationship) {131 if (relationship.autoTerminate === true) {132 // relationship was auto terminated but is no longer selected133 if ($.inArray(relationship.name, autoTerminated) === -1) {134 autoTerminatedChanged = true;135 return false;136 }137 } else if (relationship.autoTerminate === false) {138 // relationship was not auto terminated but is now selected139 if ($.inArray(relationship.name, autoTerminated) >= 0) {140 autoTerminatedChanged = true;141 return false;142 }143 }144 });145 if (autoTerminatedChanged) {146 return true;147 }148 // consider the scheduling strategy149 var schedulingStrategy = $('#scheduling-strategy-combo').combo('getSelectedOption').value;150 if (schedulingStrategy !== (details.config['schedulingStrategy'] + '')) {151 return true;152 }153 // only consider the concurrent tasks if appropriate154 if (details.supportsParallelProcessing === true) {155 // get the appropriate concurrent tasks field156 var concurrentTasks;157 if (schedulingStrategy === 'EVENT_DRIVEN') {158 concurrentTasks = $('#event-driven-concurrently-schedulable-tasks');159 } else if (schedulingStrategy === 'CRON_DRIVEN') {160 concurrentTasks = $('#cron-driven-concurrently-schedulable-tasks');161 } else {162 concurrentTasks = $('#timer-driven-concurrently-schedulable-tasks');163 }164 // check the concurrent tasks165 if (concurrentTasks.val() !== (details.config['concurrentlySchedulableTaskCount'] + '')) {166 return true;167 }168 }169 // get the appropriate scheduling period field170 var schedulingPeriod;171 if (schedulingStrategy === 'CRON_DRIVEN') {172 schedulingPeriod = $('#cron-driven-scheduling-period');173 } else if (schedulingStrategy !== 'EVENT_DRIVEN') {174 schedulingPeriod = $('#timer-driven-scheduling-period');175 }176 // check the scheduling period177 if (nf.Common.isDefinedAndNotNull(schedulingPeriod) && schedulingPeriod.val() !== (details.config['schedulingPeriod'] + '')) {178 return true;179 }180 if ($('#processor-name').val() !== details['name']) {181 return true;182 }183 if ($('#processor-enabled').hasClass('checkbox-checked') && details['state'] === 'DISABLED') {184 return true;185 } else if ($('#processor-enabled').hasClass('checkbox-unchecked') && (details['state'] === 'RUNNING' || details['state'] === 'STOPPED')) {186 return true;187 }188 if ($('#penalty-duration').val() !== (details.config['penaltyDuration'] + '')) {189 return true;190 }191 if ($('#yield-duration').val() !== (details.config['yieldDuration'] + '')) {192 return true;193 }194 if ($('#bulletin-level-combo').combo('getSelectedOption').value !== (details.config['bulletinLevel'] + '')) {195 return true;196 }197 if ($('#processor-comments').val() !== details.config['comments']) {198 return true;199 }200 // defer to the property and relationship grids201 return $('#processor-properties').propertytable('isSaveRequired');202 };203 /**204 * Marshals the data that will be used to update the processor's configuration.205 */206 var marshalDetails = function () {207 // create the config dto208 var processorConfigDto = {};209 // get the scheduling strategy210 var schedulingStrategy = $('#scheduling-strategy-combo').combo('getSelectedOption').value;211 // get the appropriate concurrent tasks field212 var concurrentTasks;213 if (schedulingStrategy === 'EVENT_DRIVEN') {214 concurrentTasks = $('#event-driven-concurrently-schedulable-tasks');215 } else if (schedulingStrategy === 'CRON_DRIVEN') {216 concurrentTasks = $('#cron-driven-concurrently-schedulable-tasks');217 } else {218 concurrentTasks = $('#timer-driven-concurrently-schedulable-tasks');219 }220 // get the concurrent tasks if appropriate221 if (!concurrentTasks.is(':disabled')) {222 processorConfigDto['concurrentlySchedulableTaskCount'] = concurrentTasks.val();223 }224 // get the appropriate scheduling period field225 var schedulingPeriod;226 if (schedulingStrategy === 'CRON_DRIVEN') {227 schedulingPeriod = $('#cron-driven-scheduling-period');228 } else if (schedulingStrategy !== 'EVENT_DRIVEN') {229 schedulingPeriod = $('#timer-driven-scheduling-period');230 }231 // get the scheduling period if appropriate232 if (nf.Common.isDefinedAndNotNull(schedulingPeriod)) {233 processorConfigDto['schedulingPeriod'] = schedulingPeriod.val();234 }235 processorConfigDto['penaltyDuration'] = $('#penalty-duration').val();236 processorConfigDto['yieldDuration'] = $('#yield-duration').val();237 processorConfigDto['bulletinLevel'] = $('#bulletin-level-combo').combo('getSelectedOption').value;238 processorConfigDto['schedulingStrategy'] = schedulingStrategy;239 processorConfigDto['comments'] = $('#processor-comments').val();240 // run duration241 var runDurationIndex = $('#run-duration-slider').slider('value');242 processorConfigDto['runDurationMillis'] = RUN_DURATION_VALUES[runDurationIndex];243 // relationships244 processorConfigDto['autoTerminatedRelationships'] = marshalRelationships();245 // properties246 var properties = $('#processor-properties').propertytable('marshalProperties');247 // set the properties248 if ($.isEmptyObject(properties) === false) {249 processorConfigDto['properties'] = properties;250 }251 // create the processor dto252 var processorDto = {};253 processorDto['id'] = $('#processor-id').text();254 processorDto['name'] = $('#processor-name').val();255 processorDto['config'] = processorConfigDto;256 // mark the processor disabled if appropriate257 if ($('#processor-enabled').hasClass('checkbox-unchecked')) {258 processorDto['state'] = 'DISABLED';259 } else if ($('#processor-enabled').hasClass('checkbox-checked')) {260 processorDto['state'] = 'STOPPED';261 }262 // create the processor entity263 var processorEntity = {};264 processorEntity['revision'] = nf.Client.getRevision();265 processorEntity['processor'] = processorDto;266 // return the marshaled details267 return processorEntity;268 };269 /**270 * Marshals the relationships that will be auto terminated.271 **/272 var marshalRelationships = function () {273 // get all available relationships274 var availableRelationships = $('#auto-terminate-relationship-names');275 var selectedRelationships = [];276 // go through each relationship to determine which are selected277 $.each(availableRelationships.children(), function (i, relationshipElement) {278 var relationship = $(relationshipElement);279 // get each relationship and its corresponding checkbox280 var relationshipCheck = relationship.children('div.processor-relationship');281 // see if this relationship has been selected282 if (relationshipCheck.hasClass('checkbox-checked')) {283 selectedRelationships.push(relationship.children('span.relationship-name-value').text());284 }285 });286 return selectedRelationships;287 };288 /**289 * Validates the specified details.290 * 291 * @argument {object} details The details to validate292 */293 var validateDetails = function (details) {294 var errors = [];295 var processor = details['processor'];296 var config = processor['config'];297 // ensure numeric fields are specified correctly298 if (nf.Common.isDefinedAndNotNull(config['concurrentlySchedulableTaskCount']) && !$.isNumeric(config['concurrentlySchedulableTaskCount'])) {299 errors.push('Concurrent tasks must be an integer value');300 }301 if (nf.Common.isDefinedAndNotNull(config['schedulingPeriod']) && nf.Common.isBlank(config['schedulingPeriod'])) {302 errors.push('Run schedule must be specified');303 }304 if (nf.Common.isBlank(config['penaltyDuration'])) {305 errors.push('Penalty duration must be specified');306 }307 if (nf.Common.isBlank(config['yieldDuration'])) {308 errors.push('Yield duration must be specified');309 }310 if (errors.length > 0) {311 nf.Dialog.showOkDialog({312 dialogContent: nf.Common.formatUnorderedList(errors),313 overlayBackground: false,314 headerText: 'Configuration Error'315 });316 return false;317 } else {318 return true;319 }320 };321 322 /**323 * Reloads the outgoing connections for the specified processor.324 * 325 * @param {object} processor326 */327 var reloadProcessorConnections = function (processor) {328 var connections = nf.Connection.getComponentConnections(processor.id);329 $.each(connections, function (_, connection) {330 if (connection.source.id === processor.id) {331 nf.Connection.reload(connection);332 }333 });334 };335 336 /**337 * Goes to a service configuration from the property table.338 */339 var goToServiceFromProperty = function () {340 return $.Deferred(function (deferred) {341 // close all fields currently being edited342 $('#processor-properties').propertytable('saveRow');343 // determine if changes have been made344 if (isSaveRequired()) {345 // see if those changes should be saved346 nf.Dialog.showYesNoDialog({347 dialogContent: 'Save changes before going to this Controller Service?',348 overlayBackground: false,349 noHandler: function () {350 deferred.resolve();351 },352 yesHandler: function () {353 var processor = $('#processor-configuration').data('processorDetails');354 saveProcessor(processor).done(function () {355 deferred.resolve();356 }).fail(function () {357 deferred.reject();358 });359 }360 });361 } else {362 deferred.resolve();363 }364 }).promise();365 };366 367 /**368 * 369 * @param {type} processor370 * @returns {undefined}371 */372 var saveProcessor = function (processor) {373 // marshal the settings and properties and update the processor374 var updatedProcessor = marshalDetails();375 // ensure details are valid as far as we can tell376 if (validateDetails(updatedProcessor)) {377 // update the selected component378 return $.ajax({379 type: 'PUT',380 data: JSON.stringify(updatedProcessor),381 url: processor.uri,382 dataType: 'json',383 processData: false,384 contentType: 'application/json'385 }).done(function (response) {386 if (nf.Common.isDefinedAndNotNull(response.processor)) {387 // update the revision388 nf.Client.setRevision(response.revision);389 }390 }).fail(handleProcessorConfigurationError);391 } else {392 return $.Deferred(function (deferred) {393 deferred.reject();394 }).promise();395 }396 };397 return {398 /**399 * Initializes the processor properties tab.400 */401 init: function () {402 // initialize the properties tabs403 $('#processor-configuration-tabs').tabbs({404 tabStyle: 'tab',405 selectedTabStyle: 'selected-tab',406 tabs: [{407 name: 'Settings',408 tabContentId: 'processor-standard-settings-tab-content'409 }, {410 name: 'Scheduling',411 tabContentId: 'processor-scheduling-tab-content'412 }, {413 name: 'Properties',414 tabContentId: 'processor-properties-tab-content'415 }, {416 name: 'Comments',417 tabContentId: 'processor-comments-tab-content'418 }],419 select: function () {420 // remove all property detail dialogs421 nf.Common.removeAllPropertyDetailDialogs();422 423 // update the processor property table size in case this is the first time its rendered424 if ($(this).text() === 'Properties') {425 $('#processor-properties').propertytable('resetTableSize');426 }427 // close all fields currently being edited428 $('#processor-properties').propertytable('saveRow');429 // show the border around the processor relationships if necessary430 var processorRelationships = $('#auto-terminate-relationship-names');431 if (processorRelationships.is(':visible') && processorRelationships.get(0).scrollHeight > processorRelationships.innerHeight()) {432 processorRelationships.css('border-width', '1px');433 }434 }435 });436 // initialize the processor configuration dialog437 $('#processor-configuration').modal({438 headerText: 'Configure Processor',439 overlayBackground: true,440 handler: {441 close: function () {442 // empty the relationship list443 $('#auto-terminate-relationship-names').css('border-width', '0').empty();444 // cancel any active edits and clear the table445 $('#processor-properties').propertytable('cancelEdit').propertytable('clear');446 // removed the cached processor details447 $('#processor-configuration').removeData('processorDetails');448 }449 }450 }).draggable({451 containment: 'parent',452 handle: '.dialog-header'453 });454 // initialize the bulletin combo455 $('#bulletin-level-combo').combo({456 options: [{457 text: 'DEBUG',458 value: 'DEBUG'459 }, {460 text: 'INFO',461 value: 'INFO'462 }, {463 text: 'WARN',464 value: 'WARN'465 }, {466 text: 'ERROR',467 value: 'ERROR'468 }]469 });470 // initialize the run duration slider471 $('#run-duration-slider').slider({472 min: 0,473 max: RUN_DURATION_VALUES.length - 1474 });475 // initialize the property table476 $('#processor-properties').propertytable({477 readOnly: false,478 dialogContainer: '#new-processor-property-container',479 descriptorDeferred: function(propertyName) {480 var processor = $('#processor-configuration').data('processorDetails');481 return $.ajax({482 type: 'GET',483 url: processor.uri + '/descriptors',484 data: {485 propertyName: propertyName486 },487 dataType: 'json'488 }).fail(nf.Common.handleAjaxError);489 },490 goToServiceDeferred: goToServiceFromProperty491 });492 },493 494 /**495 * Shows the configuration dialog for the specified processor.496 * 497 * @argument {selection} selection The selection498 */499 showConfiguration: function (selection) {500 if (nf.CanvasUtils.isProcessor(selection)) {501 var selectionData = selection.datum();502 // get the processor details503 var processor = selectionData.component;504 // reload the processor in case an property descriptors have updated505 var reloadProcessor = nf.Processor.reload(processor);506 507 // get the processor history508 var loadHistory = $.ajax({509 type: 'GET',510 url: '../nifi-api/controller/history/processors/' + encodeURIComponent(processor.id),511 dataType: 'json'512 });513 514 // once everything is loaded, show the dialog515 $.when(reloadProcessor, loadHistory).done(function (processorResponse, historyResponse) {516 // get the updated processor517 processor = processorResponse[0].processor;518 519 // get the processor history520 var processorHistory = historyResponse[0].componentHistory;521 522 // record the processor details523 $('#processor-configuration').data('processorDetails', processor);524 // determine if the enabled checkbox is checked or not525 var processorEnableStyle = 'checkbox-checked';526 if (processor['state'] === 'DISABLED') {527 processorEnableStyle = 'checkbox-unchecked';528 }529 // populate the processor settings530 $('#processor-id').text(processor['id']);531 $('#processor-type').text(nf.Common.substringAfterLast(processor['type'], '.'));532 $('#processor-name').val(processor['name']);533 $('#processor-enabled').removeClass('checkbox-unchecked checkbox-checked').addClass(processorEnableStyle);534 $('#penalty-duration').val(processor.config['penaltyDuration']);535 $('#yield-duration').val(processor.config['yieldDuration']);536 $('#processor-comments').val(processor.config['comments']);537 // set the run duration538 var runDuration = RUN_DURATION_VALUES.indexOf(processor.config['runDurationMillis']);539 $('#run-duration-slider').slider('value', runDuration);540 // select the appropriate bulletin level541 $('#bulletin-level-combo').combo('setSelectedOption', {542 value: processor.config['bulletinLevel']543 });544 // initialize the scheduling strategy545 $('#scheduling-strategy-combo').combo({546 options: getSchedulingStrategies(processor),547 selectedOption: {548 value: processor.config['schedulingStrategy']549 },550 select: function (selectedOption) {551 // show the appropriate panel552 if (selectedOption.value === 'EVENT_DRIVEN') {553 $('#event-driven-warning').show();554 $('#timer-driven-options').hide();555 $('#event-driven-options').show();556 $('#cron-driven-options').hide();557 } else {558 $('#event-driven-warning').hide();559 if (selectedOption.value === 'CRON_DRIVEN') {560 $('#timer-driven-options').hide();561 $('#event-driven-options').hide();562 $('#cron-driven-options').show();563 } else {564 $('#timer-driven-options').show();565 $('#event-driven-options').hide();566 $('#cron-driven-options').hide();567 }568 }569 }570 });571 // initialize the concurrentTasks572 var defaultConcurrentTasks = processor.config['defaultConcurrentTasks'];573 $('#timer-driven-concurrently-schedulable-tasks').val(defaultConcurrentTasks['TIMER_DRIVEN']);574 $('#event-driven-concurrently-schedulable-tasks').val(defaultConcurrentTasks['EVENT_DRIVEN']);575 $('#cron-driven-concurrently-schedulable-tasks').val(defaultConcurrentTasks['CRON_DRIVEN']);576 // get the appropriate concurrent tasks field577 var concurrentTasks;578 if (processor.config['schedulingStrategy'] === 'EVENT_DRIVEN') {579 concurrentTasks = $('#event-driven-concurrently-schedulable-tasks').val(processor.config['concurrentlySchedulableTaskCount']);580 } else if (processor.config['schedulingStrategy'] === 'CRON_DRIVEN') {581 concurrentTasks = $('#cron-driven-concurrently-schedulable-tasks').val(processor.config['concurrentlySchedulableTaskCount']);582 } else {583 concurrentTasks = $('#timer-driven-concurrently-schedulable-tasks').val(processor.config['concurrentlySchedulableTaskCount']);584 }585 // conditionally allow the user to specify the concurrent tasks586 if (nf.Common.isDefinedAndNotNull(concurrentTasks)) {587 if (processor.supportsParallelProcessing === true) {588 concurrentTasks.prop('disabled', false);589 } else {590 concurrentTasks.prop('disabled', true);591 }592 }593 // initialize the schedulingStrategy594 var defaultSchedulingPeriod = processor.config['defaultSchedulingPeriod'];595 $('#cron-driven-scheduling-period').val(defaultSchedulingPeriod['CRON_DRIVEN']);596 $('#timer-driven-scheduling-period').val(defaultSchedulingPeriod['TIMER_DRIVEN']);597 // set the scheduling period as appropriate598 if (processor.config['schedulingStrategy'] === 'CRON_DRIVEN') {599 $('#cron-driven-scheduling-period').val(processor.config['schedulingPeriod']);600 } else if (processor.config['schedulingStrategy'] !== 'EVENT_DRIVEN') {601 $('#timer-driven-scheduling-period').val(processor.config['schedulingPeriod']);602 }603 // load the relationship list604 if (!nf.Common.isEmpty(processor.relationships)) {605 $.each(processor.relationships, function (i, relationship) {606 createRelationshipOption(relationship);607 });608 } else {609 $('#auto-terminate-relationship-names').append('<div class="unset">This processor has no relationships.</div>');610 }611 var buttons = [{612 buttonText: 'Apply',613 handler: {614 click: function () {615 // close all fields currently being edited616 $('#processor-properties').propertytable('saveRow');617 // save the processor618 saveProcessor(processor).done(function (response) {619 // set the new processor state based on the response620 nf.Processor.set(response.processor);621 // reload the processor's outgoing connections622 reloadProcessorConnections(processor);623 // close the details panel624 $('#processor-configuration').modal('hide');625 });626 }627 }628 }, {629 buttonText: 'Cancel',630 handler: {631 click: function () {632 $('#processor-configuration').modal('hide');633 }634 }635 }];636 // determine if we should show the advanced button637 if (nf.Common.isDefinedAndNotNull(processor.config.customUiUrl) && processor.config.customUiUrl !== '') {638 buttons.push({639 buttonText: 'Advanced',640 handler: {641 click: function () {642 var openCustomUi = function () {643 // reset state and close the dialog manually to avoid hiding the faded background644 $('#processor-configuration').modal('hide');645 // show the custom ui646 nf.CustomUi.showCustomUi($('#processor-id').text(), processor.config.customUiUrl, true).done(function () {647 // once the custom ui is closed, reload the processor648 nf.Processor.reload(processor);649 // and reload the processor's outgoing connections650 reloadProcessorConnections(processor);651 });652 };653 // close all fields currently being edited654 $('#processor-properties').propertytable('saveRow');655 // determine if changes have been made656 if (isSaveRequired()) {657 // see if those changes should be saved658 nf.Dialog.showYesNoDialog({659 dialogContent: 'Save changes before opening the advanced configuration?',660 overlayBackground: false,661 noHandler: openCustomUi,662 yesHandler: function () {663 saveProcessor(processor).done(function (deferred) {664 // open the custom ui665 openCustomUi();666 });667 }668 });669 } else {670 // if there were no changes, simply open the custom ui671 openCustomUi();672 }673 }674 }675 });676 }677 // set the button model678 $('#processor-configuration').modal('setButtonModel', buttons);679 680 // load the property table681 $('#processor-properties').propertytable('loadProperties', processor.config.properties, processor.config.descriptors, processorHistory.propertyHistory);682 // show the details683 $('#processor-configuration').modal('show');684 // add ellipsis if necessary685 $('#processor-configuration div.relationship-name').ellipsis();686 // show the border if necessary687 var processorRelationships = $('#auto-terminate-relationship-names');688 if (processorRelationships.is(':visible') && processorRelationships.get(0).scrollHeight > processorRelationships.innerHeight()) {689 processorRelationships.css('border-width', '1px');690 }691 }).fail(nf.Common.handleAjaxError);692 }693 }694 };...
nf-processor.js
Source:nf-processor.js
...659 }660 },661 662 /**663 * Sets the specified processor(s). If the is an array, it 664 * will set each processor. If it is not an array, it will 665 * attempt to set the specified processor.666 * 667 * @param {object | array} processors668 */669 set: function (processors) {670 var set = function (processor) {671 if (processorMap.has(processor.id)) {672 // update the current entry673 var processorEntry = processorMap.get(processor.id);674 processorEntry.component = processor;675 // update the processor in the UI676 d3.select('#id-' + processor.id).call(updateProcessors);677 }...
ingest.js
Source:ingest.js
1'use strict';2Object.defineProperty(exports, "__esModule", {3 value: true4});5exports.default = function (api) {6 // Note: this isn't an actual API endpoint. It exists so the forEach processor's "processor" field7 // may recursively use the autocomplete rules for any processor.8 api.addEndpointDescription('_processor', {9 data_autocomplete_rules: processorDefinition10 });11 api.addEndpointDescription('_put_ingest_pipeline', {12 methods: ['PUT'],13 patterns: ['_ingest/pipeline/{name}'],14 data_autocomplete_rules: pipelineDefinition15 });16 api.addEndpointDescription('_get_ingest_pipeline', {17 methods: ['GET'],18 patterns: ['_ingest/pipeline/{id}']19 });20 api.addEndpointDescription('_delete_ingest_pipeline', {21 methods: ['DELETE'],22 patterns: ['_ingest/pipeline/{id}']23 });24 api.addEndpointDescription('_simulate_new_ingest_pipeline', {25 methods: ['POST'],26 patterns: ['_ingest/pipeline/_simulate'],27 url_params: simulateUrlParamsDefinition,28 data_autocomplete_rules: {29 pipeline: pipelineDefinition,30 docs: []31 }32 });33 api.addEndpointDescription('_simulate_existing_ingest_pipeline', {34 methods: ['POST'],35 patterns: ['_ingest/pipeline/{name}/_simulate'],36 url_params: simulateUrlParamsDefinition,37 data_autocomplete_rules: {38 docs: []39 }40 });41};42// Based on https://www.elastic.co/guide/en/elasticsearch/reference/master/append-processor.html43const appendProcessorDefinition = {44 append: {45 __template: {46 field: '',47 value: []48 },49 field: '',50 value: []51 }52};53// Based on https://www.elastic.co/guide/en/elasticsearch/reference/master/convert-processor.html54const convertProcessorDefinition = {55 convert: {56 __template: {57 field: '',58 type: ''59 },60 field: '',61 type: {62 __one_of: ['integer', 'float', 'string', 'boolean', 'auto']63 },64 target_field: '',65 ignore_missing: {66 __one_of: [false, true]67 }68 }69};70// Based on https://www.elastic.co/guide/en/elasticsearch/reference/master/date-processor.html71const dateProcessorDefinition = {72 date: {73 __template: {74 field: '',75 formats: []76 },77 field: '',78 target_field: '@timestamp',79 formats: [],80 timezone: 'UTC',81 locale: 'ENGLISH'82 }83};84// Based on https://www.elastic.co/guide/en/elasticsearch/reference/master/date-index-name-processor.html85const dateIndexNameProcessorDefinition = {86 date_index_name: {87 __template: {88 field: '',89 date_rounding: ''90 },91 field: '',92 date_rounding: {93 __one_of: ['y', 'M', 'w', 'd', 'h', 'm', 's']94 },95 date_formats: [],96 timezone: 'UTC',97 locale: 'ENGLISH',98 index_name_format: 'yyyy-MM-dd'99 }100};101// Based on https://www.elastic.co/guide/en/elasticsearch/reference/master/fail-processor.html102const failProcessorDefinition = {103 fail: {104 __template: {105 message: ''106 },107 message: ''108 }109};110// Based on https://www.elastic.co/guide/en/elasticsearch/reference/master/foreach-processor.html111const foreachProcessorDefinition = {112 foreach: {113 __template: {114 field: '',115 processor: {}116 },117 field: '',118 processor: {119 __scope_link: '_processor'120 }121 }122};123// Based on https://www.elastic.co/guide/en/elasticsearch/reference/master/grok-processor.html124const grokProcessorDefinition = {125 grok: {126 __template: {127 field: '',128 patterns: []129 },130 field: '',131 patterns: [],132 pattern_definitions: {},133 trace_match: {134 __one_of: [false, true]135 },136 ignore_missing: {137 __one_of: [false, true]138 }139 }140};141// Based on https://www.elastic.co/guide/en/elasticsearch/reference/master/gsub-processor.html142const gsubProcessorDefinition = {143 gsub: {144 __template: {145 field: '',146 pattern: '',147 replacement: ''148 },149 field: '',150 pattern: '',151 replacement: ''152 }153};154// Based on https://www.elastic.co/guide/en/elasticsearch/reference/master/join-processor.html155const joinProcessorDefinition = {156 join: {157 __template: {158 field: '',159 separator: ''160 },161 field: '',162 separator: ''163 }164};165// Based on https://www.elastic.co/guide/en/elasticsearch/reference/master/json-processor.html166const jsonProcessorDefinition = {167 json: {168 __template: {169 field: ''170 },171 field: '',172 target_field: '',173 add_to_root: {174 __one_of: [false, true]175 }176 }177};178// Based on https://www.elastic.co/guide/en/elasticsearch/reference/master/kv-processor.html179const kvProcessorDefinition = {180 kv: {181 __template: {182 field: '',183 field_split: '',184 value_split: ''185 },186 field: '',187 field_split: '',188 value_split: '',189 target_field: '',190 include_keys: [],191 ignore_missing: {192 __one_of: [false, true]193 }194 }195};196// Based on https://www.elastic.co/guide/en/elasticsearch/reference/master/lowercase-processor.html197const lowercaseProcessorDefinition = {198 lowercase: {199 __template: {200 field: ''201 },202 field: '',203 ignore_missing: {204 __one_of: [false, true]205 }206 }207};208// Based on https://www.elastic.co/guide/en/elasticsearch/reference/master/remove-processor.html209const removeProcessorDefinition = {210 remove: {211 __template: {212 field: ''213 },214 field: ''215 }216};217// Based on https://www.elastic.co/guide/en/elasticsearch/reference/master/rename-processor.html218const renameProcessorDefinition = {219 rename: {220 __template: {221 field: '',222 target_field: ''223 },224 field: '',225 target_field: '',226 ignore_missing: {227 __one_of: [false, true]228 }229 }230};231// Based on https://www.elastic.co/guide/en/elasticsearch/reference/master/script-processor.html232const scriptProcessorDefinition = {233 script: {234 __template: {},235 lang: 'painless',236 file: '',237 id: '',238 inline: '',239 params: {}240 }241};242// Based on https://www.elastic.co/guide/en/elasticsearch/reference/master/set-processor.html243const setProcessorDefinition = {244 set: {245 __template: {246 field: '',247 value: ''248 },249 field: '',250 value: '',251 override: {252 __one_of: [true, false]253 }254 }255};256// Based on https://www.elastic.co/guide/en/elasticsearch/reference/master/split-processor.html257const splitProcessorDefinition = {258 split: {259 __template: {260 field: '',261 separator: ''262 },263 field: '',264 separator: '',265 ignore_missing: {266 __one_of: [false, true]267 }268 }269};270// Based on https://www.elastic.co/guide/en/elasticsearch/reference/master/sort-processor.html271const sortProcessorDefinition = {272 sort: {273 __template: {274 field: ''275 },276 field: '',277 order: 'asc'278 }279};280// Based on https://www.elastic.co/guide/en/elasticsearch/reference/master/trim-processor.html281const trimProcessorDefinition = {282 trim: {283 __template: {284 field: ''285 },286 field: '',287 ignore_missing: {288 __one_of: [false, true]289 }290 }291};292// Based on https://www.elastic.co/guide/en/elasticsearch/reference/master/uppercase-processor.html293const uppercaseProcessorDefinition = {294 uppercase: {295 __template: {296 field: ''297 },298 field: '',299 ignore_missing: {300 __one_of: [false, true]301 }302 }303};304// Based on https://www.elastic.co/guide/en/elasticsearch/reference/master/dot-expand-processor.html305const dotExpanderProcessorDefinition = {306 dot_expander: {307 __template: {308 field: ''309 },310 field: '',311 path: ''312 }313};314const processorDefinition = {315 __one_of: [appendProcessorDefinition, convertProcessorDefinition, dateProcessorDefinition, dateIndexNameProcessorDefinition, failProcessorDefinition, foreachProcessorDefinition, grokProcessorDefinition, gsubProcessorDefinition, joinProcessorDefinition, jsonProcessorDefinition, kvProcessorDefinition, lowercaseProcessorDefinition, removeProcessorDefinition, renameProcessorDefinition, scriptProcessorDefinition, setProcessorDefinition, splitProcessorDefinition, sortProcessorDefinition, trimProcessorDefinition, uppercaseProcessorDefinition, dotExpanderProcessorDefinition]316};317const pipelineDefinition = {318 description: '',319 processors: [processorDefinition],320 version: 123321};322const simulateUrlParamsDefinition = {323 "verbose": "__flag__"324};...
Using AI Code Generation
1var wpt = require('wpt');2var processor = new wpt.Processor('your key here');3 if (err) {4 console.log(err);5 } else {6 console.log(data);7 }8});
Using AI Code Generation
1var wptools = require('wptools');2var options = {3};4var processor = wptools.page('Albert_Einstein', options).get();5processor.then(function(result) {6 console.log(result);7});8### wptools.page(pageName, options)9### Page.get()10MIT © [Arunoda Susiripala](
Using AI Code Generation
1var wpt = require('webpagetest');2var wpt = new WebPageTest('www.webpagetest.org');3var options = {4};5wpt.runTest(url, options, function(err, data) {6 if (err) return console.error(err);7 console.log('Test submitted successfully. Polling for results.');8 console.log('Test ID: %s', data.data.testId);9 wpt.getTestResults(data.data.testId, function(err, data) {10 if (err) return console.error(err);11 console.log('Test completed successfully!');12 console.log('Test details: %j', data);13 });14});
Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.
You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.
Get 100 minutes of automation test minutes FREE!!