{% extends "base.html" %} {% from "components/ui.html" import page_header %} {% block title %}{{ display_name }} {{ _('Integration') }} - {{ app_name }}{% endblock %} {% block content %} {% set breadcrumbs = [ {'text': 'Integrations', 'url': url_for('integrations.list_integrations')}, {'text': display_name} ] %} {{ page_header( icon_class='fas fa-plug', title_text=display_name, subtitle_text=description, breadcrumbs=breadcrumbs ) }}
{% if has_setup_wizard(provider) %}

{{ _('Guided Setup Wizard') }}

{{ _('Use our step-by-step wizard to configure this integration easily.') }}

{{ _('Launch Setup Wizard') }}
{% endif %} {% if current_user.is_admin and provider == 'linear' and integration %}

{{ _('Linear API Key') }}

{{ _('From Linear: Settings → API → Personal API keys') }}

{% endif %} {% if current_user.is_admin and provider not in ('caldav_calendar', 'activitywatch', 'linear') %}

{{ _('OAuth Credentials Setup') }}

{% if provider == 'trello' %}

{{ _('Get your API key from') }} trello.com/app-key

{{ _('Get your API secret from') }} trello.com/app-key {{ _('(shown after generating API key)') }}

{{ _('After saving API Key and Secret, you can connect Trello using OAuth flow.') }}

{% else %}

{{ _('Required for new setup. Leave empty to keep existing secret.') }}

{% if provider in ['outlook_calendar', 'microsoft_teams'] %}

{{ _('Leave empty to use "common" (multi-tenant). Enter your Azure AD tenant ID for single-tenant apps.') }}

{% endif %} {% if provider == 'gitlab' %}

{{ _('URL of your GitLab instance. Use "https://gitlab.com" for GitLab.com or your self-hosted GitLab URL.') }}

{% endif %}
{% if provider != 'trello' %}

{{ _('OAuth Redirect URI') }}

{{ _('Add this URL as an authorized redirect URI in your OAuth app settings:') }}

{{ url_for('integrations.oauth_callback', provider=provider, _external=True) }} {% if provider == 'google_calendar' %}

{{ _('Automatic Connection Flow') }}

  • {{ _('After you save these credentials, users can click "Connect Google Calendar"') }}
  • {{ _('They will be automatically redirected to Google OAuth') }}
  • {{ _('No manual credential entry needed - fully automatic!') }}
  • {{ _('Each user connects their own Google Calendar account') }}
{% endif %}
{% endif %} {% endif %}
{% endif %} {% if provider == 'caldav_calendar' and active_integration %}

{{ _('CalDAV Authentication') }}

{{ _('CalDAV uses username and password authentication (not OAuth). Update your credentials below.') }}

{{ _('Your CalDAV username (usually your email address).') }}

{{ _('Your CalDAV password or app-specific password.') }} {% if credentials %} {{ _('Leave empty to keep your current password.') }} {% endif %}

{% endif %} {% if active_integration and config_schema and config_schema.get('fields') %}

{{ _('Integration Configuration') }}

{{ _('Configure sync settings, data mappings, and other integration options.') }}

{% if config_schema.get('sections') %} {% for section in config_schema.sections %}

{{ section.get('title', 'Settings') }}

{% if section.get('description') %}

{{ section.get('description') }}

{% endif %}
{% for field_name in section.get('fields', []) %} {% set field = config_schema.fields|selectattr('name', 'equalto', field_name)|first %} {% if field %} {% set field_type = field.get('type', 'string') %} {% set field_value = current_config.get(field_name, field.get('default', '')) %}
{% if field_type == 'boolean' %}
{% elif field_type == 'select' %} {% elif field_type == 'array' %}
{% for option in field.get('options', []) %} {% set option_value = option.get('value', option.get('label', '')) %} {% set is_selected = field_value and option_value in field_value %}
{% endfor %}
{% elif field_type == 'number' %} {% elif field_type == 'text' or field_type == 'textarea' %} {% elif field_type == 'json' %} {% else %} {% endif %} {% if field.get('help') or field.get('description') %}

