|
13 | 13 | xhr.open("GET", url, true);
|
14 | 14 | xhr.send();
|
15 | 15 | }
|
16 |
| - document.addEventListener("DOMContentLoaded", function () { |
17 |
| - // Function to add links after the Docs link |
18 |
| - function addLinks(username, oidcLink, logoutLink) { |
| 16 | + |
| 17 | + function waitForDocsLink(callback) { |
| 18 | + var docsLink = document.querySelector('a[href="https://www.mlflow.org/docs/latest/index.html"]'); |
| 19 | + if (docsLink) { |
| 20 | + callback(docsLink); |
| 21 | + return; |
| 22 | + } |
| 23 | + var observer = new MutationObserver(function (mutations, obs) { |
19 | 24 | var docsLink = document.querySelector('a[href="https://www.mlflow.org/docs/latest/index.html"]');
|
20 |
| - if (!docsLink) { |
21 |
| - console.error("Docs link not found."); |
22 |
| - return; |
| 25 | + if (docsLink) { |
| 26 | + obs.disconnect(); |
| 27 | + callback(docsLink); |
23 | 28 | }
|
| 29 | + }); |
| 30 | + observer.observe(document.body, { childList: true, subtree: true }); |
| 31 | + } |
| 32 | + |
| 33 | + document.addEventListener("DOMContentLoaded", function () { |
| 34 | + function addLinks(username, oidcLink, logoutLink, docsLink) { |
24 | 35 | var parentDiv = docsLink.parentElement;
|
25 | 36 | function createLinkElement(text, link) {
|
26 | 37 | var linkElement = document.createElement('a');
|
|
39 | 50 | parentDiv.appendChild(createLinkElement('Logout', logoutLink));
|
40 | 51 | }
|
41 | 52 | // Get username and add links after Docs
|
42 |
| - makeRequest("api/2.0/mlflow/users/current", function (error, response) { |
| 53 | + makeRequest("api/2.0/mlflow/permissions/users/current", function (error, response) { |
43 | 54 | if (error) {
|
44 | 55 | console.error("Error fetching username:", error);
|
45 | 56 | return;
|
46 | 57 | }
|
47 | 58 | var username = response.display_name;
|
48 | 59 | var oidcLink = "/oidc/ui/";
|
49 | 60 | var logoutLink = "/logout";
|
50 |
| - addLinks(username, oidcLink, logoutLink); |
| 61 | + waitForDocsLink(function(docsLink) { |
| 62 | + addLinks(username, oidcLink, logoutLink, docsLink); |
| 63 | + }); |
51 | 64 | });
|
52 | 65 | });
|
53 | 66 | </script>
|
0 commit comments