This is an automated email from the ASF dual-hosted git repository. kbhatt pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/atlas.git
commit c5464da3d53a8ad9cc73dd83bf27240cecedd4f1 Author: kevalbhatt <[email protected]> AuthorDate: Wed Apr 22 19:53:55 2020 +0530 ATLAS-3752 : UI: Login js improvment --- dashboardv2/public/index.html.tpl | 11 +++++++++++ dashboardv2/public/js/modules/atlasLogin.js | 27 +++++++-------------------- dashboardv3/public/index.html.tpl | 11 +++++++++++ dashboardv3/public/js/modules/atlasLogin.js | 27 +++++++-------------------- 4 files changed, 36 insertions(+), 40 deletions(-) diff --git a/dashboardv2/public/index.html.tpl b/dashboardv2/public/index.html.tpl index 5335d39..ba1ccf0 100644 --- a/dashboardv2/public/index.html.tpl +++ b/dashboardv2/public/index.html.tpl @@ -33,6 +33,17 @@ <title>Atlas</title> <meta name="description" content="" /> <meta name="viewport" content="width=device-width" /> + <script type="text/javascript"> + var isHtmlInPath = window.location.pathname.indexOf("index.html"); + if (isHtmlInPath === -1) { + var pathname = window.location.pathname.replace(/\/[\w-]+.(jsp|html)|\/+$/ig, ''), + indexpath = pathname + "/index.html"; + if (location.hash.length > 2) { + indexpath += location.hash; + } + window.location.replace(indexpath); + } + </script> <link rel="shortcut icon" href="img/favicon.ico?bust=<%- bust %>" type="image/x-icon" /> <link rel="icon" href="img/favicon.ico?bust=<%- bust %>" type="image/x-icon" /> <!-- Place favicon.ico and apple-touch-icon.png in the root directory --> diff --git a/dashboardv2/public/js/modules/atlasLogin.js b/dashboardv2/public/js/modules/atlasLogin.js index d2d19d1..d5ad854 100644 --- a/dashboardv2/public/js/modules/atlasLogin.js +++ b/dashboardv2/public/js/modules/atlasLogin.js @@ -57,7 +57,7 @@ function doLogin() { j_username: userName, j_password: passwd }, - url: baseUrl + "j_spring_security_check", + url: baseUrl + "/j_spring_security_check", type: "POST", headers: { "cache-control": "no-cache" @@ -103,18 +103,18 @@ function redirect(baseUrl) { PRIMARY_UI = data["atlas.ui.default.version"]; } if (PRIMARY_UI !== "v2") { - indexpath = "index.html"; + indexpath = "/index.html"; } if (window.localStorage.last_ui_load === "v1") { - indexpath = "index.html"; + indexpath = "/index.html"; } else if (window.localStorage.last_ui_load === "v2") { indexpath = "/n/index.html"; } + indexpath = baseUrl + indexpath; if (location.hash.length > 2) { - window.location.replace(indexpath + location.hash); - } else { - window.location.replace(indexpath); + indexpath += location.hash; } + window.location.replace(indexpath); }, error: function() { window.location.replace("index.html"); @@ -123,20 +123,7 @@ function redirect(baseUrl) { } function getBaseUrl() { - if (!window.location.origin) { - window.location.origin = - window.location.protocol + "//" + window.location.hostname + (window.location.port ? ":" + window.location.port : ""); - } - var baseUrl = window.location.origin + window.location.pathname.substring(window.location.pathname.indexOf("/", 2) + 1, 0); - - if (baseUrl.lastIndexOf("/") != baseUrl.length - 1) { - if (baseUrl) { - baseUrl = baseUrl + "/"; - } else { - baseUrl = "/"; - } - } - return baseUrl; + return window.location.pathname.replace(/\/[\w-]+.(jsp|html)|\/+$/ig, '') } $(function() { diff --git a/dashboardv3/public/index.html.tpl b/dashboardv3/public/index.html.tpl index a272a8d..07e5bd3 100644 --- a/dashboardv3/public/index.html.tpl +++ b/dashboardv3/public/index.html.tpl @@ -33,6 +33,17 @@ <title>Atlas</title> <meta name="description" content="" /> <meta name="viewport" content="width=device-width" /> + <script type="text/javascript"> + var isHtmlInPath = window.location.pathname.indexOf("index.html"); + if (isHtmlInPath === -1) { + var pathname = window.location.pathname.replace(/\/[\w-]+.(jsp|html)|\/+$/ig, ''), + indexpath = pathname + "/index.html"; + if (location.hash.length > 2) { + indexpath += location.hash; + } + window.location.replace(indexpath); + } + </script> <link rel="shortcut icon" href="img/favicon.ico?bust=<%- bust %>" type="image/x-icon" /> <link rel="icon" href="img/favicon.ico?bust=<%- bust %>" type="image/x-icon" /> <!-- Place favicon.ico and apple-touch-icon.png in the root directory --> diff --git a/dashboardv3/public/js/modules/atlasLogin.js b/dashboardv3/public/js/modules/atlasLogin.js index d2d19d1..d5ad854 100644 --- a/dashboardv3/public/js/modules/atlasLogin.js +++ b/dashboardv3/public/js/modules/atlasLogin.js @@ -57,7 +57,7 @@ function doLogin() { j_username: userName, j_password: passwd }, - url: baseUrl + "j_spring_security_check", + url: baseUrl + "/j_spring_security_check", type: "POST", headers: { "cache-control": "no-cache" @@ -103,18 +103,18 @@ function redirect(baseUrl) { PRIMARY_UI = data["atlas.ui.default.version"]; } if (PRIMARY_UI !== "v2") { - indexpath = "index.html"; + indexpath = "/index.html"; } if (window.localStorage.last_ui_load === "v1") { - indexpath = "index.html"; + indexpath = "/index.html"; } else if (window.localStorage.last_ui_load === "v2") { indexpath = "/n/index.html"; } + indexpath = baseUrl + indexpath; if (location.hash.length > 2) { - window.location.replace(indexpath + location.hash); - } else { - window.location.replace(indexpath); + indexpath += location.hash; } + window.location.replace(indexpath); }, error: function() { window.location.replace("index.html"); @@ -123,20 +123,7 @@ function redirect(baseUrl) { } function getBaseUrl() { - if (!window.location.origin) { - window.location.origin = - window.location.protocol + "//" + window.location.hostname + (window.location.port ? ":" + window.location.port : ""); - } - var baseUrl = window.location.origin + window.location.pathname.substring(window.location.pathname.indexOf("/", 2) + 1, 0); - - if (baseUrl.lastIndexOf("/") != baseUrl.length - 1) { - if (baseUrl) { - baseUrl = baseUrl + "/"; - } else { - baseUrl = "/"; - } - } - return baseUrl; + return window.location.pathname.replace(/\/[\w-]+.(jsp|html)|\/+$/ig, '') } $(function() {
