X-Git-Url: http://git.rot13.org/?p=APKPM.git;a=blobdiff_plain;f=public%2Fuser.html;h=c5062ebfbba9981655610833d2908b2da0ae50a3;hp=46826be8503ed95d86089c1493b82fb9ba64b1c9;hb=a0b7e4f02b794cf665c8b66cd49af6dd54141fab;hpb=534fa8138fb554eef0ac07ca8816bf4819f3cb54 diff --git a/public/user.html b/public/user.html index 46826be..c5062eb 100644 --- a/public/user.html +++ b/public/user.html @@ -62,11 +62,10 @@ }; self.$watch('selected_username', self.LDAP_search ); - self.gnuplot_draw = function(h_cols) { - $log.info( 'gnuplot_draw', h_cols ); - if (h_cols.length) { - self.gnuplot.cols = h_cols; - } else { + self.gnuplot_changed = function() { + var h_cols = self.gnuplot.cols; + $log.info( 'gnuplot_changed', h_cols ); + if ( ! h_cols || h_cols.length < 1) { $log.warn("no columns for gnuplot"); return; } @@ -78,11 +77,19 @@ self.gnuplot.sql = 'select ' + cols.join(',') + ' from cpe_' + self.cpe.parser + ' where username = \'' + self.username + '\' order by timestamp desc limit 100'; $log.info( 'gnuplot', cols, self.gnuplot ); }; - self.$watch('gnuplot.sql', function() { - if ( ! self.gnuplot ) return; + self.gnuplot_refresh = function() { + if ( ! self.gnuplot || ! self.gnuplot.cols || ! self.gnuplot.sql) return; self.message.gnuplot = self.gnuplot.cols.join(' '); - self.gnuplot.img = '/gnuplot?hide=1;with=points;sql=' + self.gnuplot.sql; - }); + self.gnuplot.img = '/gnuplot?hide=1;with='+self.gnuplot.with+';sql=' + self.gnuplot.sql; + $log.info('gnuplot_refresh', self.gnuplot.img); + }; + self.$watch('gnuplot.sql', self.gnuplot_refresh ); + self.$watch('gnuplot.with', self.gnuplot_refresh ); + + self.gnuplot_onload = function() { + $log.info( 'gnuplot_onload' ); + self.message.gnuplot = 'ready'; + }; self.r.table = $resource('/table/:table'); self.table_update = function () { @@ -111,7 +118,8 @@ } if ( h_cols = self.cpe_hash[self.cpe.parser] ) { - self.gnuplot_draw( h_cols ); + self.gnuplot.cols = h_cols; + self.gnuplot_changed(); } else { self.message.gnuplot = 'no graph for ' + self.cpe.parser; } @@ -129,7 +137,7 @@ $log.info('clear_LDAP'); self.LDAP = null; self.selected_username = null; - self.gnuplot = {}; + self.gnuplot = { 'with': 'points', cols: [] }; self.cpe = {}; self.cpe_limit = 1; }; @@ -316,19 +324,23 @@ li > tt { Graph columns + - - + + +