Skip to content

Commit

Permalink
Merge pull request #149 from kaytu-io/fix-pages
Browse files Browse the repository at this point in the history
fix: Fixes usage columns
  • Loading branch information
salehkhazaei authored May 22, 2024
2 parents cea196d + f0c9cc7 commit d11f4e1
Showing 1 changed file with 4 additions and 14 deletions.
18 changes: 4 additions & 14 deletions view/page_resource_details.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,15 +50,7 @@ type ResourceDetailsPage struct {
func ExtractProperties(item *golang.OptimizationItem) map[string]Rows {
res := map[string]Rows{}
for _, dev := range item.Devices {
rows := Rows{
{
"",
"",
style.Bold.Render("Average"),
style.Bold.Render("Max"),
"",
},
}
rows := Rows{}

for _, prop := range dev.Properties {
if !strings.HasPrefix(prop.Key, " ") {
Expand All @@ -68,7 +60,6 @@ func ExtractProperties(item *golang.OptimizationItem) map[string]Rows {
prop.Key,
prop.Current,
prop.Average,
prop.Max,
prop.Recommended,
})
}
Expand All @@ -77,9 +68,9 @@ func ExtractProperties(item *golang.OptimizationItem) map[string]Rows {

for deviceID, rows := range res {
for idx, row := range rows {
if row[1] != row[4] {
if row[1] != row[3] {
row[1] = style.ChangeFrom.Render(row[1])
row[4] = style.ChangeTo.Render(row[4])
row[3] = style.ChangeTo.Render(row[3])
}
rows[idx] = row
}
Expand Down Expand Up @@ -147,8 +138,7 @@ func (m ResourceDetailsPage) OnOpen() Page {
table.NewColumn("0", "", 30),
table.NewColumn("1", "Current", 30),
table.NewColumn("2", fmt.Sprintf("%s day usage", days), 15),
table.NewColumn("3", "", 15),
table.NewColumn("4", "Recommendation", 30),
table.NewColumn("3", "Recommendation", 30),
}

m.item = item
Expand Down

0 comments on commit d11f4e1

Please sign in to comment.