VerticalMenuView 'focusItemAtTop' property, and selection by node ID on WFC
* Add new property to change how focus items are handed in VM * Select node by node iD (key press) on WFC
This commit is contained in:
parent
3d191a9c6c
commit
0b11e629a6
|
@ -248,24 +248,30 @@
|
||||||
|
|
||||||
mainMenuWaitingForCaller: {
|
mainMenuWaitingForCaller: {
|
||||||
config: {
|
config: {
|
||||||
|
// formats
|
||||||
quickLogTimestampFormat: "|01|02MM|08/|02DD hh:mm:ssa"
|
quickLogTimestampFormat: "|01|02MM|08/|02DD hh:mm:ssa"
|
||||||
nowDateTimeFormat: "|00|11ddd|08, |11MMMM Do YYYY|08, |11h|08:|11mm|08:|11ss|03a"
|
nowDateTimeFormat: "|00|11ddd|08, |11MMMM Do YYYY|08, |11h|08:|11mm|08:|11ss|03a"
|
||||||
lastLoginDateTimeFormat: "|00|10ddd hh|08:|10mm|02a"
|
lastLoginDateTimeFormat: "|00|10ddd hh|08:|10mm|02a"
|
||||||
|
|
||||||
|
// header
|
||||||
mainInfoFormat10: "|00|11{now} {currentUserName} |08- |03Prv|08:|11{newPrivateMail} |03Addr|08:|11{newMessagesAddrTo} |08- |03Avail|08:|11{availIndicator} |03Vis|08:|11{visIndicator}"
|
mainInfoFormat10: "|00|11{now} {currentUserName} |08- |03Prv|08:|11{newPrivateMail} |03Addr|08:|11{newMessagesAddrTo} |08- |03Avail|08:|11{availIndicator} |03Vis|08:|11{visIndicator}"
|
||||||
|
|
||||||
|
// today
|
||||||
mainInfoFormat11: "|00|10{callsToday:>5}"
|
mainInfoFormat11: "|00|10{callsToday:>5}"
|
||||||
mainInfoFormat12: "|00|10{postsToday:>5}"
|
mainInfoFormat12: "|00|10{postsToday:>5}"
|
||||||
mainInfoFormat13: "|00|10{uploadsToday:>2} |08/ |10{uploadBytesToday!sizeWithoutAbbr:>3} |02{uploadBytesToday!sizeAbbr}"
|
mainInfoFormat13: "|00|10{uploadsToday:>2} |08/ |10{uploadBytesToday!sizeWithoutAbbr:>3} |02{uploadBytesToday!sizeAbbr}"
|
||||||
mainInfoFormat14: "|00|10{downloadsToday:>2} |08/ |10{downloadBytesToday!sizeWithoutAbbr:>3} |02{downloadBytesToday!sizeAbbr}"
|
mainInfoFormat14: "|00|10{downloadsToday:>2} |08/ |10{downloadBytesToday!sizeWithoutAbbr:>3} |02{downloadBytesToday!sizeAbbr}"
|
||||||
|
|
||||||
mainInfoFormat15: "|00|10{lastLoginUserName:<26} |02{lastLogin}"
|
|
||||||
|
|
||||||
mainInfoFormat16: "|00|10{newUsersToday:>5}"
|
mainInfoFormat16: "|00|10{newUsersToday:>5}"
|
||||||
|
|
||||||
|
// last login
|
||||||
|
mainInfoFormat15: "|00|10{lastLoginUserName:<26} |02{lastLogin}"
|
||||||
|
|
||||||
|
// system stats
|
||||||
mainInfoFormat17: "|00|10{freeMemoryBytes!sizeWithoutAbbr} |02{freeMemoryBytes!sizeAbbr} free |08/ |10{totalMemoryBytes!sizeWithoutAbbr} |02{totalMemoryBytes!sizeAbbr}"
|
mainInfoFormat17: "|00|10{freeMemoryBytes!sizeWithoutAbbr} |02{freeMemoryBytes!sizeAbbr} free |08/ |10{totalMemoryBytes!sizeWithoutAbbr} |02{totalMemoryBytes!sizeAbbr}"
|
||||||
mainInfoFormat18: "|00|10{systemCurrentLoad} |02% |08/ |10{systemAvgLoad} |02load avg|08."
|
mainInfoFormat18: "|00|10{systemCurrentLoad} |02% |08/ |10{systemAvgLoad} |02load avg|08."
|
||||||
mainInfoFormat19: "|00|10{processUptimeSeconds!durationSeconds}"
|
mainInfoFormat19: "|00|10{processUptimeSeconds!durationSeconds}"
|
||||||
|
|
||||||
|
// totals
|
||||||
mainInfoFormat20: "|00|10{totalCalls:>5}"
|
mainInfoFormat20: "|00|10{totalCalls:>5}"
|
||||||
mainInfoFormat21: "|00|10{totalPosts:>7}"
|
mainInfoFormat21: "|00|10{totalPosts:>7}"
|
||||||
mainInfoFormat22: "|00|10{totalUsers:>5}"
|
mainInfoFormat22: "|00|10{totalUsers:>5}"
|
||||||
|
@ -300,11 +306,15 @@
|
||||||
TL18: { width: 23 }
|
TL18: { width: 23 }
|
||||||
TL19: { width: 14 }
|
TL19: { width: 14 }
|
||||||
|
|
||||||
|
// node status
|
||||||
VM1: {
|
VM1: {
|
||||||
height: 5
|
height: 5
|
||||||
width: 36
|
width: 36
|
||||||
itemFormat: "|00|11{node:<3.2} |10{userName:>13} |08> |02{action:<14.13} |14{serverName}"
|
itemFormat: "|00 |11{node:<3.2} |10{userName:<13} |02{action:<14.13} |14{serverName}"
|
||||||
|
focusItemFormat: "|00|15> |11{node:<3.2} |10{userName:<13} |02{action:<14.13} |14{serverName}"
|
||||||
|
focusItemAtTop: false
|
||||||
}
|
}
|
||||||
|
// quick log
|
||||||
VM2: {
|
VM2: {
|
||||||
height: 5
|
height: 5
|
||||||
width: 73
|
width: 73
|
||||||
|
|
|
@ -226,6 +226,10 @@ MenuView.prototype.setFocusItemIndex = function(index) {
|
||||||
this.focusedItemIndex = index;
|
this.focusedItemIndex = index;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
MenuView.prototype.getFocusItemIndex = function() {
|
||||||
|
return this.focusedItemIndex;
|
||||||
|
};
|
||||||
|
|
||||||
MenuView.prototype.onKeyPress = function(ch, key) {
|
MenuView.prototype.onKeyPress = function(ch, key) {
|
||||||
const itemIndex = this.getHotKeyItemIndex(ch);
|
const itemIndex = this.getHotKeyItemIndex(ch);
|
||||||
if(itemIndex >= 0) {
|
if(itemIndex >= 0) {
|
||||||
|
|
|
@ -11,12 +11,14 @@ const pipeToAnsi = require('./color_codes.js').pipeToAnsi;
|
||||||
// deps
|
// deps
|
||||||
const util = require('util');
|
const util = require('util');
|
||||||
const _ = require('lodash');
|
const _ = require('lodash');
|
||||||
|
const { throws } = require('assert');
|
||||||
|
|
||||||
exports.VerticalMenuView = VerticalMenuView;
|
exports.VerticalMenuView = VerticalMenuView;
|
||||||
|
|
||||||
function VerticalMenuView(options) {
|
function VerticalMenuView(options) {
|
||||||
options.cursor = options.cursor || 'hide';
|
options.cursor = options.cursor || 'hide';
|
||||||
options.justify = options.justify || 'left';
|
options.justify = options.justify || 'left';
|
||||||
|
this.focusItemAtTop = true;
|
||||||
|
|
||||||
MenuView.call(this, options);
|
MenuView.call(this, options);
|
||||||
|
|
||||||
|
@ -44,9 +46,11 @@ function VerticalMenuView(options) {
|
||||||
this.updateViewVisibleItems = function() {
|
this.updateViewVisibleItems = function() {
|
||||||
self.maxVisibleItems = Math.ceil(self.dimens.height / (self.itemSpacing + 1));
|
self.maxVisibleItems = Math.ceil(self.dimens.height / (self.itemSpacing + 1));
|
||||||
|
|
||||||
|
const topIndex = (this.focusItemAtTop ? throws.focusedItemIndex : 0) || 0;
|
||||||
|
|
||||||
self.viewWindow = {
|
self.viewWindow = {
|
||||||
top : self.focusedItemIndex,
|
top : topIndex,
|
||||||
bottom : Math.min(self.focusedItemIndex + self.maxVisibleItems, self.items.length) - 1,
|
bottom : Math.min(topIndex + self.maxVisibleItems, self.items.length) - 1,
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -143,11 +147,15 @@ VerticalMenuView.prototype.setFocus = function(focused) {
|
||||||
VerticalMenuView.prototype.setFocusItemIndex = function(index) {
|
VerticalMenuView.prototype.setFocusItemIndex = function(index) {
|
||||||
VerticalMenuView.super_.prototype.setFocusItemIndex.call(this, index); // sets this.focusedItemIndex
|
VerticalMenuView.super_.prototype.setFocusItemIndex.call(this, index); // sets this.focusedItemIndex
|
||||||
|
|
||||||
const remainAfterFocus = this.items.length - index;
|
const remainAfterFocus = this.focusItemAtTop ?
|
||||||
|
this.items.length - index :
|
||||||
|
this.items.length;
|
||||||
if(remainAfterFocus >= this.maxVisibleItems) {
|
if(remainAfterFocus >= this.maxVisibleItems) {
|
||||||
|
const topIndex = (this.focusItemAtTop ? throws.focusedItemIndex : 0) || 0;
|
||||||
|
|
||||||
this.viewWindow = {
|
this.viewWindow = {
|
||||||
top : this.focusedItemIndex,
|
top : topIndex,
|
||||||
bottom : Math.min(this.focusedItemIndex + this.maxVisibleItems, this.items.length) - 1
|
bottom : Math.min(topIndex + this.maxVisibleItems, this.items.length) - 1
|
||||||
};
|
};
|
||||||
|
|
||||||
this.positionCacheExpired = false; // skip standard behavior
|
this.positionCacheExpired = false; // skip standard behavior
|
||||||
|
@ -344,3 +352,11 @@ VerticalMenuView.prototype.setItemSpacing = function(itemSpacing) {
|
||||||
|
|
||||||
this.positionCacheExpired = true;
|
this.positionCacheExpired = true;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
VerticalMenuView.prototype.setPropertyValue = function(propName, value) {
|
||||||
|
if (propName === 'focusItemAtTop' && _.isBoolean(value)) {
|
||||||
|
this.focusItemAtTop = value;
|
||||||
|
}
|
||||||
|
|
||||||
|
VerticalMenuView.super_.prototype.setPropertyValue.call(this, propName, value);
|
||||||
|
};
|
15
core/wfc.js
15
core/wfc.js
|
@ -76,13 +76,16 @@ exports.getModule = class WaitingForCallerModule extends MenuModule {
|
||||||
return cb(null);
|
return cb(null);
|
||||||
}
|
}
|
||||||
|
|
||||||
const index = parseInt(formData.ch); // 1-based
|
const nodeId = parseInt(formData.ch); // 1-based
|
||||||
if (isNaN(index) || nodeStatusView.getCount() < index) {
|
if (isNaN(nodeId)) {
|
||||||
return cb(null);
|
return cb(null);
|
||||||
}
|
}
|
||||||
|
|
||||||
this.selectedNodeStatusIndex = index - 1;
|
const index = this._getNodeByNodeId(nodeStatusView, nodeId);
|
||||||
this._selectNodeByIndex(nodeStatusView, this.selectedNodeStatusIndex);
|
if (index > -1) {
|
||||||
|
this.selectedNodeStatusIndex = index;
|
||||||
|
this._selectNodeByIndex(nodeStatusView, this.selectedNodeStatusIndex);
|
||||||
|
}
|
||||||
return cb(null);
|
return cb(null);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -322,6 +325,10 @@ exports.getModule = class WaitingForCallerModule extends MenuModule {
|
||||||
return cb(null);
|
return cb(null);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
_getNodeByNodeId(nodeStatusView, nodeId) {
|
||||||
|
return nodeStatusView.getItems().findIndex(entry => entry.node == nodeId);
|
||||||
|
}
|
||||||
|
|
||||||
_selectNodeByIndex(nodeStatusView, index) {
|
_selectNodeByIndex(nodeStatusView, index) {
|
||||||
if (index >= 0 && nodeStatusView.getFocusItemIndex() !== index) {
|
if (index >= 0 && nodeStatusView.getFocusItemIndex() !== index) {
|
||||||
nodeStatusView.setFocusItemIndex(index);
|
nodeStatusView.setFocusItemIndex(index);
|
||||||
|
|
Loading…
Reference in New Issue