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/03/13 19:48:23 UTC

incubator-nifi git commit: NIFI-250: - Updating the controller service dialog to support a read only and editable modes.

Repository: incubator-nifi
Updated Branches:
  refs/heads/NIFI-250 40670067c -> a1a769104


NIFI-250:
- Updating the controller service dialog to support a read only and editable modes.

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

Branch: refs/heads/NIFI-250
Commit: a1a769104881eaf44ca9736cd185edc972eb5807
Parents: 4067006
Author: Matt Gilman <ma...@gmail.com>
Authored: Fri Mar 13 14:48:08 2015 -0400
Committer: Matt Gilman <ma...@gmail.com>
Committed: Fri Mar 13 14:48:08 2015 -0400

----------------------------------------------------------------------
 .../canvas/reporting-task-configuration.jsp     |  17 ++-
 .../webapp/js/nf/canvas/nf-reporting-task.js    | 118 ++++++++++++++++++-
 .../src/main/webapp/js/nf/canvas/nf-settings.js |   2 +-
 3 files changed, 131 insertions(+), 6 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-nifi/blob/a1a76910/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/WEB-INF/partials/canvas/reporting-task-configuration.jsp
----------------------------------------------------------------------
diff --git a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/WEB-INF/partials/canvas/reporting-task-configuration.jsp b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/WEB-INF/partials/canvas/reporting-task-configuration.jsp
index b138779..29737ea 100644
--- a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/WEB-INF/partials/canvas/reporting-task-configuration.jsp
+++ b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/WEB-INF/partials/canvas/reporting-task-configuration.jsp
@@ -23,13 +23,16 @@
                 <div class="settings-left">
                     <div class="setting">
                         <div class="setting-name">Name</div>
-                        <div class="setting-field">
+                        <div class="reporting-task-editable setting-field">
                             <input type="text" id="reporting-task-name" name="reporting-task-name"/>
                             <div class="reporting-task-enabled-container">
                                 <div id="reporting-task-enabled" class="nf-checkbox checkbox-unchecked"></div>
                                 <span> Enabled</span>
                             </div>
                         </div>
+                        <div class="reporting-task-read-only setting-field hidden">
+                            <span id="read-only-reporting-task-name"></span>
+                        </div>
                     </div>
                     <div class="setting">
                         <div class="setting-name">Id</div>
@@ -64,8 +67,11 @@
                                 Scheduling strategy
                                 <img class="setting-icon icon-info" src="images/iconInfo.png" alt="Info" title="The strategy used to schedule this reporting task."/>
                             </div>
-                            <div class="setting-field">
-                                <div type="text" id="reporting-task-scheduling-strategy-combo"></div>
+                            <div class="reporting-task-editable setting-field">
+                                <div id="reporting-task-scheduling-strategy-combo"></div>
+                            </div>
+                            <div class="reporting-task-read-only setting-field hidden">
+                                <span id="read-only-reporting-task-scheduling-strategy"></span>
                             </div>
                         </div>
                         <div class="reporting-task-scheduling-period-container">
@@ -73,10 +79,13 @@
                                 Run schedule
                                 <img class="setting-icon icon-info" src="images/iconInfo.png" alt="Info" title="The amount of time that should elapse between task executions."/>
                             </div>
-                            <div class="setting-field">
+                            <div class="reporting-task-editable setting-field">
                                 <input type="text" id="reporting-task-timer-driven-scheduling-period" class="reporting-task-scheduling-period small-setting-input"/>
                                 <input type="text" id="reporting-task-cron-driven-scheduling-period" class="reporting-task-scheduling-period small-setting-input"/>
                             </div>
+                            <div class="reporting-task-read-only setting-field hidden">
+                                <span id="read-only-reporting-task-scheduling-period"></span>
+                            </div>
                         </div>
                         <div class="clear"></div>
                     </div>

