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

Implemention of new WebComponent header #663

Merged
merged 3 commits into from
Nov 27, 2023
Merged
Show file tree
Hide file tree
Changes from 2 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
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -15,3 +15,4 @@ coverage/
backend/.classpath
backend/.project
package-lock.json
.idea/
4 changes: 3 additions & 1 deletion configs/localConfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,9 @@
},
"header": {
"height": 90,
"url": "/header/"
"url": "/header/",
"script": "https://cdn.jsdelivr.net/gh/georchestra/header@dist/header.js",
"legacy": false
},
"defaultMapOptions": {
"cesium": {
Expand Down
5 changes: 3 additions & 2 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@
width: 100%;
height: 90px;
border: none;
overflow: hidden;
overflow: visible;
position: absolute;
}
#container {
Expand All @@ -124,7 +124,8 @@

</head>
<body>
<iframe id="georchestra-header" src="header.html" scrolling="no" frameBorder="0"></iframe>
<geor-header id="georchestra-header"></geor-header>
<script id="georchestra-header-script"></script>
<div id="container">
<div class="_ms2_init_spinner _ms2_init_center"><div></div></div>
<div class="_ms2_init_text _ms2_init_center">Loading</div>
Expand Down
5 changes: 3 additions & 2 deletions indexTemplate.html
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@
width: 100%;
height: 90px;
border: none;
overflow: hidden;
overflow: visible;
position: absolute;
}
#container {
Expand Down Expand Up @@ -137,7 +137,8 @@
</script>
</head>
<body>
<iframe id="georchestra-header" src="header.html" scrolling="no" frameBorder="0"></iframe>
<geor-header id="georchestra-header"></geor-header>
<script id="georchestra-header-script"></script>
<div id="container">
<div class="_ms2_init_spinner _ms2_init_center"><div></div></div>
<div class="_ms2_init_text _ms2_init_center">Loading</div>
Expand Down
15 changes: 10 additions & 5 deletions js/plugins/Header.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,10 @@
import {useEffect} from "react";
import { createPlugin, connect } from "@mapstore/utils/PluginsUtils";

export const Header = ({url = "/header/", page = "mapstore", height = 90, ignoreIFrame = false}) => {
export const Header = ({url = "/header/", page = "mapstore", height = 90, ignoreIFrame = false, script = "https://cdn.jsdelivr.net/gh/georchestra/header@dist/header.js", legacy = false}) => {
useEffect(() => {
const header = document.getElementById("georchestra-header");
const headerScript = document.getElementById("georchestra-header-script");
const container = document.getElementById("container");
if (header) {
if (!ignoreIFrame && window.location !== window.parent.location) {
Expand All @@ -19,9 +20,11 @@ export const Header = ({url = "/header/", page = "mapstore", height = 90, ignore
container.style.top = '0';
}
} else {
header.style.display = 'block';
header.src = url + "?active=" + page;
header.style.height = height + "px";
header.setAttribute("active-app", page);
header.setAttribute("legacy-url", url);
header.setAttribute("legacy-header", legacy);
header.setAttribute("style", `height:${height}px`);
headerScript.src = script;

if (container) {
container.style.top = height + "px";
Expand All @@ -36,6 +39,8 @@ export const Header = ({url = "/header/", page = "mapstore", height = 90, ignore
export default createPlugin('Header', {
component: connect((state) => ({
url: state.localConfig && state.localConfig.header && state.localConfig.header.url,
height: state.localConfig && state.localConfig.header && state.localConfig.header.height
height: state.localConfig && state.localConfig.header && state.localConfig.header.height,
script: state.localConfig && state.localConfig.header && state.localConfig.header.script,
legacy: state.localConfig && state.localConfig.header && state.localConfig.header.legacy
}))(Header)
});
2 changes: 1 addition & 1 deletion web/src/main/resources/mapstore.properties
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,4 @@

datadir.location=${georchestra.extensions:},${georchestra.datadir}/mapstore
overrides.config=../default.properties
overrides.mappings=header.url=headerUrl,header.height=headerHeight
overrides.mappings=header.url=headerUrl,header.height=headerHeight,header.script=headerScript,header.legacy=useLegacyHeader
Loading