mirror of
https://github.com/kunkunsh/kunkun-ext-neohtop.git
synced 2025-04-11 17:29:45 +00:00
Merge pull request #79 from Abdenasser/pin-by-command
pin processes by command
This commit is contained in:
commit
a25bb925cd
@ -12,10 +12,10 @@
|
|||||||
export let columns: Column[];
|
export let columns: Column[];
|
||||||
export let systemStats: { memory_total: number } | null;
|
export let systemStats: { memory_total: number } | null;
|
||||||
export let sortConfig: { field: keyof Process; direction: "asc" | "desc" };
|
export let sortConfig: { field: keyof Process; direction: "asc" | "desc" };
|
||||||
export let pinnedProcesses: Set<number>;
|
export let pinnedProcesses: Set<string>;
|
||||||
|
|
||||||
export let onToggleSort: (field: keyof Process) => void;
|
export let onToggleSort: (field: keyof Process) => void;
|
||||||
export let onTogglePin: (pid: number) => void;
|
export let onTogglePin: (command: string) => void;
|
||||||
export let onShowDetails: (process: Process) => void;
|
export let onShowDetails: (process: Process) => void;
|
||||||
export let onKillProcess: (process: Process) => void;
|
export let onKillProcess: (process: Process) => void;
|
||||||
|
|
||||||
@ -111,7 +111,7 @@
|
|||||||
<tr
|
<tr
|
||||||
class:high-usage={process.cpu_usage > 50 ||
|
class:high-usage={process.cpu_usage > 50 ||
|
||||||
process.memory_usage / (systemStats?.memory_total || 0) > 0.1}
|
process.memory_usage / (systemStats?.memory_total || 0) > 0.1}
|
||||||
class:pinned={pinnedProcesses.has(process.pid)}
|
class:pinned={pinnedProcesses.has(process.command)}
|
||||||
>
|
>
|
||||||
{#each columns.filter((col) => col.visible) as column}
|
{#each columns.filter((col) => col.visible) as column}
|
||||||
<td class="truncate">
|
<td class="truncate">
|
||||||
@ -138,9 +138,9 @@
|
|||||||
<div class="action-buttons">
|
<div class="action-buttons">
|
||||||
<button
|
<button
|
||||||
class="btn-action pin-btn"
|
class="btn-action pin-btn"
|
||||||
class:pinned={pinnedProcesses.has(process.pid)}
|
class:pinned={pinnedProcesses.has(process.command)}
|
||||||
on:click={() => onTogglePin(process.pid)}
|
on:click={() => onTogglePin(process.command)}
|
||||||
title={pinnedProcesses.has(process.pid) ? "Unpin" : "Pin"}
|
title={pinnedProcesses.has(process.command) ? "Unpin" : "Pin"}
|
||||||
>
|
>
|
||||||
<Fa icon={faThumbtack} />
|
<Fa icon={faThumbtack} />
|
||||||
</button>
|
</button>
|
||||||
|
@ -18,7 +18,7 @@
|
|||||||
let isLoading = true;
|
let isLoading = true;
|
||||||
let currentPage = 1;
|
let currentPage = 1;
|
||||||
let itemsPerPage = 15;
|
let itemsPerPage = 15;
|
||||||
let pinnedProcesses: Set<number> = new Set();
|
let pinnedProcesses: Set<string> = new Set();
|
||||||
let selectedProcess: Process | null = null;
|
let selectedProcess: Process | null = null;
|
||||||
let showInfoModal = false;
|
let showInfoModal = false;
|
||||||
let showConfirmModal = false;
|
let showConfirmModal = false;
|
||||||
@ -125,8 +125,8 @@
|
|||||||
});
|
});
|
||||||
|
|
||||||
$: sortedProcesses = filteredProcesses.sort((a, b) => {
|
$: sortedProcesses = filteredProcesses.sort((a, b) => {
|
||||||
const aPin = pinnedProcesses.has(a.pid);
|
const aPin = pinnedProcesses.has(a.command);
|
||||||
const bPin = pinnedProcesses.has(b.pid);
|
const bPin = pinnedProcesses.has(b.command);
|
||||||
if (aPin && !bPin) return -1;
|
if (aPin && !bPin) return -1;
|
||||||
if (!aPin && bPin) return 1;
|
if (!aPin && bPin) return 1;
|
||||||
|
|
||||||
@ -206,11 +206,11 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function togglePin(pid: number) {
|
function togglePin(command: string) {
|
||||||
if (pinnedProcesses.has(pid)) {
|
if (pinnedProcesses.has(command)) {
|
||||||
pinnedProcesses.delete(pid);
|
pinnedProcesses.delete(command);
|
||||||
} else {
|
} else {
|
||||||
pinnedProcesses.add(pid);
|
pinnedProcesses.add(command);
|
||||||
}
|
}
|
||||||
pinnedProcesses = pinnedProcesses; // Trigger reactivity
|
pinnedProcesses = pinnedProcesses; // Trigger reactivity
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user