From 3fc8f15f56f43eaf1ceb1b9ab424dd25c5816b17 Mon Sep 17 00:00:00 2001 From: Jeremy Clements <79224539+jeclrsg@users.noreply.github.com> Date: Wed, 5 Jun 2024 15:37:17 -0400 Subject: [PATCH] HPCC-31841 ECL Watch v9 redirect to intended url after login Captures the hash portion of the ECL Watch v9 url if present, eg "#/workunits/W20240514-150949/metrics/sg974", redirecting to this intended page after login. Signed-off-by: Jeremy Clements <79224539+jeclrsg@users.noreply.github.com> --- esp/src/Login.html | 4 ++++ esp/src/src/Session.ts | 7 ++++++- 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/esp/src/Login.html b/esp/src/Login.html index 42208eceae2..f80aa1074a2 100644 --- a/esp/src/Login.html +++ b/esp/src/Login.html @@ -112,6 +112,10 @@ function (ready, nlsHPCCMod) { var nlsHPCC = nlsHPCCMod.default; ready(function () { + if (window.location.hash) { + window.localStorage.setItem("redirectAfterLogin", window.location.hash); + } + var loginStr = document.getElementById("loginStr"); var error = document.getElementById("hidden_msg"); var disabled = document.getElementById('disabled_msg'); diff --git a/esp/src/src/Session.ts b/esp/src/src/Session.ts index 281742e4b13..f7a43044e3d 100644 --- a/esp/src/src/Session.ts +++ b/esp/src/src/Session.ts @@ -6,7 +6,7 @@ import { SMCService } from "@hpcc-js/comms"; import { scopedLogger } from "@hpcc-js/util"; import { cookieKeyValStore, sessionKeyValStore, userKeyValStore } from "src/KeyValStore"; import { singletonDebounce } from "../src-react/util/throttle"; -import { parseSearch } from "../src-react/util/history"; +import { parseSearch, replaceUrl } from "../src-react/util/history"; import { ModernMode } from "./BuildInfo"; import * as ESPUtil from "./ESPUtil"; @@ -135,6 +135,11 @@ export function formatCost(value): string { export function initSession() { if (sessionIsActive > -1) { + const redirectUrl = window.localStorage.getItem("redirectAfterLogin") ?? ""; + if (redirectUrl) { + window.localStorage.removeItem("redirectAfterLogin"); + replaceUrl(redirectUrl); + } idleWatcher.on("active", function () { resetESPTime(); });