Mercurial > code > home > repos > homeauto
comparison service/usbReset/index.html @ 80:855deb1509a5
updated device tree. web ui for resetting things
Ignore-this: 7a2fe227320ca328cc46ef1f30b77c15
author | drewp@bigasterisk.com |
---|---|
date | Wed, 29 May 2013 00:43:51 -0700 |
parents | |
children | d379351d398d |
comparison
equal
deleted
inserted
replaced
79:a2df988e2087 | 80:855deb1509a5 |
---|---|
1 <?xml version="1.0" encoding="iso-8859-1"?> | |
2 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" | |
3 "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd"> | |
4 <html xmlns="http://www.w3.org/1999/xhtml"> | |
5 <head> | |
6 <title>usbreset</title> | |
7 <style> | |
8 body { | |
9 font-family: helvetica; | |
10 font-size: 12px; | |
11 } | |
12 table { | |
13 border-collapse: collapse; | |
14 } | |
15 td, th { | |
16 border: 1px solid #ccc; | |
17 padding: 3px 15px; | |
18 } | |
19 tr:nth-child(even) { background: #f8f8f8; } | |
20 tr:nth-child(odd) { background: #eee; } | |
21 </style> | |
22 </head> | |
23 <body> | |
24 | |
25 <table> | |
26 <thead> | |
27 <tr> | |
28 <th>dev</th> | |
29 <th>usbId</th> | |
30 <th>name</th> | |
31 <th>usbName</th> | |
32 </tr> | |
33 </thead> | |
34 <tbody data-bind="foreach: devices"> | |
35 <tr> | |
36 <td> | |
37 <span data-bind="text: dev"/> | |
38 <button data-bind="click: reset">Reset</button> | |
39 </td> | |
40 <td data-bind="text: usbId"></td> | |
41 <td data-bind="text: name"></td> | |
42 <td data-bind="text: usbName"></td> | |
43 </tr> | |
44 </tbody> | |
45 </table> | |
46 <pre id="error"></pre> | |
47 <script src="static/jquery-1.8.3.min.js"></script> | |
48 <script src="static/knockout-2.2.0.js"></script> | |
49 <script type="text/javascript"> | |
50 // <![CDATA[ | |
51 $(function () { | |
52 var model = { | |
53 devices: ko.observable(), | |
54 }; | |
55 | |
56 ko.applyBindings(model); | |
57 | |
58 $("#error").ajaxSend(function () { | |
59 $(this).text(""); | |
60 }).ajaxError(function (ev, xhr, settings, error) { | |
61 $(this).text(xhr.responseText); | |
62 }); | |
63 | |
64 function reloadDevices() { | |
65 | |
66 $.getJSON("devices", function (ret) { | |
67 ret.devices.forEach(function (dev) { | |
68 dev.reset = function (row, ev) { | |
69 var target = $(ev.target); | |
70 target.text("..."); | |
71 $.ajax({ | |
72 type: "POST", | |
73 url: "devices/reset", | |
74 data: {dev: dev.dev}, | |
75 success: function () { | |
76 target.text("ok"); | |
77 // resetting hubs can renumber the deeper devices | |
78 reloadDevices(); | |
79 }, | |
80 error: function () { | |
81 target.text("failed"); | |
82 }, | |
83 }); | |
84 }; | |
85 }); | |
86 model.devices(ret.devices); | |
87 }); | |
88 } | |
89 reloadDevices(); | |
90 | |
91 }); | |
92 // ]]> | |
93 </script> | |
94 </body> | |
95 </html> |