Give the job tracker stores and fix the admin route guard

createCrudStore captures the places store's pattern and now backs
places, job applications and job references. JobApplications.vue no
longer calls gql() itself and is split into the applications table, the
references table and the add form, with the status vocabulary in
jobStatus.js.

api.js is a thin REST client that turns failures into an ApiError
carrying the backend's message; the admin views and Listening.vue use it
in place of raw axios and fetch.

The router guard waited on the home query's loaded flag, which is never
set when that query fails, so /admin and /cv/jobs could hang. It now
awaits a standalone me query owned by the auth store, and homeData gains
a settled flag for widgets that only need to know the fetch finished.

The Vite proxy targets are configurable through VITE_PROXY_*, and
build:js runs the Vite build without wasm-pack.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
This commit is contained in:
2026-10-12 14:39:19 +01:00
co-authored by Claude Opus 5.5
parent 71344a1f8d
commit d3f722d077
26 changed files with 1176 additions and 681 deletions
+129
View File
@@ -0,0 +1,129 @@
<script setup>
/**
* The "add an application" form on `/cv/jobs`. Rendered only by
* JobApplications.vue; it creates through stores/jobApplications.js, so the new
* row appears in the parent's table without the two having to talk.
*
* Like JobReferences.vue it reports through the parent's single error banner:
* `fail` carries the error, `ok` says a create succeeded.
*
* Its root sits inside the parent's `.ja-root`, which jobs-shared.css relies on.
*/
import { ref } from "vue";
import { useJobApplicationsStore } from "@/stores/jobApplications";
import { STATUS_OPTIONS } from "./jobStatus";
import "./jobs-shared.css";
const emit = defineEmits(["fail", "ok"]);
const store = useJobApplicationsStore();
function today() {
return new Date().toISOString().substring(0, 10);
}
function blankForm() {
return {
jobTitle: "",
company: "",
location: "",
url: "",
status: "applied",
notes: "",
// Logging an application on the day you send it is the common case, so the
// date defaults to today rather than landing null and ageing as unknown.
appliedAt: today(),
};
}
const form = ref(blankForm());
async function createApplication() {
if (!form.value.jobTitle.trim() || !form.value.company.trim()) return;
try {
await store.create({
jobTitle: form.value.jobTitle.trim(),
company: form.value.company.trim(),
status: form.value.status,
location: form.value.location || undefined,
url: form.value.url || undefined,
notes: form.value.notes || undefined,
appliedAt: form.value.appliedAt
? new Date(form.value.appliedAt).toISOString()
: undefined,
});
form.value = blankForm();
emit("ok");
} catch (err) {
// The form is left as typed so the create can be retried.
emit("fail", err);
}
}
</script>
<template>
<form class="ja-form" @submit.prevent="createApplication">
<div class="ja-form-row">
<input
v-model="form.jobTitle"
class="ja-input"
placeholder="Job title *"
required
/>
<input
v-model="form.company"
class="ja-input"
placeholder="Company *"
required
/>
<select v-model="form.status" class="ja-input ja-select">
<option v-for="s in STATUS_OPTIONS" :key="s.value" :value="s.value">
{{ s.label }}
</option>
</select>
</div>
<div class="ja-form-row">
<input
v-model="form.location"
class="ja-input"
placeholder="Location"
/>
<input v-model="form.url" class="ja-input" placeholder="URL" />
<input
v-model="form.appliedAt"
class="ja-input"
type="date"
title="Applied date"
/>
</div>
<div class="ja-form-row">
<textarea
v-model="form.notes"
class="ja-input ja-textarea"
placeholder="Notes"
/>
<button type="submit" class="cv-btn cv-btn-primary">Add</button>
</div>
</form>
</template>
<style scoped>
/* Inputs are styled by jobs-shared.css; buttons are .cv-btn from CVLayout.vue. */
.ja-form {
display: flex;
flex-direction: column;
gap: 0.5rem;
margin-bottom: 1.5rem;
}
.ja-form-row {
display: flex;
gap: 0.5rem;
flex-wrap: wrap;
}
.ja-textarea {
resize: vertical;
min-height: 2.4rem;
}
</style>
+33 -451
View File
@@ -2,8 +2,14 @@
/**
* Route `/cv/jobs` (guarded by `meta.requiresAdmin`) — a private tracker for job
* applications and for the reusable reference snippets that feed the CV copy.
* Two independent CRUD tables over GraphQL; editing is inline via an `editingId`
* plus a scratch copy of the row.
*
* This view owns the page frame, the single error banner and the applications
* table (pipeline bar, filter/sort, inline editing via an `editingId` plus a
* scratch copy of the row). The two other pieces are components beside it:
* JobReferences.vue (the Quick Reference box, a separate table) and
* JobApplicationForm.vue (the add form). Data access is in
* stores/jobApplications.js and stores/jobAppReferences.js; nothing here calls
* gql() directly.
*
* Rows also arrive from two places that are not this page: the email pipeline,
* and the browser userscript in `public/job-capture.user.js`, which the header
@@ -11,63 +17,21 @@
*/
import { ref, computed, onMounted } from "vue";
import { RouterLink } from "vue-router";
import { gql } from "@/graphql";
import { storeToRefs } from "pinia";
import { useJobApplicationsStore } from "@/stores/jobApplications";
import { STATUS_OPTIONS, OPEN_STATUSES } from "./jobStatus";
import JobReferences from "./JobReferences.vue";
import JobApplicationForm from "./JobApplicationForm.vue";
import "./jobs-shared.css";
const applications = ref([]);
const store = useJobApplicationsStore();
const { applications } = storeToRefs(store);
const editingId = ref(null);
const editForm = ref({});
const error = ref("");
/**
* The status vocabulary is the email pipeline's (services.statusOrder), not a
* separate UI list: the pipeline writes these lowercase keys, and a status it
* does not rank switches its forward-only progression guard off for that row.
* Labels are display-only.
*/
const STATUS_OPTIONS = [
// Captured from the browser but not applied to yet. No email produces it.
{ value: "saved", label: "Saved" },
{ value: "applied", label: "Applied" },
{ value: "screening", label: "Screening" },
{ value: "assessment", label: "Assessment" },
{ value: "interviewing", label: "Interviewing" },
{ value: "offer", label: "Offer" },
{ value: "rejected", label: "Rejected" },
{ value: "withdrawn", label: "Withdrawn" },
];
// Statuses still in play — used to decide whether a row is worth chasing.
// "saved" is absent on purpose: nobody owes a reply on a job not applied to.
const OPEN_STATUSES = ["applied", "screening", "assessment", "interviewing"];
const STALE_DAYS = 14;
function today() {
return new Date().toISOString().substring(0, 10);
}
const form = ref({
jobTitle: "",
company: "",
location: "",
url: "",
status: "applied",
notes: "",
// Logging an application on the day you send it is the common case, so the
// date defaults to today rather than landing null and ageing as unknown.
appliedAt: today(),
});
const references = ref([]);
const refForm = ref({ category: "profile", label: "", value: "" });
const editingRefId = ref(null);
const editRefForm = ref({});
const REF_CATEGORIES = ["profile", "experience"];
const REF_FIELDS = `id category label value sortOrder createdAt`;
// `description` is deliberately not here: it is the full text of the posting,
// tens of kilobytes a row, and is fetched per row when asked for.
const APP_FIELDS = `id jobTitle company location url status notes appliedAt createdAt updatedAt`;
// The captured posting text for the one row whose description is open.
// `undefined` in the cache means "not fetched", `""` means "fetched, none saved".
const descriptionId = ref(null);
@@ -88,49 +52,14 @@ function fail(err) {
error.value = String(err?.message ?? err);
}
async function fetchApplications() {
try {
const data = await gql(`query { jobApplications { ${APP_FIELDS} } }`);
applications.value = data.jobApplications;
} catch (err) {
fail(err);
}
function clearError() {
error.value = "";
}
async function createApplication() {
if (!form.value.jobTitle.trim() || !form.value.company.trim()) return;
try {
const input = {
jobTitle: form.value.jobTitle.trim(),
company: form.value.company.trim(),
status: form.value.status,
location: form.value.location || undefined,
url: form.value.url || undefined,
notes: form.value.notes || undefined,
appliedAt: form.value.appliedAt
? new Date(form.value.appliedAt).toISOString()
: undefined,
};
const data = await gql(
`mutation CreateJobApplication($input: CreateJobApplicationInput!) {
createJobApplication(input: $input) { ${APP_FIELDS} }
}`,
{ input },
);
applications.value.unshift(data.createJobApplication);
form.value = {
jobTitle: "",
company: "",
location: "",
url: "",
status: "applied",
notes: "",
appliedAt: today(),
};
error.value = "";
} catch (err) {
fail(err);
}
async function fetchApplications() {
// The store's fetch() records its failure instead of throwing.
await store.fetch();
if (store.error) fail(store.error);
}
function startEdit(app) {
@@ -178,7 +107,7 @@ async function saveEdit(id) {
// "delete this wrong URL" into a silent no-op that re-renders the old
// value. appliedAt has no empty representation, so clearing it is not
// offered — the field stays as it was.
const input = {
await store.update(id, {
jobTitle: editForm.value.jobTitle,
company: editForm.value.company,
status: editForm.value.status,
@@ -188,15 +117,7 @@ async function saveEdit(id) {
appliedAt: editForm.value.appliedAt
? new Date(editForm.value.appliedAt).toISOString()
: undefined,
};
const data = await gql(
`mutation UpdateJobApplication($id: ID!, $input: UpdateJobApplicationInput!) {
updateJobApplication(id: $id, input: $input) { ${APP_FIELDS} }
}`,
{ id, input },
);
const idx = applications.value.findIndex((a) => a.id === id);
if (idx !== -1) applications.value[idx] = data.updateJobApplication;
});
editingId.value = null;
error.value = "";
} catch (err) {
@@ -210,14 +131,7 @@ async function saveEdit(id) {
async function setStatus(app, status) {
if (status === app.status) return;
try {
const data = await gql(
`mutation UpdateJobApplication($id: ID!, $input: UpdateJobApplicationInput!) {
updateJobApplication(id: $id, input: $input) { ${APP_FIELDS} }
}`,
{ id: app.id, input: { status } },
);
const idx = applications.value.findIndex((a) => a.id === app.id);
if (idx !== -1) applications.value[idx] = data.updateJobApplication;
await store.update(app.id, { status });
error.value = "";
} catch (err) {
fail(err);
@@ -232,11 +146,7 @@ async function toggleDescription(app) {
descriptionId.value = app.id;
if (descriptions.value[app.id] !== undefined) return;
try {
const data = await gql(
`query JobDescription($id: ID!) { jobApplication(id: $id) { description } }`,
{ id: app.id },
);
descriptions.value[app.id] = data.jobApplication?.description ?? "";
descriptions.value[app.id] = await store.fetchDescription(app.id);
} catch (err) {
descriptionId.value = null;
fail(err);
@@ -249,11 +159,7 @@ async function deleteApplication(app) {
if (!confirm(`Delete the ${app.jobTitle} application at ${app.company}?`))
return;
try {
await gql(
`mutation DeleteJobApplication($id: ID!) { deleteJobApplication(id: $id) }`,
{ id: app.id },
);
applications.value = applications.value.filter((a) => a.id !== app.id);
await store.remove(app.id);
error.value = "";
} catch (err) {
fail(err);
@@ -297,95 +203,6 @@ function exportCsv() {
URL.revokeObjectURL(url);
}
async function fetchReferences() {
try {
const data = await gql(`query { jobAppReferences { ${REF_FIELDS} } }`);
references.value = data.jobAppReferences;
} catch (err) {
fail(err);
}
}
async function createReference() {
if (!refForm.value.label || !refForm.value.value) return;
try {
const input = {
category: refForm.value.category,
label: refForm.value.label,
value: refForm.value.value,
};
const data = await gql(
`mutation CreateJobAppReference($input: CreateJobAppReferenceInput!) {
createJobAppReference(input: $input) { ${REF_FIELDS} }
}`,
{ input },
);
references.value.push(data.createJobAppReference);
refForm.value = { category: refForm.value.category, label: "", value: "" };
error.value = "";
} catch (err) {
fail(err);
}
}
function startRefEdit(ref) {
editingRefId.value = ref.id;
editRefForm.value = {
category: ref.category,
label: ref.label,
value: ref.value,
};
}
function cancelRefEdit() {
editingRefId.value = null;
editRefForm.value = {};
}
async function saveRefEdit(id) {
try {
const input = {
category: editRefForm.value.category || undefined,
label: editRefForm.value.label || undefined,
value: editRefForm.value.value || undefined,
};
const data = await gql(
`mutation UpdateJobAppReference($id: ID!, $input: UpdateJobAppReferenceInput!) {
updateJobAppReference(id: $id, input: $input) { ${REF_FIELDS} }
}`,
{ id, input },
);
const idx = references.value.findIndex((r) => r.id === id);
if (idx !== -1) references.value[idx] = data.updateJobAppReference;
editingRefId.value = null;
error.value = "";
} catch (err) {
fail(err);
}
}
async function deleteReference(ref) {
if (!confirm(`Delete the reference "${ref.label}"?`)) return;
try {
await gql(
`mutation DeleteJobAppReference($id: ID!) { deleteJobAppReference(id: $id) }`,
{ id: ref.id },
);
references.value = references.value.filter((r) => r.id !== ref.id);
error.value = "";
} catch (err) {
fail(err);
}
}
function refsByCategory(category) {
return references.value.filter((r) => r.category === category);
}
function copyToClipboard(text) {
navigator.clipboard.writeText(text);
}
function statusLabel(status) {
return (
STATUS_OPTIONS.find((s) => s.value === status?.toLowerCase())?.label ??
@@ -465,10 +282,7 @@ function toggleStatusFilter(status) {
statusFilter.value = statusFilter.value === status ? null : status;
}
onMounted(() => {
fetchApplications();
fetchReferences();
});
onMounted(fetchApplications);
</script>
<template>
@@ -506,134 +320,9 @@ onMounted(() => {
<button class="cv-btn cv-btn-sm" @click="error = ''">Dismiss</button>
</div>
<div class="ja-ref-section">
<h3 class="ja-ref-heading">Quick Reference</h3>
<div v-for="cat in REF_CATEGORIES" :key="cat" class="ja-ref-category">
<h4 class="ja-ref-cat-label">{{ cat }}</h4>
<div
v-for="ref in refsByCategory(cat)"
:key="ref.id"
class="ja-ref-item"
>
<template v-if="editingRefId !== ref.id">
<span class="ja-ref-label">{{ ref.label }}</span>
<span class="ja-ref-value" :title="ref.value">{{ ref.value }}</span>
<button
class="cv-btn cv-btn-sm"
@click="copyToClipboard(ref.value)"
title="Copy"
>
Copy
</button>
<button class="cv-btn cv-btn-sm" @click="startRefEdit(ref)">
Edit
</button>
<button
class="cv-btn cv-btn-sm cv-btn-danger"
@click="deleteReference(ref)"
>
Delete
</button>
</template>
<template v-else>
<select
v-model="editRefForm.category"
class="ja-input ja-input-sm ja-select"
>
<option v-for="c in REF_CATEGORIES" :key="c" :value="c">
{{ c }}
</option>
</select>
<input
v-model="editRefForm.label"
class="ja-input ja-input-sm"
placeholder="Label"
/>
<input
v-model="editRefForm.value"
class="ja-input ja-input-sm"
placeholder="Value"
/>
<button
class="cv-btn cv-btn-sm cv-btn-primary"
@click="saveRefEdit(ref.id)"
>
Save
</button>
<button class="cv-btn cv-btn-sm" @click="cancelRefEdit">
Cancel
</button>
</template>
</div>
<p v-if="!refsByCategory(cat).length" class="ja-ref-empty">
No {{ cat }} items yet.
</p>
</div>
<form class="ja-ref-form" @submit.prevent="createReference">
<select v-model="refForm.category" class="ja-input ja-select">
<option v-for="c in REF_CATEGORIES" :key="c" :value="c">
{{ c }}
</option>
</select>
<input
v-model="refForm.label"
class="ja-input"
placeholder="Label *"
required
/>
<input
v-model="refForm.value"
class="ja-input"
placeholder="Value *"
required
/>
<button type="submit" class="cv-btn cv-btn-primary">Add</button>
</form>
</div>
<JobReferences @fail="fail" @ok="clearError" />
<form class="ja-form" @submit.prevent="createApplication">
<div class="ja-form-row">
<input
v-model="form.jobTitle"
class="ja-input"
placeholder="Job title *"
required
/>
<input
v-model="form.company"
class="ja-input"
placeholder="Company *"
required
/>
<select v-model="form.status" class="ja-input ja-select">
<option v-for="s in STATUS_OPTIONS" :key="s.value" :value="s.value">
{{ s.label }}
</option>
</select>
</div>
<div class="ja-form-row">
<input
v-model="form.location"
class="ja-input"
placeholder="Location"
/>
<input v-model="form.url" class="ja-input" placeholder="URL" />
<input
v-model="form.appliedAt"
class="ja-input"
type="date"
title="Applied date"
/>
</div>
<div class="ja-form-row">
<textarea
v-model="form.notes"
class="ja-input ja-textarea"
placeholder="Notes"
/>
<button type="submit" class="cv-btn cv-btn-primary">Add</button>
</div>
</form>
<JobApplicationForm @fail="fail" @ok="clearError" />
<!-- Pipeline bar: counts at a glance, each one a filter toggle. -->
<div class="ja-pipeline" v-if="applications.length">
@@ -835,7 +524,9 @@ onMounted(() => {
</template>
<style scoped>
/* Colours are the paper palette from CVLayout.vue; buttons are .cv-btn from there too. */
/* Colours are the paper palette from CVLayout.vue; buttons are .cv-btn from
there too. The input classes (.ja-input, .ja-input-sm, .ja-select) are in
jobs-shared.css because the child components use them as well. */
.ja-root {
padding: 1.5rem;
border-top: 2px solid var(--color-ink-soft);
@@ -893,51 +584,6 @@ onMounted(() => {
font-size: 0.85rem;
}
/* Forms */
.ja-form {
display: flex;
flex-direction: column;
gap: 0.5rem;
margin-bottom: 1.5rem;
}
.ja-form-row {
display: flex;
gap: 0.5rem;
flex-wrap: wrap;
}
.ja-input {
padding: 0.35rem 0.6rem;
border: 1px solid var(--color-line);
border-radius: 4px;
font-size: 0.85rem;
background: var(--color-paper);
flex: 1;
min-width: 120px;
}
.ja-input:focus {
outline: none;
border-color: var(--color-ink-muted);
}
.ja-select {
cursor: pointer;
}
.ja-textarea {
resize: vertical;
min-height: 2.4rem;
}
.ja-input-sm {
padding: 0.2rem 0.4rem;
font-size: 0.8rem;
width: 100%;
min-width: 0;
}
.ja-edit-notes {
resize: vertical;
min-height: 3.5rem;
@@ -1139,70 +785,6 @@ onMounted(() => {
font-size: 0.9rem;
}
/* Quick-reference box */
.ja-ref-section {
margin-bottom: 1.5rem;
padding: 1rem;
border: 1px solid var(--color-line-soft);
border-radius: 6px;
background: var(--color-paper);
}
.ja-ref-heading {
font-size: 1rem;
font-weight: 600;
margin-bottom: 0.75rem;
color: var(--color-ink-soft);
}
.ja-ref-category {
margin-bottom: 0.75rem;
}
.ja-ref-cat-label {
font-size: 0.85rem;
font-weight: 600;
color: var(--color-ink-muted);
text-transform: capitalize;
margin-bottom: 0.35rem;
}
.ja-ref-item {
display: flex;
align-items: center;
gap: 0.5rem;
padding: 0.3rem 0;
}
.ja-ref-label {
font-size: 0.85rem;
font-weight: 500;
color: var(--color-ink-soft);
min-width: 80px;
}
.ja-ref-value {
font-size: 0.85rem;
color: var(--color-ink-muted);
flex: 1;
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
}
.ja-ref-empty {
font-size: 0.8rem;
color: var(--color-ink-faint);
margin: 0.2rem 0;
}
.ja-ref-form {
display: flex;
gap: 0.5rem;
margin-top: 0.75rem;
flex-wrap: wrap;
}
/* Seven columns plus an action cell will not fit a phone, so the table becomes
stacked cards with the header text carried by each cell's data-label. */
@media (max-width: 640px) {
+250
View File
@@ -0,0 +1,250 @@
<script setup>
/**
* The "Quick Reference" box on `/cv/jobs`: reusable profile/experience snippets
* to copy into application forms, with inline editing. Rendered only by
* JobApplications.vue; data comes from stores/jobAppReferences.js.
*
* It has no error display of its own — the page has one banner, in the parent,
* so failures are emitted as `fail` (with the error) and every successful
* mutation emits `ok` so the parent can clear a stale message.
*
* Its root sits inside the parent's `.ja-root`, which jobs-shared.css relies on.
*/
import { ref, onMounted } from "vue";
import { storeToRefs } from "pinia";
import { useJobAppReferencesStore } from "@/stores/jobAppReferences";
import "./jobs-shared.css";
const emit = defineEmits(["fail", "ok"]);
const store = useJobAppReferencesStore();
const { references } = storeToRefs(store);
const refForm = ref({ category: "profile", label: "", value: "" });
const editingRefId = ref(null);
const editRefForm = ref({});
const REF_CATEGORIES = ["profile", "experience"];
async function fetchReferences() {
// The store's fetch() records its failure instead of throwing.
await store.fetch();
if (store.error) emit("fail", store.error);
}
async function createReference() {
if (!refForm.value.label || !refForm.value.value) return;
try {
await store.create({
category: refForm.value.category,
label: refForm.value.label,
value: refForm.value.value,
});
refForm.value = { category: refForm.value.category, label: "", value: "" };
emit("ok");
} catch (err) {
emit("fail", err);
}
}
function startRefEdit(ref) {
editingRefId.value = ref.id;
editRefForm.value = {
category: ref.category,
label: ref.label,
value: ref.value,
};
}
function cancelRefEdit() {
editingRefId.value = null;
editRefForm.value = {};
}
async function saveRefEdit(id) {
try {
await store.update(id, {
category: editRefForm.value.category || undefined,
label: editRefForm.value.label || undefined,
value: editRefForm.value.value || undefined,
});
editingRefId.value = null;
emit("ok");
} catch (err) {
emit("fail", err);
}
}
async function deleteReference(ref) {
if (!confirm(`Delete the reference "${ref.label}"?`)) return;
try {
await store.remove(ref.id);
emit("ok");
} catch (err) {
emit("fail", err);
}
}
function refsByCategory(category) {
return references.value.filter((r) => r.category === category);
}
function copyToClipboard(text) {
navigator.clipboard.writeText(text);
}
onMounted(fetchReferences);
</script>
<template>
<div class="ja-ref-section">
<h3 class="ja-ref-heading">Quick Reference</h3>
<div v-for="cat in REF_CATEGORIES" :key="cat" class="ja-ref-category">
<h4 class="ja-ref-cat-label">{{ cat }}</h4>
<div
v-for="ref in refsByCategory(cat)"
:key="ref.id"
class="ja-ref-item"
>
<template v-if="editingRefId !== ref.id">
<span class="ja-ref-label">{{ ref.label }}</span>
<span class="ja-ref-value" :title="ref.value">{{ ref.value }}</span>
<button
class="cv-btn cv-btn-sm"
@click="copyToClipboard(ref.value)"
title="Copy"
>
Copy
</button>
<button class="cv-btn cv-btn-sm" @click="startRefEdit(ref)">
Edit
</button>
<button
class="cv-btn cv-btn-sm cv-btn-danger"
@click="deleteReference(ref)"
>
Delete
</button>
</template>
<template v-else>
<select
v-model="editRefForm.category"
class="ja-input ja-input-sm ja-select"
>
<option v-for="c in REF_CATEGORIES" :key="c" :value="c">
{{ c }}
</option>
</select>
<input
v-model="editRefForm.label"
class="ja-input ja-input-sm"
placeholder="Label"
/>
<input
v-model="editRefForm.value"
class="ja-input ja-input-sm"
placeholder="Value"
/>
<button
class="cv-btn cv-btn-sm cv-btn-primary"
@click="saveRefEdit(ref.id)"
>
Save
</button>
<button class="cv-btn cv-btn-sm" @click="cancelRefEdit">
Cancel
</button>
</template>
</div>
<p v-if="!refsByCategory(cat).length" class="ja-ref-empty">
No {{ cat }} items yet.
</p>
</div>
<form class="ja-ref-form" @submit.prevent="createReference">
<select v-model="refForm.category" class="ja-input ja-select">
<option v-for="c in REF_CATEGORIES" :key="c" :value="c">
{{ c }}
</option>
</select>
<input
v-model="refForm.label"
class="ja-input"
placeholder="Label *"
required
/>
<input
v-model="refForm.value"
class="ja-input"
placeholder="Value *"
required
/>
<button type="submit" class="cv-btn cv-btn-primary">Add</button>
</form>
</div>
</template>
<style scoped>
/* Colours are the paper palette from CVLayout.vue; buttons are .cv-btn from
there too, and the inputs are styled by jobs-shared.css. */
.ja-ref-section {
margin-bottom: 1.5rem;
padding: 1rem;
border: 1px solid var(--color-line-soft);
border-radius: 6px;
background: var(--color-paper);
}
.ja-ref-heading {
font-size: 1rem;
font-weight: 600;
margin-bottom: 0.75rem;
color: var(--color-ink-soft);
}
.ja-ref-category {
margin-bottom: 0.75rem;
}
.ja-ref-cat-label {
font-size: 0.85rem;
font-weight: 600;
color: var(--color-ink-muted);
text-transform: capitalize;
margin-bottom: 0.35rem;
}
.ja-ref-item {
display: flex;
align-items: center;
gap: 0.5rem;
padding: 0.3rem 0;
}
.ja-ref-label {
font-size: 0.85rem;
font-weight: 500;
color: var(--color-ink-soft);
min-width: 80px;
}
.ja-ref-value {
font-size: 0.85rem;
color: var(--color-ink-muted);
flex: 1;
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
}
.ja-ref-empty {
font-size: 0.8rem;
color: var(--color-ink-faint);
margin: 0.2rem 0;
}
.ja-ref-form {
display: flex;
gap: 0.5rem;
margin-top: 0.75rem;
flex-wrap: wrap;
}
</style>
+31
View File
@@ -0,0 +1,31 @@
/**
* The job-application status vocabulary, as the tracker at /cv/jobs shows it.
*
* This is a COPY. The source of truth is server-side: `enum JobStatus` in
* backend/graph/schema/job_application.graphql, ranked by `statusOrder` in
* backend/services/email_sync.go (the email pipeline only ever moves a row
* forward through that order). The server rejects any value outside the enum,
* so a status added here alone cannot be saved — add it there first.
*
* There is a third copy in vue/public/job-capture.user.js (STATUS_LABELS). A
* userscript is a single file installed into the browser and cannot import
* modules, so it has to be kept in step by hand.
*
* Values are the lowercase keys that go over the wire; labels are display-only.
*/
export const STATUS_OPTIONS = [
// Captured from the browser but not applied to yet. No email produces it.
{ value: "saved", label: "Saved" },
{ value: "applied", label: "Applied" },
{ value: "screening", label: "Screening" },
{ value: "assessment", label: "Assessment" },
{ value: "interviewing", label: "Interviewing" },
{ value: "offer", label: "Offer" },
{ value: "rejected", label: "Rejected" },
{ value: "withdrawn", label: "Withdrawn" },
];
// Statuses still in play — used to decide whether a row is worth chasing.
// "saved" is absent on purpose: nobody owes a reply on a job not applied to.
export const OPEN_STATUSES = ["applied", "screening", "assessment", "interviewing"];
+39
View File
@@ -0,0 +1,39 @@
/*
* Form controls shared by the job tracker's components (JobApplications.vue and
* the JobReferences / JobApplicationForm components it renders).
*
* These lived in JobApplications.vue's scoped block until the page was split.
* Scoped styles stop at a child component's root element, so the inputs inside
* the children would have lost them; this file is imported by each component
* instead. It is unscoped, so every selector is prefixed with the page's
* `.ja-root` class — which also keeps the specificity at (0,2,0), the same as
* the scoped originals, so they still beat CVLayout's `.cv-layout input`.
*
* Colours are the paper palette from CVLayout.vue.
*/
.ja-root .ja-input {
padding: 0.35rem 0.6rem;
border: 1px solid var(--color-line);
border-radius: 4px;
font-size: 0.85rem;
background: var(--color-paper);
flex: 1;
min-width: 120px;
}
.ja-root .ja-input:focus {
outline: none;
border-color: var(--color-ink-muted);
}
.ja-root .ja-select {
cursor: pointer;
}
.ja-root .ja-input-sm {
padding: 0.2rem 0.4rem;
font-size: 0.8rem;
width: 100%;
min-width: 0;
}
+15 -10
View File
@@ -8,7 +8,7 @@
* the response to generating it, and replacing it needs no restart.
*/
import { ref, onMounted } from "vue";
import axios from "axios";
import { api } from "@/api";
import Button from "@/components/input/Button.vue";
import SecretReveal from "@/components/admin/SecretReveal.vue";
import "./env.css";
@@ -22,11 +22,12 @@ const newToken = ref("");
async function fetchCaptureToken() {
try {
capture.value = (await axios.get("/api/admin/capture-token")).data;
capture.value = await api.get("/admin/capture-token", {
fallback: "Failed to load the capture token state",
});
error.value = "";
} catch (err) {
error.value =
err.response?.data?.error || "Failed to load the capture token state";
error.value = err.message;
}
}
@@ -42,12 +43,14 @@ async function generate() {
return;
busy.value = true;
try {
const res = await axios.post("/api/admin/capture-token");
newToken.value = res.data.token;
capture.value = { set: true, createdAt: res.data.createdAt };
const res = await api.post("/admin/capture-token", undefined, {
fallback: "Failed to generate a token",
});
newToken.value = res.token;
capture.value = { set: true, createdAt: res.createdAt };
error.value = "";
} catch (err) {
error.value = err.response?.data?.error || "Failed to generate a token";
error.value = err.message;
} finally {
busy.value = false;
}
@@ -58,11 +61,13 @@ async function revoke() {
return;
busy.value = true;
try {
capture.value = (await axios.delete("/api/admin/capture-token")).data;
capture.value = await api.delete("/admin/capture-token", {
fallback: "Failed to revoke the token",
});
newToken.value = "";
error.value = "";
} catch (err) {
error.value = err.response?.data?.error || "Failed to revoke the token";
error.value = err.message;
} finally {
busy.value = false;
}
+7 -6
View File
@@ -10,7 +10,7 @@
*/
import Button from "@/components/input/Button.vue";
import { ref } from "vue";
import axios from "axios";
import { api } from "@/api";
const emit = defineEmits(["done", "cancel"]);
@@ -34,19 +34,20 @@ async function submit() {
const formData = new FormData();
formData.append("image", file);
try {
const res = await axios.post("/api/rowing", formData, {
const res = await api.post("/rowing", formData, {
headers: { "Content-Type": "multipart/form-data" },
fallback: "Upload failed",
});
// Time comes back as a Go time.Duration, i.e. nanoseconds.
const mins = Math.floor(res.data.Time / 1e9 / 60);
const secs = String(Math.floor((res.data.Time / 1e9) % 60)).padStart(
const mins = Math.floor(res.Time / 1e9 / 60);
const secs = String(Math.floor((res.Time / 1e9) % 60)).padStart(
2,
"0",
);
results.value[i].status = `${res.data.Distance}m in ${mins}:${secs}`;
results.value[i].status = `${res.Distance}m in ${mins}:${secs}`;
results.value[i].ok = true;
} catch (err) {
results.value[i].status = err.response?.data?.error || "Upload failed";
results.value[i].status = err.message;
results.value[i].ok = false;
}
}),
+6 -4
View File
@@ -10,7 +10,7 @@
* onMounted, which is the desired "refresh on tab change" behaviour.
*/
import { ref, onMounted, computed } from "vue";
import axios from "axios";
import { api } from "@/api";
import Button from "@/components/input/Button.vue";
const lines = ref([]);
@@ -20,11 +20,13 @@ const loadingLogs = ref(false);
async function fetchLogs() {
loadingLogs.value = true;
try {
const res = await axios.get("/api/admin/logs");
lines.value = res.data.lines;
const res = await api.get("/admin/logs", {
fallback: "Failed to load logs",
});
lines.value = res.lines;
logsError.value = "";
} catch (err) {
logsError.value = err.response?.data?.error || "Failed to load logs";
logsError.value = err.message;
} finally {
loadingLogs.value = false;
}
+20 -20
View File
@@ -16,7 +16,7 @@
* once from the response that created it.
*/
import { ref, reactive, computed, onMounted, onUnmounted } from "vue";
import axios from "axios";
import { api } from "@/api";
import Button from "@/components/input/Button.vue";
import SecretReveal from "@/components/admin/SecretReveal.vue";
import CaptureToken from "./CaptureToken.vue";
@@ -54,13 +54,15 @@ function resetDrafts() {
async function fetchEnv() {
try {
const res = await axios.get("/api/admin/env");
groups.value = res.data.groups;
status.value = res.data.status;
const res = await api.get("/admin/env", {
fallback: "Failed to load the environment",
});
groups.value = res.groups;
status.value = res.status;
error.value = "";
resetDrafts();
} catch (err) {
error.value = err.response?.data?.error || "Failed to load the environment";
error.value = err.message;
} finally {
loading.value = false;
}
@@ -137,19 +139,18 @@ async function apply() {
applying.value = true;
outcome.value = null;
try {
const res = await axios.put("/api/admin/env", body);
revealed.value = res.data.generated || {};
status.value = res.data.status;
awaitedId.value = res.data.status.id;
const res = await api.put("/admin/env", body, {
fallback: "Failed to queue the change",
});
revealed.value = res.generated || {};
status.value = res.status;
awaitedId.value = res.status.id;
// Staged secrets have been sent; do not keep them in the inputs.
resetDrafts();
startPolling();
} catch (err) {
applying.value = false;
outcome.value = {
ok: false,
text: err.response?.data?.error || "Failed to queue the change",
};
outcome.value = { ok: false, text: err.message };
}
}
@@ -165,12 +166,12 @@ function stopPolling() {
async function poll() {
let next;
try {
next = (await axios.get("/api/admin/env/status")).data;
next = await api.get("/admin/env/status");
} catch (err) {
// 401/403 after an apply means the change invalidated this session
// (rotating BACKEND_SECRET does). Anything else is the backend
// restarting, which is the apply working.
if ([401, 403].includes(err.response?.status)) {
if ([401, 403].includes(err.status)) {
stopPolling();
applying.value = false;
outcome.value = {
@@ -200,15 +201,14 @@ async function poll() {
async function cancelPending() {
try {
status.value = (await axios.delete("/api/admin/env/pending")).data;
status.value = await api.delete("/admin/env/pending", {
fallback: "Failed to withdraw the change",
});
stopPolling();
applying.value = false;
outcome.value = { ok: true, text: "Pending change withdrawn. Nothing was applied." };
} catch (err) {
outcome.value = {
ok: false,
text: err.response?.data?.error || "Failed to withdraw the change",
};
outcome.value = { ok: false, text: err.message };
}
}
+5
View File
@@ -17,6 +17,11 @@ import { useAuthStore } from "@/stores/auth";
import Button from "@/components/input/Button.vue";
const auth = useAuthStore();
// Nothing else on this route resolves the session: the guard only runs for
// admin routes and the home query is not issued here. Without this, someone
// already signed in who opens /admin/login directly would see the login form
// instead of the "Already signed in" card.
auth.ensureLoaded();
const router = useRouter();
const route = useRoute();
const username = ref("");
+8 -9
View File
@@ -5,7 +5,7 @@
*/
import Button from "@/components/input/Button.vue";
import { ref, onMounted } from "vue";
import axios from "axios";
import { api } from "@/api";
const songs = ref([]);
const files = ref([]);
@@ -14,8 +14,8 @@ const loading = ref(false);
async function fetchSongs() {
try {
const res = await axios.get("/api/radio/songs");
songs.value = res.data.songs;
const res = await api.get("/radio/songs");
songs.value = res.songs;
} catch (err) {
console.error(err);
}
@@ -39,13 +39,14 @@ async function upload() {
const formData = new FormData();
formData.append("file", file);
try {
await axios.post("/api/radio/upload", formData, {
await api.post("/radio/upload", formData, {
headers: { "Content-Type": "multipart/form-data" },
fallback: "Upload failed",
});
results.value[i].status = "Uploaded";
results.value[i].ok = true;
} catch (err) {
results.value[i].status = err.response?.data?.error || "Upload failed";
results.value[i].status = err.message;
results.value[i].ok = false;
}
}),
@@ -58,7 +59,7 @@ async function upload() {
async function deleteSong(name) {
try {
await axios.delete(`/api/radio/songs/${encodeURIComponent(name)}`);
await api.delete(`/radio/songs/${encodeURIComponent(name)}`);
await fetchSongs();
} catch (err) {
console.error(err);
@@ -68,9 +69,7 @@ async function deleteSong(name) {
async function toggleSong(song) {
const action = song.disabled ? "enable" : "disable";
try {
await axios.patch(
`/api/radio/songs/${encodeURIComponent(song.name)}/${action}`,
);
await api.patch(`/radio/songs/${encodeURIComponent(song.name)}/${action}`);
await fetchSongs();
} catch (err) {
console.error(err);
+4 -2
View File
@@ -27,12 +27,14 @@ const CreateRowing = defineAsyncComponent(
);
const store = useHomeDataStore();
const { loaded, error, rowingSessions } = storeToRefs(store);
const { settled, error, rowingSessions } = storeToRefs(store);
const showCreate = ref(false);
// slice() first: reverse() mutates in place and would reorder the store's array.
const rows = computed(() => rowingSessions.value.slice().reverse());
const loading = computed(() => !loaded.value);
// `settled`, not `loaded`: a home query that fails never sets `loaded`, and the
// error branch below would be unreachable behind a permanent spinner.
const loading = computed(() => !settled.value);
const metric = ref("distance");
const hovered = ref(null);
+2 -3
View File
@@ -10,6 +10,7 @@ import { computed, onMounted } from "vue";
import { useSongsStore } from "@/stores/songs";
import { useAuthStore } from "@/stores/auth";
import { useRotation } from "@/js/useRotation";
import { api } from "@/api";
const ROTATE_MS = 5000;
const REFRESH_MS = 120000;
@@ -38,9 +39,7 @@ const showReconnect = computed(
// stays as it was.
async function reconnect() {
try {
const res = await fetch("/api/spotify/auth");
if (!res.ok) return;
const { url } = await res.json();
const { url } = await api.get("/spotify/auth");
window.location.href = url;
} catch (err) {
console.error("Cannot start Spotify re-authentication", err);
+5 -4
View File
@@ -1,9 +1,10 @@
<script setup>
/**
* Steam widget on /stp: online status plus a rotation through recent games
* (5s rotation, 5-minute re-poll, both from useRotation()). `loaded` comes from
* (5s rotation, 5-minute re-poll, both from useRotation()). `settled` comes from
* homeData so the widget can tell "not fetched yet" from "fetched, nothing to
* show".
* show" — and, unlike `loaded`, it also turns true when the fetch fails, so the
* widget cannot sit on "Loading..." forever.
*/
import { computed } from "vue";
import { storeToRefs } from "pinia";
@@ -18,7 +19,7 @@ const REFRESH_MS = 5 * 60 * 1000;
const steamStore = useSteamStore();
const { steamStatus } = storeToRefs(steamStore);
const homeData = useHomeDataStore();
const { loaded } = storeToRefs(homeData);
const { settled } = storeToRefs(homeData);
const { idx, next: nextGame } = useRotation(
() => steamStatus.value.recentGames,
@@ -47,7 +48,7 @@ function formatHours(minutes) {
</span>
</Header>
<div v-if="!loaded" class="p-2 text-sm">Loading...</div>
<div v-if="!settled" class="p-2 text-sm">Loading...</div>
<div v-else-if="game" class="game-container">
<Transition name="fade">