added limit
[APKPM.git] / templates / user.html.ep
index 1aa71cf..5c0f087 100644 (file)
                                        return;
                                }
                                self.ldap = response;
-                               var parser = response[0]._cpe_parser;
-                               console.info( 'parser', parser );
-                               if ( h_cols = self.cpe_hash[parser] ) {
+                               self._cpe_parser = response[0]._cpe_parser;
+                               self.username = response[0].cn;
+                               self.cpe = {
+                                       parser: self._cpe_parser,
+                                       table: 'cpe_' + self._cpe_parser,
+                               };
+
+                               $xhr('JSON', '/table/' + self.cpe.table + '?username='+self.username+';callback=JSON_CALLBACK', function( code, table ) {
+                                       self.cpe.rows = table.rows;
+                                       self.message = 'loaded cpe_'+self.cpe.parser+' rows';
+                               });
+                               self.message = 'loading cpe_'+self.cpe.parser+' rows...';
+
+                               if ( h_cols = self.cpe_hash[self.cpe.parser] ) {
                                        var cols = [ 'timestamp' ];
                                        for ( var i = 0; i < h_cols.length; i++ ) {
                                                cols.push( 'h->\'' + h_cols[i] + '\' as "' + h_cols[i] + '"' );
                                        }
 console.debug( cols );
-                                       self.gnuplot.sql = 'select ' + cols.join(',') + ' from cpe_' + parser + ' where username = \'' + response[0].cn + '\' order by timestamp desc limit 100';
+                                       self.gnuplot.sql = 'select ' + cols.join(',') + ' from cpe_' + self.cpe.parser + ' where username = \'' + self.username + '\' order by timestamp desc limit 100';
 
-                                       self.gnuplot.img = '/gnuplot?hide=1;with=points;sql=' + self.gnuplot.sql;
                                        console.info( 'gnuplot', self.gnuplot );
-                                       self.message = 'generating ADSL graph for '+response[0].cn + ' ';
+                                       self.message = 'generating ADSL graph for '+self.username;
+                                       self.gnuplot.img = '/gnuplot?hide=1;with=points;sql=' + self.gnuplot.sql;
                                } else {
-                                       self.message = 'no graph defined for ' + parser;
+                                       self.message = 'no graph defined for ' + self.cpe.parser;
                                }
+
                        }
                );
                self.message = 'LDAP search for '+self.selected_username;
@@ -146,7 +158,7 @@ th, td {
 
    <form ng:submit="fetch()">
     <input type="hidden" name="function_name" value="CRM_search"      size="20"/>
-    <label for="args">username:
+    <label for="args">CRM username:
     <input type="text" name="args"     placeholder="test" size="10"/>
     </label>
     <input type="submit" ng:click="fetch()" value="search">
@@ -176,14 +188,17 @@ th, td {
 
   <div ng:show="selected_username">
 
-    <tt>{{selected_username}}</tt>
+    <h2><tt>{{selected_username}}</tt> LDAP entry</h2>
 
     <ul ng:show="ldap">
-       <h2>LDAP entry</h2>
     <li ng:repeat="c in keys(ldap)"><tt>{{c}}</tt> {{ldap[0][c]}}</li>
     </ul>
 
-    <h2 ng:show="gnuplot.title">{{gnuplot.title}}</h2>
+    <div ng:show="cpe.rows">
+    <h2>{{cpe.table}} {{username}}</h2>
+    <pre>{{cpe.rows[0]}}</pre>
+    </div>
+
     <ng:include src="gnuplot.img" ng:show="gnuplot.img" onload="message = 'done'">
     <pre ng:show="gnuplot.sql">{{gnuplot.sql}}</pre>
 
@@ -191,10 +206,6 @@ th, td {
 
     <input type=checkbox name=debug value=1>
     <pre ng:show=debug>
-gnuplot={{gnuplot}}
-message={{message}}
-url={{url}}
-code={{code}}
-response={{response}}
+{{self}}
     </pre>
   </div>