Skip to content

Commit

Permalink
geosolutions-it#4809: supported browsers pre-check (geosolutions-it#5337
Browse files Browse the repository at this point in the history
)
  • Loading branch information
MV88 committed May 29, 2020
1 parent c7daac2 commit f8ae509
Show file tree
Hide file tree
Showing 9 changed files with 187 additions and 6 deletions.
4 changes: 2 additions & 2 deletions build/prod-webpack.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,13 +31,13 @@ module.exports = require('./buildConfig')(
new HtmlWebpackPlugin({
template: path.join(paths.framework, 'indexTemplate.html'),
chunks: ['mapstore2'],
inject: true,
inject: "body",
hash: true
}),
new HtmlWebpackPlugin({
template: path.join(paths.framework, 'embeddedTemplate.html'),
chunks: ['embedded'],
inject: true,
inject: "body",
hash: true,
filename: 'embedded.html'
}), new HtmlWebpackPlugin({
Expand Down
14 changes: 14 additions & 0 deletions project/standard/templates/embeddedTemplate.html
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,20 @@
<!--script src="https://cdnjs.cloudflare.com/ajax/libs/proj4js/2.3.10/proj4.js"></script-->
<script src="https://cdnjs.cloudflare.com/ajax/libs/leaflet/1.3.1/leaflet.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/leaflet.draw/1.0.2/leaflet.draw.js"></script>
<script type="text/javascript" src="https://unpkg.com/bowser@2.7.0/es5.js"></script>
<script type="text/javascript">
var browserInfo = bowser.getParser(window.navigator.userAgent);
var isValidBrowser = browserInfo.satisfies({
"edge": ">1",
"chrome": ">1",
"safari": ">1",
"firefox": ">1"
});
if (!isValidBrowser) {
window.location.href = "unsupportedBrowser.html"
document.querySelector("container").style.display = "none";
}
</script>
</head>
<body>
<div id="container">
Expand Down
15 changes: 14 additions & 1 deletion project/standard/templates/indexTemplate.html
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,20 @@
<link rel="stylesheet" href="https://cesiumjs.org/releases/1.17/Build/Cesium/Widgets/widgets.css" />
<script src="MapStore2/web/client/libs/cesium-navigation/cesium-navigation.js"></script>
<link rel="stylesheet" href="MapStore2/web/client/libs/cesium-navigation/cesium-navigation.css" />

<script type="text/javascript" src="https://unpkg.com/bowser@2.7.0/es5.js"></script>
<script type="text/javascript">
var browserInfo = bowser.getParser(window.navigator.userAgent);
var isValidBrowser = browserInfo.satisfies({
"edge": ">1",
"chrome": ">1",
"safari": ">1",
"firefox": ">1"
});
if (!isValidBrowser) {
window.location.href = "unsupportedBrowser.html"
document.querySelector("container").style.display = "none";
}
</script>
</head>
<body>
<div id="container">
Expand Down
4 changes: 2 additions & 2 deletions project/standard/templates/prod-webpack.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,13 +27,13 @@ module.exports = require('./MapStore2/build/buildConfig')(
new HtmlWebpackPlugin({
template: path.join(__dirname, 'indexTemplate.html'),
chunks: ['__PROJECTNAME__'],
inject: true,
inject: "body",
hash: true
}),
new HtmlWebpackPlugin({
template: path.join(__dirname, 'embeddedTemplate.html'),
chunks: ['__PROJECTNAME__-embedded'],
inject: true,
inject: "body",
hash: true,
filename: 'embedded.html'
}),
Expand Down
64 changes: 64 additions & 0 deletions project/standard/templates/unsupportedBrowser.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<meta http-equiv="Content-Type" content="text/html;charset=UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1.0, user-scalable=no">
<title>MapStore Unsupported Browser</title>
<style>
body {
margin: 0;
}
#container {
font-family: 'Raleway', sans-serif;
display: flex;
flex-direction: column;
align-items: center;
position: absolute;
height: 100%;
width: 100%;
justify-content: center;
}
</style>
<link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Raleway" type='text/css'>
</head>
<body>
<div id="container">
<!-- assure the two images path are fetching correctly the sources -->
<img src="assets/img/MapStore2.png" alt="Mapstore2 Logo">
<h2 class="browserUnsupported">Current Browser is not supported</h2>
<p class="description">These are the ones we support</p>
<img src="assets/img/main-desktop-browser-logos.jpg" width="300" alt="Supported Browser (Chrome, Firefox, Safari, Edge)">
</div>
<script>
switch(navigator.language) {
case "en-US": case "en": {
document.querySelector(".browserUnsupported").innerHTML = "Current Browser is not supported";
document.querySelector(".description").innerHTML = "These are the ones we support";
break;
}
case "it-IT": case "it": {
document.querySelector(".browserUnsupported").innerHTML = "Il tuo browser non è supportato";
document.querySelector(".description").innerHTML = "Questi sono i browser supportati";
break;
}
case "fr-FR": case "fr": {
document.querySelector(".browserUnsupported").innerHTML = "Le navigateur actuel n'est pas pris en charge";
document.querySelector(".description").innerHTML = "Ce sont ceux que nous soutenons";
break;
}
case "de-DE": case "de": {
document.querySelector(".browserUnsupported").innerHTML = "Der aktuelle Browser wird nicht unterstützt";
document.querySelector(".description").innerHTML = "Dies sind diejenigen, die wir unterstützen";
break;
}
case "es-ES": case "es": {
document.querySelector(".browserUnsupported").innerHTML = "El navegador actual no es compatible";
document.querySelector(".description").innerHTML = "Estos son los que apoyamos";
break;
}
}
console.log(window)
</script>
</body>
</html>
14 changes: 14 additions & 0 deletions web/client/embeddedTemplate.html
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,20 @@
<!--script src="https://cdnjs.cloudflare.com/ajax/libs/proj4js/2.3.10/proj4.js"></script-->
<script src="https://cdnjs.cloudflare.com/ajax/libs/leaflet/1.3.1/leaflet.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/leaflet.draw/1.0.2/leaflet.draw.js"></script>
<script type="text/javascript" src="https://unpkg.com/bowser@2.7.0/es5.js"></script>
<script type="text/javascript">
var browserInfo = bowser.getParser(window.navigator.userAgent);
var isValidBrowser = browserInfo.satisfies({
"edge": ">1",
"chrome": ">1",
"safari": ">1",
"firefox": ">1"
});
if (!isValidBrowser) {
window.location.href = "unsupportedBrowser.html"
document.querySelector("container").style.display = "none";
}
</script>
</head>
<body>
<div id="container">
Expand Down
15 changes: 14 additions & 1 deletion web/client/indexTemplate.html
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,20 @@
<link rel="stylesheet" href="https://cesiumjs.org/releases/1.17/Build/Cesium/Widgets/widgets.css" />
<script src="libs/cesium-navigation/cesium-navigation.js"></script>
<link rel="stylesheet" href="libs/cesium-navigation/cesium-navigation.css" />

<script type="text/javascript" src="https://unpkg.com/bowser@2.7.0/es5.js"></script>
<script type="text/javascript">
var browserInfo = bowser.getParser(window.navigator.userAgent);
var isValidBrowser = browserInfo.satisfies({
"edge": ">1",
"chrome": ">1",
"safari": ">1",
"firefox": ">1"
});
if (!isValidBrowser) {
window.location.href = "unsupportedBrowser.html"
document.querySelector("container").style.display = "none";
}
</script>
</head>
<body>
<div id="container">
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
63 changes: 63 additions & 0 deletions web/client/unsupportedBrowser.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<meta http-equiv="Content-Type" content="text/html;charset=UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1.0, user-scalable=no">
<title>MapStore Unsupported Browser</title>
<style>
body {
margin: 0;
}
#container {
font-family: 'Raleway', sans-serif;
display: flex;
flex-direction: column;
align-items: center;
position: absolute;
height: 100%;
width: 100%;
justify-content: center;
}
</style>
<link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Raleway" type='text/css'>
</head>
<body>
<div id="container">
<img src="product/assets/img/MapStore2.png" alt="Mapstore2 Logo">
<h2 class="browserUnsupported">Current Browser is not supported</h2>
<p class="description">These are the ones we support</p>
<img src="product/assets/img/main-desktop-browser-logos.jpg" width="300" alt="Supported Browser (Chrome, Firefox, Safari, Edge)">
</div>
<script>
switch(navigator.language) {
case "en-US": case "en": {
document.querySelector(".browserUnsupported").innerHTML = "Current Browser is not supported";
document.querySelector(".description").innerHTML = "These are the ones we support";
break;
}
case "it-IT": case "it": {
document.querySelector(".browserUnsupported").innerHTML = "Il tuo browser non è supportato";
document.querySelector(".description").innerHTML = "Questi sono i browser supportati";
break;
}
case "fr-FR": case "fr": {
document.querySelector(".browserUnsupported").innerHTML = "Le navigateur actuel n'est pas pris en charge";
document.querySelector(".description").innerHTML = "Ce sont ceux que nous soutenons";
break;
}
case "de-DE": case "de": {
document.querySelector(".browserUnsupported").innerHTML = "Der aktuelle Browser wird nicht unterstützt";
document.querySelector(".description").innerHTML = "Dies sind diejenigen, die wir unterstützen";
break;
}
case "es-ES": case "es": {
document.querySelector(".browserUnsupported").innerHTML = "El navegador actual no es compatible";
document.querySelector(".description").innerHTML = "Estos son los que apoyamos";
break;
}
}
console.log(window)
</script>
</body>
</html>

0 comments on commit f8ae509

Please sign in to comment.