-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathdashboard.js
More file actions
76 lines (65 loc) · 1.73 KB
/
dashboard.js
File metadata and controls
76 lines (65 loc) · 1.73 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
var blessed = require('blessed')
, contrib = require('blessed-contrib')
class CliDraw {
constructor() {
this.screen = null
this.grid = null
this.totalTable = null
this.detailsTable = null
this.initBlessed()
}
initBlessed() {
this.screen = blessed.screen()
this.grid = new contrib.grid({rows: 12, cols: 12, screen: this.screen})
this.screen.key(['escape', 'q', 'C-c'], function(ch, key) {
this.screen.destroy();
return process.exit(0);
});
this.initSurface()
}
initSurface() {
this.totalTable = this.grid.set(0, 0, 12, 2, contrib.table, {
keys: true,
fg: 'white',
selectedFg: 'white',
selectedBg: 'blue',
interactive: false,
label: 'Goldshell Miner Total',
width: '100%',
height: '100%',
border: {
type: "line",
fg: "cyan"
},
columnSpacing: 2, //in chars
columnWidth: [18, 10] /*in chars*/
})
this.detailsTable = this.grid.set(0, 2, 12, 10, contrib.table, {
keys: true,
fg: 'white',
selectedFg: 'white',
selectedBg: 'blue',
interactive: true,
label: 'Goldshell Miner Details',
width: '100%',
height: '100%',
border: {
type: "line",
fg: "cyan"
},
columnSpacing: 2, //in chars
columnWidth: [8, 18, 8, 8, 8, 8, 14, 14, 10, 10, 10, 16, 12] /*in chars*/
})
this.detailsTable.focus()
this.screen.render()
}
updateTotalTable(headers, stats) {
this.totalTable.setData({ headers: headers, data: stats})
this.screen.render()
}
updateDetailsTable(headers, stats) {
this.detailsTable.setData({ headers: headers, data: stats})
this.screen.render()
}
}
module.exports = CliDraw;