{% extends 'base_for_react.html' %}
{% load seahub_tags avatar_tags i18n %}
{% load render_bundle from webpack_loader %}

{% block sub_title %}{% trans "Settings" %} - {% endblock %}

{% block extra_style %}
{% render_bundle 'settings' 'css' %}
{% endblock %}

{% block extra_script %}
<script type="text/javascript">
// overwrite the one in base_for_react.html
window.app.pageOptions = {
  username: "{{request.user.username|escapejs}}",
  contactEmail: "{{request.user.username|email2contact_email|escapejs}}",
  avatarURL: '{% avatar_url request.user %}',
  csrfToken: '{{ csrf_token }}',

  enableUpdateUserInfo: {% if ENABLE_UPDATE_USER_INFO %} true {% else %} false {% endif %},
  nameLabel: "{% trans "Name:" context "true name" %}",
  enableUserSetContactEmail: {% if ENABLE_USER_SET_CONTACT_EMAIL %} true {% else %} false {% endif %},
  enableUserSetName: {% if ENABLE_USER_SET_NAME %} true {% else %} false {% endif %},

  canUpdatePassword: {% if not is_ldap_user and ENABLE_CHANGE_PASSWORD %} true {% else %} false {% endif %},
  {% if not is_ldap_user and ENABLE_CHANGE_PASSWORD %}
  passwordOperationText: {% if user_unusable_password %}"{% trans "Set Password" %}"{% else %}"{% trans "Update" %}"{% endif %},
  {% endif %}
  userUnusablePassword: {% if user_unusable_password %} true {% else %} false {% endif %},
  userStrongPasswordRequired: {% if strong_pwd_required %} true {% else %} false {% endif %},

  enableGetAuthToken: {% if ENABLE_GET_AUTH_TOKEN_BY_SESSION %} true {% else %} false {% endif %},

  enableWebdavSecret: {% if ENABLE_WEBDAV_SECRET %} true {% else %} false {% endif %},
  {% if ENABLE_WEBDAV_SECRET %}
  webdavUrl: "{{ WEBDAV_URL }}",
  webdavPasswordSetted: {% if WEBDAV_SECRET_SETTED %} true {% else %} false {% endif %},
  webdavSecretMinLength: {{ WEBDAV_SECRET_MIN_LENGTH }},
  webdavSecretStrengthLevel: {{ WEBDAV_SECRET_STRENGTH_LEVEL }},
  {% endif %}

  enableAddressBook: {% if ENABLE_ADDRESSBOOK_OPT_IN %} true {% else %} false {% endif %},

  currentLang: {
    langCode: '{{ LANGUAGE_CODE|escapejs }}',
    langName: '{{ LANGUAGE_CODE|language_name_local|capfirst|escapejs }}'
  },
  langList: (function() {
    var list = [];
    {% for LANG in LANGUAGES %}
    list.push({
      langCode: '{{LANG.0|escapejs}}',
      langName: '{{LANG.1|escapejs}}'
    });
    {% endfor %}
    return list;
  })(),

  fileUpdatesEmailInterval: {{ file_updates_email_interval }},
  collaborateEmailInterval: {{ collaborate_email_interval }},

  twoFactorAuthEnabled: {% if two_factor_auth_enabled %} true {% else %} false {% endif %},
  {% if two_factor_auth_enabled %}
  defaultDevice: {% if default_device %} true {% else %} false {% endif %},
  backupTokens: {{backup_tokens}},
  {% endif %}

  enableWechatWork: {% if enable_wechat_work %} true {% else %} false {% endif %},
  langCode: "{{LANGUAGE_CODE|escapejs}}",
  {% if enable_wechat_work %}
  socialConnected: {% if social_connected %} true {% else %} false {% endif %},
  socialNextPage: "{{ social_next_page|escapejs }}",
  {% endif %}

  enableDingtalk: {% if enable_dingtalk %} true {% else %} false {% endif %},
  {% if enable_dingtalk %}
  socialConnectedDingtalk: {% if social_connected_dingtalk %} true {% else %} false {% endif %},
  socialNextPage: "{{ social_next_page|escapejs }}",
  {% endif %}

  enableWeixin: {% if enable_weixin %} true {% else %} false {% endif %},
  {% if enable_weixin %}
  socialConnectedWeixin: {% if social_connected_weixin %} true {% else %} false {% endif %},
  socialNextPage: "{{ social_next_page|escapejs }}",
  {% endif %}

  enableADFS: {% if enable_adfs %} true {% else %} false {% endif %},
  {% if enable_adfs %}
  samlConnected: {% if saml_connected %} true {% else %} false {% endif %},
  socialNextPage: "{{ social_next_page|escapejs }}",
  {% endif %}

  enableMultiADFS: {% if enable_multi_adfs %} true {% else %} false {% endif %},
  {% if enable_multi_adfs %}
  orgSamlConnected: {% if org_saml_connected %} true {% else %} false {% endif %},
  socialNextPage: "{{ social_next_page|escapejs }}",
  {% endif %}

  orgID: "{{ org_id }}",

  cloudMode: {% if cloud_mode %} true {% else %} false {% endif %},
  isOrgContext: {% if org is not None %} true {% else %} false {% endif %},
  enableSeafileAI: {% if enable_seafile_ai %} true {% else %} false {% endif %},
  enableDeleteAccount: {% if ENABLE_DELETE_ACCOUNT %} true {% else %} false {% endif %},
  forceUserSSOLogin: {% if force_user_sso_login %} true {% else %} false {% endif %}
};
</script>
{% render_bundle 'settings' 'js' %}
{% endblock %}
