hedgequantx 2.7.5 → 2.7.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/src/menus/dashboard.js +45 -28
package/package.json
CHANGED
package/src/menus/dashboard.js
CHANGED
|
@@ -43,7 +43,7 @@ const dashboardMenu = async (service) => {
|
|
|
43
43
|
console.log(makeLine(propfirmText, 'center'));
|
|
44
44
|
}
|
|
45
45
|
|
|
46
|
-
// Stats bar with
|
|
46
|
+
// Stats bar with centered columns
|
|
47
47
|
const statsInfo = getCachedStats();
|
|
48
48
|
if (statsInfo) {
|
|
49
49
|
console.log(chalk.cyan('╠' + '═'.repeat(W) + '╣'));
|
|
@@ -56,14 +56,16 @@ const dashboardMenu = async (service) => {
|
|
|
56
56
|
const agentDisplay = agentCount > 0 ? `${agentCount} connected` : 'disconnected';
|
|
57
57
|
const agentColor = agentCount > 0 ? chalk.green : chalk.red;
|
|
58
58
|
|
|
59
|
-
// Fixed width columns for alignment (3 columns
|
|
59
|
+
// Fixed width columns for alignment (3 columns)
|
|
60
60
|
const icon = chalk.yellow('✔ ');
|
|
61
61
|
const colWidth = Math.floor(W / 3);
|
|
62
62
|
|
|
63
63
|
const formatCol = (label, value, valueColor = chalk.white) => {
|
|
64
|
-
const text =
|
|
65
|
-
const
|
|
66
|
-
|
|
64
|
+
const text = `✔ ${label}: ${value}`;
|
|
65
|
+
const textLen = text.length;
|
|
66
|
+
const padLeft = Math.floor((colWidth - textLen) / 2);
|
|
67
|
+
const padRight = colWidth - textLen - padLeft;
|
|
68
|
+
return ' '.repeat(Math.max(0, padLeft)) + icon + chalk.white(label + ': ') + valueColor(value) + ' '.repeat(Math.max(0, padRight));
|
|
67
69
|
};
|
|
68
70
|
|
|
69
71
|
const col1 = formatCol('Accounts', String(statsInfo.accounts));
|
|
@@ -72,39 +74,54 @@ const dashboardMenu = async (service) => {
|
|
|
72
74
|
|
|
73
75
|
const statsLine = col1 + col2 + col3;
|
|
74
76
|
const statsPlainLen = statsLine.replace(/\x1b\[[0-9;]*m/g, '').length;
|
|
75
|
-
const
|
|
76
|
-
const leftPad = Math.floor(totalPad / 2);
|
|
77
|
-
const rightPad = totalPad - leftPad;
|
|
77
|
+
const extraPad = W - statsPlainLen;
|
|
78
78
|
|
|
79
|
-
console.log(chalk.cyan('║') +
|
|
79
|
+
console.log(chalk.cyan('║') + statsLine + ' '.repeat(Math.max(0, extraPad)) + chalk.cyan('║'));
|
|
80
80
|
}
|
|
81
81
|
|
|
82
82
|
console.log(chalk.cyan('╠' + '═'.repeat(W) + '╣'));
|
|
83
83
|
|
|
84
|
-
// Menu in 2 columns -
|
|
84
|
+
// Menu in 2 columns - aligned
|
|
85
85
|
const col1Width = Math.floor(W / 2);
|
|
86
86
|
const col2Width = W - col1Width;
|
|
87
87
|
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
const
|
|
100
|
-
const
|
|
101
|
-
|
|
102
|
-
|
|
88
|
+
// Find max width for alignment
|
|
89
|
+
const menuItems = [
|
|
90
|
+
{ left: '[1] View Accounts', right: '[2] View Stats' },
|
|
91
|
+
{ left: '[+] Add Prop-Account', right: '[A] Algo-Trading' },
|
|
92
|
+
{ left: '[U] Update HQX', right: '[X] Disconnect' },
|
|
93
|
+
];
|
|
94
|
+
|
|
95
|
+
const maxLeftLen = Math.max(...menuItems.map(m => m.left.length));
|
|
96
|
+
const maxRightLen = Math.max(...menuItems.map(m => m.right.length));
|
|
97
|
+
|
|
98
|
+
const menuRow = (left, right, leftColor, rightColor) => {
|
|
99
|
+
const leftPlain = left;
|
|
100
|
+
const rightPlain = right;
|
|
101
|
+
|
|
102
|
+
// Pad left item to max width, then center in column
|
|
103
|
+
const leftPadded = leftPlain.padEnd(maxLeftLen);
|
|
104
|
+
const leftTotalPad = col1Width - maxLeftLen;
|
|
105
|
+
const leftPadL = Math.floor(leftTotalPad / 2);
|
|
106
|
+
const leftPadR = leftTotalPad - leftPadL;
|
|
107
|
+
|
|
108
|
+
// Pad right item to max width, then center in column
|
|
109
|
+
const rightPadded = rightPlain.padEnd(maxRightLen);
|
|
110
|
+
const rightTotalPad = col2Width - maxRightLen;
|
|
111
|
+
const rightPadL = Math.floor(rightTotalPad / 2);
|
|
112
|
+
const rightPadR = rightTotalPad - rightPadL;
|
|
113
|
+
|
|
114
|
+
console.log(
|
|
115
|
+
chalk.cyan('║') +
|
|
116
|
+
' '.repeat(leftPadL) + leftColor(leftPadded) + ' '.repeat(leftPadR) +
|
|
117
|
+
' '.repeat(rightPadL) + rightColor(rightPadded) + ' '.repeat(rightPadR) +
|
|
118
|
+
chalk.cyan('║')
|
|
119
|
+
);
|
|
103
120
|
};
|
|
104
121
|
|
|
105
|
-
menuRow(
|
|
106
|
-
menuRow(
|
|
107
|
-
menuRow(
|
|
122
|
+
menuRow('[1] View Accounts', '[2] View Stats', chalk.cyan, chalk.cyan);
|
|
123
|
+
menuRow('[+] Add Prop-Account', '[A] Algo-Trading', chalk.cyan, chalk.magenta);
|
|
124
|
+
menuRow('[U] Update HQX', '[X] Disconnect', chalk.yellow, chalk.red);
|
|
108
125
|
|
|
109
126
|
console.log(chalk.cyan('╚' + '═'.repeat(W) + '╝'));
|
|
110
127
|
|