Skip to content

Commit 080c868

Browse files
author
sarthakpranesh
committed
Added swap, memory and other cpu details
Signed-off-by: sarthakpranesh <[email protected]>
1 parent 434e7b3 commit 080c868

16 files changed

+215
-75
lines changed

appicon.png

106 KB
Loading

build/cpuRoller

75.9 KB
Binary file not shown.

build/cpuRoller-darwin-10.6-amd64

9.47 MB
Binary file not shown.

cpuRoller-res.syso

39.9 KB
Binary file not shown.

cpuRoller.exe.manifest

+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
2+
<assembly manifestVersion="1.0" xmlns="urn:schemas-microsoft-com:asm.v1" xmlns:asmv3="urn:schemas-microsoft-com:asm.v3">
3+
<assemblyIdentity type="win32" name="MyApplication" version="1.0.0.0" processorArchitecture="amd64"/>
4+
5+
<asmv3:application>
6+
<asmv3:windowsSettings>
7+
<dpiAware xmlns="http://schemas.microsoft.com/SMI/2005/WindowsSettings">true/pm</dpiAware> <!-- fallback for Windows 7 and 8 -->
8+
<dpiAwareness xmlns="http://schemas.microsoft.com/SMI/2016/WindowsSettings">permonitorv2,permonitor</dpiAwareness> <!-- falls back to per-monitor if per-monitor v2 is not supported -->
9+
<gdiScaling xmlns="http://schemas.microsoft.com/SMI/2017/WindowsSettings">true</gdiScaling> <!-- enables GDI DPI scaling -->
10+
</asmv3:windowsSettings>
11+
</asmv3:application>
12+
</assembly>

cpuRoller.ico

38.4 KB
Binary file not shown.

cpuRoller.rc

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
100 ICON "cpuRoller.ico"
2+
110 24 "cpuRoller.exe.manifest"

frontend/src/App.css

+30-26
Original file line numberDiff line numberDiff line change
@@ -1,38 +1,42 @@
1+
/* Background color: #162447
2+
Cards overlay: #1f4068
3+
Primary Text: #ececec
4+
Secondary Text: #e43f5a */
5+
16
.App {
2-
text-align: center;
7+
display: flex;
8+
flex-direction: column;
9+
justify-content: center;
10+
align-items: center;
11+
height: 100vh;
12+
width: 100vw;
13+
background-color: #162447;
14+
overflow: hidden;
315
}
416

