Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Webcomponent / Use relative path to load main template from cache. #8503

Open
wants to merge 5 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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") &&
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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();
});

Expand Down
5 changes: 4 additions & 1 deletion web-ui/src/main/resources/catalog/views/default/module.js
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
Loading