<commit_before>{% extends "_layouts/cp" %}

{% set title = "Import"|t %}

{% set tabs = {
    overview: { label: "Import history"|t, url: url('import') },
    upload: { label: "Upload file"|t, url: url('import/upload') },
    map:    { label: "Map fields"|t, url: '', class: 'disabled' }
} %}

{% set selectedTab = 'overview' %}

{% if craft.request.getParam('task') %}

    {% set javascript %}
    $(function() {
        setTimeout(function() {
            if(!$('#taskicon').length) {
                window.location.reload();
            } else {
                $('#taskicon').trigger('click');
                var taskCheck = setInterval(function() {
                    if((Craft.cp.runningTaskInfo && Craft.cp.runningTaskInfo.id != {{ craft.request.getParam('task') }}) || Craft.cp.runningTaskInfo === null) {
                        clearInterval(taskCheck);
                        window.location.href = 'import';
                    }
                }, 500);
            }
        }, 500);
    });
    {% endset %}
    
    {% includeJs javascript %}

{% endif %}

{% set content %}
    
    <table class="data fullwidth" id="history">
        <thead>
            <tr>
                <th scope="col" data-attribute="date">{{ "Filename"|t }}</th>
                <th scope="col" data-attribute="behavior">{{ "Import behavior"|t }}</th>
                <th scope="col" data-attribute="rows">{{ "Rows"|t }}</th>
                <th scope="col" data-attribute="started">{{ "Started"|t }}</th>
                <th scope="col" data-attribute="finished">{{ "Finished"|t }}</th>
                <th scope="col" data-attribute="totaltime">{{ "Total time"|t }}</th>
                <th scope="col" data-attribute="user">{{ "User"|t }}</th>
                <th scope="col" data-attribute="revert">{{ "Revert"|t }}</th>
            </tr>
        </thead>
        <tbody>
        {% for item in craft.import.history %}
            <tr>
                <td scope="row" data-title="{{ 'Filename'|t }}">
                    <div class="element" data-id="{{ item.id }}" data-status="{% if item.status == 'started' %}pending{% elseif item.status == 'reverted' %}archived{% else %}live{% endif %}" data-label="{{ item.file }}">
                        <div class="label">
                            <span class="status {% if item.status == 'started' %}pending{% elseif item.status == 'reverted' %}archived{% else %}live{% endif %}"></span>
                            <span class="title">
                            {% if item.status != 'started' %}
                                <a href="import/{{ item.id }}">{{ item.file }}</a>
                            {% else %}
                                {{ item.file }}
                            {% endif %}
                            </span>
                        </div>
                    </div>                
                </td>
                <td data-title="{{ 'Import behavior'|t }}">
                {% switch item.behavior %}
                    {% case 'append' %}
                        {{ "Append data"|t }}
                    {% case 'replace' %}
                        {{ "Replace data"|t }}
                    {% case 'delete' %}
                        {{ "Delete data"|t }}
                {% endswitch %}
                </td>
                <td data-title="{{ 'Rows'|t }}">{{ item.rows }}</td>
                <td data-title="{{ 'Started'|t }}">{{ item.dateCreated | datetime }}</td>
                <td data-title="{{ 'Finished'|t }}">{% if item.status != 'started' %}{{ item.dateUpdated | datetime }}{% endif %}</td>
                <td data-title="{{ 'Total time'|t }}">{% if item.status != 'started' %}{{ item.dateCreated.diff(item.dateUpdated).humanDuration() }}{% endif %}</td>
                <td data-title="{{ 'User'|t }}">
                    <a href="users/{{ item.user.id }}" class="go">{{ item.user.username }}</a>
                </td>
                <td data-title="{{ 'Revert'|t }}">
                    {% if item.status == 'finished' %}<a href="{{ actionUrl('import/history/revert', { id: item.id }) }}" class="btn small" onclick="return confirm('{{ "Are you sure you want to revert the imported entries to the previous version?"|t }}')">{{ 'Revert'|t }}</a>{% endif %}
                </td>
            </tr>
        {% endfor %}
        </tbody>
    </table>
    
{% endset %}<commit_msg>Only entry imports can be reverted, as Users don't have revisions<commit_after>{% extends "_layouts/cp" %}

{% set title = "Import"|t %}

