first stable release
10
.gitignore
vendored
Normal file
@ -0,0 +1,10 @@
|
||||
.DS_Store
|
||||
node_modules
|
||||
/build
|
||||
/.svelte-kit
|
||||
/package
|
||||
.env
|
||||
.env.*
|
||||
!.env.example
|
||||
vite.config.js.timestamp-*
|
||||
vite.config.ts.timestamp-*
|
7
.vscode/extensions.json
vendored
Normal file
@ -0,0 +1,7 @@
|
||||
{
|
||||
"recommendations": [
|
||||
"svelte.svelte-vscode",
|
||||
"tauri-apps.tauri-vscode",
|
||||
"rust-lang.rust-analyzer"
|
||||
]
|
||||
}
|
3
.vscode/settings.json
vendored
Normal file
@ -0,0 +1,3 @@
|
||||
{
|
||||
"svelte.enable-ts-plugin": true
|
||||
}
|
7
README.md
Normal file
@ -0,0 +1,7 @@
|
||||
# Tauri + SvelteKit
|
||||
|
||||
This template should help get you started developing with Tauri and SvelteKit in Vite.
|
||||
|
||||
## Recommended IDE Setup
|
||||
|
||||
[VS Code](https://code.visualstudio.com/) + [Svelte](https://marketplace.visualstudio.com/items?itemName=svelte.svelte-vscode) + [Tauri](https://marketplace.visualstudio.com/items?itemName=tauri-apps.tauri-vscode) + [rust-analyzer](https://marketplace.visualstudio.com/items?itemName=rust-lang.rust-analyzer).
|
19
jsconfig.json
Normal file
@ -0,0 +1,19 @@
|
||||
{
|
||||
"extends": "./.svelte-kit/tsconfig.json",
|
||||
"compilerOptions": {
|
||||
"allowJs": true,
|
||||
"checkJs": true,
|
||||
"esModuleInterop": true,
|
||||
"forceConsistentCasingInFileNames": true,
|
||||
"resolveJsonModule": true,
|
||||
"skipLibCheck": true,
|
||||
"sourceMap": true,
|
||||
"strict": true,
|
||||
"moduleResolution": "bundler"
|
||||
}
|
||||
// Path aliases are handled by https://kit.svelte.dev/docs/configuration#alias
|
||||
// except $lib which is handled by https://kit.svelte.dev/docs/configuration#files
|
||||
//
|
||||
// If you want to overwrite includes/excludes, make sure to copy over the relevant includes/excludes
|
||||
// from the referenced tsconfig.json - TypeScript does not merge them in
|
||||
}
|
1711
package-lock.json
generated
Normal file
34
package.json
Normal file
@ -0,0 +1,34 @@
|
||||
{
|
||||
"name": "macos-task-manager",
|
||||
"version": "0.1.0",
|
||||
"description": "",
|
||||
"type": "module",
|
||||
"scripts": {
|
||||
"dev": "vite dev",
|
||||
"build": "vite build",
|
||||
"preview": "vite preview",
|
||||
"check": "svelte-kit sync && svelte-check --tsconfig ./jsconfig.json",
|
||||
"check:watch": "svelte-kit sync && svelte-check --tsconfig ./jsconfig.json --watch",
|
||||
"tauri": "tauri"
|
||||
},
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"@fortawesome/fontawesome-svg-core": "^6.6.0",
|
||||
"@fortawesome/free-regular-svg-icons": "^6.6.0",
|
||||
"@fortawesome/free-solid-svg-icons": "^6.6.0",
|
||||
"@tauri-apps/api": "^2.0.3",
|
||||
"@tauri-apps/plugin-shell": "^2",
|
||||
"lucide-svelte": "^0.454.0",
|
||||
"svelte-fa": "^4.0.3"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@sveltejs/adapter-static": "^3.0.5",
|
||||
"@sveltejs/kit": "^2.7.0",
|
||||
"@sveltejs/vite-plugin-svelte": "^4.0.0",
|
||||
"@tauri-apps/cli": "^2",
|
||||
"svelte": "^5.0.0",
|
||||
"svelte-check": "^4.0.0",
|
||||
"typescript": "^5.5.0",
|
||||
"vite": "^5.4.10"
|
||||
}
|
||||
}
|
7
src-tauri/.gitignore
vendored
Normal file
@ -0,0 +1,7 @@
|
||||
# Generated by Cargo
|
||||
# will have compiled files and executables
|
||||
/target/
|
||||
|
||||
# Generated by Tauri
|
||||
# will have schema files for capabilities auto-completion
|
||||
/gen/schemas
|
4509
src-tauri/Cargo.lock
generated
Normal file
34
src-tauri/Cargo.toml
Normal file
@ -0,0 +1,34 @@
|
||||
[package]
|
||||
name = "macos-task-manager"
|
||||
version = "0.1.0"
|
||||
description = "A Tauri App"
|
||||
authors = ["you"]
|
||||
edition = "2021"
|
||||
|
||||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
||||
|
||||
[lib]
|
||||
# The `_lib` suffix may seem redundant but it is necessary
|
||||
# to make the lib name unique and wouldn't conflict with the bin name.
|
||||
# This seems to be only an issue on Windows, see https://github.com/rust-lang/cargo/issues/8519
|
||||
name = "macos_task_manager_lib"
|
||||
crate-type = ["staticlib", "cdylib", "rlib"]
|
||||
|
||||
[build-dependencies]
|
||||
tauri-build = { version = "2", features = [] }
|
||||
|
||||
[dependencies]
|
||||
tauri = { version = "2", features = [] }
|
||||
tauri-plugin-shell = "2"
|
||||
serde = { version = "1", features = ["derive"] }
|
||||
serde_json = "1"
|
||||
sysinfo = "0.29.0"
|
||||
base64 = "0.21"
|
||||
|
||||
[target.'cfg(target_os = "macos")'.dependencies]
|
||||
cocoa = "0.25"
|
||||
objc = "0.2"
|
||||
objc-foundation = "0.1"
|
||||
|
||||
[target.'cfg(target_os = "windows")'.dependencies]
|
||||
windows = { version = "0.48", features = ["Win32_UI_WindowsAndMessaging", "Win32_Graphics_Gdi"] }
|
3
src-tauri/build.rs
Normal file
@ -0,0 +1,3 @@
|
||||
fn main() {
|
||||
tauri_build::build()
|
||||
}
|
10
src-tauri/capabilities/default.json
Normal file
@ -0,0 +1,10 @@
|
||||
{
|
||||
"$schema": "../gen/schemas/desktop-schema.json",
|
||||
"identifier": "default",
|
||||
"description": "Capability for the main window",
|
||||
"windows": ["main"],
|
||||
"permissions": [
|
||||
"core:default",
|
||||
"shell:allow-open"
|
||||
]
|
||||
}
|
BIN
src-tauri/icons/128x128.png
Normal file
After Width: | Height: | Size: 3.4 KiB |
BIN
src-tauri/icons/128x128@2x.png
Normal file
After Width: | Height: | Size: 6.8 KiB |
BIN
src-tauri/icons/32x32.png
Normal file
After Width: | Height: | Size: 974 B |
BIN
src-tauri/icons/Square107x107Logo.png
Normal file
After Width: | Height: | Size: 2.8 KiB |
BIN
src-tauri/icons/Square142x142Logo.png
Normal file
After Width: | Height: | Size: 3.8 KiB |
BIN
src-tauri/icons/Square150x150Logo.png
Normal file
After Width: | Height: | Size: 3.9 KiB |
BIN
src-tauri/icons/Square284x284Logo.png
Normal file
After Width: | Height: | Size: 7.6 KiB |
BIN
src-tauri/icons/Square30x30Logo.png
Normal file
After Width: | Height: | Size: 903 B |
BIN
src-tauri/icons/Square310x310Logo.png
Normal file
After Width: | Height: | Size: 8.4 KiB |
BIN
src-tauri/icons/Square44x44Logo.png
Normal file
After Width: | Height: | Size: 1.3 KiB |
BIN
src-tauri/icons/Square71x71Logo.png
Normal file
After Width: | Height: | Size: 2.0 KiB |
BIN
src-tauri/icons/Square89x89Logo.png
Normal file
After Width: | Height: | Size: 2.4 KiB |
BIN
src-tauri/icons/StoreLogo.png
Normal file
After Width: | Height: | Size: 1.5 KiB |
BIN
src-tauri/icons/icon.icns
Normal file
BIN
src-tauri/icons/icon.ico
Normal file
After Width: | Height: | Size: 85 KiB |
BIN
src-tauri/icons/icon.png
Normal file
After Width: | Height: | Size: 14 KiB |
14
src-tauri/src/lib.rs
Normal file
@ -0,0 +1,14 @@
|
||||
// Learn more about Tauri commands at https://tauri.app/develop/calling-rust/
|
||||
#[tauri::command]
|
||||
fn greet(name: &str) -> String {
|
||||
format!("Hello, {}! You've been greeted from Rust!", name)
|
||||
}
|
||||
|
||||
#[cfg_attr(mobile, tauri::mobile_entry_point)]
|
||||
pub fn run() {
|
||||
tauri::Builder::default()
|
||||
.plugin(tauri_plugin_shell::init())
|
||||
.invoke_handler(tauri::generate_handler![greet])
|
||||
.run(tauri::generate_context!())
|
||||
.expect("error while running tauri application");
|
||||
}
|
166
src-tauri/src/main.rs
Normal file
@ -0,0 +1,166 @@
|
||||
#![cfg_attr(not(debug_assertions), windows_subsystem = "windows")]
|
||||
|
||||
use sysinfo::{CpuExt, SystemExt, ProcessExt, System, PidExt, ProcessStatus};
|
||||
use tauri::State;
|
||||
use std::sync::Mutex;
|
||||
|
||||
struct AppState {
|
||||
sys: Mutex<System>,
|
||||
}
|
||||
|
||||
#[derive(serde::Serialize)]
|
||||
struct ProcessInfo {
|
||||
pid: u32,
|
||||
ppid: u32,
|
||||
name: String,
|
||||
cpu_usage: f32,
|
||||
memory_usage: u64,
|
||||
status: String,
|
||||
user: String,
|
||||
command: String,
|
||||
threads: Option<u32>,
|
||||
}
|
||||
|
||||
#[derive(serde::Serialize)]
|
||||
struct SystemStats {
|
||||
cpu_usage: Vec<f32>,
|
||||
memory_total: u64,
|
||||
memory_used: u64,
|
||||
uptime: u64,
|
||||
load_avg: [f64; 3],
|
||||
}
|
||||
|
||||
#[tauri::command]
|
||||
async fn get_processes(state: State<'_, AppState>) -> Result<Vec<ProcessInfo>, String> {
|
||||
let mut sys = state.sys.lock().map_err(|_| "Failed to lock system state")?;
|
||||
sys.refresh_all();
|
||||
|
||||
Ok(sys.processes()
|
||||
.iter()
|
||||
.map(|(pid, process)| {
|
||||
let threads = if cfg!(target_os = "macos") {
|
||||
use std::process::Command;
|
||||
Command::new("ps")
|
||||
.args(["-o", "thcount=", "-p", &pid.as_u32().to_string()])
|
||||
.output()
|
||||
.ok()
|
||||
.and_then(|output| {
|
||||
String::from_utf8(output.stdout)
|
||||
.ok()
|
||||
.and_then(|s| s.trim().parse().ok())
|
||||
})
|
||||
} else {
|
||||
None
|
||||
};
|
||||
|
||||
let status = match process.status() {
|
||||
ProcessStatus::Run => "R", // Running
|
||||
ProcessStatus::Sleep => "S", // Sleeping
|
||||
ProcessStatus::Idle => "I", // Idle
|
||||
ProcessStatus::Zombie => "Z", // Zombie
|
||||
ProcessStatus::Stop => "T", // Stopped
|
||||
ProcessStatus::Dead => "X", // Dead
|
||||
_ => "Unknown",
|
||||
};
|
||||
|
||||
ProcessInfo {
|
||||
pid: pid.as_u32(),
|
||||
ppid: process.parent().unwrap_or(sysinfo::Pid::from(0)).as_u32(),
|
||||
name: process.name().to_string(),
|
||||
cpu_usage: process.cpu_usage(),
|
||||
memory_usage: process.memory(),
|
||||
status: status.to_string(),
|
||||
user: process.user_id()
|
||||
.map(|uid| uid.to_string())
|
||||
.unwrap_or_else(|| "-".to_string()),
|
||||
command: process.cmd().join(" "),
|
||||
threads,
|
||||
}
|
||||
})
|
||||
.collect())
|
||||
}
|
||||
|
||||
#[tauri::command]
|
||||
async fn get_system_stats(state: State<'_, AppState>) -> Result<SystemStats, String> {
|
||||
let mut sys = state.sys.lock().map_err(|_| "Failed to lock system state")?;
|
||||
sys.refresh_all();
|
||||
|
||||
let load_avg = sys.load_average();
|
||||
Ok(SystemStats {
|
||||
cpu_usage: sys.cpus().iter().map(|cpu| cpu.cpu_usage()).collect(),
|
||||
memory_total: sys.total_memory(),
|
||||
memory_used: sys.used_memory(),
|
||||
uptime: sys.uptime(),
|
||||
load_avg: [load_avg.one, load_avg.five, load_avg.fifteen],
|
||||
})
|
||||
}
|
||||
|
||||
#[tauri::command]
|
||||
async fn kill_process(pid: u32, state: State<'_, AppState>) -> Result<bool, String> {
|
||||
let sys = state.sys.lock().map_err(|_| "Failed to lock system state")?;
|
||||
if let Some(process) = sys.process(sysinfo::Pid::from(pid as usize)) {
|
||||
Ok(process.kill())
|
||||
} else {
|
||||
Ok(false)
|
||||
}
|
||||
}
|
||||
|
||||
#[tauri::command]
|
||||
async fn process_stop(pid: u32, state: State<'_, AppState>) -> Result<bool, String> {
|
||||
let sys = state.sys.lock().map_err(|_| "Failed to lock system state")?;
|
||||
if let Some(_process) = sys.process(sysinfo::Pid::from(pid as usize)) {
|
||||
#[cfg(target_os = "macos")]
|
||||
{
|
||||
use std::process::Command;
|
||||
Command::new("kill")
|
||||
.args(["-STOP", &pid.to_string()])
|
||||
.status()
|
||||
.map_err(|e| e.to_string())?;
|
||||
Ok(true)
|
||||
}
|
||||
#[cfg(not(target_os = "macos"))]
|
||||
{
|
||||
Ok(false)
|
||||
}
|
||||
} else {
|
||||
Ok(false)
|
||||
}
|
||||
}
|
||||
|
||||
#[tauri::command]
|
||||
async fn process_continue(pid: u32, state: State<'_, AppState>) -> Result<bool, String> {
|
||||
let sys = state.sys.lock().map_err(|_| "Failed to lock system state")?;
|
||||
if let Some(_process) = sys.process(sysinfo::Pid::from(pid as usize)) {
|
||||
#[cfg(target_os = "macos")]
|
||||
{
|
||||
use std::process::Command;
|
||||
Command::new("kill")
|
||||
.args(["-CONT", &pid.to_string()])
|
||||
.status()
|
||||
.map_err(|e| e.to_string())?;
|
||||
Ok(true)
|
||||
}
|
||||
#[cfg(not(target_os = "macos"))]
|
||||
{
|
||||
Ok(false)
|
||||
}
|
||||
} else {
|
||||
Ok(false)
|
||||
}
|
||||
}
|
||||
|
||||
fn main() {
|
||||
tauri::Builder::default()
|
||||
.manage(AppState {
|
||||
sys: Mutex::new(System::new_all()),
|
||||
})
|
||||
.invoke_handler(tauri::generate_handler![
|
||||
get_processes,
|
||||
get_system_stats,
|
||||
kill_process,
|
||||
process_stop,
|
||||
process_continue
|
||||
])
|
||||
.run(tauri::generate_context!())
|
||||
.expect("error while running tauri application");
|
||||
}
|
38
src-tauri/tauri.conf.json
Normal file
@ -0,0 +1,38 @@
|
||||
{
|
||||
"$schema": "https://schema.tauri.app/config/2",
|
||||
"productName": "NeoHtop",
|
||||
"version": "0.1.0",
|
||||
"identifier": "com.neohtop.app",
|
||||
"build": {
|
||||
"beforeDevCommand": "npm run dev",
|
||||
"devUrl": "http://localhost:1420",
|
||||
"beforeBuildCommand": "npm run build",
|
||||
"frontendDist": "../build"
|
||||
},
|
||||
"app": {
|
||||
"windows": [
|
||||
{
|
||||
"title": "NeoHtop",
|
||||
"width": 1280,
|
||||
"height": 800,
|
||||
"minWidth": 1180,
|
||||
"minHeight": 600,
|
||||
"resizable": true
|
||||
}
|
||||
],
|
||||
"security": {
|
||||
"csp": null
|
||||
}
|
||||
},
|
||||
"bundle": {
|
||||
"active": true,
|
||||
"targets": "all",
|
||||
"icon": [
|
||||
"icons/32x32.png",
|
||||
"icons/128x128.png",
|
||||
"icons/128x128@2x.png",
|
||||
"icons/icon.icns",
|
||||
"icons/icon.ico"
|
||||
]
|
||||
}
|
||||
}
|
1832
src/App.svelte
Normal file
65
src/app.css
Normal file
@ -0,0 +1,65 @@
|
||||
:root {
|
||||
/* Default theme values will be overridden by theme store */
|
||||
--base: #1e1e2e;
|
||||
--mantle: #181825;
|
||||
--crust: #11111b;
|
||||
--text: #cdd6f4;
|
||||
--subtext0: #a6adc8;
|
||||
--subtext1: #bac2de;
|
||||
--surface0: #313244;
|
||||
--surface1: #45475a;
|
||||
--surface2: #585b70;
|
||||
--overlay0: #6c7086;
|
||||
--overlay1: #7f849c;
|
||||
--blue: #89b4fa;
|
||||
--lavender: #b4befe;
|
||||
--sapphire: #74c7ec;
|
||||
--sky: #89dceb;
|
||||
--red: #f38ba8;
|
||||
--maroon: #eba0ac;
|
||||
--peach: #fab387;
|
||||
--yellow: #f9e2af;
|
||||
--green: #a6e3a1;
|
||||
--teal: #94e2d5;
|
||||
}
|
||||
|
||||
body {
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
font-family: -apple-system, BlinkMacSystemFont, sans-serif;
|
||||
background-color: var(--base);
|
||||
color: var(--text);
|
||||
-webkit-font-smoothing: antialiased;
|
||||
overflow: hidden;
|
||||
user-select: none;
|
||||
}
|
||||
|
||||
/* Global scrollbar styles */
|
||||
* {
|
||||
scrollbar-width: thin;
|
||||
scrollbar-color: var(--surface2) var(--mantle);
|
||||
}
|
||||
|
||||
::-webkit-scrollbar {
|
||||
width: 8px;
|
||||
height: 8px;
|
||||
}
|
||||
|
||||
::-webkit-scrollbar-track {
|
||||
background: var(--mantle);
|
||||
border-radius: 4px;
|
||||
}
|
||||
|
||||
::-webkit-scrollbar-thumb {
|
||||
background: var(--surface2);
|
||||
border-radius: 4px;
|
||||
transition: background 0.2s ease;
|
||||
}
|
||||
|
||||
::-webkit-scrollbar-thumb:hover {
|
||||
background: var(--surface1);
|
||||
}
|
||||
|
||||
::-webkit-scrollbar-corner {
|
||||
background: var(--mantle);
|
||||
}
|
16
src/app.html
Normal file
@ -0,0 +1,16 @@
|
||||
<!doctype html>
|
||||
<html lang="en">
|
||||
|
||||
<head>
|
||||
<meta charset="utf-8" />
|
||||
<link rel="icon" href="%sveltekit.assets%/favicon.png" />
|
||||
<meta name="viewport" content="width=device-width" />
|
||||
<title>NeoHtop</title>
|
||||
%sveltekit.head%
|
||||
</head>
|
||||
|
||||
<body data-sveltekit-preload-data="hover">
|
||||
<div style="display: contents">%sveltekit.body%</div>
|
||||
</body>
|
||||
|
||||
</html>
|
189
src/lib/components/AppInfo.svelte
Normal file
@ -0,0 +1,189 @@
|
||||
<script lang="ts">
|
||||
import { getVersion } from "@tauri-apps/api/app";
|
||||
import { onMount } from "svelte";
|
||||
import ThemeSwitcher from "./ThemeSwitcher.svelte";
|
||||
import { faInfo } from "@fortawesome/free-solid-svg-icons";
|
||||
import Fa from "svelte-fa";
|
||||
|
||||
let version = "";
|
||||
let showInfo = false;
|
||||
|
||||
const ASCII_ART = `
|
||||
███╗ ██╗███████╗ ██████╗ ██╗ ██╗████████╗ ██████╗ ██████╗
|
||||
████╗ ██║██╔════╝██╔═══██╗██║ ██║╚══██╔══╝██╔═══██╗██╔══██╗
|
||||
██╔██╗ ██║█████╗ ██║ ██║███████║ ██║ ██║ ██║██████╔╝
|
||||
██║╚██╗██║██╔══╝ ██║ ██║██╔══██║ ██║ ██║ ██║██╔═══╝
|
||||
██║ ╚████║███████╗╚██████╔╝██║ ██║ ██║ ╚██████╔╝██║
|
||||
╚═╝ ╚═══╝╚══════╝ ╚═════╝ ╚═╝ ╚═╝ ╚═╝ ╚═════╝ ╚═╝
|
||||
`;
|
||||
|
||||
const APP_INFO = {
|
||||
name: "NeoHtop",
|
||||
developer: "Abdenasser",
|
||||
github: "https://github.com/abdenasser",
|
||||
stack: ["Tauri", "Rust", "Svelte", "TypeScript"],
|
||||
};
|
||||
|
||||
onMount(async () => {
|
||||
version = await getVersion();
|
||||
});
|
||||
</script>
|
||||
|
||||
<div class="app-info">
|
||||
<ThemeSwitcher />
|
||||
<button
|
||||
class="info-button"
|
||||
on:click={() => (showInfo = !showInfo)}
|
||||
aria-label="Toggle app info"
|
||||
>
|
||||
<span class="icon">
|
||||
<Fa icon={faInfo} />
|
||||
</span>
|
||||
</button>
|
||||
|
||||
{#if showInfo}
|
||||
<div class="info-panel" on:mouseleave={() => (showInfo = false)}>
|
||||
<div class="info-content">
|
||||
<pre class="ascii-art">{ASCII_ART}</pre>
|
||||
<div class="details">
|
||||
<div class="detail-row">
|
||||
<span>NeoHtop v{version}</span>
|
||||
</div>
|
||||
<div class="detail-row">
|
||||
<span class="label">app</span>
|
||||
<span class="separator">::</span>
|
||||
<span class="value">{APP_INFO.name}</span>
|
||||
</div>
|
||||
<div class="detail-row">
|
||||
<span class="label">developer</span>
|
||||
<span class="separator">::</span>
|
||||
<span class="value">{APP_INFO.github}</span>
|
||||
</div>
|
||||
<div class="detail-row">
|
||||
<span class="label">stack</span>
|
||||
<span class="separator">::</span>
|
||||
<span class="value">{APP_INFO.stack.join(", ")}</span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
{/if}
|
||||
</div>
|
||||
|
||||
<style>
|
||||
.app-info {
|
||||
display: flex;
|
||||
gap: 8px;
|
||||
position: relative;
|
||||
}
|
||||
|
||||
.info-button,
|
||||
:global(.theme-button) {
|
||||
height: 31px;
|
||||
padding: 6px 12px;
|
||||
font-size: 12px;
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
color: var(--text);
|
||||
background: var(--surface0);
|
||||
border: 1px solid var(--surface1);
|
||||
border-radius: 6px;
|
||||
cursor: pointer;
|
||||
transition: all 0.2s ease;
|
||||
}
|
||||
|
||||
.info-button:hover,
|
||||
:global(.theme-button:hover) {
|
||||
background: var(--surface1);
|
||||
}
|
||||
|
||||
.icon {
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
font-size: 10px;
|
||||
color: var(--subtext0);
|
||||
}
|
||||
|
||||
.info-panel {
|
||||
position: absolute;
|
||||
top: 100%;
|
||||
right: 0;
|
||||
margin-top: 4px;
|
||||
padding: 16px;
|
||||
background: var(--base);
|
||||
border: 1px solid var(--surface0);
|
||||
border-radius: 6px;
|
||||
box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
|
||||
z-index: 100;
|
||||
min-width: 400px;
|
||||
}
|
||||
|
||||
.info-content {
|
||||
display: flex;
|
||||
gap: 24px;
|
||||
}
|
||||
|
||||
.ascii-art {
|
||||
font-family: monospace;
|
||||
font-size: 8px;
|
||||
line-height: 1;
|
||||
color: var(--mauve);
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
white-space: pre;
|
||||
}
|
||||
|
||||
.details {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 8px;
|
||||
padding: 8px 0;
|
||||
}
|
||||
|
||||
.detail-row {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 8px;
|
||||
font-family: monospace;
|
||||
font-size: 13px;
|
||||
}
|
||||
|
||||
.label {
|
||||
color: var(--green);
|
||||
min-width: 80px;
|
||||
}
|
||||
|
||||
.separator {
|
||||
color: var(--subtext0);
|
||||
}
|
||||
|
||||
.value {
|
||||
color: var(--text);
|
||||
}
|
||||
|
||||
.link {
|
||||
color: var(--blue);
|
||||
text-decoration: none;
|
||||
transition: color 0.2s ease;
|
||||
}
|
||||
|
||||
.link:hover {
|
||||
color: var(--sky);
|
||||
text-decoration: underline;
|
||||
}
|
||||
|
||||
.detail-row span {
|
||||
color: var(--text);
|
||||
font-weight: 500;
|
||||
}
|
||||
|
||||
a {
|
||||
color: var(--blue);
|
||||
text-decoration: none;
|
||||
}
|
||||
|
||||
a:hover {
|
||||
text-decoration: underline;
|
||||
}
|
||||
</style>
|
119
src/lib/components/KillProcessModal.svelte
Normal file
@ -0,0 +1,119 @@
|
||||
<script lang="ts">
|
||||
import Modal from "./Modal.svelte";
|
||||
|
||||
interface Process {
|
||||
pid: number;
|
||||
name: string;
|
||||
}
|
||||
|
||||
export let show = false;
|
||||
export let process: Process | null = null;
|
||||
export let onClose: () => void;
|
||||
export let onConfirm: () => Promise<void>;
|
||||
export let isKilling = false;
|
||||
</script>
|
||||
|
||||
<Modal {show} title="Confirm Action" maxWidth="400px" {onClose}>
|
||||
{#if process}
|
||||
<div class="confirm-content">
|
||||
<p class="confirm-message">Are you sure you want to end this process?</p>
|
||||
<div class="process-info">
|
||||
<span class="process-name">{process.name}</span>
|
||||
<span class="process-pid">(PID: {process.pid})</span>
|
||||
</div>
|
||||
<div class="confirm-actions">
|
||||
<button class="btn-secondary" on:click={onClose} disabled={isKilling}>
|
||||
Cancel
|
||||
</button>
|
||||
<button class="btn-danger" on:click={onConfirm} disabled={isKilling}>
|
||||
{#if isKilling}
|
||||
<div class="spinner" />
|
||||
<span>Ending...</span>
|
||||
{:else}
|
||||
End Process
|
||||
{/if}
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
{/if}
|
||||
</Modal>
|
||||
|
||||
<style>
|
||||
.confirm-content {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 16px;
|
||||
}
|
||||
|
||||
.confirm-message {
|
||||
color: var(--text);
|
||||
margin: 0;
|
||||
font-size: 14px;
|
||||
}
|
||||
|
||||
.process-info {
|
||||
background: var(--mantle);
|
||||
padding: 12px;
|
||||
border-radius: 6px;
|
||||
}
|
||||
|
||||
.process-name {
|
||||
color: var(--text);
|
||||
font-weight: 500;
|
||||
font-size: 14px;
|
||||
}
|
||||
|
||||
.process-pid {
|
||||
color: var(--subtext0);
|
||||
font-size: 12px;
|
||||
margin-left: 8px;
|
||||
}
|
||||
|
||||
.confirm-actions {
|
||||
display: flex;
|
||||
justify-content: flex-end;
|
||||
gap: 12px;
|
||||
}
|
||||
|
||||
.btn-secondary {
|
||||
padding: 8px 16px;
|
||||
font-size: 13px;
|
||||
color: var(--text);
|
||||
background: var(--surface0);
|
||||
border: 1px solid var(--surface1);
|
||||
border-radius: 6px;
|
||||
cursor: pointer;
|
||||
transition: all 0.2s ease;
|
||||
}
|
||||
|
||||
.btn-secondary:hover {
|
||||
background: var(--surface1);
|
||||
}
|
||||
|
||||
.btn-danger {
|
||||
padding: 8px 16px;
|
||||
font-size: 13px;
|
||||
color: var(--base);
|
||||
background: var(--red);
|
||||
border: none;
|
||||
border-radius: 6px;
|
||||
cursor: pointer;
|
||||
transition: all 0.2s ease;
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
gap: 8px;
|
||||
}
|
||||
|
||||
.btn-danger:disabled {
|
||||
opacity: 0.7;
|
||||
cursor: not-allowed;
|
||||
}
|
||||
|
||||
.btn-danger:hover {
|
||||
background: color-mix(in srgb, var(--red) 90%, white);
|
||||
}
|
||||
|
||||
.spinner {
|
||||
width: 16px;
|
||||
}
|
||||
</style>
|
76
src/lib/components/Modal.svelte
Normal file
@ -0,0 +1,76 @@
|
||||
<script lang="ts">
|
||||
export let show = false;
|
||||
export let maxWidth = "600px";
|
||||
export let title: string;
|
||||
export let onClose: () => void;
|
||||
</script>
|
||||
|
||||
{#if show}
|
||||
<div class="modal-backdrop" on:click={onClose}>
|
||||
<div class="modal" on:click|stopPropagation style="--max-width: {maxWidth}">
|
||||
<div class="modal-header">
|
||||
<h2>{title}</h2>
|
||||
<button class="btn-close" on:click={onClose}>×</button>
|
||||
</div>
|
||||
<div class="modal-content">
|
||||
<slot />
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
{/if}
|
||||
|
||||
<style>
|
||||
.modal-backdrop {
|
||||
position: fixed;
|
||||
top: 0;
|
||||
left: 0;
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
background: rgba(0, 0, 0, 0.5);
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
z-index: 1000;
|
||||
}
|
||||
|
||||
.modal {
|
||||
background: var(--base);
|
||||
border-radius: 8px;
|
||||
width: 100%;
|
||||
max-width: var(--max-width);
|
||||
max-height: 90vh;
|
||||
overflow: auto;
|
||||
box-shadow: 0 8px 32px rgba(0, 0, 0, 0.4);
|
||||
}
|
||||
|
||||
.modal-header {
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
align-items: center;
|
||||
padding: 16px;
|
||||
border-bottom: 1px solid var(--surface0);
|
||||
}
|
||||
|
||||
.modal-header h2 {
|
||||
margin: 0;
|
||||
font-size: 18px;
|
||||
color: var(--text);
|
||||
}
|
||||
|
||||
.btn-close {
|
||||
background: transparent;
|
||||
border: none;
|
||||
color: var(--overlay0);
|
||||
font-size: 24px;
|
||||
cursor: pointer;
|
||||
padding: 4px 8px;
|
||||
}
|
||||
|
||||
.btn-close:hover {
|
||||
color: var(--text);
|
||||
}
|
||||
|
||||
.modal-content {
|
||||
padding: 16px;
|
||||
}
|
||||
</style>
|
102
src/lib/components/ProcessDetailsModal.svelte
Normal file
@ -0,0 +1,102 @@
|
||||
<script lang="ts">
|
||||
import Modal from "./Modal.svelte";
|
||||
import { formatStatus } from "$lib/utils/processStatus";
|
||||
|
||||
interface Process {
|
||||
pid: number;
|
||||
ppid: number;
|
||||
name: string;
|
||||
cpu_usage: number;
|
||||
memory_usage: number;
|
||||
status: string;
|
||||
user: string;
|
||||
command: string;
|
||||
threads?: number;
|
||||
}
|
||||
|
||||
export let show = false;
|
||||
export let process: Process | null = null;
|
||||
export let onClose: () => void;
|
||||
|
||||
function formatMemory(bytes: number) {
|
||||
return (bytes / (1024 * 1024)).toFixed(1) + " MB";
|
||||
}
|
||||
</script>
|
||||
|
||||
<Modal {show} title="Process Details" maxWidth="500px" {onClose}>
|
||||
{#if process}
|
||||
<div class="process-details">
|
||||
<div class="detail-row">
|
||||
<span class="detail-label">Name:</span>
|
||||
<span class="detail-value">{process.name}</span>
|
||||
</div>
|
||||
<div class="detail-row">
|
||||
<span class="detail-label">PID:</span>
|
||||
<span class="detail-value">{process.pid}</span>
|
||||
</div>
|
||||
<div class="detail-row">
|
||||
<span class="detail-label">Parent PID:</span>
|
||||
<span class="detail-value">{process.ppid}</span>
|
||||
</div>
|
||||
<div class="detail-row">
|
||||
<span class="detail-label">User:</span>
|
||||
<span class="detail-value">{process.user}</span>
|
||||
</div>
|
||||
<div class="detail-row">
|
||||
<span class="detail-label">Status:</span>
|
||||
<span class="detail-value">
|
||||
{@html formatStatus(process.status)}
|
||||
</span>
|
||||
</div>
|
||||
<div class="detail-row">
|
||||
<span class="detail-label">CPU Usage:</span>
|
||||
<span class="detail-value">{process.cpu_usage.toFixed(1)}%</span>
|
||||
</div>
|
||||
<div class="detail-row">
|
||||
<span class="detail-label">Memory Usage:</span>
|
||||
<span class="detail-value">{formatMemory(process.memory_usage)}</span>
|
||||
</div>
|
||||
<div class="detail-row">
|
||||
<span class="detail-label">Command:</span>
|
||||
<span class="detail-value command">{process.command}</span>
|
||||
</div>
|
||||
</div>
|
||||
{/if}
|
||||
</Modal>
|
||||
|
||||
<style>
|
||||
.process-details {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 12px;
|
||||
}
|
||||
|
||||
.detail-row {
|
||||
display: flex;
|
||||
gap: 12px;
|
||||
padding: 8px;
|
||||
border-radius: 4px;
|
||||
}
|
||||
|
||||
.detail-row:nth-child(odd) {
|
||||
background: var(--surface0);
|
||||
}
|
||||
|
||||
.detail-label {
|
||||
flex: 0 0 120px;
|
||||
color: var(--subtext0);
|
||||
font-weight: 500;
|
||||
}
|
||||
|
||||
.detail-value {
|
||||
flex: 1;
|
||||
font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas,
|
||||
monospace;
|
||||
word-break: break-all;
|
||||
}
|
||||
|
||||
.detail-value.command {
|
||||
font-size: 12px;
|
||||
color: var(--subtext1);
|
||||
}
|
||||
</style>
|
374
src/lib/components/ProcessTable.svelte
Normal file
@ -0,0 +1,374 @@
|
||||
<script lang="ts">
|
||||
import {
|
||||
faThumbtack,
|
||||
faInfoCircle,
|
||||
faXmark,
|
||||
} from "@fortawesome/free-solid-svg-icons";
|
||||
import Fa from "svelte-fa";
|
||||
|
||||
interface Process {
|
||||
pid: number;
|
||||
ppid: number;
|
||||
name: string;
|
||||
cpu_usage: number;
|
||||
memory_usage: number;
|
||||
status:
|
||||
| "Running"
|
||||
| "Sleeping"
|
||||
| "Idle"
|
||||
| "Zombie"
|
||||
| "Unknown"
|
||||
| "Stop"
|
||||
| string;
|
||||
user: string;
|
||||
command: string;
|
||||
threads?: number;
|
||||
}
|
||||
|
||||
interface Column {
|
||||
id: keyof Process;
|
||||
label: string;
|
||||
visible: boolean;
|
||||
required?: boolean;
|
||||
format?: (value: any) => string;
|
||||
}
|
||||
|
||||
export let processes: Process[];
|
||||
export let columns: Column[];
|
||||
export let systemStats: { memory_total: number } | null;
|
||||
export let sortConfig: { field: keyof Process; direction: "asc" | "desc" };
|
||||
export let pinnedProcesses: Set<number>;
|
||||
|
||||
export let onToggleSort: (field: keyof Process) => void;
|
||||
export let onTogglePin: (pid: number) => void;
|
||||
export let onShowDetails: (process: Process) => void;
|
||||
export let onKillProcess: (process: Process) => void;
|
||||
|
||||
function getSortIndicator(field: keyof Process) {
|
||||
if (sortConfig.field !== field) return "↕";
|
||||
return sortConfig.direction === "asc" ? "↑" : "↓";
|
||||
}
|
||||
</script>
|
||||
|
||||
<div class="table-container">
|
||||
<table>
|
||||
<thead>
|
||||
<tr>
|
||||
{#each columns.filter((col) => col.visible) as column}
|
||||
<th class="sortable" on:click={() => onToggleSort(column.id)}>
|
||||
<div class="th-content">
|
||||
{column.label}
|
||||
<span
|
||||
class="sort-indicator"
|
||||
class:active={sortConfig.field === column.id}
|
||||
>
|
||||
{getSortIndicator(column.id)}
|
||||
</span>
|
||||
</div>
|
||||
</th>
|
||||
{/each}
|
||||
<th>Actions</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
{#each processes as process (process.pid)}
|
||||
<tr
|
||||
class:high-usage={process.cpu_usage > 50 ||
|
||||
process.memory_usage / (systemStats?.memory_total || 0) > 0.1}
|
||||
class:pinned={pinnedProcesses.has(process.pid)}
|
||||
>
|
||||
{#each columns.filter((col) => col.visible) as column}
|
||||
<td class="truncate">
|
||||
{#if column.format}
|
||||
{@html column.format(process[column.id])}
|
||||
{:else}
|
||||
{process[column.id]}
|
||||
{/if}
|
||||
</td>
|
||||
{/each}
|
||||
<td class="col-actions">
|
||||
<div class="action-buttons">
|
||||
<button
|
||||
class="btn-action pin-btn"
|
||||
class:pinned={pinnedProcesses.has(process.pid)}
|
||||
on:click={() => onTogglePin(process.pid)}
|
||||
title={pinnedProcesses.has(process.pid) ? "Unpin" : "Pin"}
|
||||
>
|
||||
<Fa icon={faThumbtack} />
|
||||
</button>
|
||||
<button
|
||||
class="btn-action info-btn"
|
||||
on:click={() => onShowDetails(process)}
|
||||
title="Show Details"
|
||||
>
|
||||
<Fa icon={faInfoCircle} />
|
||||
</button>
|
||||
<button
|
||||
class="btn-action kill-btn"
|
||||
on:click={() => onKillProcess(process)}
|
||||
title="End Process"
|
||||
>
|
||||
<Fa icon={faXmark} />
|
||||
</button>
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
{/each}
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
|
||||
<style>
|
||||
.table-container {
|
||||
flex: 1;
|
||||
overflow-x: auto;
|
||||
overflow-y: auto;
|
||||
|
||||
/* Scrollbar styles */
|
||||
scrollbar-width: thin; /* Firefox */
|
||||
scrollbar-color: var(--surface2) var(--mantle); /* Firefox */
|
||||
}
|
||||
|
||||
/* Webkit scrollbar styles (Chrome, Safari, Edge) */
|
||||
.table-container::-webkit-scrollbar {
|
||||
width: 8px;
|
||||
height: 8px;
|
||||
}
|
||||
|
||||
.table-container::-webkit-scrollbar-track {
|
||||
background: var(--mantle);
|
||||
border-radius: 4px;
|
||||
}
|
||||
|
||||
.table-container::-webkit-scrollbar-thumb {
|
||||
background: var(--surface2);
|
||||
border-radius: 4px;
|
||||
transition: background 0.2s ease;
|
||||
}
|
||||
|
||||
.table-container::-webkit-scrollbar-thumb:hover {
|
||||
background: var(--surface1);
|
||||
}
|
||||
|
||||
.table-container::-webkit-scrollbar-corner {
|
||||
background: var(--mantle);
|
||||
}
|
||||
|
||||
/* When both scrollbars are present, add some padding to prevent overlap */
|
||||
.table-container::-webkit-scrollbar-corner {
|
||||
background-color: var(--mantle);
|
||||
}
|
||||
|
||||
table {
|
||||
width: max-content;
|
||||
min-width: 100%;
|
||||
table-layout: fixed;
|
||||
border-collapse: collapse;
|
||||
font-size: 13px;
|
||||
}
|
||||
|
||||
th {
|
||||
position: sticky;
|
||||
top: 0;
|
||||
background: var(--mantle);
|
||||
text-align: left;
|
||||
padding: 8px 12px;
|
||||
font-weight: 500;
|
||||
color: var(--subtext0);
|
||||
border-bottom: 1px solid var(--surface0);
|
||||
transition: background-color 0.2s ease;
|
||||
z-index: 3;
|
||||
}
|
||||
|
||||
td {
|
||||
padding: 6px 12px;
|
||||
border-bottom: 1px solid var(--surface0);
|
||||
color: var(--text);
|
||||
z-index: 1;
|
||||
}
|
||||
|
||||
tr:hover {
|
||||
background-color: var(--surface0);
|
||||
}
|
||||
|
||||
.truncate {
|
||||
white-space: nowrap;
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
max-width: 0;
|
||||
}
|
||||
|
||||
.sortable {
|
||||
cursor: pointer;
|
||||
user-select: none;
|
||||
}
|
||||
|
||||
.th-content {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 8px;
|
||||
}
|
||||
|
||||
.sort-indicator {
|
||||
color: var(--overlay0);
|
||||
font-size: 12px;
|
||||
opacity: 0.5;
|
||||
transition: all 0.2s ease;
|
||||
}
|
||||
|
||||
.sort-indicator.active {
|
||||
color: var(--blue);
|
||||
opacity: 1;
|
||||
}
|
||||
|
||||
.sortable:hover .sort-indicator {
|
||||
opacity: 1;
|
||||
}
|
||||
|
||||
.high-usage {
|
||||
background-color: color-mix(in srgb, var(--red) 10%, transparent);
|
||||
}
|
||||
|
||||
.high-usage:hover {
|
||||
background-color: color-mix(in srgb, var(--red) 15%, transparent);
|
||||
}
|
||||
|
||||
tr.pinned {
|
||||
background-color: color-mix(in srgb, var(--blue) 10%, transparent);
|
||||
}
|
||||
|
||||
tr.pinned:hover {
|
||||
background-color: color-mix(in srgb, var(--blue) 15%, transparent);
|
||||
}
|
||||
|
||||
th:last-child {
|
||||
width: 120px;
|
||||
min-width: 120px;
|
||||
max-width: 120px;
|
||||
}
|
||||
|
||||
td:last-child {
|
||||
width: 120px;
|
||||
min-width: 120px;
|
||||
max-width: 120px;
|
||||
padding: 6px 8px;
|
||||
}
|
||||
|
||||
.col-actions {
|
||||
position: sticky;
|
||||
right: 0;
|
||||
z-index: 2;
|
||||
background: var(--base);
|
||||
border-left: 1px solid var(--surface0);
|
||||
width: 120px;
|
||||
}
|
||||
|
||||
.action-buttons {
|
||||
display: flex;
|
||||
gap: 4px;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
}
|
||||
|
||||
.btn-action {
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
border: none;
|
||||
cursor: pointer;
|
||||
background: transparent;
|
||||
border-radius: 6px;
|
||||
width: 28px;
|
||||
height: 28px;
|
||||
transition: all 0.2s ease;
|
||||
position: relative;
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
.btn-action::before {
|
||||
content: "";
|
||||
position: absolute;
|
||||
inset: 0;
|
||||
opacity: 0.1;
|
||||
transition: opacity 0.2s ease;
|
||||
}
|
||||
|
||||
.btn-action:hover::before {
|
||||
opacity: 0.15;
|
||||
}
|
||||
|
||||
.pin-btn {
|
||||
color: var(--sapphire);
|
||||
}
|
||||
|
||||
.pin-btn::before {
|
||||
background: var(--sapphire);
|
||||
}
|
||||
|
||||
.pin-btn.pinned {
|
||||
color: var(--blue);
|
||||
transform: rotate(45deg);
|
||||
}
|
||||
|
||||
.pin-btn.pinned::before {
|
||||
background: var(--blue);
|
||||
opacity: 0.15;
|
||||
}
|
||||
|
||||
.info-btn {
|
||||
color: var(--lavender);
|
||||
}
|
||||
|
||||
.info-btn::before {
|
||||
background: var(--lavender);
|
||||
}
|
||||
|
||||
.kill-btn {
|
||||
color: var(--red);
|
||||
border: 1px solid color-mix(in srgb, var(--red) 30%, transparent);
|
||||
}
|
||||
|
||||
.kill-btn::before {
|
||||
background: var(--red);
|
||||
}
|
||||
|
||||
.kill-btn:hover {
|
||||
color: var(--base);
|
||||
background: var(--red);
|
||||
}
|
||||
|
||||
.kill-btn:hover::before {
|
||||
opacity: 1;
|
||||
}
|
||||
|
||||
.btn-action:hover {
|
||||
box-shadow: 0 0 12px color-mix(in srgb, currentColor 20%, transparent);
|
||||
}
|
||||
|
||||
.btn-action:active {
|
||||
transform: translateY(1px);
|
||||
}
|
||||
|
||||
.pin-btn.pinned:active {
|
||||
transform: rotate(45deg) translateY(1px);
|
||||
}
|
||||
|
||||
.btn-action:focus {
|
||||
outline: none;
|
||||
box-shadow: 0 0 0 2px color-mix(in srgb, currentColor 30%, transparent);
|
||||
}
|
||||
|
||||
.btn-action:disabled {
|
||||
opacity: 0.5;
|
||||
cursor: not-allowed;
|
||||
}
|
||||
|
||||
.btn-action:disabled:hover {
|
||||
transform: none;
|
||||
box-shadow: none;
|
||||
}
|
||||
|
||||
.btn-action:disabled::before {
|
||||
display: none;
|
||||
}
|
||||
</style>
|
292
src/lib/components/StatsBar.svelte
Normal file
@ -0,0 +1,292 @@
|
||||
<script lang="ts">
|
||||
import Fa from "svelte-fa";
|
||||
import {
|
||||
faMicrochip,
|
||||
faMemory,
|
||||
faServer,
|
||||
} from "@fortawesome/free-solid-svg-icons";
|
||||
|
||||
interface SystemStats {
|
||||
cpu_usage: number[];
|
||||
memory_total: number;
|
||||
memory_used: number;
|
||||
memory_free: number;
|
||||
memory_cached: number;
|
||||
uptime: number;
|
||||
load_avg: [number, number, number];
|
||||
}
|
||||
|
||||
export let systemStats: SystemStats | null = null;
|
||||
|
||||
function formatUptime(seconds: number): string {
|
||||
const days = Math.floor(seconds / 86400);
|
||||
const hours = Math.floor((seconds % 86400) / 3600);
|
||||
const minutes = Math.floor((seconds % 3600) / 60);
|
||||
return `${days}d ${hours}h ${minutes}m`;
|
||||
}
|
||||
|
||||
function formatMemorySize(bytes: number): string {
|
||||
const gb = bytes / (1024 * 1024 * 1024);
|
||||
return `${gb.toFixed(1)} GB`;
|
||||
}
|
||||
|
||||
function formatMemoryPercentage(): string {
|
||||
if (!systemStats) return "0%";
|
||||
return (
|
||||
((systemStats.memory_used / systemStats.memory_total) * 100).toFixed(1) +
|
||||
"%"
|
||||
);
|
||||
}
|
||||
|
||||
function getUsageClass(percentage: number): string {
|
||||
if (percentage >= 90) return "critical";
|
||||
if (percentage >= 60) return "high";
|
||||
if (percentage >= 30) return "medium";
|
||||
return "low";
|
||||
}
|
||||
|
||||
$: memoryPercentage = systemStats
|
||||
? (systemStats.memory_used / systemStats.memory_total) * 100
|
||||
: 0;
|
||||
|
||||
function formatPercentage(value: number): string {
|
||||
return `${value.toFixed(1)}%`;
|
||||
}
|
||||
</script>
|
||||
|
||||
<div class="stats-bar">
|
||||
{#if systemStats}
|
||||
<div class="stats-grid">
|
||||
<div class="stat-box">
|
||||
<div class="stat-header">
|
||||
<div class="stat-title">
|
||||
<Fa icon={faMicrochip} />
|
||||
<span>CPU Usage</span>
|
||||
</div>
|
||||
</div>
|
||||
<div class="cpu-bars">
|
||||
{#each systemStats.cpu_usage as usage, i}
|
||||
<div class="cpu-bar">
|
||||
<span class="cpu-label">CPU {i}</span>
|
||||
<div class="progress-bar">
|
||||
<div
|
||||
class="progress-fill {getUsageClass(usage)}"
|
||||
style="width: {usage}%"
|
||||
></div>
|
||||
</div>
|
||||
<span class="cpu-value">{usage.toFixed(1)}%</span>
|
||||
</div>
|
||||
{/each}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="stat-box">
|
||||
<div class="stat-header">
|
||||
<div class="stat-title">
|
||||
<Fa icon={faMemory} />
|
||||
<span>Memory</span>
|
||||
</div>
|
||||
</div>
|
||||
<div class="memory-info">
|
||||
<div class="progress-bar">
|
||||
<div
|
||||
class="progress-fill {getUsageClass(memoryPercentage)}"
|
||||
style="width: {memoryPercentage}%"
|
||||
></div>
|
||||
</div>
|
||||
<div class="memory-details">
|
||||
<div class="memory-row">
|
||||
<span>Total:</span>
|
||||
<span>{formatMemorySize(systemStats.memory_total)}</span>
|
||||
</div>
|
||||
<div class="memory-row">
|
||||
<span>Used:</span>
|
||||
<span
|
||||
>{formatMemorySize(systemStats.memory_used)} ({formatPercentage(
|
||||
memoryPercentage,
|
||||
)})</span
|
||||
>
|
||||
</div>
|
||||
<div class="memory-row">
|
||||
<span>Free:</span>
|
||||
<span
|
||||
>{formatMemorySize(
|
||||
systemStats.memory_total - systemStats.memory_used,
|
||||
)}</span
|
||||
>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="stat-box">
|
||||
<div class="stat-header">
|
||||
<div class="stat-title">
|
||||
<Fa icon={faServer} />
|
||||
<span>System Info</span>
|
||||
</div>
|
||||
</div>
|
||||
<div class="system-info">
|
||||
<div class="info-row">
|
||||
<span>Uptime:</span>
|
||||
<span>{formatUptime(systemStats.uptime)}</span>
|
||||
</div>
|
||||
<div class="info-row">
|
||||
<span>Load Average:</span>
|
||||
<span>{systemStats.load_avg[0].toFixed(2)} (1m)</span>
|
||||
</div>
|
||||
<div class="info-row">
|
||||
<span></span>
|
||||
<span>{systemStats.load_avg[1].toFixed(2)} (5m)</span>
|
||||
</div>
|
||||
<div class="info-row">
|
||||
<span></span>
|
||||
<span>{systemStats.load_avg[2].toFixed(2)} (15m)</span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
{/if}
|
||||
</div>
|
||||
|
||||
<style>
|
||||
.stats-bar {
|
||||
background-color: var(--mantle);
|
||||
border-bottom: 1px solid var(--surface0);
|
||||
padding: 12px;
|
||||
}
|
||||
|
||||
.stats-grid {
|
||||
display: grid;
|
||||
grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
|
||||
gap: 16px;
|
||||
padding: 12px;
|
||||
min-width: max-content;
|
||||
}
|
||||
|
||||
.stat-box {
|
||||
background: var(--base);
|
||||
border: 1px solid var(--surface0);
|
||||
border-radius: 8px;
|
||||
padding: 16px;
|
||||
}
|
||||
|
||||
.stat-header {
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
align-items: center;
|
||||
margin-bottom: 12px;
|
||||
padding-bottom: 8px;
|
||||
border-bottom: 1px solid var(--surface0);
|
||||
}
|
||||
|
||||
.stat-title {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 8px;
|
||||
font-size: 13px;
|
||||
font-weight: 600;
|
||||
color: var(--text);
|
||||
letter-spacing: 0.5px;
|
||||
}
|
||||
|
||||
.stat-title :global(svg) {
|
||||
width: 14px;
|
||||
height: 14px;
|
||||
color: var(--subtext0);
|
||||
}
|
||||
|
||||
.cpu-bars {
|
||||
display: grid;
|
||||
grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
|
||||
gap: 8px;
|
||||
}
|
||||
|
||||
.cpu-bar {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 8px;
|
||||
font-size: 12px;
|
||||
}
|
||||
|
||||
.cpu-label {
|
||||
width: 45px;
|
||||
color: var(--subtext0);
|
||||
}
|
||||
|
||||
.cpu-value {
|
||||
width: 45px;
|
||||
text-align: right;
|
||||
color: var(--subtext0);
|
||||
}
|
||||
|
||||
.progress-bar {
|
||||
flex: 1;
|
||||
height: 8px;
|
||||
background-color: var(--surface0);
|
||||
border-radius: 4px;
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
.progress-fill {
|
||||
height: 100%;
|
||||
border-radius: 4px;
|
||||
transition: width 0.2s ease;
|
||||
}
|
||||
|
||||
.progress-fill.low {
|
||||
background-color: var(--green);
|
||||
}
|
||||
|
||||
.progress-fill.medium {
|
||||
background-color: var(--yellow);
|
||||
}
|
||||
|
||||
.progress-fill.high {
|
||||
background-color: var(--peach);
|
||||
}
|
||||
|
||||
.progress-fill.critical {
|
||||
background-color: var(--red);
|
||||
}
|
||||
|
||||
.memory-info {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 4px;
|
||||
}
|
||||
|
||||
.memory-text {
|
||||
font-size: 12px;
|
||||
color: var(--subtext0);
|
||||
}
|
||||
|
||||
.system-info {
|
||||
font-size: 12px;
|
||||
color: var(--subtext0);
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 4px;
|
||||
}
|
||||
|
||||
.memory-details {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 4px;
|
||||
margin-top: 8px;
|
||||
}
|
||||
|
||||
.memory-row,
|
||||
.info-row {
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
font-size: 12px;
|
||||
color: var(--subtext0);
|
||||
}
|
||||
|
||||
.memory-row span:first-child,
|
||||
.info-row span:first-child {
|
||||
color: var(--subtext1);
|
||||
min-width: 80px;
|
||||
}
|
||||
</style>
|
190
src/lib/components/ThemeSwitcher.svelte
Normal file
@ -0,0 +1,190 @@
|
||||
<script lang="ts">
|
||||
import { themeStore } from "$lib/stores/theme";
|
||||
import { themes } from "$lib/styles/themes";
|
||||
import { fade } from "svelte/transition";
|
||||
|
||||
let showMenu = false;
|
||||
|
||||
const themeGroups = [
|
||||
{
|
||||
label: "Dark",
|
||||
themes: ["catppuccin", "dracula", "monokaiPro", "tokyoNight"],
|
||||
},
|
||||
{
|
||||
label: "Warm",
|
||||
themes: ["gruvbox"],
|
||||
},
|
||||
{
|
||||
label: "Cool",
|
||||
themes: ["nord", "oneDark"],
|
||||
},
|
||||
{
|
||||
label: "Accessibility",
|
||||
themes: ["highContrast"],
|
||||
},
|
||||
];
|
||||
</script>
|
||||
|
||||
<div class="theme-switcher">
|
||||
<button
|
||||
class="theme-button"
|
||||
on:click={() => (showMenu = !showMenu)}
|
||||
aria-label="Toggle theme menu"
|
||||
>
|
||||
<div class="current-theme">
|
||||
<div class="theme-preview" style:background={$themeStore.colors.base}>
|
||||
<div class="preview-color" style:background={$themeStore.colors.blue} />
|
||||
<div class="preview-color" style:background={$themeStore.colors.red} />
|
||||
<div
|
||||
class="preview-color"
|
||||
style:background={$themeStore.colors.green}
|
||||
/>
|
||||
</div>
|
||||
{$themeStore.label}
|
||||
</div>
|
||||
<span class="icon">{showMenu ? "▼" : "▶"}</span>
|
||||
</button>
|
||||
|
||||
{#if showMenu}
|
||||
<div
|
||||
class="theme-menu"
|
||||
transition:fade={{ duration: 100 }}
|
||||
on:mouseleave={() => (showMenu = false)}
|
||||
>
|
||||
{#each themeGroups as group}
|
||||
<div class="theme-group">
|
||||
<div class="group-label">{group.label}</div>
|
||||
{#each group.themes as themeName}
|
||||
{@const theme = themes[themeName]}
|
||||
<button
|
||||
class="theme-option"
|
||||
class:active={$themeStore.name === theme.name}
|
||||
on:click={() => {
|
||||
themeStore.setTheme(theme.name);
|
||||
showMenu = false;
|
||||
}}
|
||||
>
|
||||
<div class="theme-preview" style:background={theme.colors.base}>
|
||||
<div
|
||||
class="preview-color"
|
||||
style:background={theme.colors.blue}
|
||||
/>
|
||||
<div
|
||||
class="preview-color"
|
||||
style:background={theme.colors.red}
|
||||
/>
|
||||
<div
|
||||
class="preview-color"
|
||||
style:background={theme.colors.green}
|
||||
/>
|
||||
</div>
|
||||
{theme.label}
|
||||
</button>
|
||||
{/each}
|
||||
</div>
|
||||
{/each}
|
||||
</div>
|
||||
{/if}
|
||||
</div>
|
||||
|
||||
<style>
|
||||
.theme-switcher {
|
||||
position: relative;
|
||||
}
|
||||
|
||||
.theme-button {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 6px;
|
||||
padding: 6px 12px;
|
||||
font-size: 12px;
|
||||
color: var(--text);
|
||||
background: var(--surface0);
|
||||
border: 1px solid var(--surface1);
|
||||
border-radius: 6px;
|
||||
cursor: pointer;
|
||||
transition: all 0.2s ease;
|
||||
}
|
||||
|
||||
.theme-button:hover {
|
||||
background: var(--surface1);
|
||||
}
|
||||
|
||||
.icon {
|
||||
font-size: 10px;
|
||||
color: var(--subtext0);
|
||||
}
|
||||
|
||||
.theme-menu {
|
||||
position: absolute;
|
||||
top: 100%;
|
||||
right: 0;
|
||||
margin-top: 4px;
|
||||
padding: 8px;
|
||||
background: var(--base);
|
||||
border: 1px solid var(--surface0);
|
||||
border-radius: 6px;
|
||||
box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
|
||||
z-index: 100;
|
||||
min-width: 200px;
|
||||
}
|
||||
|
||||
.theme-option {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 12px;
|
||||
width: 100%;
|
||||
padding: 8px;
|
||||
border: none;
|
||||
background: transparent;
|
||||
color: var(--text);
|
||||
font-size: 13px;
|
||||
cursor: pointer;
|
||||
border-radius: 4px;
|
||||
}
|
||||
|
||||
.theme-option:hover {
|
||||
background: var(--surface0);
|
||||
}
|
||||
|
||||
.theme-option.active {
|
||||
background: var(--surface0);
|
||||
}
|
||||
|
||||
.theme-preview {
|
||||
display: flex;
|
||||
gap: 4px;
|
||||
padding: 4px;
|
||||
border-radius: 4px;
|
||||
border: 1px solid var(--surface1);
|
||||
}
|
||||
|
||||
.preview-color {
|
||||
width: 12px;
|
||||
height: 12px;
|
||||
border-radius: 2px;
|
||||
}
|
||||
|
||||
.current-theme {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 8px;
|
||||
}
|
||||
|
||||
.theme-group {
|
||||
padding: 8px 0;
|
||||
}
|
||||
|
||||
.theme-group:not(:last-child) {
|
||||
border-bottom: 1px solid var(--surface0);
|
||||
}
|
||||
|
||||
.group-label {
|
||||
padding: 4px 8px;
|
||||
font-size: 11px;
|
||||
font-weight: 500;
|
||||
color: var(--subtext0);
|
||||
text-transform: uppercase;
|
||||
letter-spacing: 0.5px;
|
||||
}
|
||||
</style>
|
344
src/lib/components/ToolBar.svelte
Normal file
@ -0,0 +1,344 @@
|
||||
<script lang="ts">
|
||||
import AppInfo from "./AppInfo.svelte";
|
||||
export let searchTerm: string;
|
||||
export let itemsPerPage: number;
|
||||
export let currentPage: number;
|
||||
export let totalPages: number;
|
||||
export let totalResults: number;
|
||||
export let columns: Array<{
|
||||
id: string;
|
||||
label: string;
|
||||
visible: boolean;
|
||||
required?: boolean;
|
||||
}>;
|
||||
|
||||
const itemsPerPageOptions = [25, 50, 100, 250, 500];
|
||||
let showColumnMenu = false;
|
||||
|
||||
function changePage(page: number) {
|
||||
if (page >= 1 && page <= totalPages) {
|
||||
currentPage = page;
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<div class="toolbar">
|
||||
<div class="toolbar-content">
|
||||
<div class="search-box">
|
||||
<div class="search-input-wrapper">
|
||||
<input
|
||||
type="text"
|
||||
placeholder="Search processes"
|
||||
bind:value={searchTerm}
|
||||
class="search-input"
|
||||
/>
|
||||
{#if searchTerm}
|
||||
<button
|
||||
class="btn-clear"
|
||||
on:click={() => (searchTerm = "")}
|
||||
title="Clear search"
|
||||
>
|
||||
Clear
|
||||
</button>
|
||||
{/if}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="toolbar-spacer" />
|
||||
|
||||
<div class="pagination-controls">
|
||||
<select
|
||||
class="select-input"
|
||||
bind:value={itemsPerPage}
|
||||
aria-label="Items per page"
|
||||
>
|
||||
{#each itemsPerPageOptions as option}
|
||||
<option value={option}>{option} per page</option>
|
||||
{/each}
|
||||
</select>
|
||||
|
||||
<div class="pagination">
|
||||
<button
|
||||
class="btn-page"
|
||||
disabled={currentPage === 1}
|
||||
on:click={() => changePage(1)}
|
||||
>
|
||||
««
|
||||
</button>
|
||||
<button
|
||||
class="btn-page"
|
||||
disabled={currentPage === 1}
|
||||
on:click={() => changePage(currentPage - 1)}
|
||||
>
|
||||
«
|
||||
</button>
|
||||
<span class="page-info">
|
||||
Page {currentPage} of {totalPages}
|
||||
<span class="results-info">({totalResults} processes)</span>
|
||||
</span>
|
||||
<button
|
||||
class="btn-page"
|
||||
disabled={currentPage === totalPages}
|
||||
on:click={() => changePage(currentPage + 1)}
|
||||
>
|
||||
»
|
||||
</button>
|
||||
<button
|
||||
class="btn-page"
|
||||
disabled={currentPage === totalPages}
|
||||
on:click={() => changePage(totalPages)}
|
||||
>
|
||||
»»
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="column-toggle">
|
||||
<button
|
||||
class="btn-toggle"
|
||||
on:click={() => (showColumnMenu = !showColumnMenu)}
|
||||
aria-label="Toggle columns"
|
||||
>
|
||||
Columns
|
||||
<span class="icon">{showColumnMenu ? "▼" : "▶"}</span>
|
||||
</button>
|
||||
|
||||
{#if showColumnMenu}
|
||||
<div class="column-menu" on:mouseleave={() => (showColumnMenu = false)}>
|
||||
{#each columns as column}
|
||||
<label class="column-option">
|
||||
<input
|
||||
type="checkbox"
|
||||
bind:checked={column.visible}
|
||||
disabled={column.required}
|
||||
/>
|
||||
<span>{column.label}</span>
|
||||
</label>
|
||||
{/each}
|
||||
</div>
|
||||
{/if}
|
||||
</div>
|
||||
|
||||
<!-- <div class="toolbar-spacer" /> -->
|
||||
|
||||
<AppInfo />
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<style>
|
||||
.toolbar {
|
||||
padding: 8px;
|
||||
border-bottom: 1px solid var(--surface0);
|
||||
background-color: var(--mantle);
|
||||
}
|
||||
|
||||
.toolbar-content {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 12px;
|
||||
padding: 0 12px;
|
||||
min-width: max-content;
|
||||
}
|
||||
|
||||
.toolbar-spacer {
|
||||
flex: 1;
|
||||
}
|
||||
|
||||
.search-box {
|
||||
width: 240px;
|
||||
}
|
||||
|
||||
.search-input-wrapper {
|
||||
position: relative;
|
||||
display: flex;
|
||||
gap: 8px;
|
||||
align-items: center;
|
||||
}
|
||||
|
||||
.search-input {
|
||||
width: 240px;
|
||||
padding: 6px 12px;
|
||||
border: 1px solid var(--surface0);
|
||||
border-radius: 6px;
|
||||
font-size: 13px;
|
||||
background-color: var(--crust);
|
||||
color: var(--text);
|
||||
}
|
||||
|
||||
.search-input:focus {
|
||||
outline: none;
|
||||
border-color: var(--blue);
|
||||
box-shadow: 0 0 0 2px color-mix(in srgb, var(--blue) 25%, transparent);
|
||||
}
|
||||
|
||||
.btn-clear {
|
||||
padding: 6px 12px;
|
||||
background: var(--surface0);
|
||||
border: 1px solid var(--surface1);
|
||||
border-radius: 6px;
|
||||
color: var(--text);
|
||||
font-size: 13px;
|
||||
cursor: pointer;
|
||||
transition: all 0.2s ease;
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
||||
.btn-clear:hover {
|
||||
background: var(--surface1);
|
||||
border-color: var(--surface2);
|
||||
}
|
||||
|
||||
.pagination-controls {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 12px;
|
||||
}
|
||||
|
||||
.select-input {
|
||||
padding: 6px 12px;
|
||||
font-size: 12px;
|
||||
color: var(--text);
|
||||
background: var(--surface0);
|
||||
border: 1px solid var(--surface1);
|
||||
border-radius: 6px;
|
||||
cursor: pointer;
|
||||
appearance: none;
|
||||
padding-right: 24px;
|
||||
background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%23cdd6f4' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E");
|
||||
background-repeat: no-repeat;
|
||||
background-position: right 8px center;
|
||||
}
|
||||
|
||||
.select-input:hover {
|
||||
background-color: var(--surface1);
|
||||
}
|
||||
|
||||
.select-input:focus {
|
||||
outline: none;
|
||||
border-color: var(--blue);
|
||||
}
|
||||
|
||||
.pagination {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 8px;
|
||||
}
|
||||
|
||||
.btn-page {
|
||||
padding: 6px 10px;
|
||||
font-size: 12px;
|
||||
color: var(--text);
|
||||
background: var(--surface0);
|
||||
border: 1px solid var(--surface1);
|
||||
border-radius: 6px;
|
||||
cursor: pointer;
|
||||
transition: all 0.2s ease;
|
||||
}
|
||||
|
||||
.btn-page:hover:not(:disabled) {
|
||||
background: var(--surface1);
|
||||
}
|
||||
|
||||
.btn-page:disabled {
|
||||
opacity: 0.5;
|
||||
cursor: not-allowed;
|
||||
}
|
||||
|
||||
.page-info {
|
||||
font-size: 12px;
|
||||
color: var(--subtext0);
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 8px;
|
||||
}
|
||||
|
||||
.results-info {
|
||||
color: var(--overlay0);
|
||||
}
|
||||
|
||||
.column-toggle {
|
||||
position: relative;
|
||||
}
|
||||
|
||||
.btn-toggle {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 6px;
|
||||
padding: 6px 12px;
|
||||
font-size: 12px;
|
||||
color: var(--text);
|
||||
background: var(--surface0);
|
||||
border: 1px solid var(--surface1);
|
||||
border-radius: 6px;
|
||||
cursor: pointer;
|
||||
transition: all 0.2s ease;
|
||||
}
|
||||
|
||||
.btn-toggle:hover {
|
||||
background: var(--surface1);
|
||||
}
|
||||
|
||||
.icon {
|
||||
font-size: 10px;
|
||||
color: var(--subtext0);
|
||||
}
|
||||
|
||||
.column-menu {
|
||||
position: absolute;
|
||||
top: 100%;
|
||||
right: 0;
|
||||
margin-top: 4px;
|
||||
padding: 8px;
|
||||
background: var(--base);
|
||||
border: 1px solid var(--surface0);
|
||||
border-radius: 6px;
|
||||
box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
|
||||
z-index: 100;
|
||||
}
|
||||
|
||||
.column-option {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 8px;
|
||||
padding: 6px 8px;
|
||||
font-size: 12px;
|
||||
color: var(--text);
|
||||
cursor: pointer;
|
||||
border-radius: 4px;
|
||||
}
|
||||
|
||||
.column-option:hover {
|
||||
background: var(--surface0);
|
||||
}
|
||||
|
||||
.column-option input[type="checkbox"] {
|
||||
appearance: none;
|
||||
width: 16px;
|
||||
height: 16px;
|
||||
border: 1px solid var(--surface2);
|
||||
border-radius: 4px;
|
||||
background: var(--mantle);
|
||||
cursor: pointer;
|
||||
position: relative;
|
||||
}
|
||||
|
||||
.column-option input[type="checkbox"]:checked {
|
||||
background: var(--blue);
|
||||
border-color: var(--blue);
|
||||
}
|
||||
|
||||
.column-option input[type="checkbox"]:checked::after {
|
||||
content: "✓";
|
||||
position: absolute;
|
||||
color: var(--base);
|
||||
font-size: 12px;
|
||||
top: 50%;
|
||||
left: 50%;
|
||||
transform: translate(-50%, -50%);
|
||||
}
|
||||
|
||||
.column-option input[type="checkbox"]:disabled {
|
||||
opacity: 0.5;
|
||||
cursor: not-allowed;
|
||||
}
|
||||
</style>
|
0
src/lib/stores/index.ts
Normal file
36
src/lib/stores/theme.ts
Normal file
@ -0,0 +1,36 @@
|
||||
import { writable } from 'svelte/store';
|
||||
import { themes, type Theme } from '$lib/styles/themes';
|
||||
|
||||
function createThemeStore() {
|
||||
// Get initial theme from localStorage or default to catppuccin
|
||||
const storedTheme = typeof window !== 'undefined'
|
||||
? localStorage.getItem('theme')
|
||||
: 'catppuccin';
|
||||
|
||||
const { subscribe, set } = writable<Theme>(themes[storedTheme || 'catppuccin']);
|
||||
|
||||
return {
|
||||
subscribe,
|
||||
setTheme: (themeName: string) => {
|
||||
const theme = themes[themeName];
|
||||
if (theme) {
|
||||
localStorage.setItem('theme', themeName);
|
||||
set(theme);
|
||||
applyTheme(theme);
|
||||
}
|
||||
},
|
||||
init: () => {
|
||||
const theme = themes[storedTheme || 'catppuccin'];
|
||||
applyTheme(theme);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
function applyTheme(theme: Theme) {
|
||||
const root = document.documentElement;
|
||||
Object.entries(theme.colors).forEach(([key, value]) => {
|
||||
root.style.setProperty(`--${key}`, value);
|
||||
});
|
||||
}
|
||||
|
||||
export const themeStore = createThemeStore();
|
246
src/lib/styles/themes.ts
Normal file
@ -0,0 +1,246 @@
|
||||
export interface Theme {
|
||||
name: string;
|
||||
label: string;
|
||||
colors: {
|
||||
base: string;
|
||||
mantle: string;
|
||||
crust: string;
|
||||
text: string;
|
||||
subtext0: string;
|
||||
subtext1: string;
|
||||
surface0: string;
|
||||
surface1: string;
|
||||
surface2: string;
|
||||
overlay0: string;
|
||||
overlay1: string;
|
||||
blue: string;
|
||||
lavender: string;
|
||||
sapphire: string;
|
||||
sky: string;
|
||||
red: string;
|
||||
maroon: string;
|
||||
peach: string;
|
||||
yellow: string;
|
||||
green: string;
|
||||
teal: string;
|
||||
};
|
||||
}
|
||||
|
||||
export const themes: Record<string, Theme> = {
|
||||
catppuccin: {
|
||||
name: 'catppuccin',
|
||||
label: 'Catppuccin Mocha',
|
||||
colors: {
|
||||
base: '#1e1e2e',
|
||||
mantle: '#181825',
|
||||
crust: '#11111b',
|
||||
text: '#cdd6f4',
|
||||
subtext0: '#a6adc8',
|
||||
subtext1: '#bac2de',
|
||||
surface0: '#313244',
|
||||
surface1: '#45475a',
|
||||
surface2: '#585b70',
|
||||
overlay0: '#6c7086',
|
||||
overlay1: '#7f849c',
|
||||
blue: '#89b4fa',
|
||||
lavender: '#b4befe',
|
||||
sapphire: '#74c7ec',
|
||||
sky: '#89dceb',
|
||||
red: '#f38ba8',
|
||||
maroon: '#eba0ac',
|
||||
peach: '#fab387',
|
||||
yellow: '#f9e2af',
|
||||
green: '#a6e3a1',
|
||||
teal: '#94e2d5',
|
||||
},
|
||||
},
|
||||
dracula: {
|
||||
name: 'dracula',
|
||||
label: 'Dracula',
|
||||
colors: {
|
||||
base: '#282a36',
|
||||
mantle: '#1e1f29',
|
||||
crust: '#191a21',
|
||||
text: '#f8f8f2',
|
||||
subtext0: '#bfbfbf',
|
||||
subtext1: '#e6e6e6',
|
||||
surface0: '#44475a',
|
||||
surface1: '#6272a4',
|
||||
surface2: '#7970a9',
|
||||
overlay0: '#6272a4',
|
||||
overlay1: '#7970a9',
|
||||
blue: '#8be9fd',
|
||||
lavender: '#bd93f9',
|
||||
sapphire: '#62d6e8',
|
||||
sky: '#89ddff',
|
||||
red: '#ff5555',
|
||||
maroon: '#ff6e6e',
|
||||
peach: '#ffb86c',
|
||||
yellow: '#f1fa8c',
|
||||
green: '#50fa7b',
|
||||
teal: '#8be9fd',
|
||||
},
|
||||
},
|
||||
monokaiPro: {
|
||||
name: 'monokaiPro',
|
||||
label: 'Monokai Pro',
|
||||
colors: {
|
||||
base: '#2d2a2e',
|
||||
mantle: '#221f22',
|
||||
crust: '#1b1b1b',
|
||||
text: '#fcfcfa',
|
||||
subtext0: '#939293',
|
||||
subtext1: '#c1c0c0',
|
||||
surface0: '#403e41',
|
||||
surface1: '#565457',
|
||||
surface2: '#69676c',
|
||||
overlay0: '#727072',
|
||||
overlay1: '#848486',
|
||||
blue: '#78dce8',
|
||||
lavender: '#ab9df2',
|
||||
sapphire: '#66d9ef',
|
||||
sky: '#78dce8',
|
||||
red: '#ff6188',
|
||||
maroon: '#ff6188',
|
||||
peach: '#fc9867',
|
||||
yellow: '#ffd866',
|
||||
green: '#a9dc76',
|
||||
teal: '#78dce8',
|
||||
},
|
||||
},
|
||||
tokyoNight: {
|
||||
name: 'tokyoNight',
|
||||
label: 'Tokyo Night',
|
||||
colors: {
|
||||
base: '#1a1b26',
|
||||
mantle: '#16161e',
|
||||
crust: '#13131a',
|
||||
text: '#a9b1d6',
|
||||
subtext0: '#9aa5ce',
|
||||
subtext1: '#b4f9f8',
|
||||
surface0: '#232433',
|
||||
surface1: '#2a2b3d',
|
||||
surface2: '#32344a',
|
||||
overlay0: '#565f89',
|
||||
overlay1: '#6b7089',
|
||||
blue: '#7aa2f7',
|
||||
lavender: '#bb9af7',
|
||||
sapphire: '#7dcfff',
|
||||
sky: '#7dcfff',
|
||||
red: '#f7768e',
|
||||
maroon: '#ff9e64',
|
||||
peach: '#ff9e64',
|
||||
yellow: '#e0af68',
|
||||
green: '#9ece6a',
|
||||
teal: '#2ac3de',
|
||||
},
|
||||
},
|
||||
gruvbox: {
|
||||
name: 'gruvbox',
|
||||
label: 'Gruvbox Dark',
|
||||
colors: {
|
||||
base: '#282828',
|
||||
mantle: '#1d2021',
|
||||
crust: '#1b1b1b',
|
||||
text: '#ebdbb2',
|
||||
subtext0: '#a89984',
|
||||
subtext1: '#bdae93',
|
||||
surface0: '#3c3836',
|
||||
surface1: '#504945',
|
||||
surface2: '#665c54',
|
||||
overlay0: '#7c6f64',
|
||||
overlay1: '#928374',
|
||||
blue: '#83a598',
|
||||
lavender: '#d3869b',
|
||||
sapphire: '#83a598',
|
||||
sky: '#8ec07c',
|
||||
red: '#fb4934',
|
||||
maroon: '#cc241d',
|
||||
peach: '#fe8019',
|
||||
yellow: '#fabd2f',
|
||||
green: '#b8bb26',
|
||||
teal: '#8ec07c',
|
||||
},
|
||||
},
|
||||
nord: {
|
||||
name: 'nord',
|
||||
label: 'Nord',
|
||||
colors: {
|
||||
base: '#2e3440',
|
||||
mantle: '#272c36',
|
||||
crust: '#242933',
|
||||
text: '#eceff4',
|
||||
subtext0: '#d8dee9',
|
||||
subtext1: '#e5e9f0',
|
||||
surface0: '#3b4252',
|
||||
surface1: '#434c5e',
|
||||
surface2: '#4c566a',
|
||||
overlay0: '#616e88',
|
||||
overlay1: '#7b88a1',
|
||||
blue: '#88c0d0',
|
||||
lavender: '#b48ead',
|
||||
sapphire: '#81a1c1',
|
||||
sky: '#88c0d0',
|
||||
red: '#bf616a',
|
||||
maroon: '#d08770',
|
||||
peach: '#d08770',
|
||||
yellow: '#ebcb8b',
|
||||
green: '#a3be8c',
|
||||
teal: '#8fbcbb',
|
||||
},
|
||||
},
|
||||
oneDark: {
|
||||
name: 'oneDark',
|
||||
label: 'One Dark',
|
||||
colors: {
|
||||
base: '#282c34',
|
||||
mantle: '#21252b',
|
||||
crust: '#1b1f23',
|
||||
text: '#abb2bf',
|
||||
subtext0: '#828997',
|
||||
subtext1: '#9da5b4',
|
||||
surface0: '#31353f',
|
||||
surface1: '#393f4a',
|
||||
surface2: '#4b5263',
|
||||
overlay0: '#636d83',
|
||||
overlay1: '#767d8d',
|
||||
blue: '#61afef',
|
||||
lavender: '#c678dd',
|
||||
sapphire: '#56b6c2',
|
||||
sky: '#56b6c2',
|
||||
red: '#e06c75',
|
||||
maroon: '#be5046',
|
||||
peach: '#d19a66',
|
||||
yellow: '#e5c07b',
|
||||
green: '#98c379',
|
||||
teal: '#56b6c2',
|
||||
},
|
||||
},
|
||||
highContrast: {
|
||||
name: 'highContrast',
|
||||
label: 'High Contrast',
|
||||
colors: {
|
||||
base: '#000000', // Pure black background
|
||||
mantle: '#0a0a0a', // Slightly lighter black for layering
|
||||
crust: '#141414', // Even lighter black for depth
|
||||
text: '#ffffff', // Pure white text
|
||||
subtext0: '#e0e0e0', // Very light grey for secondary text
|
||||
subtext1: '#f0f0f0', // Almost white for important secondary text
|
||||
surface0: '#1a1a1a', // Dark surface for contrast
|
||||
surface1: '#2a2a2a', // Lighter surface for hover states
|
||||
surface2: '#3a3a3a', // Even lighter surface for active states
|
||||
overlay0: '#4a4a4a', // Medium grey for overlays
|
||||
overlay1: '#5a5a5a', // Lighter grey for overlay hover states
|
||||
blue: '#00ffff', // Cyan for primary actions
|
||||
lavender: '#ff00ff', // Magenta for accents
|
||||
sapphire: '#00ccff', // Bright blue for links
|
||||
sky: '#00ffee', // Bright cyan for highlights
|
||||
red: '#ff0000', // Pure red for errors/warnings
|
||||
maroon: '#ff3333', // Lighter red for secondary warnings
|
||||
peach: '#ffaa00', // Bright orange for notifications
|
||||
yellow: '#ffff00', // Pure yellow for important highlights
|
||||
green: '#00ff00', // Pure green for success states
|
||||
teal: '#00ffcc', // Bright teal for special actions
|
||||
},
|
||||
},
|
||||
};
|
0
src/lib/types/index.ts
Normal file
0
src/lib/utils/index.ts
Normal file
54
src/lib/utils/processStatus.ts
Normal file
@ -0,0 +1,54 @@
|
||||
export interface ProcessStatus {
|
||||
label: string;
|
||||
emoji: string;
|
||||
color: string;
|
||||
}
|
||||
|
||||
export const statusMap: Record<string, ProcessStatus> = {
|
||||
"R": { // Running
|
||||
label: "Running",
|
||||
emoji: "🏃",
|
||||
color: "var(--green)",
|
||||
},
|
||||
"S": { // Sleeping
|
||||
label: "Sleeping",
|
||||
emoji: "😴",
|
||||
color: "var(--blue)",
|
||||
},
|
||||
"I": { // Idle
|
||||
label: "Idle",
|
||||
emoji: "⌛",
|
||||
color: "var(--overlay0)",
|
||||
},
|
||||
"Z": { // Zombie
|
||||
label: "Zombie",
|
||||
emoji: "🧟",
|
||||
color: "var(--red)",
|
||||
},
|
||||
"T": { // Stopped
|
||||
label: "Stopped",
|
||||
emoji: "⛔",
|
||||
color: "var(--yellow)",
|
||||
},
|
||||
"X": { // Dead
|
||||
label: "Dead",
|
||||
emoji: "💀",
|
||||
color: "var(--red)",
|
||||
},
|
||||
"Unknown": {
|
||||
label: "Unknown",
|
||||
emoji: "🤔",
|
||||
color: "var(--overlay0)",
|
||||
},
|
||||
};
|
||||
|
||||
export function formatStatus(status: string): string {
|
||||
// Log the incoming status for debugging
|
||||
console.log('Process status:', status);
|
||||
|
||||
const processStatus = statusMap[status] || statusMap.Unknown;
|
||||
return `<span class="status-badge" style="--status-color: ${processStatus.color}">
|
||||
<span class="status-emoji">${processStatus.emoji}</span>
|
||||
${processStatus.label}
|
||||
</span>`;
|
||||
}
|
5
src/routes/+layout.js
Normal file
@ -0,0 +1,5 @@
|
||||
// Tauri doesn't have a Node.js server to do proper SSR
|
||||
// so we will use adapter-static to prerender the app (SSG)
|
||||
// See: https://v2.tauri.app/start/frontend/sveltekit/ for more info
|
||||
export const prerender = true;
|
||||
export const ssr = false;
|
5
src/routes/+layout.svelte
Normal file
@ -0,0 +1,5 @@
|
||||
<script>
|
||||
import "../app.css";
|
||||
</script>
|
||||
|
||||
<slot />
|
379
src/routes/+page.svelte
Normal file
@ -0,0 +1,379 @@
|
||||
<script lang="ts">
|
||||
import { invoke } from "@tauri-apps/api/core";
|
||||
import { onMount, onDestroy } from "svelte";
|
||||
import StatsBar from "$lib/components/StatsBar.svelte";
|
||||
import ToolBar from "$lib/components/ToolBar.svelte";
|
||||
import ProcessTable from "$lib/components/ProcessTable.svelte";
|
||||
import ProcessDetailsModal from "$lib/components/ProcessDetailsModal.svelte";
|
||||
import KillProcessModal from "$lib/components/KillProcessModal.svelte";
|
||||
import { formatStatus } from "$lib/utils/processStatus";
|
||||
import { themeStore } from "$lib/stores/theme";
|
||||
import ThemeSwitcher from "$lib/components/ThemeSwitcher.svelte";
|
||||
|
||||
interface Process {
|
||||
pid: number;
|
||||
ppid: number;
|
||||
name: string;
|
||||
cpu_usage: number;
|
||||
memory_usage: number;
|
||||
status: string;
|
||||
user: string;
|
||||
command: string;
|
||||
threads?: number;
|
||||
}
|
||||
|
||||
interface SystemStats {
|
||||
cpu_usage: number[];
|
||||
memory_total: number;
|
||||
memory_used: number;
|
||||
uptime: number;
|
||||
load_avg: [number, number, number];
|
||||
}
|
||||
|
||||
interface Column {
|
||||
id: keyof Process;
|
||||
label: string;
|
||||
visible: boolean;
|
||||
required?: boolean;
|
||||
format?: (value: any) => string;
|
||||
}
|
||||
|
||||
let processes: Process[] = [];
|
||||
let systemStats: SystemStats | null = null;
|
||||
let intervalId: number;
|
||||
let error: string | null = null;
|
||||
let searchTerm = "";
|
||||
let isLoading = true;
|
||||
let currentPage = 1;
|
||||
let itemsPerPage = 50;
|
||||
let pinnedProcesses: Set<number> = new Set();
|
||||
let selectedProcess: Process | null = null;
|
||||
let showInfoModal = false;
|
||||
let showConfirmModal = false;
|
||||
let processToKill: Process | null = null;
|
||||
let isKilling = false;
|
||||
|
||||
let columns: Column[] = [
|
||||
{ id: "name", label: "Process Name", visible: true, required: true },
|
||||
{ id: "pid", label: "PID", visible: true, required: true },
|
||||
{
|
||||
id: "status",
|
||||
label: "Status",
|
||||
visible: true,
|
||||
format: formatStatus,
|
||||
},
|
||||
{ id: "user", label: "User", visible: true },
|
||||
{
|
||||
id: "cpu_usage",
|
||||
label: "CPU %",
|
||||
visible: true,
|
||||
format: (v) => v.toFixed(1) + "%",
|
||||
},
|
||||
{
|
||||
id: "memory_usage",
|
||||
label: "Memory",
|
||||
visible: true,
|
||||
format: (v) => (v / (1024 * 1024)).toFixed(1) + " MB",
|
||||
},
|
||||
{ id: "threads", label: "Threads", visible: false },
|
||||
{ id: "command", label: "Command", visible: false },
|
||||
{ id: "ppid", label: "Parent PID", visible: false },
|
||||
];
|
||||
|
||||
let sortConfig = {
|
||||
field: "cpu_usage" as keyof Process,
|
||||
direction: "desc" as "asc" | "desc",
|
||||
};
|
||||
|
||||
$: filteredProcesses = processes.filter((process) =>
|
||||
process.name.toLowerCase().includes(searchTerm.toLowerCase()),
|
||||
);
|
||||
|
||||
$: sortedProcesses = filteredProcesses.sort((a, b) => {
|
||||
const aPin = pinnedProcesses.has(a.pid);
|
||||
const bPin = pinnedProcesses.has(b.pid);
|
||||
if (aPin && !bPin) return -1;
|
||||
if (!aPin && bPin) return 1;
|
||||
|
||||
const aValue = a[sortConfig.field];
|
||||
const bValue = b[sortConfig.field];
|
||||
const direction = sortConfig.direction === "asc" ? 1 : -1;
|
||||
|
||||
if (typeof aValue === "string" && typeof bValue === "string") {
|
||||
return direction * aValue.localeCompare(bValue);
|
||||
}
|
||||
return direction * (Number(aValue) - Number(bValue));
|
||||
});
|
||||
|
||||
$: totalPages = Math.ceil(filteredProcesses.length / itemsPerPage);
|
||||
$: paginatedProcesses = sortedProcesses.slice(
|
||||
(currentPage - 1) * itemsPerPage,
|
||||
currentPage * itemsPerPage,
|
||||
);
|
||||
|
||||
$: {
|
||||
// Reset to first page when filtering or changing items per page
|
||||
if (searchTerm || itemsPerPage) {
|
||||
currentPage = 1;
|
||||
}
|
||||
}
|
||||
|
||||
async function getProcesses() {
|
||||
try {
|
||||
processes = await invoke<Process[]>("get_processes");
|
||||
error = null;
|
||||
} catch (e) {
|
||||
error = e.toString();
|
||||
}
|
||||
}
|
||||
|
||||
async function getSystemStats() {
|
||||
try {
|
||||
systemStats = await invoke<SystemStats>("get_system_stats");
|
||||
} catch (e) {
|
||||
console.error("Failed to get system stats:", e);
|
||||
}
|
||||
}
|
||||
|
||||
async function killProcess(pid: number) {
|
||||
try {
|
||||
const success = await invoke<boolean>("kill_process", { pid });
|
||||
if (success) {
|
||||
await getProcesses();
|
||||
}
|
||||
} catch (e) {
|
||||
error = e.toString();
|
||||
}
|
||||
}
|
||||
|
||||
function toggleSort(field: keyof Process) {
|
||||
if (sortConfig.field === field) {
|
||||
sortConfig.direction = sortConfig.direction === "asc" ? "desc" : "asc";
|
||||
} else {
|
||||
sortConfig.field = field;
|
||||
sortConfig.direction = "desc";
|
||||
}
|
||||
}
|
||||
|
||||
function togglePin(pid: number) {
|
||||
if (pinnedProcesses.has(pid)) {
|
||||
pinnedProcesses.delete(pid);
|
||||
} else {
|
||||
pinnedProcesses.add(pid);
|
||||
}
|
||||
pinnedProcesses = pinnedProcesses; // Trigger reactivity
|
||||
}
|
||||
|
||||
function showProcessDetails(process: Process) {
|
||||
selectedProcess = process;
|
||||
showInfoModal = true;
|
||||
}
|
||||
|
||||
function confirmKillProcess(process: Process) {
|
||||
processToKill = process;
|
||||
showConfirmModal = true;
|
||||
}
|
||||
|
||||
async function handleConfirmKill() {
|
||||
if (processToKill) {
|
||||
isKilling = true;
|
||||
try {
|
||||
await killProcess(processToKill.pid);
|
||||
} finally {
|
||||
isKilling = false;
|
||||
showConfirmModal = false;
|
||||
processToKill = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
onMount(async () => {
|
||||
try {
|
||||
await Promise.all([getProcesses(), getSystemStats()]);
|
||||
} finally {
|
||||
isLoading = false;
|
||||
}
|
||||
|
||||
intervalId = setInterval(() => {
|
||||
getProcesses();
|
||||
getSystemStats();
|
||||
}, 2000);
|
||||
|
||||
themeStore.init();
|
||||
});
|
||||
|
||||
onDestroy(() => {
|
||||
if (intervalId) clearInterval(intervalId);
|
||||
});
|
||||
</script>
|
||||
|
||||
{#if isLoading}
|
||||
<div class="loading-container">
|
||||
<div class="loading-content">
|
||||
<div class="spinner" />
|
||||
<span class="loading-text">Loading processes...</span>
|
||||
</div>
|
||||
</div>
|
||||
{:else}
|
||||
<main>
|
||||
<StatsBar {systemStats} />
|
||||
|
||||
<ToolBar
|
||||
bind:searchTerm
|
||||
bind:itemsPerPage
|
||||
bind:currentPage
|
||||
{totalPages}
|
||||
totalResults={filteredProcesses.length}
|
||||
bind:columns
|
||||
/>
|
||||
|
||||
{#if error}
|
||||
<div class="alert">{error}</div>
|
||||
{/if}
|
||||
|
||||
<ProcessTable
|
||||
processes={paginatedProcesses}
|
||||
{columns}
|
||||
{systemStats}
|
||||
{sortConfig}
|
||||
{pinnedProcesses}
|
||||
onToggleSort={toggleSort}
|
||||
onTogglePin={togglePin}
|
||||
onShowDetails={showProcessDetails}
|
||||
onKillProcess={confirmKillProcess}
|
||||
/>
|
||||
</main>
|
||||
{/if}
|
||||
|
||||
<ProcessDetailsModal
|
||||
show={showInfoModal}
|
||||
process={selectedProcess}
|
||||
onClose={() => {
|
||||
showInfoModal = false;
|
||||
selectedProcess = null;
|
||||
}}
|
||||
/>
|
||||
|
||||
<KillProcessModal
|
||||
show={showConfirmModal}
|
||||
process={processToKill}
|
||||
{isKilling}
|
||||
onClose={() => {
|
||||
showConfirmModal = false;
|
||||
processToKill = null;
|
||||
}}
|
||||
onConfirm={handleConfirmKill}
|
||||
/>
|
||||
|
||||
<svelte:head>
|
||||
<title>NeoHtop - Modern System Monitor</title>
|
||||
<meta
|
||||
name="description"
|
||||
content="A modern, web-based system monitoring interface inspired by htop"
|
||||
/>
|
||||
</svelte:head>
|
||||
|
||||
<style>
|
||||
:global(:root) {
|
||||
--base: #1e1e2e;
|
||||
--mantle: #181825;
|
||||
--crust: #11111b;
|
||||
--text: #cdd6f4;
|
||||
--subtext0: #a6adc8;
|
||||
--subtext1: #bac2de;
|
||||
--surface0: #313244;
|
||||
--surface1: #45475a;
|
||||
--surface2: #585b70;
|
||||
--overlay0: #6c7086;
|
||||
--overlay1: #7f849c;
|
||||
--blue: #89b4fa;
|
||||
--lavender: #b4befe;
|
||||
--sapphire: #74c7ec;
|
||||
--sky: #89dceb;
|
||||
--red: #f38ba8;
|
||||
--maroon: #eba0ac;
|
||||
--peach: #fab387;
|
||||
--yellow: #f9e2af;
|
||||
--green: #a6e3a1;
|
||||
--teal: #94e2d5;
|
||||
}
|
||||
|
||||
:global(body) {
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
font-family: -apple-system, BlinkMacSystemFont, sans-serif;
|
||||
background-color: var(--base);
|
||||
color: var(--text);
|
||||
-webkit-font-smoothing: antialiased;
|
||||
overflow: hidden;
|
||||
user-select: none;
|
||||
}
|
||||
|
||||
main {
|
||||
height: 100vh;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
min-width: min-content;
|
||||
}
|
||||
|
||||
.alert {
|
||||
margin: 8px;
|
||||
padding: 8px 12px;
|
||||
background-color: var(--surface0);
|
||||
border: 1px solid var(--red);
|
||||
border-radius: 6px;
|
||||
color: var(--red);
|
||||
font-size: 13px;
|
||||
}
|
||||
|
||||
.loading-container {
|
||||
width: 100vw;
|
||||
height: 100vh;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
background: linear-gradient(135deg, var(--base) 0%, var(--mantle) 100%);
|
||||
}
|
||||
|
||||
.loading-content {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: center;
|
||||
gap: 16px;
|
||||
}
|
||||
|
||||
.spinner {
|
||||
width: 40px;
|
||||
height: 40px;
|
||||
border: 3px solid var(--surface0);
|
||||
border-top-color: var(--blue);
|
||||
border-radius: 50%;
|
||||
animation: spin 1s ease-in-out infinite;
|
||||
box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
|
||||
}
|
||||
|
||||
.loading-text {
|
||||
color: var(--subtext0);
|
||||
font-size: 14px;
|
||||
font-weight: 500;
|
||||
letter-spacing: 0.5px;
|
||||
animation: pulse 2s ease-in-out infinite;
|
||||
text-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
|
||||
}
|
||||
|
||||
@keyframes spin {
|
||||
to {
|
||||
transform: rotate(360deg);
|
||||
}
|
||||
}
|
||||
|
||||
@keyframes pulse {
|
||||
0%,
|
||||
100% {
|
||||
opacity: 0.6;
|
||||
}
|
||||
50% {
|
||||
opacity: 1;
|
||||
}
|
||||
}
|
||||
</style>
|
BIN
static/favicon.png
Normal file
After Width: | Height: | Size: 1.5 KiB |
1
static/svelte.svg
Normal file
@ -0,0 +1 @@
|
||||
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" aria-hidden="true" role="img" class="iconify iconify--logos" width="26.6" height="32" preserveAspectRatio="xMidYMid meet" viewBox="0 0 256 308"><path fill="#FF3E00" d="M239.682 40.707C211.113-.182 154.69-12.301 113.895 13.69L42.247 59.356a82.198 82.198 0 0 0-37.135 55.056a86.566 86.566 0 0 0 8.536 55.576a82.425 82.425 0 0 0-12.296 30.719a87.596 87.596 0 0 0 14.964 66.244c28.574 40.893 84.997 53.007 125.787 27.016l71.648-45.664a82.182 82.182 0 0 0 37.135-55.057a86.601 86.601 0 0 0-8.53-55.577a82.409 82.409 0 0 0 12.29-30.718a87.573 87.573 0 0 0-14.963-66.244"></path><path fill="#FFF" d="M106.889 270.841c-23.102 6.007-47.497-3.036-61.103-22.648a52.685 52.685 0 0 1-9.003-39.85a49.978 49.978 0 0 1 1.713-6.693l1.35-4.115l3.671 2.697a92.447 92.447 0 0 0 28.036 14.007l2.663.808l-.245 2.659a16.067 16.067 0 0 0 2.89 10.656a17.143 17.143 0 0 0 18.397 6.828a15.786 15.786 0 0 0 4.403-1.935l71.67-45.672a14.922 14.922 0 0 0 6.734-9.977a15.923 15.923 0 0 0-2.713-12.011a17.156 17.156 0 0 0-18.404-6.832a15.78 15.78 0 0 0-4.396 1.933l-27.35 17.434a52.298 52.298 0 0 1-14.553 6.391c-23.101 6.007-47.497-3.036-61.101-22.649a52.681 52.681 0 0 1-9.004-39.849a49.428 49.428 0 0 1 22.34-33.114l71.664-45.677a52.218 52.218 0 0 1 14.563-6.398c23.101-6.007 47.497 3.036 61.101 22.648a52.685 52.685 0 0 1 9.004 39.85a50.559 50.559 0 0 1-1.713 6.692l-1.35 4.116l-3.67-2.693a92.373 92.373 0 0 0-28.037-14.013l-2.664-.809l.246-2.658a16.099 16.099 0 0 0-2.89-10.656a17.143 17.143 0 0 0-18.398-6.828a15.786 15.786 0 0 0-4.402 1.935l-71.67 45.674a14.898 14.898 0 0 0-6.73 9.975a15.9 15.9 0 0 0 2.709 12.012a17.156 17.156 0 0 0 18.404 6.832a15.841 15.841 0 0 0 4.402-1.935l27.345-17.427a52.147 52.147 0 0 1 14.552-6.397c23.101-6.006 47.497 3.037 61.102 22.65a52.681 52.681 0 0 1 9.003 39.848a49.453 49.453 0 0 1-22.34 33.12l-71.664 45.673a52.218 52.218 0 0 1-14.563 6.398"></path></svg>
|
After Width: | Height: | Size: 1.9 KiB |
6
static/tauri.svg
Normal file
@ -0,0 +1,6 @@
|
||||
<svg width="206" height="231" viewBox="0 0 206 231" fill="none" xmlns="http://www.w3.org/2000/svg">
|
||||
<path d="M143.143 84C143.143 96.1503 133.293 106 121.143 106C108.992 106 99.1426 96.1503 99.1426 84C99.1426 71.8497 108.992 62 121.143 62C133.293 62 143.143 71.8497 143.143 84Z" fill="#FFC131"/>
|
||||
<ellipse cx="84.1426" cy="147" rx="22" ry="22" transform="rotate(180 84.1426 147)" fill="#24C8DB"/>
|
||||
<path fill-rule="evenodd" clip-rule="evenodd" d="M166.738 154.548C157.86 160.286 148.023 164.269 137.757 166.341C139.858 160.282 141 153.774 141 147C141 144.543 140.85 142.121 140.558 139.743C144.975 138.204 149.215 136.139 153.183 133.575C162.73 127.404 170.292 118.608 174.961 108.244C179.63 97.8797 181.207 86.3876 179.502 75.1487C177.798 63.9098 172.884 53.4021 165.352 44.8883C157.82 36.3744 147.99 30.2165 137.042 27.1546C126.095 24.0926 114.496 24.2568 103.64 27.6274C92.7839 30.998 83.1319 37.4317 75.8437 46.1553C74.9102 47.2727 74.0206 48.4216 73.176 49.5993C61.9292 50.8488 51.0363 54.0318 40.9629 58.9556C44.2417 48.4586 49.5653 38.6591 56.679 30.1442C67.0505 17.7298 80.7861 8.57426 96.2354 3.77762C111.685 -1.01901 128.19 -1.25267 143.769 3.10474C159.348 7.46215 173.337 16.2252 184.056 28.3411C194.775 40.457 201.767 55.4101 204.193 71.404C206.619 87.3978 204.374 103.752 197.73 118.501C191.086 133.25 180.324 145.767 166.738 154.548ZM41.9631 74.275L62.5557 76.8042C63.0459 72.813 63.9401 68.9018 65.2138 65.1274C57.0465 67.0016 49.2088 70.087 41.9631 74.275Z" fill="#FFC131"/>
|
||||
<path fill-rule="evenodd" clip-rule="evenodd" d="M38.4045 76.4519C47.3493 70.6709 57.2677 66.6712 67.6171 64.6132C65.2774 70.9669 64 77.8343 64 85.0001C64 87.1434 64.1143 89.26 64.3371 91.3442C60.0093 92.8732 55.8533 94.9092 51.9599 97.4256C42.4128 103.596 34.8505 112.392 30.1816 122.756C25.5126 133.12 23.9357 144.612 25.6403 155.851C27.3449 167.09 32.2584 177.598 39.7906 186.112C47.3227 194.626 57.153 200.784 68.1003 203.846C79.0476 206.907 90.6462 206.743 101.502 203.373C112.359 200.002 122.011 193.568 129.299 184.845C130.237 183.722 131.131 182.567 131.979 181.383C143.235 180.114 154.132 176.91 164.205 171.962C160.929 182.49 155.596 192.319 148.464 200.856C138.092 213.27 124.357 222.426 108.907 227.222C93.458 232.019 76.9524 232.253 61.3736 227.895C45.7948 223.538 31.8055 214.775 21.0867 202.659C10.3679 190.543 3.37557 175.59 0.949823 159.596C-1.47592 143.602 0.768139 127.248 7.41237 112.499C14.0566 97.7497 24.8183 85.2327 38.4045 76.4519ZM163.062 156.711L163.062 156.711C162.954 156.773 162.846 156.835 162.738 156.897C162.846 156.835 162.954 156.773 163.062 156.711Z" fill="#24C8DB"/>
|
||||
</svg>
|
After Width: | Height: | Size: 2.5 KiB |
1
static/vite.svg
Normal file
@ -0,0 +1 @@
|
||||
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" aria-hidden="true" role="img" class="iconify iconify--logos" width="31.88" height="32" preserveAspectRatio="xMidYMid meet" viewBox="0 0 256 257"><defs><linearGradient id="IconifyId1813088fe1fbc01fb466" x1="-.828%" x2="57.636%" y1="7.652%" y2="78.411%"><stop offset="0%" stop-color="#41D1FF"></stop><stop offset="100%" stop-color="#BD34FE"></stop></linearGradient><linearGradient id="IconifyId1813088fe1fbc01fb467" x1="43.376%" x2="50.316%" y1="2.242%" y2="89.03%"><stop offset="0%" stop-color="#FFEA83"></stop><stop offset="8.333%" stop-color="#FFDD35"></stop><stop offset="100%" stop-color="#FFA800"></stop></linearGradient></defs><path fill="url(#IconifyId1813088fe1fbc01fb466)" d="M255.153 37.938L134.897 252.976c-2.483 4.44-8.862 4.466-11.382.048L.875 37.958c-2.746-4.814 1.371-10.646 6.827-9.67l120.385 21.517a6.537 6.537 0 0 0 2.322-.004l117.867-21.483c5.438-.991 9.574 4.796 6.877 9.62Z"></path><path fill="url(#IconifyId1813088fe1fbc01fb467)" d="M185.432.063L96.44 17.501a3.268 3.268 0 0 0-2.634 3.014l-5.474 92.456a3.268 3.268 0 0 0 3.997 3.378l24.777-5.718c2.318-.535 4.413 1.507 3.936 3.838l-7.361 36.047c-.495 2.426 1.782 4.5 4.151 3.78l15.304-4.649c2.372-.72 4.652 1.36 4.15 3.788l-11.698 56.621c-.732 3.542 3.979 5.473 5.943 2.437l1.313-2.028l72.516-144.72c1.215-2.423-.88-5.186-3.54-4.672l-25.505 4.922c-2.396.462-4.435-1.77-3.759-4.114l16.646-57.705c.677-2.35-1.37-4.583-3.769-4.113Z"></path></svg>
|
After Width: | Height: | Size: 1.5 KiB |
18
svelte.config.js
Normal file
@ -0,0 +1,18 @@
|
||||
// Tauri doesn't have a Node.js server to do proper SSR
|
||||
// so we will use adapter-static to prerender the app (SSG)
|
||||
// See: https://v2.tauri.app/start/frontend/sveltekit/ for more info
|
||||
import adapter from "@sveltejs/adapter-static";
|
||||
import { vitePreprocess } from '@sveltejs/vite-plugin-svelte';
|
||||
|
||||
/** @type {import('@sveltejs/kit').Config} */
|
||||
const config = {
|
||||
kit: {
|
||||
adapter: adapter(),
|
||||
alias: {
|
||||
$lib: 'src/lib'
|
||||
}
|
||||
},
|
||||
preprocess: vitePreprocess()
|
||||
};
|
||||
|
||||
export default config;
|
36
vite.config.js
Normal file
@ -0,0 +1,36 @@
|
||||
import { defineConfig } from "vite";
|
||||
import { sveltekit } from "@sveltejs/kit/vite";
|
||||
|
||||
// @ts-expect-error process is a nodejs global
|
||||
const host = process.env.TAURI_DEV_HOST;
|
||||
|
||||
// https://vitejs.dev/config/
|
||||
export default defineConfig(async () => ({
|
||||
plugins: [sveltekit()],
|
||||
resolve: {
|
||||
alias: {
|
||||
$lib: "/src/lib",
|
||||
},
|
||||
},
|
||||
// Vite options tailored for Tauri development and only applied in `tauri dev` or `tauri build`
|
||||
//
|
||||
// 1. prevent vite from obscuring rust errors
|
||||
clearScreen: false,
|
||||
// 2. tauri expects a fixed port, fail if that port is not available
|
||||
server: {
|
||||
port: 1420,
|
||||
strictPort: true,
|
||||
host: host || false,
|
||||
hmr: host
|
||||
? {
|
||||
protocol: "ws",
|
||||
host,
|
||||
port: 1421,
|
||||
}
|
||||
: undefined,
|
||||
watch: {
|
||||
// 3. tell vite to ignore watching `src-tauri`
|
||||
ignored: ["**/src-tauri/**"],
|
||||
},
|
||||
},
|
||||
}));
|