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/04/29 22:32:16 UTC
[03/13] nifi git commit: NIFI-1554: - Populating component entities
in the REST API to decouple key fields from the configuration DTOs. - Added
initial support for components in UI when access isn't allowed. Formal
styling to come later.
http://git-wip-us.apache.org/repos/asf/nifi/blob/ff98d823/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/js/nf/canvas/nf-funnel.js
----------------------------------------------------------------------
diff --git a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/js/nf/canvas/nf-funnel.js b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/js/nf/canvas/nf-funnel.js
index 555450e..d042286 100644
--- a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/js/nf/canvas/nf-funnel.js
+++ b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/js/nf/canvas/nf-funnel.js
@@ -45,7 +45,7 @@ nf.Funnel = (function () {
*/
var select = function () {
return funnelContainer.selectAll('g.funnel').data(funnelMap.values(), function (d) {
- return d.component.id;
+ return d.id;
});
};
@@ -63,7 +63,7 @@ nf.Funnel = (function () {
var funnel = entered.append('g')
.attr({
'id': function (d) {
- return 'id-' + d.component.id;
+ return 'id-' + d.id;
},
'class': 'funnel component'
})
@@ -100,9 +100,9 @@ nf.Funnel = (function () {
funnel.call(nf.Selectable.activate).call(nf.ContextMenu.activate);
// only support dragging and connecting when appropriate
- if (nf.Common.isDFM()) {
- funnel.call(nf.Draggable.activate).call(nf.Connectable.activate);
- }
+ funnel.filter(function (d) {
+ return d.accessPolicy.canWrite && d.accessPolicy.canRead;
+ }).call(nf.Draggable.activate).call(nf.Connectable.activate);
return funnel;
};
@@ -142,28 +142,27 @@ nf.Funnel = (function () {
/**
* Populates the graph with the specified funnels.
*
- * @argument {object | array} funnels The funnels to add
+ * @argument {object | array} funnelEntities The funnels to add
* @argument {boolean} selectAll Whether or not to select the new contents
*/
- add: function (funnels, selectAll) {
+ add: function (funnelEntities, selectAll) {
selectAll = nf.Common.isDefinedAndNotNull(selectAll) ? selectAll : false;
- var add = function (funnel) {
+ var add = function (funnelEntity) {
// add the funnel
- funnelMap.set(funnel.id, {
+ funnelMap.set(funnelEntity.id, $.extend({
type: 'Funnel',
- component: funnel,
dimensions: dimensions
- });
+ }, funnelEntity));
};
// determine how to handle the specified funnel status
- if ($.isArray(funnels)) {
- $.each(funnels, function (_, funnel) {
- add(funnel);
+ if ($.isArray(funnelEntities)) {
+ $.each(funnelEntities, function (_, funnelEntity) {
+ add(funnelEntity);
});
} else {
- add(funnels);
+ add(funnelEntities);
}
// apply the selection and handle all new processors
@@ -211,7 +210,7 @@ nf.Funnel = (function () {
url: funnel.uri,
dataType: 'json'
}).done(function (response) {
- nf.Funnel.set(response.funnel);
+ nf.Funnel.set(response);
});
}
},
@@ -230,38 +229,31 @@ nf.Funnel = (function () {
* will set each funnel. If it is not an array, it will
* attempt to set the specified funnel.
*
- * @param {object | array} funnels
+ * @param {object | array} funnelEntities
*/
- set: function (funnels) {
- var set = function (funnel) {
- if (funnelMap.has(funnel.id)) {
+ set: function (funnelEntities) {
+ var set = function (funnelEntity) {
+ if (funnelMap.has(funnelEntity.id)) {
// update the current entry
- var funnelEntry = funnelMap.get(funnel.id);
- funnelEntry.component = funnel;
-
+ var funnelEntry = funnelMap.get(funnelEntity.id);
+ $.extend(funnelEntry, funnelEntity);
+
// update the connection in the UI
- d3.select('#id-' + funnel.id).call(updateFunnels);
+ d3.select('#id-' + funnelEntity.id).call(updateFunnels);
}
};
// determine how to handle the specified funnel status
- if ($.isArray(funnels)) {
- $.each(funnels, function (_, funnel) {
- set(funnel);
+ if ($.isArray(funnelEntities)) {
+ $.each(funnelEntities, function (_, funnelEntity) {
+ set(funnelEntity);
});
} else {
- set(funnels);
+ set(funnelEntities);
}
},
/**
- * Returns the entity key when marshalling an entity of this type.
- */
- getEntityKey: function (d) {
- return 'funnel';
- },
-
- /**
* Removes the specified funnel.
*
* @param {array|string} funnels The funnel id
http://git-wip-us.apache.org/repos/asf/nifi/blob/ff98d823/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/js/nf/canvas/nf-go-to.js
----------------------------------------------------------------------
diff --git a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/js/nf/canvas/nf-go-to.js b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/js/nf/canvas/nf-go-to.js
index f3d0738..5bf3e9e 100644
--- a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/js/nf/canvas/nf-go-to.js
+++ b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/js/nf/canvas/nf-go-to.js
@@ -156,7 +156,7 @@ nf.GoTo = (function () {
var addDestinationInputPort = function (container, connection) {
// get the remote process group
return getProcessGroup(connection.destination.groupId).done(function (response) {
- var processGroup = response.processGroup;
+ var processGroup = response.component;
// process group
var downstreamComponent = $('<div class="destination-component"></div>').appendTo(container);
@@ -263,7 +263,7 @@ nf.GoTo = (function () {
var addSourceOutputPort = function (container, connection) {
// get the remote process group
return getProcessGroup(connection.source.groupId).done(function (response) {
- var processGroup = response.processGroup;
+ var processGroup = response.component;
// process group
var sourceComponent = $('<div class="source-component"></div>').appendTo(container);
@@ -364,7 +364,7 @@ nf.GoTo = (function () {
// add the destination for each connection
$.each(connections, function (_, connection) {
// only show connections for which this selection is the source
- if (connection.source.id === selectionData.component.id) {
+ if (connection.source.id === selectionData.id) {
addConnection(connection);
}
});
@@ -403,7 +403,7 @@ nf.GoTo = (function () {
// add the source for each connection
$.each(connections, function (_, connection) {
// only show connections for which this selection is the destination
- if (connection.destination.id === selectionData.component.id) {
+ if (connection.destination.id === selectionData.id) {
addConnection(connection);
}
});
@@ -442,7 +442,7 @@ nf.GoTo = (function () {
// add the destination for each connection
$.each(connections, function (_, connection) {
// only show connections for which this selection is the source
- if (connection.source.groupId === selectionData.component.id) {
+ if (connection.source.groupId === selectionData.id) {
addConnection(connection);
}
});
@@ -481,7 +481,7 @@ nf.GoTo = (function () {
// add the source for each connection
$.each(connections, function (_, connection) {
// only show connections for which this selection is the destination
- if (connection.destination.groupId === selectionData.component.id) {
+ if (connection.destination.groupId === selectionData.id) {
addConnection(connection);
}
});
@@ -520,7 +520,7 @@ nf.GoTo = (function () {
// add the destination for each connection
$.each(connections, function (_, connection) {
// only show connections for which this selection is the source
- if (connection.source.id === selectionData.component.id) {
+ if (connection.source.id === selectionData.id) {
addConnection(connection);
}
});
@@ -562,7 +562,7 @@ nf.GoTo = (function () {
// add the source for each connection
$.each(connections, function (_, connection) {
// only show connections for which this selection is the destination
- if (connection.destination.id === selectionData.component.id) {
+ if (connection.destination.id === selectionData.id) {
addConnection(connection);
}
});
@@ -604,7 +604,7 @@ nf.GoTo = (function () {
// add the destination for each connection
$.each(connections, function (_, connection) {
// only show connections for which this selection is the source
- if (connection.source.id === selectionData.component.id) {
+ if (connection.source.id === selectionData.id) {
addConnection(connection);
}
});
@@ -643,7 +643,7 @@ nf.GoTo = (function () {
// add the source for each connection
$.each(connections, function (_, connection) {
// only show connections for which this selection is the destination
- if (connection.destination.id === selectionData.component.id) {
+ if (connection.destination.id === selectionData.id) {
addConnection(connection);
}
});
@@ -679,7 +679,7 @@ nf.GoTo = (function () {
// add the destination for each connection
$.each(connections, function (_, connection) {
// only show connections for which this selection is the source
- if (connection.source.id === selectionData.component.id) {
+ if (connection.source.id === selectionData.id) {
addConnection(connection);
}
});
@@ -715,7 +715,7 @@ nf.GoTo = (function () {
// add the source for each connection
$.each(connections, function (_, connection) {
// only show connections for which this selection is the destination
- if (connection.destination.id === selectionData.component.id) {
+ if (connection.destination.id === selectionData.id) {
addConnection(connection);
}
});
http://git-wip-us.apache.org/repos/asf/nifi/blob/ff98d823/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/js/nf/canvas/nf-label-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-label-configuration.js b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/js/nf/canvas/nf-label-configuration.js
index 6e9ee36..5524ec4 100644
--- a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/js/nf/canvas/nf-label-configuration.js
+++ b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/js/nf/canvas/nf-label-configuration.js
@@ -43,7 +43,7 @@ nf.LabelConfiguration = (function () {
// build the label entity
var labelEntity = {
'revision': nf.Client.getRevision(),
- 'label': {
+ 'component': {
'id': labelId,
'label': labelValue,
'style': {
@@ -64,7 +64,7 @@ nf.LabelConfiguration = (function () {
nf.Client.setRevision(response.revision);
// get the label out of the response
- nf.Label.set(response.label);
+ nf.Label.set(response);
}).fail(nf.Common.handleAjaxError);
// reset and hide the dialog
@@ -139,7 +139,7 @@ nf.LabelConfiguration = (function () {
}
// store the label uri
- labelId = selectionData.component.id;
+ labelId = selectionData.id;
// populate the dialog
$('#label-value').val(labelValue);
http://git-wip-us.apache.org/repos/asf/nifi/blob/ff98d823/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/js/nf/canvas/nf-label.js
----------------------------------------------------------------------
diff --git a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/js/nf/canvas/nf-label.js b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/js/nf/canvas/nf-label.js
index 5629bbb..809b905 100644
--- a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/js/nf/canvas/nf-label.js
+++ b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/js/nf/canvas/nf-label.js
@@ -53,9 +53,7 @@ nf.Label = (function () {
* Selects the labels elements against the current label map.
*/
var select = function () {
- return labelContainer.selectAll('g.label').data(labelMap.values(), function (d) {
- return d.component.id;
- });
+ return labelContainer.selectAll('g.label').data(labelMap.values());
};
/**
@@ -72,12 +70,12 @@ nf.Label = (function () {
var label = entered.append('g')
.attr({
'id': function (d) {
- return 'id-' + d.component.id;
+ return 'id-' + d.id;
},
'class': 'label component'
})
.classed('selected', selected)
- .call(position);
+ .call(nf.CanvasUtils.position);
// label border
label.append('rect')
@@ -110,31 +108,15 @@ nf.Label = (function () {
label.call(nf.Selectable.activate).call(nf.ContextMenu.activate);
// only support dragging when appropriate
- if (nf.Common.isDFM()) {
- label.call(nf.Draggable.activate);
- }
+ label.filter(function (d) {
+ return d.accessPolicy.canWrite && d.accessPolicy.canRead;
+ }).call(nf.Draggable.activate);
// call update to trigger some rendering
label.call(updateLabels);
};
/**
- * Position the component accordingly.
- *
- * @param {selection} updated
- */
- var position = function (updated) {
- if (updated.empty()) {
- return;
- }
-
- // update the processors positioning
- updated.attr('transform', function (d) {
- return 'translate(' + d.component.position.x + ', ' + d.component.position.y + ')';
- });
- };
-
- /**
* Updates the labels in the specified selection.
*
* @param {selection} updated The labels to be updated
@@ -150,9 +132,11 @@ nf.Label = (function () {
// determine all unique colors
labelMap.forEach(function (id, d) {
- var color = d.component.style['background-color'];
- if (nf.Common.isDefinedAndNotNull(color)) {
- colors.add(nf.Common.substringAfterLast(color, '#'));
+ if (d.accessPolicy.canRead) {
+ var color = d.component.style['background-color'];
+ if (nf.Common.isDefinedAndNotNull(color)) {
+ colors.add(nf.Common.substringAfterLast(color, '#'));
+ }
}
});
nf.Canvas.defineLabelColors(colors.values());
@@ -163,9 +147,11 @@ nf.Label = (function () {
'stroke': function (d) {
var color = nf.Label.defaultColor();
- // use the specified color if appropriate
- if (nf.Common.isDefinedAndNotNull(d.component.style['background-color'])) {
- color = d.component.style['background-color'];
+ if (d.accessPolicy.canRead) {
+ // use the specified color if appropriate
+ if (nf.Common.isDefinedAndNotNull(d.component.style['background-color'])) {
+ color = d.component.style['background-color'];
+ }
}
return color;
@@ -184,9 +170,11 @@ nf.Label = (function () {
'fill': function (d) {
var color = nf.Label.defaultColor();
- // use the specified color if appropriate
- if (nf.Common.isDefinedAndNotNull(d.component.style['background-color'])) {
- color = d.component.style['background-color'];
+ if (d.accessPolicy.canRead) {
+ // use the specified color if appropriate
+ if (nf.Common.isDefinedAndNotNull(d.component.style['background-color'])) {
+ color = d.component.style['background-color'];
+ }
}
// get just the color code part
@@ -206,68 +194,71 @@ nf.Label = (function () {
updated.each(function (d) {
var updatedLabel = d3.select(this);
- // update the label
- var label = updatedLabel.select('text.label-value');
+ if (d.accessPolicy.canRead) {
+ // update the label
+ var label = updatedLabel.select('text.label-value');
- // udpate the font size
- label.attr('font-size', function () {
- var fontSize = '12px';
+ // udpate the font size
+ label.attr('font-size', function () {
+ var fontSize = '12px';
- // use the specified color if appropriate
- if (nf.Common.isDefinedAndNotNull(d.component.style['font-size'])) {
- fontSize = d.component.style['font-size'];
- }
+ // use the specified color if appropriate
+ if (nf.Common.isDefinedAndNotNull(d.component.style['font-size'])) {
+ fontSize = d.component.style['font-size'];
+ }
- return fontSize;
- });
+ return fontSize;
+ });
- // remove the previous label value
- label.selectAll('tspan').remove();
+ // remove the previous label value
+ label.selectAll('tspan').remove();
- // parse the lines in this label
- var lines = [];
- if (nf.Common.isDefinedAndNotNull(d.component.label)) {
- lines = d.component.label.split('\n');
- } else {
- lines.push('');
- }
+ // parse the lines in this label
+ var lines = [];
+ if (nf.Common.isDefinedAndNotNull(d.component.label)) {
+ lines = d.component.label.split('\n');
+ } else {
+ lines.push('');
+ }
- // add label value
- $.each(lines, function (i, line) {
- label.append('tspan')
- .attr('x', '0.4em')
- .attr('dy', '1.2em')
- .text(function () {
- return line;
- });
- });
-
- // -----------
- // labelpoints
- // -----------
-
- if (nf.Common.isDFM()) {
- var pointData = [
- {x: d.dimensions.width, y: d.dimensions.height}
- ];
- var points = updatedLabel.selectAll('rect.labelpoint').data(pointData);
-
- // create a point for the end
- points.enter().append('rect')
- .attr({
- 'class': 'labelpoint',
- 'width': 10,
- 'height': 10
- })
- .call(labelPointDrag);
-
- // update the midpoints
- points.attr('transform', function (p) {
- return 'translate(' + (p.x - 10) + ', ' + (p.y - 10) + ')';
+ // add label value
+ $.each(lines, function (i, line) {
+ label.append('tspan')
+ .attr('x', '0.4em')
+ .attr('dy', '1.2em')
+ .text(function () {
+ return line;
+ });
});
- // remove old items
- points.exit().remove();
+
+ // -----------
+ // labelpoints
+ // -----------
+
+ if (d.accessPolicy.canWrite) {
+ var pointData = [
+ {x: d.dimensions.width, y: d.dimensions.height}
+ ];
+ var points = updatedLabel.selectAll('rect.labelpoint').data(pointData);
+
+ // create a point for the end
+ points.enter().append('rect')
+ .attr({
+ 'class': 'labelpoint',
+ 'width': 10,
+ 'height': 10
+ })
+ .call(labelPointDrag);
+
+ // update the midpoints
+ points.attr('transform', function (p) {
+ return 'translate(' + (p.x - 10) + ', ' + (p.y - 10) + ')';
+ });
+
+ // remove old items
+ points.exit().remove();
+ }
}
});
};
@@ -334,24 +325,27 @@ nf.Label = (function () {
// only save the updated bends if necessary
if (different) {
- var revision = nf.Client.getRevision();
+ var labelEntity = {
+ 'revision': nf.Client.getRevision(),
+ 'component': {
+ 'id': labelData.id,
+ 'width': labelData.dimensions.width,
+ 'height': labelData.dimensions.height
+ }
+ }
$.ajax({
type: 'PUT',
url: labelData.component.uri,
- data: {
- 'version': revision.version,
- 'clientId': revision.clientId,
- 'width': labelData.dimensions.width,
- 'height': labelData.dimensions.height
- },
- dataType: 'json'
+ data: JSON.stringify(labelEntity),
+ dataType: 'json',
+ contentType: 'application/json'
}).done(function (response) {
// update the revision
nf.Client.setRevision(response.revision);
// request was successful, update the entry
- nf.Label.set(response.label);
+ nf.Label.set(response);
}).fail(function () {
// determine the previous width
var width = dimensions.width;
@@ -384,43 +378,26 @@ nf.Label = (function () {
/**
* Populates the graph with the specified labels.
*
- * @argument {object | array} labels The labels to add
+ * @argument {object | array} labelEntities The labels to add
* @argument {boolean} selectAll Whether or not to select the new contents
*/
- add: function (labels, selectAll) {
+ add: function (labelEntities, selectAll) {
selectAll = nf.Common.isDefinedAndNotNull(selectAll) ? selectAll : false;
- var add = function (label) {
- // determine the width
- var width = dimensions.width;
- if (nf.Common.isDefinedAndNotNull(label.width)) {
- width = label.width;
- }
-
- // determine the height
- var height = dimensions.height;
- if (nf.Common.isDefinedAndNotNull(label.height)) {
- height = label.height;
- }
-
+ var add = function (labelEntity) {
// add the label
- labelMap.set(label.id, {
- type: 'Label',
- component: label,
- dimensions: {
- width: width,
- height: height
- }
- });
+ labelMap.set(labelEntity.id, $.extend({
+ type: 'Label'
+ }, labelEntity));
};
// determine how to handle the specified label status
- if ($.isArray(labels)) {
- $.each(labels, function (_, label) {
- add(label);
+ if ($.isArray(labelEntities)) {
+ $.each(labelEntities, function (_, labelEntity) {
+ add(labelEntity);
});
} else {
- add(labels);
+ add(labelEntities);
}
// apply the selection and handle all new labels
@@ -468,7 +445,7 @@ nf.Label = (function () {
url: label.uri,
dataType: 'json'
}).done(function (response) {
- nf.Label.set(response.label);
+ nf.Label.set(response);
});
}
},
@@ -479,7 +456,7 @@ nf.Label = (function () {
* @param {string} id The id
*/
position: function (id) {
- d3.select('#id-' + id).call(position);
+ d3.select('#id-' + id).call(nf.CanvasUtils.position);
},
/**
@@ -487,54 +464,31 @@ nf.Label = (function () {
* will set each label. If it is not an array, it will
* attempt to set the specified label.
*
- * @param {object | array} labels
+ * @param {object | array} labelEntities
*/
- set: function (labels) {
- var set = function (label) {
- if (labelMap.has(label.id)) {
- // determine the width
- var width = dimensions.width;
- if (nf.Common.isDefinedAndNotNull(label.width)) {
- width = label.width;
- }
-
- // determine the height
- var height = dimensions.height;
- if (nf.Common.isDefinedAndNotNull(label.height)) {
- height = label.height;
- }
-
+ set: function (labelEntities) {
+ var set = function (labelEntity) {
+ if (labelMap.has(labelEntity.id)) {
// update the current entry
- var labelEntry = labelMap.get(label.id);
- labelEntry.component = label;
- labelEntry.dimensions = {
- width: width,
- height: height
- };
+ var labelEntry = labelMap.get(labelEntity.id);
+ $.extend(labelEntry, labelEntity);
// update the connection in the UI
- d3.select('#id-' + label.id).call(updateLabels);
+ d3.select('#id-' + labelEntry.id).call(updateLabels);
}
};
// determine how to handle the specified label status
- if ($.isArray(labels)) {
- $.each(labels, function (_, label) {
+ if ($.isArray(labelEntities)) {
+ $.each(labelEntities, function (_, label) {
set(label);
});
} else {
- set(labels);
+ set(labelEntities);
}
},
/**
- * Returns the entity key when marshalling an entity of this type.
- */
- getEntityKey: function (d) {
- return 'label';
- },
-
- /**
* Removes the specified label.
*
* @param {array|string} labels The label id(s)
http://git-wip-us.apache.org/repos/asf/nifi/blob/ff98d823/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/js/nf/canvas/nf-port-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-port-configuration.js b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/js/nf/canvas/nf-port-configuration.js
index 41278b8..a972e8e 100644
--- a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/js/nf/canvas/nf-port-configuration.js
+++ b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/js/nf/canvas/nf-port-configuration.js
@@ -55,12 +55,10 @@ nf.PortConfiguration = (function () {
// build the port entity
var portEntity = {
- 'revision': nf.Client.getRevision()
+ 'revision': nf.Client.getRevision(),
+ 'component': port
};
- // use bracket notation to set the key based on the type
- portEntity[nf[portData.type].getEntityKey(portData)] = port;
-
// update the selected component
$.ajax({
type: 'PUT',
@@ -72,15 +70,8 @@ nf.PortConfiguration = (function () {
// update the revision
nf.Client.setRevision(response.revision);
- var port;
- if (nf.Common.isDefinedAndNotNull(response.inputPort)) {
- port = response.inputPort;
- } else {
- port = response.outputPort;
- }
-
// refresh the port component
- nf.Port.set(port);
+ nf.Port.set(response);
// close the details panel
$('#port-configuration').modal('hide');
@@ -166,7 +157,7 @@ nf.PortConfiguration = (function () {
}
// populate the port settings
- $('#port-id').text(selectionData.component.id);
+ $('#port-id').text(selectionData.id);
$('#port-name').val(selectionData.component.name);
$('#port-enabled').removeClass('checkbox-unchecked checkbox-checked').addClass(portEnableStyle);
$('#port-concurrent-tasks').val(selectionData.component.concurrentlySchedulableTaskCount);
http://git-wip-us.apache.org/repos/asf/nifi/blob/ff98d823/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/js/nf/canvas/nf-port-details.js
----------------------------------------------------------------------
diff --git a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/js/nf/canvas/nf-port-details.js b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/js/nf/canvas/nf-port-details.js
index c520044..1134fc1 100644
--- a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/js/nf/canvas/nf-port-details.js
+++ b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/js/nf/canvas/nf-port-details.js
@@ -55,7 +55,7 @@ nf.PortDetails = (function () {
// populate the port settings
nf.Common.populateField('read-only-port-name', selectionData.component.name);
- nf.Common.populateField('read-only-port-id', selectionData.component.id);
+ nf.Common.populateField('read-only-port-id', selectionData.id);
nf.Common.populateField('read-only-port-comments', selectionData.component.comments);
// show the details
http://git-wip-us.apache.org/repos/asf/nifi/blob/ff98d823/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/js/nf/canvas/nf-port.js
----------------------------------------------------------------------
diff --git a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/js/nf/canvas/nf-port.js b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/js/nf/canvas/nf-port.js
index 7b69c8b..74c7a77 100644
--- a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/js/nf/canvas/nf-port.js
+++ b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/js/nf/canvas/nf-port.js
@@ -51,9 +51,7 @@ nf.Port = (function () {
* Selects the port elements against the current port map.
*/
var select = function () {
- return portContainer.selectAll('g.input-port, g.output-port').data(portMap.values(), function (d) {
- return d.component.id;
- });
+ return portContainer.selectAll('g.input-port, g.output-port').data(portMap.values());
};
/**
@@ -70,10 +68,10 @@ nf.Port = (function () {
var port = entered.append('g')
.attr({
'id': function (d) {
- return 'id-' + d.component.id;
+ return 'id-' + d.id;
},
'class': function (d) {
- if (d.component.type === 'INPUT_PORT') {
+ if (d.portType === 'INPUT_PORT') {
return 'input-port component';
} else {
return 'output-port component';
@@ -142,7 +140,7 @@ nf.Port = (function () {
.call(nf.CanvasUtils.disableImageHref)
.attr({
'xlink:href': function (d) {
- if (d.component.type === 'INPUT_PORT') {
+ if (d.portTtype === 'INPUT_PORT') {
return 'images/iconInputPort.png';
} else {
return 'images/iconOutputPort.png';
@@ -151,7 +149,7 @@ nf.Port = (function () {
'width': 46,
'height': 31,
'x': function (d) {
- if (d.component.type === 'INPUT_PORT') {
+ if (d.portType === 'INPUT_PORT') {
return 0;
} else {
return 114;
@@ -164,7 +162,7 @@ nf.Port = (function () {
port.append('text')
.attr({
'x': function (d) {
- if (d.component.type === 'INPUT_PORT') {
+ if (d.portType === 'INPUT_PORT') {
return 52;
} else {
return 5;
@@ -183,9 +181,9 @@ nf.Port = (function () {
port.call(nf.Selectable.activate).call(nf.ContextMenu.activate);
// only activate dragging and connecting if appropriate
- if (nf.Common.isDFM()) {
- port.call(nf.Draggable.activate).call(nf.Connectable.activate);
- }
+ port.filter(function (d) {
+ return d.accessPolicy.canWrite && d.accessPolicy.canRead;
+ }).call(nf.Draggable.activate).call(nf.Connectable.activate);
// call update to trigger some rendering
port.call(updatePorts);
@@ -201,7 +199,7 @@ nf.Port = (function () {
return;
}
- updated.each(function () {
+ updated.each(function (portData) {
var port = d3.select(this);
var details = port.select('g.port-details');
@@ -246,7 +244,7 @@ nf.Port = (function () {
'width': 16,
'height': 16,
'x': function (d) {
- if (d.component.type === 'INPUT_PORT') {
+ if (d.portType === 'INPUT_PORT') {
return 33;
} else {
return 107;
@@ -279,83 +277,87 @@ nf.Port = (function () {
});
}
- // update the run status
- details.select('image.port-run-status-icon')
- .attr('xlink:href', function (d) {
- var img = '';
- if (d.component.state === 'DISABLED') {
- img = 'images/iconDisable.png';
- } else if (!nf.Common.isEmpty(d.component.validationErrors)) {
- img = 'images/iconAlert.png';
- } else if (d.component.state === 'RUNNING') {
- img = 'images/iconRun.png';
- } else if (d.component.state === 'STOPPED') {
- img = 'images/iconStop.png';
- }
- return img;
- })
- .each(function (d) {
- // remove the existing tip if necessary
- var tip = d3.select('#run-status-tip-' + d.component.id);
- if (!tip.empty()) {
- tip.remove();
- }
-
- // if there are validation errors generate a tooltip
- if (!nf.Common.isEmpty(d.component.validationErrors)) {
- tip = d3.select('#port-tooltips').append('div')
- .attr('id', function () {
- return 'run-status-tip-' + d.component.id;
- })
- .attr('class', 'tooltip nifi-tooltip')
- .html(function () {
- var list = nf.Common.formatUnorderedList(d.component.validationErrors);
- if (list === null || list.length === 0) {
- return '';
- } else {
- return $('<div></div>').append(list).html();
- }
- });
-
- // add the tooltip
- nf.CanvasUtils.canvasTooltip(tip, d3.select(this));
- }
- });
-
- // update the port name
- port.select('text.port-name')
- .each(function (d) {
- var portName = d3.select(this);
- var name = d.component.name;
- var words = name.split(/\s+/);
-
- // reset the port name to handle any previous state
- portName.text(null).selectAll('tspan, title').remove();
-
- // handle based on the number of tokens in the port name
- if (words.length === 1) {
- // apply ellipsis to the port name as necessary
- nf.CanvasUtils.ellipsis(portName, name);
- } else {
- nf.CanvasUtils.multilineEllipsis(portName, 2, name);
- }
- }).append('title').text(function (d) {
- return d.component.name;
- });
+ if (portData.accessPolicy.canRead) {
+ // update the run status
+ details.select('image.port-run-status-icon')
+ .attr('xlink:href', function (d) {
+ var img = '';
+ if (d.component.state === 'DISABLED') {
+ img = 'images/iconDisable.png';
+ } else if (!nf.Common.isEmpty(d.component.validationErrors)) {
+ img = 'images/iconAlert.png';
+ } else if (d.component.state === 'RUNNING') {
+ img = 'images/iconRun.png';
+ } else if (d.component.state === 'STOPPED') {
+ img = 'images/iconStop.png';
+ }
+ return img;
+ })
+ .each(function (d) {
+ // remove the existing tip if necessary
+ var tip = d3.select('#run-status-tip-' + d.id);
+ if (!tip.empty()) {
+ tip.remove();
+ }
+
+ // if there are validation errors generate a tooltip
+ if (!nf.Common.isEmpty(d.component.validationErrors)) {
+ tip = d3.select('#port-tooltips').append('div')
+ .attr('id', function () {
+ return 'run-status-tip-' + d.id;
+ })
+ .attr('class', 'tooltip nifi-tooltip')
+ .html(function () {
+ var list = nf.Common.formatUnorderedList(d.component.validationErrors);
+ if (list === null || list.length === 0) {
+ return '';
+ } else {
+ return $('<div></div>').append(list).html();
+ }
+ });
+
+ // add the tooltip
+ nf.CanvasUtils.canvasTooltip(tip, d3.select(this));
+ }
+ });
+
+ // update the port name
+ port.select('text.port-name')
+ .each(function (d) {
+ var portName = d3.select(this);
+ var name = d.component.name;
+ var words = name.split(/\s+/);
+
+ // reset the port name to handle any previous state
+ portName.text(null).selectAll('tspan, title').remove();
+
+ // handle based on the number of tokens in the port name
+ if (words.length === 1) {
+ // apply ellipsis to the port name as necessary
+ nf.CanvasUtils.ellipsis(portName, name);
+ } else {
+ nf.CanvasUtils.multilineEllipsis(portName, 2, name);
+ }
+ }).append('title').text(function (d) {
+ return d.component.name;
+ });
+ }
// populate the stats
port.call(updatePortStatus);
} else {
- // update the port name
- port.select('text.port-name')
- .text(function (d) {
- var name = d.component.name;
- if (name.length > PREVIEW_NAME_LENGTH) {
- return name.substring(0, PREVIEW_NAME_LENGTH) + String.fromCharCode(8230);
- } else {
- return name;
- }
- });
+ if (portData.accessPolicy.canRead) {
+ // update the port name
+ port.select('text.port-name')
+ .text(function (d) {
+ var name = d.component.name;
+ if (name.length > PREVIEW_NAME_LENGTH) {
+ return name.substring(0, PREVIEW_NAME_LENGTH) + String.fromCharCode(8230);
+ } else {
+ return name;
+ }
+ });
+ }
// remove tooltips if necessary
port.call(removeTooltips);
@@ -430,8 +432,8 @@ nf.Port = (function () {
var removeTooltips = function (removed) {
removed.each(function (d) {
// remove any associated tooltips
- $('#run-status-tip-' + d.component.id).remove();
- $('#bulletin-tip-' + d.component.id).remove();
+ $('#run-status-tip-' + d.id).remove();
+ $('#bulletin-tip-' + d.id).remove();
});
};
@@ -453,10 +455,10 @@ nf.Port = (function () {
/**
* Populates the graph with the specified ports.
*
- * @argument {object | array} ports The ports to add
+ * @argument {object | array} portNodes The ports to add
* @argument {boolean} selectAll Whether or not to select the new contents
*/
- add: function (ports, selectAll) {
+ add: function (portEntities, selectAll) {
selectAll = nf.Common.isDefinedAndNotNull(selectAll) ? selectAll : false;
// determine the appropriate dimensions for this port
@@ -465,25 +467,24 @@ nf.Port = (function () {
dimensions = remotePortDimensions;
}
- var add = function (ports) {
+ var add = function (portEntity) {
// add the port
- portMap.set(ports.id, {
+ portMap.set(portEntity.id, $.extend({
type: 'Port',
- component: ports,
dimensions: dimensions,
status: {
activeThreadCount: 0
}
- });
+ }, portEntity));
};
// determine how to handle the specified port status
- if ($.isArray(ports)) {
- $.each(ports, function (_, port) {
- add(port);
+ if ($.isArray(portEntities)) {
+ $.each(portEntities, function (_, portNode) {
+ add(portNode);
});
} else {
- add(ports);
+ add(portEntities);
}
// apply the selection and handle all new ports
@@ -539,9 +540,9 @@ nf.Port = (function () {
dataType: 'json'
}).done(function (response) {
if (nf.Common.isDefinedAndNotNull(response.inputPort)) {
- nf.Port.set(response.inputPort);
+ nf.Port.set(response);
} else {
- nf.Port.set(response.outputPort);
+ nf.Port.set(response);
}
});
}
@@ -561,27 +562,27 @@ nf.Port = (function () {
* will set each port. If it is not an array, it will
* attempt to set the specified port.
*
- * @param {object | array} ports
+ * @param {object | array} portEntities
*/
- set: function (ports) {
- var set = function (port) {
- if (portMap.has(port.id)) {
+ set: function (portEntities) {
+ var set = function (portEntity) {
+ if (portMap.has(portEntity.id)) {
// update the current entry
- var portEntry = portMap.get(port.id);
- portEntry.component = port;
+ var portEntry = portMap.get(portEntity.id);
+ $.extend(portEntry, portEntity);
// update the connection in the UI
- d3.select('#id-' + port.id).call(updatePorts);
+ d3.select('#id-' + portEntry.id).call(updatePorts);
}
};
// determine how to handle the specified ports
- if ($.isArray(ports)) {
- $.each(ports, function (_, port) {
+ if ($.isArray(portEntities)) {
+ $.each(portEntities, function (_, port) {
set(port);
});
} else {
- set(ports);
+ set(portEntities);
}
},
@@ -608,13 +609,6 @@ nf.Port = (function () {
},
/**
- * Returns the entity key when marshalling an entity of this type.
- */
- getEntityKey: function (d) {
- return d.component.type === 'INPUT_PORT' ? 'inputPort' : 'outputPort';
- },
-
- /**
* Removes the specified port.
*
* @param {string} ports The port id(s)
http://git-wip-us.apache.org/repos/asf/nifi/blob/ff98d823/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/js/nf/canvas/nf-process-group-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-process-group-configuration.js b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/js/nf/canvas/nf-process-group-configuration.js
index b72deb2..3b6cd14 100644
--- a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/js/nf/canvas/nf-process-group-configuration.js
+++ b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/js/nf/canvas/nf-process-group-configuration.js
@@ -37,7 +37,7 @@ nf.ProcessGroupConfiguration = (function () {
// build the entity
var entity = {
'revision': nf.Client.getRevision(),
- 'processGroup': {
+ 'component': {
'id': processGroupId,
'name': $('#process-group-name').val(),
'comments': $('#process-group-comments').val()
@@ -52,12 +52,12 @@ nf.ProcessGroupConfiguration = (function () {
dataType: 'json',
contentType: 'application/json'
}).done(function (response) {
- if (nf.Common.isDefinedAndNotNull(response.processGroup)) {
+ if (nf.Common.isDefinedAndNotNull(response.component)) {
// update the revision
nf.Client.setRevision(response.revision);
// refresh the process group
- nf.ProcessGroup.set(response.processGroup);
+ nf.ProcessGroup.set(response);
// close the details panel
$('#process-group-configuration').modal('hide');
@@ -104,7 +104,7 @@ nf.ProcessGroupConfiguration = (function () {
var selectionData = selection.datum();
// populate the process group settings
- $('#process-group-id').text(selectionData.component.id);
+ $('#process-group-id').text(selectionData.id);
$('#process-group-name').val(selectionData.component.name);
$('#process-group-comments').val(selectionData.component.comments);
http://git-wip-us.apache.org/repos/asf/nifi/blob/ff98d823/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/js/nf/canvas/nf-process-group-details.js
----------------------------------------------------------------------
diff --git a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/js/nf/canvas/nf-process-group-details.js b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/js/nf/canvas/nf-process-group-details.js
index 473ca9c..7796901 100644
--- a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/js/nf/canvas/nf-process-group-details.js
+++ b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/js/nf/canvas/nf-process-group-details.js
@@ -54,7 +54,7 @@ nf.ProcessGroupDetails = (function () {
var selectionData = selection.datum();
// populate the port settings
- nf.Common.populateField('read-only-process-group-id', selectionData.component.id);
+ nf.Common.populateField('read-only-process-group-id', selectionData.id);
nf.Common.populateField('read-only-process-group-name', selectionData.component.name);
nf.Common.populateField('read-only-process-group-comments', selectionData.component.comments);