Skip to content

Commit

Permalink
changes
Browse files Browse the repository at this point in the history
  • Loading branch information
st3b1t committed Jul 13, 2023
1 parent a3b5fe8 commit 0843af1
Show file tree
Hide file tree
Showing 10 changed files with 54 additions and 24 deletions.
11 changes: 10 additions & 1 deletion .github/CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -1 +1,10 @@
PRs are welcome, please make sure that your changes are well tested

Pull Requests are welcome, please make sure that your changes are tested

In order of priority how you can help out:

1. share this project in your social channels
2. testing and report bugs in new issue
3. try to resolve
4. search `//TODO` in the source code
5. add new features
14 changes: 13 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -114,9 +114,21 @@ This script Set environment var `FAKEMODE=true` to allow simulate a RPC connecti

Additional parameter `--intervalrpc=1000` allows to speed up data polling and `nodemon` to reload the code at each edits.

### Contributing

Pull Requests are welcome, please make sure that your changes are tested

In order of priority how you can help out:

1. share this project in your social channels
2. testing and report bugs in new issue
3. try to resolve
4. search `//TODO` in the source code
5. add new features


## License

Copyright (c) 2023 [st3b1t](https://github.com/st3b1t)

Released under [the MIT license](LICENSE).
Released under [MIT license](LICENSE).
2 changes: 2 additions & 0 deletions lib/bitcoin/peers.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,9 @@ function Peers(table, opts) {

Peers.prototype.updateData = function(peerData) {

//TODO change with screen witdh
const addrCol = this.table.options.columnWidth.at(-1);

const headers = [
'UserAgent',
//'Network',
Expand Down
2 changes: 1 addition & 1 deletion lib/bitcoin/rpc.js
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ module.exports = {
const {headers, blocks, initialblockdownload, verificationprogress} = blkinfo;

if (initialblockdownload || headers > blocks) {
status = `{red-fg}Block download ${Math.floor(verificationprogress*100)}%{/red-fg}`
status = `{red-fg}Syncing ${Math.floor(verificationprogress*100)}%{/red-fg}`
}
else {
status = '{green-fg}Synchronized{/green-fg}'
Expand Down
9 changes: 4 additions & 5 deletions lib/satop.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ module.exports = {

//row, col, rowSpan, colSpan, obj, opts
const mem = grid.set(0, 5, 3, 2, donut, {
label: 'Memory',
label: 'Ram',
radius: 10,
arcWidth: 6,
yPadding: 1,
Expand All @@ -51,9 +51,8 @@ module.exports = {
//row, col, rowSpan, colSpan, obj, opts
const disk = grid.set(0, 7, 3, 5, donut, {
label: 'Disks',
radius: 9,

arcWidth: 5,
radius: 10,
arcWidth: 6,
yPadding: -1,
remainColor: 'black',
showLegend: true,
Expand All @@ -65,7 +64,7 @@ module.exports = {
keys: true,
interactive: false,
columnSpacing: 2,
columnWidth: [4, 20],
columnWidth: [4, 4, 4, 20],
});

//row, col, rowSpan, colSpan, obj, opts
Expand Down
4 changes: 2 additions & 2 deletions lib/system/disk.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,9 @@ Disk.prototype.updateData = function(disks) {
, percent = use / 100
, dev = fs.replace('/dev/','')
, color = colors[i];

//const usage = ''//[used, size].map(humanBytes).join('/');
data.push({
label: mount,//const usage = [used, size].map(humanBytes).join(' of ');
label: mount,
percent,
color,
})
Expand Down
10 changes: 6 additions & 4 deletions lib/system/mem.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ function Mem(donut, opts) {
mem(data => {
this.memData = [
{
title: 'Memory',
title: 'Ram',
style: {
line: colors[0],
},
Expand All @@ -33,13 +33,15 @@ Mem.prototype.updateData = function(data) {
, percent = (100 * (1 - available / total)).toFixed() / 100
, used = total - available;

var label = `${humanBytes(used)} of ${humanBytes(total)}`;
const label = [used, total].map(humanBytes).join('/');

const usage = [used, total].map(humanBytes).join('/');
this.donut.setLabel(`Ram ${usage}`);
this.donut.setData([
{
label,
label: false,
percent,
color: colors[0],
color: colors[3],
},
]);
};
Expand Down
12 changes: 8 additions & 4 deletions lib/system/proc.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@

const {processes} = require('systeminformation')
, {colors, humanBytes} = require('../utils');
const {resolve} = require('path')
, {processes} = require('systeminformation')
, {colors, humanBytes} = require('../utils');

function Proc(table, opts) {
this.opts = opts;
Expand All @@ -18,7 +19,7 @@ function Proc(table, opts) {

Proc.prototype.updateData = function(data) {
const sortby = 'cpu';
const headers = ['%CPU', 'Command'];
const headers = ['%CPU', '%Mem', 'User', 'Command'];

var data = data.list
.sort(function(a, b) {
Expand All @@ -27,7 +28,10 @@ Proc.prototype.updateData = function(data) {
.map(p => {
return [
p.cpu.toFixed(1),
p.command
p.mem.toFixed(1),
p.user,
p.command,
//TODO show also path is screen is widht resolve(p.path, p.command),
];
});

Expand Down
8 changes: 6 additions & 2 deletions lib/system/temp.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ const {cpuTemperature} = require('systeminformation')
function Temp(lcd, opts) {
this.opts = opts;
this.lcd = lcd;
this.max = 0;

//TODO progressbar bottom lcd
/*this.bar = blessed.progressbar({
Expand Down Expand Up @@ -35,9 +36,12 @@ function Temp(lcd, opts) {
}

Temp.prototype.updateData = function(data) {
const {main} = data;
const {main, max} = data;
this.max = Math.max(this.max, max);
//TODO se color with value
this.lcd.setDisplay(`${main}C`);
//this.bar.setProgress(main);
this.lcd.setLabel(`Temp (max ${this.max}C)`);
//TODO this.bar.setProgress(main);
};

module.exports = Temp;
6 changes: 2 additions & 4 deletions lib/utils/human.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,14 @@ function humanSubver(subver) {
return subver.replace(/\//g,'')
}

function humanBytes(bytes, isDecimal) {
isDecimal = typeof isDecimal !== 'undefined' ? isDecimal : false;
function humanBytes(bytes, isDecimal = true) {
if (bytes == 0) {
return '0.00 B';
}
var base = isDecimal ? 1000 : 1024;
var e = Math.floor(Math.log(bytes) / Math.log(base));
return (
(bytes / Math.pow(base, e)).toFixed(2) +
' ' +
(bytes / Math.pow(base, e)).toFixed(1) +
' KMGTP'.charAt(e) +
(isDecimal || e == 0 ? '' : 'i') +
'B'
Expand Down

0 comments on commit 0843af1

Please sign in to comment.