Update status_ui.go and status.html
This commit is contained in:
parent
1edac26c50
commit
44de3e8694
@ -1,7 +1,6 @@
|
|||||||
package main
|
package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
|
||||||
"net/http"
|
"net/http"
|
||||||
"strconv"
|
"strconv"
|
||||||
|
|
||||||
@ -15,12 +14,16 @@ func statusPage(ctx *macaron.Context) {
|
|||||||
func jsonStatus(ctx *macaron.Context) {
|
func jsonStatus(ctx *macaron.Context) {
|
||||||
// MQTTpublish("openpdu/status", "asdss")
|
// MQTTpublish("openpdu/status", "asdss")
|
||||||
|
|
||||||
var data = [][]string{}
|
var data = make([]Dictionary, 0)
|
||||||
var o *Outlet
|
var o *Outlet
|
||||||
for i := range outlets {
|
for i := range outlets {
|
||||||
o = outlets[i]
|
o = outlets[i]
|
||||||
d := []string{fmt.Sprintf("%d", o.Num), o.Channel.Name, fmt.Sprintf("%v", o.Channel.Value)}
|
// d := []string{fmt.Sprintf("%d", o.Num), o.Channel.Name, fmt.Sprintf("%v", o.Channel.Value)}
|
||||||
data = append(data, d)
|
data = append(data, Dictionary{
|
||||||
|
"Num": o.Num,
|
||||||
|
"Description": o.Description,
|
||||||
|
"Status": o.Channel.Value,
|
||||||
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
ctx.JSON(http.StatusOK, Dictionary{
|
ctx.JSON(http.StatusOK, Dictionary{
|
||||||
|
@ -33,7 +33,7 @@
|
|||||||
<thead>
|
<thead>
|
||||||
<tr>
|
<tr>
|
||||||
<th style="width: 15px">#</th>
|
<th style="width: 15px">#</th>
|
||||||
<th>Plug name</th>
|
<th>Description</th>
|
||||||
<th style="width: 30px">Status</th>
|
<th style="width: 30px">Status</th>
|
||||||
<th style="width: 300px">Power load</th>
|
<th style="width: 300px">Power load</th>
|
||||||
<th style="width: 150px">Command</th>
|
<th style="width: 150px">Command</th>
|
||||||
@ -78,9 +78,9 @@
|
|||||||
var table = $('#example2').DataTable({
|
var table = $('#example2').DataTable({
|
||||||
'ajax': '/json/status',
|
'ajax': '/json/status',
|
||||||
"columns" : [
|
"columns" : [
|
||||||
{ "data" : 0 },
|
{ "data" : "Num" },
|
||||||
{ "data" : 1 },
|
{ "data" : "Description" },
|
||||||
{ "data" : 2 },
|
{ "data" : "Status" },
|
||||||
{ "data" : null, "defaultContent": "<div class='progress progress-xs'><div class='progress-bar progress-bar-danger' style='width: 55%'></div></div>"},
|
{ "data" : null, "defaultContent": "<div class='progress progress-xs'><div class='progress-bar progress-bar-danger' style='width: 55%'></div></div>"},
|
||||||
{ "data" : null, "defaultContent":btnhtml }
|
{ "data" : null, "defaultContent":btnhtml }
|
||||||
],
|
],
|
||||||
@ -90,7 +90,7 @@
|
|||||||
'ordering' : true,
|
'ordering' : true,
|
||||||
'info' : true,
|
'info' : true,
|
||||||
'rowCallback': function( row, data ) {
|
'rowCallback': function( row, data ) {
|
||||||
if ( data[2] == "true" ) {
|
if ( data.Status ) {
|
||||||
$('td:eq(2)', row).html( '<i class="fa fa-toggle-on"></i>' );
|
$('td:eq(2)', row).html( '<i class="fa fa-toggle-on"></i>' );
|
||||||
} else {
|
} else {
|
||||||
$('td:eq(2)', row).html( '<i class="fa fa-toggle-off"></i>' );
|
$('td:eq(2)', row).html( '<i class="fa fa-toggle-off"></i>' );
|
||||||
|
Loading…
Reference in New Issue
Block a user