diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2023-07-20 04:49:55 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2023-07-20 04:49:55 +0000 |
commit | ab1bb5b7f1c3c3a7b240ab7fc8661459ecd7decb (patch) | |
tree | 7a900833aad3ccc685712c6c2a7d87576d54f427 /web/gui/v2live.html | |
parent | Adding upstream version 1.40.1. (diff) | |
download | netdata-ab1bb5b7f1c3c3a7b240ab7fc8661459ecd7decb.tar.xz netdata-ab1bb5b7f1c3c3a7b240ab7fc8661459ecd7decb.zip |
Adding upstream version 1.41.0.upstream/1.41.0
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'web/gui/v2live.html')
-rw-r--r-- | web/gui/v2live.html | 230 |
1 files changed, 230 insertions, 0 deletions
diff --git a/web/gui/v2live.html b/web/gui/v2live.html new file mode 100644 index 00000000..36050c0f --- /dev/null +++ b/web/gui/v2live.html @@ -0,0 +1,230 @@ +<!doctype html><html><head><title>Netdata Console</title><script>var pathsRegex = /\/(spaces|nodes|overview|alerts|dashboards|anomalies|events|cloud|v2)\/?.*/ + var getBasename = function() { + return window.location.origin + window.location.pathname.replace(pathsRegex, "") + } + var goToOld = function(path) { + var goToUrl = getBasename() + path; + if (path === "/v2") { + var pathsRegex = /(\/(spaces|nodes|overview|alerts|dashboards|anomalies|events|cloud)\/?.*)/ + goToUrl = (window.location.origin + window.location.pathname).replace(pathsRegex, "/v2$1") + } + window.location.replace((goToUrl + window.location.search).replace(/([^:]\/)\/+/g, "$1")) + } + var getAssetFile = function(path) { + window.location.replace(__webpack_public_path__ + path) + } + var searchParams = new URLSearchParams(location.search) + window.envSettings = { + isAgent: true, + apiUrl: "https://app.netdata.cloud", + cloudUrl: "https://app.netdata.cloud", + uiUrl: "https://app.netdata.cloud", + webpackPublicPath: "https://app.netdata.cloud", + agentApiUrl: searchParams.get("agent") || getBasename(), + version: "6.20.2", + tracking: false, + cookieDomain: ".netdata.cloud", + } + + __webpack_public_path__ = (window.envSettings.webpackPublicPath ? "https://app.netdata.cloud/" : (window.envSettings.agentApiUrl + "/v2/")).replace(/([^:]\/)\/+/g, "$1") + + function loadStyle(url, { media, insertAfter: aref, insertBefore: bref, rel, type } = {}) { + rel = rel || 'stylesheet' + type = type || 'text/css' + return new Promise(function(resolve, reject) { + var link = document.createElement('link'); + link.type = type; + link.rel = rel; + link.href = url; + link.media = media || 'all'; + + link.onerror = function(err) { + reject(new URIError(`loadStyle: the stylesheet ${err.target.src} is not accessible.`)); + }; + + link.onload = function() { + resolve(); + }; + + if (aref) { + aref.parentNode.insertBefore(link, aref.nextSibling); + return; + } + + if (bref) { + bref.parentNode.insertBefore(link, bref); + return; + } + + document.head.appendChild(link); + }); + } + + loadStyle(window.envSettings.agentApiUrl + "/v2/static/splash.css") + loadStyle(window.envSettings.agentApiUrl + "/v2/favicon.ico", {rel: "icon", type: "image/x-icon"})</script><meta name="application-name" content="netdata"/><meta http-equiv="Content-Type" content="text/html; charset=utf-8"/><meta charset="utf-8"/><meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1"/><meta name="viewport" content="width=device-width,height=device-height,initial-scale=1,minimum-scale=1"/><meta name="apple-mobile-web-app-capable" content="yes"/><meta name="apple-mobile-web-app-status-bar-style" content="black-translucent"/></head><body><div id="app"><div id="agent-splash-screen" class="loading"><div class="hero"><div class="logo-container"><svg width="133" height="105" viewBox="0 0 133 105" fill="none" xmlns="http://www.w3.org/2000/svg" class="logo-blur"><path fill-rule="evenodd" clip-rule="evenodd" d="M81.697 105H55.0693L0.5 0.5H77.9598C108.079 0.554913 132.484 24.7711 132.5 54.6451C132.452 82.485 109.73 105 81.697 105Z" fill="rgba(0,171,68,0.1)"/></svg> <svg width="133" height="105" viewBox="0 0 133 105" fill="none" xmlns="http://www.w3.org/2000/svg" class="logo"><path fill-rule="evenodd" clip-rule="evenodd" d="M81.697 105H55.0693L0.5 0.5H77.9598C108.079 0.554913 132.484 24.7711 132.5 54.6451C132.452 82.485 109.73 105 81.697 105Z" fill="#DDFFEB"/></svg></div><div class="headings"><h1 class="title">Welcome to Netdata</h1><div class="loading-message"><p class="subtitle">Loading latest Netdata Cloud UI...</p><div class="flex-center">We couldn't load the latest Netdata Cloud UI. <a class="button ghost" href="javascript:location.reload();">You can try again <svg width="24" height="24" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg"><path d="M18.364 8.05001L17.657 7.34301C16.318 6.00369 14.5472 5.18285 12.6598 5.02654C10.7724 4.87022 8.89077 5.38856 7.34966 6.48934C5.80855 7.59011 4.70794 9.20193 4.24365 11.038C3.77936 12.8741 3.98151 14.8153 4.81412 16.5164C5.64674 18.2174 7.05583 19.5678 8.79067 20.3275C10.5255 21.0871 12.4736 21.2067 14.2883 20.6648C16.103 20.123 17.6666 18.955 18.701 17.3685C19.7353 15.782 20.1733 13.8801 19.937 12.001M18.364 8.05001L14.121 8.05101M18.364 8.05001V3.80701" stroke="#00ab44" stroke-width="2.5" stroke-linecap="round" stroke-linejoin="round"/></svg></a></div></div></div></div><div class="flex-center">Or you can load the <a class="button ghost" href="javascript:goToOld('/v1');">old single node dashboard</a> or a <a class="button ghost" href="javascript:goToOld('/v2');">local copy</a> of Netdata Cloud UI</div><div class="flex-center terms"><a href="javascript:getAssetFile('/LICENSE.txt');">Netdata Cloud UI license</a></div></div></div><script>var status = { + TIMEOUT: 'timeout', + SUCCESS: 'success', + SKIPPED: 'skipped' + }; + function loadScript( + url, + { async = true, defer = false, insertAfter: aref, insertBefore: bref, timeout = 5000, attrs, skipIf } = {} + ) { + return new Promise(function(resolve, reject) { + if (typeof skipIf === 'function' && skipIf()) { + resolve(status.SKIPPED); + return; + } + + var rejectWithTimeout = setTimeout(function() { reject(status.TIMEOUT) }, timeout); + + var script = document.createElement('script'); + script.type = 'text/javascript'; + script.src = url; + script.async = async; + script.defer = defer; + + if (attrs) { + for (var attr in attrs) { + script.setAttribute(attr, attrs[attr]); + } + } + + script.onerror = function(err) { + reject(new URIError(`loadScript: the script ${err.target.src} is not accessible.`)); + }; + + script.onload = function() { + clearTimeout(rejectWithTimeout); + resolve(status.SUCCESS); + }; + + if (aref) { + aref.parentNode.insertBefore(script, aref.nextSibling); + return; + } + + if (bref) { + bref.parentNode.insertBefore(script, bref); + return; + } + + document.body.appendChild(script); + }); + } + + fetch(window.envSettings.agentApiUrl + "/api/v1/registry?action=hello", { cache: "no-cache", credentials: "include" }) + .then(function(response) { return response.json() }) + .then(function(data) { + window.envSettings.apiUrl = data.cloud_base_url + window.envSettings.cloudUrl = data.cloud_base_url + + window.localNetdataRegistry = { + anonymousStatistics: data.anonymous_statistics, + registry: data.registry, + isNetdataRegistry: data.registry === "https://registry.my-netdata.io", + hostname: data.hostname, + mg: data.machine_guid + } + + if (window.localNetdataRegistry.anonymousStatistics) { + ;(function (w, d, s, l, i) { + w[l] = w[l] || [] + w[l].push({ + "gtm.start": new Date().getTime(), + event: "gtm.js", + }) + var f = d.getElementsByTagName(s)[0], + j = d.createElement(s), + dl = l != "dataLayer" ? "&l=" + l : "" + j.async = true + j.src = "https://www.googletagmanager.com/gtm.js?id=" + i + dl + f.parentNode.insertBefore(j, f) + })(window, document, "script", "dataLayer", "GTM-N6CBMJD") + + loadScript("https://www.googletagmanager.com/gtag/js?id=G-J69Z2JCTFB", { + async: true, + }) + window.dataLayer = window.dataLayer || [] + window.gtag = function() { + window.dataLayer.push(arguments) + } + + window.gtag("consent", "default", { + "ad_storage": "granted", + "analytics_storage": "granted", + "functionality_storage": "granted", + "personalization_storage": "granted" + }) + gtag("js", new Date()); + gtag("config", "G-J69Z2JCTFB"); + + !function(t,e){var o,n,p,r;e.__SV||(window.posthog=e,e._i=[],e.init=function(i,s,a){function g(t,e){var o=e.split(".");2==o.length&&(t=t[o[0]],e=o[1]),t[e]=function(){t.push([e].concat(Array.prototype.slice.call(arguments,0)))}}(p=t.createElement("script")).type="text/javascript",p.async=!0,p.src=s.api_host+"/static/array.js",(r=t.getElementsByTagName("script")[0]).parentNode.insertBefore(p,r);var u=e;for(void 0!==a?u=e[a]=[]:a="posthog",u.people=u.people||[],u.toString=function(t){var e="posthog";return"posthog"!==a&&(e+="."+a),t||(e+=" (stub)"),e},u.people.toString=function(){return u.toString(1)+".people (stub)"},o="capture identify alias people.set people.set_once set_config register register_once unregister opt_out_capturing has_opted_out_capturing opt_in_capturing reset isFeatureEnabled onFeatureFlags opt_in_site_apps".split(" "),n=0;n<o.length;n++)g(u,o[n]);e._i.push([i,s,a])},e.__SV=1)}(document,window.posthog||[]); + posthog.init("phc_hnhlqe6D2Q4IcQNrFItaqdXJAxQ8RcHkPAFAp74pubv", { api_host: "https://app.posthog.com", disable_session_recording: true, opt_in_site_apps: true } ) + } + + var iframe = document.createElement('iframe'); + iframe.src = data.registry + "/registry-access.html"; + iframe.style = { position: "absolute", left: "-99999999px" }; + iframe.width = 0 ; + iframe.height = 0; + iframe.tabindex = -1; + iframe.title = "empty"; + iframe.classList.add("hidden"); + document.body.appendChild(iframe); + + setTimeout(function () { + iframe.contentWindow.postMessage(window.envSettings.agentApiUrl, "*") + }, 300); + + window.addEventListener('message', function(event) { + if (event.source !== iframe.contentWindow) return; + + if (event.data.status === "disabled") console.error("Your netdata registry is disabled! Check your configuration.") + console.log("Received from iframe: " + JSON.stringify(event.data)); // Message received from child + }); + }) + + fetch(window.envSettings.agentApiUrl + "/api/v1/info") + .then(function(response) { return response.json() }) + .then(function(agent) { + window.localNetdataAgent = { + mg: agent.uid, + version: agent.version, + cloudEnabled: agent["cloud-enabled"], + cloudAvailable: agent["cloud-available"], + claimed: agent["agent-claimed"], + aclk: agent["aclk-available"] + } + + if (!window.localNetdataAgent.cloudEnabled && /netdata\.cloud/.test("https://app.netdata.cloud/bundlesManifest.6.json")) { + goToOld("/v2") + return + } + + fetch(__webpack_public_path__ + "bundlesManifest."+ window.envSettings.version.toString().replace(/(\d+)\..+/, "$1") +".json") + .then(function(response) { return response.json() }) + .then(function(data) { + Object.keys(data).forEach(function(k) { + if (/\.(map|ico|html)$/.test(data[k])) return + if (/static\//.test(data[k])) return + + if (/\.css.*$/.test(data[k])) { + loadStyle((__webpack_public_path__ + data[k]).replace(/([^:]\/)\/+/g, "$1")) + return + } + + if (/\.js.*$/.test(data[k])) { + loadScript((__webpack_public_path__ + data[k]).replace(/([^:]\/)\/+/g, "$1"), { + async: false, + }); + } + var el = document.getElementById('agent-splash-screen'); + el.classList.remove("loading"); + }) + }).catch(function() { + var el = document.getElementById('agent-splash-screen'); + el.classList.remove("loading"); + el.classList.add("error"); + }); + })</script></body></html>
\ No newline at end of file |