88import { useEffect } from "react" ;
99import { createPlugin , connect } from "@mapstore/utils/PluginsUtils" ;
1010
11- export const Header = ( { url = "/header/" , page = "mapstore" , height = 90 , ignoreIFrame = false } ) => {
11+ export const Header = ( { url = "/header/" , page = "mapstore" , height = 90 , ignoreIFrame = false ,
12+ script = "https://cdn.jsdelivr.net/gh/georchestra/header@dist/header.js" ,
13+ legacy = false ,
14+ logoUrl = "https://www.georchestra.org/public/georchestra-logo.svg" ,
15+ stylesheet = "" , configFile = "" } ) => {
1216 useEffect ( ( ) => {
1317 const header = document . getElementById ( "georchestra-header" ) ;
18+ const headerScript = document . getElementById ( "georchestra-header-script" ) ;
1419 const container = document . getElementById ( "container" ) ;
1520 if ( header ) {
1621 if ( ! ignoreIFrame && window . location !== window . parent . location ) {
@@ -19,9 +24,14 @@ export const Header = ({url = "/header/", page = "mapstore", height = 90, ignore
1924 container . style . top = '0' ;
2025 }
2126 } else {
22- header . style . display = 'block' ;
23- header . src = url + "?active=" + page ;
24- header . style . height = height + "px" ;
27+ header . setAttribute ( "active-app" , page ) ;
28+ header . setAttribute ( "legacy-url" , url ) ;
29+ header . setAttribute ( "legacy-header" , legacy ) ;
30+ header . setAttribute ( "logo-url" , logoUrl ) ;
31+ header . setAttribute ( "stylesheet" , stylesheet ) ;
32+ header . setAttribute ( "config-file" , configFile ) ;
33+ header . setAttribute ( "height" , height ) ;
34+ headerScript . src = script ;
2535
2636 if ( container ) {
2737 container . style . top = height + "px" ;
@@ -36,6 +46,11 @@ export const Header = ({url = "/header/", page = "mapstore", height = 90, ignore
3646export default createPlugin ( 'Header' , {
3747 component : connect ( ( state ) => ( {
3848 url : state . localConfig && state . localConfig . header && state . localConfig . header . url ,
39- height : state . localConfig && state . localConfig . header && state . localConfig . header . height
49+ height : state . localConfig && state . localConfig . header && state . localConfig . header . height ,
50+ script : state . localConfig && state . localConfig . header && state . localConfig . header . script ,
51+ legacy : state . localConfig && state . localConfig . header && state . localConfig . header . legacy ,
52+ logoUrl : state . localConfig && state . localConfig . header && state . localConfig . header . logoUrl ,
53+ stylesheet : state . localConfig && state . localConfig . header && state . localConfig . header . stylesheet ,
54+ configFile : state . localConfig && state . localConfig . header && state . localConfig . header . configFile
4055 } ) ) ( Header )
4156} ) ;
0 commit comments