Skip to content

Commit 409971a

Browse files
committed
feat: enhance SummaryCard component with improved heading and body structure; update utilization display formatting
1 parent b73c9fb commit 409971a

File tree

5 files changed

+27
-20
lines changed

5 files changed

+27
-20
lines changed

Diff for: src/lib/components/SummaryCard.svelte

+9-11
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<script lang="ts">
2-
import { HelpText } from '@nais/ds-svelte-community';
2+
import { BodyShort, Heading, HelpText } from '@nais/ds-svelte-community';
33
import type { Snippet } from 'svelte';
44
55
const colors = {
@@ -40,15 +40,17 @@
4040
{@render icon({ color })}
4141
</div>
4242
<div class="summary">
43-
<h4>
44-
{title}
43+
<div class="heading">
44+
<Heading level="2" size="xsmall">
45+
{title}
46+
</Heading>
4547
{#if helpText}
4648
<HelpText title={helpTextTitle ? helpTextTitle : ''}>{helpText}</HelpText>
4749
{/if}
48-
</h4>
49-
<p class="metric">
50+
</div>
51+
<BodyShort>
5052
{@render children()}
51-
</p>
53+
</BodyShort>
5254
</div>
5355
</div>
5456

@@ -76,15 +78,11 @@
7678
.summary {
7779
width: 100%;
7880
}
79-
.summary > h4 {
81+
.heading {
8082
display: flex;
8183
justify-content: space-between;
8284
margin: 0;
8385
font-size: 1rem;
8486
color: var(--color-text-secondary);
8587
}
86-
.metric {
87-
font-size: 1.5rem;
88-
margin: 0;
89-
}
9088
</style>

Diff for: src/lib/utils/resources.ts

-1
Original file line numberDiff line numberDiff line change
@@ -259,7 +259,6 @@ export function cpuUtilization(cpuRequest: number | undefined, totalUsage: numbe
259259
if (!cpuRequest) return 0;
260260
const totalCores = cpuRequest;
261261
const utilization = (totalUsage / totalCores) * 100;
262-
console.log('cpu utilization', utilization);
263262
return Math.round(utilization * 10 ** 2) / 10 ** 2;
264263
}
265264

Diff for: src/routes/team/[team]/[env]/app/[app]/Utilization.svelte

+14-4
Original file line numberDiff line numberDiff line change
@@ -48,13 +48,23 @@
4848
<Heading level="3" size="small">Utilization</Heading>
4949
<BodyShort>
5050
<CpuIcon class="text-aligned-icon" />
51-
{cpuUtil}% of {$data.utilization.cpuRequests.toLocaleString('en-GB', {
52-
maximumFractionDigits: 2
53-
})}CPUs
51+
{cpuUtilization($data.utilization.cpuRequests, $data.utilization.cpuUsage)}% of {$data.utilization.cpuRequests.toLocaleString(
52+
'en-GB',
53+
{
54+
minimumFractionDigits: 2,
55+
maximumFractionDigits: 2
56+
}
57+
)} CPUs
5458
</BodyShort>
5559
<BodyShort>
5660
<FileIcon class="text-aligned-icon" />
57-
{memUtil}% of {prettyBytes($data.utilization.memoryRequests)} of memory
61+
{(
62+
memoryUtilization($data.utilization.memoryRequests, $data.utilization.memoryUsage) * 100
63+
).toFixed(0)}% of {prettyBytes($data.utilization.memoryRequests, {
64+
locale: 'en',
65+
minimumFractionDigits: 2,
66+
maximumFractionDigits: 2
67+
})}
5868
</BodyShort>
5969
<Link href="/team/{$data.team.slug}/{$data.environment.name}/app/{$data.name}/utilization">
6070
View details

Diff for: src/routes/team/[team]/[env]/app/[app]/utilization/+page.svelte

+2-2
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@
101101
minimumFractionDigits: 2,
102102
maximumFractionDigits: 2
103103
}
104-
)} cores
104+
)} CPUs
105105
</SummaryCard>
106106
</Card>
107107
<Card columns={3} borderColor="#91dc75">
@@ -145,7 +145,7 @@
145145
</Card>
146146
<Card columns={3} borderColor="#91dc75">
147147
<SummaryCard
148-
title="Unused memory cost"
148+
title="Unused mem cost"
149149
helpTextTitle="Annual cost of unused memory"
150150
helpText="Estimate of annual cost of unused memory calculated based on current utilization."
151151
color="green"

Diff for: src/routes/team/[team]/utilization/+page.svelte

+2-2
Original file line numberDiff line numberDiff line change
@@ -211,7 +211,7 @@
211211

212212
<div class="grid">
213213
{#if resourceUtilization}
214-
<Card columns={3} borderColor="#83bff6">
214+
<Card columns={4} borderColor="#83bff6">
215215
<SummaryCard
216216
color="blue"
217217
title="Unused CPU cost"
@@ -235,7 +235,7 @@
235235
{/if}
236236
</SummaryCard>
237237
</Card>
238-
<Card columns={3} borderColor="#91dc75">
238+
<Card columns={4} borderColor="#91dc75">
239239
<SummaryCard
240240
color="green"
241241
title="Unused memory cost"

0 commit comments

Comments
 (0)