{% extends 'admin.twig' %}

{% set title %}{{ 'UsersManager_PersonalSettings'|translate }}{% endset %}

{% block content %}

<div class="ui-confirm" id="confirmTokenRegenerate">
    <h2>{{ 'UsersManager_TokenRegenerateConfirmSelf'|translate }}</h2>
    <input role="yes" type="button" value="{{ 'General_Yes'|translate }}"/>
    <input role="no" type="button" value="{{ 'General_No'|translate }}"/>
</div>

<div piwik-content-block content-title="{{ title|e('html_attr') }}" feature="true">
    <form id="userSettingsTable" piwik-form ng-controller="PersonalSettingsController as personalSettings">

        <div piwik-field uicontrol="text" name="username"
             title="{{ 'General_Username'|translate|e('html_attr') }}"
             value="{{ userLogin }}" disabled="true"
             ng-model="personalSettings.username"
             inline-help="{{ 'UsersManager_YourUsernameCannotBeChanged'|translate|e('html_attr') }}">
        </div>

        <div piwik-field uicontrol="text" name="alias"
             ng-model="personalSettings.alias"
             maxlength="45"
             title="{{ 'UsersManager_Alias'|translate|e('html_attr') }}"
             value="{{ userAlias|raw }}">
        </div>

        <div piwik-field uicontrol="text" name="email"
             ng-model="personalSettings.email"
             maxlength="100"
             title="{{ 'UsersManager_Email'|translate|e('html_attr') }}"
             value="{{ userEmail }}">
        </div>

        <div id="languageHelp" class="inline-help-node">
            <a href="?module=Proxy&amp;action=redirect&amp;url=https://matomo.org/translations/" target="_blank">
                {{ 'LanguagesManager_AboutPiwikTranslations'|translate }}</a>
        </div>

        <div piwik-field uicontrol="select" name="language"
             ng-model="personalSettings.language"
             title="{{ 'General_Language'|translate|e('html_attr') }}"
             options="{{ languageOptions|json_encode }}"
             inline-help="#languageHelp"
             value="{{ currentLanguageCode }}">
        </div>

        <div piwik-field uicontrol="select" name="timeformat"
             ng-model="personalSettings.timeformat"
             title="{{ 'General_TimeFormat'|translate|e('html_attr') }}"
             value="{{ currentTimeformat }}" options="{{ timeFormats|json_encode }}">
        </div>

        <div piwik-field uicontrol="radio" name="defaultReport"
             ng-model="personalSettings.defaultReport"
             introduction="{{ 'UsersManager_ReportToLoadByDefault'|translate|e('html_attr') }}"
             title="{{ 'General_AllWebsitesDashboard'|translate|e('html_attr') }}"
             value="{{ defaultReport }}" options="{{ defaultReportOptions|json_encode }}">
        </div>

        <div piwik-siteselector
             ng-model="personalSettings.site"
             show-selected-site="true"
             class="sites_autocomplete"
             siteid="{{ defaultReportIdSite }}"
             sitename="{{ defaultReportSiteName }}"
             switch-site-on-select="false"
             show-all-sites-item="false"
             showselectedsite="true"
             id="defaultReportSiteSelector"
        ></div>

        <div piwik-field uicontrol="radio" name="defaultDate"
             ng-model="personalSettings.defaultDate"
             introduction="{{ 'UsersManager_ReportDateToLoadByDefault'|translate|e('html_attr') }}"
             value="{{ defaultDate }}" options="{{ availableDefaultDates|json_encode }}">
        </div>

        {% if isValidHost is defined and isValidHost %}

            <div piwik-field uicontrol="password" name="password" autocomplete="off"
                 ng-model="personalSettings.password"
                 introduction="{{ 'General_ChangePassword'|translate|e('html_attr') }}"
                 title="{{ 'Login_NewPassword'|translate|e('html_attr') }}"
                 value="" inline-help="{{ 'UsersManager_IfYouWouldLikeToChangeThePasswordTypeANewOne'|translate|e('html_attr') }}">
            </div>

            <div piwik-field uicontrol="password" name="passwordBis" autocomplete="off"
                 ng-model="personalSettings.passwordBis"
                 title="{{ 'Login_NewPasswordRepeat'|translate|e('html_attr') }}"
                 value="" inline-help="{{ 'UsersManager_TypeYourPasswordAgain'|translate|e('html_attr') }}">
            </div>
        {% endif %}

        {% if isValidHost is not defined or not isValidHost %}
            <div class="alert alert-danger">
                {{ 'UsersManager_InjectedHostCannotChangePwd'|translate(invalidHost) }}
                {% if not isSuperUser %}{{ 'UsersManager_EmailYourAdministrator'|translate(invalidHostMailLinkStart,'</a>')|raw }}{% endif %}
            </div>
        {% endif %}

        <div piwik-save-button onconfirm="personalSettings.save()"
             saving="personalSettings.loading"></div>

    </form>
</div>

<div piwik-content-block
     content-title="{{ 'UsersManager_TokenAuth'|translate|e('html_attr') }}">
    <pre piwik-select-on-focus id="token_auth_user" piwik-show-sensitive-data="{{ userTokenAuth }}"></pre>

    <p>{{ 'UsersManager_TokenRegenerateLogoutWarning'|translate }}</p>
    <button class="btn btn-link"
            ng-controller="PersonalSettingsController as personalSettings"
            ng-click="personalSettings.regenerateTokenAuth()">{{ 'UsersManager_TokenRegenerateTitle'|translate }}</button>
</div>

<div piwik-plugin-settings mode="user"></div>

<div piwik-content-block
     content-title="{{ 'UsersManager_ExcludeVisitsViaCookie'|translate|e('html_attr') }}">
    <p>
        {% if ignoreCookieSet %}
            {{ 'UsersManager_YourVisitsAreIgnoredOnDomain'|translate("<strong>", piwikHost, "</strong>")|raw }}
        {% else %}
            {{ 'UsersManager_YourVisitsAreNotIgnored'|translate("<strong>","</strong>")|raw }}
        {% endif %}
    </p>
    <span style="margin-left:20px;">
    <a href='{{ linkTo({'ignoreSalt':ignoreSalt, 'module': 'UsersManager', 'action':'setIgnoreCookie'}) }}#excludeCookie'>&rsaquo; {% if ignoreCookieSet %}{{ 'UsersManager_ClickHereToDeleteTheCookie'|translate }}
        {% else %}{{'UsersManager_ClickHereToSetTheCookieOnDomain'|translate(piwikHost) }}{% endif %}
        <br/>
    </a></span>
</div>

{% endblock %}
