{# Button Moved Back To Header #}
{% if username %} {# Check if user has register_service permission for any service #} {% if 'register_service' in user_context.ui_permissions and user_context.ui_permissions.register_service %} {% endif %} {# Add Generate Token button for all authenticated users #} 🔑 Generate API Token {% endif %}
{{ username }} {% if user_context.is_admin %} 🔑 Admin Access {% elif user_context.can_modify_servers %} ⚙️ Modify Access {% else %} 👁️ Read-only Access {% endif %} {% if user_context.auth_method == 'oauth2' %} ({{ user_context.provider | title }}) {% endif %} {% if not user_context.is_admin %} Access: {{ user_context.accessible_servers | length }} server(s) {% endif %}
{% if services %} {% for service in services %}

{{ service.display_name }}

official ☁️ 💻 {# Refresh button - only show if user has health_check_service permission #} {% if can_perform_action('health_check_service', service.display_name) %} {% endif %}

Path: {{ service.path }}

{% for tag in service.tags %} {{ tag }} {% endfor %}

{{ service.description | default('No description provided.') }}

{# --- Moved Status Badge Logic Here --- #} {% set initial_status = service.health_status %} {# Determine initial class and text, avoiding 'checking' text #} {% set status_class = 'status-unknown' %} {% set display_text = 'unknown' %} {% if initial_status == 'healthy' %} {% set status_class = 'status-healthy' %} {% set display_text = 'healthy' %} {% elif initial_status.startswith('unhealthy') %} {% set status_class = 'status-unhealthy' %} {% set display_text = initial_status.split('(')[0].strip() %} {% elif initial_status.startswith('error') %} {% set status_class = 'status-error' %} {% set display_text = initial_status.split('(')[0].strip() %} {% elif initial_status == 'disabled' %} {% set status_class = 'status-disabled' %} {% set display_text = 'disabled' %} {% elif initial_status == 'checking' %} {# If checking initially, display as 'unknown' until first WS update #} {# Spinner will be shown by JS if needed #} {% set status_class = 'status-unknown' %} {% set display_text = 'unknown' %} {% endif %} {# Generate IDs - REMOVE leading slash BEFORE replacing #} {% set safe_path = service.path | replace('/', '', 1) | replace('/', '_') | replace(':', '_') %} {% set badge_id = 'status-badge-' + safe_path %} {% set spinner_id = 'spinner-for-' + safe_path %} {% set last_checked_id = 'last-checked-' + safe_path %} {# Render badge with determined initial text/class #}
{{ display_text }} {# Always render spinner, hide initially with inline style #}
{# Check if user has modify_service permission for this specific service #} {% if can_perform_action('modify_service', service.display_name) %} Modify {% endif %} {# Check if user has toggle_service permission for this specific service #} {% if can_perform_action('toggle_service', service.display_name) %} {# Add ID to form if needed, but action URL is sufficient #}
{# Add ID to label span #} {{ 'Enabled' if service.is_enabled else 'Disabled' }}
{% elif can_perform_action('list_service', service.display_name) %} {# Users who can list but not toggle: show read-only status #}
📖 {{ 'Enabled' if service.is_enabled else 'Disabled' }} (Read-only)
{% endif %}
{% endfor %} {% else %}

No services found matching your query, or none registered. Try rescanning.

{% endif %}