Skip to content

Commit 0fb4fcd

Browse files
committed
Ensure disk model information is split correctly
Update formatting in the UI
1 parent 49cdbbd commit 0fb4fcd

File tree

7 files changed

+35
-30
lines changed

7 files changed

+35
-30
lines changed

src/legacy/disks.rs

+17-17
Original file line numberDiff line numberDiff line change
@@ -81,25 +81,25 @@ fn linux_disks(lib_path: &str) -> Vec<HashMap<String, String>> {
8181
return Vec::new();
8282
}
8383
};
84-
let disks: Vec<&str> = output.lines().collect();
85-
let filtered_disks: Vec<&str> = disks.into_iter().filter(|&disk| !disk.contains("loop")).collect();
86-
let keys_raw = filtered_disks[0].to_lowercase()
87-
.replace("name", "DeviceID")
88-
.replace("model", "Name")
89-
.replace("size", "Size");
90-
let keys: Vec<&str> = keys_raw.split_whitespace().collect();
91-
let mut disk_info = Vec::new();
92-
for line in &filtered_disks[1..] {
93-
let values: Vec<&str> = line.split_whitespace().collect();
94-
let mut disk_map = HashMap::new();
95-
for (key, value) in keys.iter().zip(values.iter()) {
96-
disk_map.insert(key.to_string(), value.to_string());
84+
// Skip the header line
85+
let disks_skipped: Vec<&str> = output.lines().skip(1).collect();
86+
let filtered_disks: Vec<&str> = disks_skipped.into_iter().filter(|&disk| !disk.contains("loop")).collect();
87+
let mut disk_list = Vec::new();
88+
for disk in filtered_disks {
89+
// Split the disk info by whitespace and collect each part
90+
let parts: Vec<&str> = disk.split_whitespace().collect();
91+
// Ensure the disk info has at least 4 parts (NAME, SIZE, TYPE, MODEL)
92+
if parts.len() >= 4 {
93+
let disk_info = HashMap::from([
94+
("Name".to_string(), parts[0].to_string()),
95+
("Size".to_string(), parse_size(parts[1])),
96+
("Type".to_string(), parts[2].to_string()),
97+
("Model".to_string(), parts[3..].join(" ")),
98+
]);
99+
disk_list.push(disk_info);
97100
}
98-
disk_map.insert("Size".to_string(), parse_size(disk_map.get("Size").unwrap()));
99-
disk_map.remove("type");
100-
disk_info.push(disk_map);
101101
}
102-
disk_info
102+
disk_list
103103
}
104104

105105
/// Function to get disk information on macOS.

src/templates/error.rs

+3-2
Original file line numberDiff line numberDiff line change
@@ -51,9 +51,10 @@ pub fn get_content() -> String {
5151
5252
footer {
5353
width: 100%;
54+
color: #fff;
5455
text-align: center;
55-
align-content: center
56-
font-size: 10px;
56+
align-content: center;
57+
font-size: 14px;
5758
font-style: italic;
5859
}
5960
</style>

src/templates/index.rs

+3-2
Original file line numberDiff line numberDiff line change
@@ -96,9 +96,10 @@ pub fn get_content() -> String {
9696
9797
footer {
9898
width: 100%;
99+
color: #fff;
99100
text-align: center;
100-
align-content: center
101-
font-size: 10px;
101+
align-content: center;
102+
font-size: 14px;
102103
font-style: italic;
103104
}
104105
</style>

src/templates/logout.rs

+3-2
Original file line numberDiff line numberDiff line change
@@ -49,9 +49,10 @@ pub fn get_content() -> String {
4949
5050
footer {
5151
width: 100%;
52+
color: #fff;
5253
text-align: center;
53-
align-content: center
54-
font-size: 10px;
54+
align-content: center;
55+
font-size: 14px;
5556
font-style: italic;
5657
}
5758
</style>

src/templates/monitor.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -162,8 +162,8 @@ pub fn get_content() -> String {
162162
footer {
163163
width: 100%;
164164
text-align: center;
165-
align-content: center
166-
font-size: 10px;
165+
align-content: center;
166+
font-size: 14px;
167167
font-style: italic;
168168
}
169169
@@ -222,7 +222,7 @@ pub fn get_content() -> String {
222222
{% if sys_info_disks %}
223223
<br>
224224
<details>
225-
<summary><strong>Partitions</strong></summary>
225+
<summary><strong>Disk Information</strong></summary>
226226
{% for disk_info in sys_info_disks %}
227227
<br>
228228
{% for key, value in disk_info|items() %}

src/templates/session.rs

+3-2
Original file line numberDiff line numberDiff line change
@@ -52,9 +52,10 @@ pub fn get_content() -> String {
5252
5353
footer {
5454
width: 100%;
55+
color: #fff;
5556
text-align: center;
56-
align-content: center
57-
font-size: 10px;
57+
align-content: center;
58+
font-size: 14px;
5859
font-style: italic;
5960
}
6061
</style>

src/templates/unauthorized.rs

+3-2
Original file line numberDiff line numberDiff line change
@@ -45,9 +45,10 @@ pub fn get_content() -> String {
4545
4646
footer {
4747
width: 100%;
48+
color: #fff;
4849
text-align: center;
49-
align-content: center
50-
font-size: 10px;
50+
align-content: center;
51+
font-size: 14px;
5152
font-style: italic;
5253
}
5354
</style>

0 commit comments

Comments
 (0)