diff --git a/art/themes/luciano_blocktronics/theme.hjson b/art/themes/luciano_blocktronics/theme.hjson index 79aff03b..13830fad 100644 --- a/art/themes/luciano_blocktronics/theme.hjson +++ b/art/themes/luciano_blocktronics/theme.hjson @@ -248,24 +248,30 @@ mainMenuWaitingForCaller: { config: { + // formats quickLogTimestampFormat: "|01|02MM|08/|02DD hh:mm:ssa" nowDateTimeFormat: "|00|11ddd|08, |11MMMM Do YYYY|08, |11h|08:|11mm|08:|11ss|03a" 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}" + + // today mainInfoFormat11: "|00|10{callsToday:>5}" mainInfoFormat12: "|00|10{postsToday:>5}" 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}" - - mainInfoFormat15: "|00|10{lastLoginUserName:<26} |02{lastLogin}" - 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}" mainInfoFormat18: "|00|10{systemCurrentLoad} |02% |08/ |10{systemAvgLoad} |02load avg|08." mainInfoFormat19: "|00|10{processUptimeSeconds!durationSeconds}" + // totals mainInfoFormat20: "|00|10{totalCalls:>5}" mainInfoFormat21: "|00|10{totalPosts:>7}" mainInfoFormat22: "|00|10{totalUsers:>5}" @@ -300,11 +306,15 @@ TL18: { width: 23 } TL19: { width: 14 } + // node status VM1: { height: 5 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: { height: 5 width: 73 diff --git a/core/menu_view.js b/core/menu_view.js index 9c750aba..7e24b637 100644 --- a/core/menu_view.js +++ b/core/menu_view.js @@ -226,6 +226,10 @@ MenuView.prototype.setFocusItemIndex = function(index) { this.focusedItemIndex = index; }; +MenuView.prototype.getFocusItemIndex = function() { + return this.focusedItemIndex; +}; + MenuView.prototype.onKeyPress = function(ch, key) { const itemIndex = this.getHotKeyItemIndex(ch); if(itemIndex >= 0) { diff --git a/core/vertical_menu_view.js b/core/vertical_menu_view.js index 1837b718..6130ebde 100644 --- a/core/vertical_menu_view.js +++ b/core/vertical_menu_view.js @@ -11,12 +11,14 @@ const pipeToAnsi = require('./color_codes.js').pipeToAnsi; // deps const util = require('util'); const _ = require('lodash'); +const { throws } = require('assert'); exports.VerticalMenuView = VerticalMenuView; function VerticalMenuView(options) { options.cursor = options.cursor || 'hide'; options.justify = options.justify || 'left'; + this.focusItemAtTop = true; MenuView.call(this, options); @@ -44,9 +46,11 @@ function VerticalMenuView(options) { this.updateViewVisibleItems = function() { self.maxVisibleItems = Math.ceil(self.dimens.height / (self.itemSpacing + 1)); + const topIndex = (this.focusItemAtTop ? throws.focusedItemIndex : 0) || 0; + self.viewWindow = { - top : self.focusedItemIndex, - bottom : Math.min(self.focusedItemIndex + self.maxVisibleItems, self.items.length) - 1, + top : topIndex, + 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.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) { + const topIndex = (this.focusItemAtTop ? throws.focusedItemIndex : 0) || 0; + this.viewWindow = { - top : this.focusedItemIndex, - bottom : Math.min(this.focusedItemIndex + this.maxVisibleItems, this.items.length) - 1 + top : topIndex, + bottom : Math.min(topIndex + this.maxVisibleItems, this.items.length) - 1 }; this.positionCacheExpired = false; // skip standard behavior @@ -343,4 +351,12 @@ VerticalMenuView.prototype.setItemSpacing = function(itemSpacing) { VerticalMenuView.super_.prototype.setItemSpacing.call(this, itemSpacing); 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); }; \ No newline at end of file diff --git a/core/wfc.js b/core/wfc.js index 55d64f7e..4ae93b4c 100644 --- a/core/wfc.js +++ b/core/wfc.js @@ -76,13 +76,16 @@ exports.getModule = class WaitingForCallerModule extends MenuModule { return cb(null); } - const index = parseInt(formData.ch); // 1-based - if (isNaN(index) || nodeStatusView.getCount() < index) { + const nodeId = parseInt(formData.ch); // 1-based + if (isNaN(nodeId)) { return cb(null); } - this.selectedNodeStatusIndex = index - 1; - this._selectNodeByIndex(nodeStatusView, this.selectedNodeStatusIndex); + const index = this._getNodeByNodeId(nodeStatusView, nodeId); + if (index > -1) { + this.selectedNodeStatusIndex = index; + this._selectNodeByIndex(nodeStatusView, this.selectedNodeStatusIndex); + } return cb(null); } } @@ -322,6 +325,10 @@ exports.getModule = class WaitingForCallerModule extends MenuModule { return cb(null); } + _getNodeByNodeId(nodeStatusView, nodeId) { + return nodeStatusView.getItems().findIndex(entry => entry.node == nodeId); + } + _selectNodeByIndex(nodeStatusView, index) { if (index >= 0 && nodeStatusView.getFocusItemIndex() !== index) { nodeStatusView.setFocusItemIndex(index);