Files
torsearch/templates/broadcast/Download.stream.html.twig

47 lines
1.7 KiB
Twig

{# Learn how to use Turbo Streams: https://github.com/symfony/ux-turbo#broadcast-doctrine-entities-update #}
{% block create %}
<turbo-stream action="remove" target="active_downloads_no_downloads">
</turbo-stream>
<turbo-stream action="append" target="active_downloads">
<template>
<twig:DownloadListRow download="{{ entity }}" isBroadcasted="true" />
</template>
</turbo-stream>
{% endblock %}
{% block update %}
{% if entity.status != "Complete" %}
<turbo-stream action="update" target="download_progress_{{ id }}">
<template>
<div class="text-green-700 rounded-sm text-bold text-gray-950 text-center bg-green-600 h-5"
style="width:{{ entity.progress }}%">
<span>{{ entity.progress }}%</span>
</div>
</template>
</turbo-stream>
{% else %}
<turbo-stream action="remove" target="complete_downloads_no_downloads">
</turbo-stream>
<turbo-stream action="remove" target="ad_download_{{ id }}">
</turbo-stream>
<turbo-stream action="prepend" target="alert_list">
<template>
<twig:Alert title="Finished downloading" message="{{ entity.title }}" alert_id="{{ entity.id }}" data-controller="alert" />
</template>
</turbo-stream>
<turbo-stream action="prepend" target="complete_downloads">
<template>
<twig:DownloadListRow download="{{ entity }}" :isBroadcasted="true" />
</template>
</turbo-stream>
{% endif %}
{% endblock %}
{% block remove %}
<turbo-stream action="remove" target="ad_download_{{ id }}"></turbo-stream>
{% endblock %}