{% extends 'base.html' %}
{% from 'bootstrap/nav.html' import render_breadcrumb_item %}

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

{% block navbar %}
    <nav class="navbar navbar-expand-lg navbar-dark bg-dark">
        <div class="container">
            <a class="navbar-brand" href="{{ url_for('admin.index') }}">
                <img src="{{ url_for('static', filename='favicon.ico') }}" alt="Phshare"> Phshare Dashboard
            </a>
            <button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbarColor01"
                    aria-controls="navbarColor01" aria-expanded="false" aria-label="Toggle navigation">
                <span class="navbar-toggler-icon"></span>
            </button>

            <div class="collapse navbar-collapse" id="navbarColor01">
                <div class="navbar-nav ml-auto">
                    {{ render_nav_item('main.index', 'Return Phshare') }}
                    <div class="dropdown nav-item">
                        <a href="#" class="nav-link dropdown-toggle" data-toggle="dropdown" role="button"
                           aria-expanded="false">Manage<span class="caret"></span>
                        </a>
                        <div class="dropdown-menu dropdown-menu-right" role="menu">
                            <a class="dropdown-item" href="{{ url_for('admin.manage_photo') }}">Photos</a>
                            <a class="dropdown-item" href="{{ url_for('admin.manage_user') }}">Users</a>
                            <a class="dropdown-item" href="{{ url_for('admin.manage_tag') }}">Tags</a>
                            <a class="dropdown-item" href="{{ url_for('admin.manage_comment') }}">Comments</a>
                        </div>
                    </div>
                    <div class="dropdown nav-item">
                        <a href="#" class="nav-link dropdown-toggle" data-toggle="dropdown" role="button"
                           aria-expanded="false">
                            <img class="avatar-xs"
                                 src="{{ url_for('main.get_avatar', filename=current_user.avatar_s) }}">
                            <span class="caret"></span>
                        </a>
                        <div class="dropdown-menu dropdown-menu-right" role="menu">
                            <h6 class="dropdown-header">Logged in as {{ current_user.username }}</h6>
                            <a class="dropdown-item" href="{{ url_for('user.index', username=current_user.username) }}">
                                <span class="oi oi-person"></span> My Home
                            </a>
                            <div class="dropdown-divider"></div>
                            <a class="dropdown-item" href="{{ url_for('user.edit_profile') }}">
                                <span class="oi oi-cog"></span> Settings
                            </a>
                            <a class="dropdown-item" href="{{ url_for('auth.logout') }}">
                                <span class="oi oi-power-standby"></span> Logout
                            </a>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </nav>
{% endblock %}

{% block content %}
    <nav aria-label="breadcrumb">
        <ol class="breadcrumb">
            {{ render_breadcrumb_item('admin.index', 'Dashboard Home') }}
        </ol>
    </nav>
    <div class="row">
        <div class="col-md-6">
            <div class="card border-primary mb-3">
                <div class="card-header"><span class="oi oi-image"></span> Photos</div>
                <div class="card-body">
                    <h4 class="card-title">Total: {{ photo_count|default('0') }}</h4>
                    <p class="card-text">Reported: {{ reported_photos_count|default('0') }}</p>
                    <a class="btn btn-primary text-white" href="{{ url_for('.manage_photo') }}">Manage</a>
                </div>
            </div>
        </div>
        <div class="col-md-6">
            <div class="card border-secondary mb-3">
                <div class="card-header"><span class="oi oi-people"></span> Users</div>
                <div class="card-body">
                    <h4 class="card-title">Total: {{ user_count|default('0') }}</h4>
                    <p class="card-text">Locked: {{ locked_user_count|default('0') }}
                        Blocked: {{ blocked_user_count|default('0') }}</p>
                    <a class="btn btn-primary text-white" href="{{ url_for('.manage_user') }}">Manage</a>
                    <a class="btn btn-secondary text-white" href="{{ url_for('.manage_user', filter='locked') }}">View
                        Locked</a>
                    <a class="btn btn-secondary text-white" href="{{ url_for('.manage_user', filter='blocked') }}">View
                        Blocked</a>
                </div>
            </div>
        </div>
    </div>
    <div class="row">
        <div class="col-md-6">
            <div class="card border-danger mb-3">
                <div class="card-header"><span class="oi oi-comment-square"></span> Comments</div>
                <div class="card-body">
                    <h4 class="card-title">Total: {{ comment_count|default('0') }}</h4>
                    <p class="card-text">Reported: {{ reported_comments_count|default('0') }}</p>
                    <a class="btn btn-primary text-white" href="{{ url_for('.manage_comment') }}">Manage</a>
                </div>
            </div>
        </div>
        <div class="col-md-6">
            <div class="card border-success mb-3">
                <div class="card-header"><span class="oi oi-tag"></span> Tags</div>
                <div class="card-body">
                    <h4 class="card-title">Total: {{ tag_count|default('0') }}</h4>
                    <p class="card-text">&nbsp;</p>
                    <a class="btn btn-primary text-white" href="{{ url_for('.manage_tag') }}">Manage</a>
                </div>
            </div>
        </div>
    </div>
{% endblock %}