MediaDash/templates/index.html

123 lines
4.9 KiB
HTML

{% extends "base.html" %}
{% macro make_row(title,items) %}
<div class="d-flex flex-wrap">
{% for item in items %}
{{item|safe}}
{% endfor %}
</div>
{% endmacro %}
{% macro make_tabs(tabs) %}
<div class="row">
<div class="col">
<ul class="nav nav-pills mb-3" id="pills-tab" role="tablist">
{% for (label,_) in tabs %}
{% set slug = (label|slugify) %}
{% if not (loop.first and loop.last) %}
<li class="nav-item">
<a class="nav-link {{'active' if loop.first}}" id="nav-{{slug}}-tab" data-toggle="pill" href="#pills-{{slug}}" role="tab" aria-controls="pills-{{slug}}" aria-selected="{{loop.first}}">
{{label}}
</a>
</li>
{% endif %}
{% endfor %}
</ul>
</div>
</div>
<div class="tab-content" id="searchResults">
{% for (label,items) in tabs %}
{% set slug = (label|slugify) %}
<div class="tab-pane fade {{'show active' if loop.first}}" id="pills-{{slug}}" role="tabpanel" aria-labelledby="nav-{{slug}}-tab">
{{make_row(label,items)}}
</div>
{% endfor %}
</div>
{% endmacro %}
{% macro upcoming(data) %}
<div class="container">
<div class="row">
<div class="col-lg">
<h3>Movies</h3>
<table class="table table-sm">
<tr>
<th>Title</th>
<th>In Cinemas</th>
<th>Digital Release</th>
</tr>
{% for movie in data.calendar.movies %}
{% if movie.isAvailable and movie.hasFile %}
{% set row_class = "bg-success" %}
{% elif movie.isAvailable and not movie.hasFile %}
{% set row_class = "bg-danger" %}
{% elif not movie.isAvailable and movie.hasFile %}
{% set row_class = "bg-primary" %}
{% elif not movie.isAvailable and not movie.hasFile %}
{% set row_class = "bg-info" %}
{% endif %}
<tr class={{row_class}}>
<td>
<a href="{{urljoin(config.APP_CONFIG.radarr_url,'movie/'+movie.titleSlug)}}" style="color: #eee; text-decoration: underline;">
{{movie.title}}
</a>
</td>
<td>{{movie.inCinemas|fromiso|ago_dt_utc_human(rnd=0)}}</td>
<td>{{movie.digitalRelease|fromiso|ago_dt_utc_human(rnd=0)}}</td>
</tr>
{% endfor %}
</table>
<h3>Episodes</h3>
<table class="table table-sm">
<tr>
<th>Season | Episode Number</th>
<th>Show</th>
<th>Title</th>
<th>Air Date</th>
</tr>
{% for entry in data.calendar.episodes %}
{% if entry.episode.hasAired and entry.episode.hasFile %}
{% set row_class = "bg-success" %}
{% elif entry.episode.hasAired and not entry.episode.hasFile %}
{% set row_class = "bg-danger" %}
{% elif not entry.episode.hasAired and entry.episode.hasFile %}
{% set row_class = "bg-primary" %}
{% elif not entry.episode.hasAired and not entry.episode.hasFile %}
{% set row_class = "bg-info" %}
{% endif %}
<tr class={{row_class}}>
<td>{{entry.episode.seasonNumber}} | {{entry.episode.episodeNumber}}</td>
<td>
<a href="{{urljoin(config.APP_CONFIG.sonarr_url,'series/'+entry.series.titleSlug)}}" style="color: #eee; text-decoration: underline;">
{{entry.series.title}}
</a>
</td>
<td>{{entry.episode.title}}</td>
<td>{{entry.episode.airDateUtc|fromiso|ago_dt_utc_human(rnd=0)}}</td>
</tr>
{% endfor %}
</table>
</div>
</div>
</div>
{% endmacro %}
{% block app_content %}
{% if data is none %}
<h2>No Data available!</h2>
{% else %}
{% set tabs = [] %}
{% do tabs.append(("Upcoming",[upcoming(data)])) %}
{% for row in data.images %}
{% if row[0] is string %}
{% set title=row[0] %}
{% set row=row[1:] %}
{% do tabs.append((title,row)) %}
{% endif %}
{% endfor %}
{{make_tabs(tabs)}}
{% endif %}
{% endblock %}