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 2016/05/12 16:42:01 UTC
[4/7] nifi git commit: NIFI-1742: - Addressing issues when creating a
new inline controller service. - Ensuring controller service referencing
components are updated. - Including revisions and status with each component.
- Dynamically updating component
http://git-wip-us.apache.org/repos/asf/nifi/blob/3cc16d35/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/js/nf/canvas/nf-actions.js
----------------------------------------------------------------------
diff --git a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/js/nf/canvas/nf-actions.js b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/js/nf/canvas/nf-actions.js
index 54314e9..67871f4 100644
--- a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/js/nf/canvas/nf-actions.js
+++ b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/js/nf/canvas/nf-actions.js
@@ -60,18 +60,12 @@ nf.Actions = (function () {
* @param {object} entity
*/
var updateResource = function (uri, entity) {
- // add the revision
- entity['revision'] = nf.Client.getRevision();
-
return $.ajax({
type: 'PUT',
url: uri,
data: JSON.stringify(entity),
dataType: 'json',
contentType: 'application/json'
- }).done(function (response) {
- // update the revision
- nf.Client.setRevision(response.revision);
}).fail(function (xhr, status, error) {
if (xhr.status === 400 || xhr.status === 404 || xhr.status === 409) {
nf.Dialog.showOkDialog({
@@ -404,6 +398,7 @@ nf.Actions = (function () {
// build the entity
var entity = {
+ 'revision': nf.Client.getRevision(d),
'component': {
'id': d.id,
'state': 'STOPPED'
@@ -446,6 +441,7 @@ nf.Actions = (function () {
// build the entity
var entity = {
+ 'revision': nf.Client.getRevision(d),
'component': {
'id': d.id,
'state': 'DISABLED'
@@ -528,6 +524,7 @@ nf.Actions = (function () {
// build the entity
var entity = {
+ 'revision': nf.Client.getRevision(d),
'component': component
};
@@ -602,6 +599,7 @@ nf.Actions = (function () {
// build the entity
var entity = {
+ 'revision': nf.Client.getRevision(d),
'component': component
};
@@ -644,6 +642,7 @@ nf.Actions = (function () {
componentsToEnable.each(function (d) {
// build the entity
var entity = {
+ 'revision': nf.Client.getRevision(d),
'component': {
'id': d.id,
'transmitting': true
@@ -671,6 +670,7 @@ nf.Actions = (function () {
componentsToDisable.each(function (d) {
// build the entity
var entity = {
+ 'revision': nf.Client.getRevision(d),
'component': {
'id': d.id,
'transmitting': false
@@ -772,8 +772,10 @@ nf.Actions = (function () {
/**
* Reloads the status for the entire canvas (components and flow.)
*/
- reloadStatus: function () {
- nf.Canvas.reloadStatus();
+ reload: function () {
+ nf.Canvas.reload({
+ 'transition': true
+ });
},
/**
@@ -790,7 +792,7 @@ nf.Actions = (function () {
} else {
if (selection.size() === 1) {
var selectionData = selection.datum();
- var revision = nf.Client.getRevision();
+ var revision = nf.Client.getRevision(selectionData);
$.ajax({
type: 'DELETE',
@@ -800,9 +802,6 @@ nf.Actions = (function () {
}),
dataType: 'json'
}).done(function (response) {
- // update the revision
- nf.Client.setRevision(response.revision);
-
// remove the component/connection in question
nf[selectionData.type].remove(selectionData.id);
@@ -828,11 +827,9 @@ nf.Actions = (function () {
} else {
// create a snippet for the specified component and link to the data flow
var snippetDetails = nf.Snippet.marshal(selection, true);
- nf.Snippet.create(snippetDetails).done(function (response) {
- var snippet = response.snippet;
-
+ nf.Snippet.create(snippetDetails).done(function (snippetEntity) {
// remove the snippet, effectively removing the components
- nf.Snippet.remove(snippet.id).done(function () {
+ nf.Snippet.remove(snippetEntity).done(function () {
var components = d3.map();
// add the id to the type's array
@@ -876,11 +873,11 @@ nf.Actions = (function () {
// inform Angular app values have changed
nf.ng.Bridge.digest();
}).fail(function (xhr, status, error) {
- // unable to acutally remove the components so attempt to
+ // unable to actually remove the components so attempt to
// unlink and remove just the snippet - if unlinking fails
// just ignore
- nf.Snippet.unlink(snippet.id).done(function () {
- nf.Snippet.remove(snippet.id);
+ nf.Snippet.unlink(snippetEntity).done(function (unlinkedSnippetEntity) {
+ nf.Snippet.remove(unlinkedSnippetEntity);
});
nf.Common.handleAjaxError(xhr, status, error);
@@ -1092,7 +1089,7 @@ nf.Actions = (function () {
var processor = selection.datum();
// view the state for the selected processor
- nf.ComponentState.showState(processor.component, nf.CanvasUtils.supportsModification(selection));
+ nf.ComponentState.showState(processor.component, processor.revision, nf.CanvasUtils.supportsModification(selection));
},
/**
@@ -1228,12 +1225,11 @@ nf.Actions = (function () {
var snippetDetails = nf.Snippet.marshal(selection, false);
// create the snippet
- nf.Snippet.create(snippetDetails).done(function (response) {
- var snippet = response.snippet;
+ nf.Snippet.create(snippetDetails).done(function (snippetEntity) {
var createSnippetEntity = {
'name': templateName,
'description': templateDescription,
- 'snippetId': snippet.id
+ 'snippetId': snippetEntity.id
};
// create the template
@@ -1251,7 +1247,7 @@ nf.Actions = (function () {
});
}).always(function () {
// remove the snippet
- nf.Snippet.remove(snippet.id);
+ nf.Snippet.remove(snippetEntity);
// clear the template dialog fields
$('#new-template-name').val('');
@@ -1327,9 +1323,7 @@ nf.Actions = (function () {
};
// create a snippet from the details
- nf.Snippet.create(data['snippet']).done(function (createResponse) {
- var snippet = createResponse.snippet;
-
+ nf.Snippet.create(data['snippet']).done(function (snippetEntity) {
// determine the origin of the bounding box of the copy
var origin = pasteLocation;
var snippetOrigin = data['origin'];
@@ -1342,7 +1336,7 @@ nf.Actions = (function () {
}
// copy the snippet to the new location
- nf.Snippet.copy(snippet.id, origin).done(function (copyResponse) {
+ nf.Snippet.copy(snippetEntity.id, origin).done(function (copyResponse) {
var snippetFlow = copyResponse.flow;
// update the graph accordingly
@@ -1355,7 +1349,7 @@ nf.Actions = (function () {
nf.Birdseye.refresh();
// remove the original snippet
- nf.Snippet.remove(snippet.id).fail(reject);
+ nf.Snippet.remove(snippetEntity).fail(reject);
}).fail(function () {
// an error occured while performing the copy operation, reload the
// graph in case it was a partial success
@@ -1414,7 +1408,7 @@ nf.Actions = (function () {
// build the connection entity
var connectionEntity = {
- 'revision': nf.Client.getRevision(),
+ 'revision': nf.Client.getRevision(connection),
'component': {
'id': connection.id,
'zIndex': zIndex
@@ -1432,9 +1426,6 @@ nf.Actions = (function () {
// update the edge's zIndex
nf.Connection.set(response);
nf.Connection.reorder();
-
- // update the revision
- nf.Client.setRevision(response.revision);
});
}
}
http://git-wip-us.apache.org/repos/asf/nifi/blob/3cc16d35/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/js/nf/canvas/nf-canvas-utils.js
----------------------------------------------------------------------
diff --git a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/js/nf/canvas/nf-canvas-utils.js b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/js/nf/canvas/nf-canvas-utils.js
index 655dedb..7288dd3 100644
--- a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/js/nf/canvas/nf-canvas-utils.js
+++ b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/js/nf/canvas/nf-canvas-utils.js
@@ -57,11 +57,9 @@ nf.CanvasUtils = (function () {
nf.CanvasUtils.eligibleForMove(components, groupId).done(function () {
// create a snippet for the specified components and link to the data flow
var snippetDetails = nf.Snippet.marshal(components, true);
- nf.Snippet.create(snippetDetails).done(function (response) {
- var snippet = response.snippet;
-
+ nf.Snippet.create(snippetDetails).done(function (snippetEntity) {
// move the snippet into the target
- nf.Snippet.move(snippet.id, groupId).done(function () {
+ nf.Snippet.move(snippetEntity, groupId).done(function () {
var componentMap = d3.map();
// add the id to the type's array
@@ -90,8 +88,8 @@ nf.CanvasUtils = (function () {
}).always(function () {
// unable to acutally move the components so attempt to
// unlink and remove just the snippet
- nf.Snippet.unlink(snippet.id).done(function () {
- nf.Snippet.remove(snippet.id);
+ nf.Snippet.unlink(snippetEntity).done(function (unlinkedSnippetEntity) {
+ nf.Snippet.remove(unlinkedSnippetEntity);
});
});
}).fail(nf.Common.handleAjaxError).fail(function () {
@@ -200,7 +198,10 @@ nf.CanvasUtils = (function () {
var refreshGraph = $.Deferred(function (deferred) {
// load a different group if necessary
if (groupId !== nf.Canvas.getGroupId()) {
+ // set the new group id
nf.Canvas.setGroupId(groupId);
+
+ // reload
nf.Canvas.reload().done(function () {
deferred.resolve();
}).fail(function () {
@@ -258,21 +259,60 @@ nf.CanvasUtils = (function () {
// calculate the difference between the center point and the position of this component and convert to screen space
nf.Canvas.View.translate([(center[0] - boundingBox.x) * scale, (center[1] - boundingBox.y) * scale]);
},
+
+ /**
+ * Enables/disables the editable behavior for the specified selection based on their access policies.
+ *
+ * @param selection selection
+ */
+ editable: function (selection) {
+ var selectionData = selection.datum();
+
+ if (selectionData.accessPolicy.canWrite && selectionData.accessPolicy.canRead) {
+ if (!selection.classed('connectable')) {
+ selection.call(nf.Connectable.activate);
+ }
+ if (!selection.classed('moveable')) {
+ selection.call(nf.Draggable.activate);
+ }
+ } else {
+ if (selection.classed('connectable')) {
+ selection.call(nf.Connectable.deactivate);
+ }
+ if (selection.classed('moveable')) {
+ selection.call(nf.Draggable.deactivate);
+ }
+ }
+ },
/**
+ * Conditionally apply the transition.
+ *
+ * @param selection selection
+ * @param transition transition
+ */
+ transition: function (selection, transition) {
+ if (transition && !selection.empty()) {
+ return selection.transition().duration(400);
+ } else {
+ return selection;
+ }
+ },
+
+ /**
* Position the component accordingly.
*
* @param {selection} updated
*/
- position: function (updated) {
+ position: function (updated, transition) {
if (updated.empty()) {
return;
}
-
- // update the processors positioning
- updated.attr('transform', function (d) {
- return 'translate(' + d.position.x + ', ' + d.position.y + ')';
- });
+
+ return nf.CanvasUtils.transition(updated, transition)
+ .attr('transform', function (d) {
+ return 'translate(' + d.position.x + ', ' + d.position.y + ')';
+ });
},
/**
@@ -458,7 +498,7 @@ nf.CanvasUtils = (function () {
}
// if there are bulletins show them, otherwise hide
- if (nf.Common.isDefinedAndNotNull(d.status) && !nf.Common.isEmpty(d.status.bulletins)) {
+ if (!nf.Common.isEmpty(d.status.bulletins)) {
// update the tooltip
selection.select('text.bulletin-icon')
.each(function () {
@@ -1135,9 +1175,6 @@ nf.CanvasUtils = (function () {
// set the new group id
nf.Canvas.setGroupId(groupId);
- // clear the current components
- nf.Graph.removeAll();
-
// reload the graph
return nf.Canvas.reload().done(function () {
// attempt to restore the view
http://git-wip-us.apache.org/repos/asf/nifi/blob/3cc16d35/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/js/nf/canvas/nf-canvas.js
----------------------------------------------------------------------
diff --git a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/js/nf/canvas/nf-canvas.js b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/js/nf/canvas/nf-canvas.js
index 9cd11d8..f7e6cd2 100644
--- a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/js/nf/canvas/nf-canvas.js
+++ b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/js/nf/canvas/nf-canvas.js
@@ -108,8 +108,7 @@ nf.Canvas = (function () {
var MIN_SCALE = 0.2;
var MIN_SCALE_TO_RENDER = 0.6;
- var revisionPolling = false;
- var statusPolling = false;
+ var polling = false;
var groupId = 'root';
var groupName = null;
var parentGroupId = null;
@@ -135,58 +134,31 @@ nf.Canvas = (function () {
};
/**
- * Starts polling for the revision.
+ * Starts polling.
*
* @argument {int} autoRefreshInterval The auto refresh interval
*/
- var startRevisionPolling = function (autoRefreshInterval) {
+ var startPolling = function (autoRefreshInterval) {
// set polling flag
- revisionPolling = true;
- pollForRevision(autoRefreshInterval);
+ polling = true;
+ poll(autoRefreshInterval);
};
/**
- * Polls for the revision.
+ * Register the pooler.
*
* @argument {int} autoRefreshInterval The auto refresh interval
*/
- var pollForRevision = function (autoRefreshInterval) {
+ var poll = function (autoRefreshInterval) {
// ensure we're suppose to poll
- if (revisionPolling) {
- // check the revision
- checkRevision().done(function () {
- // start the wait to poll again
- setTimeout(function () {
- pollForRevision(autoRefreshInterval);
- }, autoRefreshInterval * 1000);
- });
- }
- };
-
- /**
- * Start polling for the status.
- *
- * @argument {int} autoRefreshInterval The auto refresh interval
- */
- var startStatusPolling = function (autoRefreshInterval) {
- // set polling flag
- statusPolling = true;
- pollForStatus(autoRefreshInterval);
- };
-
- /**
- * Register the status poller.
- *
- * @argument {int} autoRefreshInterval The auto refresh interval
- */
- var pollForStatus = function (autoRefreshInterval) {
- // ensure we're suppose to poll
- if (statusPolling) {
+ if (polling) {
// reload the status
- nf.Canvas.reloadStatus().done(function () {
+ nf.Canvas.reload({
+ 'transition': true
+ }).done(function () {
// start the wait to poll again
setTimeout(function () {
- pollForStatus(autoRefreshInterval);
+ poll(autoRefreshInterval);
}, autoRefreshInterval * 1000);
});
}
@@ -195,50 +167,50 @@ nf.Canvas = (function () {
/**
* Checks the current revision against this version of the flow.
*/
- var checkRevision = function () {
- // get the revision
- return $.ajax({
- type: 'GET',
- url: config.urls.revision,
- dataType: 'json'
- }).done(function (response) {
- if (nf.Common.isDefinedAndNotNull(response.revision)) {
- var revision = response.revision;
- var currentRevision = nf.Client.getRevision();
-
- // if there is a newer revision, there are outstanding
- // changes that need to be updated
- if (revision.version > currentRevision.version && revision.clientId !== currentRevision.clientId) {
- var refreshContainer = $('#refresh-required-container');
- var settingsRefreshIcon = $('#settings-refresh-required-icon');
-
- // insert the refresh needed text in the canvas - if necessary
- if (!refreshContainer.is(':visible')) {
- $('#stats-last-refreshed').addClass('alert');
- var refreshMessage = "This flow has been modified by '" + revision.lastModifier + "'. Please refresh.";
-
- // update the tooltip
- var refreshRequiredIcon = $('#refresh-required-icon');
- if (refreshRequiredIcon.data('qtip')) {
- refreshRequiredIcon.qtip('option', 'content.text', refreshMessage);
- } else {
- refreshRequiredIcon.qtip($.extend({
- content: refreshMessage
- }, nf.CanvasUtils.config.systemTooltipConfig));
- }
-
- refreshContainer.show();
- }
-
- // insert the refresh needed text in the settings - if necessary
- if (!settingsRefreshIcon.is(':visible')) {
- $('#settings-last-refreshed').addClass('alert');
- settingsRefreshIcon.show();
- }
- }
- }
- }).fail(nf.Common.handleAjaxError);
- };
+ // var checkRevision = function () {
+ // // get the revision
+ // return $.ajax({
+ // type: 'GET',
+ // url: config.urls.revision,
+ // dataType: 'json'
+ // }).done(function (response) {
+ // if (nf.Common.isDefinedAndNotNull(response.revision)) {
+ // var revision = response.revision;
+ // var currentRevision = nf.Client.getRevision();
+ //
+ // // if there is a newer revision, there are outstanding
+ // // changes that need to be updated
+ // if (revision.version > currentRevision.version && revision.clientId !== currentRevision.clientId) {
+ // var refreshContainer = $('#refresh-required-container');
+ // var settingsRefreshIcon = $('#settings-refresh-required-icon');
+ //
+ // // insert the refresh needed text in the canvas - if necessary
+ // if (!refreshContainer.is(':visible')) {
+ // $('#stats-last-refreshed').addClass('alert');
+ // var refreshMessage = "This flow has been modified by '" + revision.lastModifier + "'. Please refresh.";
+ //
+ // // update the tooltip
+ // var refreshRequiredIcon = $('#refresh-required-icon');
+ // if (refreshRequiredIcon.data('qtip')) {
+ // refreshRequiredIcon.qtip('option', 'content.text', refreshMessage);
+ // } else {
+ // refreshRequiredIcon.qtip($.extend({
+ // content: refreshMessage
+ // }, nf.CanvasUtils.config.systemTooltipConfig));
+ // }
+ //
+ // refreshContainer.show();
+ // }
+ //
+ // // insert the refresh needed text in the settings - if necessary
+ // if (!settingsRefreshIcon.is(':visible')) {
+ // $('#settings-last-refreshed').addClass('alert');
+ // settingsRefreshIcon.show();
+ // }
+ // }
+ // }
+ // }).fail(nf.Common.handleAjaxError);
+ // };
/**
* Initializes the canvas.
@@ -555,7 +527,7 @@ nf.Canvas = (function () {
if (isCtrl) {
if (evt.keyCode === 82) {
// ctrl-r
- nf.Actions.reloadStatus();
+ nf.Actions.reload();
// default prevented in nf-universal-capture.js
} else if (evt.keyCode === 65) {
@@ -631,8 +603,9 @@ nf.Canvas = (function () {
* Refreshes the graph.
*
* @argument {string} processGroupId The process group id
+ * @argument {object} options Configuration options
*/
- var reloadProcessGroup = function (processGroupId) {
+ var reloadProcessGroup = function (processGroupId, options) {
// load the controller
return $.ajax({
type: 'GET',
@@ -642,9 +615,6 @@ nf.Canvas = (function () {
},
dataType: 'json'
}).done(function (flowResponse) {
- // set the revision
- nf.Client.setRevision(flowResponse.revision);
-
// get the controller and its contents
var processGroupFlow = flowResponse.processGroupFlow;
@@ -654,6 +624,10 @@ nf.Canvas = (function () {
// update the breadcrumbs
nf.ng.Bridge.get('appCtrl.serviceProvider.breadcrumbsCtrl').resetBreadcrumbs();
nf.ng.Bridge.get('appCtrl.serviceProvider.breadcrumbsCtrl').generateBreadcrumbs(processGroupFlow.breadcrumb);
+ nf.ng.Bridge.get('appCtrl.serviceProvider.breadcrumbsCtrl').resetScrollPosition();
+
+ // update the timestamp
+ $('#stats-last-refreshed').text(processGroupFlow.lastRefreshed);
// set the parent id if applicable
if (nf.Common.isDefinedAndNotNull(processGroupFlow.parentGroupId)) {
@@ -662,57 +636,22 @@ nf.Canvas = (function () {
nf.Canvas.setParentGroupId(null);
}
- // since we're getting a new group, we want to clear it
- nf.Graph.removeAll();
-
// refresh the graph
- nf.Graph.add(processGroupFlow.flow, false);
+ nf.Graph.set(processGroupFlow.flow, $.extend({
+ 'selectAll': false
+ }, options));
+
+ // update component visibility
+ nf.Canvas.View.updateVisibility();
+
+ // update the birdseye
+ nf.Birdseye.refresh();
// inform Angular app values have changed
nf.ng.Bridge.digest();
}).fail(nf.Common.handleAjaxError);
};
- /**
- * Refreshes the status for the resources that exist in the specified process group.
- *
- * @argument {string} processGroupId The id of the process group
- */
- var reloadStatus = function (processGroupId) {
- // get the stats
- return $.Deferred(function (deferred) {
- $.ajax({
- type: 'GET',
- url: config.urls.api + '/flow/process-groups/' + encodeURIComponent(processGroupId) + '/status',
- data: {
- recursive: false
- },
- dataType: 'json'
- }).done(function (response) {
- // report the updated stats
- if (nf.Common.isDefinedAndNotNull(response.processGroupStatus)) {
- var processGroupStatus = response.processGroupStatus;
- var aggregateSnapshot = processGroupStatus.aggregateSnapshot;
-
- // update all the stats
- nf.Graph.setStatus(aggregateSnapshot);
-
- // update the timestamp
- $('#stats-last-refreshed').text(processGroupStatus.statsLastRefreshed);
- }
- deferred.resolve();
- }).fail(function (xhr, status, error) {
- // if clustered, a 404 likely means the flow status at the ncm is stale
- if (!nf.Canvas.isClustered() || xhr.status !== 404) {
- nf.Common.handleAjaxError(xhr, status, error);
- deferred.reject();
- } else {
- deferred.resolve();
- }
- });
- }).promise();
- };
-
return {
CANVAS_OFFSET: 0,
@@ -729,58 +668,28 @@ nf.Canvas = (function () {
},
/**
- * Stop polling for revision.
- */
- stopRevisionPolling: function () {
- // set polling flag
- revisionPolling = false;
- },
-
- /**
* Remove the status poller.
*/
- stopStatusPolling: function () {
+ stopPolling: function () {
// set polling flag
- statusPolling = false;
+ polling = false;
},
/**
* Reloads the flow from the server based on the currently specified group id.
- * To load another group, update nf.Canvas.setGroupId and call nf.Canvas.reload.
+ * To load another group, update nf.Canvas.setGroupId, clear the canvas, and call nf.Canvas.reload.
*/
- reload: function () {
+ reload: function (options) {
return $.Deferred(function (deferred) {
// hide the context menu
nf.ContextMenu.hide();
// get the process group to refresh everything
- var processGroupXhr = reloadProcessGroup(nf.Canvas.getGroupId());
+ var processGroupXhr = reloadProcessGroup(nf.Canvas.getGroupId(), options);
var statusXhr = nf.ng.Bridge.get('appCtrl.serviceProvider.headerCtrl.flowStatusCtrl').reloadFlowStatus();
var settingsXhr = nf.Settings.loadSettings(false); // don't reload the status as we want to wait for deferreds to complete
$.when(processGroupXhr, statusXhr, settingsXhr).done(function (processGroupResult) {
- // adjust breadcrumbs if necessary
- nf.ng.Bridge.get('appCtrl.serviceProvider.breadcrumbsCtrl').resetScrollPosition();
-
- // don't load the status until the graph is loaded
- reloadStatus(nf.Canvas.getGroupId()).done(function () {
- deferred.resolve(processGroupResult);
- }).fail(function () {
- deferred.reject();
- });
- });
- }).promise();
- },
-
- /**
- * Reloads the status.
- */
- reloadStatus: function () {
- return $.Deferred(function (deferred) {
- // refresh the status and check any bulletins
- $.when(reloadStatus(nf.Canvas.getGroupId()),
- nf.ng.Bridge.get('appCtrl.serviceProvider.headerCtrl.flowStatusCtrl').reloadFlowStatus(),
- checkRevision()).done(function () {
- deferred.resolve();
+ deferred.resolve(processGroupResult);
}).fail(function () {
deferred.reject();
});
@@ -863,6 +772,9 @@ nf.Canvas = (function () {
});
}).promise();
userXhr.done(function () {
+ // load the client id
+ var clientXhr = nf.Client.init();
+
// get the controller config to register the status poller
var configXhr = $.ajax({
type: 'GET',
@@ -889,7 +801,7 @@ nf.Canvas = (function () {
}).promise();
// ensure the config requests are loaded
- $.when(configXhr, userXhr).done(function (configResult) {
+ $.when(configXhr, userXhr, clientXhr).done(function (configResult, loginResult, aboutResult) {
var configResponse = configResult[0];
// calculate the canvas offset
@@ -953,10 +865,9 @@ nf.Canvas = (function () {
// determine the split between the polling
var pollingSplit = autoRefreshIntervalSeconds / 2;
- // register the revision and status polling
- startRevisionPolling(autoRefreshIntervalSeconds);
+ // register the polling
setTimeout(function () {
- startStatusPolling(autoRefreshIntervalSeconds);
+ startPolling(autoRefreshIntervalSeconds);
}, pollingSplit * 1000);
// hide the splash screen
http://git-wip-us.apache.org/repos/asf/nifi/blob/3cc16d35/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/js/nf/canvas/nf-component-state.js
----------------------------------------------------------------------
diff --git a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/js/nf/canvas/nf-component-state.js b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/js/nf/canvas/nf-component-state.js
index bb8811c..644342a 100644
--- a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/js/nf/canvas/nf-component-state.js
+++ b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/js/nf/canvas/nf-component-state.js
@@ -205,6 +205,7 @@ nf.ComponentState = (function () {
// clear the component
$('#component-state-table').removeData('component');
+ $('#component-state-table').removeData('revision');
};
return {
@@ -251,11 +252,13 @@ nf.ComponentState = (function () {
var stateEntryCount = componentStateGrid.getDataLength();
if (stateEntryCount > 0) {
+ var revision = componentStateTable.data('revision');
+
// clear the state
var revision = {
- 'revision': nf.Client.getRevision()
+ 'revision': revision
};
-
+
var component = componentStateTable.data('component');
$.ajax({
type: 'POST',
@@ -263,8 +266,8 @@ nf.ComponentState = (function () {
data: JSON.stringify(revision),
dataType: 'json'
}).done(function (response) {
- // update the revision
- nf.Client.setRevision(response.revision);
+ // TODO - update the revision
+ // nf.Client.setRevision(response.revision);
// clear the table
clearTable();
@@ -356,7 +359,7 @@ nf.ComponentState = (function () {
* @param {object} component
* @param {boolean} canClear
*/
- showState: function (component, canClear) {
+ showState: function (component, revision, canClear) {
return $.ajax({
type: 'GET',
url: component.uri + '/state',
@@ -374,6 +377,7 @@ nf.ComponentState = (function () {
// store the component
componentStateTable.data('component', component);
+ componentStateTable.data('revision', revision);
// show the dialog
$('#component-state-dialog').modal('show');
http://git-wip-us.apache.org/repos/asf/nifi/blob/3cc16d35/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/js/nf/canvas/nf-connectable.js
----------------------------------------------------------------------
diff --git a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/js/nf/canvas/nf-connectable.js b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/js/nf/canvas/nf-connectable.js
index a491266..0c69774 100644
--- a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/js/nf/canvas/nf-connectable.js
+++ b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/js/nf/canvas/nf-connectable.js
@@ -25,13 +25,13 @@ nf.Connectable = (function () {
/**
* Determines if we want to allow adding connections in the current state:
- *
+ *
* 1) When shift is down, we could be adding components to the current selection.
* 2) When the selection box is visible, we are in the process of moving all the
* components currently selected.
* 3) When the drag selection box is visible, we are in the process or selecting components
* using the selection box.
- *
+ *
* @returns {boolean}
*/
var allowConnection = function () {
@@ -44,207 +44,217 @@ nf.Connectable = (function () {
// dragging behavior for the connector
connect = d3.behavior.drag()
- .origin(function (d) {
- origin = d3.mouse(canvas.node());
- return {
- x: origin[0],
- y: origin[1]
- };
- })
- .on('dragstart', function (d) {
- // stop further propagation
- d3.event.sourceEvent.stopPropagation();
-
- // unselect the previous components
- nf.CanvasUtils.getSelection().classed('selected', false);
-
- // mark the source component has selected
- var source = d3.select(this.parentNode).classed('selected', true);
-
- // mark this component as dragging and selected
- d3.select(this).classed('dragging', true);
-
- // mark the source of the drag
- var sourceData = source.datum();
+ .origin(function (d) {
+ origin = d3.mouse(canvas.node());
+ return {
+ x: origin[0],
+ y: origin[1]
+ };
+ })
+ .on('dragstart', function (d) {
+ // stop further propagation
+ d3.event.sourceEvent.stopPropagation();
- // start the drag line and insert it first to keep it on the bottom
- var position = d3.mouse(canvas.node());
- canvas.insert('path', ':first-child')
- .datum({
- 'sourceId': sourceData.id,
- 'sourceWidth': sourceData.dimensions.width,
- 'x': position[0],
- 'y': position[1]
- })
- .attr({
- 'class': 'connector',
- 'd': function (pathDatum) {
- return 'M' + pathDatum.x + ' ' + pathDatum.y + 'L' + pathDatum.x + ' ' + pathDatum.y;
- }
- });
+ // unselect the previous components
+ nf.CanvasUtils.getSelection().classed('selected', false);
- // updates the location of the connection img
- d3.select(this).attr('transform', function () {
- return 'translate(' + position[0] + ', ' + (position[1] + 20) + ')';
- });
+ // mark the source component has selected
+ var source = d3.select(this.parentNode).classed('selected', true);
- // re-append the image to keep it on top
- canvas.node().appendChild(this);
- })
- .on('drag', function (d) {
- // updates the location of the connection img
- d3.select(this).attr('transform', function () {
- return 'translate(' + d3.event.x + ', ' + (d3.event.y + 20) + ')';
- });
+ // mark this component as dragging and selected
+ d3.select(this).classed('dragging', true);
- // mark node's connectable if supported
- var destination = d3.select('g.hover').classed('connectable-destination', function () {
- // ensure the mouse has moved at least 10px in any direction, it seems that
- // when the drag event is trigger is not consistent between browsers. as a result
- // some browser would trigger when the mouse hadn't moved yet which caused
- // click and contextmenu events to appear like an attempt to connection the
- // component to itself. requiring the mouse to have actually moved before
- // checking the eligiblity of the destination addresses the issue
- return (Math.abs(origin[0] - d3.event.x) > 10 || Math.abs(origin[1] - d3.event.y) > 10) &&
- nf.CanvasUtils.isValidConnectionDestination(d3.select(this));
- });
+ // mark the source of the drag
+ var sourceData = source.datum();
- // update the drag line
- d3.select('path.connector').classed('connectable', function () {
- if (destination.empty()) {
- return false;
- }
-
- // if there is a potential destination, see if its connectable
- return destination.classed('connectable-destination');
- }).attr('d', function (pathDatum) {
- if (!destination.empty() && destination.classed('connectable-destination')) {
- var destinationData = destination.datum();
-
- // show the line preview as appropriate
- if (pathDatum.sourceId === destinationData.id) {
- var x = pathDatum.x;
- var y = pathDatum.y;
- var componentOffset = pathDatum.sourceWidth / 2;
- var xOffset = nf.Connection.config.selfLoopXOffset;
- var yOffset = nf.Connection.config.selfLoopYOffset;
- return 'M' + x + ' ' + y + 'L' + (x + componentOffset + xOffset) + ' ' + (y - yOffset) + 'L' + (x + componentOffset + xOffset) + ' ' + (y + yOffset) + 'Z';
- } else {
- // get the position on the destination perimeter
- var end = nf.CanvasUtils.getPerimeterPoint(pathDatum, {
- 'x': destinationData.position.x,
- 'y': destinationData.position.y,
- 'width': destinationData.dimensions.width,
- 'height': destinationData.dimensions.height
- });
-
- // direct line between components to provide a 'snap feel'
- return 'M' + pathDatum.x + ' ' + pathDatum.y + 'L' + end.x + ' ' + end.y;
- }
- } else {
- return 'M' + pathDatum.x + ' ' + pathDatum.y + 'L' + d3.event.x + ' ' + d3.event.y;
+ // start the drag line and insert it first to keep it on the bottom
+ var position = d3.mouse(canvas.node());
+ canvas.insert('path', ':first-child')
+ .datum({
+ 'sourceId': sourceData.id,
+ 'sourceWidth': sourceData.dimensions.width,
+ 'x': position[0],
+ 'y': position[1]
+ })
+ .attr({
+ 'class': 'connector',
+ 'd': function (pathDatum) {
+ return 'M' + pathDatum.x + ' ' + pathDatum.y + 'L' + pathDatum.x + ' ' + pathDatum.y;
}
});
- })
- .on('dragend', function (d) {
- // stop further propagation
- d3.event.sourceEvent.stopPropagation();
- // get the add connect img
- var addConnect = d3.select(this);
+ // updates the location of the connection img
+ d3.select(this).attr('transform', function () {
+ return 'translate(' + position[0] + ', ' + (position[1] + 20) + ')';
+ });
- // get the connector, if it the current point is not over a new destination
- // the connector will be removed. otherwise it will be removed after the
- // connection has been configured/cancelled
- var connector = d3.select('path.connector');
- var connectorData = connector.datum();
+ // re-append the image to keep it on top
+ canvas.node().appendChild(this);
+ })
+ .on('drag', function (d) {
+ // updates the location of the connection img
+ d3.select(this).attr('transform', function () {
+ return 'translate(' + d3.event.x + ', ' + (d3.event.y + 20) + ')';
+ });
- // get the destination
- var destination = d3.select('g.connectable-destination');
+ // mark node's connectable if supported
+ var destination = d3.select('g.hover').classed('connectable-destination', function () {
+ // ensure the mouse has moved at least 10px in any direction, it seems that
+ // when the drag event is trigger is not consistent between browsers. as a result
+ // some browser would trigger when the mouse hadn't moved yet which caused
+ // click and contextmenu events to appear like an attempt to connection the
+ // component to itself. requiring the mouse to have actually moved before
+ // checking the eligiblity of the destination addresses the issue
+ return (Math.abs(origin[0] - d3.event.x) > 10 || Math.abs(origin[1] - d3.event.y) > 10) &&
+ nf.CanvasUtils.isValidConnectionDestination(d3.select(this));
+ });
- // we are not over a new destination
+ // update the drag line
+ d3.select('path.connector').classed('connectable', function () {
if (destination.empty()) {
- // get the source to determine if we are still over it
- var source = d3.select('#id-' + connectorData.sourceId);
- var sourceData = source.datum();
-
- // get the mouse position relative to the source
- var position = d3.mouse(source.node());
-
- // if the position is outside the component, remove the add connect img
- if (position[0] < 0 || position[0] > sourceData.dimensions.width || position[1] < 0 || position[1] > sourceData.dimensions.height) {
- addConnect.remove();
+ return false;
+ }
+
+ // if there is a potential destination, see if its connectable
+ return destination.classed('connectable-destination');
+ }).attr('d', function (pathDatum) {
+ if (!destination.empty() && destination.classed('connectable-destination')) {
+ var destinationData = destination.datum();
+
+ // show the line preview as appropriate
+ if (pathDatum.sourceId === destinationData.id) {
+ var x = pathDatum.x;
+ var y = pathDatum.y;
+ var componentOffset = pathDatum.sourceWidth / 2;
+ var xOffset = nf.Connection.config.selfLoopXOffset;
+ var yOffset = nf.Connection.config.selfLoopYOffset;
+ return 'M' + x + ' ' + y + 'L' + (x + componentOffset + xOffset) + ' ' + (y - yOffset) + 'L' + (x + componentOffset + xOffset) + ' ' + (y + yOffset) + 'Z';
} else {
- // reset the add connect img by restoring the position and place in the DOM
- addConnect.classed('dragging', false).attr('transform', function () {
- return 'translate(' + d.origX + ', ' + d.origY + ')';
+ // get the position on the destination perimeter
+ var end = nf.CanvasUtils.getPerimeterPoint(pathDatum, {
+ 'x': destinationData.position.x,
+ 'y': destinationData.position.y,
+ 'width': destinationData.dimensions.width,
+ 'height': destinationData.dimensions.height
});
- source.node().appendChild(this);
+
+ // direct line between components to provide a 'snap feel'
+ return 'M' + pathDatum.x + ' ' + pathDatum.y + 'L' + end.x + ' ' + end.y;
}
-
- // remove the connector
- connector.remove();
} else {
- // remove the add connect img
- addConnect.remove();
-
- // create the connection
- var destinationData = destination.datum();
- nf.ConnectionConfiguration.createConnection(connectorData.sourceId, destinationData.id);
+ return 'M' + pathDatum.x + ' ' + pathDatum.y + 'L' + d3.event.x + ' ' + d3.event.y;
}
});
+ })
+ .on('dragend', function (d) {
+ // stop further propagation
+ d3.event.sourceEvent.stopPropagation();
+
+ // get the add connect img
+ var addConnect = d3.select(this);
+
+ // get the connector, if it the current point is not over a new destination
+ // the connector will be removed. otherwise it will be removed after the
+ // connection has been configured/cancelled
+ var connector = d3.select('path.connector');
+ var connectorData = connector.datum();
+
+ // get the destination
+ var destination = d3.select('g.connectable-destination');
+
+ // we are not over a new destination
+ if (destination.empty()) {
+ // get the source to determine if we are still over it
+ var source = d3.select('#id-' + connectorData.sourceId);
+ var sourceData = source.datum();
+
+ // get the mouse position relative to the source
+ var position = d3.mouse(source.node());
+
+ // if the position is outside the component, remove the add connect img
+ if (position[0] < 0 || position[0] > sourceData.dimensions.width || position[1] < 0 || position[1] > sourceData.dimensions.height) {
+ addConnect.remove();
+ } else {
+ // reset the add connect img by restoring the position and place in the DOM
+ addConnect.classed('dragging', false).attr('transform', function () {
+ return 'translate(' + d.origX + ', ' + d.origY + ')';
+ });
+ source.node().appendChild(this);
+ }
+
+ // remove the connector
+ connector.remove();
+ } else {
+ // remove the add connect img
+ addConnect.remove();
+
+ // create the connection
+ var destinationData = destination.datum();
+ nf.ConnectionConfiguration.createConnection(connectorData.sourceId, destinationData.id);
+ }
+ });
},
-
+
activate: function (components) {
components
- .on('mouseenter.connectable', function (d) {
- if (allowConnection()) {
- var selection = d3.select(this);
-
- // ensure the current component supports connection source
- if (nf.CanvasUtils.isValidConnectionSource(selection)) {
- // see if theres already a connector rendered
- var addConnect = d3.select('image.add-connect');
- if (addConnect.empty()) {
- var x = (d.dimensions.width / 2) - 14;
- var y = (d.dimensions.height / 2) - 14;
-
- selection.append('image')
- .datum({
- origX: x,
- origY: y
- })
- .call(connect)
- .call(nf.CanvasUtils.disableImageHref)
- .attr({
- 'class': 'add-connect',
- 'xlink:href': 'images/addConnect.png',
- 'width': 28,
- 'height': 28,
- 'transform': 'translate(' + x + ', ' + y + ')'
- });
- }
+ .classed('connectable', true)
+ .on('mouseenter.connectable', function (d) {
+ if (allowConnection()) {
+ var selection = d3.select(this);
+
+ // ensure the current component supports connection source
+ if (nf.CanvasUtils.isValidConnectionSource(selection)) {
+ // see if theres already a connector rendered
+ var addConnect = d3.select('image.add-connect');
+ if (addConnect.empty()) {
+ var x = (d.dimensions.width / 2) - 14;
+ var y = (d.dimensions.height / 2) - 14;
+
+ selection.append('image')
+ .datum({
+ origX: x,
+ origY: y
+ })
+ .call(connect)
+ .call(nf.CanvasUtils.disableImageHref)
+ .attr({
+ 'class': 'add-connect',
+ 'xlink:href': 'images/addConnect.png',
+ 'width': 28,
+ 'height': 28,
+ 'transform': 'translate(' + x + ', ' + y + ')'
+ });
}
}
- })
- .on('mouseleave.connectable', function () {
- // conditionally remove the connector
- var addConnect = d3.select(this).select('image.add-connect');
- if (!addConnect.empty() && !addConnect.classed('dragging')) {
- addConnect.remove();
- }
- })
- // Using mouseover/out to workaround chrome issue #122746
- .on('mouseover.connectable', function () {
- // mark that we are hovering when appropriate
- d3.select(this).classed('hover', function () {
- return allowConnection();
- });
- })
- .on('mouseout.connection', function () {
- // remove all hover related classes
- d3.select(this).classed('hover connectable-destination', false);
+ }
+ })
+ .on('mouseleave.connectable', function () {
+ // conditionally remove the connector
+ var addConnect = d3.select(this).select('image.add-connect');
+ if (!addConnect.empty() && !addConnect.classed('dragging')) {
+ addConnect.remove();
+ }
+ })
+ // Using mouseover/out to workaround chrome issue #122746
+ .on('mouseover.connectable', function () {
+ // mark that we are hovering when appropriate
+ d3.select(this).classed('hover', function () {
+ return allowConnection();
});
+ })
+ .on('mouseout.connection', function () {
+ // remove all hover related classes
+ d3.select(this).classed('hover connectable-destination', false);
+ });
+ },
+
+ deactivate: function (components) {
+ components
+ .classed('connectable', false)
+ .on('mouseenter.connectable', null)
+ .on('mouseleave.connectable', null)
+ .on('mouseover.connectable', null)
+ .on('mouseout.connectable', null);
}
};
}());
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/nifi/blob/3cc16d35/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/js/nf/canvas/nf-connection-configuration.js
----------------------------------------------------------------------
diff --git a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/js/nf/canvas/nf-connection-configuration.js b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/js/nf/canvas/nf-connection-configuration.js
index e27f431..ff1f67a 100644
--- a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/js/nf/canvas/nf-connection-configuration.js
+++ b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/js/nf/canvas/nf-connection-configuration.js
@@ -843,7 +843,6 @@ nf.ConnectionConfiguration = (function () {
if (validateSettings()) {
var connectionEntity = {
- 'revision': nf.Client.getRevision(),
'component': {
'name': connectionName,
'source': {
@@ -873,9 +872,6 @@ nf.ConnectionConfiguration = (function () {
dataType: 'json',
contentType: 'application/json'
}).done(function (response) {
- // update the revision
- nf.Client.setRevision(response.revision);
-
// add the connection
nf.Graph.add({
'connections': [response]
@@ -926,8 +922,9 @@ nf.ConnectionConfiguration = (function () {
var prioritizers = $('#prioritizer-selected').sortable('toArray');
if (validateSettings()) {
+ var d = nf.Connection.get(connectionId);
var connectionEntity = {
- 'revision': nf.Client.getRevision(),
+ 'revision': nf.Client.getRevision(d),
'component': {
'id': connectionId,
'name': connectionName,
@@ -953,9 +950,6 @@ nf.ConnectionConfiguration = (function () {
contentType: 'application/json'
}).done(function (response) {
if (nf.Common.isDefinedAndNotNull(response.component)) {
- // update the revision
- nf.Client.setRevision(response.revision);
-
// update this connection
nf.Connection.set(response);