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

Commit 7bc0f42

Browse files
committed
🔀 Replace mod_syslog with mod_toplist
(merge branch move-suprompt-to-backend)
1 parent 246ae72 commit 7bc0f42

File tree

8 files changed

+106
-143
lines changed

8 files changed

+106
-143
lines changed

src/_boot.js

Lines changed: 44 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ process.on("uncaughtException", e => {
77
if (tty) {
88
tty.tty.kill();
99
}
10-
app.exit(1);
1110
});
1211

1312
signale.start(`Starting eDEX-UI v${app.getVersion()}`);
@@ -79,6 +78,49 @@ fs.readdirSync(innerFontsDir).forEach((e) => {
7978
fs.writeFileSync(path.join(fontsDir, e), fs.readFileSync(path.join(innerFontsDir, e)));
8079
});
8180

81+
function createWindow(settings) {
82+
signale.info("Creating window...");
83+
let {x, y, width, height} = electron.screen.getPrimaryDisplay().bounds;
84+
width++; height++;
85+
win = new BrowserWindow({
86+
title: "eDEX-UI",
87+
x,
88+
y,
89+
width,
90+
height,
91+
show: false,
92+
resizable: true,
93+
movable: settings.allowWindowed || false,
94+
fullscreen: true,
95+
autoHideMenuBar: true,
96+
frame: settings.allowWindowed || false,
97+
backgroundColor: '#000000',
98+
webPreferences: {
99+
devTools: true,
100+
backgroundThrottling: false,
101+
webSecurity: true,
102+
allowRunningInsecureContent: false,
103+
experimentalFeatures: settings.experimentalFeatures || false
104+
}
105+
});
106+
107+
win.loadURL(url.format({
108+
pathname: path.join(__dirname, 'ui.html'),
109+
protocol: 'file:',
110+
slashes: true
111+
}));
112+
113+
win.once("ready-to-show", () => {
114+
signale.complete("Frontend window is up!");
115+
win.show();
116+
if (!settings.allowWindowed) {
117+
win.setResizable(false);
118+
}
119+
});
120+
121+
signale.watch("Waiting for frontend connection...");
122+
}
123+
82124
app.on('ready', () => {
83125
signale.pending(`Loading settings file...`);
84126
let settings = require(settingsFile);
@@ -122,46 +164,7 @@ app.on('ready', () => {
122164
}
123165
});
124166

125-
signale.info("Creating window...");
126-
let {x, y, width, height} = electron.screen.getPrimaryDisplay().bounds;
127-
width++; height++;
128-
win = new BrowserWindow({
129-
title: "eDEX-UI",
130-
x,
131-
y,
132-
width,
133-
height,
134-
show: false,
135-
resizable: true,
136-
movable: settings.allowWindowed || false,
137-
fullscreen: true,
138-
autoHideMenuBar: true,
139-
frame: settings.allowWindowed || false,
140-
backgroundColor: '#000000',
141-
webPreferences: {
142-
devTools: true,
143-
backgroundThrottling: false,
144-
webSecurity: true,
145-
allowRunningInsecureContent: false,
146-
experimentalFeatures: settings.experimentalFeatures || false
147-
}
148-
});
149-
150-
win.loadURL(url.format({
151-
pathname: path.join(__dirname, 'ui.html'),
152-
protocol: 'file:',
153-
slashes: true
154-
}));
155-
156-
win.once("ready-to-show", () => {
157-
signale.complete("Frontend window is up!");
158-
win.show();
159-
if (!settings.allowWindowed) {
160-
win.setResizable(false);
161-
}
162-
});
163-
164-
signale.watch("Waiting for frontend connection...");
167+
createWindow(settings);
165168
});
166169

167170
app.on('web-contents-created', (e, contents) => {

src/_renderer.js

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -223,7 +223,7 @@ initMods = () => {
223223
window.mods.sysinfo = new Sysinfo("mod_column_left");
224224
window.mods.cpuinfo = new Cpuinfo("mod_column_left");
225225
window.mods.ramwatcher = new RAMwatcher("mod_column_left");
226-
window.mods.syslog = new Syslog("mod_column_left");
226+
window.mods.toplist = new Toplist("mod_column_left");
227227
window.mods.clipboardButtons = new ClipboardButtons("mod_column_left");
228228

229229
// Right column
@@ -305,8 +305,6 @@ window.themeChanger = (theme) => {
305305
window.mods.globe.globe.destroy();
306306
window.removeEventListener("resize", window.mods.globe.resizeHandler);
307307

308-
if (process.platform === "linux" || process.platform === "darwin") window.mods.syslog.tail.unwatch();
309-
310308
window._loadTheme(require(src));
311309
for (let i; i < 99999; i++) {
312310
clearInterval(i);

src/assets/css/mod_ramwatcher.css

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ div#mod_ramwatcher_inner > h1:first-child > i {
4646
text-align: right;
4747
display: inline-block;
4848
position: relative;
49-
bottom: 1.9vh;
49+
bottom: 1.6vh;
5050
width: 100%;
5151
}
5252

Lines changed: 14 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
div#mod_syslog {
1+
div#mod_toplist {
22
border-top: 0.092vh solid rgba(var(--color_r), var(--color_g), var(--color_b), 0.3);
33
font-family: var(--font_main_light);
44
letter-spacing: 0.092vh;
@@ -7,7 +7,7 @@ div#mod_syslog {
77
flex-wrap: wrap;
88
}
99

10-
div#mod_syslog::before {
10+
div#mod_toplist::before {
1111
content: "";
1212
border-left: 0.092vh solid rgba(var(--color_r), var(--color_g), var(--color_b), 0.3);
1313
align-self: flex-start;
@@ -17,7 +17,7 @@ div#mod_syslog::before {
1717
height: 0.833vh;
1818
}
1919

20-
div#mod_syslog::after {
20+
div#mod_toplist::after {
2121
content: "";
2222
border-right: 0.092vh solid rgba(var(--color_r), var(--color_g), var(--color_b), 0.3);
2323
position: relative;
@@ -26,41 +26,32 @@ div#mod_syslog::after {
2626
height: 0.833vh;
2727
}
2828

29-
div#mod_syslog h1 {
29+
div#mod_toplist h1 {
3030
font-size: 1.48vh;
3131
margin: 0vh;
3232
margin-bottom: -1vh;
33-
width: 98%;
33+
width: 97%;
34+
padding-left: 0.5vh;
3435
}
3536

