diff --git a/src-tauri/src/commands.rs b/src-tauri/src/commands.rs index 3eceec57..fbec6356 100644 --- a/src-tauri/src/commands.rs +++ b/src-tauri/src/commands.rs @@ -181,7 +181,7 @@ pub fn delete_file(path: String) -> Result<(), String> { } #[tauri::command] -pub fn add_pachtop_exclusion(window: tauri::Window) -> Result<(), String> { +pub fn add_pachtop_exclusion(_: tauri::Window) -> Result<(), String> { #[cfg(target_os = "windows")] { let shell = window.app_handle().shell(); diff --git a/src-tauri/src/metrics.rs b/src-tauri/src/metrics.rs index 05aeea34..2608b6fc 100644 --- a/src-tauri/src/metrics.rs +++ b/src-tauri/src/metrics.rs @@ -1,6 +1,7 @@ use crate::models::*; use crate::utils::{current_time, get_percentage}; use base64::prelude::*; +use chrono::prelude::*; use std::cmp::Ordering; use std::collections::HashMap; use std::str::{self}; @@ -29,6 +30,12 @@ impl SystemInformationTrait for Metrics { let hostname = System::host_name().unwrap_or("Unknown".to_string()); let core_count = System::physical_core_count(&self.sys).unwrap_or(0); let os = System::long_os_version().unwrap_or("Unknown".to_string()); + let uptime = Utc + .timestamp(System::uptime() as i64, 0) + .format("%H:%M:%S") + .to_string(); + + let arch = System::cpu_arch().unwrap_or("Unknown".to_string()); SysInfo { kernel_version, @@ -36,6 +43,8 @@ impl SystemInformationTrait for Metrics { os_version, hostname, core_count, + uptime, + arch, } } } diff --git a/src-tauri/src/models.rs b/src-tauri/src/models.rs index 2e676ff8..477121e8 100644 --- a/src-tauri/src/models.rs +++ b/src-tauri/src/models.rs @@ -89,6 +89,8 @@ pub struct SysInfo { pub hostname: String, #[ts(type = "number")] pub core_count: usize, + pub uptime: String, + pub arch: String, } pub trait SystemInformationTrait { diff --git a/src/components/system-information-widget.tsx b/src/components/system-information-widget.tsx index 9c10ff70..590fd004 100644 --- a/src/components/system-information-widget.tsx +++ b/src/components/system-information-widget.tsx @@ -1,12 +1,12 @@ -import { useShallow } from "zustand/react/shallow"; +import { useShallow } from 'zustand/react/shallow'; -import Card from "@/components/card"; -import useGlobalCpuSelectors from "@/features/metrics/stores/global-cpu.store"; -import useMemorySelectors from "@/features/metrics/stores/memory.store"; -import useSwapSelectors from "@/features/metrics/stores/swap.store"; -import useSystemStoreSelectors from "@/features/metrics/stores/system.store"; -import formatBytes from "@/features/metrics/utils/format-bytes"; -import { Grid, Group, Text, Title } from "@mantine/core"; +import Card from '@/components/card'; +import useGlobalCpuSelectors from '@/features/metrics/stores/global-cpu.store'; +import useMemorySelectors from '@/features/metrics/stores/memory.store'; +import useSwapSelectors from '@/features/metrics/stores/swap.store'; +import useSystemStoreSelectors from '@/features/metrics/stores/system.store'; +import formatBytes from '@/features/metrics/utils/format-bytes'; +import { Grid, Group, Text, Title } from '@mantine/core'; const SystemInformationWidget: React.FC = () => { const info = useSystemStoreSelectors(useShallow((state) => state.info)); @@ -17,44 +17,57 @@ const SystemInformationWidget: React.FC = () => { return ( - - + + CPU {cpuBrand} - + OS {info.os} - + + + Arch + + {info.arch} + + CPU cores {info.coreCount} - + Kernel {info.kernelVersion} - + Memory {formatBytes(memory)} - + Swap {formatBytes(swap)} + + + + Uptime + + {info.uptime} + ); diff --git a/src/lib/bindings/SysInfo.ts b/src/lib/bindings/SysInfo.ts index 5e7748c1..08f539d2 100644 --- a/src/lib/bindings/SysInfo.ts +++ b/src/lib/bindings/SysInfo.ts @@ -1,3 +1,3 @@ // This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually. -export type SysInfo = { kernelVersion: string, os: string, osVersion: string, hostname: string, coreCount: number, }; \ No newline at end of file +export type SysInfo = { kernelVersion: string, os: string, osVersion: string, hostname: string, coreCount: number, uptime: string, arch: string, }; \ No newline at end of file