display messages from each step
authorDobrica Pavlinusic <dpavlin@rot13.org>
Sun, 10 Jul 2011 22:40:06 +0000 (00:40 +0200)
committerDobrica Pavlinusic <dpavlin@rot13.org>
Sun, 10 Jul 2011 22:44:18 +0000 (00:44 +0200)
public/user.html

index 67a6eb5..92b3225 100644 (file)
                if ( ! username ) username = self.search_username;
                $log.info( 'CRM_search', username );
                self.clear();
                if ( ! username ) username = self.search_username;
                $log.info( 'CRM_search', username );
                self.clear();
+               self.message.CRM = 'search for '+username;
                self.r.CRM_search.query({username: username}, function(CRM) {
                        self.CRM = CRM;
                        $log.info( 'CRM', CRM )
                self.r.CRM_search.query({username: username}, function(CRM) {
                        self.CRM = CRM;
                        $log.info( 'CRM', CRM )
+                       if ( ! CRM.length ) {
+                               self.message.CRM = 'no results';
+                               return;
+                       }
+                       self.message.CRM = null;
                        if ( CRM.length == 1 ) {
                                self.selected_username = CRM[0].USERNAME;
                        if ( CRM.length == 1 ) {
                                self.selected_username = CRM[0].USERNAME;
-                               $log.info( 'auto-selected', self.selected_username );
+                               $log.info( 'auto-selected ', self.selected_username );
                        }
                });
        };
                        }
                });
        };
                if ( ! username ) username = self.selected_username;
 
                if ( ! username ) {
                if ( ! username ) username = self.selected_username;
 
                if ( ! username ) {
-                       $log.error( 'no username for LDAP_search' );
+                       self.message.LDAP = 'no username';
                        return;
                }
                $log.info( 'LDAP_search', username );
                self.clear_LDAP();
                self.selected_username = username;
                        return;
                }
                $log.info( 'LDAP_search', username );
                self.clear_LDAP();
                self.selected_username = username;
+               self.message.LDAP = 'search '+username;
                self.r.LDAP_search.query({ username: username }, function(LDAP) {
                        self.LDAP = LDAP;
                        $log.info( 'LDAP', LDAP );
                        if ( self.LDAP.length == 0 ) {
                self.r.LDAP_search.query({ username: username }, function(LDAP) {
                        self.LDAP = LDAP;
                        $log.info( 'LDAP', LDAP );
                        if ( self.LDAP.length == 0 ) {
-                               $log.error( 'no LDAP results for', username );
+                               self.message.LDAP ='no results for '+username;
                                return;
                        }
                        self.cpe.parser = LDAP[0]._cpe_parser;
                        self.cpe.table_name  = 'cpe_' + LDAP[0]._cpe_parser;
                        self.username = LDAP[0].cn;
                                return;
                        }
                        self.cpe.parser = LDAP[0]._cpe_parser;
                        self.cpe.table_name  = 'cpe_' + LDAP[0]._cpe_parser;
                        self.username = LDAP[0].cn;
+                       self.message.LDAP = null;
                        $log.info( 'cpe', self.cpe );
                });
        };
                        $log.info( 'cpe', self.cpe );
                });
        };
@@ -62,6 +70,9 @@
                        $log.warn("no columns for gnuplot");
                        return;
                }
                        $log.warn("no columns for gnuplot");
                        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] + '"' );
                var cols = [ 'timestamp' ];
                for ( var i = 0; i < h_cols.length; i++ ) {
                        cols.push( 'h->\'' + h_cols[i] + '\' as "' + h_cols[i] + '"' );
@@ -77,14 +88,16 @@ console.debug( cols );
        self.r.table = $resource('/table/:table');
        self.table_update = function () {
                if ( ! self.username || ! self.cpe.table_name ) return;
        self.r.table = $resource('/table/:table');
        self.table_update = function () {
                if ( ! self.username || ! self.cpe.table_name ) return;
+               self.message.table = self.username + ' loading from ' + self.cpe.table_name;
                self.r.table.get({ username: self.username, table: self.cpe.table_name, limit: self.cpe.limit }, function(table) {
                        $log.info( 'table', table );
                        self.cpe.table = table;
                self.r.table.get({ username: self.username, table: self.cpe.table_name, limit: self.cpe.limit }, function(table) {
                        $log.info( 'table', table );
                        self.cpe.table = table;
-
+                       self.message.table = table.rows.length == 0 ? 'no results' : null;
+                       
                        if ( h_cols = self.cpe_hash[self.cpe.parser] ) {
                                self.gnuplot_draw( h_cols );
                        } else {
                        if ( h_cols = self.cpe_hash[self.cpe.parser] ) {
                                self.gnuplot_draw( h_cols );
                        } else {
-                               self.message = 'no graph defined for ' + self.cpe.parser;
+                               self.message.gnuplot = 'no graph for ' + self.cpe.parser;
                        }
                });
        };
                        }
                });
        };
@@ -102,9 +115,10 @@ console.debug( cols );
                self.selected_username = null;
                self.gnuplot = {};
                self.cpe = { limit: 1 };
                self.selected_username = null;
                self.gnuplot = {};
                self.cpe = { limit: 1 };
-               self.message = null;
        };
 
        };
 
+       self.message = {};
+
        self.$watch('selected_username', function() {
                if ( self.selected_username == null ) self.clear_LDAP();
        });
        self.$watch('selected_username', function() {
                if ( self.selected_username == null ) self.clear_LDAP();
        });
@@ -226,7 +240,9 @@ th, td {
     <input type="submit" value="search in CRM">
     <input type="reset"  ng:click="clear()" value="clear">
 
     <input type="submit" value="search in CRM">
     <input type="reset"  ng:click="clear()" value="clear">
 
-    <span id="message" ng:show="message">{{message | html}}</span>
+    <span id="message" ng:show="message.$size()" ng:click="message={}" title="click to close">
+      <div ng:repeat="(category,status) in message" ng:show="status"><b>{{category}}</b> {{status}}</div>
+    </span>
 
    </form>
 
 
    </form>
 
@@ -267,7 +283,7 @@ th, td {
      <input type=button ng:click="gnuplot_draw(gnuplot.cols)" value="Redraw graph">
     </ul>
 
      <input type=button ng:click="gnuplot_draw(gnuplot.cols)" value="Redraw graph">
     </ul>
 
-    <ng:include src="gnuplot.img" ng:show="gnuplot.img" onload="message = 'done'" ></ng:include>
+    <ng:include src="gnuplot.img" ng:show="gnuplot.img" onload="message.gnuplot = null" ></ng:include>
 
     <h2 ng:show="cpe.table_name">{{cpe.table_name}} {{username}}</h2>
 
 
     <h2 ng:show="cpe.table_name">{{cpe.table_name}} {{username}}</h2>