|
3 | 3 | <head> |
4 | 4 | <title>TinyTuya API Server</title> |
5 | 5 | <script src="https://code.jquery.com/jquery-3.2.1.min.js"></script> |
| 6 | + <link rel="stylesheet" href="tinytuya.css"> |
6 | 7 | </head> |
7 | 8 |
|
8 | | -<body> |
| 9 | +<body> |
9 | 10 | <div class="title"></div> |
10 | | - <p>Stats</p> |
| 11 | + <div class="row"> |
| 12 | + <div class="lcolumn"> |
| 13 | + <p class="onlinetext">Devices Online</p> |
| 14 | + <div class="devices"></div> |
| 15 | + </div> |
| 16 | + <div class = "rcolumn"> |
| 17 | + <p class="offlinetext">Devices Offline</p> |
| 18 | + <div class="offline"></div> |
| 19 | + </div> |
| 20 | + </div> |
11 | 21 | <div class="number"></div> |
12 | | - <p class="onlinetext">Devices Online</p> |
13 | | - <div class="devices"></div> |
14 | | - <p class="offlinetext">Registered Devices Offline</p> |
15 | | - <div class="offline"></div> |
16 | 22 | <script> |
17 | 23 |
|
18 | 24 | // Get Version |
|
29 | 35 | function numdevices() { |
30 | 36 | var pwurl = window.location.protocol + "//" + window.location.hostname + ":8888/numdevices"; |
31 | 37 | $.getJSON(pwurl, function(data) { |
32 | | - var text = `Number of Devices Found: ${data.found}` + "<br>" + |
33 | | - `Total Devices Registered: ${data.registered}`; |
| 38 | + var text = `Number of Devices Found: ${data.found}` + |
| 39 | + ` - Registered: ${data.registered}`; |
34 | 40 | var online = `Devices Online: ${data.found}`; |
35 | 41 | var numoff = data.registered - data.found; |
36 | 42 | if(numoff<0) numoff = 0; |
|
68 | 74 | // print sorted list |
69 | 75 | let sortedDevices = deviceDB.sort((c1, c2) => (c1.name > c2.name) ? 1 : (c1.name < c2.name) ? -1 : 0); |
70 | 76 | let rownum = 1; |
| 77 | + output = "<table><thead>\n<tr>\n<th>#</th><th>Device Name</th><th>Device ID</th>" + |
| 78 | + "<th>IP Address</th><th>Version</th><th>Control</th>\n</tr></thead>\n<tbody>"; |
71 | 79 | for (let x in sortedDevices) { |
72 | | - output = output + rownum + |
73 | | - " - <a href='device.html?id=" + sortedDevices[x].id + "'>" + |
74 | | - (sortedDevices[x].name.length > 0 ? sortedDevices[x].name : '[' + sortedDevices[x].id + ']') + "</a> - " + |
75 | | - "<a href='device_dps.html?id=" + sortedDevices[x].id + "'>" + sortedDevices[x].id + "</a> -" + |
76 | | - sortedDevices[x].ip + "<br>\n"; |
| 80 | + output = output + "<tr>\n<td>" + rownum + "</td>" + |
| 81 | + " <td> <a href='device_dps.html?id=" + sortedDevices[x].id + "'>" + |
| 82 | + (sortedDevices[x].name.length > 0 ? sortedDevices[x].name : '[' + sortedDevices[x].id + ']') + |
| 83 | + "</a> </td><td>" + |
| 84 | + "<div class='id'>" + sortedDevices[x].id + "</div></td><td>" + |
| 85 | + "<div class='address'>" + sortedDevices[x].ip + "</div></td><td>" + |
| 86 | + "<div class='version'>" + sortedDevices[x].version + "</div></td>" + |
| 87 | + " <td> <a href='device_dps.html?id=" + sortedDevices[x].id + "'>View</a></td>" |
| 88 | + "\n</tr>\n"; |
77 | 89 | rownum++; |
78 | 90 | } |
79 | | - |
| 91 | + output = output + "</tbody>\n</table>\n"; |
| 92 | + |
80 | 93 | $(".devices").html(output); |
81 | 94 |
|
82 | 95 | // TODO - convert to table |
|
107 | 120 | // print sorted list |
108 | 121 | let sortedDevices = deviceDB.sort((c1, c2) => (c1.name > c2.name) ? 1 : (c1.name < c2.name) ? -1 : 0); |
109 | 122 | let rownum = 1; |
| 123 | + output = "<table><thead>\n<tr>\n<th>#</th><th>Device Name</th><th>Device ID</th>" + |
| 124 | + "</tr></thead>\n<tbody>"; |
110 | 125 | for (let x in sortedDevices) { |
111 | | - output = output + rownum + |
112 | | - " - <a href='device.html?id=" + sortedDevices[x].id + "'>" + |
113 | | - (sortedDevices[x].name.length > 0 ? sortedDevices[x].name : '[' + sortedDevices[x].id + ']') + "</a> - " + |
114 | | - sortedDevices[x].id + "<br>\n"; |
| 126 | + output = output + "<tr>\n<td>" + rownum + "</td>" + |
| 127 | + " <td> <a href='device_dps.html?id=" + sortedDevices[x].id + "'>" + |
| 128 | + (sortedDevices[x].name.length > 0 ? sortedDevices[x].name : '[' + sortedDevices[x].id + ']') + |
| 129 | + "</a> </td><td>" + |
| 130 | + "<div class='id'>" + sortedDevices[x].id + "</div></td>" + |
| 131 | + "\n</tr>\n"; |
115 | 132 | rownum++; |
116 | 133 | } |
| 134 | + output = output + "</tbody>\n</table>\n"; |
117 | 135 |
|
118 | 136 | $(".offline").html(output); |
119 | 137 | }); |
|
0 commit comments