studioespresso/craft-exporter

View on GitHub
src/templates/sprig/queue.twig

Summary

Maintainability
Test Coverage
{% set export = exportId ? craft.exports.id(exportId).one() : create('studioespresso\\exporter\\elements\\ExportElement') %}

{# Refreshes the component every 5 seconds #}
{% set timezone = timezone ?? 'Europe/Brussels' %}

<div sprig s-trigger="every 5s" class="pulse">
    {% set isRunning = craft.exporter.listenForJob(export) %}
    {% if isRunning %}
        <h2>{{ "⏳Your export running, stay tuned"|t("exporter") }}</h2>
        <p>
            Depending on number of entries in your export, this could take a while...
        </p>
    {% else %}
        <h2>{{ "✅ Done!"|t("exporter") }}</h2>
        {{ "Your export has finished and has sent by e-mail." }}
{#        <div>#}
{#            Done! Click the button below to download your export!#}
{#            <form method="post">#}
{#                {{ csrfInput() }}#}
{#                {{ actionInput('exporter/element/get-download') }}#}
{#                {{ hiddenInput('exportId', export.id) }}#}
{#                {{ hiddenInput('fileName', craft.app.request.getQueryParam('fileName')) }}#}
{#                <button type="submit" class="btn submit">{{ 'Download file' }}</button>#}
{#            </form>#}
{#        </div>#}
    {% endif %}
    <hr>
    {{ "View last updated at:"|t("exporter") }} {{ now|time('long', timezone=timezone) }}
</div>