X-Git-Url: http://git.rot13.org/?a=blobdiff_plain;f=templates%2Fuser.html.ep;h=5c0f087bca0abefe8c6302a647b84767639fa1cb;hb=3ffef4b6db52c61b4b8ceb51999784694243f72d;hp=c21a19ba74758e94b655d874001081f75f97ee62;hpb=96811068e7e490f2e66a89325e3f71449fa720ff;p=APKPM.git diff --git a/templates/user.html.ep b/templates/user.html.ep index c21a19b..5c0f087 100644 --- a/templates/user.html.ep +++ b/templates/user.html.ep @@ -5,21 +5,28 @@ var self = this; this.fetch = function() { - if ( ! self.args ) return; + 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 '+self.args+''; }); + 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.gnuplot = {}; self.ldap = null; + self.message = null; }; this.columns = [ @@ -32,6 +39,12 @@ 'OPT82' ]; + this.cpe_hash = { + 'Davolink': [ 'Max_down', 'Max_up' ], +// 'Davolink': [ 'select timestamp,h->\'Max_down\' as Max_down,h->\'Max_up\' as Max_up from cpe_Davolink where username = \'', '\' order by timestamp desc limit 100' ], +// 'EasyGateway': + }; + this.keys = function(h) { if ( angular.isArray(h) ) h = h[0]; var keys = []; @@ -45,15 +58,47 @@ this.select = function(crm) { console.log( 'crm = ',crm ); self.selected_username = crm.USERNAME; - self.gnuplot_sql = null; + self.gnuplot = {}; $xhr('JSON' , '/g/LDAP_search/' + self.selected_username + '?callback=JSON_CALLBACK' , function(code, response) { console.debug( code, response ); + if ( ! response[0] ) { + self.message = 'no user ' + self.selected_username + ' in LDAP'; + return; + } 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._cpe_parser = response[0]._cpe_parser; + self.username = response[0].cn; + self.cpe = { + parser: self._cpe_parser, + table: 'cpe_' + self._cpe_parser, + }; + + $xhr('JSON', '/table/' + self.cpe.table + '?username='+self.username+';callback=JSON_CALLBACK', function( code, table ) { + self.cpe.rows = table.rows; + self.message = 'loaded cpe_'+self.cpe.parser+' rows'; + }); + self.message = 'loading cpe_'+self.cpe.parser+' rows...'; + + if ( h_cols = self.cpe_hash[self.cpe.parser] ) { + var cols = [ 'timestamp' ]; + for ( var i = 0; i < h_cols.length; i++ ) { + cols.push( 'h->\'' + h_cols[i] + '\' as "' + h_cols[i] + '"' ); + } +console.debug( cols ); + self.gnuplot.sql = 'select ' + cols.join(',') + ' from cpe_' + self.cpe.parser + ' where username = \'' + self.username + '\' order by timestamp desc limit 100'; + + console.info( 'gnuplot', self.gnuplot ); + self.message = 'generating ADSL graph for '+self.username; + self.gnuplot.img = '/gnuplot?hide=1;with=points;sql=' + self.gnuplot.sql; + } else { + self.message = 'no graph defined for ' + self.cpe.parser; + } + } ); + self.message = 'LDAP search for '+self.selected_username; }; } @@ -99,19 +144,28 @@ th, td { background: #eee; } +#message { + padding: 3px; + background: #ff8; + + margin-left: 1em; + position: fixed; +} +
+
-