Skip to content

Commit d157ef9

Browse files
authored
polish pods table and events table (#3241)
1 parent 37d13ba commit d157ef9

File tree

8 files changed

+11
-35
lines changed

8 files changed

+11
-35
lines changed

modules/cmp/component-protocol/components/cmp-dashboard-events-list/eventTable/model.go

+1
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,7 @@ type Column struct {
8282
Title string `json:"title,omitempty"`
8383
Sorter bool `json:"sorter,omitempty"`
8484
Align string `json:"align,omitempty"`
85+
Hidden bool `json:"hidden"`
8586
}
8687

8788
type Operation struct {

modules/cmp/component-protocol/components/cmp-dashboard-events-list/eventTable/render.go

+3-2
Original file line numberDiff line numberDiff line change
@@ -317,7 +317,6 @@ func (t *ComponentEventTable) SetComponentValue(ctx context.Context) {
317317
DataIndex: "lastSeen",
318318
Title: cputil.I18n(ctx, "lastSeen"),
319319
Sorter: true,
320-
Align: "right",
321320
},
322321
{
323322
DataIndex: "type",
@@ -338,6 +337,7 @@ func (t *ComponentEventTable) SetComponentValue(ctx context.Context) {
338337
DataIndex: "source",
339338
Title: cputil.I18n(ctx, "source"),
340339
Sorter: true,
340+
Hidden: true,
341341
},
342342
{
343343
DataIndex: "message",
@@ -348,12 +348,13 @@ func (t *ComponentEventTable) SetComponentValue(ctx context.Context) {
348348
DataIndex: "count",
349349
Title: cputil.I18n(ctx, "count"),
350350
Sorter: true,
351-
Align: "right",
351+
Hidden: true,
352352
},
353353
{
354354
DataIndex: "name",
355355
Title: cputil.I18n(ctx, "name"),
356356
Sorter: true,
357+
Hidden: true,
357358
},
358359
{
359360
DataIndex: "namespace",

modules/cmp/component-protocol/components/cmp-dashboard-podDetail/containerTable/render.go

-2
Original file line numberDiff line numberDiff line change
@@ -189,12 +189,10 @@ func (containerTable *ContainerTable) Render(ctx context.Context, c *cptype.Comp
189189
{
190190
DataIndex: "restartCount",
191191
Title: cputil.I18n(ctx, "restartCount"),
192-
Align: "right",
193192
},
194193
{
195194
DataIndex: "operate",
196195
Title: cputil.I18n(ctx, "operate"),
197-
Fixed: "right",
198196
},
199197
}
200198
containerTable.Transfer(c)

modules/cmp/component-protocol/components/cmp-dashboard-pods/podsTable/model.go

+1
Original file line numberDiff line numberDiff line change
@@ -156,6 +156,7 @@ type Column struct {
156156
Sorter bool `json:"sorter"`
157157
Fixed string `json:"fixed,omitempty"`
158158
Align string `json:"align,omitempty"`
159+
Hidden bool `json:"hidden"`
159160
}
160161

161162
type Operation struct {

modules/cmp/component-protocol/components/cmp-dashboard-pods/podsTable/render.go

+4-11
Original file line numberDiff line numberDiff line change
@@ -588,7 +588,7 @@ func (p *ComponentPodsTable) parseResPercent(usedPercent float64, totQty *resour
588588
}
589589
tip = fmt.Sprintf("%s/%s", cmpcputil.ResourceToString(p.sdk, usedRes, format),
590590
cmpcputil.ResourceToString(p.sdk, float64(totQty.MilliValue()), format))
591-
value = fmt.Sprintf("%.2f", usedPercent)
591+
value = fmt.Sprintf("%.1f", usedPercent)
592592
} else {
593593
totRes = totQty.Value()
594594
usedRes = float64(totRes) * usedPercent / 100
@@ -601,7 +601,7 @@ func (p *ComponentPodsTable) parseResPercent(usedPercent float64, totQty *resour
601601
}
602602
tip = fmt.Sprintf("%s/%s", cmpcputil.ResourceToString(p.sdk, usedRes, format),
603603
cmpcputil.ResourceToString(p.sdk, float64(totQty.Value()), format))
604-
value = fmt.Sprintf("%.2f", usedPercent)
604+
value = fmt.Sprintf("%.1f", usedPercent)
605605
}
606606
return status, value, tip
607607
}
@@ -613,6 +613,7 @@ func (p *ComponentPodsTable) SetComponentValue(ctx context.Context) {
613613
p.Props.PageSizeOptions = []string{
614614
"10", "20", "50", "100",
615615
}
616+
616617
p.Props.Columns = []Column{
617618
{
618619
DataIndex: "name",
@@ -633,18 +634,17 @@ func (p *ComponentPodsTable) SetComponentValue(ctx context.Context) {
633634
DataIndex: "ready",
634635
Title: cputil.I18n(ctx, "ready"),
635636
Sorter: true,
636-
Align: "right",
637637
},
638638
{
639639
DataIndex: "node",
640640
Title: cputil.I18n(ctx, "node"),
641641
Sorter: true,
642+
Hidden: true,
642643
},
643644
{
644645
DataIndex: "age",
645646
Title: cputil.I18n(ctx, "age"),
646647
Sorter: true,
647-
Align: "right",
648648
},
649649
}
650650

@@ -654,19 +654,16 @@ func (p *ComponentPodsTable) SetComponentValue(ctx context.Context) {
654654
DataIndex: "cpuRequests",
655655
Title: cputil.I18n(ctx, "cpuRequests"),
656656
Sorter: true,
657-
Align: "right",
658657
},
659658
{
660659
DataIndex: "cpuLimits",
661660
Title: cputil.I18n(ctx, "cpuLimits"),
662661
Sorter: true,
663-
Align: "right",
664662
},
665663
{
666664
DataIndex: "cpuPercent",
667665
Title: cputil.I18n(ctx, "cpuPercent"),
668666
Sorter: true,
669-
Align: "right",
670667
},
671668
}...)
672669
} else {
@@ -675,27 +672,23 @@ func (p *ComponentPodsTable) SetComponentValue(ctx context.Context) {
675672
DataIndex: "memoryRequests",
676673
Title: cputil.I18n(ctx, "memoryRequests"),
677674
Sorter: true,
678-
Align: "right",
679675
},
680676
{
681677
DataIndex: "memoryLimits",
682678
Title: cputil.I18n(ctx, "memoryLimits"),
683679
Sorter: true,
684-
Align: "right",
685680
},
686681
{
687682
DataIndex: "memoryPercent",
688683
Title: cputil.I18n(ctx, "memoryPercent"),
689684
Sorter: true,
690-
Align: "right",
691685
},
692686
}...)
693687
}
694688
p.Props.Columns = append(p.Props.Columns, Column{
695689
DataIndex: "gotoWorkload",
696690
Title: cputil.I18n(ctx, "operate"),
697691
Sorter: false,
698-
Fixed: "right",
699692
})
700693
p.Operations = map[string]interface{}{
701694
"changeSort": Operation{

modules/cmp/component-protocol/components/cmp-dashboard-workload-detail/podsTable/render.go

+2-10
Original file line numberDiff line numberDiff line change
@@ -680,7 +680,7 @@ func (p *ComponentPodsTable) parseResPercent(usedPercent float64, totQty *resour
680680
}
681681
tip = fmt.Sprintf("%s/%s", cmpcputil.ResourceToString(p.sdk, usedRes, format),
682682
cmpcputil.ResourceToString(p.sdk, float64(totQty.MilliValue()), format))
683-
value = fmt.Sprintf("%.2f", usedPercent)
683+
value = fmt.Sprintf("%.1f", usedPercent)
684684
} else {
685685
totRes = totQty.Value()
686686
usedRes = float64(totRes) * usedPercent / 100
@@ -693,7 +693,7 @@ func (p *ComponentPodsTable) parseResPercent(usedPercent float64, totQty *resour
693693
}
694694
tip = fmt.Sprintf("%s/%s", cmpcputil.ResourceToString(p.sdk, usedRes, format),
695695
cmpcputil.ResourceToString(p.sdk, float64(totQty.Value()), format))
696-
value = fmt.Sprintf("%.2f", usedPercent)
696+
value = fmt.Sprintf("%.1f", usedPercent)
697697
}
698698
return status, value, tip
699699
}
@@ -725,7 +725,6 @@ func (p *ComponentPodsTable) SetComponentValue(ctx context.Context) {
725725
DataIndex: "ready",
726726
Title: cputil.I18n(ctx, "ready"),
727727
Sorter: true,
728-
Align: "right",
729728
},
730729
{
731730
DataIndex: "nodeName",
@@ -736,43 +735,36 @@ func (p *ComponentPodsTable) SetComponentValue(ctx context.Context) {
736735
DataIndex: "age",
737736
Title: cputil.I18n(ctx, "age"),
738737
Sorter: true,
739-
Align: "right",
740738
},
741739
{
742740
DataIndex: "cpuRequests",
743741
Title: cputil.I18n(ctx, "cpuRequests"),
744742
Sorter: true,
745-
Align: "right",
746743
},
747744
{
748745
DataIndex: "cpuLimits",
749746
Title: cputil.I18n(ctx, "cpuLimits"),
750747
Sorter: true,
751-
Align: "right",
752748
},
753749
{
754750
DataIndex: "cpuPercent",
755751
Title: cputil.I18n(ctx, "cpuPercent"),
756752
Sorter: true,
757-
Align: "right",
758753
},
759754
{
760755
DataIndex: "memoryRequests",
761756
Title: cputil.I18n(ctx, "memoryRequests"),
762757
Sorter: true,
763-
Align: "right",
764758
},
765759
{
766760
DataIndex: "memoryLimits",
767761
Title: cputil.I18n(ctx, "memoryLimits"),
768762
Sorter: true,
769-
Align: "right",
770763
},
771764
{
772765
DataIndex: "memoryPercent",
773766
Title: cputil.I18n(ctx, "memoryPercent"),
774767
Sorter: true,
775-
Align: "right",
776768
},
777769
//{
778770
// DataIndex: "operate",

modules/cmp/component-protocol/components/cmp-dashboard-workloads-list/workloadTable/render.go

-9
Original file line numberDiff line numberDiff line change
@@ -530,49 +530,41 @@ func (w *ComponentWorkloadTable) SetComponentValue(ctx context.Context) {
530530
DataIndex: "age",
531531
Title: cputil.I18n(ctx, "age"),
532532
Sorter: true,
533-
Align: "right",
534533
}
535534
readyColumn := Column{
536535
DataIndex: "ready",
537536
Title: cputil.I18n(ctx, "ready"),
538537
Sorter: true,
539-
Align: "right",
540538
}
541539
upToDateColumn := Column{
542540
DataIndex: "upToDate",
543541
Title: cputil.I18n(ctx, "upToDate"),
544542
Sorter: true,
545-
Align: "right",
546543
}
547544
availableColumn := Column{
548545
DataIndex: "available",
549546
Title: cputil.I18n(ctx, "available"),
550547
Sorter: true,
551-
Align: "right",
552548
}
553549
desiredColumn := Column{
554550
DataIndex: "desired",
555551
Title: cputil.I18n(ctx, "desired"),
556552
Sorter: true,
557-
Align: "right",
558553
}
559554
currentColumn := Column{
560555
DataIndex: "current",
561556
Title: cputil.I18n(ctx, "current"),
562557
Sorter: true,
563-
Align: "right",
564558
}
565559
completionsColumn := Column{
566560
DataIndex: "completions",
567561
Title: cputil.I18n(ctx, "completions"),
568562
Sorter: true,
569-
Align: "right",
570563
}
571564
durationColumn := Column{
572565
DataIndex: "duration",
573566
Title: cputil.I18n(ctx, "jobDuration"),
574567
Sorter: true,
575-
Align: "right",
576568
}
577569
scheduleColumn := Column{
578570
DataIndex: "schedule",
@@ -583,7 +575,6 @@ func (w *ComponentWorkloadTable) SetComponentValue(ctx context.Context) {
583575
DataIndex: "lastSchedule",
584576
Title: cputil.I18n(ctx, "lastSchedule"),
585577
Sorter: true,
586-
Align: "right",
587578
}
588579

589580
if len(w.State.Values.Kind) != 1 {

modules/cmp/component-protocol/components/cmp-dashboard-workloads-list/workloadTable/render_test.go

-1
Original file line numberDiff line numberDiff line change
@@ -424,7 +424,6 @@ func TestComponentWorkloadTable_Transfer(t *testing.T) {
424424
DataIndex: "test",
425425
Title: "testTitle",
426426
Sorter: true,
427-
Align: "right",
428427
},
429428
},
430429
RowKey: "testKey",

0 commit comments

Comments
 (0)