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 2015/02/18 19:42:31 UTC
[1/2] incubator-nifi git commit: NIFI-325: - Code clean up. -
Ensuring the fill color action is available in toolbar and context menu under
the same conditions. - Only applying the new color if different.
Repository: incubator-nifi
Updated Branches:
refs/heads/develop dde5fd51a -> 0047fa450
NIFI-325:
- Code clean up.
- Ensuring the fill color action is available in toolbar and context menu under the same conditions.
- Only applying the new color if different.
Project: http://git-wip-us.apache.org/repos/asf/incubator-nifi/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-nifi/commit/4239797b
Tree: http://git-wip-us.apache.org/repos/asf/incubator-nifi/tree/4239797b
Diff: http://git-wip-us.apache.org/repos/asf/incubator-nifi/diff/4239797b
Branch: refs/heads/develop
Commit: 4239797b9f26f3e7be5746b55d5cac9cb7128172
Parents: dde5fd5
Author: Matt Gilman <ma...@gmail.com>
Authored: Tue Feb 17 11:44:15 2015 -0500
Committer: Matt Gilman <ma...@gmail.com>
Committed: Tue Feb 17 11:44:15 2015 -0500
----------------------------------------------------------------------
.../src/main/webapp/js/nf/canvas/nf-actions.js | 16 ++---
.../webapp/js/nf/canvas/nf-canvas-header.js | 62 +++++++++++---------
.../webapp/js/nf/canvas/nf-canvas-toolbar.js | 15 +----
.../main/webapp/js/nf/canvas/nf-canvas-utils.js | 21 +++++++
.../main/webapp/js/nf/canvas/nf-context-menu.js | 7 +--
5 files changed, 62 insertions(+), 59 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-nifi/blob/4239797b/nifi/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/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/js/nf/canvas/nf-actions.js b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/js/nf/canvas/nf-actions.js
index 6624d52..f2dc9b3 100644
--- a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/js/nf/canvas/nf-actions.js
+++ b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/js/nf/canvas/nf-actions.js
@@ -843,17 +843,11 @@ nf.Actions = (function () {
* @param {type} selection The selection
*/
fillColor: function (selection) {
- var selectedProcessors = selection.filter(function(d) {
- return nf.CanvasUtils.isProcessor(d3.select(this));
- });
- var selectedLabels = selection.filter(function(d) {
- return nf.CanvasUtils.isLabel(d3.select(this));
- });
-
- var allProcessors = selectedProcessors.size() === selection.size();
- var allLabels = selectedLabels.size() === selection.size();
-
- if (allProcessors || allLabels) {
+ if (nf.CanvasUtils.isColorable(selection)) {
+ // we know that the entire selection is processors or labels... this
+ // checks if the first item is a processor... if true, all processors
+ var allProcessors = nf.CanvasUtils.isProcessor(selection);
+
var color;
if (allProcessors) {
color = nf.Processor.defaultColor();
http://git-wip-us.apache.org/repos/asf/incubator-nifi/blob/4239797b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/js/nf/canvas/nf-canvas-header.js
----------------------------------------------------------------------
diff --git a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/js/nf/canvas/nf-canvas-header.js b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/js/nf/canvas/nf-canvas-header.js
index 5daf415..335b145 100644
--- a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/js/nf/canvas/nf-canvas-header.js
+++ b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/js/nf/canvas/nf-canvas-header.js
@@ -182,34 +182,37 @@ nf.CanvasHeader = (function () {
// get the color and update the styles
var color = $('#fill-color').minicolors('value');
- // update the style for the specified component
- $.ajax({
- type: 'PUT',
- url: selectedData.component.uri,
- data: {
- 'version': revision.version,
- 'clientId': revision.clientId,
- 'style[background-color]': color
- },
- dataType: 'json'
- }).done(function (response) {
- // update the revision
- nf.Client.setRevision(response.revision);
-
- // update the processor
- if (nf.CanvasUtils.isProcessor(selected)) {
- nf.Processor.set(response.processor);
- } else {
- nf.Label.set(response.label);
- }
- }).fail(function (xhr, status, error) {
- if (xhr.status === 400 || xhr.status === 404 || xhr.status === 409) {
- nf.Dialog.showOkDialog({
- dialogContent: nf.Common.escapeHtml(xhr.responseText),
- overlayBackground: true
- });
- }
- });
+ // ensure the color actually changed
+ if (color !== selectedData.component.style['background-color']) {
+ // update the style for the specified component
+ $.ajax({
+ type: 'PUT',
+ url: selectedData.component.uri,
+ data: {
+ 'version': revision.version,
+ 'clientId': revision.clientId,
+ 'style[background-color]': color
+ },
+ dataType: 'json'
+ }).done(function (response) {
+ // update the revision
+ nf.Client.setRevision(response.revision);
+
+ // update the processor
+ if (nf.CanvasUtils.isProcessor(selected)) {
+ nf.Processor.set(response.processor);
+ } else {
+ nf.Label.set(response.label);
+ }
+ }).fail(function (xhr, status, error) {
+ if (xhr.status === 400 || xhr.status === 404 || xhr.status === 409) {
+ nf.Dialog.showOkDialog({
+ dialogContent: nf.Common.escapeHtml(xhr.responseText),
+ overlayBackground: true
+ });
+ }
+ });
+ }
});
// close the dialog
@@ -255,12 +258,13 @@ nf.CanvasHeader = (function () {
var hex = $('#fill-color-value').val();
// only update the fill color when its a valid hex color string
+ // #[six hex characters|three hex characters] case insensitive
if (/(^#[0-9A-F]{6}$)|(^#[0-9A-F]{3}$)/i.test(hex)) {
$('#fill-color').minicolors('value', hex);
}
};
- // initialize the fill color value
+ // apply fill color from field on blur and enter press
$('#fill-color-value').on('blur', updateColor).on('keyup', function(e) {
var code = e.keyCode ? e.keyCode : e.which;
if (code === $.ui.keyCode.ENTER) {
http://git-wip-us.apache.org/repos/asf/incubator-nifi/blob/4239797b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/js/nf/canvas/nf-canvas-toolbar.js
----------------------------------------------------------------------
diff --git a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/js/nf/canvas/nf-canvas-toolbar.js b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/js/nf/canvas/nf-canvas-toolbar.js
index 1031c6c..e2ec53e 100644
--- a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/js/nf/canvas/nf-canvas-toolbar.js
+++ b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/js/nf/canvas/nf-canvas-toolbar.js
@@ -141,19 +141,8 @@ nf.CanvasToolbar = (function () {
actions['group'].disable();
}
- // determine if the current selection is entirely processors or labels
- var selectedProcessors = selection.filter(function(d) {
- return nf.CanvasUtils.isProcessor(d3.select(this));
- });
- var selectedLabels = selection.filter(function(d) {
- return nf.CanvasUtils.isLabel(d3.select(this));
- });
-
- var allProcessors = selectedProcessors.size() === selection.size();
- var allLabels = selectedLabels.size() === selection.size();
-
- // if there are any colorable components enable the button
- if (allProcessors || allLabels) {
+ // if there are any colorable components enable the fill button
+ if (nf.CanvasUtils.isColorable(selection)) {
actions['fill'].enable();
} else {
actions['fill'].disable();
http://git-wip-us.apache.org/repos/asf/incubator-nifi/blob/4239797b/nifi/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/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/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/js/nf/canvas/nf-canvas-utils.js
index c9211b2..796ffdf 100644
--- a/nifi/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/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/js/nf/canvas/nf-canvas-utils.js
@@ -475,6 +475,27 @@ nf.CanvasUtils = (function () {
},
/**
+ * Determines if the specified selection is colorable (in a single action).
+ *
+ * @param {selection} selection The selection
+ * @returns {boolean}
+ */
+ isColorable: function(selection) {
+ // determine if the current selection is entirely processors or labels
+ var selectedProcessors = selection.filter(function(d) {
+ return nf.CanvasUtils.isProcessor(d3.select(this));
+ });
+ var selectedLabels = selection.filter(function(d) {
+ return nf.CanvasUtils.isLabel(d3.select(this));
+ });
+
+ var allProcessors = selectedProcessors.size() === selection.size();
+ var allLabels = selectedLabels.size() === selection.size();
+
+ return allProcessors || allLabels;
+ },
+
+ /**
* Determines if the specified selection is a connection.
*
* @argument {selection} selection The selection
http://git-wip-us.apache.org/repos/asf/incubator-nifi/blob/4239797b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/js/nf/canvas/nf-context-menu.js
----------------------------------------------------------------------
diff --git a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/js/nf/canvas/nf-context-menu.js b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/js/nf/canvas/nf-context-menu.js
index dfb8d7a..d9b63cd 100644
--- a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/js/nf/canvas/nf-context-menu.js
+++ b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/js/nf/canvas/nf-context-menu.js
@@ -179,12 +179,7 @@ nf.ContextMenu = (function () {
* @param {selection} selection The selection
*/
var isColorable = function (selection) {
- // ensure the correct number of components are selected
- if (selection.size() !== 1) {
- return false;
- }
-
- return nf.Common.isDFM() && (nf.CanvasUtils.isProcessor(selection) || nf.CanvasUtils.isLabel(selection));
+ return nf.Common.isDFM() && nf.CanvasUtils.isColorable(selection);
};
/**
[2/2] incubator-nifi git commit: NIFI-326: - Enabling the
Enable/Disable button whenever the selection is not empty. - On
Enable/Disable click,
the components that support the desired action are filtered. The action
(Enable/Disable) is then applied to th
Posted by mc...@apache.org.
NIFI-326:
- Enabling the Enable/Disable button whenever the selection is not empty.
- On Enable/Disable click, the components that support the desired action are filtered. The action (Enable/Disable) is then applied to the filtered selection.
Project: http://git-wip-us.apache.org/repos/asf/incubator-nifi/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-nifi/commit/0047fa45
Tree: http://git-wip-us.apache.org/repos/asf/incubator-nifi/tree/0047fa45
Diff: http://git-wip-us.apache.org/repos/asf/incubator-nifi/diff/0047fa45
Branch: refs/heads/develop
Commit: 0047fa4502223fbaff858f885496dd00fe035353
Parents: 4239797
Author: Matt Gilman <ma...@gmail.com>
Authored: Tue Feb 17 12:34:01 2015 -0500
Committer: Matt Gilman <ma...@gmail.com>
Committed: Tue Feb 17 12:34:01 2015 -0500
----------------------------------------------------------------------
.../src/main/webapp/js/nf/canvas/nf-actions.js | 15 ++++++++++++---
.../main/webapp/js/nf/canvas/nf-canvas-toolbar.js | 8 +-------
2 files changed, 13 insertions(+), 10 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-nifi/blob/0047fa45/nifi/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/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/js/nf/canvas/nf-actions.js b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/js/nf/canvas/nf-actions.js
index f2dc9b3..0af6198 100644
--- a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/js/nf/canvas/nf-actions.js
+++ b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/js/nf/canvas/nf-actions.js
@@ -349,7 +349,12 @@ nf.Actions = (function () {
enable: function () {
var components = d3.selectAll('g.component.selected').filter(function (d) {
var selected = d3.select(this);
- return (nf.CanvasUtils.isProcessor(selected) || nf.CanvasUtils.isInputPort(selected) || nf.CanvasUtils.isOutputPort(selected)) && nf.CanvasUtils.supportsModification(selected);
+ var selectedData = selected.datum();
+
+ // processors and ports that support modification and are not currently stopped
+ return (nf.CanvasUtils.isProcessor(selected) || nf.CanvasUtils.isInputPort(selected) || nf.CanvasUtils.isOutputPort(selected)) &&
+ nf.CanvasUtils.supportsModification(selected) &&
+ selectedData.component.state !== 'STOPPED';
});
if (components.empty()) {
nf.Dialog.showOkDialog({
@@ -379,7 +384,12 @@ nf.Actions = (function () {
disable: function () {
var components = d3.selectAll('g.component.selected').filter(function (d) {
var selected = d3.select(this);
- return (nf.CanvasUtils.isProcessor(selected) || nf.CanvasUtils.isInputPort(selected) || nf.CanvasUtils.isOutputPort(selected)) && nf.CanvasUtils.supportsModification(selected);
+ var selectedData = selected.datum();
+
+ // processors and ports that support modification and are not currently disabled
+ return (nf.CanvasUtils.isProcessor(selected) || nf.CanvasUtils.isInputPort(selected) || nf.CanvasUtils.isOutputPort(selected)) &&
+ nf.CanvasUtils.supportsModification(selected) &&
+ selectedData.component.state !== 'DISABLED';
});
if (components.empty()) {
nf.Dialog.showOkDialog({
@@ -435,7 +445,6 @@ nf.Actions = (function () {
data['running'] = true;
}
- // update the resource
updateResource(d.component.uri, data).done(function (response) {
if (nf.CanvasUtils.isProcessor(selected)) {
nf.Processor.set(response.processor);
http://git-wip-us.apache.org/repos/asf/incubator-nifi/blob/0047fa45/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/js/nf/canvas/nf-canvas-toolbar.js
----------------------------------------------------------------------
diff --git a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/js/nf/canvas/nf-canvas-toolbar.js b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/js/nf/canvas/nf-canvas-toolbar.js
index e2ec53e..b5702af 100644
--- a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/js/nf/canvas/nf-canvas-toolbar.js
+++ b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/js/nf/canvas/nf-canvas-toolbar.js
@@ -148,14 +148,8 @@ nf.CanvasToolbar = (function () {
actions['fill'].disable();
}
- // determine if there are any selected components that support enable/disable
- var supportsEnable = selection.filter(function(d) {
- var selected = d3.select(this);
- return nf.CanvasUtils.isProcessor(selected) || nf.CanvasUtils.isInputPort(selected) || nf.CanvasUtils.isOutputPort(selected);
- });
-
// ensure the entire selection supports enable/disable
- if (!supportsEnable.empty() && supportsEnable.size() === selection.size()) {
+ if (!selection.empty()) {
actions['enable'].enable();
actions['disable'].enable();
} else {