From 0843af120efd83de1f105bf5ac5b88997cb06bd1 Mon Sep 17 00:00:00 2001 From: st3b1t Date: Fri, 14 Jul 2023 01:44:05 +0200 Subject: [PATCH] changes --- .github/CONTRIBUTING.md | 11 ++++++++++- README.md | 14 +++++++++++++- lib/bitcoin/peers.js | 2 ++ lib/bitcoin/rpc.js | 2 +- lib/satop.js | 9 ++++----- lib/system/disk.js | 4 ++-- lib/system/mem.js | 10 ++++++---- lib/system/proc.js | 12 ++++++++---- lib/system/temp.js | 8 ++++++-- lib/utils/human.js | 6 ++---- 10 files changed, 54 insertions(+), 24 deletions(-) diff --git a/.github/CONTRIBUTING.md b/.github/CONTRIBUTING.md index 20f1788..b57b9aa 100644 --- a/.github/CONTRIBUTING.md +++ b/.github/CONTRIBUTING.md @@ -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 diff --git a/README.md b/README.md index fa47de5..7754ad1 100644 --- a/README.md +++ b/README.md @@ -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). diff --git a/lib/bitcoin/peers.js b/lib/bitcoin/peers.js index 08152e2..01cc51c 100644 --- a/lib/bitcoin/peers.js +++ b/lib/bitcoin/peers.js @@ -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', diff --git a/lib/bitcoin/rpc.js b/lib/bitcoin/rpc.js index 09eb2e5..d934434 100644 --- a/lib/bitcoin/rpc.js +++ b/lib/bitcoin/rpc.js @@ -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}' diff --git a/lib/satop.js b/lib/satop.js index b2f8a18..9677657 100644 --- a/lib/satop.js +++ b/lib/satop.js @@ -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, @@ -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, @@ -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 diff --git a/lib/system/disk.js b/lib/system/disk.js index 8ce86b0..8c46ec0 100644 --- a/lib/system/disk.js +++ b/lib/system/disk.js @@ -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, }) diff --git a/lib/system/mem.js b/lib/system/mem.js index c434abb..ac23218 100644 --- a/lib/system/mem.js +++ b/lib/system/mem.js @@ -9,7 +9,7 @@ function Mem(donut, opts) { mem(data => { this.memData = [ { - title: 'Memory', + title: 'Ram', style: { line: colors[0], }, @@ -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], }, ]); }; diff --git a/lib/system/proc.js b/lib/system/proc.js index 6d630eb..6e1ceb7 100644 --- a/lib/system/proc.js +++ b/lib/system/proc.js @@ -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; @@ -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) { @@ -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), ]; }); diff --git a/lib/system/temp.js b/lib/system/temp.js index 89d0d6f..d4abba9 100644 --- a/lib/system/temp.js +++ b/lib/system/temp.js @@ -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({ @@ -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; diff --git a/lib/utils/human.js b/lib/utils/human.js index eb5dfbb..aa5cd02 100644 --- a/lib/utils/human.js +++ b/lib/utils/human.js @@ -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'