You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ambari.apache.org by ji...@apache.org on 2024/09/03 00:55:05 UTC

(ambari) branch trunk updated: AMBARI-26107: Migrate away from DOMNodeInserted to MutationObserver (ambari-admin) (#3819)

This is an automated email from the ASF dual-hosted git repository.

jialiang pushed a commit to branch trunk
in repository https://gitbox.apache.org/repos/asf/ambari.git


The following commit(s) were added to refs/heads/trunk by this push:
     new 98b4cb0189 AMBARI-26107: Migrate away from DOMNodeInserted to MutationObserver (ambari-admin) (#3819)
98b4cb0189 is described below

commit 98b4cb01896e01e9a96ffd9025eeb7500160dcab
Author: Prabhjyot <pr...@acceldata.io>
AuthorDate: Mon Sep 2 20:54:59 2024 -0400

    AMBARI-26107: Migrate away from DOMNodeInserted to MutationObserver (ambari-admin) (#3819)
---
 .../app/scripts/controllers/SideNavCtrl.js         | 29 ++++++++++++++++------
 1 file changed, 21 insertions(+), 8 deletions(-)

diff --git a/ambari-admin/src/main/resources/ui/admin-web/app/scripts/controllers/SideNavCtrl.js b/ambari-admin/src/main/resources/ui/admin-web/app/scripts/controllers/SideNavCtrl.js
index 6bf356d796..2e3e820513 100644
--- a/ambari-admin/src/main/resources/ui/admin-web/app/scripts/controllers/SideNavCtrl.js
+++ b/ambari-admin/src/main/resources/ui/admin-web/app/scripts/controllers/SideNavCtrl.js
@@ -35,14 +35,27 @@ angular.module('ambariAdminConsole')
   }
 
   function initNavigationBar () {
-    $('body').on('DOMNodeInserted', '.navigation-bar', function() {
-      $('.navigation-bar').navigationBar({
-        fitHeight: true,
-        collapseNavBarClass: 'fa-angle-double-left',
-        expandNavBarClass: 'fa-angle-double-right'
-      });
-      //initTooltips();
-      $('body').off('DOMNodeInserted', '.navigation-bar');
+    const observer = new MutationObserver(mutations => {
+      var targetNode
+      if (mutations.some((mutation) => mutation.type === 'childList' && (targetNode = $('.navigation-bar')).length)) {
+        observer.disconnect();
+        //initTooltips();
+        targetNode.navigationBar({
+          fitHeight: true,
+          collapseNavBarClass: 'fa-angle-double-left',
+          expandNavBarClass: 'fa-angle-double-right'
+        });
+      }
+    });
+
+    setTimeout(() => {
+      // remove observer if selected element is not found in 10secs.
+      observer.disconnect();
+    }, 10000)
+
+    observer.observe(document.body, {
+      childList: true,
+      subtree: true
     });
   }
 


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@ambari.apache.org
For additional commands, e-mail: commits-help@ambari.apache.org