Files
komp_ac/web/templates/pages/admin/ecb/workspace.html
2026-08-24 10:44:56 +02:00

155 lines
9.0 KiB
HTML

{% extends "ui/base.html" %}
{% import "ui/alert.html" as alert %}
{% import "ui/toast.html" as toast %}
{% block title %}{{ nav.tr("rates-title") }}{% endblock %}
{% block content %}
<main>
<section class="heading">
<div>
<p class="eyebrow">{{ nav.tr("rates-eyebrow") }}</p>
<h1>{{ nav.tr("rates-title") }}</h1>
<p>{{ nav.tr("rates-description") }}</p>
</div>
<div class="actions"><a href="/admin">{{ nav.tr("ui-back-to-admin-panel") }}</a></div>
</section>
{%- if let Some(message) = page.status %}{% call toast::success(nav.tr("rates-updated"), message) %}{% endcall %}{% endif -%}
{%- if let Some(message) = page.error %}{% call alert::error(nav.locale, nav.tr("rates-could-not-continue"), message) %}{% endcall %}{% endif -%}
<nav class="tabs" aria-label="{{ nav.tr("rates-sections") }}">
<a class="tab" href="#configuration"><span>{{ nav.tr("rates-tab-configuration") }}</span><small>{{ nav.tr("rates-tab-configuration-sub") }}</small></a>
<a class="tab" href="#evidence"><span>{{ nav.tr("rates-tab-evidence") }}</span><small>{{ nav.tr("rates-tab-evidence-sub") }}</small></a>
<a class="tab" href="#providers"><span>{{ nav.tr("rates-tab-providers") }}</span><small>{{ nav.tr("rates-tab-providers-sub") }}</small></a>
</nav>
<section class="panel" id="configuration">
<h2>{{ nav.tr("rates-profile-configuration") }}</h2>
{% if page.profiles.is_empty() %}
<p class="hint">{{ nav.tr("rates-no-profiles") }}</p>
{% else %}
<form method="get" action="/admin/exchange-rates" class="form-grid">
<label>{{ nav.tr("rates-profile") }}
<select name="profile" onchange="this.form.submit()">
{% for profile in page.profiles %}
<option value="{{ profile }}" {% if page.is_selected_profile(profile) %}selected{% endif %}>{{ profile }}</option>
{% endfor %}
</select>
</label>
</form>
{% if let Some(settings) = page.settings %}
<dl class="status-grid">
<div><dt>{{ nav.tr("rates-accounting-currency") }}</dt><dd><strong>{{ settings.accounting_currency }}</strong> · {{ nav.tr("rates-immutable") }}</dd></div>
<div><dt>{{ nav.tr("rates-configured-currencies") }}</dt><dd>{{ settings.foreign_currencies.len() }}</dd></div>
<div><dt>{{ nav.tr("rates-registered-providers") }}</dt><dd>{% if page.providers.is_empty() %}—{% else %}{{ page.providers|join(", ") }}{% endif %}</dd></div>
</dl>
{% if settings.foreign_currencies.is_empty() %}
<p class="hint">{{ nav.tr("rates-no-foreign-currencies") }}</p>
{% else %}
<div class="table-scroll">
<table class="builder-table">
<thead><tr><th>{{ nav.tr("rates-foreign-currency") }}</th><th>{{ nav.tr("rates-default-provider") }}</th><th>{{ nav.tr("rates-providers") }}</th><th>{{ nav.tr("rates-coverage") }}</th><th></th></tr></thead>
<tbody>
{% for currency in settings.foreign_currencies %}
<tr>
<td><strong>{{ currency.currency }}</strong></td>
<td><span class="tag">{{ currency.default_source_id }}</span></td>
<td>{% for source in currency.sources %}<span class="tag">{{ source.source_id }}</span> {% endfor %}</td>
<td>
{% for source in currency.sources %}
<div>
<span class="tag {{ source.coverage_class() }}">{% if source.coverage_complete %}{{ nav.tr("rates-ready") }}{% else %}{{ nav.tr("rates-importing") }}{% endif %}</span>
<span class="hint">{{ source.source_id }}{% if let Some(from) = source.verified_from_date %} · {{ from }}{% endif %}{% if let Some(through) = source.verified_through_date %} → {{ through }}{% endif %}</span>
</div>
{% endfor %}
</td>
<td>
{% if page.can_configure %}
{% for source in currency.sources %}
{% if source.source_id != currency.default_source_id %}
<form method="post" action="/admin/exchange-rates/configuration">
<input type="hidden" name="profile" value="{{ page.selected_profile }}">
<input type="hidden" name="currency" value="{{ currency.currency }}">
<input type="hidden" name="source_id" value="{{ source.source_id }}">
<input type="hidden" name="make_default" value="true">
<button type="submit" class="secondary">{{ nav.tr("rates-make-default") }}</button>
</form>
{% endif %}
{% endfor %}
{% endif %}
</td>
</tr>
{% endfor %}
</tbody>
</table>
</div>
{% endif %}
{% if page.can_configure %}
<h3>{{ nav.tr("rates-add-binding") }}</h3>
<p class="hint">{{ nav.tr("rates-append-only-hint") }}</p>
<form method="post" action="/admin/exchange-rates/configuration">
<input type="hidden" name="profile" value="{{ page.selected_profile }}">
<div class="form-grid">
<label>{{ nav.tr("rates-foreign-currency") }}
<input name="currency" value="{{ page.configuration.currency }}" list="currency-codes" maxlength="3" placeholder="CZK" required>
</label>
<label>{{ nav.tr("rates-provider") }}
<select name="source_id" required>
<option value="">{{ nav.tr("rates-choose-provider") }}</option>
{% for provider in page.providers %}<option value="{{ provider }}" {% if page.configuration.source_id == *provider %}selected{% endif %}>{{ provider }}</option>{% endfor %}
</select>
</label>
{% if page.providers.len() > 1 %}
<label class="check"><input type="checkbox" name="make_default" value="true" {% if page.configuration.make_default %}checked{% endif %}>{{ nav.tr("rates-make-default-now") }}</label>
{% endif %}
</div>
<div class="form-actions"><button type="submit">{{ nav.tr("rates-add-binding") }}</button></div>
</form>
{% endif %}
{% endif %}
{% endif %}
</section>
<section class="panel" id="evidence">
<h2>{{ nav.tr("rates-evidence-lookup") }}</h2>
<p class="hint">{{ nav.tr("rates-evidence-hint") }}</p>
<form method="post" action="/admin/exchange-rates/evidence">
<input type="hidden" name="profile" value="{{ page.selected_profile }}">
<div class="form-grid">
<label>{{ nav.tr("rates-table") }}<input name="table_name" value="{{ page.evidence_form.table_name }}" required></label>
<label>{{ nav.tr("rates-record-id") }}<input name="record_id" value="{{ page.evidence_form.record_id }}" inputmode="numeric" required></label>
<label>{{ nav.tr("rates-column") }}<input name="column_name" value="{{ page.evidence_form.column_name }}" required></label>
</div>
<div class="form-actions"><button type="submit">{{ nav.tr("rates-find-evidence") }}</button></div>
</form>
{% if let Some(has_exchange) = page.evidence_has_exchange %}
{% if !has_exchange %}<p class="hint">{{ nav.tr("rates-no-exchange") }}</p>
{% else if page.evidence.is_empty() %}<p class="hint">{{ nav.tr("rates-no-evidence") }}</p>
{% else %}
<div class="table-scroll"><table class="builder-table">
<thead><tr><th>#</th><th>{{ nav.tr("rates-revision") }}</th><th>{{ nav.tr("rates-conversion") }}</th><th>{{ nav.tr("rates-provider") }}</th><th>{{ nav.tr("rates-rate-date") }}</th><th>{{ nav.tr("rates-created") }}</th><th>{{ nav.tr("rates-reason") }}</th></tr></thead>
<tbody>{% for item in page.evidence %}<tr>
<td>{{ item.evidence.evidence_id }}</td><td>{{ item.evidence.row_revision }}</td>
<td>{{ item.evidence.original_amount }} {{ item.evidence.original_currency }} → {{ item.evidence.converted_amount }} {{ item.evidence.accounting_currency }}</td>
<td>{{ item.evidence.source_id }}</td><td>{{ item.evidence.rate_date.as_deref().unwrap_or("—") }}</td><td>{{ item.evidence.evidence_created_at }}</td><td>{{ item.evidence.selection_reason }}</td>
</tr>{% endfor %}</tbody>
</table></div>
{% if page.evidence_has_more %}<p class="hint">{{ nav.tr("rates-more-evidence") }}</p>{% endif %}
{% endif %}
{% endif %}
</section>
<section id="providers">
<div class="heading"><div><h2>{{ nav.tr("rates-provider-health") }}</h2><p>{{ nav.tr("rates-provider-health-hint") }}</p></div></div>
{{ provider_status|safe }}
{{ provider_attempts|safe }}
</section>
<datalist id="currency-codes">{% for code in currency_codes %}<option value="{{ code }}"></option>{% endfor %}</datalist>
</main>
{% endblock %}