Skip to content

Commit

Permalink
Ensure disk model information is split correctly
Browse files Browse the repository at this point in the history
Update formatting in the UI
  • Loading branch information
dormant-user committed Sep 26, 2024
1 parent 49cdbbd commit 0fb4fcd
Show file tree
Hide file tree
Showing 7 changed files with 35 additions and 30 deletions.
34 changes: 17 additions & 17 deletions src/legacy/disks.rs
Original file line number Diff line number Diff line change
Expand Up @@ -81,25 +81,25 @@ fn linux_disks(lib_path: &str) -> Vec<HashMap<String, String>> {
return Vec::new();
}
};
let disks: Vec<&str> = output.lines().collect();
let filtered_disks: Vec<&str> = disks.into_iter().filter(|&disk| !disk.contains("loop")).collect();
let keys_raw = filtered_disks[0].to_lowercase()
.replace("name", "DeviceID")
.replace("model", "Name")
.replace("size", "Size");
let keys: Vec<&str> = keys_raw.split_whitespace().collect();
let mut disk_info = Vec::new();
for line in &filtered_disks[1..] {
let values: Vec<&str> = line.split_whitespace().collect();
let mut disk_map = HashMap::new();
for (key, value) in keys.iter().zip(values.iter()) {
disk_map.insert(key.to_string(), value.to_string());
// Skip the header line
let disks_skipped: Vec<&str> = output.lines().skip(1).collect();
let filtered_disks: Vec<&str> = disks_skipped.into_iter().filter(|&disk| !disk.contains("loop")).collect();
let mut disk_list = Vec::new();
for disk in filtered_disks {
// Split the disk info by whitespace and collect each part
let parts: Vec<&str> = disk.split_whitespace().collect();
// Ensure the disk info has at least 4 parts (NAME, SIZE, TYPE, MODEL)
if parts.len() >= 4 {
let disk_info = HashMap::from([
("Name".to_string(), parts[0].to_string()),
("Size".to_string(), parse_size(parts[1])),
("Type".to_string(), parts[2].to_string()),
("Model".to_string(), parts[3..].join(" ")),
]);
disk_list.push(disk_info);
}
disk_map.insert("Size".to_string(), parse_size(disk_map.get("Size").unwrap()));
disk_map.remove("type");
disk_info.push(disk_map);
}
disk_info
disk_list
}

/// Function to get disk information on macOS.
Expand Down
5 changes: 3 additions & 2 deletions src/templates/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -51,9 +51,10 @@ pub fn get_content() -> String {
footer {
width: 100%;
color: #fff;
text-align: center;
align-content: center
font-size: 10px;
align-content: center;
font-size: 14px;
font-style: italic;
}
</style>
Expand Down
5 changes: 3 additions & 2 deletions src/templates/index.rs
Original file line number Diff line number Diff line change
Expand Up @@ -96,9 +96,10 @@ pub fn get_content() -> String {
footer {
width: 100%;
color: #fff;
text-align: center;
align-content: center
font-size: 10px;
align-content: center;
font-size: 14px;
font-style: italic;
}
</style>
Expand Down
5 changes: 3 additions & 2 deletions src/templates/logout.rs
Original file line number Diff line number Diff line change
Expand Up @@ -49,9 +49,10 @@ pub fn get_content() -> String {
footer {
width: 100%;
color: #fff;
text-align: center;
align-content: center
font-size: 10px;
align-content: center;
font-size: 14px;
font-style: italic;
}
</style>
Expand Down
6 changes: 3 additions & 3 deletions src/templates/monitor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -162,8 +162,8 @@ pub fn get_content() -> String {
footer {
width: 100%;
text-align: center;
align-content: center
font-size: 10px;
align-content: center;
font-size: 14px;
font-style: italic;
}
Expand Down Expand Up @@ -222,7 +222,7 @@ pub fn get_content() -> String {
{% if sys_info_disks %}
<br>
<details>
<summary><strong>Partitions</strong></summary>
<summary><strong>Disk Information</strong></summary>
{% for disk_info in sys_info_disks %}
<br>
{% for key, value in disk_info|items() %}
Expand Down
5 changes: 3 additions & 2 deletions src/templates/session.rs
Original file line number Diff line number Diff line change
Expand Up @@ -52,9 +52,10 @@ pub fn get_content() -> String {
footer {
width: 100%;
color: #fff;
text-align: center;
align-content: center
font-size: 10px;
align-content: center;
font-size: 14px;
font-style: italic;
}
</style>
Expand Down
5 changes: 3 additions & 2 deletions src/templates/unauthorized.rs
Original file line number Diff line number Diff line change
Expand Up @@ -45,9 +45,10 @@ pub fn get_content() -> String {
footer {
width: 100%;
color: #fff;
text-align: center;
align-content: center
font-size: 10px;
align-content: center;
font-size: 14px;
font-style: italic;
}
</style>
Expand Down

0 comments on commit 0fb4fcd

Please sign in to comment.