Skip to content

Commit

Permalink
Optimise Quicklook display in Curses UI
Browse files Browse the repository at this point in the history
  • Loading branch information
nicolargo committed May 3, 2024
1 parent 39be7f5 commit bc349db
Show file tree
Hide file tree
Showing 9 changed files with 213 additions and 270 deletions.
432 changes: 181 additions & 251 deletions docs/api.rst

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion docs/man/glances.1
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ level margin: \\n[rst2man-indent\\n[rst2man-indent-level]]
.\" new: \\n[rst2man-indent\\n[rst2man-indent-level]]
.in \\n[rst2man-indent\\n[rst2man-indent-level]]u
..
.TH "GLANCES" "1" "Apr 28, 2024" "4.0.0_beta04" "Glances"
.TH "GLANCES" "1" "May 03, 2024" "4.0.0_rc02" "Glances"
.SH NAME
glances \- An eye on your system
.SH SYNOPSIS
Expand Down
2 changes: 1 addition & 1 deletion glances/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
# Global name
# Version should start and end with a numerical char
# See https://packaging.python.org/specifications/core-metadata/#version
__version__ = '4.0.0_rc01'
__version__ = '4.0.0_rc02'
__apiversion__ = '4'
__author__ = 'Nicolas Hennion <nicolas@nicolargo.com>'
__license__ = 'LGPLv3'
Expand Down
6 changes: 5 additions & 1 deletion glances/outputs/glances_curses.py
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ class _GlancesCurses(object):

# Define top menu
_top = ['quicklook', 'cpu', 'percpu', 'gpu', 'mem', 'memswap', 'load']
_quicklook_max_width = 68
_quicklook_max_width = 58

# Define left sidebar
# This default list is also defined in the glances/outputs/static/js/uiconfig.json
Expand Down Expand Up @@ -598,6 +598,10 @@ def __get_stat_display(self, stats, layer):
ret = {}

for p in stats.getPluginsList(enable=False):
# Ignore Quicklook because it is compute later in __display_top
if p == 'quicklook':
continue

# Compute the plugin max size for the left sidebar
plugin_max_width = None
if p in self._left_sidebar:
Expand Down
2 changes: 2 additions & 0 deletions glances/outputs/glances_restful_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -276,6 +276,8 @@ def _router(self):
# Statics files
self._app.mount("/static", StaticFiles(directory=self.STATIC_PATH), name="static")

logger.info("Get WebUI in {}".format(self.STATIC_PATH))

bindmsg = 'Glances Web User Interface started on {}'.format(self.bind_url)
else:
bindmsg = 'The WebUI is disable (--disable-webui)'
Expand Down
2 changes: 1 addition & 1 deletion glances/outputs/static/js/App.vue
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,7 @@ export default {
return title ? `${title} - Glances` : 'Glances';
},
leftMenu() {
return this.config.outputs.left_menu !== undefined
return this.config.outputs !== undefined && this.config.outputs.left_menu !== undefined
? this.config.outputs.left_menu.split(',')
: uiconfig.leftMenu;
}
Expand Down
5 changes: 4 additions & 1 deletion glances/outputs/static/js/components/plugin-quicklook.vue
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
<template>
<section id="quicklook" class="plugin">
<div class="cpu-name">
<div class="cpu-name text-left">
{{ cpu_name }}
</div>
<!-- <div class="cpu-freq text-right" v-if="cpu_hz_current">
{{ cpu_hz_current }}/{{ cpu_hz }}Ghz
</div> -->
<div class="table">
<div class="table-row" v-if="!args.percpu">
<div class="table-cell text-left">CPU</div>
Expand Down
2 changes: 1 addition & 1 deletion glances/outputs/static/public/glances.js

Large diffs are not rendered by default.

30 changes: 17 additions & 13 deletions glances/plugins/quicklook/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,7 @@ def msg_curse(self, args=None, max_width=10):
return ret

if not max_width:
# No max_width defined, return an emptu curse message
# No max_width defined, return an empty message
logger.debug("No max_width defined for the {} plugin, it will not be displayed.".format(self.plugin_name))
return ret

Expand All @@ -192,18 +192,22 @@ def msg_curse(self, args=None, max_width=10):
##########################

# System information
if 'cpu_name' in self.stats and 'cpu_hz_current' in self.stats and 'cpu_hz' in self.stats:
msg_name = self.stats['cpu_name']
if self.stats['cpu_hz_current'] and self.stats['cpu_hz']:
msg_freq = ' - {:.2f}/{:.2f}GHz'.format(
self._hz_to_ghz(self.stats['cpu_hz_current']), self._hz_to_ghz(self.stats['cpu_hz'])
)
else:
msg_freq = ''
if len(msg_name + msg_freq) - 6 <= max_width:
ret.append(self.curse_add_line(msg_name))
ret.append(self.curse_add_line(msg_freq))
ret.append(self.curse_new_line())
if 'cpu_hz_current' in self.stats and 'cpu_hz' in self.stats:
msg_freq = ' {:.2f}/{:.2f}GHz'.format(
self._hz_to_ghz(self.stats['cpu_hz_current']), self._hz_to_ghz(self.stats['cpu_hz'])
)
else:
msg_freq = ''

if 'cpu_name' in self.stats and (max_width - len(msg_freq) + 7) > 0:
msg_name = '{:{width}}'.format(self.stats['cpu_name'],
width=max_width - len(msg_freq) + 7)
else:
msg_name = '' if msg_freq == '' else 'Frequency'

ret.append(self.curse_add_line(msg_name))
ret.append(self.curse_add_line(msg_freq))
ret.append(self.curse_new_line())

# Loop over CPU, MEM and LOAD
for key in self.stats_list:
Expand Down

0 comments on commit bc349db

Please sign in to comment.