{% set tabs = {
    overview: { label: "Import history"|t, url: url('import') },
    upload: { label: "Upload file"|t, url: url('import/upload') },
    map:    { label: "Map fields"|t, url: '', class: 'disabled' }
} %}

{% set selectedTab = 'overview' %}

{% if craft.request.getParam('task') %}

    {% set javascript %}
    $(function() {
        setTimeout(function() {
            if(!$('#taskicon').length) {
                window.location.reload();
            } else {
                $('#taskicon').trigger('click');
                var taskCheck = setInterval(function() {
                    if((Craft.cp.runningTaskInfo && Craft.cp.runningTaskInfo.id != {{ craft.request.getParam('task') }}) || Craft.cp.runningTaskInfo === null) {
                        clearInterval(taskCheck);
                        window.location.href = 'import';
                    }
                }, 500);
            }
        }, 500);
    });
    {% endset %}
    
    {% includeJs javascript %}

{% endif %}

{% set content %}
    
    <table class="data fullwidth" id="history">
        <thead>
            <tr>
                <th scope="col" data-attribute="date">{{ "Filename"|t }}</th>
                <th scope="col" data-attribute="behavior">{{ "Import behavior"|t }}</th>
                <th scope="col" data-attribute="rows">{{ "Rows"|t }}</th>
                <th scope="col" data-attribute="started">{{ "Started"|t }}</th>
                <th scope="col" data-attribute="finished">{{ "Finished"|t }}</th>
                <th scope="col" data-attribute="totaltime">{{ "Total time"|t }}</th>
                <th scope="col" data-attribute="user">{{ "User"|t }}</th>
                <th scope="col" data-attribute="revert">{{ "Revert"|t }}</th>
            </tr>
        </thead>
        <tbody>
        {% for item in craft.import.history %}
            <tr>
                <td scope="row" data-title="{{ 'Filename'|t }}">
                    <div class="element" data-id="{{ item.id }}" data-status="{% if item.status == 'started' %}pending{% elseif item.status == 'reverted' %}archived{% else %}live{% endif %}" data-label="{{ item.file }}">
                        <div class="label">
                            <span class="status {% if item.status == 'started' %}pending{% elseif item.status == 'reverted' %}archived{% else %}live{% endif %}"></span>
                            <span class="title">
                            {% if item.status != 'started' %}
                                <a href="import/{{ item.id }}">{{ item.file }}</a>
                            {% else %}
                                {{ item.file }}
                            {% endif %}
                            </span>
                        </div>
                    </div>                
                </td>
                <td data-title="{{ 'Import behavior'|t }}">
                {% switch item.behavior %}
                    {% case 'append' %}
                        {{ "Append data"|t }}
                    {% case 'replace' %}
                        {{ "Replace data"|t }}
                    {% case 'delete' %}
                        {{ "Delete data"|t }}
                {% endswitch %}
                </td>
                <td data-title="{{ 'Rows'|t }}">{{ item.rows }}</td>
                <td data-title="{{ 'Started'|t }}">{{ item.dateCreated | datetime }}</td>
                <td data-title="{{ 'Finished'|t }}">{% if item.status != 'started' %}{{ item.dateUpdated | datetime }}{% endif %}</td>
                <td data-title="{{ 'Total time'|t }}">{% if item.status != 'started' %}{{ item.dateCreated.diff(item.dateUpdated).humanDuration() }}{% endif %}</td>
                <td data-title="{{ 'User'|t }}">
                    <a href="users/{{ item.user.id }}" class="go">{{ item.user.username }}</a>
                </td>
                <td data-title="{{ 'Revert'|t }}">
                    {% if item.status == 'finished' and item.elementtype == 'Entry' %}<a href="{{ actionUrl('import/history/revert', { id: item.id }) }}" class="btn small" onclick="return confirm('{{ "Are you sure you want to revert the imported entries to the previous version?"|t }}')">{{ 'Revert'|t }}</a>{% endif %}
                </td>
            </tr>
        {% endfor %}
        </tbody>
    </table>
    
{% endset %}
{'fraction_non_alphanumeric': 0.19618682310469315, 'fraction_numerical': 0.0013537906137184115, 'mean_word_length': 1.5860560093348892, 'pattern_counts': {'":': 0, '<': 115, '<?xml version=': 0, '>': 115, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 4, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7018085', 'n_tokens_mistral': 2694, 'n_tokens_neox': 2398, 'n_words': 551}