Compare commits

...

3 Commits

Author SHA1 Message Date
Michael Wyraz 860c9bbe1d Better event handling, fix race condition, make history work 2021-11-03 21:32:30 +01:00
Michael Wyraz 4be1964c56 Better embeding support + example 2021-11-03 21:32:30 +01:00
Michael Wyraz e76c9910d0 Add leipzig config 2021-11-03 21:32:24 +01:00
5 changed files with 77 additions and 65 deletions

View File

@ -1,73 +1,39 @@
module.exports = function () {
return {
// Variables are NODE_ID and NODE_NAME (only a-z0-9\- other chars are replaced with _)
'nodeInfos': [
{
'name': 'Clientstatistik',
'href': 'https://regensburg.freifunk.net/netz/statistik/node/{NODE_ID}/',
'image': 'https://grafana.regensburg.freifunk.net/render/d-solo/000000026/node?panelId=1&var-node={NODE_ID}&from=now-1d&width=650&height=350&theme=light&_t={TIME}',
'title': 'Clientstatistik für {NODE_ID} - weiteren Statistiken',
'width': 650,
'height': 350
'href': 'https://stats.freifunk-leipzig.de/d/GVI39bqGk/nodespublic?orgId=1&refresh=5m&var-nodeid={NODE_ID}',
'image': 'https://stats.freifunk-leipzig.de/render/d-solo/GVI39bqGk/statistiken?orgId=1&panelId=2&var-nodeid={NODE_ID}&width=650&height=350&from=now-1d&theme=light',
'title': 'Entwicklung der Anzahl der Clients innerhalb des letzten Tages'
},
{
'name': 'Trafficstatistik',
'href': 'https://regensburg.freifunk.net/netz/statistik/node/{NODE_ID}/',
'image': 'https://grafana.regensburg.freifunk.net/render/d-solo/000000026/node?panelId=2&from=now-1d&var-node={NODE_ID}&width=650&height=350&theme=light&_t={TIME}',
'title': 'Trafficstatistik für {NODE_ID} - weiteren Statistiken',
'width': 650,
'height': 350
},
{
'name': 'Systemlast',
'href': 'https://regensburg.freifunk.net/netz/statistik/node/{NODE_ID}/',
'image': 'https://grafana.regensburg.freifunk.net/render/d-solo/000000026/node?panelId=4&from=now-1d&var-node={NODE_ID}&width=650&height=350&theme=light&_t={TIME}',
'title': 'Systemlast für {NODE_ID} - weiteren Statistiken',
'width': 650,
'height': 350
},
{
'name': 'Airtime',
'href': 'https://regensburg.freifunk.net/netz/statistik/node/{NODE_ID}/',
'image': 'https://grafana.regensburg.freifunk.net/render/d-solo/000000026/node?panelId=5&from=now-1d&var-node={NODE_ID}&width=650&height=350&theme=light&_t={TIME}',
'title': 'Airtime für {NODE_ID} - weiteren Statistiken',
'width': 650,
'height': 350
}
],
'linkInfos': [
{
'name': 'Statistik für alle Links zwischen diese Knoten',
'image': 'https://grafana.regensburg.freifunk.net/render/d-solo/nvSNqoHmz/link?panelId=7&var-node={SOURCE_ID}&var-nodetolink={TARGET_ID}&from=now-1d&&width=650&height=350&theme=light&_t={TIME}',
'title': 'Linkstatistik des letzten Tages, min und max aller Links zwischen diesen Knoten',
'width': 650,
'height': 350
}
],
'globalInfos': [
{
'name': 'Globale Statistik',
'href': 'https://regensburg.freifunk.net/netz/statistik',
'image': 'https://grafana.regensburg.freifunk.net/render/d-solo/000000028/globals?panelId=2&from=now-7d&&width=650&height=350&theme=light&_t={TIME}',
'title': 'Globale Statistik - weiteren Statistiken',
'width': 650,
'height': 350
'name': 'Traffic',
'href': 'https://stats.freifunk-leipzig.de/d/GVI39bqGk/nodespublic?orgId=1&refresh=5m&var-nodeid={NODE_ID}',
'image': 'https://stats.freifunk-leipzig.de/render/d-solo/GVI39bqGk/statistiken?orgId=1&panelId=6&var-nodeid={NODE_ID}&width=650&height=350&from=now-1d&theme=light',
'title': 'Traffic innerhalb des letzten Tages'
}
],
// Array of data provider are supported
'dataPath': [
'https://regensburg.freifunk.net/data/'
'https://meshviewer.freifunk-leipzig.de/data/'
],
'siteName': 'Freifunk Regensburg',
'siteName': 'Freifunk Leipzig',
'mapLayers': [
{
'name': 'Wikimedia OSM Map',
'url': 'https://maps.wikimedia.org/osm-intl/{z}/{x}/{y}{r}.png',
'name': 'OpenStreetMap.HOT',
'url': 'https://{s}.tile.openstreetmap.fr/hot/{z}/{x}/{y}.png',
'config': {
'maxZoom': 19,
'attribution': '&copy; Openstreetmap France | &copy; <a href="http://www.openstreetmap.org/copyright">OpenStreetMap</a>'
}
},
{
'name': 'Esri.WorldImagery',
'url': '//server.arcgisonline.com/ArcGIS/rest/services/World_Imagery/MapServer/tile/{z}/{y}/{x}',
'config': {
'maxZoom': 20,
'subdomains': '1234',
'attribution': '<a href="https://wikimediafoundation.org/wiki/Maps_Terms_of_Use" rel="noopener" target="_blank">Wikimedia maps</a><a href="http://www.openmaptiles.org/" target="_blank">&copy; OpenMapTiles</a> <a href="http://www.openstreetmap.org/about/" target="_blank" rel="noopener">&copy; OpenStreetMap contributors</a>',
'start': 6
'attribution': 'Tiles &copy; Esri &mdash; Source: Esri, i-cubed, USDA, USGS, AEX, GeoEye, Getmapping, Aerogrid, IGN, IGP, UPR-EGP, and the GIS User Community'
}
}
],
@ -75,34 +41,35 @@ module.exports = function () {
'fixedCenter': [
// Northwest
[
49.3522,
11.7752
51.4168,
12.1983
],
// Southeast
[
48.7480,
12.8917
51.2516,
12.4791
]
],
'domainNames': [
{
'domain': 'ffrgb-bat15',
'name': 'Regensburg'
'domain': 'l',
'name': 'Leipzig (Gluon)'
},
{
'domain': 'ffrgb',
'name': 'Regensburg'
'domain': 'meshkit',
'name': 'Leipzig (meshkit)'
}
],
'linkList': [
{
'title': 'Impressum',
'href': '/verein/impressum/'
'href': 'https://freifunk.net/impressum/'
},
{
'title': 'Datenschutz',
'href': '/verein/datenschutz/'
'href': 'https://freifunk.net/datenschutz/'
}
]
};
};

View File

@ -1,6 +1,6 @@
module.exports = function (gulp, plugins, config) {
return function copy() {
gulp.src(['html/*.html', 'assets/favicon/*'])
gulp.src(['html/*.html', 'html/*.js', 'assets/favicon/*'])
.pipe(gulp.dest(config.build));
gulp.src(['assets/logo.svg', 'service-worker.js'])
.pipe(gulp.dest(config.build));

6
html/embed.html Normal file
View File

@ -0,0 +1,6 @@
<html>
<iframe src="./index.html" style="border: 1px solid red; width: 95%; height: 95%" id="meshviewer-embedded"></iframe>
<script type="text/javascript" src="./embed.js" />
</html>

35
html/embed.js Normal file
View File

@ -0,0 +1,35 @@
(function() {
var iframe=document.getElementById("meshviewer-embedded")
if (!iframe) {
console.log("IFrame 'meshviewer-embedded' not found")
return;
}
if (!iframe.contentWindow) {
console.log("Element 'meshviewer-embedded' seems not to be a valid iframe")
return;
}
function updateIframeHash() { // see https://gist.github.com/manufitoussi/7529fa882ff0b737f257
if(iframe.contentWindow.location.host !== "") {
// iframe already loaded.
iframe.contentWindow.location.hash = window.location.hash;
} else {
// iframe is just starting.
var newHash = window.location.hash;
var srcStr = iframe.getAttribute('src');
var words = srcStr.split('#');
var href = words[0];
var newSrc = href + newHash;
iframe.setAttribute('src', newSrc);
}
};
updateIframeHash();
iframe.contentWindow.addEventListener("message", (event) => {
if (event && event.data && event.data.hash) {
window.location.replace(event.data.hash);
}
}, false);
window.onhashchange = updateIframeHash;
}) ();

View File

@ -71,6 +71,10 @@ define(['moment', 'utils/router', 'leaflet', 'gui', 'helper', 'utils/language'],
};
}
window.onhashchange = function () {
window.postMessage({hash: window.location.hash}, '*');
};
var language = new Language();
window.router = new Router(language);