5-
.App-logo {
6-
height: 40vmin;
7-
pointer-events: none;
17+
.PrimaryText {
18+
color: #ececec;
19+
font-weight: 600;
820
}
921

10-
@media (prefers-reduced-motion: no-preference) {
11-
.App-logo {
12-
animation: App-logo-spin infinite 20s linear;
13-
}
22+
.SecondaryText {
23+
color: #e43f5a;
24+
font-weight: 600;
1425
}
1526

16-
.App-header {
17-
background-color: #282c34;
18-
min-height: 100vh;
19-
display: flex;
20-
flex-direction: column;
21-
align-items: center;
22-
justify-content: center;
23-
font-size: calc(10px + 2vmin);
24-
color: white;
27+
.SysInfo {
28+
align-self: flex-start;
29+
margin: 4px 100px;
2530
}
2631

27-
.App-link {
28-
color: #61dafb;
32+
.GridContainer {
33+
display: grid;
34+
grid-template-columns: auto auto auto;
35+
margin: 10px;
2936
}
3037

31-
@keyframes App-logo-spin {
32-
from {
33-
transform: rotate(0deg);
34-
}
35-
to {
36-
transform: rotate(360deg);
37-
}
38+
.GridItem {
39+
display: flex;
40+
justify-content: center;
41+
align-items: center;
3842
}

frontend/src/App.js

+47-5
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,55 @@
1-
import React from 'react';
1+
import React, {useState, useEffect} from 'react';
22
import './App.css';
3-
import CPU from './components/CPU';
3+
4+
// importing components
5+
import SectionTable from './components/SectionTable/index.js'
46

57
function App() {
8+
const [result, setResult] = useState(null);
9+
10+
useEffect(() => {
11+
window.backend.initStats().then((result) => setResult(result));
12+
setInterval(() => {
13+
window.backend.updateCPUStats().then((result) => {
14+
console.log(result)
15+
setResult(result)
16+
});
17+
}, 1000);
18+
}, [])
19+
620
return (
721
<div id="app" className="App">
8-
<header className="App-header">
9-
<CPU />
10-
</header>
22+
<h2 className="PrimaryText SysInfo">Operating System: {result !== null ? result.Os : "..."}</h2>
23+
<h2 className="PrimaryText SysInfo">System Arch: {result !== null ? result.Arch : "..."}</h2>
24+
<div className="GridContainer">
25+
<div className="GridItem">
26+
<SectionTable title="CPU Info" data={{
27+
"Cores": result !== null ? result.Count : 0,
28+
"Threads": result !== null ? (result.CPUInfo.length !== 0 ? result.CPUInfo.length : 0) : 0,
29+
"Usage": result !== null ? result.Usage : 0,
30+
"Name": result !== null ? (result.CPUInfo.length !== 0 ? result.CPUInfo[0].modelName : "...") : "...",
31+
}}
32+
/>
33+
</div>
34+
<div className="GridItem">
35+
<SectionTable title="System RAM" data={{
36+
Total: result !== null ? result.Mem.total : 0,
37+
Used: result !== null ? result.Mem.used : 0,
38+
Available: result !== null ? result.Mem.available : 0,
39+
"Used %": result !== null ? `${Math.round(result.Mem.usedPercent)}%` : "0%"
40+
}}
41+
/>
42+
</div>
43+
<div className="GridItem">
44+
<SectionTable title="Swap" data={{
45+
Total: result !== null ?result.Swap.total : 0,
46+
Used: result !== null ?result.Swap.used : 0,
47+
Available: result !== null ?result.Swap.free : 0,
48+
"Used %": result !== null ? `${Math.round(result.Swap.usedPercent)}%` : "0%"
49+
}}
50+
/>
51+
</div>
52+
</div>
1153
</div>
1254
);
1355
}

frontend/src/components/CPU.js

-21
This file was deleted.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
import React from 'react';
2+
3+
// importing styles
4+
import './style.css'
5+
6+
const SectionTable = ({title, data, style}) => {
7+
8+
return (
9+
<div className="SectionTableWrapper" style={style}>
10+
<h2 className="SectionTableHeader PrimaryText">{title}</h2>
11+
<table className="SectionTable">
12+
{Object.keys(data).map((key) => {
13+
return (
14+
<tr>
15+
<td className="PrimaryText">{key}</td>
16+
<td className="SecondaryText">{data[key]}</td>
17+
</tr>
18+
)
19+
})}
20+
</table>
21+
</div>
22+
);
23+
}
24+
25+
export default SectionTable;
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
.SectionTableWrapper {
2+
display: flex;
3+
flex-direction: column;
4+
padding: 10px;
5+
margin: 10px;
6+
background-color: #1f4068;
7+
border-radius: 8px;
8+
width: 25vw;
9+
max-height: 20vh;
10+
}
11+
12+
.SectionTableHeader {
13+
align-self: flex-start;
14+
margin-top: 0px;
15+
}
16+
17+
.SectionTable {
18+
width: 100%;
19+
}

go.mod

-2
Original file line numberDiff line numberDiff line change
@@ -10,13 +10,11 @@ require (
1010
github.com/leaanthony/mewn v0.10.7
1111
github.com/leaanthony/slicer v1.4.1 // indirect
1212
github.com/mattn/go-colorable v0.1.7 // indirect
13-
github.com/mgutz/ansi v0.0.0-20200706080929-d51e80ef957d // indirect
1413
github.com/pkg/errors v0.9.1 // indirect
1514
github.com/shirou/gopsutil v2.20.8+incompatible
1615
github.com/wailsapp/wails v1.8.0
1716
golang.org/x/image v0.0.0-20200801110659-972c09e46d76 // indirect
1817
golang.org/x/net v0.0.0-20200904194848-62affa334b73 // indirect
1918
golang.org/x/sys v0.0.0-20200909081042-eff7692f9009 // indirect
20-
gopkg.in/AlecAivazis/survey.v1 v1.8.8 // indirect
2119
gopkg.in/yaml.v3 v3.0.0-20200615113413-eeeca48fe776 // indirect
2220
)

go.sum

-9
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
github.com/AlecAivazis/survey/v2 v2.0.5/go.mod h1:WYBhg6f0y/fNYUuesWQc0PKbJcEliGcYHB9sNT3Bg74=
21
github.com/Masterminds/semver v1.4.2 h1:WBLTQ37jOCzSLtXNdoo8bNM8876KhNqOKvrlGITgsTc=
32
github.com/Masterminds/semver v1.4.2/go.mod h1:MB6lktGJrhw8PrUyiEoblNEGEQ+RzHPF078ddwwvV3Y=
43
github.com/Masterminds/semver v1.5.0 h1:H65muMkzWKEuNDnfl9d70GUjFniHKHRbFPGBuZ3QEww=
@@ -32,7 +31,6 @@ github.com/konsorten/go-windows-terminal-sequences v1.0.1/go.mod h1:T0+1ngSBFLxv
3231
github.com/konsorten/go-windows-terminal-sequences v1.0.2 h1:DB17ag19krx9CFsz4o3enTrPXyIXCl+2iCXH/aMAp9s=
3332
github.com/konsorten/go-windows-terminal-sequences v1.0.2/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ=
3433
github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ=
35-
github.com/kr/pty v1.1.4/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ=
3634
github.com/leaanthony/mewn v0.10.7 h1:jCcNJyIUOpwj+I5SuATvCugDjHkoo+j6ubEOxxrxmPA=
3735
github.com/leaanthony/mewn v0.10.7/go.mod h1:CRkTx8unLiSSilu/Sd7i1LwrdaAL+3eQ3ses99qGMEQ=
3836
github.com/leaanthony/slicer v1.4.0 h1:Q9u4w+UBU4WHjXnEDdz+eRLMKF/rnyosRBiqULnc1J8=
@@ -48,7 +46,6 @@ github.com/leaanthony/wincursor v0.1.0/go.mod h1:7TVwwrzSH/2Y9gLOGH+VhA+bZhoWXBR
4846
github.com/mattn/go-colorable v0.0.9/go.mod h1:9vuHe8Xs5qXnSaW/c/ABM9alt+Vo+STaOChaDxuIBZU=
4947
github.com/mattn/go-colorable v0.1.1 h1:G1f5SKeVxmagw/IyvzvtZE4Gybcc4Tr1tf7I8z0XgOg=
5048
github.com/mattn/go-colorable v0.1.1/go.mod h1:FuOcm+DKB9mbwrcAfNl7/TZVBZ6rcnceauSikq3lYCQ=
51-
github.com/mattn/go-colorable v0.1.2/go.mod h1:U0ppj6V5qS13XJ6of8GYAs25YV2eR4EVcfRqFIhoBtE=
5249
github.com/mattn/go-colorable v0.1.4/go.mod h1:U0ppj6V5qS13XJ6of8GYAs25YV2eR4EVcfRqFIhoBtE=
5350
github.com/mattn/go-colorable v0.1.7 h1:bQGKb3vps/j0E9GfJQ03JyhRuxsvdAanXlT9BTw3mdw=
5451
github.com/mattn/go-colorable v0.1.7/go.mod h1:u6P/XSegPjTcexA+o6vUJrdnUu04hMope9wVRipJSqc=
@@ -63,8 +60,6 @@ github.com/mattn/go-isatty v0.0.12 h1:wuysRhFDzyxgEmMf5xjvJ2M9dZoWAXNNr5LSBS7uHX
6360
github.com/mattn/go-isatty v0.0.12/go.mod h1:cbi8OIDigv2wuxKPP5vlRcQ1OAZbq2CE4Kysco4FUpU=
6461
github.com/mgutz/ansi v0.0.0-20170206155736-9520e82c474b h1:j7+1HpAFS1zy5+Q4qx1fWh90gTKwiN4QCGoY9TWyyO4=
6562
github.com/mgutz/ansi v0.0.0-20170206155736-9520e82c474b/go.mod h1:01TrycV0kFyexm33Z7vhZRXopbI8J3TDReVlkTgMUxE=
66-
github.com/mgutz/ansi v0.0.0-20200706080929-d51e80ef957d h1:5PJl274Y63IEHC+7izoQE9x6ikvDFZS2mDVS3drnohI=
67-
github.com/mgutz/ansi v0.0.0-20200706080929-d51e80ef957d/go.mod h1:01TrycV0kFyexm33Z7vhZRXopbI8J3TDReVlkTgMUxE=
6863
github.com/nfnt/resize v0.0.0-20180221191011-83c6a9932646 h1:zYyBkD/k9seD2A7fsi6Oo2LfFZAehjjQMERAvZLEDnQ=
6964
github.com/nfnt/resize v0.0.0-20180221191011-83c6a9932646/go.mod h1:jpp1/29i3P1S/RLdc7JQKbRpFeM1dOBd8T9ki5s+AY8=
7065
github.com/pkg/browser v0.0.0-20180916011732-0a3d74bf9ce4 h1:49lOXmGaUpV9Fz3gd7TFZY106KVlPVa5jcYD1gaQf98=
@@ -91,7 +86,6 @@ github.com/wailsapp/wails v1.8.0 h1:gnQhpwoGM8s2GD5PZrgMKU1PO3pQ9cdKKJgwtkNz2f4=
9186
github.com/wailsapp/wails v1.8.0/go.mod h1:XFZunea+USOCMMgBlz0A0JHLL3oWrRhnOl4baZlRpxo=
9287
golang.org/x/crypto v0.0.0-20190123085648-057139ce5d2b/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4=
9388
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
94-
golang.org/x/crypto v0.0.0-20190530122614-20be4c3c3ed5/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI=
9589
golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto=
9690
golang.org/x/image v0.0.0-20200430140353-33d19683fad8 h1:6WW6V3x1P/jokJBpRQYUJnMHRP6isStQwCozxnU7XQw=
9791
golang.org/x/image v0.0.0-20200430140353-33d19683fad8/go.mod h1:FeLwcggjj3mMvU+oOTbSwawSJRM1uh48EjtB4UJZlP0=
@@ -108,7 +102,6 @@ golang.org/x/sys v0.0.0-20181228144115-9a3f9b0469bb/go.mod h1:STP8DvDyc/dI5b8T5h
108102
golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
109103
golang.org/x/sys v0.0.0-20190222072716-a9d3bda3a223/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
110104
golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
111-
golang.org/x/sys v0.0.0-20190530182044-ad28b68e88f1/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
112105
golang.org/x/sys v0.0.0-20191026070338-33540a1f6037/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
113106
golang.org/x/sys v0.0.0-20200116001909-b77594299b42/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
114107
golang.org/x/sys v0.0.0-20200223170610-d5e6a3e2c0ae/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
@@ -120,8 +113,6 @@ golang.org/x/text v0.3.0 h1:g61tztE5qeGQ89tm6NTjjM9VPIm088od1l6aSorWRWg=
120113
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
121114
gopkg.in/AlecAivazis/survey.v1 v1.8.4 h1:10xXXN3wgIhPheb5NI58zFgZv32Ana7P3Tl4shW+0Qc=
122115
gopkg.in/AlecAivazis/survey.v1 v1.8.4/go.mod h1:iBNOmqKz/NUbZx3bA+4hAGLRC7fSK7tgtVDT4tB22XA=
123-
gopkg.in/AlecAivazis/survey.v1 v1.8.8 h1:5UtTowJZTz1j7NxVzDGKTz6Lm9IWm8DDF6b7a2wq9VY=
124-
gopkg.in/AlecAivazis/survey.v1 v1.8.8/go.mod h1:CaHjv79TCgAvXMSFJSVgonHXYWxnhzI3eoHtnX5UgUo=
125116
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM=
126117
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
127118
gopkg.in/yaml.v3 v3.0.0-20190709130402-674ba3eaed22 h1:0efs3hwEZhFKsCoP8l6dDB1AZWMgnEl3yWXWRZTOaEA=

main.go

+17-6
Original file line numberDiff line numberDiff line change
@@ -2,16 +2,26 @@ package main
22

33
import (
44
"cpuRoller/pkg/sys"
5-
"fmt"
65

76
"github.com/leaanthony/mewn"
87
"github.com/wailsapp/wails"
98
)
109

11-
func basic() string {
12-
stats := &sys.Stats{}
13-
var cpuUse *sys.CpuUsage = stats.GetCPUUsage()
14-
return fmt.Sprint(cpuUse.Average)
10+
var (
11+
stats = &sys.Stats{}
12+
cpuStats sys.CpuStats
13+
)
14+
15+
func initStats() sys.CpuStats {
16+
cpuStats = stats.GetStats()
17+
return cpuStats
18+
}
19+
20+
func updateCPUStats() sys.CpuStats {
21+
cpuStats.Usage = stats.GetCPUUsage()
22+
cpuStats.Swap = stats.GetSwapMemory()
23+
cpuStats.Mem = stats.GetMemory()
24+
return cpuStats
1525
}
1626

1727
func main() {
@@ -27,6 +37,7 @@ func main() {
2737
CSS: css,
2838
Colour: "#131313",
2939
})
30-
app.Bind(basic)
40+
app.Bind(initStats)
41+
app.Bind(updateCPUStats)
3142
app.Run()
3243
}

0 commit comments

Comments
 (0)