{% extends "layout.html" %}
{% block body %}
        {% include "notifications.html" %}
        <div class="col-sm-9 col-sm-offset-3 col-md-10 col-md-offset-2 main">
          {% include "small_topbar.html" %}
          <ul class="breadcrumb" style="margin-bottom: 5px;">
            <li class="active">{{ _('User settings') }}</li>
          </ul>
          <br />
          <div id="user-panel-sessions" class="form-container">
            <legend id="sessions">{{ _('Sessions') }}</legend>
            <div class="table-responsive">
              <table class="table table-striped table-hover nowrap" id="table-sessions" width="100%">
                <thead>
                  <tr>
                    <th>IP</th>
                    <th>{{ _('Last seen') }}</th>
                    <th>{{ _('User-Agent') }}</th>
                    <th>{{ _('API Login') }}</th>
                    <th>{{ _('Current session') }}</th>
                    <th>{{ _('Expire') }}</th>
                    <th>{{ _('Revoke') }}</th>
                  </tr>
                </thead>
                <tbody>
                </tbody>
              </table>
            </div>
          </div>
          <div id="user-panel-prefs" class="form-container">
            <legend id="prefs">{{ _('Preferences') }}</legend>
            <form class="form-horizontal well" name="changePassword" ng-submit="submitChangePass($event)" method="POST" action="{{ url_for('api.auth_users', name=current_user.name) }}">
              <fieldset>
                <legend>{{ _('Password') }}</legend>
                <div class="form-group" ng-class="{'has-error': changePassword.oldPass.$invalid  && changePassword.oldPass.$dirty}">
                  <label for="oldPassword" class="col-lg-2 control-label">{{ _('Current password') }}</label>
                  <div class="col-lg-3">
                    <input class="form-control input-sm" name="oldPass" id="oldPassword" placeholder="{{ _('Current password') }}" type="password" ng-required="true" ng-model="user.oldPassword">
                  </div>
                  <span ng-show="changePassword.oldPass.$invalid  && changePassword.oldPass.$dirty" class="help-inline text-danger" ng-cloak>Required</span>
                </div>
                <div class="form-group" ng-class="{'has-error': changePassword.newPass.$invalid && changePassword.newPass.$dirty}">
                  <label for="inputPassword" class="col-lg-2 control-label">{{ _('New password') }}</label>
                  <div class="col-lg-3">
                    <input class="form-control input-sm" name="newPass" id="inputPassword" placeholder="{{ _('New password') }}" type="password" ng-required="true" ng-model="user.newPassword">
                  </div>
                  <span ng-show="changePassword.newPass.$invalid  && changePassword.newPass.$dirty" class="help-inline text-danger" ng-cloak>Required</span>
                </div>
                <div class="form-group" ng-class="{'has-warning': changePassword.confPass.$invalid  && changePassword.confPass.$dirty}">
                  <label for="confirmPassword" class="col-lg-2 control-label">{{ _('Confirm password') }}</label>
                  <div class="col-lg-3">
                    <input class="form-control input-sm" name="confPass" id="confirmPassword" placeholder="{{ _('New password (confirm)') }}" type="password" ng-required="true" ng-model="user.confPassword" compare-to="user.newPassword">
                  </div>
                  <span ng-show="changePassword.confPass.$invalid  && changePassword.confPass.$dirty" class="help-inline text-warning" ng-cloak>Passwords mismatch</span>
                </div>
                <div class="form-group">
                  <div class="col-lg-10 col-lg-offset-2">
                    <button type="reset" class="btn btn-default">{{ _('Cancel') }}</button>
                    <button type="submit" class="btn btn-primary" ng-disabled="changePassword.$invalid && changePassword.$dirty">{{ _('Submit') }}</button>
                  </div>
                </div>
              </fieldset>
            </form>
            <div></div>
          </div>
          <!-- NOT YET IMPLEMENTED
          <div id="user-panel-acl" class="form-container">
            <legend id="acl">{{ _('ACL') }}</legend>
            <div></div>
          </div>
          -->
        </div>
        <div id="confirmation-modal" class="modal fade">
          <div class="modal-dialog modal-lg">
            <div class="modal-content">
              <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
                <h4 class="modal-title">Confirmation</h4>
              </div>
              <div class="modal-body">
                <div class="alert alert-warning">
                  <span class="glyphicon glyphicon-question-sign"></span>&nbsp;{{ _('You are about to revoke a session, are you sure?') }}
                  <pre id="session-details"></pre>
                </div>
                <div class="alert alert-danger" id="error-confirm" style="display:none;">
                  <strong><span class="glyphicon glyphicon-exclamation-sign"></span>&nbsp;{{ _('Warning!') }}</strong> {{ _('You are about to revoke your <strong>current</strong> session.') }}
                </div>
              </div>
              <div class="modal-footer">
                <button type="button" class="btn btn-default" data-dismiss="modal">{{ _('Cancel') }}</button>
                <button type="button" class="btn btn-info" data-dismiss="modal" id="perform-revoke">{{ _('Confirm') }}</button>
              </div>
            </div>
          </div>
        </div>
{% endblock %}
