Add pages to WFC

This commit is contained in:
Bryan Ashby 2022-06-04 15:37:31 -06:00
parent 2e4df79d52
commit 3d191a9c6c
No known key found for this signature in database
GPG Key ID: C2C1B501E4EFD994
2 changed files with 96 additions and 34 deletions

View File

@ -364,7 +364,7 @@ exports.ThemeManager = class ThemeManager {
async.each([ ...this.availableThemes.keys() ], (themeId, nextThemeId) => {
this._loadTheme(themeId, err => {
if (!err) {
Log.info({ themeId }, 'Theme reloaded');
Log.info({ themeId }, `Theme "${themeId}" reloaded`);
}
return nextThemeId(null); // always proceed
});

View File

@ -25,6 +25,8 @@ exports.moduleInfo = {
const FormIds = {
main: 0,
help: 1,
fullLog: 2,
};
const MciViewIds = {
@ -52,6 +54,8 @@ exports.getModule = class WaitingForCallerModule extends MenuModule {
this.config.acs = 'SC' + this.config.acs; // secure connection at the very least
}
this.selectedNodeStatusIndex = -1; // no selection
this.menuMethods = {
toggleAvailable : (formData, extraArgs, cb) => {
const avail = this.client.user.isAvailable();
@ -63,22 +67,53 @@ exports.getModule = class WaitingForCallerModule extends MenuModule {
this.client.user.setVisibility(!visible);
return this._refreshAll(cb);
},
displayHelp : (formData, extraArgs, cb) => {
return this._displayHelpPage(cb);
},
setNodeStatusSelection : (formData, extraArgs, cb) => {
const nodeStatusView = this.getView('main', MciViewIds.main.nodeStatus);
if (!nodeStatusView) {
return cb(null);
}
const index = parseInt(formData.ch); // 1-based
if (isNaN(index) || nodeStatusView.getCount() < index) {
return cb(null);
}
this.selectedNodeStatusIndex = index - 1;
this._selectNodeByIndex(nodeStatusView, this.selectedNodeStatusIndex);
return cb(null);
}
}
}
// initSequence -> MenuModule.displayArtAndPrepViewController() (make common)
// main, help, log, ...
mciReady(mciData, cb) {
super.mciReady(mciData, err => {
if (err) {
return cb(err);
}
initSequence() {
async.series(
[
(callback) => {
return this.prepViewController('main', FormIds.main, mciData.menu, callback);
return this.beforeArt(callback);
},
(callback) => {
return this._displayMainPage(false, callback);
}
],
() => {
this.finishedLoading();
}
);
}
_displayMainPage(clearScreen, cb) {
async.series(
[
(callback) => {
return this.displayArtAndPrepViewController(
'main',
FormIds.main,
{ clearScreen },
callback
);
},
(callback) => {
const quickLogView = this.viewControllers.main.getView(MciViewIds.main.quickLogView);
@ -86,6 +121,7 @@ exports.getModule = class WaitingForCallerModule extends MenuModule {
return callback(null);
}
if (!this.logRingBuffer) {
const logLevel = this.config.quickLogLevel || // WFC specific
_.get(Config(), 'logging.rotatingFile.level') || // ...or system setting
'info'; // ...or default to info
@ -97,6 +133,7 @@ exports.getModule = class WaitingForCallerModule extends MenuModule {
level : logLevel,
stream : this.logRingBuffer
});
}
return callback(null);
},
@ -111,8 +148,21 @@ exports.getModule = class WaitingForCallerModule extends MenuModule {
return cb(err);
}
);
}
_displayHelpPage(cb) {
this._stopRefreshing();
this.displayAsset(
this.menuConfig.config.art.help,
{ clearScreen : true },
() => {
this.client.waitForKeyPress( () => {
return this._displayMainPage(true, cb);
});
}
);
}
enter() {
this.client.stopIdleMonitor();
@ -150,6 +200,10 @@ exports.getModule = class WaitingForCallerModule extends MenuModule {
}
_startRefreshing() {
if (this.mainRefreshTimer) {
this._stopRefreshing();
}
this.mainRefreshTimer = setInterval( () => {
this._refreshAll();
}, MainStatRefreshTimeMs);
@ -268,6 +322,14 @@ exports.getModule = class WaitingForCallerModule extends MenuModule {
return cb(null);
}
_selectNodeByIndex(nodeStatusView, index) {
if (index >= 0 && nodeStatusView.getFocusItemIndex() !== index) {
nodeStatusView.setFocusItemIndex(index);
} else {
nodeStatusView.redraw();
}
}
_refreshNodeStatus(cb) {
const nodeStatusView = this.getView('main', MciViewIds.main.nodeStatus);
if (!nodeStatusView) {
@ -292,9 +354,9 @@ exports.getModule = class WaitingForCallerModule extends MenuModule {
});
});
// :TODO: Currently this always redraws due to setItems(). We really need painters alg.; The alternative now is to compare items... yuk.
nodeStatusView.setItems(nodeStatusItems);
nodeStatusView.redraw();
this._selectNodeByIndex(nodeStatusView, this.selectedNodeStatusIndex); // redraws
return cb(null);
}