redraw gnuplot only if SQL for it changes
authorDobrica Pavlinusic <dpavlin@rot13.org>
Tue, 12 Jul 2011 12:41:14 +0000 (14:41 +0200)
committerDobrica Pavlinusic <dpavlin@rot13.org>
Tue, 12 Jul 2011 12:44:25 +0000 (14:44 +0200)
public/user.html

index e8d3f1d..df9cc3c 100644 (file)
                        return;
                }
 
-               self.message.gnuplot = 'redrawing '+h_cols.join(' ');
-
                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';
-
-               $log.info( 'gnuplot', self.gnuplot );
-               self.gnuplot.img = '/gnuplot?hide=1;with=points;sql=' + self.gnuplot.sql;
-
+               $log.info( 'gnuplot', cols, self.gnuplot );
        };
+       self.$watch('gnuplot.sql', function() {
+               if ( ! self.gnuplot ) return;
+               self.message.gnuplot = self.gnuplot.cols.join(' ');
+               self.gnuplot.img = '/gnuplot?hide=1;with=points;sql=' + self.gnuplot.sql;
+       });
 
        self.r.table = $resource('/table/:table');
        self.table_update = function () {