http://git-wip-us.apache.org/repos/asf/incubator-nifi/blob/a1a76910/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/js/nf/canvas/nf-reporting-task.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-reporting-task.js b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/js/nf/canvas/nf-reporting-task.js
index c9af041..699b695 100644
--- a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/js/nf/canvas/nf-reporting-task.js
+++ b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/js/nf/canvas/nf-reporting-task.js
@@ -18,6 +18,11 @@
 /* global nf */
 
 nf.ReportingTask = (function () {
+    
+    var config = {
+        edit: 'edit',
+        readOnly: 'read-only'
+    };
 
     /**
      * Handle any expected reporting task configuration errors.
@@ -244,7 +249,7 @@ nf.ReportingTask = (function () {
             }
 
             // initialize the reporting task configuration dialog
-            $('#reporting-task-configuration').modal({
+            $('#reporting-task-configuration').data('mode', config.edit).modal({
                 headerText: 'Configure Reporting Task',
                 overlayBackground: false,
                 handler: {
@@ -277,6 +282,22 @@ nf.ReportingTask = (function () {
          * @argument {reportingTask} reportingTask      The reporting task
          */
         showConfiguration: function (reportingTask) {
+            var reportingTaskDialog = $('#reporting-task-configuration');
+            if (reportingTaskDialog.data('mode') === config.readOnly) {
+                // update the visibility
+                $('#reporting-task-configuration .reporting-task-read-only').hide();
+                $('#reporting-task-configuration .reporting-task-editable').show();
+                
+                // initialize the property table
+                $('#reporting-task-properties').propertytable({
+                    readOnly: false,
+                    newPropertyDialogContainer: '#new-reporting-task-property-container'
+                });
+                
+                // update the mode
+                reportingTaskDialog.data('mode', config.edit);
+            }
+            
             // reload the task in case the property descriptors have changed
             var reloadTask = $.ajax({
                 type: 'GET',
@@ -477,8 +498,103 @@ nf.ReportingTask = (function () {
             }).fail(nf.Common.handleAjaxError);
         }, 
         
+        /**
+         * Shows the reporting task details in a read only dialog.
+         * 
+         * @param {object} reportingTask
+         */
         showDetails: function(reportingTask) {
+            var reportingTaskDialog = $('#reporting-task-configuration');
+            if (reportingTaskDialog.data('mode') === config.edit) {
+                // update the visibility
+                $('#reporting-task-configuration .reporting-task-read-only').show();
+                $('#reporting-task-configuration .reporting-task-editable').hide();
+                
+                // initialize the property table
+                $('#reporting-task-properties').propertytable({
+                    readOnly: true,
+                    newPropertyDialogContainer: '#new-reporting-task-property-container'
+                });
+                
+                // update the mode
+                reportingTaskDialog.data('mode', config.readOnly);
+            }
             
+            // reload the task in case the property descriptors have changed
+            var reloadTask = $.ajax({
+                type: 'GET',
+                url: reportingTask.uri,
+                dataType: 'json'
+            });
+            
+            // get the reporting task history
+            var loadHistory = $.ajax({
+                type: 'GET',
+                url: '../nifi-api/controller/history/reporting-tasks/' + encodeURIComponent(reportingTask.id),
+                dataType: 'json'
+            });
+            
+            // once everything is loaded, show the dialog
+            $.when(reloadTask, loadHistory).done(function (taskResponse, historyResponse) {
+                // get the updated reporting task
+                reportingTask = taskResponse[0].reportingTask;
+                
+                // get the reporting task history
+                var reportingTaskHistory = historyResponse[0].componentHistory;
+                
+                // populate the reporting task settings
+                $('#reporting-task-id').text(reportingTask['id']);
+                $('#reporting-task-type').text(nf.Common.substringAfterLast(reportingTask['type'], '.'));
+                $('#read-only-reporting-task-name').text(reportingTask['name']);
+
+                // select the availability when appropriate
+                if (nf.Canvas.isClustered()) {
+                    if (reportingTask['availability'] === 'node') {
+                        $('#availability').text('Node');
+                    } else {
+                        $('#availability').text('Cluster Manager');
+                    }
+                }
+                
+                // scheduling
+                $('#read-only-reporting-task-scheduling-strategy').text(reportingTask['schedulingStrategy']);
+                $('#read-only-reporting-task-scheduling-period').text(reportingTask['schedulingPeriod']);
+                
+                var buttons = [{
+                        buttonText: 'Ok',
+                        handler: {
+                            click: function () {
+                                // hide the dialog
+                                reportingTaskDialog.modal('hide');
+                            }
+                        }
+                    }];
+
+                // determine if we should show the advanced button
+                if (nf.Common.isDefinedAndNotNull(nf.CustomProcessorUi) && nf.Common.isDefinedAndNotNull(reportingTask.customUiUrl) && reportingTask.customUiUrl !== '') {
+                    buttons.push({
+                        buttonText: 'Advanced',
+                        handler: {
+                            click: function () {
+                                // reset state and close the dialog manually to avoid hiding the faded background
+                                reportingTaskDialog.modal('hide');
+
+                                // show the custom ui
+                                nf.CustomProcessorUi.showCustomUi(reportingTask.id, reportingTask.customUiUrl, false);
+                            }
+                        }
+                    });
+                }
+                
+                // show the dialog
+                reportingTaskDialog.modal('setButtonModel', buttons).modal('show');
+                
+                // load the property table
+                $('#controller-service-properties').propertytable('loadProperties', reportingTask.properties, reportingTask.descriptors, reportingTaskHistory.propertyHistory);
+                
+                // show the details
+                reportingTaskDialog.modal('show');
+            });
         },
         
         /**

http://git-wip-us.apache.org/repos/asf/incubator-nifi/blob/a1a76910/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/js/nf/canvas/nf-settings.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-settings.js b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/js/nf/canvas/nf-settings.js
index fc01532..d3a3eff 100644
--- a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/js/nf/canvas/nf-settings.js
+++ b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/js/nf/canvas/nf-settings.js
@@ -1439,7 +1439,7 @@ nf.Settings = (function () {
                 }
             } else if (reportingTasksGrid.getColumns()[args.cell].id === 'moreDetails') {
                 if (target.hasClass('view-reporting-task')) {
-
+                    nf.ReportingTask.showDetails(reportingTask);
                 }
             }
         });