You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@nifi.apache.org by GitBox <gi...@apache.org> on 2019/04/25 19:15:44 UTC

[GitHub] [nifi] aeaversa commented on a change in pull request #3281: NIFI-5986 Adding "Stop & Configure" button functionality to Processor…

aeaversa commented on a change in pull request #3281: NIFI-5986 Adding "Stop & Configure" button functionality to Processor…
URL: https://github.com/apache/nifi/pull/3281#discussion_r278693906
 
 

 ##########
 File path: nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/js/jquery/statusbar/jquery.statusbar.js
 ##########
 @@ -0,0 +1,287 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/**
+ * Create a new status bar.
+ *
+ *  $(selector).statusbar();
+ *
+ *
+ */
+(function ($) {
+
+    // static key path variables
+    var PROCESSOR_ID_KEY = 'component.id',
+        ACTIVE_THREAD_COUNT_KEY = 'status.aggregateSnapshot.activeThreadCount',
+        RUN_STATUS_KEY = 'status.aggregateSnapshot.runStatus',
+        BULLETINS_KEY = 'bulletins';
+
+    var isUndefined = function (obj) {
+        return typeof obj === 'undefined';
+    };
+
+    var isNull = function (obj) {
+        return obj === null;
+    };
+
+    var isDefinedAndNotNull = function (obj) {
+        return !isUndefined(obj) && !isNull(obj);
+    };
+
+    var getKeyValue = function(obj,key){
+        return key.split('.').reduce(function(o,x){
+            return(typeof o === undefined || o === null)? o : (typeof o[x] == 'function')?o[x]():o[x];
+        }, obj);
+    }
+
+    var methods = {
+
+        /**
+         * Initializes the status bar.
+         */
+        init: function () {
+            // get the combo
+            var bar = $(this).addClass('dialog-status-bar');;
+
+            bar.html('<text class="run-status-icon"></text>'+
+                     '<span class="dialog-status-bar-state"></span>'+
+                     '<span class="dialog-status-bar-threads" count="0"></span>'+
+                     '<div class="dialog-status-bar-bulletins fa fa-sticky-note-o" count="0">'+
+                         '<div class="dialog-status-bar-bulletins-content"></div>'+
+                     '</div>'+
+                     '<div class="dialog-status-bar-buttons"></div>');
+            return bar;
+        },
+
+        /**
+         * Shows the  status bar.
+         */
+        show: function () {
+            var bar = $(this);
+            if (bar.is(':visible')) {
+                bar.show();
+            }
+            return bar;
+        },
+
+        /**
+         * Hides the status bar.
+         */
+        hide: function () {
+            var bar = $(this);
+            if (bar.is(':visible')) {
+                bar.hide();
+            }
+            return bar;
+        },
+
+
+        /**
+         * Initializes the synchronization process to the canvas element
+         *
+         * @param {object/fn} current selectionObject to observe
+         */
+        observe: function(statusObj) {
+            var bar = $(this);
+            var selector = getKeyValue(((typeof statusObj == 'function')?statusObj():statusObj),PROCESSOR_ID_KEY);
+            var g = document.querySelector('g[id="id-'+selector+'"]');
+
+            //perform the initial set
+            bar.statusbar('set',statusObj);
+
+            //create and store an observer
+            bar.data('observer',new MutationObserver(function(mutations){
 
 Review comment:
   @mcgilman - It was a function simply to allow the statusbar to re-query the object for the latest values when a mutation the DOM element is detected, as well as allowing other functionality to execute in the parent dialog when a mutation is observed. I agree its a little confusing so I refactored to simply pass in the processor id to query and a separate callback. 

----------------------------------------------------------------
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:
users@infra.apache.org


With regards,
Apache Git Services