diff --git a/web-ui/src/main/resources/catalog/components/common/map/mapService.js b/web-ui/src/main/resources/catalog/components/common/map/mapService.js index ab9420fb2a6..743f09e2ed3 100644 --- a/web-ui/src/main/resources/catalog/components/common/map/mapService.js +++ b/web-ui/src/main/resources/catalog/components/common/map/mapService.js @@ -43,7 +43,7 @@ getMapservices: function () { if (mapservicesCache === null) { var client = new XMLHttpRequest(); - client.open("GET", "../api/mapservices", false); + client.open("GET", gnGlobalSettings.gnUrl + "api/mapservices", false); client.setRequestHeader("accept", "application/json"); client.send(); if (client.status === 200) { diff --git a/web-ui/src/main/resources/catalog/components/utility/CORSInterceptor.js b/web-ui/src/main/resources/catalog/components/utility/CORSInterceptor.js index 2729b21050b..2f020cd7476 100644 --- a/web-ui/src/main/resources/catalog/components/utility/CORSInterceptor.js +++ b/web-ui/src/main/resources/catalog/components/utility/CORSInterceptor.js @@ -71,7 +71,7 @@ (config.url.indexOf("http") !== 0 && config.url.indexOf("//") !== 0); // If this is an authorized mapservice then we need to adjust the url or add auth headers - // Only check http url and exclude any urls like data: which should not be changed. Also, there is not need to check prox urls. + // Only check http url and exclude any urls like data: which should not be changed. Also, there is no need to check proxy urls. if ( config.url !== null && config.url.startsWith("http") && diff --git a/web-ui/src/main/resources/catalog/components/utility/SessionService.js b/web-ui/src/main/resources/catalog/components/utility/SessionService.js index 4b79897b743..324a958d8d6 100644 --- a/web-ui/src/main/resources/catalog/components/utility/SessionService.js +++ b/web-ui/src/main/resources/catalog/components/utility/SessionService.js @@ -42,9 +42,9 @@ module.factory("gnSessionService", [ "$rootScope", "$translate", - "$timeout", "$cookies", - function ($rootScope, $translate, $timeout, $cookies) { + "$interval", + function ($rootScope, $translate, $cookies, $interval) { var session = { remainingTime: null, start: null, @@ -109,10 +109,22 @@ } } function scheduleCheck(user, interval) { - $timeout(function () { - check(user); - scheduleCheck(user, interval); - }, interval || session.checkInterval); + // FIXME: When embedding the app using webcomponent mode, + // this interact with the location for unknown reason. + // This was observed when deploying an Angular app with the map as webcomponent + // on Apache or GN5 spring boot app embedded. + // Map actions are oddly redirecting to other route. + // The link between scheduleCheck and $locationChangeSuccess is not clear. + if (typeof gnShadowRoot === "undefined") { + $interval( + function () { + check(user); + }, + interval || session.checkInterval, + 0, + false + ); + } } return { getSession: getSession, diff --git a/web-ui/src/main/resources/catalog/components/viewer/ViewerDirective.js b/web-ui/src/main/resources/catalog/components/viewer/ViewerDirective.js index b48ad9e2c40..cb94a3656af 100644 --- a/web-ui/src/main/resources/catalog/components/viewer/ViewerDirective.js +++ b/web-ui/src/main/resources/catalog/components/viewer/ViewerDirective.js @@ -383,7 +383,14 @@ } }); - scope.$on("$locationChangeSuccess", function (next, current) { + scope.$on("$locationChangeSuccess", function (evt, next, current, newState, oldState) { + // When using window.location.hash or replace to change the location + // $locationChangeSuccess is triggered 2 times. + // Second time on HashChangeEvent which can be ignored + // and the state contains a navigationId property. + if (oldState && oldState.navigationId) { + return; + } initFromLocation(); }); diff --git a/web-ui/src/main/resources/catalog/views/default/module.js b/web-ui/src/main/resources/catalog/views/default/module.js index 380d6b1ed5d..b916a7a6868 100644 --- a/web-ui/src/main/resources/catalog/views/default/module.js +++ b/web-ui/src/main/resources/catalog/views/default/module.js @@ -530,7 +530,10 @@ ); } var setActiveTab = function () { - $scope.activeTab = $location.path().match(/^(\/[a-zA-Z0-9]*)($|\/.*)/)[1]; + let match = $location.path().match(/^(\/[a-zA-Z0-9]*)($|\/.*)/); + if (match) { + $scope.activeTab = match[1]; + } }; setActiveTab(); diff --git a/web-ui/src/main/resources/catalog/webcomponents/webcomponents.js b/web-ui/src/main/resources/catalog/webcomponents/webcomponents.js index 8c9e22aa6db..a9c0a635a42 100644 --- a/web-ui/src/main/resources/catalog/webcomponents/webcomponents.js +++ b/web-ui/src/main/resources/catalog/webcomponents/webcomponents.js @@ -40,7 +40,7 @@ customElements.define( var div = document.createElement("div"); div.setAttribute( "data-ng-include", - "'" + baseUrl + "/catalog/views/default/templates/index.html'" + "'../../catalog/views/default/templates/index.html'" ); div.setAttribute("class", "gn-full"); app.appendChild(div);