display last ping for user
[APKPM.git] / public / user.html
index 1e3ee78..e8d3f1d 100644 (file)
@@ -88,8 +88,21 @@ console.debug( cols );
        self.r.table = $resource('/table/:table');
        self.table_update = function () {
                if ( ! self.username || ! self.cpe.table_name ) return;
+
+               self.message.ping = self.username+' loading';
+               self.r.table.get({ username: self.username, table: 'ping', limit: 1 }, function(ping) {
+                       $log.info('ping', ping);
+                       self.message.ping = null;
+                       var hash = {};
+                       for(var i = 0; i <= ping.columns.length; i++) {
+                               hash[ping.columns[i]] = ping.rows[0][i];
+                       }
+                       self.cpe.ping = hash;
+                       $log.info('ping hash', hash);
+               });
+
                self.message.table = self.username + ' loading from ' + self.cpe.table_name;
-               self.r.table.get({ username: self.username, table: self.cpe.table_name, limit: self.cpe.limit }, function(table) {
+               self.r.table.get({ username: self.username, table: self.cpe.table_name, limit: self.cpe_limit }, function(table) {
                        $log.info( 'table', table );
                        self.cpe.table = table;
                        self.message.table = null;
@@ -118,7 +131,8 @@ console.debug( cols );
                self.LDAP = null;
                self.selected_username = null;
                self.gnuplot = {};
-               self.cpe = { limit: 1 };
+               self.cpe = {};
+               self.cpe_limit = 1;
        };
 
        self.message = {};
@@ -128,9 +142,8 @@ console.debug( cols );
        });
 
        self.clear();
-       self.cpe_limit = self.cpe.limit;
        self.$watch('cpe_limit', function() {
-               $log.info( 'limit', self.cpe.limit = self.cpe_limit );
+               $log.info( 'cpe_limit', self.cpe_limit );
                self.table_update();
        });
 
@@ -223,6 +236,9 @@ th, td {
        float: right;
 }
 
+li > tt {
+       font-weight: bold;
+}
 
 </style>
 
@@ -230,7 +246,7 @@ th, td {
 
    <form ng:submit="CRM_search()">
     <label for="args">username:
-    <input type="text" name="search_username" placeholder="test" size="10" ng:required />
+    <input type="text" name="search_username" placeholder="test" size="10" autofocus ng:required />
     </label>
     <input type="submit" value="search in CRM">
     <input type="reset"  ng:click="clear()" value="clear">
@@ -268,9 +284,13 @@ th, td {
     <h2><tt>{{selected_username}}</tt> LDAP entry</h2>
 
     <ul ng:show="LDAP">
-     <li ng:repeat="c in keys(LDAP)">{{c}} <b>{{LDAP[0][c]}}</b></li>
+     <li ng:repeat="c in keys(LDAP)"><tt>{{c}}</tt> {{LDAP[0][c]}}</li>
     </ul>
 
+    <div ng:show="cpe.ping">
+     ping <tt>{{cpe.ping.ip}}</tt> rtt <tt>{{cpe.ping.rtt}}</tt> at <tt>{{cpe.ping.timestamp}}</tt>
+    </div>
+
    <div class="panel_right" ng:show="cpe.table">
     <label>
      Graph columns