{# Журналы: задания по кластеру, развёртывание (provision_log), Helm (helm_addon_log).
   Переключатель режима — как «Простой / Расширенный» на странице редактирования кластера.
   Автор: Сергей Антропов — https://devops.org.ru #}
{% extends "base.html" %}

{% block page_title %}Журнал{% endblock %}

{% block body_extra_class %} journal-page-loading{% endblock %}

{% block body_attrs %}data-dashboard-mode="journal"{% endblock %}

{% block footer %}
<div class="footer-inner">
  <p class="footer-copyright">
    © {{ app_title }} ·
    <a href="https://devops.org.ru" target="_blank" rel="noopener">devops.org.ru</a>
  </p>
</div>
{% endblock %}

{% block content %}
<div
  id="journal-page-loading-overlay"
  class="page-loading-overlay"
  role="status"
  aria-live="polite"
  aria-busy="true"
  aria-label="Загрузка журнала"
>
  <div class="page-loading-backdrop" aria-hidden="true"></div>
  <div class="page-loading-center">
    <span class="spinner page-loading-spinner" aria-hidden="true"></span>
    <span class="page-loading-label">Загрузка журнала…</span>
  </div>
</div>

<section class="card hero-panel cluster-create-hero" aria-labelledby="journal-hero-title">
  <h1 class="page-title" id="journal-hero-title">Журналы</h1>
</section>

<section class="card create-cluster-card journal-toolbar-card">
  <h2 class="create-cluster-card__title">Вид журнала</h2>

  <fieldset class="cluster-edit-mode-fieldset journal-view-fieldset">
    <legend class="cluster-edit-mode-legend">Режим просмотра</legend>
    <div
      class="cluster-edit-segmented"
      role="radiogroup"
      aria-label="Какой журнал показывать"
    >
      <div class="cluster-edit-segment-item">
        <input
          type="radio"
          name="journal_view"
          id="journal-seg-per-cluster"
          class="cluster-edit-segment-native"
          value="per_cluster"
          checked
        />
        <label for="journal-seg-per-cluster" class="cluster-edit-segment-label">
          <span class="cluster-edit-segment-title">По кластеру</span>
          <span class="cluster-edit-segment-sub-wrap">
            <span class="cluster-edit-segment-sub">История заданий</span>
            <span class="cluster-edit-segment-sub">create / start / stop</span>
          </span>
        </label>
      </div>
      <div class="cluster-edit-segment-item">
        <input
          type="radio"
          name="journal_view"
          id="journal-seg-provision"
          class="cluster-edit-segment-native"
          value="provision"
        />
        <label for="journal-seg-provision" class="cluster-edit-segment-label">
          <span class="cluster-edit-segment-title">Развёртывание</span>
          <span class="cluster-edit-segment-sub-wrap">
            <span class="cluster-edit-segment-sub">Последний provision_log</span>
            <span class="cluster-edit-segment-sub">по каждому кластеру</span>
          </span>
        </label>
      </div>
      <div class="cluster-edit-segment-item">
        <input
          type="radio"
          name="journal_view"
          id="journal-seg-helm"
          class="cluster-edit-segment-native"
          value="helm_addons"
        />
        <label for="journal-seg-helm" class="cluster-edit-segment-label">
          <span class="cluster-edit-segment-title">Helm-аддоны</span>
          <span class="cluster-edit-segment-sub-wrap">
            <span class="cluster-edit-segment-sub">История операций Helm</span>
            <span class="cluster-edit-segment-sub">install / delete</span>
          </span>
        </label>
      </div>
    </div>
  </fieldset>

  <div id="journal-cluster-picker" class="journal-cluster-picker">
    <label for="journal-cluster-select" class="journal-cluster-picker-label">Кластер</label>
    <select id="journal-cluster-select" class="journal-cluster-select" aria-describedby="journal-cluster-picker-hint">
      <option value="">— загрузка —</option>
    </select>
    <p id="journal-cluster-picker-hint" class="muted journal-cluster-picker-hint">
      Журнал заданий только для выбранного каталога в <code>clusters/</code>.
    </p>
  </div>

  <div class="journal-toolbar-actions">
    <button type="button" class="btn-secondary" id="journal-refresh-btn">Обновить</button>
  </div>
  <p id="journal-status" class="muted journal-status" role="status" aria-live="polite"></p>
</section>

<section class="card journal-list-card">
  <h2 class="create-cluster-card__title" id="journal-table-section-title">Записи</h2>
  <div id="journal-empty" class="muted journal-empty hidden">Нет записей.</div>
  <div id="journal-table-wrap" class="journal-table-wrap">
    <table class="journal-table" id="journal-table" aria-describedby="journal-hero-title">
      <thead>
        <tr>
          <th scope="col">Завершено (UTC)</th>
          <th scope="col">Кластер</th>
          <th scope="col" id="journal-th-kind">Тип / операция</th>
          <th scope="col">Статус</th>
          <th scope="col">Сообщение</th>
          <th scope="col">Лог</th>
        </tr>
      </thead>
      <tbody id="journal-tbody"></tbody>
    </table>
  </div>
  <nav
    id="journal-pagination"
    class="journal-pagination hidden"
    aria-label="Страницы журнала"
    role="navigation"
  ></nav>
</section>
{% endblock %}

{% block scripts %}
<script src="/static/js/journal.js" defer></script>
{% endblock %}
