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