nifi-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mcgil...@apache.org
Subject [1/2] incubator-nifi git commit: NIFI-475: - Prompting the user to save changes before navigating to the controller service definition.
Date Tue, 07 Apr 2015 16:35:51 GMT
Repository: incubator-nifi
Updated Branches:
  refs/heads/NIFI-475 74f1dad44 -> eb5912711


NIFI-475:
- Prompting the user to save changes before navigating to the controller service definition.

Project: http://git-wip-us.apache.org/repos/asf/incubator-nifi/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-nifi/commit/780da7f3
Tree: http://git-wip-us.apache.org/repos/asf/incubator-nifi/tree/780da7f3
Diff: http://git-wip-us.apache.org/repos/asf/incubator-nifi/diff/780da7f3

Branch: refs/heads/NIFI-475
Commit: 780da7f388584ada4bb5c25491aa1e1096896193
Parents: 74f1dad
Author: Matt Gilman <matt.c.gilman@gmail.com>
Authored: Tue Apr 7 11:56:40 2015 -0400
Committer: Matt Gilman <matt.c.gilman@gmail.com>
Committed: Tue Apr 7 11:56:40 2015 -0400

----------------------------------------------------------------------
 .../js/nf/canvas/nf-controller-service.js       |   4 +
 .../js/nf/canvas/nf-processor-configuration.js  | 134 +++++++++++--------
 2 files changed, 85 insertions(+), 53 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-nifi/blob/780da7f3/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/js/nf/canvas/nf-controller-service.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-controller-service.js
b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/js/nf/canvas/nf-controller-service.js
index 2584bc2..39bbe64 100644
--- a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/js/nf/canvas/nf-controller-service.js
+++ b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/js/nf/canvas/nf-controller-service.js
@@ -1141,6 +1141,10 @@ nf.ControllerService = (function () {
                     });
                 }
             }).fail(handleControllerServiceConfigurationError);
+        } else {
+            return $.Deferred(function (deferred) {
+                deferred.reject();
+            }).promise();
         }
     };
     

http://git-wip-us.apache.org/repos/asf/incubator-nifi/blob/780da7f3/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/js/nf/canvas/nf-processor-configuration.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-processor-configuration.js
b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/js/nf/canvas/nf-processor-configuration.js
index be3e4c1..2e48579 100644
--- a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/js/nf/canvas/nf-processor-configuration.js
+++ b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/js/nf/canvas/nf-processor-configuration.js
@@ -380,6 +380,70 @@ nf.ProcessorConfiguration = (function () {
             }
         });
     };
+    
+    /**
+     * Goes to a service configuration from the property table.
+     */
+    var goToServiceFromProperty = function () {
+        return $.Deferred(function (deferred) {
+            // close all fields currently being edited
+            $('#processor-properties').propertytable('saveRow');
+
+            // determine if changes have been made
+            if (isSaveRequired()) {
+                // see if those changes should be saved
+                nf.Dialog.showYesNoDialog({
+                    dialogContent: 'Save changes before going to this Controller Service?',
+                    overlayBackground: false,
+                    noHandler: function () {
+                        deferred.resolve();
+                    },
+                    yesHandler: function () {
+                        var processor = $('#processor-configuration').data('processorDetails');
+                        saveProcessor(processor).done(function () {
+                            deferred.resolve();
+                        }).fail(function () {
+                            deferred.reject();
+                        });
+                    }
+                });
+            } else {
+                deferred.resolve();
+            }
+        }).promise();
+    };
+    
+    /**
+     * 
+     * @param {type} processor
+     * @returns {undefined}
+     */
+    var saveProcessor = function (processor) {
+        // marshal the settings and properties and update the processor
+        var updatedProcessor = marshalDetails();
+
+        // ensure details are valid as far as we can tell
+        if (validateDetails(updatedProcessor)) {
+            // update the selected component
+            return $.ajax({
+                type: 'PUT',
+                data: JSON.stringify(updatedProcessor),
+                url: processor.uri,
+                dataType: 'json',
+                processData: false,
+                contentType: 'application/json'
+            }).done(function (response) {
+                if (nf.Common.isDefinedAndNotNull(response.processor)) {
+                    // update the revision
+                    nf.Client.setRevision(response.revision);
+                }
+            }).fail(handleProcessorConfigurationError);
+        } else {
+            return $.Deferred(function (deferred) {
+                deferred.reject();
+            }).promise();
+        }
+    };
 
     return {
         /**
@@ -481,7 +545,8 @@ nf.ProcessorConfiguration = (function () {
                         },
                         dataType: 'json'
                     }).fail(nf.Common.handleAjaxError);
-                }
+                },
+                goToServiceDeferred: goToServiceFromProperty
             });
         },
         
@@ -625,35 +690,17 @@ nf.ProcessorConfiguration = (function () {
                                     // close all fields currently being edited
                                     $('#processor-properties').propertytable('saveRow');
 
-                                    // marshal the settings and properties and update the
processor
-                                    var updatedProcessor = marshalDetails();
-
-                                    // ensure details are valid as far as we can tell
-                                    if (validateDetails(updatedProcessor)) {
-                                        // update the selected component
-                                        $.ajax({
-                                            type: 'PUT',
-                                            data: JSON.stringify(updatedProcessor),
-                                            url: processor.uri,
-                                            dataType: 'json',
-                                            processData: false,
-                                            contentType: 'application/json'
-                                        }).done(function (response) {
-                                            if (nf.Common.isDefinedAndNotNull(response.processor))
{
-                                                // update the revision
-                                                nf.Client.setRevision(response.revision);
-
-                                                // set the new processor state based on the
response
-                                                nf.Processor.set(response.processor);
-
-                                                // reload the processor's outgoing connections
-                                                reloadProcessorConnections(processor);
-
-                                                // close the details panel
-                                                $('#processor-configuration').modal('hide');
-                                            }
-                                        }).fail(handleProcessorConfigurationError);
-                                    }
+                                    // save the processor
+                                    saveProcessor(processor).done(function (response) {
+                                        // set the new processor state based on the response
+                                        nf.Processor.set(response.processor);
+
+                                        // reload the processor's outgoing connections
+                                        reloadProcessorConnections(processor);
+
+                                        // close the details panel
+                                        $('#processor-configuration').modal('hide');
+                                    });
                                 }
                             }
                         }, {
@@ -696,29 +743,10 @@ nf.ProcessorConfiguration = (function () {
                                             overlayBackground: false,
                                             noHandler: openCustomUi,
                                             yesHandler: function () {
-                                                // marshal the settings and properties and
update the processor
-                                                var updatedProcessor = marshalDetails();
-
-                                                // ensure details are valid as far as we
can tell
-                                                if (validateDetails(updatedProcessor)) {
-                                                    // update the selected component
-                                                    $.ajax({
-                                                        type: 'PUT',
-                                                        data: JSON.stringify(updatedProcessor),
-                                                        url: processor.uri,
-                                                        dataType: 'json',
-                                                        processData: false,
-                                                        contentType: 'application/json'
-                                                    }).done(function (response) {
-                                                        if (nf.Common.isDefinedAndNotNull(response.processor))
{
-                                                            // update the revision
-                                                            nf.Client.setRevision(response.revision);
-
-                                                            // open the custom ui
-                                                            openCustomUi();
-                                                        }
-                                                    }).fail(handleProcessorConfigurationError);
-                                                }
+                                                saveProcessor(processor).done(function (deferred)
{
+                                                    // open the custom ui
+                                                    openCustomUi();
+                                                });
                                             }
                                         });
                                     } else {


Mime
View raw message