parse show interface $port adsl-status
[APKPM.git] / public / gearman.html
1 <!doctype html>
2 <html xmlns:ng="http://angularjs.org">
3  <script src="http://code.angularjs.org/angular-0.9.12.min.js" ng:autobind></script>
4  <body>
5   <script>
6     function GearmanCntl($xhr,$location,$defer) {
7       var self = this;
8
9       this.status_update = function() {
10         $xhr('JSON', '/_g/status?callback=JSON_CALLBACK', function(code,response) {
11           self.g = response;
12         });
13         if ( self.status_interval > 0 ) {
14                 $defer( self.status_update, self.status_interval * 1000 );
15         }
16       }
17         this.status_interval = 5; // seconds
18         this.status_update();
19
20         var a = $location.hashPath.split('/');
21         self.function_name = a[0];
22         self.args = a[1];
23  
24       this.fetch = function() {
25         self.clear();
26         $location.hashPath = self.function_name + '/' + self.args;
27         self.url = '/g/' + $location.hashPath + '?callback=JSON_CALLBACK';
28         $xhr('JSON', self.url, function(code, response) {
29           self.code = code;
30           self.response = response;
31         });
32       };
33    
34       this.clear = function() {
35         self.code = null;
36         self.response = null;
37       };
38     }
39     GearmanCntl.$inject = ['$xhr','$location','$defer'];
40   </script>
41   <div ng:controller="GearmanCntl">
42     <select name="function_name">
43     <option ng:repeat="f in g.status" ng:show="f.available" value="{{f.function}}">{{f.function}}</option>
44     <input type="text" name="args"     value="127.0.0.1" size="40"/>
45     <button ng:click="fetch()">fetch</button>
46     <button ng:click="clear()">clear</button>
47
48     <table ng:show="response.columns">
49     <tr><th ng:repeat="c in response.columns">{{c}}</th></tr>
50     <tr ng:repeat="r in response.rows">
51      <td ng:repeat="v in r">{{v}}</td>
52     </tr>
53     </table>
54
55     <pre>
56 url={{url}}
57 code={{code}}
58 response={{response}}
59     </pre>
60
61 <table>
62 <tr><th>function</th><th>total</th><th>running</th><th>available</th></tr>
63 <tr ng:repeat="f in g.status.$orderBy('function')">
64 <td>{{f.function}}</td>
65 <td>{{f.total}}</td>
66 <td>{{f.running}}</td>
67 <td>{{f.available}}</td>
68 </tr>
69 </table>
70 <button ng:click="status_update()">update</button>
71 <input name=status_interval size=2>s
72
73   </div>
74  </body>
75 </html>