Skip to content

Commit d3225ab

Browse files
authored
Merge pull request #78 from K97i/v2-ram
Add RAM modal
2 parents 52e309d + c436194 commit d3225ab

File tree

2 files changed

+84
-17
lines changed

2 files changed

+84
-17
lines changed

new/apps/web/src/lib/components/Widgets.svelte

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,9 @@
1919
</script>
2020

2121
<div class="widgets">
22-
<Cpu cpu={report.Hardware.Cpu} cpuMoreInfo={cpuMoreInfo} />
23-
<!--<RAM ramData={rawJSON.Hardware.Ram} pagefileData={rawJSON.System.PageFile} />
22+
<Cpu cpu={report.Hardware.Cpu} />
23+
<Ram ram={report.Hardware.Ram} pagefile={report.System.PageFile}/>
24+
<!--
2425
<Motherboard
2526
tpmData={rawJSON.Security.Tpm}
2627
motherboardData={rawJSON.Hardware.Motherboard}

new/apps/web/src/lib/components/widgets/Ram.svelte

Lines changed: 81 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,69 @@
1-
<!-- NOT YET IMPLEMENTED IN NEW WIDGET SYSTEM -->
21
<script lang="ts">
32
import Widget from '../../common/ModalWidget.svelte';
4-
import Rambuilder from '../logic/RamBuilder.svelte';
53
6-
export let ramData;
7-
export let pagefileData;
4+
interface RamInfo {
5+
DeviceLocation: string;
6+
BankLocator: string;
7+
Manufacturer: string;
8+
SerialNumber: string;
9+
PartNumber: string;
10+
ConfiguredSpeed: number;
11+
Capacity: number;
12+
}
13+
14+
interface PagefileInfo {
15+
AllocatedBaseSize: number;
16+
Caption: string;
17+
CurrentUsage: number;
18+
PeakUsage: number;
19+
}
20+
21+
interface Props {
22+
ram: Array<RamInfo>;
23+
pagefile: PagefileInfo;
24+
}
25+
26+
let {
27+
ram,
28+
pagefile
29+
}: Props = $props();
30+
31+
const flexBasis: string = `${100 / (Object.keys(ram).length % 4 ? Object.keys(ram).length % 4 : 4)}%`;
32+
833
</script>
934

1035
<!-- RAM -->
1136

12-
<Widget title="Memory" modalId="ram-modal">
13-
<div slot="values">
14-
<Rambuilder data={ramData} />
15-
</div>
37+
<Widget title="Memory">
38+
39+
{#snippet widgetContents()}
40+
<div class="flex-container">
41+
{#each ram as ramStick, i}
1642

17-
<div slot="modal-body">
43+
{#if ramStick.Capacity > 0}
44+
<div style="flex: 1 1 {flexBasis};">
45+
<span>{Math.floor(ramStick.Capacity / 1000)} GB</span>
46+
<div>DIMM {i+1}</div>
47+
</div>
48+
{:else}
49+
<div style="flex: 1 1 {flexBasis};">
50+
<span style="color: rgb(215,27,27);">--</span>
51+
<div>DIMM {i+1}</div>
52+
</div>
53+
{/if}
54+
55+
<!--
56+
Checks if report has more than 4 RAM Modules,
57+
and if each block has reached the 4th module in this row
58+
-->
59+
{#if Object.keys(ram).length > 4 && (i + 1) % 4 == 0}
60+
<div style="flex-basis: 100%;"></div>
61+
{/if}
62+
{/each}
63+
</div>
64+
{/snippet}
65+
66+
{#snippet modalContents()}
1867
<h5>Physical Memory</h5>
1968
<table class="table">
2069
<thead>
@@ -27,7 +76,7 @@
2776
</tr>
2877
</thead>
2978
<tbody>
30-
{#each ramData as ramStick}
79+
{#each ram as ramStick}
3180
{#if ramStick['Capacity'] <= 0}
3281
<tr>
3382
<td>{ramStick['DeviceLocation']}</td>
@@ -50,21 +99,38 @@
5099
<tbody>
51100
<tr>
52101
<td>File Path</td>
53-
<td>{pagefileData.Caption}</td>
102+
<td>{pagefile.Caption}</td>
54103
</tr>
55104
<tr>
56105
<td>Allocated Base Size</td>
57-
<td>{pagefileData.AllocatedBaseSize} MB</td>
106+
<td>{pagefile.AllocatedBaseSize} MB</td>
58107
</tr>
59108
<tr>
60109
<td>Current Usage</td>
61-
<td>{pagefileData.CurrentUsage} MB</td>
110+
<td>{pagefile.CurrentUsage} MB</td>
62111
</tr>
63112
<tr>
64113
<td>Peak Usage</td>
65-
<td>{pagefileData.PeakUsage} MB</td>
114+
<td>{pagefile.PeakUsage} MB</td>
66115
</tr>
67116
</tbody>
68117
</table>
69-
</div>
118+
{/snippet}
70119
</Widget>
120+
121+
<style>
122+
span {
123+
color: var(--color-secondary-50);
124+
}
125+
126+
div {
127+
color: var(--color-surface-300);
128+
font-size: 13pt;
129+
}
130+
131+
.flex-container {
132+
display: flex;
133+
flex-flow: row wrap;
134+
max-width: inherit;
135+
}
136+
</style>

0 commit comments

Comments
 (0)