Refactor how left bar is displayed

This commit is contained in:
nicolargo 2024-04-28 09:37:26 +02:00
parent c0284fbc69
commit a60e8a42c7
4 changed files with 11 additions and 7 deletions

View File

@ -27,7 +27,7 @@ history_size=1200
separator=True separator=True
# Set the the Curses and WebUI interface left menu plugin list (comma-separated) # Set the the Curses and WebUI interface left menu plugin list (comma-separated)
#left_menu=network,wifi,connections,ports,diskio,fs,irq,folders,raid,smart,sensors,now #left_menu=network,wifi,connections,ports,diskio,fs,irq,folders,raid,smart,sensors,now
# Limit the number of processes to display (for the WebUI) # Limit the number of processes to display
max_processes_display=25 max_processes_display=25
# Set URL prefix for the WebUI and the API # Set URL prefix for the WebUI and the API
# Example: url_prefix=/glances/ => http://localhost/glances/ # Example: url_prefix=/glances/ => http://localhost/glances/

View File

@ -27,7 +27,7 @@ history_size=1200
separator=True separator=True
# Set the the Curses and WebUI interface left menu plugin list (comma-separated) # Set the the Curses and WebUI interface left menu plugin list (comma-separated)
#left_menu=network,wifi,connections,ports,diskio,fs,irq,folders,raid,smart,sensors,now #left_menu=network,wifi,connections,ports,diskio,fs,irq,folders,raid,smart,sensors,now
# Limit the number of processes to display (for the WebUI) # Limit the number of processes to display
max_processes_display=25 max_processes_display=25
# Set URL prefix for the WebUI and the API # Set URL prefix for the WebUI and the API
# Example: url_prefix=/glances/ => http://localhost/glances/ # Example: url_prefix=/glances/ => http://localhost/glances/

View File

@ -606,10 +606,9 @@ class _GlancesCurses(object):
# Compute the plugin max size # Compute the plugin max size
plugin_max_width = None plugin_max_width = None
if p in self._left_sidebar: if p in self._left_sidebar:
plugin_max_width = max(self._left_sidebar_min_width,
self.term_window.getmaxyx()[1] - 105)
plugin_max_width = min(self._left_sidebar_max_width, plugin_max_width = min(self._left_sidebar_max_width,
plugin_max_width) max(self._left_sidebar_min_width,
self.term_window.getmaxyx()[1] - 105))
# Get the view # Get the view
ret[p] = stats.get_plugin(p).get_stats_display(args=self.args, ret[p] = stats.get_plugin(p).get_stats_display(args=self.args,
@ -622,7 +621,7 @@ class _GlancesCurses(object):
The value is dynamicaly computed.""" The value is dynamicaly computed."""
max_processes_displayed = ( max_processes_displayed = (
self.term_window.getmaxyx()[0] self.term_window.getmaxyx()[0]
- 11 - 11 # Glances header + Top + Process header
- (0 if 'containers' not in stat_display else self.get_stats_display_height(stat_display["containers"])) - (0 if 'containers' not in stat_display else self.get_stats_display_height(stat_display["containers"]))
- ( - (
0 0
@ -641,7 +640,7 @@ class _GlancesCurses(object):
if max_processes_displayed < 0: if max_processes_displayed < 0:
max_processes_displayed = 0 max_processes_displayed = 0
if glances_processes.max_processes is None or glances_processes.max_processes != max_processes_displayed: if glances_processes.max_processes is None or glances_processes.max_processes != max_processes_displayed:
logger.debug("Set number of displayed processes to {}".format(max_processes_displayed)) logger.info("Set number of displayed processes to {}".format(max_processes_displayed))
glances_processes.max_processes = max_processes_displayed glances_processes.max_processes = max_processes_displayed
def display(self, stats, cs_status=None): def display(self, stats, cs_status=None):

View File

@ -13,6 +13,7 @@ from datetime import datetime
from time import tzname from time import tzname
import pytz import pytz
from glances.logger import logger
from glances.events_list import glances_events from glances.events_list import glances_events
# from glances.logger import logger # from glances.logger import logger
@ -120,6 +121,10 @@ class PluginModel(GlancesPluginModel):
glances_events.set_max_events(config.get_int_value('alert', 'max_events', default=10)) glances_events.set_max_events(config.get_int_value('alert', 'max_events', default=10))
glances_events.set_min_duration(config.get_int_value('alert', 'min_duration', default=6)) glances_events.set_min_duration(config.get_int_value('alert', 'min_duration', default=6))
glances_events.set_min_interval(config.get_int_value('alert', 'min_interval', default=6)) glances_events.set_min_interval(config.get_int_value('alert', 'min_interval', default=6))
else:
glances_events.set_max_events(10)
glances_events.set_min_duration(6)
glances_events.set_min_interval(6)
def update(self): def update(self):
"""Nothing to do here. Just return the global glances_log.""" """Nothing to do here. Just return the global glances_log."""