{# @var craft \craft\web\twig\variables\CraftVariable #}
{#
/**
 * Retour plugin for Craft CMS 3.x
 *
 * Retour Dashboard index.twig
 *
 * @author    nystudio107
 * @copyright Copyright (c) 2018 nystudio107
 * @link      https://nystudio107.com/
 * @package   Retour
 * @since     3.0.0
 */
#}

{% requirePermission "retour:dashboard" %}

{% extends "retour/_layouts/retour-cp.twig" %}

{% import "_includes/forms" as forms %}

{% block contextMenu %}
    {% include "retour/_includes/sites-menu.twig" %}
{% endblock %}

{% block actionButton %}
    <div class="buttons">
        <div class="retour-button-container">
            <a href="{{ actionUrl('retour/file/export-statistics') }}" class="btn icon">{{ "Export CSV File"|t }}</a>
        </div>
        <a href="{{ actionUrl('retour/statistics/clear-statistics') }}" class="btn delete icon">{{ "Clear Stats"|t }}</a>
    </div>
{% endblock %}

{% block content %}
    <div id="cp-nav-content">
        <div class="field readable">
            {% if showWelcome %}
                <confetti-party />
                </confetti-party>
                <div class="readable" style="text-align:center; margin:0 auto; padding: 5% 10%;">
                    <img src="{{ baseAssetsUrl ~ '/img/Retour-icon.svg' }}"
                         width="30%" height="auto"/>
                    <h2>Thanks for using Retour!</h2>
                    <p>
                        Retour allows you to intelligently redirect legacy URLs, so that you don't lose SEO value when rebuilding & restructuring a website.
                    </p>
                    <p>
                        Retour was entirely rewritten for Craft CMS 3, and was designed to be performant.
                    </p>
                    <p>We hope you love it! For more information, please <a href="{{ docsUrl }}" target="_blank" rel="noopener">see the documentation</a>.</p>
                </div>
            {% endif %}
        </div>
        <div class="flex overflow-hidden w-full flex-no-wrap">
            <div class="flex-grow">
                <div class="shadow">
                    <dashboard-chart
                            title="404s by Month"
                            sub-title="Discrete 404 URI hits in the last month"
                            range="month"
                            :refresh-interval-secs="{{ settings.refreshIntervalSecs ?? 5 }}"
                            :site-id="{{ currentSiteId }}"
                            :api-url="'{{ actionUrl('retour/charts/dashboard') }}'"
                    >
                    </dashboard-chart>
                </div>
            </div>
            <div class="flex-grow">
                <div class="shadow">
                    <dashboard-chart
                            title="404s by Week"
                            sub-title="Discrete 404 URI hits in the last week"
                            range="week"
                            :refresh-interval-secs="{{ settings.refreshIntervalSecs ?? 5 }}"
                            :site-id="{{ currentSiteId }}"
                            :api-url="'{{ actionUrl('retour/charts/dashboard') }}'"
                    >
                    </dashboard-chart>
                </div>
            </div>
            <div class="flex-grow">
                <div class="shadow">
                    <dashboard-chart
                            title="404s by Day"
                            sub-title="Discrete 404 URI hits in the last day"
                            range="day"
                            :refresh-interval-secs="{{ settings.refreshIntervalSecs ?? 5 }}"
                            :site-id="{{ currentSiteId }}"
                            :api-url="'{{ actionUrl('retour/charts/dashboard') }}'"
                    >
                    </dashboard-chart>
                </div>
            </div>
        </div>
        <dashboard-table
                :refresh-interval-secs="{{ settings.refreshIntervalSecs ?? 5 }}"
                :site-id="{{ currentSiteId }}"
                :api-url="'{{ actionUrl('retour/tables/dashboard') }}'"
        >
        </dashboard-table>

    </div>
{% endblock %}

{% block foot %}
    {# include our JavaScript modules #}
    {{ parent() }}
    {% set tagOptions = {
        'depends': [
            'nystudio107\\retour\\assetbundles\\retour\\RetourAsset'
        ],
    } %}
    {{ craft.retour.register('src/js/Dashboard.js', false, tagOptions, tagOptions) }}
{% endblock %}
