fix user.html link
[APKPM.git] / public / gearman.html
index 411aad3..82146f5 100644 (file)
@@ -3,19 +3,28 @@
  <script src="http://code.angularjs.org/angular-0.9.12.min.js" ng:autobind></script>
  <body>
   <script>
-    function GearmanCntl($xhr) {
+    function GearmanCntl($xhr,$location,$defer) {
       var self = this;
-  
+
       this.status_update = function() {
         $xhr('JSON', '/_g/status?callback=JSON_CALLBACK', function(code,response) {
           self.g = response;
         });
+        if ( self.status_interval > 0 ) {
+               $defer( self.status_update, self.status_interval * 1000 );
+       }
       }
-      this.status_update();
+       this.status_interval = 5; // seconds
+       this.status_update();
+
+       var a = $location.hashPath.split('/');
+       self.function_name = a[0];
+       self.args = a[1];
  
       this.fetch = function() {
         self.clear();
-       self.url = '/g/' + self.function_name + '/' + self.args + '?callback=JSON_CALLBACK';
+        $location.hashPath = self.function_name + '/' + self.args;
+       self.url = '/g/' + $location.hashPath + '?callback=JSON_CALLBACK';
         $xhr('JSON', self.url, function(code, response) {
           self.code = code;
           self.response = response;
@@ -27,7 +36,7 @@
         self.response = null;
       };
     }
-    GearmanCntl.$inject = ['$xhr'];
+    GearmanCntl.$inject = ['$xhr','$location','$defer'];
   </script>
   <div ng:controller="GearmanCntl">
     <select name="function_name">
     <button ng:click="fetch()">fetch</button>
     <button ng:click="clear()">clear</button>
 
+    <table ng:show="response.columns">
+    <tr><th ng:repeat="c in response.columns">{{c}}</th></tr>
+    <tr ng:repeat="r in response.rows">
+     <td ng:repeat="v in r">{{v}}</td>
+    </tr>
+    </table>
+
     <pre>
 url={{url}}
 code={{code}}
@@ -44,7 +60,7 @@ response={{response}}
 
 <table>
 <tr><th>function</th><th>total</th><th>running</th><th>available</th></tr>
-<tr ng:repeat="f in g.status">
+<tr ng:repeat="f in g.status.$orderBy('function')">
 <td>{{f.function}}</td>
 <td>{{f.total}}</td>
 <td>{{f.running}}</td>
@@ -52,6 +68,7 @@ response={{response}}
 </tr>
 </table>
 <button ng:click="status_update()">update</button>
+<input name=status_interval size=2>s
 
   </div>
  </body>