Skip to content

Commit

Permalink
feat: set header to config file
Browse files Browse the repository at this point in the history
  • Loading branch information
f-necas committed Dec 23, 2024
1 parent d1582f5 commit 50e44c2
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 37 deletions.
8 changes: 3 additions & 5 deletions configs/localConfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,9 @@
},
"stylesheetUri": "",
"header": {
"height": 90,
"url": "/header/",
"height": 80,
"configFile": "",
"script": "https://cdn.jsdelivr.net/gh/georchestra/header@dist/header.js",
"legacy": false,
"logoUrl": "https://www.georchestra.org/public/georchestra-logo.svg",
"stylesheet": ""
},
"defaultMapOptions": {
Expand Down Expand Up @@ -844,7 +842,7 @@
"containerPosition": "header",
"className": "navbar shadow navbar-home"
}
},
},
"Details",
"AddWidgetDashboard",
"MapConnectionDashboard",
Expand Down
2 changes: 1 addition & 1 deletion index.html
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@
}
#georchestra-header {
width: 100%;
height: 90px;
height: 80px;
border: none;
overflow: visible;
position: absolute;
Expand Down
4 changes: 2 additions & 2 deletions indexTemplate.html
Original file line number Diff line number Diff line change
Expand Up @@ -101,14 +101,14 @@
}
#georchestra-header {
width: 100%;
height: 90px;
height: 80px;
border: none;
overflow: visible;
position: absolute;
}
#container {
position: absolute;
top: 90px;
top: 80px;
bottom: 0;
height: unset !important;
width: 100%;
Expand Down
40 changes: 12 additions & 28 deletions js/plugins/Header.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,47 +8,31 @@
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 = ({ page = "mapstore", height = 80,
script = "https://cdn.jsdelivr.net/gh/georchestra/header@dist/header.js",
legacy = false,
logoUrl = "https://www.georchestra.org/public/georchestra-logo.svg",
stylesheet = ""}) => {
stylesheet = "", configFile = ""}) => {
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) {
header.style.display = 'none';
if (container) {
container.style.top = '0';
}
} else {
header.setAttribute("active-app", page);
header.setAttribute("legacy-url", url);
header.setAttribute("legacy-header", legacy);
header.setAttribute("style", `height:${height}px`);
header.setAttribute("logo-url", logoUrl);
header.setAttribute("stylesheet", stylesheet);
headerScript.src = script;

if (container) {
container.style.top = height + "px";
}
header.setAttribute("active-app", page);
header.setAttribute("stylesheet", stylesheet);
header.setAttribute("config-file", configFile);
headerScript.src = script;
if (container) {
container.style.top = height + "px";
}

}
}, [page, url, height, window.location, window.parent.location]);
}, [page, window.location, window.parent.location]);
return null;
};

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,
script: state.localConfig && state.localConfig.header && state.localConfig.header.script,
legacy: state.localConfig && state.localConfig.header && state.localConfig.header.legacy,
logoUrl: state.localConfig && state.localConfig.header && state.localConfig.header.logoUrl,
stylesheet: state.localConfig && state.localConfig.header && state.localConfig.header.stylesheet
height: state.localConfig && state.localConfig.header && state.localConfig.header.height,
stylesheet: state.localConfig && state.localConfig.header && state.localConfig.header.stylesheet,
configFile: state.localConfig && state.localConfig.header && state.localConfig.header.configFile
}))(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,header.script=headerScript,header.legacy=useLegacyHeader,header.logoUrl=logoUrl,header.stylesheet=georchestraStylesheet
overrides.mappings=header.script=headerScript,header.height=headerHeight,header.stylesheet=georchestraStylesheet,header.configFile=headerConfigFile

0 comments on commit 50e44c2

Please sign in to comment.