Skip to content

Commit

Permalink
Show more info in footer
Browse files Browse the repository at this point in the history
  • Loading branch information
hmpf committed Jul 3, 2024
1 parent ee93ebc commit d91de78
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 7 deletions.
33 changes: 26 additions & 7 deletions src/howitz/endpoints.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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()
Expand Down Expand Up @@ -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')
Expand Down
9 changes: 9 additions & 0 deletions src/howitz/templates/components/footer/footer-info.html
Original file line number Diff line number Diff line change
@@ -1,6 +1,15 @@
<p class="p-2 text-white text-semibold inline-block">
Howitz: version {{ howitz_version }}.
</p>
<p class="p-2 text-white text-semibold inline-block">
Updating every {{ refresh_interval }}s.
</p>
<p class="p-2 text-white text-semibold inline-block">
Sort method: {{ sort_by }}.
</p>
<p class="p-2 text-white text-semibold inline-block">
Configured timezone is {{ timezone }}.
</p>
<p class="p-2 text-white text-semibold inline-block">
Connected to "{{ zino_server }}" with {{ protocol }}.
</p>

0 comments on commit d91de78

Please sign in to comment.