major fix
This commit is contained in:
1 parent
929088cef0
commit
9e799049a7
10 files changed
+339
-281
No files matched your search
+60
-107
@@ -14,52 +14,40 @@
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: center;
|
||||
padding: 2rem 1rem;
|
||||
padding: 2.5rem 1rem;
|
||||
}
|
||||
h1 { font-size: 1.6rem; margin-bottom: 1.5rem; color: #f97316; }
|
||||
h1 { font-size: 1.5rem; margin-bottom: 0.4rem; color: #f97316; }
|
||||
.week-label { font-size: 0.9rem; color: #888; margin-bottom: 1.8rem; }
|
||||
.card {
|
||||
background: #1c1c1c;
|
||||
border: 1px solid #2e2e2e;
|
||||
border-radius: 10px;
|
||||
padding: 1.5rem;
|
||||
padding: 1.4rem;
|
||||
width: 100%;
|
||||
max-width: 540px;
|
||||
margin-bottom: 1.2rem;
|
||||
max-width: 500px;
|
||||
margin-bottom: 1rem;
|
||||
}
|
||||
label { display: block; font-size: 0.85rem; color: #aaa; margin-bottom: 0.3rem; }
|
||||
.row { display: flex; gap: 1rem; margin-bottom: 1rem; }
|
||||
.row > div { flex: 1; }
|
||||
input[type="date"] {
|
||||
width: 100%;
|
||||
padding: 0.5rem 0.7rem;
|
||||
background: #2a2a2a;
|
||||
border: 1px solid #3e3e3e;
|
||||
border-radius: 6px;
|
||||
color: #e8e8e8;
|
||||
font-size: 0.95rem;
|
||||
}
|
||||
.btn-row { display: flex; gap: 0.8rem; }
|
||||
button {
|
||||
flex: 1;
|
||||
padding: 0.6rem 1rem;
|
||||
width: 100%;
|
||||
padding: 0.7rem 1rem;
|
||||
border: none;
|
||||
border-radius: 6px;
|
||||
font-size: 0.95rem;
|
||||
font-size: 1rem;
|
||||
cursor: pointer;
|
||||
transition: opacity 0.15s;
|
||||
}
|
||||
button:disabled { opacity: 0.5; cursor: not-allowed; }
|
||||
#btn-fetch { background: #2563eb; color: #fff; }
|
||||
#btn-report { background: #f97316; color: #fff; }
|
||||
button:not(:disabled):hover { opacity: 0.85; }
|
||||
button:disabled { opacity: 0.45; cursor: not-allowed; }
|
||||
#btn-report { background: #f97316; color: #fff; font-weight: 600; }
|
||||
#btn-report:not(:disabled):hover { opacity: 0.85; }
|
||||
.detail-grid {
|
||||
display: grid;
|
||||
grid-template-columns: 1fr 1fr;
|
||||
gap: 0.6rem 1.2rem;
|
||||
grid-template-columns: auto 1fr;
|
||||
gap: 0.5rem 1.2rem;
|
||||
font-size: 0.9rem;
|
||||
margin-bottom: 1rem;
|
||||
}
|
||||
.detail-grid .label { color: #888; }
|
||||
.detail-grid .value { color: #fff; font-weight: 600; }
|
||||
.detail-grid .lbl { color: #888; white-space: nowrap; }
|
||||
.detail-grid .val { color: #fff; font-weight: 600; }
|
||||
#report-box {
|
||||
width: 100%;
|
||||
background: #111;
|
||||
@@ -70,58 +58,50 @@
|
||||
font-family: monospace;
|
||||
font-size: 0.95rem;
|
||||
white-space: pre-wrap;
|
||||
min-height: 80px;
|
||||
resize: vertical;
|
||||
min-height: 72px;
|
||||
}
|
||||
#copy-btn {
|
||||
margin-top: 0.7rem;
|
||||
background: #16a34a;
|
||||
color: #fff;
|
||||
flex: none;
|
||||
width: 100%;
|
||||
}
|
||||
.status { font-size: 0.85rem; color: #f59e0b; min-height: 1.2rem; margin-top: 0.5rem; }
|
||||
#copy-btn:not(:disabled):hover { opacity: 0.85; }
|
||||
.status { font-size: 0.85rem; color: #f59e0b; min-height: 1.2rem; margin-top: 0.6rem; text-align: center; }
|
||||
.error { color: #f87171; }
|
||||
.hidden { display: none; }
|
||||
.media-name { font-size: 0.78rem; color: #666; margin-top: 0.8rem; word-break: break-word; }
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<h1>🏴☠️ One Piece Progress Reporter</h1>
|
||||
<div class="week-label">Week: <strong>{{ date_range }}</strong> ({{ week_start }} → {{ week_end }})</div>
|
||||
|
||||
<div class="card" style="margin-top:0.8rem;">
|
||||
<h2 style="font-size:0.95rem;color:#aaa;margin-bottom:0.5rem;">Environment</h2>
|
||||
<pre id="env" style="white-space:pre-wrap;font-family:monospace;font-size:0.85rem;color:#ddd;background:#0b0b0b;border-radius:6px;padding:0.6rem;">
|
||||
JELLYFIN_HOST={{ config.JELLYFIN_HOST }}
|
||||
JELLYFIN_API_KEY={{ config.JELLYFIN_API_KEY }}
|
||||
JELLYFIN_USER_ID={{ config.JELLYFIN_USER_ID }}
|
||||
TOTAL_EPISODES={{ config.TOTAL_EPISODES }}
|
||||
DB_PATH={{ config.DB_PATH }}
|
||||
</pre>
|
||||
</div>
|
||||
|
||||
<div class="card">
|
||||
<div class="row">
|
||||
<div>
|
||||
<label for="start">Week Start</label>
|
||||
<input type="date" id="start" value="{{ default_start }}" />
|
||||
</div>
|
||||
<div>
|
||||
<label for="end">Week End (Saturday)</label>
|
||||
<input type="date" id="end" value="{{ default_end }}" />
|
||||
</div>
|
||||
</div>
|
||||
<div class="btn-row">
|
||||
<button id="btn-fetch">Fetch Episodes</button>
|
||||
<button id="btn-report">Generate Report</button>
|
||||
</div>
|
||||
<button id="btn-report">Generate Report</button>
|
||||
<div id="status" class="status"></div>
|
||||
</div>
|
||||
|
||||
<div class="card hidden" id="details-card">
|
||||
<h2 style="font-size:1rem;margin-bottom:0.8rem;color:#aaa;">Episode Details</h2>
|
||||
<div class="detail-grid">
|
||||
<span class="label">Latest episode</span> <span class="value" id="d-latest">—</span>
|
||||
<span class="label">Previous week</span> <span class="value" id="d-previous">—</span>
|
||||
<span class="label">Watched this week</span><span class="value" id="d-watched">—</span>
|
||||
<span class="label">Total in series</span> <span class="value" id="d-total">—</span>
|
||||
<span class="label">Jellyfin (latest)</span><span class="value" id="d-jf-latest">—</span>
|
||||
<span class="label">Jellyfin (prev)</span> <span class="value" id="d-jf-prev">—</span>
|
||||
<span class="lbl">Last episode watched</span><span class="val" id="d-latest">—</span>
|
||||
<span class="lbl">Previous week ended at</span><span class="val" id="d-previous">—</span>
|
||||
<span class="lbl">Watched this week</span><span class="val" id="d-watched">—</span>
|
||||
<span class="lbl">Total in series</span><span class="val" id="d-total">—</span>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="card hidden" id="report-card">
|
||||
<h2 style="font-size:1rem;margin-bottom:0.8rem;color:#aaa;">Report</h2>
|
||||
<div id="report-box"></div>
|
||||
<button id="copy-btn">📋 Copy to Clipboard</button>
|
||||
<div id="media-name" class="media-name hidden"></div>
|
||||
</div>
|
||||
|
||||
<script>
|
||||
@@ -133,69 +113,42 @@
|
||||
el.classList.toggle('error', isError);
|
||||
}
|
||||
|
||||
function setLoading(on) {
|
||||
$('btn-fetch').disabled = on;
|
||||
$('btn-report').disabled = on;
|
||||
}
|
||||
|
||||
function showDetails(data) {
|
||||
$('d-latest').textContent = data.latest_episode;
|
||||
$('d-previous').textContent = data.previous_episode;
|
||||
$('d-watched').textContent = data.watched_this_week;
|
||||
$('d-total').textContent = data.total_episodes;
|
||||
$('d-jf-latest').textContent = `S${String(data.latest_jellyfin.season).padStart(2,'0')}E${String(data.latest_jellyfin.episode).padStart(2,'0')}`;
|
||||
$('d-jf-prev').textContent = `S${String(data.previous_jellyfin.season).padStart(2,'0')}E${String(data.previous_jellyfin.episode).padStart(2,'0')}`;
|
||||
$('details-card').classList.remove('hidden');
|
||||
}
|
||||
|
||||
async function doFetch() {
|
||||
setLoading(true);
|
||||
setStatus('Fetching episode data…');
|
||||
$('btn-report').addEventListener('click', async () => {
|
||||
$('btn-report').disabled = true;
|
||||
setStatus('Fetching from Jellyfin…');
|
||||
$('details-card').classList.add('hidden');
|
||||
$('report-card').classList.add('hidden');
|
||||
try {
|
||||
const start = $('start').value;
|
||||
const end = $('end').value;
|
||||
const resp = await fetch(`/api/fetch-episodes?start=${start}&end=${end}`);
|
||||
const data = await resp.json();
|
||||
if (data.error) throw new Error(data.error);
|
||||
showDetails(data);
|
||||
setStatus('');
|
||||
} catch (e) {
|
||||
setStatus(e.message, true);
|
||||
} finally {
|
||||
setLoading(false);
|
||||
}
|
||||
}
|
||||
|
||||
async function doReport() {
|
||||
setLoading(true);
|
||||
setStatus('Generating report…');
|
||||
$('report-card').classList.add('hidden');
|
||||
try {
|
||||
const start = $('start').value;
|
||||
const end = $('end').value;
|
||||
const resp = await fetch(`/api/report?start=${start}&end=${end}`);
|
||||
const resp = await fetch('/api/report');
|
||||
const data = await resp.json();
|
||||
if (data.error) throw new Error(data.error);
|
||||
showDetails(data);
|
||||
|
||||
$('d-latest').textContent = data.latest_episode;
|
||||
$('d-previous').textContent = data.previous_episode;
|
||||
$('d-watched').textContent = data.watched_this_week;
|
||||
$('d-total').textContent = data.total_episodes;
|
||||
$('report-box').textContent = data.report;
|
||||
$('report-card').classList.remove('hidden');
|
||||
|
||||
if (data.media_name) {
|
||||
$('media-name').textContent = '📁 ' + data.media_name;
|
||||
$('media-name').classList.remove('hidden');
|
||||
}
|
||||
|
||||
$('details-card').classList.remove('hidden');
|
||||
setStatus('');
|
||||
} catch (e) {
|
||||
setStatus(e.message, true);
|
||||
} finally {
|
||||
setLoading(false);
|
||||
$('btn-report').disabled = false;
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
$('btn-fetch').addEventListener('click', doFetch);
|
||||
$('btn-report').addEventListener('click', doReport);
|
||||
$('copy-btn').addEventListener('click', () => {
|
||||
navigator.clipboard.writeText($('report-box').textContent)
|
||||
.then(() => setStatus('Copied!'))
|
||||
.catch(() => setStatus('Copy failed', true));
|
||||
.then(() => setStatus('Copied to clipboard!'))
|
||||
.catch(() => setStatus('Copy failed — select text manually', true));
|
||||
});
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
|
||||
Reference in new issue
Block a user