{% extends "base.html" %} {% from "_macros.html" import option_field, secret_field, number_field, env_label, env_label_existing %} {% block title %}{{ t("新建目标") if mode == "create" else t("编辑目标") }} · {{ product_name }}{% endblock %} {% block container_class %} container--form{% endblock %} {% block content %} {% set connection_rows = option_rows | selectattr("section", "equalto", "connection") | list %} {% set connection_secrets = secret_rows | selectattr("section", "equalto", "connection") | list %} {% set scope_rows = option_rows | selectattr("section", "equalto", "scope") | list %} {% set advanced_rows = option_rows | selectattr("section", "equalto", "advanced") | list %} {% set advanced_secrets = secret_rows | selectattr("section", "equalto", "advanced") | list %} {% set advanced_open = (advanced_rows | selectattr("error") | list | length) or (advanced_secrets | selectattr("error") | list | length) or (common_rows | selectattr("error") | list | length) %} {% if errors.get("_form") %} {% endif %} {% if errors and errors.keys() | reject("equalto", "_form") | list %} {% endif %}
{% if mode == "create" %}{% endif %}

{{ t('基本信息') }}

{% if mode == "create" %}
{% if environments|length <= 1 %} {{ t('所属环境') }}
{{ env_label(environments[0]) if environments else t('还没有环境') }}{% if environments %} {{ environments[0].key }}{% endif %}
{% else %} {% endif %} {% if errors.get('environment') %}{% endif %}

{{ t('保存后不能更换环境。') }}{% if environments|length <= 1 %} {{ t('新建环境') }}{% endif %}

{% else %}
{{ t('所属环境') }}
{{ env_label_existing(existing) }} {{ existing.environment_key }}

{{ t('创建后不能更换环境。') }}

{% endif %} {% if mode == "create" %}

{{ t('小写字母、数字与连字符,创建后不可修改;排查时传这个名字。') }}

{% else %}
{{ t('名称') }}
{{ existing.name }}

{{ t('创建后不可修改。') }}

{% endif %}

{{ t('停用后不能使用该目标,配置会保留。') }}

{{ t('连接') }}

{{ t('主机、账号、密钥、TLS 或超时变化后,需要重新测试才能保存。') }}

{% for row in connection_rows %}{{ option_field(row) }}{% endfor %} {% for row in connection_secrets %}{{ secret_field(row) }}{% endfor %}
{% if scope_rows %}

{{ t('授权范围') }}

{{ t('只会查询这里列出的范围。留空时按该项自己的默认处理。') }}

{% for row in scope_rows %}{{ option_field(row) }}{% endfor %}
{% endif %} {% if advanced_rows or advanced_secrets or common_rows %}
{{ t('高级设置') }}{{ t('TLS、证书、运行限制') }}
{% if advanced_rows %}

{{ t('安全连接') }}

{% for row in advanced_rows %}{{ option_field(row) }}{% endfor %}
{% endif %} {% if advanced_secrets %}
{% for row in advanced_secrets %}{{ secret_field(row) }}{% endfor %}
{% endif %}

{{ t('运行限制') }}

{{ t('这些上限作用于之后的工具调用。') }}

{% for row in common_rows %}{{ number_field(row) }}{% endfor %}
{% endif %}
{% if test_result %}{{ t('连接测试通过') if test_result.ok else t('连接测试失败') }}{% else %}{{ t('未测试') }}{% endif %} {% if test_result and test_result.ok %}{{ t('连接测试通过,可以保存。') }}{% elif test_result and test_result.message %}{{ test_result.message }}{% endif %} {% if test_result and test_result.checked_at_at %}{{ local_time(test_result.checked_at_at, true) }}{% elif test_result and test_result.checked_at %}{{ test_result.checked_at }}{% endif %}{% if test_result and test_result.duration_ms %} · {{ t('耗时') }} {{ test_result.duration_ms }} ms{% endif %}

{% if mode == 'edit' %}{{ t('连接未修改,可以直接保存。') }}{% else %}{{ t('请先测试连接') }}{% endif %}

{{ t('取消') }}
{% if mode == "create" and environments|length <= 1 %} {% set env_return = 'stay' %} {% include "_environment_drawer.html" %} {% endif %} {% endblock %}