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/provenance/nf-provenance.js ---------------------------------------------------------------------- diff --git a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/js/nf/provenance/nf-provenance.js b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/js/nf/provenance/nf-provenance.js index 9e5d457..9dd9983 100644 --- a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/js/nf/provenance/nf-provenance.js +++ b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/js/nf/provenance/nf-provenance.js @@ -15,285 +15,348 @@ * limitations under the License. */ -/* global nf, top */ +/* global nf, top, define, module, require, exports */ + +(function (root, factory) { + if (typeof define === 'function' && define.amd) { + define(['jquery', + 'angular', + 'nf.Common', + 'nf.ng.AppConfig', + 'nf.ng.AppCtrl', + 'nf.ng.ProvenanceLineage', + 'nf.ng.ProvenanceTable', + 'nf.ng.Bridge', + 'nf.ErrorHandler', + 'nf.Storage'], + function ($, + angular, + common, + appConfig, + appCtrl, + provenanceLineage, + provenanceTable, + angularBridge, + errorHandler, + storage) { + return (nf.ng.Provenance = + factory($, + angular, + common, + appConfig, + appCtrl, + provenanceLineage, + provenanceTable, + angularBridge, + errorHandler, + storage)); + }); + } else if (typeof exports === 'object' && typeof module === 'object') { + module.exports = (nf.ng.Provenance = + factory(require('jquery'), + require('angular'), + require('nf.Common'), + require('nf.ng.AppConfig'), + require('nf.ng.AppCtrl'), + require('nf.ng.ProvenanceLineage'), + require('nf.ng.ProvenanceTable'), + require('nf.ng.Bridge'), + require('nf.ErrorHandler'), + require('nf.Storage'))); + } else { + nf.ng.Provenance = factory(root.$, + root.angular, + root.nf.Common, + root.nf.ng.AppConfig, + root.nf.ng.AppCtrl, + root.nf.ng.ProvenanceLineage, + root.nf.ng.ProvenanceTable, + root.nf.ng.Bridge, + root.nf.ErrorHandler, + root.nf.Storage); + } +}(this, function ($, angular, common, appConfig, appCtrl, provenanceLineage, provenanceTable, angularBridge, errorHandler, storage) { + 'use strict'; -$(document).ready(function () { - //Create Angular App - var app = angular.module('ngProvenanceApp', ['ngResource', 'ngRoute', 'ngMaterial', 'ngMessages']); + $(document).ready(function () { + //Create Angular App + var app = angular.module('ngProvenanceApp', ['ngResource', 'ngRoute', 'ngMaterial', 'ngMessages']); - //Define Dependency Injection Annotations - nf.ng.AppConfig.$inject = ['$mdThemingProvider', '$compileProvider']; - nf.ng.AppCtrl.$inject = ['$scope']; - nf.ng.Provenance.$inject = ['provenanceTableCtrl']; - nf.ng.ProvenanceLineage.$inject = []; - nf.ng.ProvenanceTable.$inject = ['provenanceLineageCtrl']; + //Define Dependency Injection Annotations + appConfig.$inject = ['$mdThemingProvider', '$compileProvider']; + appCtrl.$inject = ['$scope']; + nfProvenance.$inject = ['provenanceTableCtrl']; + provenanceLineage.$inject = []; + provenanceTable.$inject = ['provenanceLineageCtrl']; - //Configure Angular App - app.config(nf.ng.AppConfig); + //Configure Angular App + app.config(appConfig); - //Define Angular App Controllers - app.controller('ngProvenanceAppCtrl', nf.ng.AppCtrl); + //Define Angular App Controllers + app.controller('ngProvenanceAppCtrl', appCtrl); - //Define Angular App Services - app.service('provenanceCtrl', nf.ng.Provenance); - app.service('provenanceLineageCtrl', nf.ng.ProvenanceLineage); - app.service('provenanceTableCtrl', nf.ng.ProvenanceTable); + //Define Angular App Services + app.service('provenanceCtrl', nfProvenance); + app.service('provenanceLineageCtrl', provenanceLineage); + app.service('provenanceTableCtrl', provenanceTable); - //Manually Boostrap Angular App - nf.ng.Bridge.injector = angular.bootstrap($('body'), ['ngProvenanceApp'], { strictDi: true }); + //Manually Boostrap Angular App + angularBridge.injector = angular.bootstrap($('body'), ['ngProvenanceApp'], {strictDi: true}); - // initialize the status page - nf.ng.Bridge.injector.get('provenanceCtrl').init(); -}); + // initialize the status page + angularBridge.injector.get('provenanceCtrl').init(); + }); -nf.ng.Provenance = function (provenanceTableCtrl) { - 'use strict'; + var nfProvenance = function (provenanceTableCtrl) { - /** - * Configuration object used to hold a number of configuration items. - */ - var config = { - urls: { - clusterSummary: '../nifi-api/flow/cluster/summary', - banners: '../nifi-api/flow/banners', - about: '../nifi-api/flow/about', - currentUser: '../nifi-api/flow/current-user' - } - }; - - /** - * Whether or not this NiFi is clustered. - */ - var isClustered = null; - - /** - * Determines if this NiFi is clustered. - */ - var detectedCluster = function () { - return $.ajax({ - type: 'GET', - url: config.urls.clusterSummary - }).done(function (response) { - isClustered = response.clusterSummary.connectedToCluster; - }).fail(nf.Common.handleAjaxError); - }; - - /** - * Loads the controller configuration. - */ - var loadAbout = function () { - // get the about details - return $.ajax({ - type: 'GET', - url: config.urls.about, - dataType: 'json' - }).done(function (response) { - var aboutDetails = response.about; - var provenanceTitle = aboutDetails.title + ' Data Provenance'; - - // store the controller name - $('#nifi-controller-uri').text(aboutDetails.uri); - - // set the timezone for the start and end time - $('.timezone').text(aboutDetails.timezone); - - // store the content viewer url if available - if (!nf.Common.isBlank(aboutDetails.contentViewerUrl)) { - $('#nifi-content-viewer-url').text(aboutDetails.contentViewerUrl); + /** + * Configuration object used to hold a number of configuration items. + */ + var config = { + urls: { + clusterSummary: '../nifi-api/flow/cluster/summary', + banners: '../nifi-api/flow/banners', + about: '../nifi-api/flow/about', + currentUser: '../nifi-api/flow/current-user' } + }; - // set the document title and the about title - document.title = provenanceTitle; - $('#provenance-header-text').text(provenanceTitle); - }).fail(nf.Common.handleAjaxError); - }; - - /** - * Loads the current user. - */ - var loadCurrentUser = function () { - return $.ajax({ - type: 'GET', - url: config.urls.currentUser, - dataType: 'json' - }).done(function (currentUser) { - nf.Common.setCurrentUser(currentUser); - }).fail(nf.Common.handleAjaxError); - }; - - /** - * Initializes the provenance page. - */ - var initializeProvenancePage = function () { - // define mouse over event for the refresh button - $('#refresh-button').click(function () { - provenanceTableCtrl.loadProvenanceTable(); - }); - - // return a deferred for page initialization - return $.Deferred(function (deferred) { - // get the banners if we're not in the shell - if (top === window) { - $.ajax({ - type: 'GET', - url: config.urls.banners, - dataType: 'json' - }).done(function (response) { - // ensure the banners response is specified - if (nf.Common.isDefinedAndNotNull(response.banners)) { - if (nf.Common.isDefinedAndNotNull(response.banners.headerText) && response.banners.headerText !== '') { - // update the header text - var bannerHeader = $('#banner-header').text(response.banners.headerText).show(); - - // show the banner - var updateTop = function (elementId) { - var element = $('#' + elementId); - element.css('top', (parseInt(bannerHeader.css('height'), 10) + parseInt(element.css('top'), 10)) + 'px'); - }; - - // update the position of elements affected by top banners - updateTop('provenance'); - } + /** + * Whether or not this NiFi is clustered. + */ + var isClustered = null; + + /** + * Determines if this NiFi is clustered. + */ + var detectedCluster = function () { + return $.ajax({ + type: 'GET', + url: config.urls.clusterSummary + }).done(function (response) { + isClustered = response.clusterSummary.connectedToCluster; + }).fail(errorHandler.handleAjaxError); + }; - if (nf.Common.isDefinedAndNotNull(response.banners.footerText) && response.banners.footerText !== '') { - // update the footer text and show it - var bannerFooter = $('#banner-footer').text(response.banners.footerText).show(); + /** + * Loads the controller configuration. + */ + var loadAbout = function () { + // get the about details + return $.ajax({ + type: 'GET', + url: config.urls.about, + dataType: 'json' + }).done(function (response) { + var aboutDetails = response.about; + var provenanceTitle = aboutDetails.title + ' Data Provenance'; + + // store the controller name + $('#nifi-controller-uri').text(aboutDetails.uri); + + // set the timezone for the start and end time + $('.timezone').text(aboutDetails.timezone); + + // store the content viewer url if available + if (!common.isBlank(aboutDetails.contentViewerUrl)) { + $('#nifi-content-viewer-url').text(aboutDetails.contentViewerUrl); + } + + // set the document title and the about title + document.title = provenanceTitle; + $('#provenance-header-text').text(provenanceTitle); + }).fail(errorHandler.handleAjaxError); + }; - var updateBottom = function (elementId) { - var element = $('#' + elementId); - element.css('bottom', parseInt(bannerFooter.css('height'), 10) + 'px'); - }; + /** + * Loads the current user. + */ + var loadCurrentUser = function () { + return $.ajax({ + type: 'GET', + url: config.urls.currentUser, + dataType: 'json' + }).done(function (currentUser) { + common.setCurrentUser(currentUser); + }).fail(errorHandler.handleAjaxError); + }; - // update the position of elements affected by bottom banners - updateBottom('provenance'); + /** + * Initializes the provenance page. + */ + var initializeProvenancePage = function () { + // define mouse over event for the refresh button + $('#refresh-button').click(function () { + provenanceTableCtrl.loadProvenanceTable(); + }); + + // return a deferred for page initialization + return $.Deferred(function (deferred) { + // get the banners if we're not in the shell + if (top === window) { + $.ajax({ + type: 'GET', + url: config.urls.banners, + dataType: 'json' + }).done(function (response) { + // ensure the banners response is specified + if (common.isDefinedAndNotNull(response.banners)) { + if (common.isDefinedAndNotNull(response.banners.headerText) && response.banners.headerText !== '') { + // update the header text + var bannerHeader = $('#banner-header').text(response.banners.headerText).show(); + + // show the banner + var updateTop = function (elementId) { + var element = $('#' + elementId); + element.css('top', (parseInt(bannerHeader.css('height'), 10) + parseInt(element.css('top'), 10)) + 'px'); + }; + + // update the position of elements affected by top banners + updateTop('provenance'); + } + + if (common.isDefinedAndNotNull(response.banners.footerText) && response.banners.footerText !== '') { + // update the footer text and show it + var bannerFooter = $('#banner-footer').text(response.banners.footerText).show(); + + var updateBottom = function (elementId) { + var element = $('#' + elementId); + element.css('bottom', parseInt(bannerFooter.css('height'), 10) + 'px'); + }; + + // update the position of elements affected by bottom banners + updateBottom('provenance'); + } } - } + deferred.resolve(); + }).fail(function (xhr, status, error) { + errorHandler.handleAjaxError(xhr, status, error); + deferred.reject(); + }); + } else { deferred.resolve(); - }).fail(function (xhr, status, error) { - nf.Common.handleAjaxError(xhr, status, error); - deferred.reject(); - }); - } else { - deferred.resolve(); - } - }).promise(); - }; + } + }).promise(); + }; - function ProvenanceCtrl() { - } + function ProvenanceCtrl() { + } - ProvenanceCtrl.prototype = { - constructor: ProvenanceCtrl, + ProvenanceCtrl.prototype = { + constructor: ProvenanceCtrl, + + /** + * Initializes the status page. + */ + init: function () { + storage.init(); + + // load the user and detect if the NiFi is clustered + $.when(loadAbout(), loadCurrentUser(), detectedCluster()).done(function () { + // create the provenance table + provenanceTableCtrl.init(isClustered).done(function () { + var searchTerms = {}; + + // look for a processor id in the query search + var initialComponentId = $('#initial-component-query').text(); + if ($.trim(initialComponentId) !== '') { + // populate initial search component + $('input.searchable-component-id').val(initialComponentId); + + // build the search criteria + searchTerms['ProcessorID'] = initialComponentId; + } - /** - * Initializes the status page. - */ - init: function () { - nf.Storage.init(); - - // load the user and detect if the NiFi is clustered - $.when(loadAbout(), loadCurrentUser(), detectedCluster()).done(function () { - // create the provenance table - provenanceTableCtrl.init(isClustered).done(function () { - var searchTerms = {}; - - // look for a processor id in the query search - var initialComponentId = $('#initial-component-query').text(); - if ($.trim(initialComponentId) !== '') { - // populate initial search component - $('input.searchable-component-id').val(initialComponentId); - - // build the search criteria - searchTerms['ProcessorID'] = initialComponentId; - } - - // look for a flowfile uuid in the query search - var initialFlowFileUuid = $('#initial-flowfile-query').text(); - if ($.trim(initialFlowFileUuid) !== '') { - // populate initial search component - $('input.searchable-flowfile-uuid').val(initialFlowFileUuid); - - // build the search criteria - searchTerms['FlowFileUUID'] = initialFlowFileUuid; - } - - // load the provenance table - if ($.isEmptyObject(searchTerms)) { - // load the provenance table - provenanceTableCtrl.loadProvenanceTable(); - } else { - // load the provenance table - provenanceTableCtrl.loadProvenanceTable({ - 'searchTerms': searchTerms - }); - } - - var setBodySize = function () { - //alter styles if we're not in the shell - if (top === window) { - $('body').css({ - 'height': $(window).height() + 'px', - 'width': $(window).width() + 'px' - }); + // look for a flowfile uuid in the query search + var initialFlowFileUuid = $('#initial-flowfile-query').text(); + if ($.trim(initialFlowFileUuid) !== '') { + // populate initial search component + $('input.searchable-flowfile-uuid').val(initialFlowFileUuid); + + // build the search criteria + searchTerms['FlowFileUUID'] = initialFlowFileUuid; + } - $('#provenance').css('margin', 40); - $('#provenance-refresh-container').css({ - 'bottom': '0px', - 'left': '0px', - 'right': '0px' + // load the provenance table + if ($.isEmptyObject(searchTerms)) { + // load the provenance table + provenanceTableCtrl.loadProvenanceTable(); + } else { + // load the provenance table + provenanceTableCtrl.loadProvenanceTable({ + 'searchTerms': searchTerms }); } - // configure the initial grid height - provenanceTableCtrl.resetTableSize(); - }; + var setBodySize = function () { + //alter styles if we're not in the shell + if (top === window) { + $('body').css({ + 'height': $(window).height() + 'px', + 'width': $(window).width() + 'px' + }); + + $('#provenance').css('margin', 40); + $('#provenance-refresh-container').css({ + 'bottom': '0px', + 'left': '0px', + 'right': '0px' + }); + } - // once the table is initialized, finish initializing the page - initializeProvenancePage().done(function () { - // set the initial size - setBodySize(); - }); + // configure the initial grid height + provenanceTableCtrl.resetTableSize(); + }; - $(window).on('resize', function (e) { - setBodySize(); - // resize dialogs when appropriate - var dialogs = $('.dialog'); - for (var i = 0, len = dialogs.length; i < len; i++) { - if ($(dialogs[i]).is(':visible')){ - setTimeout(function(dialog){ - dialog.modal('resize'); - }, 50, $(dialogs[i])); + // once the table is initialized, finish initializing the page + initializeProvenancePage().done(function () { + // set the initial size + setBodySize(); + }); + + $(window).on('resize', function (e) { + setBodySize(); + // resize dialogs when appropriate + var dialogs = $('.dialog'); + for (var i = 0, len = dialogs.length; i < len; i++) { + if ($(dialogs[i]).is(':visible')) { + setTimeout(function (dialog) { + dialog.modal('resize'); + }, 50, $(dialogs[i])); + } } - } - // resize grids when appropriate - var gridElements = $('*[class*="slickgrid_"]'); - for (var j = 0, len = gridElements.length; j < len; j++) { - if ($(gridElements[j]).is(':visible')){ - setTimeout(function(gridElement){ - gridElement.data('gridInstance').resizeCanvas(); - }, 50, $(gridElements[j])); + // resize grids when appropriate + var gridElements = $('*[class*="slickgrid_"]'); + for (var j = 0, len = gridElements.length; j < len; j++) { + if ($(gridElements[j]).is(':visible')) { + setTimeout(function (gridElement) { + gridElement.data('gridInstance').resizeCanvas(); + }, 50, $(gridElements[j])); + } } - } - // toggle tabs .scrollable when appropriate - var tabsContainers = $('.tab-container'); - var tabsContents = []; - for (var k = 0, len = tabsContainers.length; k < len; k++) { - if ($(tabsContainers[k]).is(':visible')){ - tabsContents.push($('#' + $(tabsContainers[k]).attr('id') + '-content')); + // toggle tabs .scrollable when appropriate + var tabsContainers = $('.tab-container'); + var tabsContents = []; + for (var k = 0, len = tabsContainers.length; k < len; k++) { + if ($(tabsContainers[k]).is(':visible')) { + tabsContents.push($('#' + $(tabsContainers[k]).attr('id') + '-content')); + } } - } - $.each(tabsContents, function (index, tabsContent) { - nf.Common.toggleScrollable(tabsContent.get(0)); + $.each(tabsContents, function (index, tabsContent) { + common.toggleScrollable(tabsContent.get(0)); + }); }); }); }); - }); + } } + + var provenanceCtrl = new ProvenanceCtrl(); + return provenanceCtrl; } - var provenanceCtrl = new ProvenanceCtrl(); - return provenanceCtrl; -}; \ No newline at end of file + return nfProvenance; +})); \ 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/summary/nf-cluster-search.js ---------------------------------------------------------------------- diff --git a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/js/nf/summary/nf-cluster-search.js b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/js/nf/summary/nf-cluster-search.js index a12b536..b4fa88b 100644 --- a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/js/nf/summary/nf-cluster-search.js +++ b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/js/nf/summary/nf-cluster-search.js @@ -14,7 +14,33 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -nf.ClusterSearch = (function () { + +/* global nf, define, module, require, exports */ + +(function (root, factory) { + if (typeof define === 'function' && define.amd) { + define(['jquery', + 'nf.Common', + 'nf.Dialog', + 'nf.SummaryTable'], + function ($, common, dialog, summaryTable) { + return (nf.ClusterSearch = factory($, common, dialog, summaryTable)); + }); + } else if (typeof exports === 'object' && typeof module === 'object') { + module.exports = (nf.ClusterSearch = + factory(require('jquery'), + require('nf.Common'), + require('nf.Dialog'), + require('nf.SummaryTable'))); + } else { + nf.ClusterSearch = factory(root.$, + root.nf.Common, + root.nf.Dialog, + root.nf.SummaryTable); + } +}(this, function ($, common, dialog, summaryTable) { + 'use strict'; + /** * Configuration object used to hold a number of configuration items. */ @@ -59,10 +85,10 @@ nf.ClusterSearch = (function () { // selects the specified node var selectNode = function (node) { // update the urls to point to this specific node of the cluster - nf.SummaryTable.setClusterNodeId(node.id); + summaryTable.setClusterNodeId(node.id); // load the summary for the selected node - nf.SummaryTable.loadSummaryTable(); + summaryTable.loadSummaryTable(); // update the header $('#summary-header-text').text(node.address + ' Summary'); @@ -70,9 +96,9 @@ nf.ClusterSearch = (function () { // ensure the search found some results if (!$.isArray(searchResults) || searchResults.length === 0) { - nf.Dialog.showOkDialog({ + dialog.showOkDialog({ headerText: 'Cluster Search', - dialogContent: 'No nodes match \'' + nf.Common.escapeHtml(clusterSearchTerm) + '\'.' + dialogContent: 'No nodes match \'' + common.escapeHtml(clusterSearchTerm) + '\'.' }); } else if (searchResults.length > 1) { var exactMatch = false; @@ -91,9 +117,9 @@ nf.ClusterSearch = (function () { // close the dialog $('#view-single-node-dialog').modal('hide'); } else { - nf.Dialog.showOkDialog({ + dialog.showOkDialog({ headerText: 'Cluster Search', - dialogContent: 'More than one node matches \'' + nf.Common.escapeHtml(clusterSearchTerm) + '\'.' + dialogContent: 'More than one node matches \'' + common.escapeHtml(clusterSearchTerm) + '\'.' }); } } else if (searchResults.length === 1) { @@ -146,9 +172,9 @@ nf.ClusterSearch = (function () { // results are normalized into a single element array var searchResults = items[0]; - var self = this; + var nfClusterSearchAutocomplete = this; $.each(searchResults.nodeResults, function (_, node) { - self._renderItem(ul, { + nfClusterSearchAutocomplete._renderItem(ul, { label: node.address, value: node.address }); @@ -208,8 +234,8 @@ nf.ClusterSearch = (function () { // handle the view cluster click event $('#view-cluster-link').click(function () { // reset the urls and refresh the table - nf.SummaryTable.setClusterNodeId(null); - nf.SummaryTable.loadSummaryTable(); + summaryTable.setClusterNodeId(null); + summaryTable.loadSummaryTable(); // update the header $('#summary-header-text').text('NiFi Summary'); @@ -219,4 +245,4 @@ nf.ClusterSearch = (function () { $('#view-options-container').show(); } }; -}()); \ No newline at end of file +})); \ No newline at end of file
