Skip to content

Commit

Permalink
feat(ui): updating pods table column name (#369)
Browse files Browse the repository at this point in the history
  • Loading branch information
BillyFigueroa authored Sep 20, 2024
1 parent 0a67913 commit 25aaaf9
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 8 deletions.
2 changes: 1 addition & 1 deletion ui/src/lib/features/k8s/workloads/pods/component.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
['containers', '1/12'],
['status', 'w-1/12'],
['restarts', 'w-1/12'],
['metrics', 'w-1/12'],
['usage', 'w-1/12'],
['node', 'w-1/12 truncate'],
['age', 'w-1/12'],
]
Expand Down
6 changes: 3 additions & 3 deletions ui/src/lib/features/k8s/workloads/pods/component.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ suite('PodTable Component', () => {
['containers', '1/12'],
['status', 'w-1/12'],
['restarts', 'w-1/12'],
['metrics', 'w-1/12'],
['usage', 'w-1/12'],
['node', 'w-1/12 truncate'],
['age', 'w-1/12'],
],
Expand Down Expand Up @@ -165,7 +165,7 @@ suite('PodTable Component', () => {
},
sort: 2,
},
metrics: {
usage: {
component: SvelteComponent,
sort: 0,
// metrics added by store.filterCallback (not currently called in this test)
Expand All @@ -188,7 +188,7 @@ suite('PodTable Component', () => {
expectEqualIgnoringFields(start()[0].table, expectedTable as unknown, [
'creationTimestamp',
'containers.component',
'metrics.component',
'usage.component',
'status.component',
])
vi.unstubAllGlobals()
Expand Down
11 changes: 7 additions & 4 deletions ui/src/lib/features/k8s/workloads/pods/store.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ interface Row extends CommonRow {
controlled_by: string
node: string
status: { component: typeof Status; props: { type: keyof K8StatusMapping; status: string } }
metrics: {
usage: {
component: typeof PodMetrics
sort: number
props: {
Expand Down Expand Up @@ -81,7 +81,7 @@ export function createStore(): ResourceStoreInterface<Resource, Row> {
(r.status?.containerStatuses?.length ?? 0) +
(r.status?.ephemeralContainerStatuses?.length ?? 0),
},
metrics: {
usage: {
component: PodMetrics,
sort: 0,
props: {
Expand All @@ -105,9 +105,12 @@ export function createStore(): ResourceStoreInterface<Resource, Row> {
const key = `${d.resource.metadata?.namespace}/${d.resource.metadata?.name}`
const metric = metrics.get(key)

console.log('metric')
console.log(metric)

if (metric?.containers) {
d.table.metrics.sort = metric.containers.reduce((sum, container) => sum + parseCPU(container.usage.cpu), 0)
d.table.metrics.props.containers = metric.containers
d.table.usage.sort = metric.containers.reduce((sum, container) => sum + parseCPU(container.usage.cpu), 0)
d.table.usage.props.containers = metric.containers
}

return d
Expand Down

0 comments on commit 25aaaf9

Please sign in to comment.