mirror of https://github.com/aredn/aredn.git
Better mesh empty page (#1505)
* Fix mesh data syntax error when page is empty * Make sure we have at least one host to show on the mesh page
This commit is contained in:
parent
c0e154794b
commit
2bfad694d8
|
@ -45,11 +45,16 @@ const h = fs.open("/var/run/hosts_olsr");
|
|||
if (h) {
|
||||
let originator = null;
|
||||
let first = true;
|
||||
let fallback = null;
|
||||
for (let line = h.read("line"); length(line); line = h.read("line")) {
|
||||
const v = match(trim(line), reHostsOlsr);
|
||||
if (v) {
|
||||
if (originator !== v[3]) {
|
||||
if (originator) {
|
||||
if (first && fallback) {
|
||||
print(`["${fallback}"]`);
|
||||
}
|
||||
fallback = null;
|
||||
print("],");
|
||||
}
|
||||
originator = v[3];
|
||||
|
@ -75,8 +80,14 @@ if (h) {
|
|||
}
|
||||
first = false;
|
||||
}
|
||||
else if (originator === "myself" && index(host, "dtdlink") === 0) {
|
||||
fallback = replace(host, /^dtdlink\.(.+)\.local\.mesh$/, "$1");
|
||||
}
|
||||
}
|
||||
}
|
||||
if (first && fallback) {
|
||||
print(`["${fallback}"]`);
|
||||
}
|
||||
print("]");
|
||||
h.close();
|
||||
}
|
||||
|
@ -108,7 +119,9 @@ if (s) {
|
|||
first = false;
|
||||
}
|
||||
}
|
||||
print("]");
|
||||
if (ip) {
|
||||
print("]");
|
||||
}
|
||||
s.close();
|
||||
}
|
||||
print(`},etx:[["${myself}",0.0],`);
|
||||
|
|
Loading…
Reference in New Issue