adding more statuses

This commit is contained in:
Abdenasser 2024-10-31 16:10:50 +01:00
parent 3af2f26178
commit d7cd3bf883
3 changed files with 62 additions and 14 deletions

View File

@ -43,14 +43,18 @@ async fn get_processes(state: State<'_, AppState>) -> Result<Vec<ProcessInfo>, S
.map(|(pid, process)| {
let status = match process.status() {
ProcessStatus::Run => "Running",
ProcessStatus::Sleep => {
if process.cpu_usage() < 0.1 {
"Idle"
} else {
"Sleeping"
}
},
_ => "Unknown"
ProcessStatus::Sleep => "Sleeping",
ProcessStatus::Idle => "Idle",
ProcessStatus::Stop => "Stopped",
ProcessStatus::Zombie => "Zombie",
ProcessStatus::Tracing => "Tracing",
ProcessStatus::Dead => "Dead",
ProcessStatus::Wakekill => "Wake Kill",
ProcessStatus::Waking => "Waking",
ProcessStatus::Parked => "Parked",
ProcessStatus::LockBlocked => "Lock Blocked",
ProcessStatus::UninterruptibleDiskSleep => "Disk Sleep",
ProcessStatus::Unknown(_) => "Unknown"
};
let user = process.user_id()

View File

@ -19,13 +19,12 @@
const itemsPerPageOptions = [25, 50, 100, 250, 500];
let showColumnMenu = false;
const statusOptions = [
{ value: "all", label: "All Statuses" },
{ value: "Running", label: "🏃 Running" },
{ value: "Sleeping", label: "😴 Sleeping" },
{ value: "Idle", label: "⌛ Idle" },
{ value: "Unknown", label: "🫥 Unknown" },
...Object.values(statusMap).map((status) => ({
value: status.label,
label: status.label,
})),
];
function changePage(page: number) {

View File

@ -20,9 +20,54 @@ export const statusMap: Record<string, ProcessStatus> = {
emoji: "⌛",
color: "var(--overlay0)",
},
"Stopped": {
label: "Stopped",
emoji: "🛑",
color: "var(--red)",
},
"Zombie": {
label: "Zombie",
emoji: "🧟",
color: "var(--red)",
},
"Tracing": {
label: "Tracing",
emoji: "🔍",
color: "var(--yellow)",
},
"Dead": {
label: "Dead",
emoji: "💀",
color: "var(--red)",
},
"Wakekill": {
label: "Wake Kill",
emoji: "🔪",
color: "var(--red)",
},
"Waking": {
label: "Waking",
emoji: "🔄",
color: "var(--yellow)",
},
"Parked": {
label: "Parked",
emoji: "🫥",
color: "var(--overlay0)",
},
"LockBlocked": {
label: "Lock Blocked",
emoji: "🔒",
color: "var(--red)",
},
"UninterruptibleDiskSleep": {
label: "Disk Sleep",
emoji: "💤",
color: "var(--overlay0)",
},
"Unknown": {
label: "Unknown",
emoji: "🫥",
emoji: "",
color: "var(--overlay0)",
},
};