This commit is contained in:
Paolo Asperti 2021-01-05 09:43:50 +01:00
parent 6f42dafcb9
commit 76576053e2
Signed by: paspo
GPG Key ID: 06D46905D19D5182
2 changed files with 13 additions and 20 deletions

View File

@ -71,7 +71,6 @@ func startServer() {
m := macaron.Classic() m := macaron.Classic()
m.Use(pongo2.Pongoer()) m.Use(pongo2.Pongoer())
m.Use(macaron.Static("static")) m.Use(macaron.Static("static"))
// m.Get("/", myHandler)
m.Get("/", statusPage) m.Get("/", statusPage)
m.Get("/outlets", outletsPage) m.Get("/outlets", outletsPage)
@ -87,12 +86,6 @@ func startServer() {
m.Get("/json/status", jsonStatus) m.Get("/json/status", jsonStatus)
m.Post("/json/outlet/:id/toggle", jsonOutletToggle) m.Post("/json/outlet/:id/toggle", jsonOutletToggle)
m.Get("/boards", func(ctx *macaron.Context) {
ctx.HTML(200, "boards") // 200 is the response code.
})
logInfo("hostname: " + viper.GetString("system.hostname"))
logInfo("Web interface ready") logInfo("Web interface ready")
http.ListenAndServe("0.0.0.0:"+viper.GetString("system.listeningport"), m) http.ListenAndServe("0.0.0.0:"+viper.GetString("system.listeningport"), m)
} }

View File

@ -72,16 +72,6 @@
$(function () { $(function () {
var btnhtml = `<div class="btn-group"> var btnhtml = `<div class="btn-group">
<button type="button" class="btn btn-info" script="toggle">Toggle</button> <button type="button" class="btn btn-info" script="toggle">Toggle</button>
<button type="button" class="btn btn-info dropdown-toggle" data-toggle="dropdown">
<span class="caret"></span>
<span class="sr-only">Toggle Dropdown</span>
</button>
<ul class="dropdown-menu" role="menu">
<li><a href="#">On</a></li>
<li><a href="#">Off</a></li>
<li class="divider"></li>
<li><a href="#">Edit</a></li>
</ul>
</div>`; </div>`;
@ -98,10 +88,20 @@
'lengthChange': true, 'lengthChange': true,
'searching' : true, 'searching' : true,
'ordering' : true, 'ordering' : true,
'info' : true 'info' : true,
'rowCallback': function( row, data ) {
if ( data[2] == "true" ) {
$('td:eq(2)', row).html( '<i class="fa fa-toggle-on"></i>' );
} else {
$('td:eq(2)', row).html( '<i class="fa fa-toggle-off"></i>' );
}
}
}); });
// fa-toggle-off // autoreload every 3 seconds
setInterval( function () {
table.ajax.reload();
}, 3000 );
$('#example2 tbody').on( 'click', '[script="toggle"]', function (e) { $('#example2 tbody').on( 'click', '[script="toggle"]', function (e) {
e.preventDefault(); e.preventDefault();