2026-04-29 17:49:07 +03:00
{% extends "admin/layout.html" %}
{% let active_page = "media" %}
{% block title %}{{ t.media_title }}{% endblock %}
{% block content %}
< div class = "page-head" >
< h1 > {{ t.media_title }}</ h1 >
</ div >
<!-- Client filter -->
< div style = "margin-bottom:1rem;" >
< div class = "select is-small" >
< select onchange = "window.location.href='/admin/media?lang={{ lang.code() }}' + (this.value ? '&client_id=' + this.value : '')" >
< option value = "" > {{ t.media_all_clients }}</ option >
{% for c in & clients %}
< option value = "{{ c.id }}" {% if c . id . unwrap () == filter_client_id %} selected {% endif %} > {{ c.name }}</ option >
{% endfor %}
</ select >
</ div >
</ div >
{% if items.is_empty() %}
< p class = "has-text-grey" > {{ t.media_empty }}</ p >
{% else %}
< div class = "media-grid" >
{% for item in & items %}
< div class = "media-card" >
{% if item.media.file_type == "photo" %}
2026-08-09 00:15:40 +01:00
< a href = "{{ item.media.url }}" data-lightbox = "photo" >
2026-08-09 01:05:47 +01:00
< span class = "photo-thumb media-loading-frame is-loading" >
< img src = "{{ item.media.thumbnail_url }}" alt = "" loading = "lazy" data-media-load >
</ span >
2026-04-29 17:49:07 +03:00
</ a >
{% else %}
2026-08-09 00:15:40 +01:00
< a href = "{{ item.media.url }}" data-lightbox = "video" >
2026-08-09 01:05:47 +01:00
< div class = "video-thumb media-loading-frame{% if !item.media.thumbnail_url.is_empty() %} is-loading{% endif %}" data-video-preview >
{% if !item.media.thumbnail_url.is_empty() %}
< img class = "video-preview-sprite" src = "{{ item.media.thumbnail_url }}" alt = "" loading = "lazy" data-media-load data-preview-frames = "4" >
{% endif %}
2026-08-08 10:19:47 +01:00
< span class = "video-play" > ▶</ span >
</ div >
2026-04-29 17:49:07 +03:00
</ a >
{% endif %}
< div class = "media-info" >
< div class = "media-meta" >
< strong > {{ item.client_name }}</ strong >
{% if let Some(d) = item.visit_date.as_deref() %}
< span style = "color:#999;" > {{ d }}</ span >
{% endif %}
</ div >
{% if let Some(cap) = item.media.caption.as_deref() %}
< div style = "font-size:0.82rem;color:#666;margin-top:0.2rem;" > {{ cap }}</ div >
{% endif %}
2026-07-11 15:20:21 +03:00
< form method = "post" action = "/admin/media/{{ item.media.id.unwrap() }}/delete" onsubmit = "return confirm('{{ t.media_delete_confirm }}');" style = "margin-top:0.3rem;" >
2026-04-29 17:49:07 +03:00
< button class = "button is-small is-danger is-outlined btn-sm" > {{ t.media_delete }}</ button >
</ form >
</ div >
</ div >
{% endfor %}
</ div >
2026-08-08 11:45:29 +01:00
{% if total_pages > 1 %}
< nav class = "media-pagination" aria-label = "Pagination" >
{% if page > 1 %}
< a class = "button is-small" href = "/admin/media?lang={{ lang.code() }}&page={{ page - 1 }}{% if filter_client_id > 0 %}&client_id={{ filter_client_id }}{% endif %}" > ←</ a >
{% endif %}
{% for p in 1..=total_pages %}
< a class = "button is-small{% if p == page %} is-link{% endif %}" href = "/admin/media?lang={{ lang.code() }}&page={{ p }}{% if filter_client_id > 0 %}&client_id={{ filter_client_id }}{% endif %}" > {{ p }}</ a >
{% endfor %}
{% if page < total_pages %}
< a class = "button is-small" href = "/admin/media?lang={{ lang.code() }}&page={{ page + 1 }}{% if filter_client_id > 0 %}&client_id={{ filter_client_id }}{% endif %}" > →</ a >
{% endif %}
</ nav >
{% endif %}
2026-04-29 17:49:07 +03:00
{% endif %}
< style >
. media-grid {
display : grid ;
grid-template-columns : repeat ( auto - fill , minmax ( 200 px , 1 fr ));
gap : 0.75 rem ;
}
. media-card {
background : #fff ;
border-radius : 10 px ;
border : 1 px solid #eee ;
overflow : hidden ;
}
. media-card img {
width : 100 % ;
height : 160 px ;
object-fit : cover ;
display : block ;
}
2026-08-09 01:05:47 +01:00
. media-card . photo-thumb {
width : 100 % ;
height : 160 px ;
}
2026-04-29 17:49:07 +03:00
. media-card . video-thumb {
2026-08-08 10:19:47 +01:00
position : relative ;
2026-04-29 17:49:07 +03:00
width : 100 % ;
height : 160 px ;
2026-08-08 10:19:47 +01:00
background : #111 ;
}
. media-card . video-play {
position : absolute ;
top : 50 % ;
left : 50 % ;
transform : translate ( -50 % , -50 % );
color : white ;
font-size : 2.5 rem ;
line-height : 1 ;
text-shadow : 0 1 px 5 px #000 ;
pointer-events : none ;
2026-04-29 17:49:07 +03:00
}
. media-info {
padding : 0.6 rem 0.75 rem ;
}
2026-08-08 11:45:29 +01:00
. media-pagination {
display : flex ;
flex-wrap : wrap ;
justify-content : center ;
gap : 0.35 rem ;
margin-top : 1.25 rem ;
}
2026-04-29 17:49:07 +03:00
. media-meta {
display : flex ;
justify-content : space-between ;
align-items : center ;
font-size : 0.85 rem ;
2026-05-11 13:25:19 +01:00
color : #333 ;
2026-04-29 17:49:07 +03:00
}
@ media ( max-width : 480px ) {
. media-grid {
grid-template-columns : repeat ( auto - fill , minmax ( 150 px , 1 fr ));
}
2026-08-09 01:05:47 +01:00
. media-card img , . media-card . photo-thumb , . media-card . video-thumb {
2026-04-29 17:49:07 +03:00
height : 120 px ;
}
}
</ style >
{% endblock %}