Skip to content

Commit 9e38da0

Browse files
committed
fix: [GSHDF-846] update header plugin for mapstore
1 parent 5f8803f commit 9e38da0

File tree

9 files changed

+68
-23
lines changed

9 files changed

+68
-23
lines changed

.github/workflows/mapstore.yml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ on: [push, pull_request]
33

44
jobs:
55
build:
6-
runs-on: ubuntu-20.04
6+
runs-on: ubuntu-latest
77
permissions:
88
contents: read
99
packages: write
@@ -29,7 +29,7 @@ jobs:
2929
node-version: '12.x'
3030

3131
- name: "cache node modules"
32-
uses: actions/cache@v1
32+
uses: actions/cache@v4
3333
env:
3434
cache-name: cache-node-modules
3535
with:
@@ -41,7 +41,7 @@ jobs:
4141
${{ runner.os }}-
4242
4343
- name: "Maven repository caching"
44-
uses: actions/cache@v1
44+
uses: actions/cache@v4
4545
with:
4646
path: ~/.m2/repository
4747
key: mapstore-${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }}
@@ -67,7 +67,7 @@ jobs:
6767
run: mkdir -p scratch && cp web/target/georchestra-mapstore*.deb scratch/georchestra-mapstore-${{ github.sha }}.deb
6868

6969
- name: "publish deb as artifact"
70-
uses: actions/upload-artifact@v1
70+
uses: actions/upload-artifact@v4
7171
with:
7272
name: georchestra-mapstore.deb
7373
path: scratch/georchestra-mapstore-${{ github.sha }}.deb
@@ -76,7 +76,7 @@ jobs:
7676
run: mkdir -p scratch && cp web/target/mapstore.war scratch/mapstore-${{ github.sha }}.war
7777

7878
- name: "publish war as artifact"
79-
uses: actions/upload-artifact@v1
79+
uses: actions/upload-artifact@v4
8080
with:
8181
name: mapstore.war
8282
path: scratch/mapstore-${{ github.sha }}.war

api.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
<title>geOrchestra</title>
88
<link rel="preconnect" href="https://fonts.gstatic.com">
99
<link href="https://fonts.googleapis.com/css2?family=Noto+Sans&display=swap" rel="stylesheet">
10-
<link rel="shortcut icon" type="image/png" href="https://cdn.jslibs.mapstore2.geo-solutions.it/leaflet/favicon.ico" />
10+
<link rel="shortcut icon" type="image/png" href="/favicon.ico" />
1111
<!--script src="https://cdnjs.cloudflare.com/ajax/libs/proj4js/2.3.10/proj4.js"></script-->
1212
<style>
1313
#container {

apiTemplate.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
<title>geOrchestra</title>
88
<link rel="preconnect" href="https://fonts.gstatic.com">
99
<link href="https://fonts.googleapis.com/css2?family=Noto+Sans&display=swap" rel="stylesheet">
10-
<link rel="shortcut icon" type="image/png" href="https://cdn.jslibs.mapstore2.geo-solutions.it/leaflet/favicon.ico" />
10+
<link rel="shortcut icon" type="image/png" href="/favicon.ico" />
1111
<!--script src="https://cdnjs.cloudflare.com/ajax/libs/proj4js/2.3.10/proj4.js"></script-->
1212
<style>
1313
#container {

embedded.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@
103103
<link rel="preconnect" href="https://fonts.gstatic.com">
104104
<link href="https://fonts.googleapis.com/css2?family=Noto+Sans&display=swap" rel="stylesheet">
105105
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css" />
106-
<link rel="shortcut icon" type="image/png" href="https://cdn.jslibs.mapstore2.geo-solutions.it/leaflet/favicon.ico" />
106+
<link rel="shortcut icon" type="image/png" href="/favicon.ico" />
107107
<!--script src="https://cdnjs.cloudflare.com/ajax/libs/proj4js/2.3.10/proj4.js"></script-->
108108
</head>
109109
<body>

embeddedTemplate.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@
103103
<link rel="preconnect" href="https://fonts.gstatic.com">
104104
<link href="https://fonts.googleapis.com/css2?family=Noto+Sans&display=swap" rel="stylesheet">
105105
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css" />
106-
<link rel="shortcut icon" type="image/png" href="https://cdn.jslibs.mapstore2.geo-solutions.it/leaflet/favicon.ico" />
106+
<link rel="shortcut icon" type="image/png" href="/favicon.ico" />
107107
<!--script src="https://cdnjs.cloudflare.com/ajax/libs/proj4js/2.3.10/proj4.js"></script-->
108108
<script async type="text/javascript" src="https://unpkg.com/bowser@2.7.0/es5.js" onload="checkBrowser()"></script>
109109
<script type="text/javascript">

