{% extends "layouts/default.html" %}

{% block title %} Dashboard {% endblock title %}

{% block stylesheets %}

{% endblock stylesheets %}

{% block content %}

{% if current_user.is_authenticated %}

<div class="page-inner">
    <div class="row ">
        <div class="col-md-12">
            <div class="card card-profile">
                <div class="card-header">
                    <div class="profile-picture">
                        <div class="avatar avatar-xl">
                            <img src="/static/assets/img/profile.jpg" alt="..." class="avatar-img rounded-circle">
                        </div>
                    </div>
                </div>
                <div class="card-body">
                    <div class="user-profile text-center">
                        <div class="name">{{ current_user.name }}</div>
                        <div class="desc">Forensicator</div>
                    </div>
                </div>
                <div class="card-footer">
                    <div class="row">
                        <div class="form-group col">
                            <div class="input-group mb-3">
                                <div class="input-group-prepend">
                                    <span class="input-group-text">
                                        <i class="icon-token"></i>
                                        Name
                                    </span>
                                </div>
                                <input class="form-control" value="{{ current_user.name }}" readonly>
                            </div>
                        </div>
                        <div class="form-group col">
                            <div class="input-group mb-3">
                                <div class="input-group-prepend">
                                    <span class="input-group-text">
                                        <i class="icon-token"></i>
                                        Username
                                    </span>
                                </div>
                                <input class="form-control disable" value="{{ current_user.user }}" readonly>
                            </div>
                        </div>
                    </div>
                    <div class="row">
                        <div class="form-group col">
                            <div class="input-group mb-3">
                                <div class="input-group-prepend">
                                    <span class="input-group-text">
                                        <i class="icon-token"></i>
                                        Email
                                    </span>
                                </div>
                                <input class="form-control disable" value="{{ current_user.email }}" readonly>
                            </div>
                        </div>
                        <div class="form-group col">
                            <div class="input-group mb-3">
                                <div class="input-group-prepend">
                                    <span class="input-group-text">
                                        <i class="icon-token"></i>
                                        #ID
                                    </span>
                                </div>
                                <input class="form-control disable" value="{{ current_user.id }}" readonly>
                            </div>
                        </div>
                        <div class="form-group col">
                            <div class="input-group mb-3">
                                <div class="input-group-prepend">
                                    <span class="input-group-text">
                                        <i class="icon-token"></i>
                                        #UUID
                                    </span>
                                </div>
                                <input class="form-control disable" value="{{ current_user.uuid }}" readonly>
                            </div>
                        </div>
                    </div>
                    {% if config['AUTHENTICATION_TYPE'] == 'local' or config['AUTHENTICATION_TYPE'] == 'ldap' %}
                    <div class="row mb-4">
                        <div class="form-group col">
                            <div class="input-group">
                                <div class="input-group-prepend">
                                    <span class="input-group-text">
                                        <i class="icon-token"></i>
                                        API Key
                                    </span>
                                </div>
                                <input class="form-control disable" value="{{ current_user.api_key }}" readonly>
                                <div class="input-group-append">
                                    <button class="btn btn-sm btn-dark" type="button" onclick="renew_api()">Renew</button>
                                </div>
                            </div>
                        </div>
                    </div>
                    {% endif %}
                    <div class="row">
                        <div class="col">
                            <div class="form-group">
                                <label class="form-label d-block">IRIS Theme</label>
                                <div class="selectgroup selectgroup-primary selectgroup-pills">
                                    <label class="selectgroup-item" title="Light mode">
                                        <input type="radio" name="iris-theme" value="false" class="selectgroup-input" {% if not current_user.in_dark_mode %}checked{% endif %}>
                                        <span class="selectgroup-button selectgroup-button-icon"><i class="fa fa-sun"></i></span>
                                    </label>
                                    <label class="selectgroup-item" title="Dark mode">
                                        <input type="radio" name="iris-theme" value="true" class="selectgroup-input" {% if current_user.in_dark_mode %}checked{% endif %}>
                                        <span class="selectgroup-button selectgroup-button-icon"><i class="fa fa-moon"></i></span>
                                    </label>
                                </div>
                            </div>
                        </div>
                        <div class="col">
                            <div class="form-group">
                                <label class="form-label d-block">Prompt a confirmation box before deleting objects</label>
                                <div class="selectgroup selectgroup-primary selectgroup-pills">
                                    <label class="selectgroup-item" title="Do not prompt a confirmation popup and delete objects directly">
                                        <input type="radio" name="user-has-deletion-prompt" value="false" class="selectgroup-input" {% if not current_user.has_deletion_confirmation %}checked{% endif %}>
                                        <span class="selectgroup-button selectgroup-button-icon"><i class="fa fa-comment-slash"></i></span>
                                    </label>
                                    <label class="selectgroup-item" title="Prompt a confirmation popup before deleting objects">
                                        <input type="radio" name="user-has-deletion-prompt" value="true" class="selectgroup-input" {% if current_user.has_deletion_confirmation %}checked{% endif %}>
                                        <span class="selectgroup-button selectgroup-button-icon"><i class="fa fa-comment"></i></span>
                                    </label>
                                </div>
                            </div>
                        </div>
                    </div>
                    <div class="row">
                        <div class="col-6 float-left mt-4">
                            <button class="btn btn-dark" type="button" onclick="refresh_user_permissions();" id="user_refresh_perms_btn">Refresh access</button>
                        </div>

                        <div class="col-6 mt-4">
                            {% if mfa_enabled %}
                                <a class="btn btn-primary float-right mr-2" type="button" href="/auth/mfa-setup">Reset MFA</a>
                            {% endif %}
                            <button class="btn float-right btn-primary mr-2" type="button" onclick="update_password();">Change password</button>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>
<div class="modal" tabindex="-1" role="dialog" id="modal_pwd_user" data-backdrop="true">
    <div class="modal-lg modal-dialog" role="document">
        <div class="modal-content" id="modal_pwd_user_content">

        </div><!-- /.modal-content -->
    </div><!-- /.modal-dialog -->
</div>
{% endif %}

{% endblock content %}

{% block javascripts %}
    <script src="/static/assets/js/iris/user.js"></script>
{% endblock javascripts %}