X-Git-Url: http://git.rot13.org/?a=blobdiff_plain;f=templates%2Fuser.html.ep;h=1aa71cf8e3627652574d730514645bc35978a69d;hb=92c0a1384510c822396225cc8b0a523e23df07f2;hp=ec3364baba681157bbee8f0d98634abdd3319791;hpb=d6ebd339f06c55ac41f185bb793dddb8677aee4c;p=APKPM.git diff --git a/templates/user.html.ep b/templates/user.html.ep index ec3364b..1aa71cf 100644 --- a/templates/user.html.ep +++ b/templates/user.html.ep @@ -5,18 +5,28 @@ 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 '+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 = {}; + self.ldap = null; + self.message = null; }; this.columns = [ @@ -29,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 = []; @@ -40,28 +56,108 @@ }; this.select = function(crm) { - console.log( crm ); + console.log( 'crm = ',crm ); self.selected_username = crm.USERNAME; - }; + 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; + var parser = response[0]._cpe_parser; + console.info( 'parser', parser ); + if ( h_cols = self.cpe_hash[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_' + parser + ' where username = \'' + response[0].cn + '\' order by timestamp desc limit 100'; - this.selected_username = ''; + self.gnuplot.img = '/gnuplot?hide=1;with=points;sql=' + self.gnuplot.sql; + console.info( 'gnuplot', self.gnuplot ); + self.message = 'generating ADSL graph for '+response[0].cn + ' '; + } else { + self.message = 'no graph defined for ' + parser; + } + } + ); + self.message = 'LDAP search for '+self.selected_username; + }; } CRM.$inject = ['$xhr']; + + +
+ +
- - - loading {{url}} - {{response.length}} results + + + + {{message | html}} + +
-
-Add columns: +
+Add columns
  • {{c}}
@@ -71,18 +167,34 @@ Add columns: {{c}} - + {{u[c]}} +
+ + {{selected_username}} + +
    +

    LDAP entry

    +
  • {{c}} {{ldap[0][c]}}
  • +
+ +

{{gnuplot.title}}

+ +
{{gnuplot.sql}}
+ +
+
+gnuplot={{gnuplot}}
+message={{message}}
 url={{url}}
 code={{code}}
 response={{response}}
-username={{username}}