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/nf-processor-details.js ---------------------------------------------------------------------- diff --git a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/js/nf/nf-processor-details.js b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/js/nf/nf-processor-details.js index e5dd2a6..829490f 100644 --- a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/js/nf/nf-processor-details.js +++ b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/js/nf/nf-processor-details.js @@ -15,9 +15,40 @@ * limitations under the License. */ -/* global nf */ - -nf.ProcessorDetails = (function () { +/* global nf, define, module, require, exports */ + +(function (root, factory) { + if (typeof define === 'function' && define.amd) { + define(['jquery', + 'nf.Common', + 'nf.UniversalCapture', + 'nf.Dialog', + 'nf.ErrorHandler', + 'nf.CustomUi', + 'nf.ClusterSummary'], + function ($, common, universalCapture, dialog, errorHandler, customUi, clusterSummary) { + return (nf.ProcessorDetails = factory($, common, universalCapture, dialog, errorHandler, customUi, clusterSummary)); + }); + } else if (typeof exports === 'object' && typeof module === 'object') { + module.exports = (nf.ProcessorDetails = + factory(require('jquery'), + require('nf.Common'), + require('nf.UniversalCapture'), + require('nf.Dialog'), + require('nf.ErrorHandler'), + require('nf.CustomUi'), + require('nf.ClusterSummary'))); + } else { + nf.ProcessorDetails = factory(root.$, + root.nf.Common, + root.nf.UniversalCapture, + root.nf.Dialog, + root.nf.ErrorHandler, + root.nf.CustomUi, + root.nf.ClusterSummary); + } +}(this, function ($, common, universalCapture, dialog, errorHandler, customUi, clusterSummary) { + 'use strict'; /** * Creates an option for the specified relationship name. @@ -34,7 +65,7 @@ nf.ProcessorDetails = (function () { // build the relationship container element var relationshipContainerElement = $('<div class="processor-relationship-container"></div>').append(relationshipLabel).appendTo('#read-only-auto-terminate-relationship-names'); - if (!nf.Common.isBlank(relationship.description)) { + if (!common.isBlank(relationship.description)) { var relationshipDescription = $('<div class="relationship-description"></div>').text(relationship.description); relationshipContainerElement.append(relationshipDescription); } @@ -46,7 +77,8 @@ nf.ProcessorDetails = (function () { /** * Initializes the processor details dialog. */ - init: function () { + init: function (supportsGoTo) { + // initialize the properties tabs $('#processor-details-tabs').tabbs({ tabStyle: 'tab', @@ -67,7 +99,7 @@ nf.ProcessorDetails = (function () { }], select: function () { // remove all property detail dialogs - nf.UniversalCapture.removeAllPropertyDetailDialogs(); + universalCapture.removeAllPropertyDetailDialogs(); // resize the property grid in case this is the first time its rendered if ($(this).text() === 'Properties') { @@ -95,31 +127,32 @@ nf.ProcessorDetails = (function () { $('#read-only-processor-properties').propertytable('clear'); // clear the processor details - nf.Common.clearField('read-only-processor-id'); - nf.Common.clearField('read-only-processor-type'); - nf.Common.clearField('read-only-processor-name'); - nf.Common.clearField('read-only-concurrently-schedulable-tasks'); - nf.Common.clearField('read-only-scheduling-period'); - nf.Common.clearField('read-only-penalty-duration'); - nf.Common.clearField('read-only-yield-duration'); - nf.Common.clearField('read-only-run-duration'); - nf.Common.clearField('read-only-bulletin-level'); - nf.Common.clearField('read-only-execution-node'); - nf.Common.clearField('read-only-execution-status'); - nf.Common.clearField('read-only-processor-comments'); + common.clearField('read-only-processor-id'); + common.clearField('read-only-processor-type'); + common.clearField('read-only-processor-name'); + common.clearField('read-only-concurrently-schedulable-tasks'); + common.clearField('read-only-scheduling-period'); + common.clearField('read-only-penalty-duration'); + common.clearField('read-only-yield-duration'); + common.clearField('read-only-run-duration'); + common.clearField('read-only-bulletin-level'); + common.clearField('read-only-execution-node'); + common.clearField('read-only-execution-status'); + common.clearField('read-only-processor-comments'); // removed the cached processor details $('#processor-details').removeData('processorDetails'); $('#processor-details').removeData('processorHistory'); }, open: function () { - nf.Common.toggleScrollable($('#' + this.find('.tab-container').attr('id') + '-content').get(0)); + common.toggleScrollable($('#' + this.find('.tab-container').attr('id') + '-content').get(0)); } } }); // initialize the properties $('#read-only-processor-properties').propertytable({ + supportsGoTo: supportsGoTo, readOnly: true }); }, @@ -137,7 +170,7 @@ nf.ProcessorDetails = (function () { url: '../nifi-api/processors/' + encodeURIComponent(processorId), dataType: 'json' }).done(function (response) { - if (nf.Common.isDefinedAndNotNull(response.component)) { + if (common.isDefinedAndNotNull(response.component)) { // get the processor details var details = response.component; @@ -145,16 +178,16 @@ nf.ProcessorDetails = (function () { $('#processor-details').data('processorDetails', details); // populate the processor settings - nf.Common.populateField('read-only-processor-id', details['id']); - nf.Common.populateField('read-only-processor-type', nf.Common.substringAfterLast(details['type'], '.')); - nf.Common.populateField('read-only-processor-name', details['name']); - nf.Common.populateField('read-only-concurrently-schedulable-tasks', details.config['concurrentlySchedulableTaskCount']); - nf.Common.populateField('read-only-scheduling-period', details.config['schedulingPeriod']); - nf.Common.populateField('read-only-penalty-duration', details.config['penaltyDuration']); - nf.Common.populateField('read-only-yield-duration', details.config['yieldDuration']); - nf.Common.populateField('read-only-run-duration', nf.Common.formatDuration(details.config['runDurationMillis'])); - nf.Common.populateField('read-only-bulletin-level', details.config['bulletinLevel']); - nf.Common.populateField('read-only-processor-comments', details.config['comments']); + common.populateField('read-only-processor-id', details['id']); + common.populateField('read-only-processor-type', common.substringAfterLast(details['type'], '.')); + common.populateField('read-only-processor-name', details['name']); + common.populateField('read-only-concurrently-schedulable-tasks', details.config['concurrentlySchedulableTaskCount']); + common.populateField('read-only-scheduling-period', details.config['schedulingPeriod']); + common.populateField('read-only-penalty-duration', details.config['penaltyDuration']); + common.populateField('read-only-yield-duration', details.config['yieldDuration']); + common.populateField('read-only-run-duration', common.formatDuration(details.config['runDurationMillis'])); + common.populateField('read-only-bulletin-level', details.config['bulletinLevel']); + common.populateField('read-only-processor-comments', details.config['comments']); var showRunSchedule = true; @@ -171,7 +204,7 @@ nf.ProcessorDetails = (function () { } else { schedulingStrategy = "On primary node"; } - nf.Common.populateField('read-only-scheduling-strategy', schedulingStrategy); + common.populateField('read-only-scheduling-strategy', schedulingStrategy); // only show the run schedule when applicable if (showRunSchedule === true) { @@ -183,13 +216,13 @@ nf.ProcessorDetails = (function () { var executionNode = details.config['executionNode']; // only show the execution-node when applicable - if (nf.Canvas.isClustered() || executionNode === 'PRIMARY') { + if (clusterSummary.isClustered() || executionNode === 'PRIMARY') { if (executionNode === 'ALL') { executionNode = "All nodes"; } else if (executionNode === 'PRIMARY') { executionNode = "Primary node only"; } - nf.Common.populateField('read-only-execution-node', executionNode); + common.populateField('read-only-execution-node', executionNode); $('#read-only-execution-node-options').show(); } else { @@ -197,7 +230,7 @@ nf.ProcessorDetails = (function () { } // load the relationship list - if (!nf.Common.isEmpty(details.relationships)) { + if (!common.isEmpty(details.relationships)) { $.each(details.relationships, function (i, relationship) { createRelationshipOption(relationship); }); @@ -245,7 +278,7 @@ nf.ProcessorDetails = (function () { }]; // determine if we should show the advanced button - if (nf.Common.isDefinedAndNotNull(nf.CustomUi) && nf.Common.isDefinedAndNotNull(processor.config.customUiUrl) && processor.config.customUiUrl !== '') { + if (top === window && common.isDefinedAndNotNull(customUi) && common.isDefinedAndNotNull(processor.config.customUiUrl) && processor.config.customUiUrl !== '') { buttons.push({ buttonText: 'Advanced', clazz: 'fa fa-cog button-icon', @@ -260,7 +293,7 @@ nf.ProcessorDetails = (function () { $('#processor-details').modal('hide'); // show the custom ui - nf.CustomUi.showCustomUi(processorResponse, processor.config.customUiUrl, false); + customUi.showCustomUi(processorResponse, processor.config.customUiUrl, false); } } }); @@ -279,14 +312,14 @@ nf.ProcessorDetails = (function () { } }).fail(function (xhr, status, error) { if (xhr.status === 400 || xhr.status === 404 || xhr.status === 409) { - nf.Dialog.showOkDialog({ + dialog.showOkDialog({ headerText: 'Error', - dialogContent: nf.Common.escapeHtml(xhr.responseText) + dialogContent: common.escapeHtml(xhr.responseText) }); } else { - nf.Common.handleAjaxError(xhr, status, error); + errorHandler.handleAjaxError(xhr, status, error); } }); } }; -}()); +}));
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/nf-shell.js ---------------------------------------------------------------------- diff --git a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/js/nf/nf-shell.js b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/js/nf/nf-shell.js index c51f03f..d3644ad 100644 --- a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/js/nf/nf-shell.js +++ b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/js/nf/nf-shell.js @@ -15,46 +15,64 @@ * limitations under the License. */ -/* global nf */ - -$(document).ready(function () { - // configure the dialog - $('#shell-dialog').modal({ - scrollableContentStyle: 'scrollable', - header: false, - footer: false, - responsive: { - x: false, - y: false - } - }); - - // register a listener when the frame is closed - $('#shell-close-button').click(function () { - // close the shell - $('#shell-dialog').modal('hide'); - }); - - // register a listener when the frame is undocked - $('#shell-undock-button').click(function () { - var uri = $('#shell-iframe').attr('src'); - if (!nf.Common.isBlank(uri)) { - // open the page and close the shell - window.open(uri); +/* global nf, define, module, require, exports */ + +(function (root, factory) { + if (typeof define === 'function' && define.amd) { + define(['jquery', + 'nf.Common', + 'nf.ContextMenu'], + function ($, common, contextMenu) { + return (nf.Shell = factory($, common, contextMenu)); + }); + } else if (typeof exports === 'object' && typeof module === 'object') { + module.exports = (nf.Shell = factory(require('jquery'), + require('nf.Common'), + require('nf.ContextMenu'))); + } else { + nf.Shell = factory(root.$, + root.nf.Common, + root.nf.ContextMenu); + } +}(this, function ($, common, contextMenu) { + 'use strict'; + + $(document).ready(function () { + // configure the dialog + $('#shell-dialog').modal({ + scrollableContentStyle: 'scrollable', + header: false, + footer: false, + responsive: { + x: false, + y: false + } + }); + // register a listener when the frame is closed + $('#shell-close-button').click(function () { // close the shell $('#shell-dialog').modal('hide'); - } - }); -}); + }); -nf.Shell = (function () { + // register a listener when the frame is undocked + $('#shell-undock-button').click(function () { + var uri = $('#shell-iframe').attr('src'); + if (!common.isBlank(uri)) { + // open the page and close the shell + window.open(uri); + + // close the shell + $('#shell-dialog').modal('hide'); + } + }); + }); var showPageResize = null; var showContentResize = null; return { - + resizeContent: function (shell) { var contentContainer = shell.find('.shell-content-container'); contentContainer.css({ @@ -73,24 +91,24 @@ nf.Shell = (function () { }); shell.trigger("shell:iframe:resize"); }, - + /** * Shows a page in the shell. - * + * * @argument {string} uri The URI to show * @argument {boolean} canUndock Whether or not the shell is undockable */ showPage: function (uri, canUndock) { // if the context menu is on this page, attempt to close - if (nf.Common.isDefinedAndNotNull(nf.ContextMenu)) { - nf.ContextMenu.hide(); + if (common.isDefinedAndNotNull(contextMenu)) { + contextMenu.hide(); } - + return $.Deferred(function (deferred) { var shell = $('#shell'); // default undockable to true - if (nf.Common.isNull(canUndock) || nf.Common.isUndefined(canUndock)) { + if (common.isNull(canUndock) || common.isUndefined(canUndock)) { canUndock = true; } @@ -103,7 +121,7 @@ nf.Shell = (function () { // register a new open handler $('#shell-dialog').modal('setOpenHandler', function () { - nf.Common.toggleScrollable($('#' + this.find('.tab-container').attr('id') + '-content').get(0)); + common.toggleScrollable($('#' + this.find('.tab-container').attr('id') + '-content').get(0)); }); // show the custom processor ui @@ -127,19 +145,19 @@ nf.Shell = (function () { }).appendTo(shell); }).promise(); }, - + /** * Shows the specified content in the shell. When the shell is closed, the content * will be hidden and returned to its previous location in the dom. - * + * * @argument {string} domId The id of the element to show in the shell */ showContent: function (domId) { // if the context menu is on this page, attempt to close - if (nf.Common.isDefinedAndNotNull(nf.ContextMenu)) { - nf.ContextMenu.hide(); + if (common.isDefinedAndNotNull(contextMenu)) { + contextMenu.hide(); } - + return $.Deferred(function (deferred) { var content = $(domId); if (content.length) { @@ -154,7 +172,7 @@ nf.Shell = (function () { // close any open combos var combos = $('.combo'); for (var i = 0, len = combos.length; i < len; i++) { - if ($(combos[i]).is(':visible')){ + if ($(combos[i]).is(':visible')) { $(combos[i]).combo('close'); } } @@ -179,11 +197,11 @@ nf.Shell = (function () { width: shell.width(), height: shell.height() }).append(content).appendTo(shell); - + // show the content content.show(); } }).promise(); } }; -}()); +})); 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/nf-status-history.js ---------------------------------------------------------------------- diff --git a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/js/nf/nf-status-history.js b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/js/nf/nf-status-history.js index 17d40d8..04fbf00 100644 --- a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/js/nf/nf-status-history.js +++ b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/js/nf/nf-status-history.js @@ -15,9 +15,32 @@ * limitations under the License. */ -/* global nf, d3 */ - -nf.StatusHistory = (function () { +/* global nf, define, module, require, exports */ + +(function (root, factory) { + if (typeof define === 'function' && define.amd) { + define(['jquery', + 'd3', + 'nf.Common', + 'nf.Dialog', + 'nf.ErrorHandler'], + function ($, d3, common, dialog, errorHandler) { + return (nf.StatusHistory = factory($, d3, common, dialog, errorHandler)); + }); + } else if (typeof exports === 'object' && typeof module === 'object') { + module.exports = (nf.StatusHistory = factory(require('jquery'), + require('d3'), + require('nf.Common'), + require('nf.Dialog'), + require('nf.ErrorHandler'))); + } else { + nf.StatusHistory = factory(root.$, + root.d3, + root.nf.Common, + root.nf.Dialog, + root.nf.ErrorHandler); + } +}(this, function ($, d3, common, dialog, errorHandler) { var config = { nifiInstanceId: 'nifi-instance-id', nifiInstanceLabel: 'NiFi', @@ -42,19 +65,19 @@ nf.StatusHistory = (function () { */ var formatters = { 'DURATION': function (d) { - return nf.Common.formatDuration(d); + return common.formatDuration(d); }, 'COUNT': function (d) { // need to handle floating point number since this formatter // will also be used for average values if (d % 1 === 0) { - return nf.Common.formatInteger(d); + return common.formatInteger(d); } else { - return nf.Common.formatFloat(d); + return common.formatFloat(d); } }, 'DATA_SIZE': function (d) { - return nf.Common.formatDataSize(d); + return common.formatDataSize(d); } }; @@ -102,10 +125,10 @@ nf.StatusHistory = (function () { // get the descriptors var descriptors = componentStatusHistory.fieldDescriptors; statusHistory.details = componentStatusHistory.componentDetails; - statusHistory.selectedDescriptor = nf.Common.isUndefined(selectedDescriptor) ? descriptors[0] : selectedDescriptor; + statusHistory.selectedDescriptor = common.isUndefined(selectedDescriptor) ? descriptors[0] : selectedDescriptor; // ensure enough status snapshots - if (nf.Common.isDefinedAndNotNull(componentStatusHistory.aggregateSnapshots) && componentStatusHistory.aggregateSnapshots.length > 1) { + if (common.isDefinedAndNotNull(componentStatusHistory.aggregateSnapshots) && componentStatusHistory.aggregateSnapshots.length > 1) { statusHistory.instances.push({ id: config.nifiInstanceId, label: config.nifiInstanceLabel, @@ -119,7 +142,7 @@ nf.StatusHistory = (function () { // get the status for each node in the cluster if applicable $.each(componentStatusHistory.nodeSnapshots, function (_, nodeSnapshots) { // ensure enough status snapshots - if (nf.Common.isDefinedAndNotNull(nodeSnapshots.statusSnapshots) && nodeSnapshots.statusSnapshots.length > 1) { + if (common.isDefinedAndNotNull(nodeSnapshots.statusSnapshots) && nodeSnapshots.statusSnapshots.length > 1) { statusHistory.instances.push({ id: nodeSnapshots.nodeId, label: nodeSnapshots.address + ':' + nodeSnapshots.apiPort, @@ -145,7 +168,7 @@ nf.StatusHistory = (function () { */ var insufficientHistory = function () { // notify the user - nf.Dialog.showOkDialog({ + dialog.showOkDialog({ headerText: 'Status History', dialogContent: 'Insufficient history, please try again later.' }); @@ -193,7 +216,7 @@ nf.StatusHistory = (function () { options.push({ text: d.label, value: d.field, - description: nf.Common.escapeHtml(d.description) + description: common.escapeHtml(d.description) }); }); @@ -306,7 +329,7 @@ nf.StatusHistory = (function () { // go through each instance of this status history $.each(statusHistory.instances, function (_, instance) { // if this is the first time this instance is being rendered, make it visible - if (nf.Common.isUndefinedOrNull(instances[instance.id])) { + if (common.isUndefinedOrNull(instances[instance.id])) { instances[instance.id] = true; } @@ -363,7 +386,7 @@ nf.StatusHistory = (function () { var chartContainer = $('#status-history-chart-container').empty(); if (chartContainer.hasClass('ui-resizable')) { chartContainer.resizable('destroy'); - chartContainer.removeAttr( "style" ); + chartContainer.removeAttr("style"); } // calculate the dimensions @@ -440,8 +463,8 @@ nf.StatusHistory = (function () { return s.timestamp; }); }); - addDetailItem(detailsContainer, 'Start', nf.Common.formatDateTime(minDate)); - addDetailItem(detailsContainer, 'End', nf.Common.formatDateTime(maxDate)); + addDetailItem(detailsContainer, 'Start', common.formatDateTime(minDate)); + addDetailItem(detailsContainer, 'End', common.formatDateTime(maxDate)); // determine the x axis range x.domain([minDate, maxDate]); @@ -721,7 +744,7 @@ nf.StatusHistory = (function () { .on('brush', brushed); // conditionally set the brush extent - if (nf.Common.isDefinedAndNotNull(brushExtent)) { + if (common.isDefinedAndNotNull(brushExtent)) { brush = brush.extent(brushExtent); } @@ -902,7 +925,7 @@ nf.StatusHistory = (function () { // ----------- dialog = $('#status-history-dialog'); var nfDialog = {}; - if (nf.Common.isDefinedAndNotNull(dialog.data('nf-dialog'))) { + if (common.isDefinedAndNotNull(dialog.data('nf-dialog'))) { nfDialog = dialog.data('nf-dialog'); } nfDialog['min-width'] = (dialog.width() / $(window).width()) * 100 + '%'; @@ -1019,12 +1042,12 @@ nf.StatusHistory = (function () { $('<div class="setting-name"></div>').text(label).appendTo(detailContainer); var detailElement = $('<div class="setting-field"></div>').text(value).appendTo(detailContainer); - if (nf.Common.isDefinedAndNotNull(valueElementId)) { + if (common.isDefinedAndNotNull(valueElementId)) { detailElement.attr('id', valueElementId); } }; - return { + var nfStatusHistory = { /** * Initializes the lineage graph. * @@ -1037,13 +1060,13 @@ nf.StatusHistory = (function () { var statusHistory = $('#status-history-dialog').data('status-history'); if (statusHistory !== null) { if (statusHistory.type === config.type.processor) { - nf.StatusHistory.showProcessorChart(statusHistory.groupId, statusHistory.id, statusHistory.selectedDescriptor); + nfStatusHistory.showProcessorChart(statusHistory.groupId, statusHistory.id, statusHistory.selectedDescriptor); } else if (statusHistory.type === config.type.processGroup) { - nf.StatusHistory.showProcessGroupChart(statusHistory.groupId, statusHistory.id, statusHistory.selectedDescriptor); + nfStatusHistory.showProcessGroupChart(statusHistory.groupId, statusHistory.id, statusHistory.selectedDescriptor); } else if (statusHistory.type === config.type.remoteProcessGroup) { - nf.StatusHistory.showRemoteProcessGroupChart(statusHistory.groupId, statusHistory.id, statusHistory.selectedDescriptor); + nfStatusHistory.showRemoteProcessGroupChart(statusHistory.groupId, statusHistory.id, statusHistory.selectedDescriptor); } else { - nf.StatusHistory.showConnectionChart(statusHistory.groupId, statusHistory.id, statusHistory.selectedDescriptor); + nfStatusHistory.showConnectionChart(statusHistory.groupId, statusHistory.id, statusHistory.selectedDescriptor); } } }); @@ -1088,7 +1111,7 @@ nf.StatusHistory = (function () { if (e.target === window) { updateChart(); } - nf.Common.toggleScrollable($('#status-history-details').get(0)); + common.toggleScrollable($('#status-history-details').get(0)); }) }, @@ -1106,7 +1129,7 @@ nf.StatusHistory = (function () { dataType: 'json' }).done(function (response) { handleStatusHistoryResponse(groupId, connectionId, response.statusHistory, config.type.connection, selectedDescriptor); - }).fail(nf.Common.handleAjaxError); + }).fail(errorHandler.handleAjaxError); }, /** @@ -1123,7 +1146,7 @@ nf.StatusHistory = (function () { dataType: 'json' }).done(function (response) { handleStatusHistoryResponse(groupId, processorId, response.statusHistory, config.type.processor, selectedDescriptor); - }).fail(nf.Common.handleAjaxError); + }).fail(errorHandler.handleAjaxError); }, /** @@ -1140,7 +1163,7 @@ nf.StatusHistory = (function () { dataType: 'json' }).done(function (response) { handleStatusHistoryResponse(groupId, processGroupId, response.statusHistory, config.type.processGroup, selectedDescriptor); - }).fail(nf.Common.handleAjaxError); + }).fail(errorHandler.handleAjaxError); }, /** @@ -1157,7 +1180,9 @@ nf.StatusHistory = (function () { dataType: 'json' }).done(function (response) { handleStatusHistoryResponse(groupId, remoteProcessGroupId, response.statusHistory, config.type.remoteProcessGroup, selectedDescriptor); - }).fail(nf.Common.handleAjaxError); + }).fail(errorHandler.handleAjaxError); } }; -}()); \ No newline at end of file + + return nfStatusHistory; +})); \ 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/nf-storage.js ---------------------------------------------------------------------- diff --git a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/js/nf/nf-storage.js b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/js/nf/nf-storage.js index efb90fe..b96d61e 100644 --- a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/js/nf/nf-storage.js +++ b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/js/nf/nf-storage.js @@ -15,9 +15,19 @@ * limitations under the License. */ -/* global nf, d3 */ +/* global nf, define, module, require, exports */ -nf.Storage = (function () { +(function (root, factory) { + if (typeof define === 'function' && define.amd) { + define([], function () { + return (nf.Storage = factory()); + }); + } else if (typeof exports === 'object' && typeof module === 'object') { + module.exports = (nf.Storage = factory()); + } else { + nf.Storage = factory(); + } +}(this, function () { // Store items for two days before being eligible for removal. var MILLIS_PER_DAY = 86400000; @@ -37,7 +47,7 @@ nf.Storage = (function () { /** * Checks the expiration for the specified entry. - * + * * @param {object} entry * @returns {boolean} */ @@ -53,10 +63,10 @@ nf.Storage = (function () { return false; } }; - + /** * Gets an enty for the key. The entry expiration is not checked. - * + * * @param {string} key */ var getEntry = function (key) { @@ -74,7 +84,7 @@ nf.Storage = (function () { return null; } }; - + return { /** * Initializes the storage. Items will be persisted for two days. Once the scripts runs @@ -85,17 +95,17 @@ nf.Storage = (function () { try { // get the next item var key = localStorage.key(i); - + // attempt to get the item which will expire if necessary - nf.Storage.getItem(key); + this.getItem(key); } catch (e) { } } }, - + /** * Stores the specified item. - * + * * @param {string} key * @param {object} item * @param {integer} expires @@ -113,23 +123,23 @@ nf.Storage = (function () { // store the item localStorage.setItem(key, JSON.stringify(entry)); }, - + /** * Returns whether there is an entry for this key. This will not check the expiration. If * the entry is expired, it will return null on a subsequent getItem invocation. - * + * * @param {string} key * @returns {boolean} */ hasItem: function (key) { return getEntry(key) !== null; }, - + /** * Gets the item with the specified key. If an item with this key does * not exist, null is returned. If an item exists but cannot be parsed * or is malformed/unrecognized, null is returned. - * + * * @param {type} key */ getItem: function (key) { @@ -140,7 +150,7 @@ nf.Storage = (function () { // if the entry is expired, drop it and return null if (checkExpiration(entry)) { - nf.Storage.removeItem(key); + this.removeItem(key); return null; } @@ -151,11 +161,11 @@ nf.Storage = (function () { return null; } }, - + /** * Gets the expiration for the specified item. This will not check the expiration. If * the entry is expired, it will return null on a subsequent getItem invocation. - * + * * @param {string} key * @returns {integer} */ @@ -172,14 +182,14 @@ nf.Storage = (function () { return null; } }, - + /** * Removes the item with the specified key. - * + * * @param {type} key */ removeItem: function (key) { localStorage.removeItem(key); } }; -}()); \ No newline at end of file +})); \ 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/nf-universal-capture.js ---------------------------------------------------------------------- diff --git a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/js/nf/nf-universal-capture.js b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/js/nf/nf-universal-capture.js index 6db1cc5..ffadf64 100644 --- a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/js/nf/nf-universal-capture.js +++ b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/js/nf/nf-universal-capture.js @@ -15,108 +15,122 @@ * limitations under the License. */ -/** - * Captures keydown on the window to ensure certain keystrokes are handled in a consistent manner, particularly those - * that can lead to browser navigation/reload. - */ -$(document).ready(function ($) { - // setup a listener to ensure keystrokes are being overridden in a consistent manner - $(window).on('keydown', function (evt) { - // consider escape, before checking dialogs - var isCtrl = evt.ctrlKey || evt.metaKey; - if (!isCtrl && evt.keyCode === 27) { - // esc - - // prevent escape when editing a property with allowable values - that component does not handle key - // events so it can bubble up to here. once here we are unable to cancel the current edit so we simply - // return. this is not an issue for viewing in read only mode as the table is not in an edit mode. this - // is not an issue for other fields as they can handle key events locally and cancel the edit appropriately - var visibleCombo = $('div.value-combo'); - if (visibleCombo.is(':visible') && visibleCombo.parent().hasClass('combo-editor')) { - return; - } +/* global nf, define, module, require, exports */ - // consider property detail dialogs - if ($('div.property-detail').is(':visible')) { - nf.UniversalCapture.removeAllPropertyDetailDialogs(); +(function (root, factory) { + if (typeof define === 'function' && define.amd) { + define(['jquery'], function ($) { + return (nf.UniversalCapture = factory($)); + }); + } else if (typeof exports === 'object' && typeof module === 'object') { + module.exports = (nf.UniversalCapture = factory(require('jquery'))); + } else { + nf.UniversalCapture = factory(root.$); + } +}(this, function ($) { + 'use strict'; - // prevent further bubbling as we're already handled it - evt.stopImmediatePropagation(); - evt.preventDefault(); - } else { - var target = $(evt.target); - if (target.length) { - // special handling for body as the target - var cancellables = $('.cancellable'); - if (cancellables.length) { - var zIndexMax = null; - var dialogMax = null; - - // identify the top most cancellable - $.each(cancellables, function (_, cancellable) { - var dialog = $(cancellable); - var zIndex = dialog.css('zIndex'); - - // if the dialog has a zIndex consider it - if (dialog.is(':visible') && (zIndex !== null && typeof zIndex !== 'undefined')) { - zIndex = parseInt(zIndex, 10); - if (zIndexMax === null || zIndex > zIndexMax) { - zIndexMax = zIndex; - dialogMax = dialog; + /** + * Captures keydown on the window to ensure certain keystrokes are handled in a consistent manner, particularly those + * that can lead to browser navigation/reload. + */ + $(document).ready(function ($) { + // setup a listener to ensure keystrokes are being overridden in a consistent manner + $(window).on('keydown', function (evt) { + // consider escape, before checking dialogs + var isCtrl = evt.ctrlKey || evt.metaKey; + if (!isCtrl && evt.keyCode === 27) { + // esc + + // prevent escape when editing a property with allowable values - that component does not handle key + // events so it can bubble up to here. once here we are unable to cancel the current edit so we simply + // return. this is not an issue for viewing in read only mode as the table is not in an edit mode. this + // is not an issue for other fields as they can handle key events locally and cancel the edit appropriately + var visibleCombo = $('div.value-combo'); + if (visibleCombo.is(':visible') && visibleCombo.parent().hasClass('combo-editor')) { + return; + } + + // consider property detail dialogs + if ($('div.property-detail').is(':visible')) { + nfUniversalDialog.removeAllPropertyDetailDialogs(); + + // prevent further bubbling as we're already handled it + evt.stopImmediatePropagation(); + evt.preventDefault(); + } else { + var target = $(evt.target); + if (target.length) { + // special handling for body as the target + var cancellables = $('.cancellable'); + if (cancellables.length) { + var zIndexMax = null; + var dialogMax = null; + + // identify the top most cancellable + $.each(cancellables, function (_, cancellable) { + var dialog = $(cancellable); + var zIndex = dialog.css('zIndex'); + + // if the dialog has a zIndex consider it + if (dialog.is(':visible') && (zIndex !== null && typeof zIndex !== 'undefined')) { + zIndex = parseInt(zIndex, 10); + if (zIndexMax === null || zIndex > zIndexMax) { + zIndexMax = zIndex; + dialogMax = dialog; + } } - } - }); - - // if we've identified a dialog to close do so and stop propagation - if (dialogMax !== null) { - // hide the cancellable - if (dialogMax.hasClass('modal')) { - dialogMax.modal('hide'); - } else { - dialogMax.hide(); - } + }); - // prevent further bubbling as we're already handled it - evt.stopImmediatePropagation(); - evt.preventDefault(); + // if we've identified a dialog to close do so and stop propagation + if (dialogMax !== null) { + // hide the cancellable + if (dialogMax.hasClass('modal')) { + dialogMax.modal('hide'); + } else { + dialogMax.hide(); + } - return; + // prevent further bubbling as we're already handled it + evt.stopImmediatePropagation(); + evt.preventDefault(); + + return; + } } - } - // now see if we're in a frame - if (top !== window) { - // and our parent has shell defined - if (typeof parent.nf !== 'undefined' && typeof parent.nf.Shell !== 'undefined') { - parent.$('#shell-close-button').click(); + // now see if we're in a frame + if (top !== window) { + // and our parent has shell defined + if (typeof parent.nf !== 'undefined' && typeof parent.nf.Shell !== 'undefined') { + parent.$('#shell-close-button').click(); - // prevent further bubbling as we're already handled it - evt.stopImmediatePropagation(); - evt.preventDefault(); + // prevent further bubbling as we're already handled it + evt.stopImmediatePropagation(); + evt.preventDefault(); - return; + return; + } } } } - } - } else { - if (isCtrl) { - if (evt.keyCode === 82) { - // ctrl-r - evt.preventDefault(); - } } else { - if (!$('input, textarea').is(':focus') && (evt.keyCode == 8 || evt.keyCode === 46)) { - // backspace or delete - evt.preventDefault(); + if (isCtrl) { + if (evt.keyCode === 82) { + // ctrl-r + evt.preventDefault(); + } + } else { + if (!$('input, textarea').is(':focus') && (evt.keyCode == 8 || evt.keyCode === 46)) { + // backspace or delete + evt.preventDefault(); + } } } - } + }); }); -}); -nf.UniversalCapture = (function() { - return { + var nfUniversalDialog = { /** * Removes all read only property detail dialogs. */ @@ -127,4 +141,6 @@ nf.UniversalCapture = (function() { propertyDetails.hide().remove(); } }; -}()); \ No newline at end of file + + return nfUniversalDialog; +})); \ No newline at end of file
