Megatest

Check-in [4809ab9726]
Login
Overview
Comment:Refactored dashboard code to make plugging in a new vector graphics view easier
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | v1.61
Files: files | file ages | folders
SHA1: 4809ab972671a2534320c912ab172c1f7c8e8c34
User & Date: mrwellan on 2016-06-29 18:10:12
Other Links: branch diff | manifest | tags
Context
2016-06-30
04:50
Added rerun to rhb menu check-in: 61dfefd369 user: matt tags: v1.61
2016-06-29
18:10
Refactored dashboard code to make plugging in a new vector graphics view easier check-in: 4809ab9726 user: mrwellan tags: v1.61
2016-06-28
16:46
Merged in changes made by Ritika for a right mouse menu for buttons. Not complete but xterm launching works check-in: ce0b996d14 user: mrwellan tags: v1.61
Changes

Modified dashboard.scm from [f1d9d3d3f8] to [357056d7b4].

875
876
877
878
879
880
881

882
883
884
885
886
887
888

;;======================================================================
;; R U N   C O N T R O L S
;;======================================================================
;;
;; A gui for launching tests
;;

(define (dashboard:run-controls)
  (let* ((targets       (make-hash-table))
	 (test-records  (make-hash-table))
	 (all-tests-registry (tests:get-all)) ;; (tests:get-valid-tests *toppath* '()))
	 (test-names    (hash-table-keys all-tests-registry))
	 (sorted-testnames #f)
	 (action        "-run")







>







875
876
877
878
879
880
881
882
883
884
885
886
887
888
889

;;======================================================================
;; R U N   C O N T R O L S
;;======================================================================
;;
;; A gui for launching tests
;;

(define (dashboard:run-controls)
  (let* ((targets       (make-hash-table))
	 (test-records  (make-hash-table))
	 (all-tests-registry (tests:get-all)) ;; (tests:get-valid-tests *toppath* '()))
	 (test-names    (hash-table-keys all-tests-registry))
	 (sorted-testnames #f)
	 (action        "-run")
906
907
908
909
910
911
912























































913
914
915
916
917
918
919
920


























921


















922




923
924
925
926
























927













928




929









930






931
932
933
934








935



















































































936






































937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
    (hash-table-set! tests-draw-state 'first-time #t)
    ;; (hash-table-set! tests-draw-state 'scalef 1)
    (tests:get-full-data test-names test-records '() all-tests-registry)
    (set! sorted-testnames (tests:sort-by-priority-and-waiton test-records))
    
    ;; refer to (d:alldat-keys *alldat*), (d:alldat-dbkeys *alldat*) for keys
    (iup:vbox























































     ;; The command line display/exectution control
     (iup:frame
      #:title "Command to be exectuted"
      (iup:hbox
       (iup:label "Run on" #:size "40x")
       (iup:radio 
	(iup:hbox
	 (iup:toggle "Local" #:size "40x")


























	 (iup:toggle "Server" #:size "40x")))


















       (let ((tb (iup:textbox 




		  #:value "megatest "
		  #:expand "HORIZONTAL"
		  #:readonly "YES"
		  #:font "Courier New, -12"
























		  )))













	 (dboard:data-set-command-tb! *data* tb)




	 tb)









       (iup:button "Execute" #:size "50x"






		   #:action (lambda (obj)
			      (let ((cmd (conc "xterm -geometry 180x20 -e \""
					       (iup:attribute (dboard:data-get-command-tb *data*) "VALUE")
					       ";echo Press any key to continue;bash -c 'read -n 1 -s'\" &")))








				(system cmd))))))


























































































































     (iup:split
      #:orientation "HORIZONTAL"
      
      (iup:split
       #:value 300

       ;; Target, testpatt, state and status input boxes
       ;;
       (iup:vbox
	;; Command to run
	(iup:frame
	 #:title "Set the action to take"
	 (iup:hbox
	  ;; (iup:label "Command to run" #:expand "HORIZONTAL" #:size "70x" #:alignment "LEFT:ACENTER")
	  (let* ((cmds-list '("run" "remove-runs" "set-state-status" "lock-runs" "unlock-runs"))
		 (lb         (iup:listbox #:expand "HORIZONTAL"
					  #:dropdown "YES"
					  #:action (lambda (obj val index lbstate)
						     ;; (print obj " " val " " index " " lbstate)
						     (dboard:data-set-command! *data* val)
						     (dashboard:update-run-command))))
		 (default-cmd (car cmds-list)))
	    (iuplistbox-fill-list lb cmds-list selected-item: default-cmd)
	    (dboard:data-set-command! *data* default-cmd)
	    lb)))

	(iup:frame
	 #:title "Runname"
	 (let* ((default-run-name (seconds->work-week/day (current-seconds)))
		(tb (iup:textbox #:expand "HORIZONTAL"
				 #:action (lambda (obj val txt)
					    ;; (print "obj: " obj " val: " val " unk: " unk)
					    (dboard:data-set-run-name! *data* txt) ;; (iup:attribute obj "VALUE"))
					    (dashboard:update-run-command))
				 #:value (or default-run-name (dboard:data-get-run-name *data*))))
		(lb (iup:listbox #:expand "HORIZONTAL"
				 #:dropdown "YES"
				 #:action (lambda (obj val index lbstate)
					    (if (not (equal? val ""))
						(begin
						  (iup:attribute-set! tb "VALUE" val)
						  (dboard:data-set-run-name! *data* val)
						  (dashboard:update-run-command))))))
		(refresh-runs-list (lambda ()
				     (let* ((target        (dboard:data-get-target-string *data*))
					    (runs-for-targ (if (d:alldat-useserver *alldat*)
							       (rmt:get-runs-by-patt (d:alldat-keys *alldat*) "%" target #f #f #f)
							       (db:get-runs-by-patt (d:alldat-dblocal *alldat*) (d:alldat-keys *alldat*) "%" target #f #f #f)))
					    (runs-header   (vector-ref runs-for-targ 0))
					    (runs-dat      (vector-ref runs-for-targ 1))
					    (run-names     (cons default-run-name 
								 (map (lambda (x)
									(db:get-value-by-header x runs-header "runname"))
								      runs-dat))))
				       ;; (iup:attribute-set! lb "REMOVEITEM" "ALL")
				       (iuplistbox-fill-list lb run-names selected-item: default-run-name)))))
	   (set! updater-for-runs refresh-runs-list)
	   (refresh-runs-list)
	   (dboard:data-set-run-name! *data* default-run-name)
	   (iup:hbox
	    tb
	    lb)))

	(iup:frame
	 #:title "SELECTORS"
	 (iup:vbox
	  ;; Text box for test patterns
	  (iup:frame
	   #:title "Test patterns (one per line)"
	   (let ((tb (iup:textbox #:action (lambda (val a b)
					     (dboard:data-set-test-patts!
					      *data*
					      (dboard:lines->test-patt b))
					     (dashboard:update-run-command))
				  #:value (dboard:test-patt->lines
					   (dboard:data-get-test-patts *data*))
				  #:expand "YES"
				  #:size "x50"
				  #:multiline "YES")))
	     (set! test-patterns-textbox tb)
	     tb))
	  (iup:frame
	   #:title "Target"
	   ;; Target selectors
	   (apply iup:hbox
		  (let* ((dat      (dashboard:update-target-selector key-listboxes action-proc: update-keyvals))
			 (key-lb   (car dat))
			 (combos   (cadr dat)))
		    (set! key-listboxes key-lb)
		    combos)))
	  (iup:hbox
	   ;; Text box for STATES
	   (iup:frame
	    #:title "States"
	    (dashboard:text-list-toggle-box 
	     ;; Move these definitions to common and find the other useages and replace!
	     (map cadr *common:std-states*) ;; '("COMPLETED" "RUNNING" "STUCK" "INCOMPLETE" "LAUNCHED" "REMOTEHOSTSTART" "KILLED")
	     (lambda (all)
	       (dboard:data-set-states! *data* all)
	       (dashboard:update-run-command))))
	   ;; Text box for STATES
	   (iup:frame
	    #:title "Statuses"
	    (dashboard:text-list-toggle-box 
	     (map cadr *common:std-statuses*) ;; '("PASS" "FAIL" "n/a" "CHECK" "WAIVED" "SKIP" "DELETED" "STUCK/DEAD")
	     (lambda (all)
	       (dboard:data-set-statuses! *data* all)
	       (dashboard:update-run-command))))))))
       
       (iup:frame
	#:title "Tests and Tasks"
	(let* ((updater #f)
	       (last-xadj 0)
	       (last-yadj 0)
	       (the-cnv   #f)
	       (canvas-obj 
                (iup:canvas #:action (make-canvas-action
				      (lambda (cnv xadj yadj)
					(if (not updater)
					    (set! updater (lambda (xadj yadj)
							    ;; (print "cnv: " cnv " xadj: " xadj " yadj: " yadj)
							    (dashboard:draw-tests cnv xadj yadj tests-draw-state sorted-testnames test-records)
							    (set! last-xadj xadj)
							    (set! last-yadj yadj))))
					(updater xadj yadj)
					(set! the-cnv cnv)
					))
			    ;; Following doesn't work 
			    #:wheel-cb (lambda (obj step x y dir) ;; dir is 4 for up and 5 for down. I think.
					 (let ((scalef (hash-table-ref tests-draw-state 'scalef)))
					   (hash-table-set! tests-draw-state 'scalef (+ scalef
											(if (> step 0)
											    (* scalef 0.01)
											    (* scalef -0.01))))
					   (if the-cnv
					       (dashboard:draw-tests the-cnv last-xadj last-yadj tests-draw-state sorted-testnames test-records))
					   ))
			    ;; #:size "50x50"
			    #:expand "YES"
			    #:scrollbar "YES"
			    #:posx "0.5"
			    #:posy "0.5"
			    #:button-cb (lambda (obj btn pressed x y status)
					  ;; (print "obj: " obj ", pressed " pressed ", status " status)
					; (print "canvas-origin: " (canvas-origin the-cnv))
					  ;; (let-values (((xx yy)(canvas-origin the-cnv)))
					  ;; (canvas-transform-set! the-cnv #f)
					  ;; (print "canvas-origin: " xx " " yy " click at " x " " y))
					  (let* ((tests-info     (hash-table-ref tests-draw-state 'tests-info))
						 (selected-tests (hash-table-ref tests-draw-state 'selected-tests))
						 (scalef         (hash-table-ref tests-draw-state 'scalef))
						 (sizey          (hash-table-ref tests-draw-state 'sizey))
						 (xoffset        (dcommon:get-xoffset tests-draw-state #f #f))
						 (yoffset        (dcommon:get-yoffset tests-draw-state #f #f))
						 (new-y          (- sizey y)))
					    ;; (print "xoffset=" xoffset ", yoffset=" yoffset)
					    ;; (print "\tx\ty\tllx\tlly\turx\tury")
					    (for-each (lambda (test-name)
							(let* ((rec-coords (hash-table-ref tests-info test-name))
							       (llx        (dcommon:x->canvas (list-ref rec-coords 0) scalef xoffset))
							       (lly        (dcommon:y->canvas (list-ref rec-coords 1) scalef yoffset))
							       (urx        (dcommon:x->canvas (list-ref rec-coords 2) scalef xoffset))
							       (ury        (dcommon:y->canvas (list-ref rec-coords 3) scalef yoffset)))
							  ;; (if (eq? pressed 1)
							  ;;    (print "\tx=" x "\ty=" y "\tnew-y=" new-y "\tllx=" llx "\tlly=" lly "\turx=" urx "\tury=" ury "\t" test-name " "))
							  (if (and (eq? pressed 1)
								   (>= x llx)
								   (>= new-y lly)
								   (<= x urx)
								   (<= new-y ury))
							      (let ((patterns (string-split (iup:attribute test-patterns-textbox "VALUE"))))
								(let* ((selected     (not (member test-name patterns)))
								       (newpatt-list (if selected
											 (cons test-name patterns)
											 (delete test-name patterns)))
								       (newpatt      (string-intersperse newpatt-list "\n")))
								  (iup:attribute-set! obj "REDRAW" "ALL")
								  (hash-table-set! selected-tests test-name selected)
								  (iup:attribute-set! test-patterns-textbox "VALUE" newpatt)
								  (dboard:data-set-test-patts! *data* (dboard:lines->test-patt newpatt))
								  (dashboard:update-run-command)
								  (if updater (updater last-xadj last-yadj)))))))
						      (hash-table-keys tests-info)))))))
	  canvas-obj)))
      
      (iup:frame
       #:title "Logs" ;; To be replaced with tabs
       (let ((logs-tb (iup:textbox #:expand "YES"
				   #:multiline "YES")))
	 (dboard:data-set-logs-textbox! *data* logs-tb)
	 logs-tb))))))


;; (trace dashboard:populate-target-dropdown
;;        common:list-is-sublist)
;; 
;;       ;; key1 key2 key3 ...
;;       ;; target entry (wild cards allowed)
;;       
;;       ;; The action
;;       (iup:hbox
;;        ;; label Action | action selector
;;        ))
;;      ;; Test/items selector
;;      (iup:hbox
;;       ;; tests
;;       ;; items
;;       ))
;;     ;; The command line
;;     (iup:hbox
;;      ;; commandline entry
;;      ;; GO button
;;      )
;;     ;; The command log monitor
;;     (iup:tabs
;;      ;; log monitor
;;      )))

;;======================================================================
;; S U M M A R Y 
;;======================================================================
;;
;; General info about the run(s) and megatest area
(define (dashboard:summary data)
  (let* ((db               (d:alldat-dblocal data))







>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
|
|
|
|
|
|
|
|
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
|
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
|
>
>
>
>
|
|
|
<
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
|
>
>
>
>
>
>
>
>
>
>
>
>
>
|
>
>
>
>
|
>
>
>
>
>
>
>
>
>
|
>
>
>
>
>
>
|
<
|
<
>
>
>
>
>
>
>
>
|
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>

>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>









|
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
|
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
|
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
|
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<

<
<
<
<
<
<
|
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
|







<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<







907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029

1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090

1091

1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232















1233




































1234

























1235



















1236






1237




































































1238
1239
1240
1241
1242
1243
1244
1245


























1246
1247
1248
1249
1250
1251
1252
    (hash-table-set! tests-draw-state 'first-time #t)
    ;; (hash-table-set! tests-draw-state 'scalef 1)
    (tests:get-full-data test-names test-records '() all-tests-registry)
    (set! sorted-testnames (tests:sort-by-priority-and-waiton test-records))
    
    ;; refer to (d:alldat-keys *alldat*), (d:alldat-dbkeys *alldat*) for keys
    (iup:vbox
     (dcommon:command-execution-control *data*)
     (iup:split
      #:orientation "HORIZONTAL"
      
      (iup:split
       #:value 300

       ;; Target, testpatt, state and status input boxes
       ;;
       (iup:vbox
	;; Command to run, placed over the top of the canvas
	(dcommon:command-action-selector *data*)
	(dcommon:command-runname-selector *alldat* *data*)
	(dcommon:command-testname-selector *alldat* *data* update-keyvals key-listboxes))
       
       (dcommon:command-tests-tasks-canvas *data* test-records sorted-testnames tests-draw-state))
       
      (iup:frame
       #:title "Logs" ;; To be replaced with tabs
       (let ((logs-tb (iup:textbox #:expand "YES"
				   #:multiline "YES")))
	 (dboard:data-set-logs-textbox! *data* logs-tb)
	 logs-tb))))))
;; 
;; (define (dashboard:run-controls)
;;   (let* ((targets       (make-hash-table))
;; 	 (test-records  (make-hash-table))
;; 	 (all-tests-registry (tests:get-all)) ;; (tests:get-valid-tests *toppath* '()))
;; 	 (test-names    (hash-table-keys all-tests-registry))
;; 	 (sorted-testnames #f)
;; 	 (action        "-run")
;; 	 (cmdln         "")
;; 	 (runlogs       (make-hash-table))
;; 	 (key-listboxes #f)
;; 	 (updater-for-runs #f)
;; 	 (update-keyvals (lambda ()
;; 			   (let ((targ (map (lambda (x)
;; 					      (iup:attribute x "VALUE"))
;; 					    (car (dashboard:update-target-selector key-listboxes))))
;; 				 (curr-runname (dboard:data-get-run-name *data*)))
;; 			     (dboard:data-set-target! *data* targ)
;; 			     (if updater-for-runs (updater-for-runs))
;; 			     (if (or (not (equal? curr-runname (dboard:data-get-run-name *data*)))
;; 				     (equal? (dboard:data-get-run-name *data*) ""))
;; 				 (dboard:data-set-run-name! *data* curr-runname))
;; 			     (dashboard:update-run-command))))
;; 	 (tests-draw-state (make-hash-table)) ;; use for keeping state of the test canvas
;; 	 (test-patterns-textbox  #f))
;;     (hash-table-set! tests-draw-state 'first-time #t)
;;     ;; (hash-table-set! tests-draw-state 'scalef 1)
;;     (tests:get-full-data test-names test-records '() all-tests-registry)
;;     (set! sorted-testnames (tests:sort-by-priority-and-waiton test-records))
;;     
;;     ;; refer to (d:alldat-keys *alldat*), (d:alldat-dbkeys *alldat*) for keys
;;     (iup:vbox
;;      ;; The command line display/exectution control
;;      (iup:frame
;;       #:title "Command to be exectuted"
;;       (iup:hbox
;;        (iup:label "Run on" #:size "40x")
;;        (iup:radio 
;; 	(iup:hbox
;; 	 (iup:toggle "Local" #:size "40x")
;; 	 (iup:toggle "Server" #:size "40x")))
;;        (let ((tb (iup:textbox 
;; 		  #:value "megatest "
;; 		  #:expand "HORIZONTAL"
;; 		  #:readonly "YES"
;; 		  #:font "Courier New, -12"
;; 		  )))
;; 	 (dboard:data-set-command-tb! *data* tb)
;; 	 tb)
;;        (iup:button "Execute" #:size "50x"
;; 		   #:action (lambda (obj)
;; 			      (let ((cmd (conc "xterm -geometry 180x20 -e \""
;; 					       (iup:attribute (dboard:data-get-command-tb *data*) "VALUE")
;; 					       ";echo Press any key to continue;bash -c 'read -n 1 -s'\" &")))
;; 				(system cmd))))))
;; 
;;      (iup:split
;;       #:orientation "HORIZONTAL"
;;       
;;       (iup:split
;;        #:value 300
;; 
;;        ;; Target, testpatt, state and status input boxes
;;        ;;
;;        (iup:vbox
;; 	;; Command to run
;; 	(iup:frame
;; 	 #:title "Set the action to take"
;; 	 (iup:hbox
;; 	  ;; (iup:label "Command to run" #:expand "HORIZONTAL" #:size "70x" #:alignment "LEFT:ACENTER")
;; 	  (let* ((cmds-list '("run" "remove-runs" "set-state-status" "lock-runs" "unlock-runs"))
;; 		 (lb         (iup:listbox #:expand "HORIZONTAL"
;; 					  #:dropdown "YES"
;; 					  #:action (lambda (obj val index lbstate)
;; 						     ;; (print obj " " val " " index " " lbstate)
;; 						     (dboard:data-set-command! *data* val)
;; 						     (dashboard:update-run-command))))
;; 		 (default-cmd (car cmds-list)))
;; 	    (iuplistbox-fill-list lb cmds-list selected-item: default-cmd)
;; 	    (dboard:data-set-command! *data* default-cmd)
;; 	    lb)))
;; 
;; 	(iup:frame
;; 	 #:title "Runname"
;; 	 (let* ((default-run-name (seconds->work-week/day (current-seconds)))
;; 		(tb (iup:textbox #:expand "HORIZONTAL"
;; 				 #:action (lambda (obj val txt)
;; 					    ;; (print "obj: " obj " val: " val " unk: " unk)
;; 					    (dboard:data-set-run-name! *data* txt) ;; (iup:attribute obj "VALUE"))
;; 					    (dashboard:update-run-command))
;; 				 #:value (or default-run-name (dboard:data-get-run-name *data*))))
;; 		(lb (iup:listbox #:expand "HORIZONTAL"
;; 				 #:dropdown "YES"

;; 				 #:action (lambda (obj val index lbstate)
;; 					    (if (not (equal? val ""))
;; 						(begin
;; 						  (iup:attribute-set! tb "VALUE" val)
;; 						  (dboard:data-set-run-name! *data* val)
;; 						  (dashboard:update-run-command))))))
;; 		(refresh-runs-list (lambda ()
;; 				     (let* ((target        (dboard:data-get-target-string *data*))
;; 					    (runs-for-targ (if (d:alldat-useserver *alldat*)
;; 							       (rmt:get-runs-by-patt (d:alldat-keys *alldat*) "%" target #f #f #f)
;; 							       (db:get-runs-by-patt (d:alldat-dblocal *alldat*) (d:alldat-keys *alldat*) "%" target #f #f #f)))
;; 					    (runs-header   (vector-ref runs-for-targ 0))
;; 					    (runs-dat      (vector-ref runs-for-targ 1))
;; 					    (run-names     (cons default-run-name 
;; 								 (map (lambda (x)
;; 									(db:get-value-by-header x runs-header "runname"))
;; 								      runs-dat))))
;; 				       ;; (iup:attribute-set! lb "REMOVEITEM" "ALL")
;; 				       (iuplistbox-fill-list lb run-names selected-item: default-run-name)))))
;; 	   (set! updater-for-runs refresh-runs-list)
;; 	   (refresh-runs-list)
;; 	   (dboard:data-set-run-name! *data* default-run-name)
;; 	   (iup:hbox
;; 	    tb
;; 	    lb)))
;; 
;; 	(iup:frame
;; 	 #:title "SELECTORS"
;; 	 (iup:vbox
;; 	  ;; Text box for test patterns
;; 	  (iup:frame
;; 	   #:title "Test patterns (one per line)"
;; 	   (let ((tb (iup:textbox #:action (lambda (val a b)
;; 					     (dboard:data-set-test-patts!
;; 					      *data*
;; 					      (dboard:lines->test-patt b))
;; 					     (dashboard:update-run-command))
;; 				  #:value (dboard:test-patt->lines
;; 					   (dboard:data-get-test-patts *data*))
;; 				  #:expand "YES"
;; 				  #:size "x50"
;; 				  #:multiline "YES")))
;; 	     (set! test-patterns-textbox tb)
;; 	     tb))
;; 	  (iup:frame
;; 	   #:title "Target"
;; 	   ;; Target selectors
;; 	   (apply iup:hbox
;; 		  (let* ((dat      (dashboard:update-target-selector key-listboxes action-proc: update-keyvals))
;; 			 (key-lb   (car dat))
;; 			 (combos   (cadr dat)))
;; 		    (set! key-listboxes key-lb)
;; 		    combos)))
;; 	  (iup:hbox
;; 	   ;; Text box for STATES
;; 	   (iup:frame
;; 	    #:title "States"
;; 	    (dashboard:text-list-toggle-box 
;; 	     ;; Move these definitions to common and find the other useages and replace!
;; 	     (map cadr *common:std-states*) ;; '("COMPLETED" "RUNNING" "STUCK" "INCOMPLETE" "LAUNCHED" "REMOTEHOSTSTART" "KILLED")
;; 	     (lambda (all)

;; 	       (dboard:data-set-states! *data* all)

;; 	       (dashboard:update-run-command))))
;; 	   ;; Text box for STATES
;; 	   (iup:frame
;; 	    #:title "Statuses"
;; 	    (dashboard:text-list-toggle-box 
;; 	     (map cadr *common:std-statuses*) ;; '("PASS" "FAIL" "n/a" "CHECK" "WAIVED" "SKIP" "DELETED" "STUCK/DEAD")
;; 	     (lambda (all)
;; 	       (dboard:data-set-statuses! *data* all)
;; 	       (dashboard:update-run-command))))))))
;;        
;;        (iup:frame
;; 	#:title "Tests and Tasks"
;; 	(let* ((updater #f)
;; 	       (last-xadj 0)
;; 	       (last-yadj 0)
;; 	       (the-cnv   #f)
;; 	       (canvas-obj 
;;                 (iup:canvas #:action (make-canvas-action
;; 				      (lambda (cnv xadj yadj)
;; 					(if (not updater)
;; 					    (set! updater (lambda (xadj yadj)
;; 							    ;; (print "cnv: " cnv " xadj: " xadj " yadj: " yadj)
;; 							    (dashboard:draw-tests cnv xadj yadj tests-draw-state sorted-testnames test-records)
;; 							    (set! last-xadj xadj)
;; 							    (set! last-yadj yadj))))
;; 					(updater xadj yadj)
;; 					(set! the-cnv cnv)
;; 					))
;; 			    ;; Following doesn't work 
;; 			    #:wheel-cb (lambda (obj step x y dir) ;; dir is 4 for up and 5 for down. I think.
;; 					 (let ((scalef (hash-table-ref tests-draw-state 'scalef)))
;; 					   (hash-table-set! tests-draw-state 'scalef (+ scalef
;; 											(if (> step 0)
;; 											    (* scalef 0.01)
;; 											    (* scalef -0.01))))
;; 					   (if the-cnv
;; 					       (dashboard:draw-tests the-cnv last-xadj last-yadj tests-draw-state sorted-testnames test-records))
;; 					   ))
;; 			    ;; #:size "50x50"
;; 			    #:expand "YES"
;; 			    #:scrollbar "YES"
;; 			    #:posx "0.5"
;; 			    #:posy "0.5"
;; 			    #:button-cb (lambda (obj btn pressed x y status)
;; 					  ;; (print "obj: " obj ", pressed " pressed ", status " status)
;; 					; (print "canvas-origin: " (canvas-origin the-cnv))
;; 					  ;; (let-values (((xx yy)(canvas-origin the-cnv)))
;; 					  ;; (canvas-transform-set! the-cnv #f)
;; 					  ;; (print "canvas-origin: " xx " " yy " click at " x " " y))
;; 					  (let* ((tests-info     (hash-table-ref tests-draw-state 'tests-info))
;; 						 (selected-tests (hash-table-ref tests-draw-state 'selected-tests))
;; 						 (scalef         (hash-table-ref tests-draw-state 'scalef))
;; 						 (sizey          (hash-table-ref tests-draw-state 'sizey))
;; 						 (xoffset        (dcommon:get-xoffset tests-draw-state #f #f))
;; 						 (yoffset        (dcommon:get-yoffset tests-draw-state #f #f))
;; 						 (new-y          (- sizey y)))
;; 					    ;; (print "xoffset=" xoffset ", yoffset=" yoffset)
;; 					    ;; (print "\tx\ty\tllx\tlly\turx\tury")
;; 					    (for-each (lambda (test-name)
;; 							(let* ((rec-coords (hash-table-ref tests-info test-name))
;; 							       (llx        (dcommon:x->canvas (list-ref rec-coords 0) scalef xoffset))
;; 							       (lly        (dcommon:y->canvas (list-ref rec-coords 1) scalef yoffset))
;; 							       (urx        (dcommon:x->canvas (list-ref rec-coords 2) scalef xoffset))
;; 							       (ury        (dcommon:y->canvas (list-ref rec-coords 3) scalef yoffset)))
;; 							  ;; (if (eq? pressed 1)
;; 							  ;;    (print "\tx=" x "\ty=" y "\tnew-y=" new-y "\tllx=" llx "\tlly=" lly "\turx=" urx "\tury=" ury "\t" test-name " "))
;; 							  (if (and (eq? pressed 1)
;; 								   (>= x llx)
;; 								   (>= new-y lly)
;; 								   (<= x urx)
;; 								   (<= new-y ury))
;; 							      (let ((patterns (string-split (iup:attribute test-patterns-textbox "VALUE"))))
;; 								(let* ((selected     (not (member test-name patterns)))
;; 								       (newpatt-list (if selected
;; 											 (cons test-name patterns)
;; 											 (delete test-name patterns)))
;; 								       (newpatt      (string-intersperse newpatt-list "\n")))
;; 								  (iup:attribute-set! obj "REDRAW" "ALL")
;; 								  (hash-table-set! selected-tests test-name selected)
;; 								  (iup:attribute-set! test-patterns-textbox "VALUE" newpatt)
;; 								  (dboard:data-set-test-patts! *data* (dboard:lines->test-patt newpatt))
;; 								  (dashboard:update-run-command)
;; 								  (if updater (updater last-xadj last-yadj)))))))
;; 						      (hash-table-keys tests-info)))))))
;; 	  canvas-obj)))
;;       
;;       (iup:frame
;;        #:title "Logs" ;; To be replaced with tabs
;;        (let ((logs-tb (iup:textbox #:expand "YES"
;; 				   #:multiline "YES")))
;; 	 (dboard:data-set-logs-textbox! *data* logs-tb)
;; 	 logs-tb))))))

;;======================================================================
;; R U N   C O N T R O L S
;;======================================================================
;;
;; A gui for launching tests
;;
(define (dashboard:run-times)
  (let* ((targets       (make-hash-table))
	 (test-records  (make-hash-table))
	 (all-tests-registry (tests:get-all)) ;; (tests:get-valid-tests *toppath* '()))
	 (test-names    (hash-table-keys all-tests-registry))
	 (sorted-testnames #f)
	 (action        "-run")
	 (cmdln         "")
	 (runlogs       (make-hash-table))
	 (key-listboxes #f)
	 (updater-for-runs #f)
	 (update-keyvals (lambda ()
			   (let ((targ (map (lambda (x)
					      (iup:attribute x "VALUE"))
					    (car (dashboard:update-target-selector key-listboxes))))
				 (curr-runname (dboard:data-get-run-name *data*)))
			     (dboard:data-set-target! *data* targ)
			     (if updater-for-runs (updater-for-runs))
			     (if (or (not (equal? curr-runname (dboard:data-get-run-name *data*)))
				     (equal? (dboard:data-get-run-name *data*) ""))
				 (dboard:data-set-run-name! *data* curr-runname))
			     (dashboard:update-run-command))))
	 (tests-draw-state (make-hash-table)) ;; use for keeping state of the test canvas
	 (test-patterns-textbox  #f))
    (hash-table-set! tests-draw-state 'first-time #t)
    ;; (hash-table-set! tests-draw-state 'scalef 1)
    (tests:get-full-data test-names test-records '() all-tests-registry)
    (set! sorted-testnames (tests:sort-by-priority-and-waiton test-records))
    
    ;; refer to (d:alldat-keys *alldat*), (d:alldat-dbkeys *alldat*) for keys
    (iup:vbox
     (dcommon:command-execution-control *data*)
     (iup:split
      #:orientation "HORIZONTAL"
      
      (iup:split
       #:value 300

       ;; Target, testpatt, state and status input boxes
       ;;
       (iup:vbox
	;; Command to run, placed over the top of the canvas















	(dcommon:command-action-selector *data*)




































	(dcommon:command-runname-selector *alldat* *data*)

























	(dcommon:command-testname-selector *alldat* *data* update-keyvals key-listboxes))



















       






       (dcommon:command-tests-tasks-canvas *data* test-records sorted-testnames tests-draw-state))




































































       
      (iup:frame
       #:title "Logs" ;; To be replaced with tabs
       (let ((logs-tb (iup:textbox #:expand "YES"
				   #:multiline "YES")))
	 (dboard:data-set-logs-textbox! *data* logs-tb)
	 logs-tb))))))



























;;======================================================================
;; S U M M A R Y 
;;======================================================================
;;
;; General info about the run(s) and megatest area
(define (dashboard:summary data)
  (let* ((db               (d:alldat-dblocal data))
1761
1762
1763
1764
1765
1766
1767
1768
1769
1770
1771
1772
1773
1774
1775
				       ;; 		 (buttndat (hash-table-ref (d:alldat-buttondat *alldat*) button-key))
				       ;; 		 (test-id  (db:test-get-id (vector-ref buttndat 3)))
				       ;; 		 (run-id   (db:test-get-run_id (vector-ref buttndat 3)))
				       ;; 		 (cmd  (conc toolpath " -test " run-id "," test-id "&")))
				       ;; ;(print "Launching " cmd)
				       ;; 	    (system cmd)))
                                       #:button-cb (lambda (obj a pressed x y btn . rem)
                                                     (print "pressed= " pressed " x= " x " y= " y " rem=" rem " btn=" btn " string? " (string? btn))
                                                     (if  (substring-index "3" btn)
                                                          (if (eq? pressed 1)
                                                              (let* ((toolpath (car (argv)))
                                                                     (buttndat (hash-table-ref (d:alldat-buttondat *alldat*) button-key))
                                                                     (test-id  (db:test-get-id (vector-ref buttndat 3)))
                                                                     (run-id   (db:test-get-run_id (vector-ref buttndat 3)))
                                                                     (test-name (db:test-get-testname (rmt:get-test-info-by-id run-id test-id)))







|







1852
1853
1854
1855
1856
1857
1858
1859
1860
1861
1862
1863
1864
1865
1866
				       ;; 		 (buttndat (hash-table-ref (d:alldat-buttondat *alldat*) button-key))
				       ;; 		 (test-id  (db:test-get-id (vector-ref buttndat 3)))
				       ;; 		 (run-id   (db:test-get-run_id (vector-ref buttndat 3)))
				       ;; 		 (cmd  (conc toolpath " -test " run-id "," test-id "&")))
				       ;; ;(print "Launching " cmd)
				       ;; 	    (system cmd)))
                                       #:button-cb (lambda (obj a pressed x y btn . rem)
                                                     ;; (print "pressed= " pressed " x= " x " y= " y " rem=" rem " btn=" btn " string? " (string? btn))
                                                     (if  (substring-index "3" btn)
                                                          (if (eq? pressed 1)
                                                              (let* ((toolpath (car (argv)))
                                                                     (buttndat (hash-table-ref (d:alldat-buttondat *alldat*) button-key))
                                                                     (test-id  (db:test-get-id (vector-ref buttndat 3)))
                                                                     (run-id   (db:test-get-run_id (vector-ref buttndat 3)))
                                                                     (test-name (db:test-get-testname (rmt:get-test-info-by-id run-id test-id)))
1791
1792
1793
1794
1795
1796
1797



1798
1799
1800
1801
1802
1803
1804
1805
1806
1807
1808
1809
1810
1811

1812
1813
1814
1815
1816
1817
1818
                                                                                       (let* ((cmd (conc toolpath " -xterm " run-id "," test-id "&")))
                                                                                         (system cmd))))
                                                                                    (iup:menu-item
                                                                                     "Edit testconfig"
                                                                                     #:action
                                                                                     (lambda (obj)
                                                                                       (let* ((all-tests (tests:get-all))



                                                                                              (editor (or (get-environment-variable "VISUAL")
                                                                                                          (get-environment-variable "EDITOR") "gvim"))
                                                                                              (tconfig (conc (hash-table-ref all-tests test-name) "/testconfig"))
                                                                                              (cmd (conc (if (string-search "\\b(vim?|nano|pico)\\b")
                                                                                                             (conc "xterm -e " editor)
                                                                                                             editor)
                                                                                                         " " tconfig)))
                                                                                         (system cmd))))
                                                                                    )))))
                                                                (iup:show popup-menu
                                                                          #:x 'mouse
                                                                          #:y 'mouse
                                                                          #:modal? "NO")
                                                                (print "got here")))

                                                         (if (eq? pressed 0)
                                                             (let* ((toolpath (car (argv)))
                                                                    (buttndat (hash-table-ref (d:alldat-buttondat *alldat*) button-key))
                                                                    (test-id  (db:test-get-id (vector-ref buttndat 3)))
                                                                    (run-id   (db:test-get-run_id (vector-ref buttndat 3)))
                                                                    (cmd  (conc toolpath " -test " run-id "," test-id "&")))
                                                               (system cmd)))







>
>
>
|


|









|
>







1882
1883
1884
1885
1886
1887
1888
1889
1890
1891
1892
1893
1894
1895
1896
1897
1898
1899
1900
1901
1902
1903
1904
1905
1906
1907
1908
1909
1910
1911
1912
1913
                                                                                       (let* ((cmd (conc toolpath " -xterm " run-id "," test-id "&")))
                                                                                         (system cmd))))
                                                                                    (iup:menu-item
                                                                                     "Edit testconfig"
                                                                                     #:action
                                                                                     (lambda (obj)
                                                                                       (let* ((all-tests (tests:get-all))
											      (editor-rx (or (configf:lookup *configdat* "setup" "editor-regex") 
													     "\\b(vim?|nano|pico)\\b"))
                                                                                              (editor (or (configf:lookup *configdat* "setup" "editor")
													  (get-environment-variable "VISUAL")
                                                                                                          (get-environment-variable "EDITOR") "gvim"))
                                                                                              (tconfig (conc (hash-table-ref all-tests test-name) "/testconfig"))
                                                                                              (cmd (conc (if (string-search editor-rx editor)
                                                                                                             (conc "xterm -e " editor)
                                                                                                             editor)
                                                                                                         " " tconfig)))
                                                                                         (system cmd))))
                                                                                    )))))
                                                                (iup:show popup-menu
                                                                          #:x 'mouse
                                                                          #:y 'mouse
                                                                          #:modal? "NO")
                                                                ;; (print "got here")
								))
                                                         (if (eq? pressed 0)
                                                             (let* ((toolpath (car (argv)))
                                                                    (buttndat (hash-table-ref (d:alldat-buttondat *alldat*) button-key))
                                                                    (test-id  (db:test-get-id (vector-ref buttndat 3)))
                                                                    (run-id   (db:test-get-run_id (vector-ref buttndat 3)))
                                                                    (cmd  (conc toolpath " -test " run-id "," test-id "&")))
                                                               (system cmd)))
1841
1842
1843
1844
1845
1846
1847

1848
1849
1850
1851
1852
1853

1854
1855
1856
1857
1858
1859
1860
					(d:alldat-please-update-set! *alldat* #t)
					(d:alldat-curr-tab-num-set! *alldat* curr))
		    (dashboard:summary *alldat*)
		    runs-view
		    (dashboard:one-run db  data runs-sum-dat)
		    ;; (dashboard:new-view db data new-view-dat)
		    (dashboard:run-controls)

		    )))
	;; (set! (iup:callback tabs tabchange-cb:) (lambda (a b c)(print "SWITCHED TO TAB: " a " " b " " c)))
	(iup:attribute-set! tabs "TABTITLE0" "Summary")
	(iup:attribute-set! tabs "TABTITLE1" "Runs")
	(iup:attribute-set! tabs "TABTITLE2" "Run Summary")
	(iup:attribute-set! tabs "TABTITLE3" "Run Control")

	;; (iup:attribute-set! tabs "TABTITLE3" "New View")
	;; (iup:attribute-set! tabs "TABTITLE4" "Run Control")
	(iup:attribute-set! tabs "BGCOLOR" "190 190 190")
	(d:alldat-hide-not-hide-tabs-set! *alldat* tabs)
	(iup:vbox
	 tabs
	 controls))))







>






>







1936
1937
1938
1939
1940
1941
1942
1943
1944
1945
1946
1947
1948
1949
1950
1951
1952
1953
1954
1955
1956
1957
					(d:alldat-please-update-set! *alldat* #t)
					(d:alldat-curr-tab-num-set! *alldat* curr))
		    (dashboard:summary *alldat*)
		    runs-view
		    (dashboard:one-run db  data runs-sum-dat)
		    ;; (dashboard:new-view db data new-view-dat)
		    (dashboard:run-controls)
		    (dashboard:run-times)
		    )))
	;; (set! (iup:callback tabs tabchange-cb:) (lambda (a b c)(print "SWITCHED TO TAB: " a " " b " " c)))
	(iup:attribute-set! tabs "TABTITLE0" "Summary")
	(iup:attribute-set! tabs "TABTITLE1" "Runs")
	(iup:attribute-set! tabs "TABTITLE2" "Run Summary")
	(iup:attribute-set! tabs "TABTITLE3" "Run Control")
	(iup:attribute-set! tabs "TABTITLE4" "Run Times")
	;; (iup:attribute-set! tabs "TABTITLE3" "New View")
	;; (iup:attribute-set! tabs "TABTITLE4" "Run Control")
	(iup:attribute-set! tabs "BGCOLOR" "190 190 190")
	(d:alldat-hide-not-hide-tabs-set! *alldat* tabs)
	(iup:vbox
	 tabs
	 controls))))

Modified dcommon.scm from [ba01e4089c] to [05bf078426].

9
10
11
12
13
14
15

16
17
18
19
20
21
22
;;  PURPOSE.
;;======================================================================

(use format)
(require-library iup)
(import (prefix iup iup:))
(use canvas-draw)

(use regex defstruct)

(declare (unit dcommon))

(declare (uses megatest-version))
(declare (uses gutils))
(declare (uses db))







>







9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
;;  PURPOSE.
;;======================================================================

(use format)
(require-library iup)
(import (prefix iup iup:))
(use canvas-draw)
(import canvas-draw-iup)
(use regex defstruct)

(declare (unit dcommon))

(declare (uses megatest-version))
(declare (uses gutils))
(declare (uses db))
898
899
900
901
902
903
904
















































































































































































































905
906
907
908
909
910
911
		 (ury   (+ lly boxh)))
	    (dcommon:draw-test cnv xoffset yoffset scalef llx lly boxw boxh hed (hash-table-ref/default selected-tests hed #f))
	    (dcommon:draw-edges cnv xoffset yoffset scalef edges)
	    (if (not (null? tal))
		;; leave a column of space to the right to list items
		(loop (car tal)
		      (cdr tal))))))))

















































































































































































































;;======================================================================
;;  S T E P S
;;======================================================================

(define (dcommon:populate-steps teststeps steps-matrix)
  (let ((max-row 0)







>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>







899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
		 (ury   (+ lly boxh)))
	    (dcommon:draw-test cnv xoffset yoffset scalef llx lly boxw boxh hed (hash-table-ref/default selected-tests hed #f))
	    (dcommon:draw-edges cnv xoffset yoffset scalef edges)
	    (if (not (null? tal))
		;; leave a column of space to the right to list items
		(loop (car tal)
		      (cdr tal))))))))

;;======================================================================
;; RUN CONTROLS
;;======================================================================

(define (dcommon:command-execution-control data)
  ;; The command line display/exectution control
  (iup:frame
   #:title "Command to be exectuted"
   (iup:hbox
    (iup:label "Run on" #:size "40x")
    (iup:radio 
     (iup:hbox
      (iup:toggle "Local" #:size "40x")
      (iup:toggle "Server" #:size "40x")))
    (let ((tb (iup:textbox 
	       #:value "megatest "
	       #:expand "HORIZONTAL"
	       #:readonly "YES"
	       #:font "Courier New, -12"
	       )))
      (dboard:data-set-command-tb! data tb)
      tb)
    (iup:button "Execute" #:size "50x"
		#:action (lambda (obj)
			   (let ((cmd (conc "xterm -geometry 180x20 -e \""
					    (iup:attribute (dboard:data-get-command-tb data) "VALUE")
					    ";echo Press any key to continue;bash -c 'read -n 1 -s'\" &")))
			     (system cmd)))))))

(define (dcommon:command-action-selector data)
  (iup:frame
   #:title "Set the action to take"
   (iup:hbox
    ;; (iup:label "Command to run" #:expand "HORIZONTAL" #:size "70x" #:alignment "LEFT:ACENTER")
    (let* ((cmds-list '("run" "remove-runs" "set-state-status" "lock-runs" "unlock-runs"))
	   (lb         (iup:listbox #:expand "HORIZONTAL"
				    #:dropdown "YES"
				    #:action (lambda (obj val index lbstate)
					       ;; (print obj " " val " " index " " lbstate)
					       (dboard:data-set-command! data val)
					       (dashboard:update-run-command))))
	   (default-cmd (car cmds-list)))
      (iuplistbox-fill-list lb cmds-list selected-item: default-cmd)
      (dboard:data-set-command! data default-cmd)
      lb))))

(define (dcommon:command-runname-selector alldat data)
  (iup:frame
   #:title "Runname"
   (let* ((default-run-name (seconds->work-week/day (current-seconds)))
	  (tb (iup:textbox #:expand "HORIZONTAL"
			   #:action (lambda (obj val txt)
				      ;; (print "obj: " obj " val: " val " unk: " unk)
				      (dboard:data-set-run-name! data txt) ;; (iup:attribute obj "VALUE"))
				      (dashboard:update-run-command))
			   #:value (or default-run-name (dboard:data-get-run-name data))))
	  (lb (iup:listbox #:expand "HORIZONTAL"
			   #:dropdown "YES"
			   #:action (lambda (obj val index lbstate)
				      (if (not (equal? val ""))
					  (begin
					    (iup:attribute-set! tb "VALUE" val)
					    (dboard:data-set-run-name! data val)
					    (dashboard:update-run-command))))))
	  (refresh-runs-list (lambda ()
			       (let* ((target        (dboard:data-get-target-string data))
				      (runs-for-targ (if (d:alldat-useserver alldat)
							 (rmt:get-runs-by-patt (d:alldat-keys alldat) "%" target #f #f #f)
							 (db:get-runs-by-patt (d:alldat-dblocal alldat) (d:alldat-keys alldat) "%" target #f #f #f)))
				      (runs-header   (vector-ref runs-for-targ 0))
				      (runs-dat      (vector-ref runs-for-targ 1))
				      (run-names     (cons default-run-name 
							   (map (lambda (x)
								  (db:get-value-by-header x runs-header "runname"))
								runs-dat))))
				 ;; (iup:attribute-set! lb "REMOVEITEM" "ALL")
				 (iuplistbox-fill-list lb run-names selected-item: default-run-name)))))
     (set! updater-for-runs refresh-runs-list)
     (refresh-runs-list)
     (dboard:data-set-run-name! *data* default-run-name)
     (iup:hbox
      tb
      lb))))

(define (dcommon:command-testname-selector alldat data update-keyvals key-listboxes)
  (iup:frame
   #:title "SELECTORS"
   (iup:vbox
    ;; Text box for test patterns
    (iup:frame
     #:title "Test patterns (one per line)"
     (let ((tb (iup:textbox #:action (lambda (val a b)
				       (dboard:data-set-test-patts!
					*data*
					(dboard:lines->test-patt b))
				       (dashboard:update-run-command))
			    #:value (dboard:test-patt->lines
				     (dboard:data-get-test-patts *data*))
			    #:expand "YES"
			    #:size "x50"
			    #:multiline "YES")))
       (set! test-patterns-textbox tb)
       tb))
    (iup:frame
     #:title "Target"
     ;; Target selectors
     (apply iup:hbox
	    (let* ((dat      (dashboard:update-target-selector key-listboxes action-proc: update-keyvals))
		   (key-lb   (car dat))
		   (combos   (cadr dat)))
	      (set! key-listboxes key-lb)
	      combos)))
    (iup:hbox
     ;; Text box for STATES
     (iup:frame
      #:title "States"
      (dashboard:text-list-toggle-box 
       ;; Move these definitions to common and find the other useages and replace!
       (map cadr *common:std-states*) ;; '("COMPLETED" "RUNNING" "STUCK" "INCOMPLETE" "LAUNCHED" "REMOTEHOSTSTART" "KILLED")
       (lambda (all)
	 (dboard:data-set-states! *data* all)
	 (dashboard:update-run-command))))
     ;; Text box for STATES
     (iup:frame
      #:title "Statuses"
      (dashboard:text-list-toggle-box 
       (map cadr *common:std-statuses*) ;; '("PASS" "FAIL" "n/a" "CHECK" "WAIVED" "SKIP" "DELETED" "STUCK/DEAD")
       (lambda (all)
	 (dboard:data-set-statuses! *data* all)
	 (dashboard:update-run-command))))))))

(define (dcommon:command-tests-tasks-canvas data test-records sorted-testnames tests-draw-state)
  (iup:frame
   #:title "Tests and Tasks"
   (let* ((updater #f)
	  (last-xadj 0)
	  (last-yadj 0)
	  (the-cnv   #f)
	  (canvas-obj 
	   (iup:canvas #:action (make-canvas-action
				 (lambda (cnv xadj yadj)
				   (if (not updater)
				       (set! updater (lambda (xadj yadj)
						       ;; (print "cnv: " cnv " xadj: " xadj " yadj: " yadj)
						       (dashboard:draw-tests cnv xadj yadj tests-draw-state sorted-testnames test-records)
						       (set! last-xadj xadj)
						       (set! last-yadj yadj))))
				   (updater xadj yadj)
				   (set! the-cnv cnv)
				   ))
		       ;; Following doesn't work 
		       #:wheel-cb (lambda (obj step x y dir) ;; dir is 4 for up and 5 for down. I think.
				    (let ((scalef (hash-table-ref tests-draw-state 'scalef)))
				      (hash-table-set! tests-draw-state 'scalef (+ scalef
										   (if (> step 0)
										       (* scalef 0.01)
										       (* scalef -0.01))))
				      (if the-cnv
					  (dashboard:draw-tests the-cnv last-xadj last-yadj tests-draw-state sorted-testnames test-records))
				      ))
		       ;; #:size "50x50"
		       #:expand "YES"
		       #:scrollbar "YES"
		       #:posx "0.5"
		       #:posy "0.5"
		       #:button-cb (lambda (obj btn pressed x y status)
				     ;; (print "obj: " obj ", pressed " pressed ", status " status)
					; (print "canvas-origin: " (canvas-origin the-cnv))
				     ;; (let-values (((xx yy)(canvas-origin the-cnv)))
				     ;; (canvas-transform-set! the-cnv #f)
				     ;; (print "canvas-origin: " xx " " yy " click at " x " " y))
				     (let* ((tests-info     (hash-table-ref tests-draw-state 'tests-info))
					    (selected-tests (hash-table-ref tests-draw-state 'selected-tests))
					    (scalef         (hash-table-ref tests-draw-state 'scalef))
					    (sizey          (hash-table-ref tests-draw-state 'sizey))
					    (xoffset        (dcommon:get-xoffset tests-draw-state #f #f))
					    (yoffset        (dcommon:get-yoffset tests-draw-state #f #f))
					    (new-y          (- sizey y)))
				       ;; (print "xoffset=" xoffset ", yoffset=" yoffset)
				       ;; (print "\tx\ty\tllx\tlly\turx\tury")
				       (for-each (lambda (test-name)
						   (let* ((rec-coords (hash-table-ref tests-info test-name))
							  (llx        (dcommon:x->canvas (list-ref rec-coords 0) scalef xoffset))
							  (lly        (dcommon:y->canvas (list-ref rec-coords 1) scalef yoffset))
							  (urx        (dcommon:x->canvas (list-ref rec-coords 2) scalef xoffset))
							  (ury        (dcommon:y->canvas (list-ref rec-coords 3) scalef yoffset)))
						     ;; (if (eq? pressed 1)
						     ;;    (print "\tx=" x "\ty=" y "\tnew-y=" new-y "\tllx=" llx "\tlly=" lly "\turx=" urx "\tury=" ury "\t" test-name " "))
						     (if (and (eq? pressed 1)
							      (>= x llx)
							      (>= new-y lly)
							      (<= x urx)
							      (<= new-y ury))
							 (let ((patterns (string-split (iup:attribute test-patterns-textbox "VALUE"))))
							   (let* ((selected     (not (member test-name patterns)))
								  (newpatt-list (if selected
										    (cons test-name patterns)
										    (delete test-name patterns)))
								  (newpatt      (string-intersperse newpatt-list "\n")))
							     (iup:attribute-set! obj "REDRAW" "ALL")
							     (hash-table-set! selected-tests test-name selected)
							     (iup:attribute-set! test-patterns-textbox "VALUE" newpatt)
							     (dboard:data-set-test-patts! *data* (dboard:lines->test-patt newpatt))
							     (dashboard:update-run-command)
							     (if updater (updater last-xadj last-yadj)))))))
						 (hash-table-keys tests-info)))))))
     canvas-obj)))

;;======================================================================
;;  S T E P S
;;======================================================================

(define (dcommon:populate-steps teststeps steps-matrix)
  (let ((max-row 0)