Skip to content

Commit

Permalink
Synced repo to live version
Browse files Browse the repository at this point in the history
  • Loading branch information
Moritz Kaspar Rudert (mortzu) committed Jun 26, 2020
1 parent d993956 commit 32baf92
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 11 deletions.
30 changes: 24 additions & 6 deletions app.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,9 @@ $(function() {
+ '<td>' + gatemon['provider'] + '</td>'
+ '<td>' + ((gatemon['node-id'] != 'unknown' && gatemon['node-id'] != undefined) ? '<a href="https://map.bremen.freifunk.net/#!/map/' + gatemon['node-id'] + '">' + gatemon['node-hostname'] + '</a></td>' : '')
+ '<td>' + gatemon['version'] + '</td>'
+ '<td class="' + gatemon_class + '"><time class="timeago" datetime="' + gatemon['lastupdated'] + '">' + gatemon['lastupdated'] + '</time></td>'
+ '<td class="' + gatemon_class + '">'
+ '<time class="timeago" datetime="' + gatemon['lastupdated'] + '">' + gatemon['lastupdated'] + '</time>'
+ '</td>'
+ '</tr>').appendTo($('#lastupdated'));
$(".timeago").timeago();

Expand All @@ -59,10 +61,25 @@ $(function() {

// Check if an element with ID of vpnserver exists
if ($("#" + vpnserver_name).length == 0) {
$('<div class="col-lg-6 col-md-12"><div class="well"><table class="table" id="' + vpnserver_name + '"><thead><tr id="' + vpnserver_name + 'server"></tr><tr id="' + vpnserver_name + 'services"><td></td></tr><tr id="' + vpnserver_name + 'servicesfamily"><td></td></tr></thead><tbody></tbody></table></div></div>').appendTo($('#content'));
$('<div class="col-lg-6 col-md-12"><div class="well">'
+ '<table class="table" id="' + vpnserver_name + '">'
+ '<thead>'
+ '<tr id="' + vpnserver_name + 'server"></tr>'
+ '<tr id="' + vpnserver_name + 'services"><td></td></tr>'
+ '<tr id="' + vpnserver_name + 'servicesfamily"><td></td></tr>'
+ '</thead>'
+ '<tbody></tbody>'
+ '</table></div></div>').appendTo($('#content'));
}

$('<tr id="' + vpnserver_name + gatemon['uuid'] + '"><td class="' + gatemon_class + '" title="Name: ' + gatemon['name'] + '\nProvider: ' + gatemon['provider'] + '\nVersion: ' + gatemon['version'] + '\nZuletzt aktualisiert: ' + gatemon['lastupdated'] + '">' + gatemon['name'] + '</td></tr>').appendTo($('#' + vpnserver_name + ' tbody'));
$('<tr id="' + vpnserver_name + gatemon['uuid'] + '">'
+ '<td class="' + gatemon_class + '" title="'
+ 'Name: ' + gatemon['name'] + '\n'
+ 'Provider: ' + gatemon['provider'] + '\n'
+ 'Version: ' + gatemon['version'] + '\n'
+ 'Zuletzt aktualisiert: ' + gatemon['lastupdated'] + '">'
+ gatemon['name']
+ '</td></tr>').appendTo($('#' + vpnserver_name + ' tbody'));

// Iterate over services returned by gatemon
counter = 0;
Expand All @@ -71,14 +88,15 @@ $(function() {
counter++;
if (gatemon_counter <= 1) {
$('<td colspan="2" class="text-center">' + key + '</td>').appendTo($('#' + vpnserver_name + 'services'));
$('<td class="text-center">IPv4</td><td class="text-center">IPv6</td>').appendTo($('#' + vpnserver_name + 'servicesfamily'));
$('<td class="text-center">IPv4</td>'
+ '<td class="text-center">IPv6</td>').appendTo($('#' + vpnserver_name + 'servicesfamily'));
}

$.each(['ipv4', 'ipv6'], function() {
if (vpnserver_status[key][this]['up']) {
$('<td class="good"' + (vpnserver_status[key][this]['time'] != false ? ' title="run time: ' + vpnserver_status[key][this]['time'] + 's"' : '') + '></td>').appendTo($('#' + vpnserver_name + gatemon['uuid']));
$('<td class="good"' + (vpnserver_status[key][this]['time'] != undefined ? ' title="run time: ' + vpnserver_status[key][this]['time'] + 's"' : '') + '></td>').appendTo($('#' + vpnserver_name + gatemon['uuid']));
} else {
$('<td class="bad"' + (vpnserver_status[key][this]['time'] != false ? ' title="run time: ' + vpnserver_status[key][this]['time'] + 's"' : '') + '></td>').appendTo($('#' + vpnserver_name + gatemon['uuid']));
$('<td class="bad"' + (vpnserver_status[key][this]['time'] != undefined ? ' title="run time: ' + vpnserver_status[key][this]['time'] + 's"' : '') + (vpnserver_status[key][this]["error-message"] != undefined ? "\nerror-message: " + vpnserver_status[key][this]["error-message"] : "") + '></td>').appendTo($('#' + vpnserver_name + gatemon['uuid']));
}
});
}
Expand Down
1 change: 1 addition & 0 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width">
<title>Freifunk Bremen - Status</title>
<link rel="stylesheet" href="/vendor/twbs/bootstrap/dist/css/bootstrap.min.css" type="text/css">
<link rel="stylesheet" href="/style.css" type="text/css">
Expand Down
12 changes: 7 additions & 5 deletions put.php
Original file line number Diff line number Diff line change
Expand Up @@ -88,8 +88,9 @@ function parseAndSanitizeInput ($report_text) {
'uuid' => $report_decoded['uuid'],
'name' => $report_decoded['name'] ?? 'unknown',
'provider' => $report_decoded['provider'] ?? 'unknown',
'node-hostname' => $report_decoded['node-hostname'] ?? 'unknown',
'node-id' => $report_decoded['node-id'] ?? 'unknown',
'node-hostname' => $report_decoded['node-hostname'] ?? NULL,
'node-id' => $report_decoded['node-id'] ?? NULL,
'current_vpn_server' => $report_decoded['current_vpn_server'] ?? NULL,
'vpn-servers' => array(),
);

Expand All @@ -107,10 +108,11 @@ function parseAndSanitizeInput ($report_text) {
else
$newServerData['status'][$topic][$addrType]['up'] = boolval($reportedServerData[$topic][0][$addrType]['status']);

if (isset($reportedServerData[$topic][0][$addrType]['time']))
if (isset($reportedServerData[$topic][0][$addrType]['time']) && !empty($reportedServerData[$topic][0][$addrType]['time']))
$newServerData['status'][$topic][$addrType]['time'] = $reportedServerData[$topic][0][$addrType]['time'];
else
$newServerData['status'][$topic][$addrType]['time'] = false;

if (isset($reportedServerData[$topic][0][$addrType]['error-message']) && !empty($reportedServerData[$topic][0][$addrType]['error-message']))
$newServerData['status'][$topic][$addrType]['error-message'] = $reportedServerData[$topic][0][$addrType]['error-message'];
}
}

Expand Down

0 comments on commit 32baf92

Please sign in to comment.