first commit

This commit is contained in:
VPN SaaS Dev
2026-05-12 03:52:13 +09:00
commit d93c88c751
44 changed files with 4108 additions and 0 deletions

291
web/index.html Normal file
View File

@@ -0,0 +1,291 @@
<!doctype html>
<html lang="ru">
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<meta name="theme-color" content="#16806a" />
<meta name="apple-mobile-web-app-capable" content="yes" />
<meta name="apple-mobile-web-app-title" content="Гараж" />
<title>Гараж</title>
<link rel="manifest" href="/manifest.webmanifest" />
<link rel="stylesheet" href="/static/styles.css" />
<script src="https://telegram.org/js/telegram-web-app.js"></script>
</head>
<body>
<main class="shell">
<header class="topbar">
<div>
<p class="eyebrow">Drivers</p>
<h1>Гараж</h1>
</div>
<div class="top-actions">
<button class="icon-btn" id="refreshBtn" title="Обновить" aria-label="Обновить"></button>
<button class="icon-btn" id="menuBtn" title="Меню" aria-label="Меню"></button>
</div>
</header>
<section class="hero-grid">
<div class="summary-card">
<span>Автомобиль</span>
<strong id="selectedCarTitle">Не выбран</strong>
<small id="selectedCarMeta">Добавь авто или выбери из списка</small>
</div>
<div class="summary-card accent">
<span>Расходы</span>
<strong id="summaryTotal">0</strong>
<small>топливо, сервис и ремонты</small>
</div>
<div class="summary-card blue">
<span>Средний расход</span>
<strong id="summaryConsumption">-</strong>
<small>л/100 км по полным данным</small>
</div>
</section>
<section class="layout">
<aside class="panel reveal">
<div class="section-head">
<h2>Автомобили</h2>
<button class="ghost-btn" id="addCarQuickBtn">+</button>
</div>
<div id="cars" class="cars"></div>
</aside>
<section class="workspace reveal">
<section class="progress-strip">
<div>
<span>Профиль учета</span>
<strong id="scoreTitle">Старт</strong>
</div>
<div class="progress-track"><span id="scoreBar"></span></div>
<small id="scoreHint">Добавь авто и первую запись, чтобы видеть точные отчеты</small>
</section>
<section class="report-bar">
<div>
<p class="eyebrow">Отчет</p>
<h2>Стоимость владения</h2>
</div>
<div class="period-controls">
<select id="periodPreset" aria-label="Период отчета">
<option value="all">Весь срок</option>
<option value="month">Месяц</option>
<option value="day">День</option>
<option value="quarter">Квартал</option>
<option value="year">Год</option>
<option value="custom">Свой период</option>
</select>
<input id="periodFrom" type="date" aria-label="Дата начала" />
<input id="periodTo" type="date" aria-label="Дата окончания" />
</div>
</section>
<div class="stats" id="stats"></div>
<section class="quick-actions">
<button class="action-card active" data-action="fuel">
<span>Заправка</span>
<strong>30 сек</strong>
</button>
<button class="action-card" data-action="service">
<span>Сервис</span>
<strong>ТО / ремонт</strong>
</button>
<button class="action-card" data-action="scan">
<span>Скан чека</span>
<strong>OCR</strong>
</button>
</section>
<section class="charts">
<div class="chart-card">
<div class="section-head">
<h2>Динамика расходов</h2>
</div>
<canvas id="expensesChart" width="720" height="260"></canvas>
</div>
<div class="chart-card compact">
<div class="section-head">
<h2>Структура</h2>
</div>
<canvas id="splitChart" width="280" height="260"></canvas>
</div>
</section>
<form id="fuelForm" class="entry-form quick-form">
<label>
Дата
<input name="entry_date" type="date" required />
</label>
<label>
Одометр, км
<input name="odometer" type="number" min="0" required />
</label>
<label>
Литры
<input name="liters" type="number" min="0" step="0.001" required />
</label>
<label>
Цена за литр
<input name="price_per_liter" type="number" min="0" step="0.01" required />
</label>
<label>
АЗС
<select name="station">
<option value="">Не выбрано</option>
<option>Shell</option>
<option>Lukoil</option>
<option>Gazprom</option>
<option>Rosneft</option>
<option>Neste</option>
</select>
</label>
<label class="check">
<input name="is_full_tank" type="checkbox" checked />
Полный бак
</label>
<button type="submit">Сохранить заправку</button>
</form>
<form id="serviceForm" class="entry-form hidden">
<label>
Дата
<input name="entry_date" type="date" required />
</label>
<label>
Одометр, км
<input name="odometer" type="number" min="0" />
</label>
<label>
Тип
<select name="service_type">
<option value="maintenance">Обслуживание</option>
<option value="repair">Ремонт</option>
<option value="fluid">Жидкости</option>
<option value="tire">Шины</option>
<option value="inspection">Осмотр</option>
<option value="insurance">Страховка</option>
<option value="tax">Налог</option>
<option value="other">Другое</option>
</select>
</label>
<label>
Что сделано
<input name="title" placeholder="Замена масла" required />
</label>
<div class="preset-row">
<button type="button" data-service-title="Замена масла" data-service-type="maintenance">Масло</button>
<button type="button" data-service-title="Шиномонтаж" data-service-type="tire">Шины</button>
<button type="button" data-service-title="Диагностика" data-service-type="inspection">Осмотр</button>
</div>
<label>
Стоимость
<input name="total_cost" type="number" min="0" step="0.01" required />
</label>
<label>
Исполнитель
<input name="vendor" placeholder="СТО / магазин" />
</label>
<button type="submit">Сохранить запись</button>
</form>
</section>
</section>
</main>
<div class="drawer hidden" id="userDrawer">
<div class="drawer-panel">
<div class="section-head">
<h2>Меню</h2>
<button class="icon-btn" id="closeMenuBtn" aria-label="Закрыть">×</button>
</div>
<button class="menu-row" id="openCarFormBtn">Добавить автомобиль</button>
<button class="menu-row" id="openSettingsBtn">Локаль и валюта</button>
<button class="menu-row" id="openNotificationsBtn">Уведомления</button>
<button class="menu-row" id="openScanBtn">Сканировать чек</button>
<section class="drawer-section hidden" id="settingsSection">
<h2>Настройки</h2>
<form id="settingsForm" class="grid-form drawer-form">
<label>
Язык
<select name="locale" id="localeSelect">
<option value="ru">Русский</option>
<option value="en">English</option>
<option value="ko">한국어</option>
</select>
</label>
<label>
Валюта
<select name="currency" id="currencySelect">
<option value="RUB">RUB ₽</option>
<option value="USD">USD $</option>
<option value="EUR">EUR €</option>
<option value="KRW">KRW ₩</option>
<option value="KZT">KZT ₸</option>
</select>
</label>
<button type="submit">Сохранить настройки</button>
</form>
</section>
<section class="drawer-section hidden" id="notificationsSection">
<h2>Уведомления</h2>
<div class="tip-card" id="notificationStatus">Напомним о ТО, страховке и регулярном внесении пробега.</div>
<button type="button" class="wide-btn" id="enableNotificationsBtn">Включить уведомления</button>
</section>
<section class="drawer-section hidden" id="scanSection">
<h2>Скан чека</h2>
<form id="ocrForm" class="grid-form drawer-form">
<label>
Фото или файл чека
<span class="scan-actions">
<button type="button" class="ghost-btn" id="scanCameraBtn">Сфотографировать</button>
<button type="button" class="ghost-btn" id="scanFileBtn">Выбрать файл</button>
</span>
<input id="receiptCameraInput" class="hidden-file" type="file" accept="image/*" capture="environment" />
<input id="receiptFileInput" class="hidden-file" type="file" accept="image/*,.pdf,.txt" />
</label>
<div id="receiptFileName" class="file-hint">Файл не выбран</div>
<button type="submit">Распознать</button>
</form>
<div id="ocrResult" class="tip-card">После распознавания поля заправки заполнятся автоматически.</div>
</section>
<section class="drawer-section" id="carFormSection">
<h2>Новое авто</h2>
<form id="carForm" class="grid-form drawer-form">
<label>
Название авто
<input name="name" placeholder="Toyota Camry" required />
</label>
<label>
Марка
<select name="make" id="makeSelect" required></select>
</label>
<label>
Модель
<select name="model" id="modelSelect" required></select>
</label>
<label>
Год
<input name="year" type="number" min="1900" max="2100" />
</label>
<button type="submit">Добавить авто</button>
</form>
</section>
</div>
</div>
<div class="report-sheet hidden" id="reportSheet">
<div class="sheet-panel">
<div class="section-head">
<h2 id="reportTitle">Отчет</h2>
<button class="icon-btn" id="closeReportBtn" aria-label="Закрыть">×</button>
</div>
<div id="reportBody"></div>
</div>
</div>
<script src="/static/app.js"></script>
</body>
</html>