36-
div#mod_syslog i {
37+
div#mod_toplist i {
3738
font-style: normal;
3839
font-size: 1.20vh;
3940
opacity: 0.5;
4041
text-align: right;
4142
display: inline-block;
4243
position: relative;
43-
bottom: 1.78vh;
44+
bottom: 1.6vh;
4445
width: 100%;
4546
}
4647

47-
div#mod_syslog pre {
48-
overflow: hidden;
49-
white-space: pre-wrap;
48+
table#mod_toplist_table {
5049
margin: 0px;
51-
height: 9.8vh;
52-
margin-top: 0.2vh;
53-
width: 99%;
54-
margin-left: 1%;
55-
display: flex;
56-
align-items: flex-end;
57-
justify-content: flex-start;
58-
opacity: 0.8;
50+
margin-bottom: 0.2vh;
51+
width: 97%;
52+
padding-left: 0.5vh;
5953
}
6054

61-
div#mod_syslog pre:empty::after {
62-
content: "NO LOG";
63-
margin: auto;
64-
position: relative;
65-
right: 0.5vh;
55+
table#mod_toplist_table > td {
56+
6657
}

src/classes/syslog.class.js

Lines changed: 0 additions & 72 deletions
This file was deleted.

src/classes/toplist.class.js

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
class Toplist {
2+
constructor(parentId) {
3+
if (!parentId) throw "Missing parameters";
4+
5+
this.si = require("systeminformation");
6+
7+
// Create DOM
8+
this.parent = document.getElementById(parentId);
9+
this._element = document.createElement("div");
10+
this._element.setAttribute("id", "mod_toplist");
11+
this._element.innerHTML = `<h1>TOP PROCESSES<i>PID | NAME | CPU | MEM</i></h1><br>
12+
<table id="mod_toplist_table"></table>`;
13+
14+
this.parent.append(this._element);
15+
16+
this.updateList();
17+
this.listUpdater = setInterval(() => {
18+
this.updateList();
19+
}, 5000);
20+
}
21+
updateList() {
22+
this.si.processes().then(data => {
23+
let list = data.list.sort((a, b) => {
24+
return ((b.pcpu-a.pcpu)*100 + b.pmem-a.pmem);
25+
}).splice(0, 5);
26+
27+
document.querySelectorAll("#mod_toplist_table > tr").forEach(el => {
28+
el.remove();
29+
});
30+
list.forEach(proc => {
31+
let el = document.createElement("tr");
32+
el.innerHTML = `<td>${proc.pid}</td>
33+
<td><strong>${proc.name}</strong></td>
34+
<td>${Math.round(proc.pcpu)}%</td>
35+
<td>${proc.pmem}%</td>`;
36+
document.getElementById("mod_toplist_table").append(el);
37+
});
38+
});
39+
}
40+
}
41+
42+
module.exports = {
43+
Toplist
44+
};

src/package.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,6 @@
2929
"pretty-bytes": "5.1.0",
3030
"signale": "1.3.0",
3131
"smoothie": "1.35.0",
32-
"sudo-prompt": "8.2.3",
3332
"systeminformation": "3.45.6",
3433
"tail": "1.3.0",
3534
"ws": "6.0.0",

src/ui.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
<link rel="stylesheet" href="assets/css/mod_conninfo.css" />
2424
<link rel="stylesheet" href="assets/css/mod_globe.css" />
2525
<link rel="stylesheet" href="assets/css/mod_ramwatcher.css" />
26-
<link rel="stylesheet" href="assets/css/mod_syslog.css" />
26+
<link rel="stylesheet" href="assets/css/mod_toplist.css" />
2727
<link rel="stylesheet" href="assets/css/mod_clipboardButtons.css" />
2828

2929
<!-- Load main modules classes -->
@@ -40,7 +40,7 @@
4040
<script src="classes/conninfo.class.js"></script>
4141
<script src="classes/locationGlobe.class.js"></script>
4242
<script src="classes/ramwatcher.class.js"></script>
43-
<script src="classes/syslog.class.js"></script>
43+
<script src="classes/toplist.class.js"></script>
4444
<script src="classes/clipboardButtons.class.js"></script>
4545
</head>
4646
<body class="solidBackground">

0 commit comments

Comments
 (0)