@@ -284,10 +284,12 @@ const (
284
284
)
285
285
286
286
func (ui * Termui ) staticRender () {
287
+ checking , checkingColor := statusShort (sdk .StatusChecking .String ())
287
288
waiting , waitingColor := statusShort (sdk .StatusWaiting .String ())
288
289
building , buildingColor := statusShort (sdk .StatusBuilding .String ())
289
290
disabled , disabledColor := statusShort (sdk .StatusDisabled .String ())
290
- ui .header .Text = fmt .Sprintf ("[CDS | (h)elp | (q)uit | Legend: ](fg-cyan) [Waiting:%s](%s) [Building:%s](%s) [Disabled:%s](%s)" ,
291
+ ui .header .Text = fmt .Sprintf ("[CDS | (h)elp | (q)uit | Legend:](fg-cyan) [Checking:%s](%s) [Waiting:%s](%s) [Building:%s](%s) [Disabled:%s](%s)" ,
292
+ checking , checkingColor ,
291
293
waiting , waitingColor ,
292
294
building , buildingColor ,
293
295
disabled , disabledColor )
@@ -493,30 +495,41 @@ func (ui *Termui) computeStatusHatcheriesWorkers(workers []sdk.Worker) {
493
495
status [w .Status .String ()] = status [w .Status .String ()] + 1
494
496
}
495
497
498
+ sort .Slice (statusTitle , func (i , j int ) bool {
499
+ return statusWeight (statusTitle [i ]) < statusWeight (statusTitle [j ])
500
+ })
501
+
496
502
var items []string
497
503
sort .Strings (hatcheryNames )
498
504
for _ , name := range hatcheryNames {
499
505
v := hatcheries [name ]
500
506
var t string
507
+ var statusText []string
501
508
for _ , status := range statusTitle {
502
509
if v [status ] > 0 {
503
510
icon , color := statusShort (status )
504
- t = fmt .Sprintf ("%s[ %d%s ](%s)" , t , v [status ], icon , color )
511
+ statusText = append ( statusText , fmt .Sprintf ("[ %d%s](%s)" , v [status ], icon , color ) )
505
512
}
506
513
}
507
- if len (t ) == 0 {
508
- t = fmt .Sprintf ("%s[ _ ](fg-white)" , t )
514
+ if len (statusText ) == 0 {
515
+ t = fmt .Sprintf (" [_ %s](fg-white)" , name )
516
+ } else {
517
+ t = fmt .Sprintf (" %s [%s](fg-white)" , strings .Join (statusText , " " ), name )
509
518
}
510
- t = fmt .Sprintf ("%s[ %s](fg-white)" , t , name )
511
519
items = append (items , t )
512
520
}
513
521
ui .statusHatcheriesWorkers .SetItems (items ... )
514
522
515
- sort .Strings (statusTitle )
516
- title := " Hatcheries "
523
+ var titleStatusText []string
517
524
for _ , s := range statusTitle {
518
- icon , color := statusShort (s )
519
- title = fmt .Sprintf ("%s[%d%s](%s) " , title , status [s ], icon , color )
525
+ if status [s ] > 0 {
526
+ icon , color := statusShort (s )
527
+ titleStatusText = append (titleStatusText , fmt .Sprintf ("[%d%s](%s)" , status [s ], icon , color ))
528
+ }
529
+ }
530
+ title := " Hatcheries "
531
+ if len (titleStatusText ) > 0 {
532
+ title = fmt .Sprintf ("%s%s " , title , strings .Join (titleStatusText , " " ))
520
533
}
521
534
ui .statusHatcheriesWorkers .BorderLabel = title
522
535
}
@@ -632,13 +645,27 @@ func statusShort(status string) (string, string) {
632
645
case sdk .StatusBuilding .String ():
633
646
return "b" , "fg-blue"
634
647
case sdk .StatusDisabled .String ():
635
- return "d" , "fg-grey "
648
+ return "d" , "fg-white "
636
649
case sdk .StatusChecking .String ():
637
650
return "c" , "fg-yellow"
638
651
}
639
652
return status , "fg-default"
640
653
}
641
654
655
+ func statusWeight (status string ) int {
656
+ switch status {
657
+ case sdk .StatusDisabled .String ():
658
+ return 4
659
+ case sdk .StatusBuilding .String ():
660
+ return 3
661
+ case sdk .StatusWaiting .String ():
662
+ return 2
663
+ case sdk .StatusChecking .String ():
664
+ return 1
665
+ }
666
+ return 0
667
+ }
668
+
642
669
func pad (t string , size int ) string {
643
670
if len (t ) > size {
644
671
return t [0 :size - 3 ] + "..."
0 commit comments