7 this.fetch = function() {
8 if ( ! self.args ) return;
9 self.url = '/g/' + self.function_name + '/' + self.args + '?callback=JSON_CALLBACK';
10 $xhr('JSON', self.url, function(code, response) {
12 self.response = response;
16 this.clear = function() {
20 self.selected_username = null;
21 self.gnuplot_sql = null;
35 this.keys = function(h) {
36 if ( angular.isArray(h) ) h = h[0];
38 for(i in h) if (h.hasOwnProperty(i))
45 this.select = function(crm) {
46 console.log( 'crm = ',crm );
47 self.selected_username = crm.USERNAME;
48 self.gnuplot_sql = null;
50 , '/g/LDAP_search/' + self.selected_username + '?callback=JSON_CALLBACK'
51 , function(code, response) {
52 console.debug( code, response );
54 self.gnuplot_sql = '/gnuplot?sql=select timestamp,snrtx,attntx,pwrtx,pwrrx,attnrx,snrrx from adsl where username = \'' + response[0].cn + '\'';
61 CRM.$inject = ['$xhr'];
63 <div ng:controller="CRM">
64 <form ng:submit="fetch()">
65 <input type="hidden" name="function_name" value="CRM_search" size="20"/>
66 <label for="args">username:
67 <input type="text" name="args" placeholder="test" size="10"/>
69 <input type="submit" ng:click="fetch()" value="search">
70 <input type="reset" ng:click="clear()" value="clear">
72 <b ng:show="url && ! code">loading {{url}}</b>
73 <b ng:show="response">{{response.length}} results for <tt>{{args}}</tt></b>
76 <div style="font-size: 80%; float: right" ng:show="response">
79 <li ng:repeat="c in keys(response)" ng:show="columns.indexOf(c) < 0" ng:click="columns.push(c)">{{c}}
83 <table ng:show="response">
85 <th ng:repeat="c in columns" ng:click="columns.$remove(c)">{{c}}</th>
87 <tr ng:repeat="u in response" ng:click="select(u)">
88 <td ng:repeat="c in columns" ng:show="! selected_username || selected_username == u.USERNAME">{{u[c]}}</td>
92 <input type=button value="Show ALL results, not just {{selected_username}}" ng:click="selected_username=''" ng:show="selected_username">
94 <div ng:show="selected_username">
96 <tt>{{selected_username}}</tt>
99 <li ng:repeat="c in keys(ldap)"><tt>{{c}}</tt> {{ldap[0][c]}}</li>
102 <ng:include src="gnuplot_sql" ng:show="gnuplot_sql">
106 <input type=checkbox name=debug value=1>
110 response={{response}}
111 username={{username}}