19
web/manifest.webmanifest Normal file
View File

@@ -0,0 +1,19 @@
{
"name": "Гараж: учет авто",
"short_name": "Гараж",
"description": "Учет заправок, сервиса, ремонтов и стоимости владения автомобилем.",
"start_url": "/",
"scope": "/",
"display": "standalone",
"orientation": "portrait",
"background_color": "#eef3f1",
"theme_color": "#16806a",
"icons": [
{
"src": "/static/icon.svg",
"sizes": "any",
"type": "image/svg+xml",
"purpose": "any maskable"
}
]
}

1102
web/static/app.js Normal file

File diff suppressed because it is too large Load Diff

5
web/static/icon.svg Normal file
View File

@@ -0,0 +1,5 @@
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 512 512" role="img" aria-label="Гараж">
<rect width="512" height="512" rx="108" fill="#16806a"/>
<path fill="#ffffff" d="M126 283h260l-22-76c-7-23-25-37-49-37H197c-24 0-42 14-49 37l-22 76Zm63-78h134c9 0 15 5 18 14l10 34H161l10-34c3-9 9-14 18-14Z"/>
<path fill="#dff3ec" d="M101 277c0-13 10-23 23-23h264c13 0 23 10 23 23v68c0 13-10 23-23 23h-15v17c0 12-10 22-22 22h-24c-12 0-22-10-22-22v-17h-98v17c0 12-10 22-22 22h-24c-12 0-22-10-22-22v-17h-15c-13 0-23-10-23-23v-68Zm58 57a30 30 0 1 0 0-60 30 30 0 0 0 0 60Zm194 0a30 30 0 1 0 0-60 30 30 0 0 0 0 60Z"/>
</svg>

