Skip to content
This repository was archived by the owner on Oct 22, 2021. It is now read-only.

Commit 70dbb3f

Browse files
authored
feat: added a more detailed process view modal (#922)
1 parent b2269ea commit 70dbb3f

File tree

5 files changed

+134
-9
lines changed

5 files changed

+134
-9
lines changed

src/assets/css/mod_processlist.css

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
table#processContainer {
2+
display: block;
3+
max-height: 60vh;
4+
overflow: auto;
5+
}
6+
7+
table#processContainer td.header {
8+
font-weight: bold;
9+
background: rgba(var(--color_r), var(--color_g), var(--color_b), 0.6);
10+
color: var(--color_light_black);
11+
text-align: center;
12+
}
13+
14+
table#processContainer td.pid {
15+
width: 5vw;
16+
}
17+
18+
table#processContainer td.name {
19+
width: 12vw;
20+
}
21+
22+
table#processContainer td.user {
23+
width: 7vw;
24+
}
25+
26+
table#processContainer td.cpu {
27+
width: 3vw;
28+
text-align: center;
29+
}
30+
31+
table#processContainer td.mem{
32+
width: 3vw;
33+
text-align: center;
34+
35+
}
36+
table#processContainer td.state {
37+
width: 6vw;
38+
text-align: center;
39+
}
40+
table#processContainer td.started {
41+
width: 11vw;
42+
43+
}
44+
45+
table#processContainer td.runtime {
46+
width: 5vw;
47+
}
48+

src/assets/css/mod_toplist.css

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,10 @@ div#mod_toplist::before {
1717
height: 0.833vh;
1818
}
1919

20+
div#mod_toplist:hover {
21+
cursor: pointer;
22+
}
23+
2024
div#mod_toplist::after {
2125
content: "";
2226
border-right: 0.092vh solid rgba(var(--color_r), var(--color_g), var(--color_b), 0.3);

src/classes/filesystem.class.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -551,7 +551,7 @@ class FilesystemDisplay {
551551

552552
if (typeof name === "number") {
553553
block = this.cwd[name];
554-
name = block.name
554+
name = block.name;
555555
}
556556

557557
block.path = block.path.replace(/\\/g, "/");

src/classes/toplist.class.js

Lines changed: 80 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ class Toplist {
88
this._element.setAttribute("id", "mod_toplist");
99
this._element.innerHTML = `<h1>TOP PROCESSES<i>PID | NAME | CPU | MEM</i></h1><br>
1010
<table id="mod_toplist_table"></table>`;
11+
this._element.onclick = this.processList;
1112

1213
this.parent.append(this._element);
1314

@@ -20,15 +21,15 @@ class Toplist {
2021
window.si.processes().then(data => {
2122
if (window.settings.excludeThreadsFromToplist === true) {
2223
data.list = data.list.sort((a, b) => {
23-
return (a.pid-b.pid);
24+
return (a.pid-b.pid);
2425
}).filter((e, index, a) => {
25-
let i = a.findIndex(x => x.name === e.name);
26-
if (i !== -1 && i !== index) {
27-
a[i].pcpu = a[i].pcpu+e.pcpu;
28-
a[i].pmem = a[i].pmem+e.pmem;
29-
return false;
30-
}
31-
return true;
26+
let i = a.findIndex(x => x.name === e.name);
27+
if (i !== -1 && i !== index) {
28+
a[i].pcpu = a[i].pcpu+e.pcpu;
29+
a[i].pmem = a[i].pmem+e.pmem;
30+
return false;
31+
}
32+
return true;
3233
});
3334
}
3435

@@ -49,6 +50,77 @@ class Toplist {
4950
});
5051
});
5152
}
53+
54+
processList(){
55+
function updateProcessList(){
56+
window.si.processes().then(data => {
57+
if (window.settings.excludeThreadsFromToplist === true) {
58+
data.list = data.list.sort((a, b) => {
59+
return (a.pid-b.pid);
60+
}).filter((e, index, a) => {
61+
let i = a.findIndex(x => x.name === e.name);
62+
if (i !== -1 && i !== index) {
63+
a[i].pcpu = a[i].pcpu+e.pcpu;
64+
a[i].pmem = a[i].pmem+e.pmem;
65+
return false;
66+
}
67+
return true;
68+
});
69+
}
70+
71+
let list = data.list.sort((a, b) => {
72+
return ((b.pcpu-a.pcpu)*100 + b.pmem-a.pmem);
73+
});//.splice(0, 30);
74+
75+
document.querySelectorAll("#processList > tr").forEach(el => {
76+
el.remove();
77+
});
78+
79+
list.forEach(proc => {
80+
let runtime = new Date(Date.now() - Date.parse(proc.started));
81+
let el = document.createElement("tr");
82+
el.innerHTML = `<td class="pid">${proc.pid}</td>
83+
<td class="name">${proc.name}</td>
84+
<td class="user">${proc.user}</td>
85+
<td class="cpu">${Math.round(proc.pcpu*10)/10}%</td>
86+
<td class="mem">${Math.round(proc.pmem*10)/10}%</td>
87+
<td class="state">${proc.state}</td>
88+
<td class="started">${proc.started}</td>
89+
<td class="runtime">${runtime.getHours()}:${runtime.getMinutes()}:${runtime.getSeconds()}</td>`;
90+
document.getElementById("processList").append(el);
91+
});
92+
});
93+
}
94+
95+
window.keyboard.detach();
96+
new Modal(
97+
{
98+
type: "custom",
99+
title: "Active Processes",
100+
html: `
101+
<table id=\"processContainer\">
102+
<thead>
103+
<tr>
104+
<td class="pid header">PID</td>
105+
<td class="name header">Name</td>
106+
<td class="user header">User</td>
107+
<td class="cpu header">CPU</td>
108+
<td class="mem header">Memory</td>
109+
<td class="state header">State</td>
110+
<td class="started header">Started</td>
111+
<td class="runtime header">Runtime</td>
112+
</tr>
113+
</thead>
114+
<tbody id=\"processList\">
115+
</tbody>
116+
</table>`,
117+
}
118+
);
119+
updateProcessList();
120+
window.keyboard.attach();
121+
window.term[window.currentTerm].term.focus();
122+
setInterval(updateProcessList, 2000);
123+
}
52124
}
53125

54126
module.exports = {

src/ui.html

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828
<link rel="stylesheet" href="assets/css/mod_ramwatcher.css" />
2929
<link rel="stylesheet" href="assets/css/mod_toplist.css" />
3030
<link rel="stylesheet" href="assets/css/mod_fuzzyFinder.css" />
31+
<link rel="stylesheet" href="assets/css/mod_processlist.css" />
3132
<!-- Load extra CSS -->
3233
<link rel="stylesheet" href="assets/css/extra_ratios.css" />
3334

0 commit comments

Comments
 (0)