Comparing version 0.1.8 to 0.2.0
79
app.js
@@ -20,3 +20,4 @@ /** | ||
os = require('os'), | ||
cli = require('commander'); | ||
cli = require('commander'), | ||
upgrade = require('./upgrade.js'); | ||
@@ -29,4 +30,9 @@ // Set up the commander instance and add the required options | ||
*/ | ||
var screen, charts = [], loadedTheme; | ||
var screen, | ||
charts = [], | ||
loadedTheme, | ||
intervals = []; | ||
var upgradeNotice = false; | ||
// Private variables | ||
@@ -65,9 +71,19 @@ | ||
var drawHeader = function() { | ||
var headerText, headerTextNoTags; | ||
if (upgradeNotice) { | ||
upgradeNotice = upgradeNotice + ''; | ||
headerText = ' {bold}vtop{/bold}{white-fg} for ' + os.hostname() + ' {red-bg} Press \'u\' to upgrade to v' + upgradeNotice + ' {/red-bg}{/white-fg}'; | ||
headerTextNoTags = ' vtop for ' + os.hostname() + ' Press \'u\' to upgrade to v' + upgradeNotice + ' '; | ||
} else { | ||
headerText = ' {bold}vtop{/bold}{white-fg} for ' + os.hostname() + ' '; | ||
headerTextNoTags = ' vtop for ' + os.hostname() + ' '; | ||
} | ||
var header = blessed.text({ | ||
top: 'top', | ||
left: 'left', | ||
width: '50%', | ||
width: headerTextNoTags.length, | ||
height: '1', | ||
fg: loadedTheme.title.fg, | ||
content: ' {bold}vtop{/bold}{white-fg} for ' + os.hostname() + '{/white-fg}', | ||
content: headerText, | ||
tags: true | ||
@@ -77,4 +93,4 @@ }); | ||
top: 'top', | ||
left: '50%', | ||
width: '50%', | ||
right: 0, | ||
width: 9, | ||
height: '1', | ||
@@ -252,4 +268,2 @@ align: 'right', | ||
graph2.setContent(drawChart(chartKey + 1)); | ||
//console.log(processList.width); | ||
//console.log(charts[2].plugin.currentValue); | ||
processList.setContent(drawTable(chartKey + 2)); | ||
@@ -266,4 +280,9 @@ | ||
var theme = cli.theme; | ||
loadedTheme = require('./themes/' + theme + '.json'); | ||
try { | ||
loadedTheme = require('./themes/' + theme + '.json'); | ||
} catch(e) { | ||
console.log('The theme \'' + theme + '\' does not exist.'); | ||
process.exit(1); | ||
} | ||
// Create a screen object. | ||
@@ -273,9 +292,40 @@ screen = blessed.screen(); | ||
// Configure 'q', esc, Ctrl+C for quit | ||
var upgrading = false; | ||
upgrade.check(function(v) { | ||
upgradeNotice = v; | ||
}); | ||
screen.on('keypress', function(ch, key) { | ||
if (key.name === 'q' || key.name === 'escape' || (key.name == 'c' && key.ctrl === true)) { | ||
if ( | ||
upgrading == false && | ||
( | ||
key.name === 'q' || | ||
key.name === 'escape' || | ||
(key.name == 'c' && key.ctrl === true) | ||
) | ||
) { | ||
return process.exit(0); | ||
} | ||
if (key.name === 'u' && upgrading == false) { | ||
upgrading = true; | ||
// Clear all intervals | ||
for (var interval in intervals) { | ||
clearInterval(intervals[interval]); | ||
} | ||
program = blessed.program(); | ||
program.clear(); | ||
program.disableMouse(); | ||
program.showCursor(); | ||
program.normalBuffer(); | ||
// @todo: show changelog AND smush existing data into it :D | ||
upgrade.install('vtop'); | ||
} | ||
}); | ||
drawHeader(); | ||
setInterval(drawHeader, 1000); | ||
drawFooter(); | ||
@@ -342,3 +392,2 @@ | ||
var setupCharts = function() { | ||
// @todo: Fix these drunken magic numbers | ||
size.pixel.width = (graph.width - 2) * 2; | ||
@@ -394,8 +443,8 @@ size.pixel.height = (graph.height - 2) * 4; | ||
screen.on('resize', setupCharts); | ||
setInterval(draw, 100); | ||
intervals.push(setInterval(draw, 100)); | ||
// @todo Make this more sexy | ||
setInterval(charts[0].plugin.poll, charts[0].plugin.interval); | ||
setInterval(charts[1].plugin.poll, charts[1].plugin.interval); | ||
setInterval(charts[2].plugin.poll, charts[2].plugin.interval); | ||
intervals.push(setInterval(charts[0].plugin.poll, charts[0].plugin.interval)); | ||
intervals.push(setInterval(charts[1].plugin.poll, charts[1].plugin.interval)); | ||
intervals.push(setInterval(charts[2].plugin.poll, charts[2].plugin.interval)); | ||
@@ -402,0 +451,0 @@ } |
{ | ||
"name": "vtop", | ||
"version": "0.1.8", | ||
"version": "0.2.0", | ||
"description": "Wow such top. So stats", | ||
@@ -29,4 +29,5 @@ "homepage": "http://parall.ax/vtop", | ||
"blessed": "0.0.33", | ||
"commander": "2.2.0" | ||
"commander": "2.2.0", | ||
"sudo": "1.0.3" | ||
} | ||
} |
@@ -14,3 +14,3 @@ vtop | ||
``` | ||
npm install -g vtop | ||
sudo npm install -g vtop | ||
``` | ||
@@ -17,0 +17,0 @@ |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Uses eval
Supply chain riskPackage uses dynamic code execution (e.g., eval()), which is a dangerous practice. This can prevent the code from running in certain environments and increases the risk that the code may contain exploits or malicious behavior.
Found 1 instance in 1 package
Dynamic require
Supply chain riskDynamic require can indicate the package is performing dangerous or unsafe dynamic code execution.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
1933424
18
721
6
4
5
+ Addedsudo@1.0.3
+ Addedinpath@1.0.2(transitive)
+ Addedpidof@1.0.2(transitive)
+ Addedsudo@1.0.3(transitive)