-
Notifications
You must be signed in to change notification settings - Fork 19
/
progress.mjs
100 lines (87 loc) · 1.68 KB
/
progress.mjs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
import { ConsoleManager, Progress, ConfirmPopup } from "../dist/esm/ConsoleGui.mjs"
const opt = {
title: "Progress Bar Test",
layoutOptions: {
type: "single"
},
logLocation: "popup",
enableMouse: true
}
const GUI = new ConsoleManager(opt)
GUI.on("exit", () => {
closeApp()
})
GUI.on("keypressed", (key) => {
switch (key.name) {
case "q":
new ConfirmPopup({
id: "popupQuit",
title: "Are you sure you want to quit?"
}).show().on("confirm", () => closeApp())
break
default:
break
}
})
const closeApp = () => {
console.clear()
process.exit()
}
GUI.refresh()
const p1 = new Progress({
id: "htop-mem",
x: 2,
y: 1,
label: "Mem",
length: 40,
min: 0,
max: 100,
unit: "G",
style: {
boxed: true,
theme: "htop",
showMinMax: false,
}
})
setInterval(() => {
p1.setValue(Math.floor(Math.random() * 100))
}, 400)
new Progress({
id: "interactive",
x: 2,
y: 3,
length: 40,
thickness: 3,
label: "Interactive Progress (use scroll wheel)",
min: 0,
max: 100,
value: 50,
interactive: true,
increment: 1,
style: {
boxed: true,
theme: "precision",
color: "green",
showMinMax: true,
}
})
const p2 = new Progress({
id: "vertical",
x: 2,
y: 6,
label: "Vertical Progress",
length: 20,
min: 0,
max: 100,
unit: "%",
orientation: "vertical",
style: {
boxed: true,
theme: "precision",
showMinMax: false,
showLabel: true,
}
})
setInterval(() => {
p2.setValue(Math.floor(Math.random() * 100))
}, 400)