mirror of
https://github.com/Unitech/pm2.git
synced 2025-12-08 20:35:53 +00:00
update CliUX display to something more compact
This commit is contained in:
parent
2726eb92e1
commit
72fca4e7a5
56
lib/CliUx.js
56
lib/CliUx.js
@ -1,7 +1,8 @@
|
||||
var Table = require('cli-table');
|
||||
var Table = require('cli-table');
|
||||
var sprintf = require('util').format;
|
||||
var p = require('path');
|
||||
var UX = module.exports = {};
|
||||
var p = require('path');
|
||||
var UX = module.exports = {};
|
||||
|
||||
require('colors');
|
||||
|
||||
UX.miniDisplay = function(list) {
|
||||
@ -31,8 +32,9 @@ UX.miniDisplay = function(list) {
|
||||
|
||||
UX.dispAsTable = function(list) {
|
||||
var table = new Table({
|
||||
head: ["App Name", "id", "mode","PID","status", "port", "Restarted", "Uptime", "memory", "err logs"],
|
||||
colAligns : ['left', 'left', 'left', 'left','left', 'left', 'right', 'left', 'right']
|
||||
head: ['app name', 'id', 'mode','pid','status', 'port', 'restarted', 'uptime', 'memory', 'error logs'],
|
||||
colAligns : ['left', 'left', 'left', 'left','left', 'left', 'left', 'left', 'left'],
|
||||
style : {'padding-left' : 1, head : ['cyan', 'bold'], border : ['white'], compact : true}
|
||||
});
|
||||
|
||||
list.forEach(function(l) {
|
||||
@ -71,38 +73,6 @@ UX.processing = {
|
||||
}
|
||||
};
|
||||
|
||||
// UX.processing = {
|
||||
// start : function() {
|
||||
// // Code grabbed from Mocha by Visionmedia/Tj
|
||||
// // https://github.com/visionmedia/mocha/blob/master/bin/_mocha
|
||||
|
||||
// var spinner = 'win32' == process.platform
|
||||
// ? ['|','/','-','\\']
|
||||
// : ['◜','◠','◝','◞','◡','◟'];
|
||||
|
||||
// function play(arr, interval) {
|
||||
// var len = arr.length
|
||||
// , interval = interval || 100
|
||||
// , i = 0;
|
||||
|
||||
// timer = setInterval(function(){
|
||||
// var str = arr[i++ % len];
|
||||
// process.stdout.write('\u001b[0G' + str);
|
||||
// }, interval);
|
||||
// }
|
||||
|
||||
// var frames = spinner.map(function(c) {
|
||||
// return sprintf(' \u001b[96m%s \u001b[90mProcessing...\u001b[0m', c);
|
||||
// });
|
||||
|
||||
// play(frames, 70);
|
||||
// },
|
||||
// stop : function() {
|
||||
// process.stdout.write('\u001b[0G\u001b[2K');
|
||||
// clearInterval(timer);
|
||||
// }
|
||||
// };
|
||||
|
||||
UX.bytesToSize = function(bytes, precision) {
|
||||
var kilobyte = 1024;
|
||||
var megabyte = kilobyte * 1024;
|
||||
@ -131,23 +101,23 @@ function timeSince(date) {
|
||||
var interval = Math.floor(seconds / 31536000);
|
||||
|
||||
if (interval > 1) {
|
||||
return interval + "y";
|
||||
return interval + 'y';
|
||||
}
|
||||
interval = Math.floor(seconds / 2592000);
|
||||
if (interval > 1) {
|
||||
return interval + "m";
|
||||
return interval + 'm';
|
||||
}
|
||||
interval = Math.floor(seconds / 86400);
|
||||
if (interval > 1) {
|
||||
return interval + "d";
|
||||
return interval + 'd';
|
||||
}
|
||||
interval = Math.floor(seconds / 3600);
|
||||
if (interval > 1) {
|
||||
return interval + "h";
|
||||
return interval + 'h';
|
||||
}
|
||||
interval = Math.floor(seconds / 60);
|
||||
if (interval > 1) {
|
||||
return interval + "m";
|
||||
return interval + 'm';
|
||||
}
|
||||
return Math.floor(seconds) + "s";
|
||||
return Math.floor(seconds) + 's';
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user