clear before fetch to remove selection
[APKPM.git] / templates / user.html.ep
index cb3c2e5..937b8f2 100644 (file)
@@ -5,7 +5,8 @@
       var self = this;
    
       this.fetch = function() {
-        self.clear();
+       self.clear();
+        if ( ! self.args ) return;
        self.url = '/g/' + self.function_name + '/' + self.args + '?callback=JSON_CALLBACK';
         $xhr('JSON', self.url, function(code, response) {
           self.code = code;
@@ -51,7 +52,7 @@
                        , function(code, response) {
                                console.debug( code, response );
                                self.ldap = response;
-                               self.gnuplot_sql = '/gnuplot?sql=select timestamp,snrtx,attntx,pwrtx,pwrrx,attnrx,snrrx from adsl where username = \'' + response[0].cn + '\'';
+                               self.gnuplot_sql = '/gnuplot?hide=1;with=points;sql=select timestamp,snrtx,attntx,pwrtx,pwrrx,attnrx,snrrx from adsl where username = \'' + response[0].cn + '\' order by timestamp desc limit 100';
                        }
                );
        };
 
     CRM.$inject = ['$xhr'];
   </script>
+
+<style type="text/css">
+#columns {
+       position: fixed;
+       top: 0;
+       right: 0;
+       z-index: 10;
+       background: #eee;
+}
+
+#columns > span {
+       float: right;
+}
+
+#columns ul {
+       display: none;
+}
+
+#columns:hover ul {
+       display: block;
+}
+
+table {
+       border-collapse:collapse;
+}
+
+th {
+       border-bottom: 2px solid gray;
+}
+
+th, td {
+       border-left: 1em solid white;
+       border-right: 1em solid white;
+}
+
+.zebra {
+       background: #eee;
+}
+
+</style>
+
   <div ng:controller="CRM">
+   <form ng:submit="fetch()">
     <input type="hidden" name="function_name" value="CRM_search"      size="20"/>
     <label for="args">username:
-    <input type="text" name="args"     value="test" size="10"/>
+    <input type="text" name="args"     placeholder="test" size="10"/>
     </label>
-    <button ng:click="fetch()">fetch</button>
-    <button ng:click="clear()">clear</button>
+    <input type="submit" ng:click="fetch()" value="search">
+    <input type="reset"  ng:click="clear()" value="clear">
+
     <b ng:show="url && ! code">loading {{url}}</b>
-    <b ng:show="response">{{response.length}} results</b>
+    <b ng:show="response">{{response.length}} results for <tt>{{args}}</tt></b>
+   </form>
 
-<div style="font-size: 80%; float: right" ng:show="response">
-Add columns:
+<div id="columns" ng:show="response">
+<span>Add columns</span>
 <ul>
 <li ng:repeat="c in keys(response)" ng:show="columns.indexOf(c) < 0" ng:click="columns.push(c)">{{c}}
 </ul>
@@ -81,7 +126,7 @@ Add columns:
     <tr>
        <th ng:repeat="c in columns" ng:click="columns.$remove(c)">{{c}}</th>
     </tr>
-    <tr ng:repeat="u in response" ng:click="select(u)">
+    <tr ng:repeat="u in response" ng:click="select(u)" ng:class-even="'zebra'">
        <td ng:repeat="c in columns" ng:show="! selected_username || selected_username == u.USERNAME">{{u[c]}}</td>
     </tr>
     </table>