diff --git a/src/howitz/endpoints.py b/src/howitz/endpoints.py index d74be603..8675fb0f 100644 --- a/src/howitz/endpoints.py +++ b/src/howitz/endpoints.py @@ -25,6 +25,7 @@ from howitz.users.utils import authenticate_user +from . import __version__ from .config.defaults import DEFAULT_TIMEZONE from .utils import login_check, date_str_without_timezone, shorten_downtime, calculate_event_age_no_seconds @@ -161,6 +162,29 @@ def clear_ui_state(): current_app.cache.clear() +def get_timezone(): + tz = current_app.howitz_config["timezone"] # Get raw string from config. Accepted values are 'UTC' or 'LOCAL'. + if tz == 'LOCAL': # Change to a specific timezone name if 'LOCAL' + tz = datetime.now(timezone.utc).astimezone().tzinfo + elif not tz == DEFAULT_TIMEZONE: # Fall back to default if invalid value is provided + tz = f"{DEFAULT_TIMEZONE} (default)" + return tz + + +def get_info_dict(): + with current_app.app_context(): + events = current_app.cache.get("events") or () + info_dict = { + 'event_count': len(events), + 'howitz_version': __version__, + 'sort_by': session.get('sort_by') or 'raw', + 'timezone': get_timezone(), + 'zino_server': current_app.zino_config.server, + 'protocol': 'TCP v1', + } + return info_dict + + def get_current_events(): try: current_app.event_manager.get_events() @@ -441,15 +465,10 @@ def index(): @main.get('/footer') def footer(): - tz = current_app.howitz_config["timezone"] # Get raw string from config. Accepted values are 'UTC' or 'LOCAL'. - if tz == 'LOCAL': # Change to a specific timezone name if 'LOCAL' - tz = datetime.now(timezone.utc).astimezone().tzinfo - elif not tz == DEFAULT_TIMEZONE: # Fall back to default if invalid value is provided - tz = f"{DEFAULT_TIMEZONE} (default)" - + info_dict = get_info_dict() return render_template('/components/footer/footer-info.html', refresh_interval=current_app.howitz_config["refresh_interval"], - timezone=tz) + **info_dict) @main.route('/login') diff --git a/src/howitz/templates/components/footer/footer-info.html b/src/howitz/templates/components/footer/footer-info.html index 3da04b85..ecaae59a 100644 --- a/src/howitz/templates/components/footer/footer-info.html +++ b/src/howitz/templates/components/footer/footer-info.html @@ -1,6 +1,15 @@ +

+ Howitz: version {{ howitz_version }}. +

Updating every {{ refresh_interval }}s.

+

+ Sort method: {{ sort_by }}. +

Configured timezone is {{ timezone }}.

+

+ Connected to "{{ zino_server }}" with {{ protocol }}. +