After

Width:  |  Height:  |  Size: 623 B

878
web/static/styles.css Normal file
View File

@@ -0,0 +1,878 @@
:root {
color-scheme: light;
--bg: #eef3f1;
--text: #18211f;
--muted: #73807b;
--line: #d8e1de;
--surface: #ffffff;
--soft: #f7faf8;
--accent: #16806a;
--accent-2: #3f7fba;
--fuel: #36a388;
--service: #3f7fba;
--danger: #b5473e;
--shadow: 0 14px 40px rgba(24, 33, 31, 0.08);
}
.top-actions {
display: flex;
gap: 8px;
}
.ghost-btn {
min-height: 34px;
padding: 0 12px;
background: #edf3f0;
color: var(--accent);
box-shadow: none;
}
.progress-strip {
display: grid;
grid-template-columns: 150px 1fr;
gap: 10px 14px;
align-items: center;
padding: 12px;
margin-bottom: 14px;
border: 1px solid var(--line);
border-radius: 8px;
background: #f5faf8;
}
.progress-strip span,
.progress-strip small {
color: var(--muted);
}
.progress-strip strong {
display: block;
margin-top: 2px;
}
.progress-strip small {
grid-column: 2;
}
.progress-track {
height: 10px;
overflow: hidden;
border-radius: 999px;
background: #e3ebe7;
}
.progress-track span {
display: block;
width: 0;
height: 100%;
border-radius: inherit;
background: linear-gradient(90deg, var(--accent), var(--accent-2));
transition: width 360ms ease;
}
.stat {
display: grid;
width: 100%;
color: var(--text);
text-align: left;
box-shadow: none;
}
.quick-actions {
display: grid;
grid-template-columns: repeat(3, minmax(0, 1fr));
gap: 10px;
margin-bottom: 14px;
}
.action-card {
display: grid;
gap: 4px;
min-height: 72px;
color: var(--text);
text-align: left;
background: var(--soft);
border: 1px solid var(--line);
box-shadow: none;
}
.action-card span {
color: var(--muted);
}
.action-card.active {
color: #fff;
background: var(--accent);
border-color: var(--accent);
}
.action-card.active span {
color: rgba(255, 255, 255, 0.78);
}
.preset-row {
display: flex;
gap: 8px;
align-items: end;
flex-wrap: wrap;
}
.preset-row button {
min-height: 36px;
padding: 0 12px;
background: #edf3f0;
color: var(--text);
box-shadow: none;
}
.drawer,
.report-sheet {
position: fixed;
inset: 0;
z-index: 20;
display: grid;
align-items: end;
background: rgba(17, 25, 22, 0.32);
backdrop-filter: blur(5px);
}
.drawer.hidden,
.report-sheet.hidden {
display: none;
}
.drawer-panel,
.sheet-panel {
max-height: 88vh;
overflow: auto;
padding: 18px;
border-radius: 16px 16px 0 0;
background: var(--surface);
box-shadow: 0 -18px 50px rgba(24, 33, 31, 0.18);
animation: sheetUp 220ms ease both;
}
.drawer-panel {
width: min(520px, 100%);
margin-left: auto;
}
.drawer-section {
margin-top: 14px;
padding-top: 14px;
border-top: 1px solid var(--line);
}
.drawer-form {
grid-template-columns: 1fr;
margin-top: 12px;
}
.menu-row {
display: block;
width: 100%;
margin-bottom: 8px;
background: var(--soft);
color: var(--text);
text-align: left;
border: 1px solid var(--line);
box-shadow: none;
}
.wide-btn {
width: 100%;
margin-top: 10px;
}
.scan-actions {
display: grid;
grid-template-columns: repeat(2, minmax(0, 1fr));
gap: 8px;
}
.scan-actions button {
width: 100%;
}
.hidden-file {
position: absolute;
width: 1px;
height: 1px;
opacity: 0;
pointer-events: none;
}
.file-hint {
min-height: 42px;
display: flex;
align-items: center;
color: var(--muted);
font-size: 13px;
word-break: break-word;
}
.sheet-panel {
width: min(720px, 100%);
margin: 0 auto;
}
.report-grid {
display: grid;
grid-template-columns: repeat(2, minmax(0, 1fr));
gap: 10px;
margin-bottom: 12px;
}
.report-metric,
.tip-card {
padding: 12px;
border: 1px solid var(--line);
border-radius: 8px;
background: var(--soft);
}
.report-metric span {
display: block;
color: var(--muted);
font-size: 12px;
}
.report-metric strong {
display: block;
margin-top: 6px;
font-size: 20px;
}
.report-records {
max-height: 360px;
overflow: auto;
}
@keyframes sheetUp {
from {
transform: translateY(24px);
opacity: 0;
}
to {
transform: translateY(0);
opacity: 1;
}
}
@media (max-width: 980px) {
.shell {
padding: 14px 12px 96px;
}
.hero-grid {
display: flex;
overflow-x: auto;
scroll-snap-type: x mandatory;
padding-bottom: 2px;
}
.summary-card {
min-width: 78vw;
scroll-snap-align: start;
}
.cars {
display: flex;
overflow-x: auto;
padding-bottom: 2px;
}
.car-item {
min-width: 230px;
}
.quick-actions {
position: sticky;
top: 0;
z-index: 5;
grid-template-columns: repeat(3, minmax(0, 1fr));
padding: 6px 0;
background: rgba(238, 243, 241, 0.92);
backdrop-filter: blur(8px);
}
.action-card {
min-height: 58px;
padding: 8px;
}
.progress-strip,
.report-grid {
grid-template-columns: 1fr;
}
.progress-strip small {
grid-column: auto;
}
}
@media (max-width: 980px) {
.shell {
padding: 14px 12px 96px;
}
.hero-grid {
display: flex;
overflow-x: auto;
scroll-snap-type: x mandatory;
padding-bottom: 2px;
}
.summary-card {
min-width: 78vw;
scroll-snap-align: start;
}
.cars {
display: flex;
overflow-x: auto;
padding-bottom: 2px;
}
.car-item {
min-width: 230px;
}
.quick-actions {
position: sticky;
top: 0;
z-index: 5;
grid-template-columns: repeat(3, minmax(0, 1fr));
padding: 6px 0;
background: rgba(238, 243, 241, 0.92);
backdrop-filter: blur(8px);
}
.action-card {
min-height: 58px;
padding: 8px;
}
.progress-strip,
.report-grid {
grid-template-columns: 1fr;
}
.progress-strip small {
grid-column: auto;
}
}
* {
box-sizing: border-box;
}
body {
margin: 0;
background:
linear-gradient(180deg, rgba(255, 255, 255, 0.72), rgba(238, 243, 241, 0)),
var(--bg);
color: var(--text);
font-family: Inter, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}
button,
input,
select {
font: inherit;
}
button {
border: 0;
background: var(--accent);
color: #fff;
min-height: 42px;
border-radius: 7px;
padding: 0 16px;
cursor: pointer;
transition:
transform 160ms ease,
box-shadow 160ms ease,
background 160ms ease,
border-color 160ms ease;
}
button:hover {
transform: translateY(-1px);
box-shadow: 0 10px 24px rgba(22, 128, 106, 0.18);
}
button:active {
transform: translateY(0) scale(0.99);
}
button:disabled {
opacity: 0.55;
}
.shell {
width: min(1200px, 100%);
margin: 0 auto;
padding: 18px;
}
.topbar {
display: flex;
align-items: center;
justify-content: space-between;
gap: 16px;
padding: 8px 0 18px;
}
.eyebrow {
margin: 0;
color: var(--accent-2);
font-size: 13px;
font-weight: 800;
text-transform: uppercase;
}
h1,
h2 {
margin: 0;
letter-spacing: 0;
}
h1 {
font-size: clamp(30px, 4vw, 42px);
}
h2 {
font-size: 18px;
}
.icon-btn {
width: 44px;
padding: 0;
background: var(--surface);
color: var(--text);
border: 1px solid var(--line);
box-shadow: none;
}
.loading .icon-btn {
animation: spin 800ms linear infinite;
}
.hero-grid {
display: grid;
grid-template-columns: 1.25fr 1fr 1fr;
gap: 12px;
margin-bottom: 16px;
}
.summary-card,
.band,
.panel,
.workspace,
.chart-card {
background: rgba(255, 255, 255, 0.92);
border: 1px solid var(--line);
border-radius: 8px;
box-shadow: var(--shadow);
}
.summary-card {
display: grid;
gap: 6px;
min-height: 112px;
padding: 16px;
overflow: hidden;
position: relative;
animation: rise 420ms ease both;
}
.summary-card::after {
content: "";
position: absolute;
inset: auto -20px -30px auto;
width: 130px;
height: 90px;
background: rgba(54, 163, 136, 0.12);
transform: rotate(-14deg);
}
.summary-card.accent::after {
background: rgba(54, 163, 136, 0.16);
}
.summary-card.blue::after {
background: rgba(63, 127, 186, 0.15);
}
.summary-card span,
.summary-card small,
.stat span,
.stat em {
color: var(--muted);
}
.summary-card strong {
font-size: clamp(22px, 4vw, 31px);
line-height: 1.05;
z-index: 1;
}
.summary-card small {
z-index: 1;
}
.band {
padding: 14px;
margin-bottom: 16px;
}
.section-head {
display: flex;
align-items: center;
justify-content: space-between;
gap: 12px;
margin-bottom: 12px;
}
.grid-form,
.entry-form {
display: grid;
grid-template-columns: 1.1fr 1fr 1fr 120px auto;
gap: 12px;
align-items: end;
}
label {
display: grid;
gap: 6px;
color: var(--muted);
font-size: 13px;
}
input,
select {
width: 100%;
min-height: 42px;
border: 1px solid var(--line);
border-radius: 7px;
background: #fff;
color: var(--text);
padding: 0 11px;
transition:
border-color 160ms ease,
box-shadow 160ms ease,
transform 160ms ease;
}
input:focus,
select:focus {
outline: none;
border-color: var(--accent);
box-shadow: 0 0 0 4px rgba(22, 128, 106, 0.12);
}
select:disabled {
background: #f1f5f3;
color: #9aa4a0;
}
.layout {
display: grid;
grid-template-columns: 310px 1fr;
gap: 16px;
align-items: start;
}
.panel,
.workspace {
padding: 16px;
}
.report-bar {
display: flex;
align-items: end;
justify-content: space-between;
gap: 14px;
margin-bottom: 14px;
padding-bottom: 14px;
border-bottom: 1px solid var(--line);
}
.report-bar .eyebrow {
margin-bottom: 2px;
}
.period-controls {
display: grid;
grid-template-columns: 140px 150px 150px;
gap: 8px;
align-items: center;
}
.panel {
position: sticky;
top: 12px;
}
.cars {
display: grid;
gap: 9px;
}
.car-item {
display: grid;
grid-template-columns: 42px 1fr;
align-items: center;
gap: 10px;
width: 100%;
min-height: 64px;
background: var(--soft);
color: var(--text);
text-align: left;
border: 1px solid transparent;
box-shadow: none;
}
.car-item small {
display: block;
margin-top: 2px;
color: var(--muted);
}
.car-item.active {
border-color: rgba(22, 128, 106, 0.48);
background: #e5f4ef;
}
.car-badge {
display: grid;
place-items: center;
width: 42px;
height: 42px;
border-radius: 50%;
background: #d7ebe5;
color: #11634f;
font-size: 13px;
font-weight: 800;
}
.stats {
display: grid;
grid-template-columns: repeat(4, minmax(120px, 1fr));
gap: 10px;
margin-bottom: 14px;
}
.stat {
border: 1px solid var(--line);
border-radius: 8px;
padding: 12px;
min-height: 92px;
background: var(--soft);
}
.stat strong {
display: block;
margin-top: 6px;
font-size: 22px;
}
.stat em {
display: block;
margin-top: 4px;
font-size: 12px;
font-style: normal;
}
.pop {
animation: pop 260ms ease both;
}
.charts {
display: grid;
grid-template-columns: minmax(0, 1fr) 300px;
gap: 12px;
margin-bottom: 14px;
}
.chart-card {
min-height: 320px;
padding: 14px;
box-shadow: none;
}
.chart-card canvas {
display: block;
width: 100%;
height: 250px;
}
.chart-card.compact {
min-width: 0;
}
.tabs {
display: flex;
gap: 8px;
margin-bottom: 12px;
padding: 4px;
width: fit-content;
background: #edf2ef;
border-radius: 8px;
}
.tab {
background: transparent;
color: var(--text);
box-shadow: none;
}
.tab:hover {
box-shadow: none;
}
.tab.active {
background: var(--accent-2);
color: #fff;
}
.entry-form {
grid-template-columns: repeat(3, minmax(140px, 1fr));
border-top: 1px solid var(--line);
padding-top: 14px;
animation: fade 180ms ease both;
}
.check {
display: flex;
align-items: center;
gap: 8px;
min-height: 42px;
}
.check input {
width: 18px;
min-height: 18px;
accent-color: var(--accent);
}
.hidden {
display: none;
}
.history {
margin-top: 20px;
border-top: 1px solid var(--line);
padding-top: 16px;
}
.record {
display: grid;
grid-template-columns: 110px 1fr auto;
gap: 12px;
padding: 12px 0;
border-bottom: 1px solid var(--line);
align-items: center;
animation: fade 220ms ease both;
}
.record small {
color: var(--muted);
}
.record .fuel {
color: var(--fuel);
}
.record .service {
color: var(--service);
}
.empty {
color: var(--muted);
padding: 18px 0;
}
.error {
margin: 12px auto;
width: min(920px, calc(100% - 24px));
padding: 12px 14px;
border-radius: 8px;
background: #fff1ef;
border: 1px solid #f0c8c1;
color: var(--danger);
}
.reveal {
animation: rise 360ms ease both;
}
@keyframes rise {
from {
opacity: 0;
transform: translateY(10px);
}
to {
opacity: 1;
transform: translateY(0);
}
}
@keyframes fade {
from {
opacity: 0;
}
to {
opacity: 1;
}
}
@keyframes pop {
0% {
opacity: 0;
transform: scale(0.98);
}
100% {
opacity: 1;
transform: scale(1);
}
}
@keyframes spin {
to {
transform: rotate(360deg);
}
}
@media (max-width: 980px) {
.hero-grid,
.layout,
.charts,
.grid-form,
.entry-form,
.stats,
.period-controls {
grid-template-columns: 1fr;
}
.report-bar {
align-items: stretch;
flex-direction: column;
}
.panel {
position: static;
}
.tabs {
width: 100%;
}
.tab {
flex: 1;
}
.record {
grid-template-columns: 1fr;
}
}