index.html

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -101,9 +101,9 @@
101101
}
102102
#georchestra-header {
103103
width: 100%;
104-
height: 90px;
104+
height: 80px;
105105
border: none;
106-
overflow: hidden;
106+
overflow: visible;
107107
position: absolute;
108108
}
109109
#container {
@@ -118,13 +118,14 @@
118118
<link rel="preconnect" href="https://fonts.gstatic.com">
119119
<link href="https://fonts.googleapis.com/css2?family=Noto+Sans&display=swap" rel="stylesheet">
120120
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css" />
121-
<link rel="shortcut icon" type="image/png" href="https://cdn.jslibs.mapstore2.geo-solutions.it/leaflet/favicon.ico" />
121+
<link rel="shortcut icon" type="image/png" href="/favicon.ico" />
122122
<!--script src="https://cdnjs.cloudflare.com/ajax/libs/proj4js/2.3.10/proj4.js"></script-->
123123
<!--<script src="https://www.mapquestapi.com/sdk/leaflet/v2.2/mq-map.js?key=__API_KEY_MAPQUEST__"></script>-->
124124

125125
</head>
126126
<body>
127-
<iframe id="georchestra-header" src="header.html" scrolling="no" frameBorder="0"></iframe>
127+
<geor-header id="georchestra-header"></geor-header>
128+
<script id="georchestra-header-script"></script>
128129
<div id="container">
129130
<div class="_ms2_init_spinner _ms2_init_center"><div></div></div>
130131
<div class="_ms2_init_text _ms2_init_center">Loading</div>

indexTemplate.html

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -101,14 +101,14 @@
101101
}
102102
#georchestra-header {
103103
width: 100%;
104-
height: 90px;
104+
height: 80px;
105105
border: none;
106-
overflow: hidden;
106+
overflow: visible;
107107
position: absolute;
108108
}
109109
#container {
110110
position: absolute;
111-
top: 90px;
111+
top: 80px;
112112
bottom: 0;
113113
height: unset !important;
114114
width: 100%;
@@ -117,7 +117,7 @@
117117
<link rel="preconnect" href="https://fonts.gstatic.com">
118118
<link href="https://fonts.googleapis.com/css2?family=Noto+Sans&display=swap" rel="stylesheet">
119119
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css" />
120-
<link rel="shortcut icon" type="image/png" href="https://cdn.jslibs.mapstore2.geo-solutions.it/leaflet/favicon.ico" />
120+
<link rel="shortcut icon" type="image/png" href="/favicon.ico" />
121121
<script src="https://cdnjs.cloudflare.com/ajax/libs/proj4js/2.3.10/proj4.js"></script>
122122
<script async type="text/javascript" src="https://unpkg.com/bowser@2.7.0/es5.js" onload="checkBrowser()"></script>
123123
<script type="text/javascript">
@@ -137,7 +137,8 @@
137137
</script>
138138
</head>
139139
<body>
140-
<iframe id="georchestra-header" src="header.html" scrolling="no" frameBorder="0"></iframe>
140+
<geor-header id="georchestra-header"></geor-header>
141+
<script id="georchestra-header-script"></script>
141142
<div id="container">
142143
<div class="_ms2_init_spinner _ms2_init_center"><div></div></div>
143144
<div class="_ms2_init_text _ms2_init_center">Loading</div>

js/plugins/EasyTheming.jsx

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
/*
2+
* Copyright 2019, GeoSolutions Sas.
3+
* All rights reserved.
4+
*
5+
* This source code is licensed under the BSD-style license found in the
6+
* LICENSE file in the root directory of this source tree.
7+
*/
8+
import {useEffect} from "react";
9+
import {createPlugin, connect} from "@mapstore/utils/PluginsUtils";
10+
11+
export const Easytheming = ({stylesheet = ""}) => {
12+
useEffect(() => {
13+
if (stylesheet) {
14+
const link = document.createElement("link");
15+
link.setAttribute("rel", "stylesheet");
16+
link.setAttribute("type", "text/css");
17+
link.setAttribute("href", stylesheet);
18+
document.head.appendChild(link);
19+
}
20+
}, []);
21+
return null;
22+
};
23+
24+
export default createPlugin('Easytheming', {
25+
component: connect((state) => ({
26+
stylesheet: state.localConfig && state.localConfig.stylesheetUri
27+
}))(Easytheming)
28+
});

js/plugins/Header.jsx

Lines changed: 20 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,14 @@
88
import {useEffect} from "react";
99
import { 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
3646
export 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

Comments
 (0)