7 this.fetch = function() {
10 self.message = 'Enter part of username to search';
13 self.url = '/g/' + self.function_name + '/' + self.args + '?callback=JSON_CALLBACK';
14 $xhr('JSON', self.url, function(code, response) {
16 self.response = response;
17 self.message = response.length + ' results for <tt>'+self.args+'</tt>';
19 self.message = 'loading '+self.url;
22 this.clear = function() {
26 self.selected_username = null;
27 self.gnuplot_sql = null;
42 this.keys = function(h) {
43 if ( angular.isArray(h) ) h = h[0];
45 for(i in h) if (h.hasOwnProperty(i))
52 this.select = function(crm) {
53 console.log( 'crm = ',crm );
54 self.selected_username = crm.USERNAME;
55 self.gnuplot_sql = null;
57 , '/g/LDAP_search/' + self.selected_username + '?callback=JSON_CALLBACK'
58 , function(code, response) {
59 console.debug( code, response );
61 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 self.message = 'generating ADSL graph for '+response[0].cn;
65 self.message = 'LDAP search for '+self.selected_username;
70 CRM.$inject = ['$xhr'];
73 <style type="text/css">
95 border-collapse:collapse;
99 border-bottom: 2px solid gray;
103 border-left: 1em solid white;
104 border-right: 1em solid white;
121 <div ng:controller="CRM">
123 <form ng:submit="fetch()">
124 <input type="hidden" name="function_name" value="CRM_search" size="20"/>
125 <label for="args">username:
126 <input type="text" name="args" placeholder="test" size="10"/>
128 <input type="submit" ng:click="fetch()" value="search">
129 <input type="reset" ng:click="clear()" value="clear">
131 <span id="message" ng:show="message">{{message | html}}</span>
135 <div id="columns" ng:show="response">
136 <span>Add columns</span>
138 <li ng:repeat="c in keys(response)" ng:show="columns.indexOf(c) < 0" ng:click="columns.push(c)">{{c}}
142 <table ng:show="response">
144 <th ng:repeat="c in columns" ng:click="columns.$remove(c)">{{c}}</th>
146 <tr ng:repeat="u in response" ng:click="select(u)" ng:class-even="'zebra'">
147 <td ng:repeat="c in columns" ng:show="! selected_username || selected_username == u.USERNAME">{{u[c]}}</td>
151 <input type=button value="Show ALL results, not just {{selected_username}}" ng:click="selected_username=''" ng:show="selected_username">
153 <div ng:show="selected_username">
155 <tt>{{selected_username}}</tt>
158 <li ng:repeat="c in keys(ldap)"><tt>{{c}}</tt> {{ldap[0][c]}}</li>
161 <ng:include src="gnuplot_sql" ng:show="gnuplot_sql">
165 <input type=checkbox name=debug value=1>
170 response={{response}}