From 369bd60fff12e3c0a20877b3fe9b99c16b76fd18 Mon Sep 17 00:00:00 2001 From: Florian Necas Date: Wed, 22 Jan 2025 14:08:58 +0100 Subject: [PATCH] feat: update dev header to get the new one --- .github/workflows/mapstore.yml | 4 ++-- configs/localConfig.json | 6 +++++- js/plugins/Header.jsx | 23 ++++++++++++++++++----- 3 files changed, 25 insertions(+), 8 deletions(-) diff --git a/.github/workflows/mapstore.yml b/.github/workflows/mapstore.yml index d792353c3..e06084183 100644 --- a/.github/workflows/mapstore.yml +++ b/.github/workflows/mapstore.yml @@ -67,7 +67,7 @@ jobs: run: mkdir -p scratch && cp web/target/georchestra-mapstore*.deb scratch/georchestra-mapstore-${{ github.sha }}.deb - name: "publish deb as artifact" - uses: actions/upload-artifact@v1 + uses: actions/upload-artifact@v4 with: name: georchestra-mapstore.deb path: scratch/georchestra-mapstore-${{ github.sha }}.deb @@ -76,7 +76,7 @@ jobs: run: mkdir -p scratch && cp web/target/mapstore.war scratch/mapstore-${{ github.sha }}.war - name: "publish war as artifact" - uses: actions/upload-artifact@v1 + uses: actions/upload-artifact@v4 with: name: mapstore.war path: scratch/mapstore-${{ github.sha }}.war diff --git a/configs/localConfig.json b/configs/localConfig.json index 0eff60c3d..cf39f28d4 100644 --- a/configs/localConfig.json +++ b/configs/localConfig.json @@ -20,7 +20,11 @@ }, "header": { "height": 90, - "url": "/header/" + "url": "/header/", + "script": "https://cdn.jsdelivr.net/gh/georchestra/header@dist/header.js", + "legacy": false, + "logoUrl": "https://www.georchestra.org/public/georchestra-logo.svg", + "stylesheet": "" }, "defaultMapOptions": { "cesium": { diff --git a/js/plugins/Header.jsx b/js/plugins/Header.jsx index 6e9139b5e..5300568a5 100644 --- a/js/plugins/Header.jsx +++ b/js/plugins/Header.jsx @@ -8,9 +8,14 @@ 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, + logoUrl = "https://www.georchestra.org/public/georchestra-logo.svg", + stylesheet = ""}) => { 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) { @@ -19,9 +24,13 @@ 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`); + header.setAttribute("logo-url", logoUrl); + header.setAttribute("stylesheet", stylesheet); + headerScript.src = script; if (container) { container.style.top = height + "px"; @@ -36,6 +45,10 @@ 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, + logoUrl: state.localConfig && state.localConfig.header && state.localConfig.header.logoUrl, + stylesheet: state.localConfig && state.localConfig.header && state.localConfig.header.stylesheet }))(Header) });