Merge branch 'devel' of h1dev:/srv/APKPM/
[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) {
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       }
14         this.status_update();
15       setInterval( this.status_update, 5000 );
16
17         var a = $location.hashPath.split('/');
18         self.function_name = a[0];
19         self.args = a[1];
20  
21       this.fetch = function() {
22         self.clear();
23         $location.hashPath = self.function_name + '/' + self.args;
24         self.url = '/g/' + $location.hashPath + '?callback=JSON_CALLBACK';
25         $xhr('JSON', self.url, function(code, response) {
26           self.code = code;
27           self.response = response;
28         });
29       };
30    
31       this.clear = function() {
32         self.code = null;
33         self.response = null;
34       };
35     }
36     GearmanCntl.$inject = ['$xhr','$location'];
37   </script>
38   <div ng:controller="GearmanCntl">
39     <select name="function_name">
40     <option ng:repeat="f in g.status" ng:show="f.available" value="{{f.function}}">{{f.function}}</option>
41     <input type="text" name="args"     value="127.0.0.1" size="40"/>
42     <button ng:click="fetch()">fetch</button>
43     <button ng:click="clear()">clear</button>
44
45     <table ng:show="response.columns">
46     <tr><th ng:repeat="c in response.columns">{{c}}</th></tr>
47     <tr ng:repeat="r in response.rows">
48      <td ng:repeat="v in r">{{v}}</td>
49     </tr>
50     </table>
51
52     <pre>
53 url={{url}}
54 code={{code}}
55 response={{response}}
56     </pre>
57
58 <table>
59 <tr><th>function</th><th>total</th><th>running</th><th>available</th></tr>
60 <tr ng:repeat="f in g.status">
61 <td>{{f.function}}</td>
62 <td>{{f.total}}</td>
63 <td>{{f.running}}</td>
64 <td>{{f.available}}</td>
65 </tr>
66 </table>
67 <button ng:click="status_update()">update</button>
68
69   </div>
70  </body>
71 </html>