var self = this;
this.fetch = function() {
- self.clear();
+ self.clear();
+ if ( ! self.args ) {
+ self.message = 'Enter part of username to search';
+ return;
+ }
self.url = '/g/' + self.function_name + '/' + self.args + '?callback=JSON_CALLBACK';
$xhr('JSON', self.url, function(code, response) {
self.code = code;
self.response = response;
+ self.message = response.length + ' results for <tt>'+self.args+'</tt>';
});
+ self.message = 'loading '+self.url;
};
-
+
this.clear = function() {
self.url = null;
self.code = null;
self.response = null;
+ self.selected_username = null;
+ self.gnuplot_sql = null;
+ self.ldap = null;
+ self.message = null;
};
this.columns = [
};
this.select = function(crm) {
- console.log( crm );
+ console.log( 'crm = ',crm );
self.selected_username = crm.USERNAME;
+ self.gnuplot_sql = null;
+ $xhr('JSON'
+ , '/g/LDAP_search/' + self.selected_username + '?callback=JSON_CALLBACK'
+ , function(code, response) {
+ console.debug( code, response );
+ self.ldap = response;
+ 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';
+ self.message = 'generating ADSL graph for '+response[0].cn;
+ }
+ );
+ self.message = 'LDAP search for '+self.selected_username;
};
- this.selected_username = '';
-
}
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;
+}
+
+#message {
+ padding: 3px;
+ background: #ff8;
+
+ margin-left: 1em;
+ position: fixed;
+}
+
+</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>
- <b ng:show="url && ! code">loading {{url}}</b>
- <b ng:show="response">{{response.length}} results</b>
+ <input type="submit" ng:click="fetch()" value="search">
+ <input type="reset" ng:click="clear()" value="clear">
-<div style="font-size: 80%; float: right" ng:show="response">
-Add columns:
+ <span id="message" ng:show="message">{{message | html}}</span>
+
+ </form>
+
+<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>
<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>
<input type=button value="Show ALL results, not just {{selected_username}}" ng:click="selected_username=''" ng:show="selected_username">
+ <div ng:show="selected_username">
+
+ <tt>{{selected_username}}</tt>
+
+ <ul ng:show="ldap">
+ <li ng:repeat="c in keys(ldap)"><tt>{{c}}</tt> {{ldap[0][c]}}</li>
+ </ul>
+
+ <ng:include src="gnuplot_sql" ng:show="gnuplot_sql">
+
+ </div>
+
<input type=checkbox name=debug value=1>
<pre ng:show=debug>
+message={{message}}
url={{url}}
code={{code}}
response={{response}}
-username={{username}}
</pre>
</div>