You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@nifi.apache.org by mc...@apache.org on 2017/01/20 21:19:41 UTC
[08/12] nifi git commit: [NIFI-3359] Modularize all of nifi-web-ui
except canvas directory - Removing shell.jsp from summary.jsp. - This closes
#1428
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/history/nf-history-table.js
----------------------------------------------------------------------
diff --git a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/js/nf/history/nf-history-table.js b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/js/nf/history/nf-history-table.js
index 5de2440..38f21e8 100644
--- a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/js/nf/history/nf-history-table.js
+++ b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/js/nf/history/nf-history-table.js
@@ -15,9 +15,37 @@
* limitations under the License.
*/
-/* global nf, Slick */
-
-nf.HistoryTable = (function () {
+/* global nf, top, define, module, require, exports */
+
+(function (root, factory) {
+ if (typeof define === 'function' && define.amd) {
+ define(['jquery',
+ 'Slick',
+ 'nf.Common',
+ 'nf.Dialog',
+ 'nf.ErrorHandler',
+ 'nf.HistoryModel'],
+ function ($, Slick, common, dialog, errorHandler, HistoryModel) {
+ return (nf.HistoryTable = factory($, Slick, common, dialog, errorHandler, HistoryModel));
+ });
+ } else if (typeof exports === 'object' && typeof module === 'object') {
+ module.exports = (nf.HistoryTable =
+ factory(require('jquery'),
+ require('Slick'),
+ require('nf.Common'),
+ require('nf.Dialog'),
+ require('nf.ErrorHandler'),
+ require('nf.HistoryModel')));
+ } else {
+ nf.HistoryTable = factory(root.$,
+ root.Slick,
+ root.nf.Common,
+ root.nf.Dialog,
+ root.nf.ErrorHandler,
+ root.nf.HistoryModel);
+ }
+}(this, function ($, Slick, common, dialog, errorHandler, HistoryModel) {
+ 'use strict';
/**
* Configuration object used to hold a number of configuration items.
@@ -151,7 +179,7 @@ nf.HistoryTable = (function () {
historyModel.setFilterArgs(filter);
// reload the table
- nf.HistoryTable.loadHistoryTable();
+ nfHistoryTable.loadHistoryTable();
}
}
},
@@ -212,15 +240,15 @@ nf.HistoryTable = (function () {
}
var endDateTime = endDate + ' ' + endTime;
var timezone = $('.timezone:first').text();
- nf.Dialog.showYesNoDialog({
+ dialog.showYesNoDialog({
headerText: 'History',
- dialogContent: "Are you sure you want to delete all history before '" + nf.Common.escapeHtml(endDateTime) + " " + nf.Common.escapeHtml(timezone) + "'?",
+ dialogContent: "Are you sure you want to delete all history before '" + common.escapeHtml(endDateTime) + " " + common.escapeHtml(timezone) + "'?",
yesHandler: function () {
purgeHistory(endDateTime);
}
});
} else {
- nf.Dialog.showOkDialog({
+ dialog.showOkDialog({
headerText: 'History',
dialogContent: 'The end date must be specified.'
});
@@ -262,7 +290,7 @@ nf.HistoryTable = (function () {
historyModel.setFilterArgs({});
// refresh the table
- nf.HistoryTable.loadHistoryTable();
+ nfHistoryTable.loadHistoryTable();
});
// add hover effect and click handler for opening the dialog
@@ -272,7 +300,7 @@ nf.HistoryTable = (function () {
// define a custom formatter for the more details column
var moreDetailsFormatter = function (row, cell, value, columnDef, dataContext) {
- if(dataContext.canRead === true) {
+ if (dataContext.canRead === true) {
return '<div title="View Details" class="pointer show-action-details fa fa-info-circle" style="margin-top: 4px;"></div>';
}
return "";
@@ -280,10 +308,10 @@ nf.HistoryTable = (function () {
// define how general values are formatted
var valueFormatter = function (row, cell, value, columnDef, dataContext) {
- if(dataContext.canRead !== true) {
+ if (dataContext.canRead !== true) {
return '<span class="unset" style="font-size: 13px; padding-top: 2px;">Not authorized</span>';
}
- return nf.Common.formatValue(dataContext.action[columnDef.field]);
+ return common.formatValue(dataContext.action[columnDef.field]);
};
// initialize the templates table
@@ -297,12 +325,48 @@ nf.HistoryTable = (function () {
width: 50,
maxWidth: 50
},
- {id: 'timestamp', name: 'Date/Time', field: 'timestamp', sortable: true, resizable: true, formatter: valueFormatter},
- {id: 'sourceName', name: 'Name', field: 'sourceName', sortable: true, resizable: true, formatter: valueFormatter},
- {id: 'sourceType', name: 'Type', field: 'sourceType', sortable: true, resizable: true, formatter: valueFormatter},
- {id: 'operation', name: 'Operation', field: 'operation', sortable: true, resizable: true, formatter: valueFormatter},
- {id: 'userIdentity', name: 'User', field: 'userIdentity', sortable: true, resizable: true, formatter: valueFormatter}
+ {
+ id: 'timestamp',
+ name: 'Date/Time',
+ field: 'timestamp',
+ sortable: true,
+ resizable: true,
+ formatter: valueFormatter
+ },
+ {
+ id: 'sourceName',
+ name: 'Name',
+ field: 'sourceName',
+ sortable: true,
+ resizable: true,
+ formatter: valueFormatter
+ },
+ {
+ id: 'sourceType',
+ name: 'Type',
+ field: 'sourceType',
+ sortable: true,
+ resizable: true,
+ formatter: valueFormatter
+ },
+ {
+ id: 'operation',
+ name: 'Operation',
+ field: 'operation',
+ sortable: true,
+ resizable: true,
+ formatter: valueFormatter
+ },
+ {
+ id: 'userIdentity',
+ name: 'User',
+ field: 'userIdentity',
+ sortable: true,
+ resizable: true,
+ formatter: valueFormatter
+ }
];
+
var historyOptions = {
forceFitColumns: true,
enableTextSelectionOnCells: true,
@@ -313,7 +377,7 @@ nf.HistoryTable = (function () {
};
// create the remote model
- var historyModel = new nf.HistoryModel();
+ var historyModel = new HistoryModel();
// initialize the grid
var historyGrid = new Slick.Grid('#history-table', historyModel, historyColumns, historyOptions);
@@ -365,7 +429,7 @@ nf.HistoryTable = (function () {
$('#history-table').data('gridInstance', historyGrid);
// add the purge button if appropriate
- if (nf.Common.canModifyController()) {
+ if (common.canModifyController()) {
$('#history-purge-button').on('click', function () {
$('#history-purge-dialog').modal('show');
}).show();
@@ -385,8 +449,8 @@ nf.HistoryTable = (function () {
}),
dataType: 'json'
}).done(function () {
- nf.HistoryTable.loadHistoryTable();
- }).fail(nf.Common.handleAjaxError);
+ nfHistoryTable.loadHistoryTable();
+ }).fail(errorHandler.handleAjaxError);
};
/**
@@ -397,19 +461,19 @@ nf.HistoryTable = (function () {
var showActionDetails = function (action) {
// create the markup for the dialog
var detailsMarkup = $('<div></div>').append(
- $('<div class="action-detail"><div class="history-details-name">Id</div>' + nf.Common.escapeHtml(action.sourceId) + '</div>'));
+ $('<div class="action-detail"><div class="history-details-name">Id</div>' + common.escapeHtml(action.sourceId) + '</div>'));
// get any component details
var componentDetails = action.componentDetails;
// inspect the operation to determine if there are any component details
- if (nf.Common.isDefinedAndNotNull(componentDetails)) {
+ if (common.isDefinedAndNotNull(componentDetails)) {
if (action.sourceType === 'Processor' || action.sourceType === 'ControllerService' || action.sourceType === 'ReportingTask') {
detailsMarkup.append(
- $('<div class="action-detail"><div class="history-details-name">Type</div>' + nf.Common.escapeHtml(componentDetails.type) + '</div>'));
+ $('<div class="action-detail"><div class="history-details-name">Type</div>' + common.escapeHtml(componentDetails.type) + '</div>'));
} else if (action.sourceType === 'RemoteProcessGroup') {
detailsMarkup.append(
- $('<div class="action-detail"><div class="history-details-name">Uri</div>' + nf.Common.formatValue(componentDetails.uri) + '</div>'));
+ $('<div class="action-detail"><div class="history-details-name">Uri</div>' + common.formatValue(componentDetails.uri) + '</div>'));
}
}
@@ -417,30 +481,30 @@ nf.HistoryTable = (function () {
var actionDetails = action.actionDetails;
// inspect the operation to determine if there are any action details
- if (nf.Common.isDefinedAndNotNull(actionDetails)) {
+ if (common.isDefinedAndNotNull(actionDetails)) {
if (action.operation === 'Configure') {
detailsMarkup.append(
- $('<div class="action-detail"><div class="history-details-name">Name</div>' + nf.Common.formatValue(actionDetails.name) + '</div>')).append(
- $('<div class="action-detail"><div class="history-details-name">Value</div>' + nf.Common.formatValue(actionDetails.value) + '</div>')).append(
- $('<div class="action-detail"><div class="history-details-name">Previous Value</div>' + nf.Common.formatValue(actionDetails.previousValue) + '</div>'));
+ $('<div class="action-detail"><div class="history-details-name">Name</div>' + common.formatValue(actionDetails.name) + '</div>')).append(
+ $('<div class="action-detail"><div class="history-details-name">Value</div>' + common.formatValue(actionDetails.value) + '</div>')).append(
+ $('<div class="action-detail"><div class="history-details-name">Previous Value</div>' + common.formatValue(actionDetails.previousValue) + '</div>'));
} else if (action.operation === 'Connect' || action.operation === 'Disconnect') {
detailsMarkup.append(
- $('<div class="action-detail"><div class="history-details-name">Source Id</div>' + nf.Common.escapeHtml(actionDetails.sourceId) + '</div>')).append(
- $('<div class="action-detail"><div class="history-details-name">Source Name</div>' + nf.Common.formatValue(actionDetails.sourceName) + '</div>')).append(
- $('<div class="action-detail"><div class="history-details-name">Source Type</div>' + nf.Common.escapeHtml(actionDetails.sourceType) + '</div>')).append(
- $('<div class="action-detail"><div class="history-details-name">Relationship(s)</div>' + nf.Common.formatValue(actionDetails.relationship) + '</div>')).append(
- $('<div class="action-detail"><div class="history-details-name">Destination Id</div>' + nf.Common.escapeHtml(actionDetails.destinationId) + '</div>')).append(
- $('<div class="action-detail"><div class="history-details-name">Destination Name</div>' + nf.Common.formatValue(actionDetails.destinationName) + '</div>')).append(
- $('<div class="action-detail"><div class="history-details-name">Destination Type</div>' + nf.Common.escapeHtml(actionDetails.destinationType) + '</div>'));
+ $('<div class="action-detail"><div class="history-details-name">Source Id</div>' + common.escapeHtml(actionDetails.sourceId) + '</div>')).append(
+ $('<div class="action-detail"><div class="history-details-name">Source Name</div>' + common.formatValue(actionDetails.sourceName) + '</div>')).append(
+ $('<div class="action-detail"><div class="history-details-name">Source Type</div>' + common.escapeHtml(actionDetails.sourceType) + '</div>')).append(
+ $('<div class="action-detail"><div class="history-details-name">Relationship(s)</div>' + common.formatValue(actionDetails.relationship) + '</div>')).append(
+ $('<div class="action-detail"><div class="history-details-name">Destination Id</div>' + common.escapeHtml(actionDetails.destinationId) + '</div>')).append(
+ $('<div class="action-detail"><div class="history-details-name">Destination Name</div>' + common.formatValue(actionDetails.destinationName) + '</div>')).append(
+ $('<div class="action-detail"><div class="history-details-name">Destination Type</div>' + common.escapeHtml(actionDetails.destinationType) + '</div>'));
} else if (action.operation === 'Move') {
detailsMarkup.append(
- $('<div class="action-detail"><div class="history-details-name">Group</div>' + nf.Common.formatValue(actionDetails.group) + '</div>')).append(
- $('<div class="action-detail"><div class="history-details-name">Group Id</div>' + nf.Common.escapeHtml(actionDetails.groupId) + '</div>')).append(
- $('<div class="action-detail"><div class="history-details-name">Previous Group</div>' + nf.Common.formatValue(actionDetails.previousGroup) + '</div>')).append(
- $('<div class="action-detail"><div class="history-details-name">Previous Group Id</div>' + nf.Common.escapeHtml(actionDetails.previousGroupId) + '</div>'));
+ $('<div class="action-detail"><div class="history-details-name">Group</div>' + common.formatValue(actionDetails.group) + '</div>')).append(
+ $('<div class="action-detail"><div class="history-details-name">Group Id</div>' + common.escapeHtml(actionDetails.groupId) + '</div>')).append(
+ $('<div class="action-detail"><div class="history-details-name">Previous Group</div>' + common.formatValue(actionDetails.previousGroup) + '</div>')).append(
+ $('<div class="action-detail"><div class="history-details-name">Previous Group Id</div>' + common.escapeHtml(actionDetails.previousGroupId) + '</div>'));
} else if (action.operation === 'Purge') {
detailsMarkup.append(
- $('<div class="action-detail"><div class="history-details-name">End Date</div>' + nf.Common.escapeHtml(actionDetails.endDate) + '</div>'));
+ $('<div class="action-detail"><div class="history-details-name">End Date</div>' + common.escapeHtml(actionDetails.endDate) + '</div>'));
}
}
@@ -451,7 +515,7 @@ nf.HistoryTable = (function () {
$('#action-details-dialog').modal('show');
};
- return {
+ var nfHistoryTable = {
init: function () {
initDetailsDialog();
initFilterDialog();
@@ -464,7 +528,7 @@ nf.HistoryTable = (function () {
*/
resetTableSize: function () {
var historyGrid = $('#history-table').data('gridInstance');
- if (nf.Common.isDefinedAndNotNull(historyGrid)) {
+ if (common.isDefinedAndNotNull(historyGrid)) {
historyGrid.resizeCanvas();
}
},
@@ -483,4 +547,6 @@ nf.HistoryTable = (function () {
historyGrid.onViewportChanged.notify();
}
};
-}());
+
+ return nfHistoryTable;
+}));
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/history/nf-history.js
----------------------------------------------------------------------
diff --git a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/js/nf/history/nf-history.js b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/js/nf/history/nf-history.js
index 0f436e9..7f73724 100644
--- a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/js/nf/history/nf-history.js
+++ b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/js/nf/history/nf-history.js
@@ -15,14 +15,42 @@
* limitations under the License.
*/
-/* global nf, top */
-
-$(document).ready(function () {
- // initialize the status page
- nf.History.init();
-});
-
-nf.History = (function () {
+/* global nf, top, define, module, require, exports */
+
+(function (root, factory) {
+ if (typeof define === 'function' && define.amd) {
+ define(['jquery',
+ 'nf.Common',
+ 'nf.HistoryTable',
+ 'nf.ErrorHandler',
+ 'nf.Storage',
+ 'nf.ClusterSummary'],
+ function ($, common, historyTable, errorHandler, storage, clusterSummary) {
+ return (nf.History = factory($, common, historyTable, errorHandler, storage, clusterSummary));
+ });
+ } else if (typeof exports === 'object' && typeof module === 'object') {
+ module.exports = (nf.History =
+ factory(require('jquery'),
+ require('nf.Common'),
+ require('nf.HistoryTable'),
+ require('nf.ErrorHandler'),
+ require('nf.Storage'),
+ require('nf.ClusterSummary')));
+ } else {
+ nf.History = factory(root.$,
+ root.nf.Common,
+ root.nf.HistoryTable,
+ root.nf.ErrorHandler,
+ root.nf.Storage,
+ root.nf.ClusterSummary);
+ }
+}(this, function ($, common, historyTable, errorHandler, storage, clusterSummary) {
+ 'use strict';
+
+ $(document).ready(function () {
+ // initialize the status page
+ nfHistory.init();
+ });
/**
* Configuration object used to hold a number of configuration items.
@@ -31,8 +59,7 @@ nf.History = (function () {
urls: {
banners: '../nifi-api/flow/banners',
about: '../nifi-api/flow/about',
- currentUser: '../nifi-api/flow/current-user',
- clusterSummary: '../nifi-api/flow/cluster/summary'
+ currentUser: '../nifi-api/flow/current-user'
}
};
@@ -45,28 +72,8 @@ nf.History = (function () {
url: config.urls.currentUser,
dataType: 'json'
}).done(function (currentUser) {
- nf.Common.setCurrentUser(currentUser);
- }).fail(nf.Common.handleAjaxError);
- };
-
- /**
- * Loads the flow configuration and updated the cluster state.
- *
- * @returns xhr
- */
- var loadClusterSummary = function () {
- return $.ajax({
- type: 'GET',
- url: config.urls.clusterSummary,
- dataType: 'json'
- }).done(function (response) {
- var clusterSummary = response.clusterSummary;
-
- // if clustered, show message to indicate location of actions
- if (clusterSummary.clustered === true) {
- $('#cluster-history-message').show();
- }
- });
+ common.setCurrentUser(currentUser);
+ }).fail(errorHandler.handleAjaxError);
};
/**
@@ -75,7 +82,7 @@ nf.History = (function () {
var initializeHistoryPage = function () {
// define mouse over event for the refresh button
$('#refresh-button').click(function () {
- nf.HistoryTable.loadHistoryTable();
+ historyTable.loadHistoryTable();
});
// return a deferred for page initialization
@@ -88,8 +95,8 @@ nf.History = (function () {
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 !== '') {
+ 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();
@@ -103,7 +110,7 @@ nf.History = (function () {
updateTop('history');
}
- if (nf.Common.isDefinedAndNotNull(response.banners.footerText) && response.banners.footerText !== '') {
+ 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();
@@ -119,7 +126,7 @@ nf.History = (function () {
deferred.resolve();
}).fail(function (xhr, status, error) {
- nf.Common.handleAjaxError(xhr, status, error);
+ errorHandler.handleAjaxError(xhr, status, error);
deferred.reject();
});
} else {
@@ -128,22 +135,28 @@ nf.History = (function () {
}).promise();
};
- return {
+ var nfHistory = {
/**
* Initializes the status page.
*/
init: function () {
- nf.Storage.init();
-
// load the current user
- loadCurrentUser().done(function () {
- loadClusterSummary();
+ var currentUser = loadCurrentUser()
+
+ storage.init();
+
+ // ensure the config requests are loaded
+ $.when(currentUser).done(function (currentUserResult) {
+ // if clustered, show message to indicate location of actions
+ if (clusterSummary.isClustered() === true) {
+ $('#cluster-history-message').show();
+ }
// create the history table
- nf.HistoryTable.init();
+ historyTable.init();
// load the history table
- nf.HistoryTable.loadHistoryTable();
+ historyTable.loadHistoryTable();
// once the table is initialized, finish initializing the page
initializeHistoryPage().done(function () {
@@ -154,13 +167,13 @@ nf.History = (function () {
'height': $(window).height() + 'px',
'width': $(window).width() + 'px'
});
-
+
$('#history').css('margin', 40);
$('#history-refresh-container').css('margin', 40);
}
// configure the initial grid height
- nf.HistoryTable.resetTableSize();
+ historyTable.resetTableSize();
};
// get the about details
@@ -178,15 +191,15 @@ nf.History = (function () {
// set the initial size
setBodySize();
- }).fail(nf.Common.handleAjaxError);
+ }).fail(errorHandler.handleAjaxError);
$(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){
+ if ($(dialogs[i]).is(':visible')) {
+ setTimeout(function (dialog) {
dialog.modal('resize');
}, 50, $(dialogs[i]));
}
@@ -195,8 +208,8 @@ nf.History = (function () {
// 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){
+ if ($(gridElements[j]).is(':visible')) {
+ setTimeout(function (gridElement) {
gridElement.data('gridInstance').resizeCanvas();
}, 50, $(gridElements[j]));
}
@@ -206,16 +219,18 @@ nf.History = (function () {
var tabsContainers = $('.tab-container');
var tabsContents = [];
for (var k = 0, len = tabsContainers.length; k < len; k++) {
- if ($(tabsContainers[k]).is(':visible')){
+ if ($(tabsContainers[k]).is(':visible')) {
tabsContents.push($('#' + $(tabsContainers[k]).attr('id') + '-content'));
}
}
$.each(tabsContents, function (index, tabsContent) {
- nf.Common.toggleScrollable(tabsContent.get(0));
+ common.toggleScrollable(tabsContent.get(0));
});
});
});
});
}
};
-}());
\ No newline at end of file
+
+ return nfHistory;
+}));
\ 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/login/nf-login.js
----------------------------------------------------------------------
diff --git a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/js/nf/login/nf-login.js b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/js/nf/login/nf-login.js
index 11faba5..a18d5d7 100644
--- a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/js/nf/login/nf-login.js
+++ b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/js/nf/login/nf-login.js
@@ -15,13 +15,32 @@
* limitations under the License.
*/
-/* global nf, top */
-
-$(document).ready(function () {
- nf.Login.init();
-});
-
-nf.Login = (function () {
+/* global nf, top, define, module, require, exports */
+
+(function (root, factory) {
+ if (typeof define === 'function' && define.amd) {
+ define(['jquery',
+ 'nf.Common',
+ 'nf.Dialog',
+ 'nf.Storage'],
+ function ($, common, dialog, storage) {
+ return (nf.Login = factory($, common, dialog, storage));
+ });
+ } else if (typeof exports === 'object' && typeof module === 'object') {
+ module.exports = (nf.Login =
+ factory(require('jquery'),
+ require('nf.Common'),
+ require('nf.Dialog'),
+ require('nf.Storage')));
+ } else {
+ nf.Login = factory(root.$, root.nf.Common, root.nf.Dialog, root.nf.Storage);
+ }
+}(this, function ($, common, dialog, storage) {
+ 'use strict';
+
+ $(document).ready(function () {
+ nfLogin.init();
+ });
var config = {
urls: {
@@ -62,12 +81,12 @@ nf.Login = (function () {
var login = function () {
// remove focus
$('#username, #password').blur();
-
+
// show the logging message...
$('#login-progress-label').text('Logging in...');
$('#login-progress-container').show();
$('#login-submission-container').hide();
-
+
// login submit
$.ajax({
type: 'POST',
@@ -78,9 +97,9 @@ nf.Login = (function () {
}
}).done(function (jwt) {
// get the payload and store the token with the appropirate expiration
- var token = nf.Common.getJwtPayload(jwt);
- var expiration = parseInt(token['exp'], 10) * nf.Common.MILLIS_PER_SECOND;
- nf.Storage.setItem('jwt', jwt, expiration);
+ var token = common.getJwtPayload(jwt);
+ var expiration = parseInt(token['exp'], 10) * common.MILLIS_PER_SECOND;
+ storage.setItem('jwt', jwt, expiration);
// check to see if they actually have access now
$.ajax({
@@ -89,10 +108,10 @@ nf.Login = (function () {
dataType: 'json'
}).done(function (response) {
var accessStatus = response.accessStatus;
-
+
// update the logout link appropriately
showLogoutLink();
-
+
// update according to the access status
if (accessStatus.status === 'ACTIVE') {
// reload as appropriate - no need to schedule token refresh as the page is reloading
@@ -122,9 +141,9 @@ nf.Login = (function () {
$('#login-message-container').show();
});
}).fail(function (xhr, status, error) {
- nf.Dialog.showOkDialog({
+ dialog.showOkDialog({
headerText: 'Login',
- dialogContent: nf.Common.escapeHtml(xhr.responseText)
+ dialogContent: common.escapeHtml(xhr.responseText)
});
// update the form visibility
@@ -134,20 +153,20 @@ nf.Login = (function () {
};
var showLogoutLink = function () {
- nf.Common.showLogoutLink();
+ common.showLogoutLink();
};
- return {
+ var nfLogin = {
/**
* Initializes the login page.
*/
init: function () {
- nf.Storage.init();
+ storage.init();
- if (nf.Storage.getItem('jwt') !== null) {
+ if (storage.getItem('jwt') !== null) {
showLogoutLink();
}
-
+
// supporting logging in via enter press
$('#username, #password').on('keyup', function (e) {
var code = e.keyCode ? e.keyCode : e.which;
@@ -166,7 +185,7 @@ nf.Login = (function () {
$('#login-message').text(xhr.responseText);
initializeMessage();
});
-
+
// access config
var accessConfigXhr = $.ajax({
type: 'GET',
@@ -180,22 +199,22 @@ nf.Login = (function () {
var accessConfigResponse = accessConfigResult[0];
var accessConfig = accessConfigResponse.config;
-
+
// possible login states
var needsLogin = true;
var showMessage = false;
-
+
// handle the status appropriately
if (accessStatus.status === 'UNKNOWN') {
needsLogin = true;
} else if (accessStatus.status === 'ACTIVE') {
showMessage = true;
needsLogin = false;
-
+
$('#login-message-title').text('Success');
$('#login-message').text(accessStatus.message);
}
-
+
// if login is required, verify its supported
if (accessConfig.supportsLogin === false && needsLogin === true) {
$('#login-message-title').text('Access Denied');
@@ -214,4 +233,6 @@ nf.Login = (function () {
});
}
};
-}());
\ No newline at end of file
+
+ return nfLogin;
+}));
\ 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-ajax-setup.js
----------------------------------------------------------------------
diff --git a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/js/nf/nf-ajax-setup.js b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/js/nf/nf-ajax-setup.js
index ad540b8..eaf61cf 100644
--- a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/js/nf/nf-ajax-setup.js
+++ b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/js/nf/nf-ajax-setup.js
@@ -15,25 +15,43 @@
* limitations under the License.
*/
-/**
- * Performs ajax setup for use within NiFi.
- */
-$(document).ready(function ($) {
- // include jwt when possible
- $.ajaxSetup({
- 'beforeSend': function(xhr) {
- var hadToken = nf.Storage.hasItem('jwt');
+/* global nf, define, module, require, exports */
+
+(function (root, factory) {
+ if (typeof define === 'function' && define.amd) {
+ define(['jquery',
+ 'nf.Storage'],
+ function ($, storage) {
+ return (nf.AjaxSetup = factory($, storage));
+ });
+ } else if (typeof exports === 'object' && typeof module === 'object') {
+ module.exports = (nf.AjaxSetup = factory(require('jquery'),
+ require('nf.Storage')));
+ } else {
+ nf.AjaxSetup = factory(root.$,
+ root.nf.Storage);
+ }
+}(this, function ($, storage) {
+ /**
+ * Performs ajax setup for use within NiFi.
+ */
+ $(document).ready(function ($) {
+ // include jwt when possible
+ $.ajaxSetup({
+ 'beforeSend': function (xhr) {
+ var hadToken = storage.hasItem('jwt');
- // get the token to include in all requests
- var token = nf.Storage.getItem('jwt');
- if (token !== null) {
- xhr.setRequestHeader('Authorization', 'Bearer ' + token);
- } else {
- // if the current user was logged in with a token and the token just expired, cancel the request
- if (hadToken === true) {
- return false;
+ // get the token to include in all requests
+ var token = storage.getItem('jwt');
+ if (token !== null) {
+ xhr.setRequestHeader('Authorization', 'Bearer ' + token);
+ } else {
+ // if the current user was logged in with a token and the token just expired, cancel the request
+ if (hadToken === true) {
+ return false;
+ }
}
}
- }
+ });
});
-});
\ 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-client.js
----------------------------------------------------------------------
diff --git a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/js/nf/nf-client.js b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/js/nf/nf-client.js
index 3cf9fdf..aedd555 100644
--- a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/js/nf/nf-client.js
+++ b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/js/nf/nf-client.js
@@ -15,15 +15,33 @@
* limitations under the License.
*/
-/* global nf */
+/* global nf, define, module, require, exports */
+
+(function (root, factory) {
+ if (typeof define === 'function' && define.amd) {
+ define(['jquery',
+ 'nf.Common'],
+ function ($, common) {
+ return (nf.Client = factory($, common));
+ });
+ } else if (typeof exports === 'object' && typeof module === 'object') {
+ module.exports = (nf.Client =
+ factory(require('jquery'),
+ require('nf.Common')));
+ } else {
+ nf.Client =
+ factory(root.$,
+ root.nf.Common);
+ }
+}(this, function ($, common) {
+ 'use strict';
-nf.Client = (function() {
var clientId = null;
-
+
return {
/**
* Initializes the client.
- *
+ *
* @returns deferred
*/
init: function () {
@@ -55,7 +73,7 @@ nf.Client = (function() {
* @return {boolean} whether proposedData is newer than currentData
*/
isNewerRevision: function (currentData, proposedData) {
- if (nf.Common.isDefinedAndNotNull(currentData)) {
+ if (common.isDefinedAndNotNull(currentData)) {
var currentRevision = currentData.revision;
var proposedRevision = proposedData.revision;
@@ -66,4 +84,4 @@ nf.Client = (function() {
}
}
};
-}());
\ 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-cluster-summary.js
----------------------------------------------------------------------
diff --git a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/js/nf/nf-cluster-summary.js b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/js/nf/nf-cluster-summary.js
new file mode 100644
index 0000000..1352843
--- /dev/null
+++ b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/js/nf/nf-cluster-summary.js
@@ -0,0 +1,81 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/* global nf, define, module, require, exports */
+
+(function (root, factory) {
+ if (typeof define === 'function' && define.amd) {
+ define(['jquery'], function ($) {
+ return (nf.ClusterSummary = factory($));
+ });
+ } else if (typeof exports === 'object' && typeof module === 'object') {
+ module.exports = (nf.ClusterSummary =
+ factory(require('jquery')));
+ } else {
+ nf.ClusterSummary = factory(root.$);
+ }
+}(this, function ($) {
+ var clustered = false;
+ var connectedToCluster = false;
+
+ var config = {
+ urls: {
+ clusterSummary: '../nifi-api/flow/cluster/summary'
+ }
+ };
+
+ return {
+
+ /**
+ * Loads the flow configuration and updated the cluster state.
+ *
+ * @returns xhr
+ */
+ loadClusterSummary: function () {
+ return $.ajax({
+ type: 'GET',
+ url: config.urls.clusterSummary,
+ dataType: 'json'
+ }).done(function (clusterSummaryResult) {
+ var clusterSummaryResponse = clusterSummaryResult;
+ var clusterSummary = clusterSummaryResponse.clusterSummary;
+
+ // establish the initial cluster state
+ clustered = clusterSummary.clustered;
+ connectedToCluster = clusterSummary.connectedToCluster;
+ });
+ },
+
+ /**
+ * Return whether this instance of NiFi is clustered.
+ *
+ * @returns {Boolean}
+ */
+ isClustered: function () {
+ return clustered === true;
+ },
+
+ /**
+ * Return whether this instance is connected to a cluster.
+ *
+ * @returns {boolean}
+ */
+ isConnectedToCluster: function () {
+ return connectedToCluster === true;
+ }
+ };
+}));
\ No newline at end of file