Development

This commit is contained in:
Matthew Grotke 2026-06-11 01:49:59 -04:00
parent 4b44fdf65a
commit ce280b6d7a
6 changed files with 20 additions and 6 deletions

View file

@ -21,10 +21,11 @@ HEALTH_FILE = f'{CONFIGS_DIR}/.health'
DNS_METRICS_DB = f'{CONFIGS_DIR}/.dns-metrics' DNS_METRICS_DB = f'{CONFIGS_DIR}/.dns-metrics'
DNS_QUERIES_DB = f'{CONFIGS_DIR}/.dns-queries' DNS_QUERIES_DB = f'{CONFIGS_DIR}/.dns-queries'
BLOCKLISTS_DIR = f'{CONFIGS_DIR}/blocklists' BLOCKLISTS_DIR = f'{CONFIGS_DIR}/blocklists'
PRODUCT_NAME = os.environ.get('PRODUCT_NAME', 'routlin') import settings as _settings
PRODUCT_NAME = _settings.product_name()
WEB_APP_DISPLAY_NAME = _settings.web_app_display_name()
DASHB_TIMER_NAME = f'{PRODUCT_NAME}-dashboard-queue' DASHB_TIMER_NAME = f'{PRODUCT_NAME}-dashboard-queue'
DDNS_TIMER_NAME = f'{PRODUCT_NAME}-ddns-update' DDNS_TIMER_NAME = f'{PRODUCT_NAME}-ddns-update'
WEB_APP_DISPLAY_NAME = os.environ.get('WEB_APP_DISPLAY_NAME', f'{PRODUCT_NAME.capitalize()} Dashboard')
DASHB_INTERVAL_SECS = 30 DASHB_INTERVAL_SECS = 30
QUEUE_MAX_LINES = 50 QUEUE_MAX_LINES = 50

View file

@ -1547,8 +1547,7 @@ def render_layout(view_id, content_html, tokens, page_name=None, suppress_pendin
has_pending_alert = not config_utils._apply_changes_immediately() and bool(config_utils.get_dashboard_pending()) has_pending_alert = not config_utils._apply_changes_immediately() and bool(config_utils.get_dashboard_pending())
titlebar_html = f'<div class="titlebar"><span class="titlebar-brand">{config_utils.WEB_APP_DISPLAY_NAME}</span></div>' titlebar_html = f'<div class="titlebar"><span class="titlebar-brand">{config_utils.WEB_APP_DISPLAY_NAME}</span></div>'
navbar_html = build_navbar(view_id, level, tokens, pending_alert=has_pending_alert) navbar_html = build_navbar(view_id, level, tokens, pending_alert=has_pending_alert)
edition = 'Pro' if settings.is_pro() else 'CE' footer_html = f'<footer class="footer">{config_utils.WEB_APP_DISPLAY_NAME}</footer>'
footer_html = f'<footer class="footer">{config_utils.PRODUCT_NAME.capitalize()}-{edition}</footer>'
page_hash = config_utils.config_hash() page_hash = config_utils.config_hash()
lan_iface = e(tokens.get('GENERAL_LAN_INTERFACE', '')) lan_iface = e(tokens.get('GENERAL_LAN_INTERFACE', ''))

View file

@ -30,6 +30,7 @@ def accountdetails_save():
return redirect(f'/{_PAGE}') return redirect(f'/{_PAGE}')
tz_offset = _tz_to_offset_seconds(tz) tz_offset = _tz_to_offset_seconds(tz)
session['timezone'] = tz
session['tz_offset_seconds'] = tz_offset session['tz_offset_seconds'] = tz_offset
flash('Preferences saved.', 'success') flash('Preferences saved.', 'success')

View file

@ -8,6 +8,6 @@ def collect_tokens(cfg):
tokens = config_utils.collect_layout_tokens(cfg) tokens = config_utils.collect_layout_tokens(cfg)
blank = [{'value': '', 'label': '-- Select Timezone --'}] blank = [{'value': '', 'label': '-- Select Timezone --'}]
tokens['PREF_EMAIL'] = session.get('email_address', '') tokens['PREF_EMAIL'] = session.get('email_address', '')
tokens['PREF_TIMEZONE'] = '' tokens['PREF_TIMEZONE'] = session.get('timezone', '')
tokens['TIMEZONE_OPTIONS'] = json.dumps(blank + [{'value': tz, 'label': tz} for tz in sanitize.VALID_TIMEZONES]) tokens['TIMEZONE_OPTIONS'] = json.dumps(blank + [{'value': tz, 'label': tz} for tz in sanitize.VALID_TIMEZONES])
return tokens return tokens

View file

@ -52,6 +52,7 @@ class SqliteSessionInterface(SessionInterface):
'email_address': str(row['email']), 'email_address': str(row['email']),
'access_level': _LEVEL_INT_TO_STR.get(row['access_level'], 'viewer'), 'access_level': _LEVEL_INT_TO_STR.get(row['access_level'], 'viewer'),
'tz_offset_seconds': int(row['tz_offset_seconds']), 'tz_offset_seconds': int(row['tz_offset_seconds']),
'timezone': str(prefs.get('timezone', '')),
'apply_changes_immediately': bool(prefs.get('apply_changes_immediately', False)), 'apply_changes_immediately': bool(prefs.get('apply_changes_immediately', False)),
'_flashes': flashes, '_flashes': flashes,
} }
@ -91,7 +92,10 @@ class SqliteSessionInterface(SessionInterface):
try: try:
con = self._connect() con = self._connect()
if account_id: if account_id:
prefs = json.dumps({'apply_changes_immediately': bool(session.get('apply_changes_immediately', False))}) prefs = json.dumps({
'timezone': session.get('timezone', ''),
'apply_changes_immediately': bool(session.get('apply_changes_immediately', False)),
})
tz_offset = int(session.get('tz_offset_seconds', 0)) tz_offset = int(session.get('tz_offset_seconds', 0))
con.execute('INSERT OR IGNORE INTO clients (cookie_unique_token) VALUES (?)', (session.sid,)) con.execute('INSERT OR IGNORE INTO clients (cookie_unique_token) VALUES (?)', (session.sid,))
con.execute( con.execute(

View file

@ -1,6 +1,15 @@
import os import os
def product_name():
return os.environ.get('PRODUCT_NAME', 'routlin')
def web_app_display_name():
edition = 'Pro' if is_pro() else 'CE'
return os.environ.get('WEB_APP_DISPLAY_NAME', f'{product_name().capitalize()}-{edition}')
def is_production(): def is_production():
return not os.environ.get('DEV_MODE', '').lower() in ('1', 'true', 'yes') return not os.environ.get('DEV_MODE', '').lower() in ('1', 'true', 'yes')