7 this.fetch = function() {
9 if ( ! self.args ) return;
10 self.url = '/g/' + self.function_name + '/' + self.args + '?callback=JSON_CALLBACK';
11 $xhr('JSON', self.url, function(code, response) {
13 self.response = response;
17 this.clear = function() {
21 self.selected_username = null;
22 self.gnuplot_sql = null;
36 this.keys = function(h) {
37 if ( angular.isArray(h) ) h = h[0];
39 for(i in h) if (h.hasOwnProperty(i))
46 this.select = function(crm) {
47 console.log( 'crm = ',crm );
48 self.selected_username = crm.USERNAME;
49 self.gnuplot_sql = null;
51 , '/g/LDAP_search/' + self.selected_username + '?callback=JSON_CALLBACK'
52 , function(code, response) {
53 console.debug( code, response );
55 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';
62 CRM.$inject = ['$xhr'];
65 <style type="text/css">
87 border-collapse:collapse;
91 border-bottom: 2px solid gray;
95 border-left: 1em solid white;
96 border-right: 1em solid white;
105 <div ng:controller="CRM">
106 <form ng:submit="fetch()">
107 <input type="hidden" name="function_name" value="CRM_search" size="20"/>
108 <label for="args">username:
109 <input type="text" name="args" placeholder="test" size="10"/>
111 <input type="submit" ng:click="fetch()" value="search">
112 <input type="reset" ng:click="clear()" value="clear">
114 <b ng:show="url && ! code">loading {{url}}</b>
115 <b ng:show="response">{{response.length}} results for <tt>{{args}}</tt></b>
118 <div id="columns" ng:show="response">
119 <span>Add columns</span>
121 <li ng:repeat="c in keys(response)" ng:show="columns.indexOf(c) < 0" ng:click="columns.push(c)">{{c}}
125 <table ng:show="response">
127 <th ng:repeat="c in columns" ng:click="columns.$remove(c)">{{c}}</th>
129 <tr ng:repeat="u in response" ng:click="select(u)" ng:class-even="'zebra'">
130 <td ng:repeat="c in columns" ng:show="! selected_username || selected_username == u.USERNAME">{{u[c]}}</td>
134 <input type=button value="Show ALL results, not just {{selected_username}}" ng:click="selected_username=''" ng:show="selected_username">
136 <div ng:show="selected_username">
138 <tt>{{selected_username}}</tt>
141 <li ng:repeat="c in keys(ldap)"><tt>{{c}}</tt> {{ldap[0][c]}}</li>
144 <ng:include src="gnuplot_sql" ng:show="gnuplot_sql">
148 <input type=checkbox name=debug value=1>
152 response={{response}}
153 username={{username}}