<!DOCTYPE HTML>
<html xmlns:th="http://www.thymeleaf.org"
      xmlns:layout="http://www.w3.org/1999/xhtml"
      layout:decorate="~{layouts/main-layout}">
<head>
    <title>Спутники</title>
    <link rel="stylesheet" href="/css/catalog.css"/>
</head>
<body>
<th:block layout:fragment="content">
    <div id="catalog-page" data-page="satellites" class="catalog-page py-3">
        <div class="d-flex justify-content-between align-items-start flex-wrap gap-3 mb-4">
            <div>
                <h2 class="mb-1">Спутники</h2>
                <div class="catalog-helper">Карточки спутников, observation profile и slot profile.</div>
            </div>
            <div class="d-flex gap-2">
                <button id="satellites-refresh" type="button" class="btn btn-outline-secondary">Обновить</button>
                <button id="satellites-new" type="button" class="btn btn-primary">Новый спутник</button>
            </div>
        </div>

        <div id="satellites-alert"></div>

        <div class="row g-4">
            <div class="col-12 col-xxl-4">
                <div class="card catalog-card catalog-list-card h-100">
                    <div class="card-header">
                        <div class="catalog-section-title">Список спутников</div>
                    </div>
                    <div class="card-body catalog-list-search p-3 border-bottom">
                        <input id="satellite-search" class="form-control" placeholder="Поиск по ID, имени, коду"/>
                    </div>
                    <div class="card-body catalog-list catalog-list-page-scroll p-0">
                        <table class="table table-hover mb-0">
                            <thead class="table-light">
                            <tr>
                                <th>ID</th>
                                <th>Код</th>
                                <th>Имя</th>
                                <th>Тип</th>
                                <th>Слоты</th>
                            </tr>
                            </thead>
                            <tbody id="satellites-table-body"></tbody>
                        </table>
                    </div>
                </div>
            </div>

            <div class="col-12 col-xxl-8">
                <div class="d-flex flex-column gap-4">
                    <div class="card catalog-card">
                        <div class="card-header d-flex justify-content-between align-items-center flex-wrap gap-2">
                            <div class="catalog-section-title" id="satellite-form-title">Новый спутник</div>
                            <button id="satellite-delete" type="button" class="btn btn-outline-danger btn-sm">Удалить спутник</button>
                        </div>
                        <div class="card-body">
                            <form id="satellite-form" class="d-flex flex-column gap-3">
                                <div class="catalog-form-grid">
                                    <div>
                                        <label for="satellite-id" class="form-label">ID</label>
                                        <input id="satellite-id" type="number" min="1" class="form-control" required/>
                                    </div>
                                    <div>
                                        <label for="satellite-norad-id" class="form-label">NORAD ID</label>
                                        <input id="satellite-norad-id" type="number" min="1" class="form-control"/>
                                    </div>
                                    <div>
                                        <label for="satellite-code" class="form-label">Code</label>
                                        <input id="satellite-code" class="form-control" required/>
                                    </div>
                                    <div>
                                        <label for="satellite-name" class="form-label">Name</label>
                                        <input id="satellite-name" class="form-control" required/>
                                    </div>
                                    <div>
                                        <label for="satellite-type-code" class="form-label">Type code</label>
                                        <input id="satellite-type-code" class="form-control" required/>
                                    </div>
                                </div>

                                <div class="catalog-form-grid align-items-end">
                                    <div class="form-check">
                                        <input id="satellite-active" class="form-check-input" type="checkbox" checked>
                                        <label class="form-check-label" for="satellite-active">Активен</label>
                                    </div>
                                    <div class="form-check">
                                        <input id="satellite-scan-tle" class="form-check-input" type="checkbox">
                                        <label class="form-check-label" for="satellite-scan-tle">Сканировать TLE</label>
                                    </div>
                                    <div>
                                        <label for="satellite-red" class="form-label">Red</label>
                                        <input id="satellite-red" type="number" min="0" max="255" class="form-control" value="255" required/>
                                    </div>
                                    <div>
                                        <label for="satellite-green" class="form-label">Green</label>
                                        <input id="satellite-green" type="number" min="0" max="255" class="form-control" value="0" required/>
                                    </div>
                                    <div>
                                        <label for="satellite-blue" class="form-label">Blue</label>
                                        <input id="satellite-blue" type="number" min="0" max="255" class="form-control" value="0" required/>
                                    </div>
                                    <div>
                                        <label class="form-label">Preview</label>
                                        <div id="satellite-color-preview" class="catalog-color-preview"></div>
                                    </div>
                                </div>

                                <div>
                                    <button type="submit" class="btn btn-primary">Сохранить карточку</button>
                                </div>
                            </form>
                        </div>
                    </div>

                    <div class="card catalog-card">
                        <div class="card-header d-flex justify-content-between align-items-center flex-wrap gap-2">
                            <div class="catalog-section-title">Observation profile</div>
                            <button id="observation-delete" type="button" class="btn btn-outline-danger btn-sm">Удалить profile</button>
                        </div>
                        <div class="card-body">
                            <form id="observation-form" class="d-flex flex-column gap-3">
                                <div class="catalog-form-grid">
                                    <div>
                                        <label for="observation-capture-angle" class="form-label">Capture angle</label>
                                        <input id="observation-capture-angle" type="number" step="any" class="form-control" required/>
                                    </div>
                                    <div>
                                        <label for="observation-sun-angle-min" class="form-label">Sun angle min</label>
                                        <input id="observation-sun-angle-min" type="number" step="any" class="form-control" required/>
                                    </div>
                                    <div>
                                        <label for="observation-duration-min" class="form-label">Duration min, s</label>
                                        <input id="observation-duration-min" type="number" min="0" class="form-control" required/>
                                    </div>
                                    <div>
                                        <label for="observation-duration-max" class="form-label">Duration max, s</label>
                                        <input id="observation-duration-max" type="number" min="0" class="form-control" required/>
                                    </div>
                                    <div>
                                        <label for="observation-mmi" class="form-label">MMI, s</label>
                                        <input id="observation-mmi" type="number" min="0" class="form-control" required/>
                                    </div>
                                    <div>
                                        <label for="observation-daily-max" class="form-label">Daily max, s</label>
                                        <input id="observation-daily-max" type="number" min="0" class="form-control" required/>
                                    </div>
                                    <div>
                                        <label for="observation-revolution-max" class="form-label">Revolution max, s</label>
                                        <input id="observation-revolution-max" type="number" min="0" class="form-control" required/>
                                    </div>
                                </div>
                                <div>
                                    <button type="submit" class="btn btn-primary">Сохранить observation profile</button>
                                </div>
                            </form>
                        </div>
                    </div>

                    <div class="card catalog-card">
                        <div class="card-header d-flex justify-content-between align-items-center flex-wrap gap-2">
                            <div class="catalog-section-title">Slot profile</div>
                            <button id="slot-delete" type="button" class="btn btn-outline-danger btn-sm">Удалить profile</button>
                        </div>
                        <div class="card-body">
                            <form id="slot-ic-form" class="d-flex flex-column gap-3">
                                <div>
                                    <div class="catalog-section-title">Начальные условия орбиты</div>
                                    <div id="slot-ic-status" class="catalog-helper mt-2">Начальные условия не заданы.</div>
                                </div>

                                <div class="catalog-form-grid">
                                    <div>
                                        <label for="slot-ic-time" class="form-label">Time</label>
                                        <input id="slot-ic-time" type="text" class="form-control" placeholder="dd.mm.yyyy hh:mm:ss.zzz" required/>
                                    </div>
                                    <div>
                                        <label for="slot-ic-revolution" class="form-label">Revolution</label>
                                        <input id="slot-ic-revolution" type="number" class="form-control" required/>
                                    </div>
                                    <div>
                                        <label for="slot-ic-s-ball" class="form-label">S-ball</label>
                                        <input id="slot-ic-s-ball" type="number" step="any" class="form-control" required/>
                                    </div>
                                    <div>
                                        <label for="slot-ic-f81" class="form-label">F81</label>
                                        <input id="slot-ic-f81" type="number" step="any" class="form-control" required/>
                                    </div>
                                </div>

                                <div class="catalog-form-grid">
                                    <div>
                                        <label for="slot-ic-x" class="form-label">X</label>
                                        <input id="slot-ic-x" type="number" step="any" class="form-control" required/>
                                    </div>
                                    <div>
                                        <label for="slot-ic-y" class="form-label">Y</label>
                                        <input id="slot-ic-y" type="number" step="any" class="form-control" required/>
                                    </div>
                                    <div>
                                        <label for="slot-ic-z" class="form-label">Z</label>
                                        <input id="slot-ic-z" type="number" step="any" class="form-control" required/>
                                    </div>
                                </div>

                                <div class="catalog-form-grid">
                                    <div>
                                        <label for="slot-ic-vx" class="form-label">Vx</label>
                                        <input id="slot-ic-vx" type="number" step="any" class="form-control" required/>
                                    </div>
                                    <div>
                                        <label for="slot-ic-vy" class="form-label">Vy</label>
                                        <input id="slot-ic-vy" type="number" step="any" class="form-control" required/>
                                    </div>
                                    <div>
                                        <label for="slot-ic-vz" class="form-label">Vz</label>
                                        <input id="slot-ic-vz" type="number" step="any" class="form-control" required/>
                                    </div>
                                </div>

                                <div>
                                    <button type="submit" class="btn btn-primary">Сохранить начальные условия</button>
                                </div>
                            </form>

                            <hr class="my-4">

                            <form id="slot-form" class="d-flex flex-column gap-3">
                                <div class="catalog-form-grid">
                                    <div>
                                        <label for="slot-cycle-revs" class="form-label">Cycle revs</label>
                                        <input id="slot-cycle-revs" type="number" min="0" class="form-control" required/>
                                    </div>
                                    <div>
                                        <label for="slot-tn-calc" class="form-label">TN calc</label>
                                        <input id="slot-tn-calc" type="text" class="form-control" placeholder="dd.mm.yyyy hh:mm:ss.zzz"/>
                                    </div>
                                    <div>
                                        <label for="slot-duration" class="form-label">Slot duration</label>
                                        <input id="slot-duration" type="number" min="0" class="form-control" required/>
                                    </div>
                                    <div>
                                        <label for="slot-duration-calc-days" class="form-label">Duration calc, days</label>
                                        <input id="slot-duration-calc-days" type="number" min="0" class="form-control" required/>
                                    </div>
                                    <div>
                                        <label for="slot-max-chain-length" class="form-label">Max chain length</label>
                                        <input id="slot-max-chain-length" type="number" min="0" class="form-control" required/>
                                    </div>
                                </div>
                                <div>
                                    <label for="slot-default-angles" class="form-label">Default angles</label>
                                    <textarea id="slot-default-angles" class="form-control" rows="8" placeholder="18.5, 21.58&#10;20.85, 23.82"></textarea>
                                    <div class="catalog-helper mt-2">Один диапазон на строку: `angleBegin, angleEnd`.</div>
                                </div>
                                <div class="d-flex flex-wrap gap-2">
                                    <button id="slot-calculate" type="button" class="btn btn-outline-secondary">Расчет слотов</button>
                                    <button type="submit" class="btn btn-primary">Сохранить slot profile</button>
                                </div>
                            </form>

                            <div id="slot-calculation-summary" class="catalog-slot-summary mt-4"></div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
    <script src="/catalog_scripts.js"></script>
</th:block>
</body>
</html>