{{ field.get('help', field.get('description', '')) }}

{% endif %}
{% endif %} {% endfor %}
{% endfor %} {% else %}
{% for field in config_schema.fields %} {% set field_name = field.name %} {% set field_type = field.get('type', 'string') %} {% set field_value = current_config.get(field_name, field.get('default', '')) %}
{% if field_type == 'boolean' %}
{% elif field_type == 'select' %} {% elif field_type == 'array' %}
{% for option in field.get('options', []) %} {% set option_value = option.get('value', option.get('label', '')) %} {% set is_selected = field_value and option_value in field_value %}
{% endfor %}
{% elif field_type == 'number' %} {% elif field_type == 'text' or field_type == 'textarea' %} {% elif field_type == 'json' %} {% else %} {% endif %} {% if field.get('help') or field.get('description') %}

{{ field.get('help', field.get('description', '')) }}

{% endif %}
{% endfor %}
{% endif %}
{% endif %}

{{ _('Connection Management') }}

{% set active_integration = integration if is_global else user_integration %} {% if connector_error %}

{{ _('Connector Error') }}: {{ connector_error }}

{% endif %} {% if active_integration %}

{{ display_name }}

{% if active_integration.is_active %} {{ _('Connected') }} {% else %} {{ _('Not Connected') }} {% endif %} {% if is_global %} {{ _('Global') }} {% endif %} {% if active_integration.last_sync_status == 'success' %} {{ _('Sync OK') }} {% elif active_integration.last_sync_status == 'error' %} {{ _('Sync Error') }} {% endif %}
{% if credentials %}
{{ _('Connection Status') }}: {% if credentials.expires_at %} {{ _('Expires') }}: {{ credentials.expires_at|user_datetime }} {% else %} {{ _('No expiration') }} {% endif %}
{% else %}
{{ _('Connection Status') }}: {{ _('Not connected') }}
{% endif %} {% if active_integration.last_sync_at %}
{{ _('Last Sync') }}: {{ active_integration.last_sync_at|user_datetime }}
{% else %}
{{ _('Last Sync') }}: {{ _('Never') }}
{% endif %}
{% if active_integration.last_error %}

{{ _('Last Error') }}: {{ active_integration.last_error }}

{% endif %}
{% if connector %}
{{ _('View Details') }}
{% endif %}
{% elif provider == 'caldav_calendar' %}

{{ _('CalDAV uses username/password authentication. Click below to set up your CalDAV connection.') }}

{{ _('Setup CalDAV Integration') }}
{% elif provider == 'activitywatch' %}

{{ _('ActivityWatch imports window and web activity from your local aw-server. Click below to configure.') }}

{{ _('Setup ActivityWatch Integration') }}
{% elif provider == 'trello' %} {% if is_global and not current_user.is_admin %}

{{ _('Trello integration must be configured by an administrator.') }}

{% elif current_creds.get('api_key') %}

{{ _('OAuth credentials are configured. You can now connect Trello.') }}

{{ _('Connect Trello') }}
{% else %}

{{ _('Please configure Trello API key and token in the OAuth Credentials Setup section above.') }}

{% endif %} {% else %} {% if current_creds.get('client_id') or (is_global and current_user.is_admin) or (not is_global) %}
{% if is_global and not current_creds.get('client_id') and current_user.is_admin %}

{{ _('Please configure OAuth credentials in the section above before connecting.') }}

{% elif not is_global and not current_creds.get('client_id') %}

{{ _('OAuth credentials need to be configured by an administrator first.') }}

{% else %}

{% if provider == 'google_calendar' %} {{ _('Connect your Google Calendar account. You will be redirected to Google for authorization.') }} {% else %} {{ _('Connect this integration. You will be redirected to the provider for authorization.') }} {% endif %}

{% if provider == 'google_calendar' %} {{ _('Connect Google Calendar') }} {% else %} {{ _('Connect') }} {{ display_name }} {% endif %} {% endif %}
{% else %}

{{ _('OAuth credentials need to be configured by an administrator first.') }}

{% endif %} {% endif %}
{% endblock %}