Readability pass across all four areas of the stack. Comments explain why rather than what, concentrated at the points where behaviour is non-obvious: concurrency, caching, auth, scraping and nginx templating. Backend: doc comments on every exported declaration across handlers, services, models and resolvers. Resolver commentary lives inside function bodies so gqlgen does not strip it on regeneration; schema files use # comments rather than description blocks so introspection output is unchanged. Extracted the duplicated auth-cookie blocks into helpers. Frontend: header comments on every component, store and view, including STATUS: notes marking which of the parallel/legacy views are still live. Documented the non-reactive animation-state pattern, the homeData hub and the WebSocket stale-socket guard. Removed a few dead imports and named the reconnect-backoff and poll-interval constants. Python: module and function docstrings covering the Travelodge scraping contract, the deadline threading, the two-executor concurrency and the NDJSON streaming protocol. Infra: header blocks on every compose file, nginx template, Dockerfile and entrypoint, covering the config selection, envsubst allow-lists, rate-limit semantics and volume persistence. Hoisted the duplicated envsubst variable list in nginx/entrypoint.sh. New: backend/README.md, python/README.md, DEPLOYMENT.md, .env.example, backend/graph/doc.go. Refreshed vue/README.md. Corrected CLAUDE.md, which stated a 24h access token where main.go sets 7 days. No behaviour change. go build/vet, vite build, py_compile and docker compose config all pass. Co-Authored-By: Claude Opus 5 <[email protected]>
193 lines
4.5 KiB
Vue
193 lines
4.5 KiB
Vue
<script setup>
|
||
/**
|
||
* The Places-to-go table inside the Collage widget. Sign-in only.
|
||
*
|
||
* Fetches lazily and at most once: onMounted covers an already-signed-in visitor,
|
||
* the `loggedIn` watcher covers someone who signs in while the page is open, and
|
||
* both check `!loaded && !loading` so the two paths can't fire two requests.
|
||
*/
|
||
import { computed, onMounted, watch } from "vue";
|
||
import { usePlacesStore } from "@/stores/places";
|
||
import { useAuthStore } from "@/stores/auth";
|
||
|
||
const places = usePlacesStore();
|
||
const auth = useAuthStore();
|
||
const loggedIn = computed(() => auth.loggedIn);
|
||
|
||
// Two entry points, one fetch: onMounted covers an already-signed-in visitor,
|
||
// the watcher covers signing in with the page already open. The
|
||
// !loaded && !loading test is what stops them both firing a request.
|
||
onMounted(() => {
|
||
if (loggedIn.value && !places.loaded && !places.loading) places.fetch();
|
||
});
|
||
|
||
watch(loggedIn, (isIn) => {
|
||
if (isIn && !places.loaded && !places.loading) places.fetch();
|
||
});
|
||
|
||
async function toggleDone(place) {
|
||
if (!loggedIn.value) return;
|
||
try {
|
||
await places.toggleDone(place);
|
||
} catch (err) {
|
||
console.error(err);
|
||
}
|
||
}
|
||
|
||
async function remove(place) {
|
||
if (!loggedIn.value) return;
|
||
if (!confirm(`Delete "${place.title}"?`)) return;
|
||
try {
|
||
await places.remove(place.id);
|
||
} catch (err) {
|
||
console.error(err);
|
||
}
|
||
}
|
||
</script>
|
||
|
||
<template>
|
||
<div class="places-table">
|
||
<p v-if="!places.loaded && places.loading" class="places-empty">
|
||
Loading…
|
||
</p>
|
||
<p v-else-if="places.error" class="places-empty">
|
||
Couldn't load places.
|
||
</p>
|
||
<p v-else-if="!places.places.length" class="places-empty">
|
||
Nothing here yet — add somewhere to go.
|
||
</p>
|
||
<table v-else class="places">
|
||
<thead>
|
||
<tr>
|
||
<th>Title</th>
|
||
<th class="col-loc">Where</th>
|
||
<th class="col-cat">Type</th>
|
||
<th class="col-cost">Cost</th>
|
||
<th v-if="loggedIn" class="col-act"></th>
|
||
</tr>
|
||
</thead>
|
||
<tbody>
|
||
<tr
|
||
v-for="place in places.places"
|
||
:key="place.id"
|
||
:class="{ 'is-done': place.done }"
|
||
>
|
||
<td>
|
||
<div class="title-cell">
|
||
<button
|
||
v-if="loggedIn"
|
||
class="done-toggle"
|
||
:title="place.done ? 'Mark as pending' : 'Mark as done'"
|
||
@click="toggleDone(place)"
|
||
>
|
||
{{ place.done ? "✓" : "○" }}
|
||
</button>
|
||
<span class="title-text">{{ place.title }}</span>
|
||
</div>
|
||
<small v-if="place.notes" class="notes">{{ place.notes }}</small>
|
||
</td>
|
||
<td class="col-loc">{{ place.location || "—" }}</td>
|
||
<td class="col-cat">{{ place.category || "—" }}</td>
|
||
<td class="col-cost">{{ place.cost || "—" }}</td>
|
||
<td v-if="loggedIn" class="col-act">
|
||
<button class="row-action" @click="remove(place)" title="Delete">
|
||
×
|
||
</button>
|
||
</td>
|
||
</tr>
|
||
</tbody>
|
||
</table>
|
||
</div>
|
||
</template>
|
||
|
||
<style scoped>
|
||
.places-table {
|
||
width: 100%;
|
||
height: 100%;
|
||
overflow-y: auto;
|
||
}
|
||
|
||
.places-empty {
|
||
padding: 12px;
|
||
text-align: center;
|
||
color: var(--color-muted);
|
||
}
|
||
|
||
table.places {
|
||
width: 100%;
|
||
border: none;
|
||
border-collapse: collapse;
|
||
font-size: 0.85rem;
|
||
}
|
||
|
||
table.places th {
|
||
position: sticky;
|
||
top: 0;
|
||
background-color: var(--color-surface);
|
||
border-right: 1px dotted var(--color-tertiary);
|
||
border-bottom: 1px solid var(--color-primary);
|
||
padding: 4px 6px;
|
||
text-align: left;
|
||
font-family: var(--font-heading);
|
||
}
|
||
|
||
table.places td {
|
||
padding: 4px 6px;
|
||
vertical-align: top;
|
||
border-bottom: 1px dotted var(--color-quaternary);
|
||
}
|
||
|
||
.title-cell {
|
||
display: flex;
|
||
align-items: center;
|
||
gap: 6px;
|
||
}
|
||
|
||
.title-text {
|
||
color: var(--color-primary);
|
||
font-family: var(--font-heading);
|
||
}
|
||
|
||
.notes {
|
||
display: block;
|
||
color: var(--color-muted);
|
||
font-size: 0.75rem;
|
||
padding-top: 2px;
|
||
}
|
||
|
||
tr.is-done .title-text {
|
||
text-decoration: line-through;
|
||
color: var(--color-muted);
|
||
}
|
||
|
||
.done-toggle,
|
||
.row-action {
|
||
background-color: transparent;
|
||
color: var(--color-primary);
|
||
border: 1px solid var(--color-quaternary);
|
||
width: 20px;
|
||
height: 20px;
|
||
line-height: 1;
|
||
cursor: pointer;
|
||
font-family: var(--font-heading);
|
||
padding: 0;
|
||
}
|
||
.done-toggle:hover,
|
||
.row-action:hover {
|
||
border-color: var(--color-tertiary);
|
||
color: var(--color-tertiary);
|
||
}
|
||
|
||
.col-cost,
|
||
.col-cat {
|
||
white-space: nowrap;
|
||
}
|
||
|
||
@media (max-width: 700px) {
|
||
.col-cost,
|
||
.col-cat {
|
||
display: none;
|
||
}
|
||
}
|
||
</style>
|