mtien-apache commented on a change in pull request #4846:
URL: https://github.com/apache/nifi/pull/4846#discussion_r583774545



##########
File path: 
nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/js/nf/canvas/header/components/nf-ng-group-component.js
##########
@@ -129,17 +133,78 @@
                  * Initialize the modal.
                  */
                 init: function () {
+                    var self = this;
+
+                    self.fileForm = $('#file-upload-form').ajaxForm({
+                        url: '../nifi-api/process-groups/',
+                        dataType: 'json',
+                        beforeSubmit: function ($form, options) {
+                            // ensure uploading to the current process group
+                            options.url += 
(encodeURIComponent(nfCanvasUtils.getGroupId()) + '/process-groups/upload');
+                        }
+                    });
+
                     // configure the new process group dialog
                     this.getElement().modal({
                         scrollableContentStyle: 'scrollable',
                         headerText: 'Add Process Group',
                         handler: {
                             close: function () {
+                                self.fileToBeUploaded = null;
+                                $('#selected-file-name').text('');
+                                $('#upload-file-field').val('');
                                 $('#new-process-group-name').val('');
                                 
$('#new-process-group-dialog').removeData('pt');
+
+                                // reset the form to ensure that the change 
fire will fire
+                                self.fileForm.resetForm();
                             }
                         }
                     });
+
+                    $('#upload-file-field-button').on('click', function (e) {
+                        $('#upload-file-field').click();
+                    });
+
+                    $('#upload-file-field').on('change', function (e) {
+                        $('#upload-file-field-button').hide();
+
+                        self.fileToBeUploaded = e.target;
+                        var filename = $(this).val();
+                        var filenameExtension;
+                        if (!nfCommon.isBlank(filename)) {
+                            filenameExtension = filename.replace(/^.*[\\\/]/, 
'');
+                            filename = filename.replace(/^.*[\\\/]/, 
'').replace(/\..*/, '');

Review comment:
       Revised - I moved to two separate methods describing its functions.




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


Reply via email to