55
web/sw.js Normal file
View File

@@ -0,0 +1,55 @@
const CACHE_NAME = "drivers-garage-v1";
const APP_SHELL = [
"/",
"/static/app.js",
"/static/styles.css",
"/static/icon.svg",
"/manifest.webmanifest",
];
self.addEventListener("install", (event) => {
event.waitUntil(caches.open(CACHE_NAME).then((cache) => cache.addAll(APP_SHELL)));
self.skipWaiting();
});
self.addEventListener("activate", (event) => {
event.waitUntil(
caches
.keys()
.then((keys) => Promise.all(keys.filter((key) => key !== CACHE_NAME).map((key) => caches.delete(key)))),
);
self.clients.claim();
});
self.addEventListener("fetch", (event) => {
const { request } = event;
if (request.method !== "GET") return;
if (new URL(request.url).pathname.startsWith("/api/")) return;
event.respondWith(
fetch(request)
.then((response) => {
const copy = response.clone();
caches.open(CACHE_NAME).then((cache) => cache.put(request, copy));
return response;
})
.catch(() => caches.match(request).then((cached) => cached || caches.match("/"))),
);
});
self.addEventListener("push", (event) => {
const data = event.data?.json?.() || {};
event.waitUntil(
self.registration.showNotification(data.title || "Гараж", {
body: data.body || "Пора обновить данные по автомобилю.",
icon: "/static/icon.svg",
badge: "/static/icon.svg",
tag: data.tag || "drivers-garage-reminder",
data: data.url || "/",
}),
);
});
self.addEventListener("notificationclick", (event) => {
event.notification.close();
event.waitUntil(clients.openWindow(event.notification.data || "/"));
});