Index: dashboard-tests.scm ================================================================== --- dashboard-tests.scm +++ dashboard-tests.scm @@ -118,10 +118,20 @@ (lambda (testdat)(conc (db:test-get-run_duration testdat)))) (store-label "CPULoad" (iup:label (conc (db:test-get-final_logf testdat)) #:expand "HORIZONTAL") (lambda (testdat)(conc (db:test-get-final_logf testdat))))))))) +;; use a global for setting the buttons colors +;; state status teststeps +(define *state-status* (vector #f #f #f)) +(define (update-state-status-buttons testdat) + (let* ((state (db:test-get-state testdat)) + (status (db:test-get-status testdat)) + (color (get-color-for-state-status state status))) + ((vector-ref *state-status* 0) state color) + ((vector-ref *state-status* 1) status color))) + ;;====================================================================== ;; Set fields ;;====================================================================== (define (set-fields-panel test-id testdat) (let ((newcomment #f) @@ -130,50 +140,55 @@ (iup:frame #:title "Set fields" (iup:vbox (iup:hbox (iup:label "Comment:") (iup:textbox #:action (lambda (val a b) + (db:test-set-state-status-by-id *db* test-id #f #f b) (set! newcomment b)) #:value (db:test-get-comment testdat) #:expand "YES")) - (iup:hbox - (iup:label "STATE:") - (let ((lb (iup:listbox #:action (lambda (val a b c) - (set! newstate a)) - #:dropdown "YES" - ))) - (iuplistbox-fill-list lb - (list "Set state" "COMPLETED" "NOT_STARTED" "RUNNING" "REMOTEHOSTSTART" "KILLED" "KILLREQ") - "Set state" ) - lb)) - (iup:hbox - (iup:label "STATUS:") - (let ((lb (iup:listbox #:action (lambda (val a b c) - (set! newstatus a)) - #:dropdown "YES" - ))) - (iuplistbox-fill-list lb - (list "Set status" "PASS" "WARN" "FAIL" "CHECK" "n/a") - "Set status" ) - lb)) - ;; The control buttons - (iup:vbox - (iup:button "Apply" - #:expand "YES" - #:action (lambda (x) - (db:test-set-state-status-by-id *db* test-id newstate newstatus newcomment) - )) - (iup:hbox - (iup:vbox - (iup:button "Apply and close" - #:action (lambda (x) - (db:test-set-state-status-by-id *db* test-id newstate newstatus newcomment) - (exit)))) - (iup:vbox - (iup:button "Cancel and close" - #:action (lambda (x) - (exit)))))))))) + (apply iup:hbox + (iup:label "STATE:" #:size "30x") + (let* ((btns (map (lambda (state) + (let ((btn (iup:button state + #:expand "YES" #:size "70x" + #:action (lambda (x) + (db:test-set-state-status-by-id *db* test-id state #f #f) + (db:test-set-state! testdat state))))) + btn)) + (list "COMPLETED" "NOT_STARTED" "RUNNING" "REMOTEHOSTSTART" "KILLED" "KILLREQ")))) + (vector-set! *state-status* 0 + (lambda (state color) + (for-each + (lambda (btn) + (let* ((name (iup:attribute btn "TITLE")) + (newcolor (if (equal? name state) color "192 192 192"))) + (if (not (colors-similar? newcolor (iup:attribute btn "BGCOLOR"))) + (iup:attribute-set! btn "BGCOLOR" newcolor)))) + btns))) + btns)) + (apply iup:hbox + (iup:label "STATUS:" #:size "30x") + (let* ((btns (map (lambda (status) + (let ((btn (iup:button status + #:expand "YES" #:size "70x" + #:action (lambda (x) + (db:test-set-state-status-by-id *db* test-id #f status #f) + (db:test-set-status! testdat status))))) + btn)) + (list "PASS" "WARN" "FAIL" "CHECK" "n/a" "WAIVED")))) + (vector-set! *state-status* 1 + (lambda (status color) + (for-each + (lambda (btn) + (let* ((name (iup:attribute btn "TITLE")) + (newcolor (if (equal? name status) color "192 192 192"))) + (if (not (colors-similar? newcolor (iup:attribute btn "BGCOLOR"))) + (iup:attribute-set! btn "BGCOLOR" newcolor)))) + btns))) + btns)))))) + ;;====================================================================== ;; ;;====================================================================== (define (examine-test db test-id mx1) ;; run-id run-key origtest) @@ -182,11 +197,11 @@ (keydat (if testdat (keys:get-key-val-pairs db run-id) #f)) (rundat (if testdat (db:get-run-info db run-id) #f)) (runname (if testdat (db:get-value-by-header (db:get-row rundat) (db:get-header rundat) "runname") #f)) - (teststeps (if testdat (db:get-steps-for-test db test-id) #f)) + ;(teststeps (if testdat (db:get-steps-for-test db test-id) #f)) (logfile "/this/dir/better/not/exist") (rundir logfile) (testfullname (if testdat (db:test-get-fullname testdat) "Gathering data ...")) (viewlog (lambda (x) (if (file-exists? logfile) @@ -210,11 +225,11 @@ (set! logfile (conc (db:test-get-rundir testdat) "/" (db:test-get-final_logf testdat))) (set! rundir (db:test-get-rundir testdat)) (set! testfullname (db:test-get-fullname testdat)) (mutex-unlock! mx1)) (begin - (db:test-set-testname testdat "DEAD OR DELETED TEST")))))) + (db:test-set-testname! testdat "DEAD OR DELETED TEST")))))) (widgets (make-hash-table)) (self #f) (store-label (lambda (name lbl cmd) (hash-table-set! widgets name (lambda (testdat) @@ -240,17 +255,44 @@ (iup:hbox ; #:expand "YES" (run-info-panel keydat testdat runname) (test-info-panel testdat store-label widgets)) (host-info-panel testdat store-label) ;; The controls - (iup:frame #:title "Actions" - (iup:hbox - (iup:vbox - (iup:button "View Log" #:action viewlog #:expand "HORIZONTAL")) - (iup:vbox - (iup:button "Start Xterm" #:action xterm #:expand "YES")))) - (set-fields-panel test-id testdat)))) + (iup:frame #:title "Actions" + (iup:hbox + (iup:button "View Log" #:action viewlog #:size "120x") + (iup:button "Start Xterm" #:action xterm #:size "120x") + (iup:button "Close" #:action (lambda (x)(exit)) #:size "120x"))) + (set-fields-panel test-id testdat) + (iup:frame + #:title "Test Steps" + (let ((stepsdat (iup:label "Test steps ........................................." + #:expand "YES" + #:size "200x150" + #:alignment "ALEFT:ATOP"))) + (hash-table-set! widgets "Test Steps" (lambda (testdat) + (let* ((currval (iup:attribute stepsdat "TITLE")) + (fmtstr "~15a~8a~8a~20a") + (newval (string-intersperse + (append + (list + (format #f fmtstr "Stepname" "State" "Status" "Event Time") + (format #f fmtstr "========" "=====" "======" "==========")) + (map (lambda (x) + ;; take advantage of the \n on time->string + (format #f fmtstr + (db:step-get-stepname x) + (db:step-get-state x) + (db:step-get-status x) + (time->string + (seconds->local-time + (db:step-get-event_time x))))) + (db:get-steps-for-test db test-id))) + "\n"))) + (if (not (equal? currval newval)) + (iup:attribute-set! stepsdat "TITLE" newval))))) + stepsdat))))) (iup:show self) ;; Now start keeping the gui updated from the db (let loop ((i 0)) (thread-sleep! 0.1) (refreshdat) ;; update from the db here @@ -259,11 +301,11 @@ (for-each (lambda (key) ;; (print "Updating " key) ((hash-table-ref widgets key) testdat)) (hash-table-keys widgets)) - ;(thread-resume! other-thread) + (update-state-status-buttons testdat) ; (iup:refresh self) (iup:main-loop-flush) (if *exit-started* (set! *exit-started* 'ok) (loop i))))))) Index: dashboard.scm ================================================================== --- dashboard.scm +++ dashboard.scm @@ -158,20 +158,22 @@ (define (get-color-for-state-status state status) (case (string->symbol state) ((COMPLETED) (if (equal? status "PASS") "70 249 73" - (if (equal? status "WARN") + (if (or (equal? status "WARN") + (equal? status "WAIVED")) "255 172 13" "223 33 49"))) ;; greenish orangeish redish ((LAUNCHED) "101 123 142") ((CHECK) "255 100 50") ((REMOTEHOSTSTART) "50 130 195") ((RUNNING) "9 131 232") ((KILLREQ) "39 82 206") ((KILLED) "234 101 17") - (else "192 192 192"))) + ((NOT_STARTED) "240 240 240") + (else "192 192 192"))) (define (update-buttons uidat numruns numtests) (let* ((runs (if (> (length *allruns*) numruns) (take-right *allruns* numruns) (pad-list *allruns* numruns))) @@ -313,11 +315,15 @@ (update-search "item-name" val))) (iup:button "Quit" #:action (lambda (obj)(sqlite3:finalize! *db*)(exit))) (iup:button "<- Left" #:action (lambda (obj)(set! *start-run-offset* (+ *start-run-offset* 1)))) (iup:button "Up ^" #:action (lambda (obj)(set! *start-test-offset* (if (> *start-test-offset* 0)(- *start-test-offset* 1) 0)))) (iup:button "Down v" #:action (lambda (obj)(set! *start-test-offset* (if (>= *start-test-offset* (length *alltestnamelst*))(length *alltestnamelst*)(+ *start-test-offset* 1))))) - (iup:button "Right ->" #:action (lambda (obj)(set! *start-run-offset* (if (> *start-run-offset* 0)(- *start-run-offset* 1) 0)))))) + (iup:button "Right ->" #:action (lambda (obj)(set! *start-run-offset* (if (> *start-run-offset* 0)(- *start-run-offset* 1) 0)))) + ;(iup:button "inc rows" #:action (lambda (obj)(set! *num-tests* (+ *num-tests* 1)))) + ;(iup:button "dec rows" #:action (lambda (obj)(set! *num-tests* (if (> *num-tests* 0)(- *num-tests* 1) 0)))) + ) + ) ;; create the left most column for the run key names and the test names (set! lftlst (list (apply iup:vbox (map (lambda (x) (let ((res (iup:hbox @@ -436,21 +442,10 @@ (exit 1))))) ((args:get-arg "-test") (let ((testid (string->number (args:get-arg "-test")))) (if testid (set! *job* (lambda (mx1) - ; (on-exit (lambda () - ; ; ;;(iup:main-loop-flush) - ; (set! *exit-started* #t) - ; (let loop ((i 0)) - ; (if (and (< i 100) - ; (not (eq? *exit-started* 'ok))) - ; (begin - ; (thread-sleep! 0.1) - ; (loop (+ i 1))))) - ; (sqlite3:finalize! *db*) - ; (exit))) (examine-test *db* testid mx1))) (begin (print "ERROR: testid is not a number " (args:get-arg "-test")) (exit 1))))) (else Index: db.scm ================================================================== --- db.scm +++ db.scm @@ -194,11 +194,13 @@ (define-inline (db:test-get-final_logf vec) (vector-ref vec 13)) (define-inline (db:test-get-comment vec) (vector-ref vec 14)) (define-inline (db:test-get-fullname vec) (conc (db:test-get-testname vec) "/" (db:test-get-item-path vec))) -(define-inline (db:test-set-testname vec val)(vector-set! vec 2 val)) +(define-inline (db:test-set-testname! vec val)(vector-set! vec 2 val)) +(define-inline (db:test-set-state! vec val)(vector-set! vec 3 val)) +(define-inline (db:test-set-status! vec val)(vector-set! vec 4 val)) (define (db-get-tests-for-run db run-id . params) (let ((res '()) (testpatt (if (or (null? params)(not (car params))) "%" (car params))) (itempatt (if (> (length params) 1)(cadr params) "%")))