Split the job tracker out of web_server into its own app
Test and publish / test (push) Successful in 6m39s
Test and publish / publish (push) Failing after 0s

The applications tracker, leads inbox, email pipeline and capture userscript
move here from web_server's backend, Python service and Vue app, as one Go
binary that serves its own Vue SPA under /jobs/.

- The Go services, resolvers and tests move over almost unchanged.
- The three Claude calls are ported from Python to Go (internal/claude),
  with the same prompts, per-model request shaping and error messages.
- There is no login: internal/auth asks the site backend's
  /auth/validate-admin with the visitor's cookies, and relays refreshed
  cookies back.
- A Settings page replaces the admin-panel capture token card and adds the
  Microsoft sign-in link and a manual email sync.
- The userscript is 2.0.0, at /jobs/, and migrates a saved API base.
- Dockerfile, a standalone compose with Postgres, Makefile, and a Gitea CI
  workflow that tests and publishes the image.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
This commit is contained in:
2026-10-14 16:24:16 +01:00
co-authored by Claude Opus 5.5
commit 67cb8137f9
88 changed files with 22715 additions and 0 deletions
+10
View File
@@ -0,0 +1,10 @@
<script setup>
/**
* Root component. Each page draws its own header, so this is only the outlet.
*/
import { RouterView } from "vue-router";
</script>
<template>
<RouterView />
</template>
+72
View File
@@ -0,0 +1,72 @@
/**
* The REST half of the API client, beside graphql.js: a thin axios wrapper for
* the tracker's JSON endpoints under /jobs/api that are not GraphQL (the
* capture token and the email sync controls on the Settings page).
*
* It does two things a bare axios call does not:
* - prefixes the API base, so callers name the route
* (`api.get("/admin/capture-token")`);
* - turns a failure into an ApiError whose `message` is the server's
* `{"error": "..."}` body when there is one.
*
* Resolves to the parsed response body, not the axios response. A 401 means
* the main site's session has lapsed, and sends the browser to its login.
*/
import axios from "axios";
import { goToLogin } from "@/session";
export class ApiError extends Error {
/**
* @param {string} message
* @param {number|undefined} status HTTP status; undefined when no response
* arrived at all (network down, backend restarting)
* @param {*} data the parsed error body, if any
*/
constructor(message, status, data) {
super(message);
this.name = "ApiError";
this.status = status;
this.data = data;
}
}
/**
* @param {string} method
* @param {string} path route below the API base, with its leading slash
* @param {object} [options]
* @param {*} [options.body] JSON-serialisable body, or a FormData for
* multipart uploads (axios sets the boundary itself)
* @param {string} [options.fallback] message to use when the backend sent no
* `error` string — callers pass the sentence their UI shows
* Any other option (`headers`, `params`, `onUploadProgress`, `signal`, …) is
* handed to axios unchanged.
*/
async function request(method, path, { body, fallback, ...config } = {}) {
try {
const res = await axios.request({
method,
url: `${import.meta.env.BASE_URL}api${path}`,
data: body,
...config,
});
return res.data;
} catch (err) {
if (err.response?.status === 401) goToLogin();
const data = err.response?.data;
const serverMessage = typeof data?.error === "string" ? data.error : "";
throw new ApiError(
serverMessage || fallback || err.message,
err.response?.status,
data,
);
}
}
export const api = {
get: (path, options) => request("get", path, options),
delete: (path, options) => request("delete", path, options),
post: (path, body, options) => request("post", path, { ...options, body }),
put: (path, body, options) => request("put", path, { ...options, body }),
patch: (path, body, options) => request("patch", path, { ...options, body }),
};
+142
View File
@@ -0,0 +1,142 @@
/*
* Global stylesheet: the tracker's whole look outside the components.
*
* Ported from the main site, where these pages ran inside CVLayout.vue, which
* re-pointed the site's dark design tokens to ink-on-paper values. This app is
* only ever light, so the paper palette is declared directly and the base
* element styles below are what that layout produced.
*
* Tailwind is here for its preflight reset, which the components were written
* against (box-sizing, zeroed margins, unstyled buttons). They use no utility
* classes; their own scoped <style> blocks do the layout.
*/
@import "tailwindcss";
@font-face {
font-family: "big_noodle_titling";
src: url("/jobs/fonts/big_noodle_titling.woff2") format("woff2");
font-weight: normal;
font-style: normal;
font-display: swap;
}
@font-face {
font-family: "CreatoDisplay";
src: url("/jobs/fonts/CreatoDisplay-Bold.woff2") format("woff2");
font-weight: normal;
font-style: normal;
font-display: swap;
}
/* `static` = always emit these variables, because component <style> blocks
reference them with var(). */
@theme static {
/* Paper palette */
--color-ink: #111;
--color-ink-soft: #333;
--color-ink-muted: #555;
--color-ink-faint: #999;
--color-ink-link: #0066cc;
--color-ink-danger: #c00;
--color-paper: #fff;
--color-paper-tint: #f5f5f5;
--color-paper-shade: #eee;
--color-line: #ccc;
--color-line-soft: #e0e0e0;
--font-heading: "big_noodle_titling", sans-serif;
--font-body: "CreatoDisplay", sans-serif;
--default-font-family: var(--font-body);
}
body {
margin: 0 auto;
width: 100%;
min-height: 100vh;
overflow-x: hidden;
background: var(--color-paper-tint);
color: var(--color-ink);
}
h1,
h2,
h3,
h4 {
margin: 0;
font-family: var(--font-heading);
color: var(--color-ink);
}
h1 {
font-size: 1.5rem;
}
h2 {
font-size: 1.25rem;
}
h3,
h4 {
font-size: 1.125rem;
}
p,
small,
code,
ul,
li,
a {
color: var(--color-ink);
}
input,
textarea {
color: var(--color-ink);
background: var(--color-paper);
border: 1px solid var(--color-line);
}
input::placeholder,
textarea::placeholder {
color: var(--color-ink-faint);
opacity: 1;
}
/* Buttons shared by every page */
.cv-btn {
padding: 0.4rem 1rem;
border: 1px solid var(--color-ink-soft);
border-radius: 4px;
background: var(--color-paper);
color: var(--color-ink-soft);
cursor: pointer;
font-size: 0.9rem;
white-space: nowrap;
text-decoration: none;
transition:
background 0.15s,
color 0.15s;
}
.cv-btn:hover {
background: var(--color-paper-shade);
}
.cv-btn:disabled {
opacity: 0.5;
cursor: default;
}
.cv-btn-sm {
padding: 0.2rem 0.55rem;
font-size: 0.8rem;
}
.cv-btn-primary,
.cv-btn.active {
background: var(--color-ink-soft);
color: var(--color-paper);
}
.cv-btn-primary:hover {
background: var(--color-ink-muted);
}
.cv-btn-danger {
border-color: var(--color-ink-danger);
color: var(--color-ink-danger);
}
.cv-btn-danger:hover {
background: #fee;
}
+22
View File
@@ -0,0 +1,22 @@
/**
* The app's entire GraphQL client: a thin axios POST to the tracker's
* /jobs/api/graphql. Every Pinia store goes through this; there is no cache
* or normalisation layer.
*
* Auth rides along in the main site's HTTP-only cookies, which the browser
* sends because the request is same-origin (nginx in production, the Vite
* proxy in dev). A lapsed session sends the browser to the site's login.
*/
import axios from "axios";
import { ADMIN_REQUIRED, goToLogin } from "@/session";
export async function gql(query, variables = {}) {
const res = await axios.post(`${import.meta.env.BASE_URL}api/graphql`, { query, variables });
const errors = res.data.errors;
if (errors?.some((e) => e.message === ADMIN_REQUIRED)) {
goToLogin();
}
if (errors && !res.data.data) throw new Error(errors[0].message);
return res.data.data;
}
+11
View File
@@ -0,0 +1,11 @@
/**
* App entry point. Mounts <App> on #app with the router and a fresh Pinia.
*/
import { createApp } from "vue";
import { createPinia } from "pinia";
import App from "./App.vue";
import router from "./router";
import "./assets/styles.css";
createApp(App).use(router).use(createPinia()).mount("#app");
+19
View File
@@ -0,0 +1,19 @@
/**
* Routes, under the app's base path (/jobs/, from vite.config.js).
*
* There is no login guard: the tracker borrows the main site's session, and a
* page whose first request is refused sends the browser to the site's login
* (session.js). Every page loads its data on mount, so that is immediate.
*/
import { createRouter, createWebHistory } from "vue-router";
export default createRouter({
history: createWebHistory(import.meta.env.BASE_URL),
routes: [
{ path: "/", name: "tracker", component: () => import("@/views/JobApplications.vue") },
{ path: "/leads", name: "leads", component: () => import("@/views/JobLeads.vue") },
{ path: "/settings", name: "settings", component: () => import("@/views/Settings.vue") },
{ path: "/:pathMatch(.*)*", redirect: "/" },
],
});
+18
View File
@@ -0,0 +1,18 @@
/**
* What to do when the tracker says the caller is not the admin.
*
* The tracker has no login of its own: it borrows the main site's session
* (internal/auth on the server). By the time a request is refused, the server
* has already tried the site's refresh token on our behalf, so there is
* nothing left to retry here — the session is gone and the only way back is
* the site's login page, which returns to this page afterwards (Login.vue
* follows `?redirect=` with a full page load for paths outside its own app).
*/
// The message the @admin directive and the REST admin check both send.
export const ADMIN_REQUIRED = "admin access required";
export function goToLogin() {
const here = window.location.pathname + window.location.search;
window.location.assign(`/admin/login?redirect=${encodeURIComponent(here)}`);
}
+123
View File
@@ -0,0 +1,123 @@
/**
* Factory for the "CRUD store" pattern shared by stores/places.js,
* jobApplications.js and jobAppReferences.js.
*
* Each of those is one GraphQL type with the schema's standard quartet — a list
* query, `create<Type>(input:)`, `update<Type>(id:, input:)` and
* `delete<Type>(id:)` — plus a local array that is patched after each mutation
* instead of being refetched. The operation and input-type names are derived
* from `type` because the schema is consistent about them
* (`Create<Type>Input`, `Update<Type>Input`); a type that breaks the convention
* should not be forced through here.
*
* `fields` is interpolated into every query and mutation so the selection set
* can never drift between them.
*
* Error contract, which callers rely on: fetch() never throws — it records the
* failure on `error` — because it is fired from lifecycle hooks with nothing to
* catch it. create/update/remove DO throw, so the form or row that triggered
* them can show the message and keep the user's typing.
*/
import { defineStore } from "pinia";
import { ref } from "vue";
import { gql } from "@/graphql";
/**
* @param {string} id Pinia store id
* @param {object} options
* @param {string} options.type GraphQL type name, e.g. "Place"
* @param {string} options.list list query field, e.g. "places"
* @param {string} options.fields selection set shared by every operation
* @param {string} [options.itemsKey] name the array is exposed under (defaults
* to `list`); components import it by that name
* @param {"prepend"|"append"} [options.insert] where create() puts the new row
* locally, matching the order the list query returns
* @param {"object"|"boolean"} [options.deleteReturns] what the delete mutation
* returns. An object type needs a selection set and a scalar must not have
* one, so the mutation text differs; the schema has both kinds.
* @param {(ctx: object) => object} [options.extend] extra state/actions merged
* into the store; receives the base members
*/
export function createCrudStore(
id,
{
type,
list,
fields,
itemsKey = list,
insert = "prepend",
deleteReturns = "object",
extend,
},
) {
const deleteSelection = deleteReturns === "object" ? "{ id }" : "";
return defineStore(id, () => {
const items = ref([]);
const loaded = ref(false);
const loading = ref(false);
const error = ref(null);
/** Load the whole list. Records failures on `error` rather than throwing. */
async function fetch() {
loading.value = true;
try {
const data = await gql(`query ${type}List { ${list} { ${fields} } }`);
items.value = data[list] || [];
loaded.value = true;
error.value = null;
} catch (err) {
error.value = err;
} finally {
loading.value = false;
}
}
/** Create a row and add it locally. Throws on failure. */
async function create(input) {
const data = await gql(
`mutation Create${type}($input: Create${type}Input!) {
create${type}(input: $input) { ${fields} }
}`,
{ input },
);
const created = data[`create${type}`];
items.value =
insert === "append"
? [...items.value, created]
: [created, ...items.value];
return created;
}
/** Patch a row and replace it in the local list. Throws on failure. */
async function update(rowId, input) {
const data = await gql(
`mutation Update${type}($id: ID!, $input: Update${type}Input!) {
update${type}(id: $id, input: $input) { ${fields} }
}`,
{ id: rowId, input },
);
const updated = data[`update${type}`];
const idx = items.value.findIndex((item) => item.id === rowId);
if (idx >= 0) items.value[idx] = updated;
return updated;
}
/** Delete a row and drop it from the local list. Throws on failure. */
async function remove(rowId) {
await gql(
`mutation Delete${type}($id: ID!) { delete${type}(id: $id) ${deleteSelection} }`,
{ id: rowId },
);
items.value = items.value.filter((item) => item.id !== rowId);
}
const base = { loaded, loading, error, fetch, create, update, remove };
return {
[itemsKey]: items,
...base,
...(extend ? extend({ items, ...base }) : {}),
};
});
}
+21
View File
@@ -0,0 +1,21 @@
/**
* The "Quick Reference" snippets on /jobs/ (reusable profile/experience text
* to paste into application forms) — CRUD built on createCrudStore().
*
* A separate table from the applications themselves; the two only share a page.
*/
import { createCrudStore } from "@/stores/createCrudStore";
const REF_FIELDS = `id category label value sortOrder createdAt`;
export const useJobAppReferencesStore = createCrudStore("jobAppReferences", {
type: "JobAppReference",
list: "jobAppReferences",
itemsKey: "references",
fields: REF_FIELDS,
// The list comes back in sortOrder/creation order, so new rows go last.
insert: "append",
// deleteJobAppReference returns Boolean!, and errors for an id that is gone.
deleteReturns: "boolean",
});
+39
View File
@@ -0,0 +1,39 @@
/**
* Job applications for the tracker at /jobs/ — CRUD built on
* createCrudStore(), plus the on-demand posting text.
*
* Admin-only on the server, and only that one page uses it, so nothing fetches
* it until the view mounts.
*/
import { createCrudStore } from "@/stores/createCrudStore";
import { gql } from "@/graphql";
// `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`;
export const useJobApplicationsStore = createCrudStore("jobApplications", {
type: "JobApplication",
list: "jobApplications",
itemsKey: "applications",
fields: APP_FIELDS,
insert: "prepend",
// deleteJobApplication returns Boolean!, and errors for an id that is gone.
deleteReturns: "boolean",
extend: () => ({
/**
* The captured posting text for one row; `""` when none was saved. Throws
* on failure. Not cached here: the view keeps its own per-visit cache, so
* returning to the page re-reads a posting the userscript may have
* replaced.
*/
async fetchDescription(id) {
const data = await gql(
`query JobDescription($id: ID!) { jobApplication(id: $id) { description } }`,
{ id },
);
return data.jobApplication?.description ?? "";
},
}),
});
+121
View File
@@ -0,0 +1,121 @@
/**
* Job leads for the inbox at /jobs/leads: postings the server's fetcher found
* (internal/services/job_leads.go), which are dismissed or promoted into the
* tracker from that page.
*
* Not a createCrudStore(): leads are never created or edited from the browser.
* The mutations here move a lead between its three states, and each returns
* the lead so the local row is replaced rather than the list refetched.
*
* Error contract matches the CRUD stores: fetch() and fetchStatus() record a
* failure on `error` and never throw, because they run from lifecycle hooks
* and a poll timer; everything else throws.
*/
import { defineStore } from "pinia";
import { ref } from "vue";
import { gql } from "@/graphql";
// `description` is deliberately not here: it is the full text of the posting
// and is fetched per lead when asked for, as on the tracker.
const LEAD_FIELDS = `id createdAt sourceKind jobTitle company location url postedAt lastSeenAt matched state score scoreReasons scoredAt jobAppId`;
export const useJobLeadsStore = defineStore("jobLeads", () => {
const leads = ref([]);
const loading = ref(false);
const error = ref(null);
// { running, lastRunAt, lastError } for the fetcher; null until first read.
const status = ref(null);
/**
* Load every lead, all states. `includeUnmatched` also returns the ones the
* keyword pre-filter rejected, which is most of a company board.
*/
async function fetch({ includeUnmatched = false } = {}) {
loading.value = true;
try {
const data = await gql(
`query JobLeads($includeUnmatched: Boolean) {
jobLeads(includeUnmatched: $includeUnmatched) { ${LEAD_FIELDS} }
}`,
{ includeUnmatched },
);
leads.value = data.jobLeads || [];
error.value = null;
} catch (err) {
error.value = err;
} finally {
loading.value = false;
}
}
function replace(lead) {
const idx = leads.value.findIndex((l) => l.id === lead.id);
if (idx >= 0) leads.value[idx] = lead;
return lead;
}
async function transition(mutation, id) {
const data = await gql(
`mutation ${mutation}($id: ID!) { ${mutation}(id: $id) { ${LEAD_FIELDS} } }`,
{ id },
);
return replace(data[mutation]);
}
/** Each returns the updated lead and throws on failure. */
const dismiss = (id) => transition("dismissJobLead", id);
const restore = (id) => transition("restoreJobLead", id);
/** Adds the lead to the tracker as a saved application. */
const promote = (id) => transition("promoteJobLead", id);
/** The posting text for one lead; `""` when the source gave none. Throws. */
async function fetchDescription(id) {
const data = await gql(
`query JobLeadDescription($id: ID!) { jobLead(id: $id) { description } }`,
{ id },
);
return data.jobLead?.description ?? "";
}
async function fetchStatus() {
try {
const data = await gql(`query JobLeadSyncStatus { jobLeadSyncStatus { running lastRunAt lastError } }`);
status.value = data.jobLeadSyncStatus;
} catch (err) {
error.value = err;
}
return status.value;
}
/**
* Start a fetch-and-score run on the server. Resolves at once — true if it
* started, false if one was already going — and the caller polls
* fetchStatus() to see it finish. Throws on failure.
*/
async function runSync() {
const data = await gql(`mutation RunJobLeadSync { runJobLeadSync }`);
return data.runJobLeadSync;
}
/**
* Score every unscored lead in the inbox without polling any source. Same
* contract as runSync(): resolves at once, and fetchStatus() shows it finish.
*/
async function scoreAll() {
const data = await gql(`mutation ScoreJobLeads { scoreJobLeads }`);
return data.scoreJobLeads;
}
/**
* Score every inbox lead again, scored or not — for after the profile or
* the model has changed. Same contract as runSync(). Each lead keeps its old
* score until its new one lands, so the list never goes blank.
*/
async function rescoreAll() {
const data = await gql(`mutation RescoreJobLeads { rescoreJobLeads }`);
return data.rescoreJobLeads;
}
return { leads, loading, error, status, fetch, dismiss, restore, promote, fetchDescription, fetchStatus, runSync, scoreAll, rescoreAll };
});
+44
View File
@@ -0,0 +1,44 @@
/**
* The single search profile on /jobs/leads: the free text every lead is scored
* against, the keyword lists behind the pre-filter, and the inbox's minimum
* score. One row on the server, so this is a fetch and a save rather than a
* createCrudStore() list.
*
* Error contract matches the CRUD stores: fetch() records its failure on
* `error` and never throws; save() throws so the form can keep the typing.
*/
import { defineStore } from "pinia";
import { ref } from "vue";
import { gql } from "@/graphql";
const PROFILE_FIELDS = `profile includeKeywords excludeKeywords locations minScore updatedAt`;
export const useJobSearchProfileStore = defineStore("jobSearchProfile", () => {
const profile = ref(null);
const error = ref(null);
async function fetch() {
try {
const data = await gql(`query JobSearchProfile { jobSearchProfile { ${PROFILE_FIELDS} } }`);
profile.value = data.jobSearchProfile;
error.value = null;
} catch (err) {
error.value = err;
}
}
/** Save the edited fields. Throws on failure. */
async function save(input) {
const data = await gql(
`mutation UpdateJobSearchProfile($input: UpdateJobSearchProfileInput!) {
updateJobSearchProfile(input: $input) { ${PROFILE_FIELDS} }
}`,
{ input },
);
profile.value = data.updateJobSearchProfile;
return profile.value;
}
return { profile, error, fetch, save };
});
+24
View File
@@ -0,0 +1,24 @@
/**
* The places the lead fetcher polls, edited on /jobs/leads — CRUD built on
* createCrudStore().
*
* `lastFetchedAt`, `lastCount` and `lastError` are written by the fetcher on
* the server, not by any mutation here, so the page calls fetch() again after
* a run to see them move.
*/
import { createCrudStore } from "@/stores/createCrudStore";
const SOURCE_FIELDS = `id kind label token query location enabled lastFetchedAt lastCount lastError`;
export const useJobSourcesStore = createCrudStore("jobSources", {
type: "JobSource",
list: "jobSources",
itemsKey: "sources",
fields: SOURCE_FIELDS,
// The list comes back ordered by label; a new row goes last until the next
// fetch sorts it into place.
insert: "append",
// deleteJobSource returns Boolean!, and errors for an id that is gone.
deleteReturns: "boolean",
});
+129
View File
@@ -0,0 +1,129 @@
<script setup>
/**
* The "add an application" form on `/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>
+846
View File
@@ -0,0 +1,846 @@
<script setup>
/**
* Route `/jobs/` — a private tracker for job
* applications and for the reusable reference snippets that feed the CV copy.
*
* 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 three places that are not this page: the email
* pipeline, the browser userscript in `public/job-capture.user.js`, which the
* header links to for installing, and the leads inbox at `/jobs/leads`
* (JobLeads.vue), where tracking a lead adds it here as Saved.
*/
import { ref, computed, onMounted } from "vue";
import { RouterLink } from "vue-router";
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";
// Served from web/public/ under the app's base path (/jobs/).
const userscriptUrl = `${import.meta.env.BASE_URL}job-capture.user.js`;
const store = useJobApplicationsStore();
const { applications } = storeToRefs(store);
const editingId = ref(null);
const editForm = ref({});
const error = ref("");
const STALE_DAYS = 14;
// 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);
const descriptions = ref({});
// Filter/sort state. All of it runs over the already-loaded array — the query
// has no arguments and the dataset is one person's applications.
const search = ref("");
const statusFilter = ref(null);
const sortKey = ref("updatedAt");
const sortDir = ref("desc");
function fail(err) {
console.error(err);
// The realistic failure here is a lapsed 7-day cookie: the router guard only
// checks the in-memory admin flag, so every mutation returns "admin access
// required" while the page still looks signed in.
error.value = String(err?.message ?? err);
}
function clearError() {
error.value = "";
}
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) {
// Switching rows mid-edit would throw away unsaved typing silently, and the
// Edit button sits in every row, so the misclick is easy to make.
if (editingId.value !== null && editingId.value !== app.id && isEditDirty()) {
if (!confirm("Discard unsaved changes to the row you are editing?")) return;
}
editingId.value = app.id;
editForm.value = {
jobTitle: app.jobTitle,
company: app.company,
location: app.location ?? "",
url: app.url ?? "",
status: app.status,
notes: app.notes ?? "",
appliedAt: app.appliedAt ? app.appliedAt.substring(0, 10) : "",
};
}
function isEditDirty() {
const app = applications.value.find((a) => a.id === editingId.value);
if (!app) return false;
const e = editForm.value;
return (
e.jobTitle !== app.jobTitle ||
e.company !== app.company ||
e.location !== (app.location ?? "") ||
e.url !== (app.url ?? "") ||
e.status !== app.status ||
e.notes !== (app.notes ?? "") ||
e.appliedAt !== (app.appliedAt ? app.appliedAt.substring(0, 10) : "")
);
}
function cancelEdit() {
editingId.value = null;
editForm.value = {};
}
async function saveEdit(id) {
try {
// Optional fields send `''` rather than `undefined` when emptied: the
// resolver skips fields that are absent, so `|| undefined` would turn
// "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.
await store.update(id, {
jobTitle: editForm.value.jobTitle,
company: editForm.value.company,
status: editForm.value.status,
location: editForm.value.location ?? "",
url: editForm.value.url ?? "",
notes: editForm.value.notes ?? "",
appliedAt: editForm.value.appliedAt
? new Date(editForm.value.appliedAt).toISOString()
: undefined,
});
editingId.value = null;
error.value = "";
} catch (err) {
// editingId is deliberately left set: the row stays open with the typing
// intact so the save can be retried.
fail(err);
}
}
/** Status is the field that changes most, so it is editable straight from the pill. */
async function setStatus(app, status) {
if (status === app.status) return;
try {
await store.update(app.id, { status });
error.value = "";
} catch (err) {
fail(err);
}
}
async function toggleDescription(app) {
if (descriptionId.value === app.id) {
descriptionId.value = null;
return;
}
descriptionId.value = app.id;
if (descriptions.value[app.id] !== undefined) return;
try {
descriptions.value[app.id] = await store.fetchDescription(app.id);
} catch (err) {
descriptionId.value = null;
fail(err);
}
}
async function deleteApplication(app) {
// Delete sits next to Edit in a 0.4rem-gap row and the notes it takes with
// it are not recoverable through any UI path.
if (!confirm(`Delete the ${app.jobTitle} application at ${app.company}?`))
return;
try {
await store.remove(app.id);
error.value = "";
} catch (err) {
fail(err);
}
}
function exportCsv() {
const headers = [
"Job Title",
"Company",
"Status",
"Location",
"URL",
"Applied",
"Notes",
"Created",
];
const rows = applications.value.map((a) => [
a.jobTitle,
a.company,
a.status,
a.location ?? "",
a.url ?? "",
a.appliedAt ? a.appliedAt.substring(0, 10) : "",
a.notes ?? "",
a.createdAt ? a.createdAt.substring(0, 10) : "",
]);
const escape = (v) => `"${String(v).replace(/"/g, '""')}"`;
// CRLF joins and a BOM because the destination for an exported tracker is
// Excel, which otherwise reads the UTF-8 as the local ANSI codepage (so "£"
// and accents arrive mangled) and mis-splits LF-only rows.
const csv =
"\ufeff" +
[headers, ...rows].map((r) => r.map(escape).join(",")).join("\r\n");
const blob = new Blob([csv], { type: "text/csv;charset=utf-8" });
const url = URL.createObjectURL(blob);
const a = document.createElement("a");
a.href = url;
a.download = "job_applications.csv";
a.click();
URL.revokeObjectURL(url);
}
function statusLabel(status) {
return (
STATUS_OPTIONS.find((s) => s.value === status?.toLowerCase())?.label ??
status
);
}
function statusClass(status) {
return `ja-badge-${status?.toLowerCase() ?? "unknown"}`;
}
/** Whole days between a timestamp and now; null when there is no date. */
function daysSince(iso) {
if (!iso) return null;
return Math.floor((Date.now() - new Date(iso).getTime()) / 86400000);
}
function ageLabel(app) {
// createdAt is the fallback: an application logged without an applied date
// still has a meaningful age.
const days = daysSince(app.appliedAt ?? app.createdAt);
return days === null ? "—" : days === 0 ? "today" : `${days}d`;
}
/** A row worth chasing: still open, and nothing has moved it in a fortnight. */
function isStale(app) {
if (!OPEN_STATUSES.includes(app.status?.toLowerCase())) return false;
const days = daysSince(app.updatedAt ?? app.createdAt);
return days !== null && days >= STALE_DAYS;
}
const statusCounts = computed(() => {
const counts = {};
for (const app of applications.value) {
const key = app.status?.toLowerCase();
counts[key] = (counts[key] ?? 0) + 1;
}
return counts;
});
const visibleApplications = computed(() => {
const q = search.value.trim().toLowerCase();
const rows = applications.value.filter((app) => {
if (statusFilter.value && app.status?.toLowerCase() !== statusFilter.value)
return false;
if (!q) return true;
// Notes are searched because the email pipeline appends its findings
// there, making them the de-facto history of the application.
return [app.jobTitle, app.company, app.location, app.notes]
.filter(Boolean)
.some((field) => field.toLowerCase().includes(q));
});
const dir = sortDir.value === "asc" ? 1 : -1;
return [...rows].sort((a, b) => {
const av = a[sortKey.value] ?? "";
const bv = b[sortKey.value] ?? "";
// Rows missing the sort field go last in either direction rather than
// clustering at whichever end empty-string happens to sort to.
if (!av && bv) return 1;
if (av && !bv) return -1;
if (av === bv) return 0;
return av > bv ? dir : -dir;
});
});
function toggleSort(key) {
if (sortKey.value === key) {
sortDir.value = sortDir.value === "asc" ? "desc" : "asc";
} else {
sortKey.value = key;
sortDir.value = "desc";
}
}
function toggleStatusFilter(status) {
statusFilter.value = statusFilter.value === status ? null : status;
}
onMounted(fetchApplications);
</script>
<template>
<div class="ja-root">
<div class="ja-header">
<div class="ja-header-left">
<!-- The CV is the main site's page, outside this app: a full load. -->
<a href="/cv" class="ja-back">← CV</a>
<h2 class="ja-heading">Job Applications</h2>
</div>
<div class="ja-header-right">
<!-- Postings the server found by itself; tracking one there adds it
to this page as Saved. -->
<RouterLink to="/leads" class="cv-btn ja-btn-link">Leads</RouterLink>
<RouterLink to="/settings" class="cv-btn ja-btn-link">Settings</RouterLink>
<!-- A plain link to a static file: Violentmonkey intercepts any
navigation to a URL ending in .user.js and offers to install it.
The token it then asks for is generated on the Settings page. -->
<a
class="cv-btn"
:href="userscriptUrl"
target="_blank"
rel="noopener"
title="Violentmonkey userscript that adds the job you are viewing. After installing, generate a capture token on the Settings page and paste it into the script's menu: Configure job capture."
>
Install capture script
</a>
<button
class="cv-btn"
@click="exportCsv"
:disabled="!applications.length"
>
Export CSV
</button>
</div>
</div>
<div v-if="error" class="ja-error" role="alert">
<span>{{ error }}</span>
<button class="cv-btn cv-btn-sm" @click="error = ''">Dismiss</button>
</div>
<JobReferences @fail="fail" @ok="clearError" />
<JobApplicationForm @fail="fail" @ok="clearError" />
<!-- Pipeline bar: counts at a glance, each one a filter toggle. -->
<div class="ja-pipeline" v-if="applications.length">
<button
v-for="s in STATUS_OPTIONS"
:key="s.value"
class="ja-pipe-tile"
:class="{ 'ja-pipe-active': statusFilter === s.value }"
@click="toggleStatusFilter(s.value)"
>
<span class="ja-pipe-count">{{ statusCounts[s.value] ?? 0 }}</span>
<span class="ja-pipe-label">{{ s.label }}</span>
</button>
</div>
<div class="ja-filterbar" v-if="applications.length">
<input
v-model="search"
class="ja-input"
type="search"
placeholder="Search title, company, location, notes…"
/>
<span class="ja-count"
>{{ visibleApplications.length }} / {{ applications.length }}</span
>
</div>
<table class="ja-table" v-if="visibleApplications.length">
<thead>
<tr>
<th class="ja-sortable" @click="toggleSort('jobTitle')">Title</th>
<th class="ja-sortable" @click="toggleSort('company')">Company</th>
<th class="ja-sortable" @click="toggleSort('status')">Status</th>
<th>Location</th>
<th class="ja-sortable" @click="toggleSort('appliedAt')">Applied</th>
<th>Notes</th>
<th></th>
</tr>
</thead>
<tbody>
<template v-for="app in visibleApplications" :key="app.id">
<tr v-if="editingId !== app.id" :class="{ 'ja-stale': isStale(app) }">
<td data-label="Title">
<a
v-if="app.url"
:href="app.url"
target="_blank"
rel="noopener"
class="ja-link"
>{{ app.jobTitle }}</a
>
<span v-else>{{ app.jobTitle }}</span>
</td>
<td data-label="Company">{{ app.company }}</td>
<td data-label="Status">
<select
class="ja-badge ja-badge-select"
:class="statusClass(app.status)"
:value="app.status?.toLowerCase()"
@change="setStatus(app, $event.target.value)"
>
<option
v-for="s in STATUS_OPTIONS"
:key="s.value"
:value="s.value"
>
{{ s.label }}
</option>
<!-- A status the pipeline wrote that we no longer list still
needs to render rather than showing a blank select. -->
<option
v-if="!STATUS_OPTIONS.some((s) => s.value === app.status)"
:value="app.status"
>
{{ statusLabel(app.status) }}
</option>
</select>
</td>
<td data-label="Location">{{ app.location || "—" }}</td>
<td
data-label="Applied"
:title="app.appliedAt ? app.appliedAt.substring(0, 10) : ''"
>
{{ ageLabel(app) }}
</td>
<td class="ja-notes-cell" data-label="Notes" :title="app.notes">
{{ app.notes ?? "" }}
</td>
<td class="ja-actions">
<button
class="cv-btn cv-btn-sm"
title="Posting text saved when the job was captured"
@click="toggleDescription(app)"
>
{{ descriptionId === app.id ? "Hide" : "Posting" }}
</button>
<button class="cv-btn cv-btn-sm" @click="startEdit(app)">
Edit
</button>
<button
class="cv-btn cv-btn-sm cv-btn-danger"
@click="deleteApplication(app)"
>
Delete
</button>
</td>
</tr>
<tr v-else class="ja-edit-row">
<td data-label="Title">
<input
v-model="editForm.jobTitle"
class="ja-input ja-input-sm"
placeholder="Job title"
/>
<input
v-model="editForm.url"
class="ja-input ja-input-sm"
placeholder="URL"
/>
</td>
<td data-label="Company">
<input
v-model="editForm.company"
class="ja-input ja-input-sm"
placeholder="Company"
/>
</td>
<td data-label="Status">
<select
v-model="editForm.status"
class="ja-input ja-input-sm ja-select"
>
<option
v-for="s in STATUS_OPTIONS"
:key="s.value"
:value="s.value"
>
{{ s.label }}
</option>
</select>
</td>
<td data-label="Location">
<input
v-model="editForm.location"
class="ja-input ja-input-sm"
placeholder="Location"
/>
</td>
<td data-label="Applied">
<input
v-model="editForm.appliedAt"
class="ja-input ja-input-sm"
type="date"
/>
</td>
<td data-label="Notes">
<!-- Textarea, not an input: the pipeline appends newline-joined
findings here, so notes are routinely multi-line. -->
<textarea
v-model="editForm.notes"
class="ja-input ja-input-sm ja-edit-notes"
placeholder="Notes"
/>
</td>
<td class="ja-actions">
<button
class="cv-btn cv-btn-sm cv-btn-primary"
@click="saveEdit(app.id)"
>
Save
</button>
<button class="cv-btn cv-btn-sm" @click="cancelEdit">
Cancel
</button>
</td>
</tr>
<tr v-if="descriptionId === app.id" class="ja-desc-row">
<td colspan="7">
<p v-if="descriptions[app.id] === undefined" class="ja-empty">
Loading…
</p>
<pre v-else-if="descriptions[app.id]" class="ja-desc">{{
descriptions[app.id]
}}</pre>
<p v-else class="ja-empty">
No posting text saved — only jobs added with the capture script
have one.
</p>
</td>
</tr>
</template>
</tbody>
</table>
<p v-else-if="applications.length" class="ja-empty">
No applications match this filter.
</p>
<p v-else class="ja-empty">No applications yet.</p>
</div>
</template>
<style scoped>
/* 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);
background: var(--color-paper-tint);
}
.ja-header {
display: flex;
align-items: center;
justify-content: space-between;
margin-bottom: 1rem;
}
.ja-header-left {
display: flex;
align-items: center;
gap: 1rem;
}
.ja-header-right {
display: flex;
align-items: center;
gap: 0.5rem;
flex-wrap: wrap;
justify-content: flex-end;
}
.ja-back {
font-size: 0.85rem;
color: var(--color-ink-muted);
text-decoration: none;
}
.ja-back:hover {
color: var(--color-ink);
}
.ja-btn-link {
text-decoration: none;
}
.ja-heading {
font-size: 1.1rem;
font-weight: 600;
color: var(--color-ink-soft);
}
.ja-error {
display: flex;
align-items: center;
justify-content: space-between;
gap: 1rem;
margin-bottom: 1rem;
padding: 0.5rem 0.75rem;
border: 1px solid #b91c1c;
border-radius: 4px;
background: #fef2f2;
color: #7f1d1d;
font-size: 0.85rem;
}
.ja-edit-notes {
resize: vertical;
min-height: 3.5rem;
}
/* Pipeline bar */
.ja-pipeline {
display: flex;
gap: 0.4rem;
flex-wrap: wrap;
margin-bottom: 0.75rem;
}
.ja-pipe-tile {
display: flex;
flex-direction: column;
align-items: center;
gap: 0.1rem;
padding: 0.4rem 0.7rem;
border: 1px solid var(--color-line-soft);
border-radius: 4px;
background: var(--color-paper);
cursor: pointer;
min-width: 68px;
}
.ja-pipe-tile:hover {
background: var(--color-paper-shade);
}
.ja-pipe-active {
border-color: var(--color-ink);
background: var(--color-paper-shade);
}
.ja-pipe-count {
font-size: 1rem;
font-weight: 600;
color: var(--color-ink-soft);
}
.ja-pipe-label {
font-size: 0.7rem;
color: var(--color-ink-muted);
}
.ja-filterbar {
display: flex;
align-items: center;
gap: 0.75rem;
margin-bottom: 0.75rem;
}
.ja-count {
font-size: 0.8rem;
color: var(--color-ink-faint);
white-space: nowrap;
}
/* Applications table */
.ja-table {
width: 100%;
border-collapse: collapse;
font-size: 0.85rem;
}
.ja-table th,
.ja-table td {
text-align: left;
padding: 0.45rem 0.6rem;
border-bottom: 1px solid var(--color-line-soft);
vertical-align: middle;
}
.ja-table th {
font-weight: 600;
color: var(--color-ink-muted);
background: var(--color-paper-shade);
}
.ja-sortable {
cursor: pointer;
user-select: none;
}
.ja-sortable:hover {
color: var(--color-ink);
}
.ja-table tr:hover td {
background: var(--color-paper-shade);
}
/* Open for a fortnight with nothing moving — the follow-up queue. */
.ja-stale td:first-child {
box-shadow: inset 3px 0 0 var(--color-ink-muted);
}
.ja-edit-row td {
padding: 0.3rem 0.4rem;
vertical-align: top;
}
.ja-actions {
display: flex;
gap: 0.4rem;
white-space: nowrap;
}
.ja-notes-cell {
max-width: 200px;
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
}
/* The posting text is long, so it scrolls inside the row instead of pushing
the rest of the table off the screen. */
.ja-desc {
max-height: 22rem;
overflow: auto;
margin: 0;
padding: 0.6rem;
border: 1px solid var(--color-line-soft);
border-radius: 4px;
background: var(--color-paper);
font-family: inherit;
font-size: 0.8rem;
white-space: pre-wrap;
}
.ja-desc-row:hover td {
background: transparent;
}
.ja-link {
color: var(--color-ink-link);
text-decoration: none;
}
.ja-link:hover {
text-decoration: underline;
}
/* Status pill, doubling as an inline select. Palette is CVLayout's paper
tokens with a per-status tint, rather than off-theme Tailwind colours. */
.ja-badge {
display: inline-block;
padding: 0.15rem 0.5rem;
border-radius: 10px;
font-size: 0.78rem;
font-weight: 500;
border: 1px solid var(--color-line);
background: var(--color-paper-shade);
color: var(--color-ink-soft);
}
.ja-badge-select {
cursor: pointer;
appearance: none;
}
.ja-badge-saved {
background: var(--color-paper);
color: var(--color-ink-muted);
border-style: dashed;
}
.ja-badge-applied {
background: #eef2ff;
color: #3730a3;
}
.ja-badge-screening {
background: #fefce8;
color: #854d0e;
}
.ja-badge-assessment {
background: #fff7ed;
color: #9a3412;
}
.ja-badge-interviewing {
background: #f5f3ff;
color: #5b21b6;
}
.ja-badge-offer {
background: #f0fdf4;
color: #166534;
}
.ja-badge-rejected {
background: #fef2f2;
color: #991b1b;
}
.ja-badge-withdrawn {
background: var(--color-paper-shade);
color: var(--color-ink-faint);
}
.ja-empty {
color: var(--color-ink-faint);
font-size: 0.9rem;
}
/* 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) {
.ja-table thead {
display: none;
}
.ja-table,
.ja-table tbody,
.ja-table tr,
.ja-table td {
display: block;
width: 100%;
}
.ja-table tr {
margin-bottom: 0.75rem;
border: 1px solid var(--color-line-soft);
border-radius: 6px;
background: var(--color-paper);
}
.ja-table td {
border-bottom: none;
padding: 0.3rem 0.6rem;
}
.ja-table td[data-label]::before {
content: attr(data-label);
display: block;
font-size: 0.7rem;
text-transform: uppercase;
color: var(--color-ink-faint);
}
.ja-notes-cell {
max-width: none;
white-space: pre-wrap;
overflow: visible;
}
.ja-stale td:first-child {
box-shadow: inset 0 3px 0 var(--color-ink-muted);
}
}
</style>
+660
View File
@@ -0,0 +1,660 @@
<script setup>
/**
* Route `/jobs/leads` — the leads inbox:
* postings the server found on its own, waiting to be tracked or dismissed.
*
* The server side is internal/services/job_leads.go. On a timer, or when
* "Check now" is pressed here, it polls the sources (JobSources.vue), keeps
* the postings that pass the keyword filter and has Claude score them against
* the profile (JobSearchProfile.vue). Nothing reaches the tracker at /jobs/
* until **Track** is pressed on a lead, which adds it there as Saved.
*
* This view owns the page frame, the single error banner, the run button and
* the list. Data access is in stores/jobLeads.js; nothing here calls gql().
*
* There are three server jobs. "Check now" polls the sources and scores up to
* forty new leads; "Score unscored" polls nothing and scores the whole
* backlog; "Rescore all" scores every inbox lead again, for after the profile
* or the model has changed. Each takes from seconds to many minutes, so the
* button does not wait: the server starts the job and this page polls its
* status, then reloads the list when it finishes.
*/
import { ref, computed, onMounted, onBeforeUnmount } from "vue";
import { RouterLink } from "vue-router";
import { storeToRefs } from "pinia";
import { useJobLeadsStore } from "@/stores/jobLeads";
import { useJobSearchProfileStore } from "@/stores/jobSearchProfile";
import JobSources from "./JobSources.vue";
import JobSearchProfile from "./JobSearchProfile.vue";
import "./jobs-shared.css";
const TABS = [
{ value: "new", label: "Inbox" },
{ value: "promoted", label: "Tracked" },
{ value: "dismissed", label: "Dismissed" },
];
// Labels for JobLead.sourceKind; a COPY of the kinds in JobSources.vue.
const SOURCE_LABELS = { greenhouse: "Greenhouse", lever: "Lever", ashby: "Ashby", adzuna: "Adzuna", reed: "Reed" };
const POLL_MS = 3000;
const store = useJobLeadsStore();
const { leads, status, loading } = storeToRefs(store);
const { profile } = storeToRefs(useJobSearchProfileStore());
const error = ref("");
const tab = ref("new");
const search = ref("");
// Two separate "show me the rest" switches: leads scored below the profile's
// minimum (already loaded, hidden here), and leads the keyword filter
// rejected (not loaded at all until asked for — that is most of every board).
const showLowScores = ref(false);
const showUnmatched = ref(false);
// "score" is the order the server sends; "posted" re-sorts here by the
// posting's own date.
const sortBy = ref("score");
const busyId = ref(null);
const sourcesBox = ref(null);
// The posting text for the one lead whose description is open.
// `undefined` in the cache means "not fetched", `""` means "fetched, none".
const descriptionId = ref(null);
const descriptions = ref({});
function fail(err) {
console.error(err);
error.value = String(err?.message ?? err);
}
function clearError() {
error.value = "";
}
async function fetchLeads() {
// The store's fetch() records its failure instead of throwing.
await store.fetch({ includeUnmatched: showUnmatched.value });
if (store.error) fail(store.error);
}
const minScore = computed(() => profile.value?.minScore ?? 0);
/** An unscored lead is never "low": no score is not a bad score. */
const isLow = (lead) => lead.score != null && lead.score < minScore.value;
const counts = computed(() => {
const out = { new: 0, promoted: 0, dismissed: 0 };
for (const lead of leads.value) if (lead.state in out) out[lead.state]++;
return out;
});
const inTab = computed(() => leads.value.filter((lead) => lead.state === tab.value));
const hiddenLow = computed(() =>
tab.value === "new" && !showLowScores.value ? inTab.value.filter(isLow).length : 0,
);
/** When the posting went up; when we first saw it if the source gave no date. */
const postedTime = (lead) => new Date(lead.postedAt ?? lead.createdAt).getTime();
// The server already sorts best-first, unscored after scored, newest first
// within a score, so by score this only filters. By date it re-sorts a copy;
// Array.sort is stable, so postings of the same day stay best-first.
const visibleLeads = computed(() => {
const needle = search.value.trim().toLowerCase();
const shown = inTab.value.filter((lead) => {
if (tab.value === "new" && !showLowScores.value && isLow(lead)) return false;
if (!needle) return true;
return [lead.jobTitle, lead.company, lead.location, lead.scoreReasons]
.some((field) => field?.toLowerCase().includes(needle));
});
if (sortBy.value === "posted") shown.sort((a, b) => postedTime(b) - postedTime(a));
return shown;
});
function scoreClass(lead) {
if (lead.score == null) return "jl-score-none";
if (lead.score >= 80) return "jl-score-high";
if (lead.score >= 60) return "jl-score-mid";
return "jl-score-low";
}
/** The tooltip says when, which during a rescore is how to tell new from old. */
function scoreTitle(lead) {
if (lead.score == null) return "Not scored";
const when = lead.scoredAt
? `, scored ${new Date(lead.scoredAt).toLocaleString(undefined, { dateStyle: "medium", timeStyle: "short" })}`
: "";
return `Fit score ${lead.score} out of 100${when}`;
}
function ageLabel(lead) {
const at = lead.postedAt ?? lead.createdAt;
if (!at) return "";
const days = Math.floor((Date.now() - new Date(at).getTime()) / 86_400_000);
const age = days <= 0 ? "today" : days === 1 ? "1 day ago" : `${days} days ago`;
return lead.postedAt ? `posted ${age}` : `found ${age}`;
}
async function act(lead, action) {
busyId.value = lead.id;
try {
await store[action](lead.id);
if (descriptionId.value === lead.id) descriptionId.value = null;
error.value = "";
} catch (err) {
fail(err);
} finally {
busyId.value = null;
}
}
async function toggleDescription(lead) {
if (descriptionId.value === lead.id) {
descriptionId.value = null;
return;
}
descriptionId.value = lead.id;
if (descriptions.value[lead.id] !== undefined) return;
try {
descriptions.value[lead.id] = await store.fetchDescription(lead.id);
} catch (err) {
descriptionId.value = null;
fail(err);
}
}
async function toggleUnmatched() {
showUnmatched.value = !showUnmatched.value;
await fetchLeads();
}
// Run and poll
let pollTimer = null;
function stopPolling() {
clearTimeout(pollTimer);
pollTimer = null;
}
/** Poll until the run finishes, then reload what it changed. */
async function pollStatus() {
const current = await store.fetchStatus();
if (current?.running) {
// Scores are saved one at a time, so reloading as it goes lets a long
// "Score unscored" fill the list in rather than sit still for minutes.
await fetchLeads();
pollTimer = setTimeout(pollStatus, POLL_MS);
return;
}
stopPolling();
if (current?.lastError) fail(current.lastError);
await Promise.all([fetchLeads(), sourcesBox.value?.refresh()]);
}
/** Start one of the server jobs ("runSync", "scoreAll", "rescoreAll") and wait on it. */
async function start(job) {
try {
// false means a job was already going (the scheduler's, say); either way
// there is now one to wait for.
await store[job]();
error.value = "";
status.value = { ...(status.value ?? {}), running: true };
stopPolling();
pollTimer = setTimeout(pollStatus, POLL_MS);
} catch (err) {
fail(err);
}
}
// Matched inbox leads that have a score: what "Rescore all" would redo, on
// top of the unscored ones.
const scoredCount = computed(
() => leads.value.filter((lead) => lead.state === "new" && lead.matched && lead.score != null).length,
);
function rescore() {
const total = scoredCount.value + unscoredCount.value;
// One Claude call per lead, and it replaces scores that were paid for.
if (!confirm(`Score all ${total} inbox leads again? This makes one Claude call per lead.`)) return;
start("rescoreAll");
}
// Matched inbox leads with no score: what "Score unscored" would work
// through. A lead Claude failed on three times stays in this count, though
// the server will not try it again.
const unscoredCount = computed(
() => leads.value.filter((lead) => lead.state === "new" && lead.matched && lead.score == null).length,
);
const running = computed(() => !!status.value?.running);
const lastRun = computed(() => {
if (running.value) return "Working…";
if (!status.value?.lastRunAt) return "";
const when = new Date(status.value.lastRunAt).toLocaleString(undefined, { dateStyle: "medium", timeStyle: "short" });
return `Last checked ${when}`;
});
onMounted(async () => {
await fetchLeads();
// Arriving mid-run (the scheduler's, or one started before a reload) should
// look the same as having pressed the button.
const current = await store.fetchStatus();
if (current?.running) pollTimer = setTimeout(pollStatus, POLL_MS);
});
onBeforeUnmount(stopPolling);
</script>
<template>
<div class="ja-root jl-root">
<div class="jl-header">
<div class="jl-header-left">
<RouterLink to="/" class="jl-back">← Tracker</RouterLink>
<h2 class="jl-heading">Job Leads</h2>
</div>
<div class="jl-header-right">
<span class="jl-hint">{{ lastRun }}</span>
<button
v-if="scoredCount"
class="cv-btn"
:disabled="running"
title="Score every inbox lead again, including ones already scored. Use after changing the profile or the model. Old scores stay until replaced."
@click="rescore"
>
Rescore all
</button>
<button
v-if="unscoredCount"
class="cv-btn"
:disabled="running"
title="Score every unscored lead in the inbox against the profile, without polling the sources. One Claude call per lead."
@click="start('scoreAll')"
>
Score unscored ({{ unscoredCount }})
</button>
<button
class="cv-btn cv-btn-primary"
:disabled="running"
title="Poll every source now, then score up to 40 new leads. Profile and keyword changes take effect on a run."
@click="start('runSync')"
>
{{ running ? "Working…" : "Check now" }}
</button>
</div>
</div>
<div v-if="error" class="jl-error" role="alert">
<span>{{ error }}</span>
<button class="cv-btn cv-btn-sm" @click="error = ''">Dismiss</button>
</div>
<JobSearchProfile @fail="fail" @ok="clearError" />
<JobSources ref="sourcesBox" @fail="fail" @ok="clearError" />
<div class="jl-tabs">
<button
v-for="t in TABS"
:key="t.value"
class="jl-tab"
:class="{ 'jl-tab-active': tab === t.value }"
@click="tab = t.value"
>
<span class="jl-tab-count">{{ counts[t.value] }}</span>
<span class="jl-tab-label">{{ t.label }}</span>
</button>
</div>
<div class="jl-filterbar">
<input v-model="search" class="ja-input" type="search" placeholder="Search title, company, location, reasons…" />
<select v-model="sortBy" class="ja-input ja-select jl-sort" title="Order of the list">
<option value="score">Best score first</option>
<option value="posted">Newest posting first</option>
</select>
<label v-if="tab === 'new'" class="jl-check">
<input v-model="showLowScores" type="checkbox" />
Below {{ minScore }}<template v-if="hiddenLow"> ({{ hiddenLow }} hidden)</template>
</label>
<label v-if="tab === 'new'" class="jl-check" title="Postings the keyword filter rejected. They are never scored.">
<input :checked="showUnmatched" type="checkbox" @change="toggleUnmatched" />
Filtered out
</label>
</div>
<article
v-for="lead in visibleLeads"
:key="lead.id"
class="jl-lead"
:class="{ 'jl-lead-unmatched': !lead.matched && lead.state === 'new' }"
>
<div class="jl-score" :class="scoreClass(lead)" :title="scoreTitle(lead)">
{{ lead.score ?? "–" }}
</div>
<div class="jl-lead-body">
<div class="jl-lead-title">
<a v-if="lead.url" :href="lead.url" target="_blank" rel="noopener" class="jl-link">{{ lead.jobTitle }}</a>
<span v-else>{{ lead.jobTitle }}</span>
<span class="jl-lead-company">{{ lead.company }}</span>
</div>
<div class="jl-lead-meta">
<span v-if="lead.location">{{ lead.location }}</span>
<span>{{ SOURCE_LABELS[lead.sourceKind] ?? lead.sourceKind }}</span>
<span>{{ ageLabel(lead) }}</span>
<span v-if="!lead.matched && lead.state === 'new'">filtered out</span>
</div>
<p v-if="lead.scoreReasons" class="jl-lead-reasons">{{ lead.scoreReasons }}</p>
<pre v-if="descriptionId === lead.id" class="jl-desc">{{
descriptions[lead.id] === undefined ? "Loading…" : descriptions[lead.id] || "The source gave no description."
}}</pre>
</div>
<div class="jl-lead-actions">
<button class="cv-btn cv-btn-sm" @click="toggleDescription(lead)">
{{ descriptionId === lead.id ? "Hide" : "Posting" }}
</button>
<template v-if="lead.state === 'new'">
<button
class="cv-btn cv-btn-sm cv-btn-primary"
:disabled="busyId === lead.id"
title="Add to the tracker as Saved"
@click="act(lead, 'promote')"
>
Track
</button>
<button class="cv-btn cv-btn-sm" :disabled="busyId === lead.id" @click="act(lead, 'dismiss')">Dismiss</button>
</template>
<button v-else-if="lead.state === 'dismissed'" class="cv-btn cv-btn-sm" :disabled="busyId === lead.id" @click="act(lead, 'restore')">
Restore
</button>
<RouterLink v-else to="/" class="cv-btn cv-btn-sm jl-btn-link">In tracker</RouterLink>
</div>
</article>
<p v-if="!visibleLeads.length" class="jl-empty">
<template v-if="loading">Loading…</template>
<template v-else-if="tab !== 'new'">Nothing here.</template>
<template v-else-if="hiddenLow">Nothing at or above {{ minScore }}. Tick "Below {{ minScore }}" to see the rest.</template>
<template v-else-if="!leads.length">No leads yet. Add a source above, then press "Check now".</template>
<template v-else>The inbox is empty.</template>
</p>
</div>
</template>
<!-- Unscoped on purpose, for the same reason as jobs-shared.css: the two child
components render the boxes these classes style, and a scoped rule stops
at a child's root element. Every selector is under .jl-root. -->
<style>
.jl-root .jl-box {
margin-bottom: 1rem;
padding: 0.75rem 1rem;
border: 1px solid var(--color-line-soft);
border-radius: 6px;
background: var(--color-paper);
}
.jl-root .jl-box-heading {
font-size: 1rem;
font-weight: 600;
color: var(--color-ink-soft);
cursor: pointer;
}
.jl-root .jl-box-heading > span {
margin-left: 0.6rem;
font-weight: 400;
}
.jl-root .jl-hint {
font-size: 0.8rem;
color: var(--color-ink-faint);
}
.jl-root p.jl-hint {
margin: 0.5rem 0 0;
}
.jl-root .jl-warn {
font-size: 0.8rem;
color: var(--color-ink-danger);
}
</style>
<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. The frame matches
the tracker page's (.ja-root and friends in JobApplications.vue), whose
rules are scoped to that component and so are repeated here. */
.jl-root {
padding: 1.5rem;
border-top: 2px solid var(--color-ink-soft);
background: var(--color-paper-tint);
}
.jl-header {
display: flex;
align-items: center;
justify-content: space-between;
gap: 1rem;
margin-bottom: 1rem;
}
.jl-header-left,
.jl-header-right {
display: flex;
align-items: center;
gap: 1rem;
}
.jl-back {
font-size: 0.85rem;
color: var(--color-ink-muted);
text-decoration: none;
}
.jl-back:hover {
color: var(--color-ink);
}
.jl-heading {
font-size: 1.1rem;
font-weight: 600;
color: var(--color-ink-soft);
}
.jl-error {
display: flex;
align-items: center;
justify-content: space-between;
gap: 1rem;
margin-bottom: 1rem;
padding: 0.5rem 0.75rem;
border: 1px solid #b91c1c;
border-radius: 4px;
background: #fef2f2;
color: #7f1d1d;
font-size: 0.85rem;
}
.jl-tabs {
display: flex;
gap: 0.5rem;
margin-bottom: 0.75rem;
}
.jl-tab {
display: flex;
align-items: baseline;
gap: 0.4rem;
padding: 0.4rem 0.9rem;
border: 1px solid var(--color-line-soft);
border-radius: 6px;
background: var(--color-paper);
color: var(--color-ink-muted);
cursor: pointer;
}
.jl-tab-active {
border-color: var(--color-ink-soft);
color: var(--color-ink);
}
.jl-tab-count {
font-size: 1.05rem;
font-weight: 600;
}
.jl-tab-label {
font-size: 0.8rem;
}
.jl-filterbar {
display: flex;
align-items: center;
gap: 1rem;
margin-bottom: 0.75rem;
}
.jl-sort {
flex: 0 0 auto;
}
.jl-check {
display: flex;
align-items: center;
gap: 0.35rem;
font-size: 0.8rem;
color: var(--color-ink-muted);
white-space: nowrap;
cursor: pointer;
}
.jl-lead {
display: flex;
align-items: flex-start;
gap: 0.9rem;
margin-bottom: 0.5rem;
padding: 0.7rem 0.9rem;
border: 1px solid var(--color-line-soft);
border-radius: 6px;
background: var(--color-paper);
}
.jl-lead-unmatched {
opacity: 0.6;
}
/* The score reads as a number first; the tint only groups it. Same tints as
the tracker's status pills. */
.jl-score {
flex: 0 0 2.6rem;
padding: 0.35rem 0;
border-radius: 6px;
font-size: 1rem;
font-weight: 600;
text-align: center;
color: var(--color-ink-soft);
background: var(--color-paper-shade);
}
.jl-score-high {
background: #dcfce7;
color: #14532d;
}
.jl-score-mid {
background: #fef9c3;
color: #713f12;
}
.jl-score-none {
color: var(--color-ink-faint);
}
.jl-lead-body {
flex: 1;
min-width: 0;
}
.jl-lead-title {
font-size: 0.95rem;
font-weight: 600;
color: var(--color-ink);
}
.jl-lead-company {
margin-left: 0.5rem;
font-weight: 400;
color: var(--color-ink-muted);
}
.jl-link {
color: var(--color-ink-link);
text-decoration: none;
}
.jl-link:hover {
text-decoration: underline;
}
.jl-lead-meta {
display: flex;
flex-wrap: wrap;
gap: 0.25rem 0.9rem;
margin-top: 0.15rem;
font-size: 0.8rem;
color: var(--color-ink-faint);
}
.jl-lead-reasons {
margin: 0.4rem 0 0;
font-size: 0.85rem;
color: var(--color-ink-soft);
}
/* The posting text is long, so it scrolls inside the card. */
.jl-desc {
max-height: 22rem;
overflow: auto;
margin: 0.6rem 0 0;
padding: 0.6rem;
border: 1px solid var(--color-line-soft);
border-radius: 4px;
background: var(--color-paper-tint);
font-family: inherit;
font-size: 0.8rem;
white-space: pre-wrap;
}
.jl-lead-actions {
display: flex;
gap: 0.4rem;
white-space: nowrap;
}
.jl-btn-link {
text-decoration: none;
}
.jl-empty {
color: var(--color-ink-faint);
font-size: 0.9rem;
}
@media (max-width: 640px) {
.jl-header,
.jl-filterbar {
flex-wrap: wrap;
}
.jl-lead {
flex-wrap: wrap;
}
.jl-lead-body {
flex-basis: calc(100% - 3.5rem);
}
.jl-lead-actions {
flex-basis: 100%;
}
}
</style>
+250
View File
@@ -0,0 +1,250 @@
<script setup>
/**
* The "Quick Reference" box on `/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>
+167
View File
@@ -0,0 +1,167 @@
<script setup>
/**
* The "Search profile" box on `/jobs/leads`: what a lead is judged against.
* Rendered only by JobLeads.vue; data comes from stores/jobSearchProfile.js.
*
* Two different things are edited here. The keyword lists drive a cheap
* filter on the server that decides which postings are shown and scored at
* all; the profile text is what Claude scores those against. Both take effect
* on the next run, not on save — the parent says so beside "Check now".
*
* Like JobReferences.vue it has no error display of its own: failures are
* emitted as `fail` and successes as `ok`, for the page's single banner.
*/
import { ref, computed, watch, onMounted } from "vue";
import { storeToRefs } from "pinia";
import { useJobSearchProfileStore } from "@/stores/jobSearchProfile";
import "./jobs-shared.css";
const emit = defineEmits(["fail", "ok"]);
const store = useJobSearchProfileStore();
const { profile } = storeToRefs(store);
const blank = () => ({ profile: "", includeKeywords: "", excludeKeywords: "", locations: "", minScore: 60 });
const form = ref(blank());
const saving = ref(false);
function reset() {
form.value = profile.value
? {
profile: profile.value.profile,
includeKeywords: profile.value.includeKeywords,
excludeKeywords: profile.value.excludeKeywords,
locations: profile.value.locations,
minScore: profile.value.minScore,
}
: blank();
}
watch(profile, reset);
const dirty = computed(
() => !!profile.value && Object.keys(form.value).some((key) => form.value[key] !== profile.value[key]),
);
// Open by default until there is something in it: an empty profile means no
// lead is ever scored, which is worth making obvious.
const isEmpty = computed(() => !!profile.value && !profile.value.profile.trim());
async function save() {
saving.value = true;
try {
await store.save({ ...form.value, minScore: Number(form.value.minScore) || 0 });
emit("ok");
} catch (err) {
emit("fail", err);
} finally {
saving.value = false;
}
}
onMounted(async () => {
await store.fetch();
if (store.error) emit("fail", store.error);
reset();
});
</script>
<template>
<details class="jl-box" :open="isEmpty">
<summary class="jl-box-heading">
Search profile
<span v-if="isEmpty" class="jl-warn">empty — leads will not be scored</span>
</summary>
<form class="jl-profile" @submit.prevent="save">
<label class="jl-field jl-field-wide">
<span>About you and what you want</span>
<textarea
v-model="form.profile"
class="ja-input jl-textarea"
rows="8"
placeholder="Experience, skills, the kind of role, level, location and working arrangement you are after. Each lead is scored against this text and nothing else."
></textarea>
</label>
<label class="jl-field">
<span>Title must include one of</span>
<textarea v-model="form.includeKeywords" class="ja-input jl-textarea" rows="4" placeholder="engineer&#10;developer"></textarea>
</label>
<label class="jl-field">
<span>Title must not include</span>
<textarea v-model="form.excludeKeywords" class="ja-input jl-textarea" rows="4" placeholder="intern&#10;principal"></textarea>
</label>
<label class="jl-field">
<span>Location must include one of</span>
<textarea v-model="form.locations" class="ja-input jl-textarea" rows="4" placeholder="london&#10;remote"></textarea>
</label>
<p class="jl-hint jl-field-wide">
One entry per line; an empty list is no restriction. Title keywords match whole words, so
"intern" does not exclude "Internal". Only leads that pass are shown and scored.
</p>
<div class="jl-profile-actions jl-field-wide">
<label class="jl-inline">
Hide leads scoring below
<input v-model="form.minScore" class="ja-input jl-num" type="number" min="0" max="100" />
</label>
<button type="button" class="cv-btn cv-btn-sm" :disabled="!dirty || saving" @click="reset">Reset</button>
<button type="submit" class="cv-btn cv-btn-sm cv-btn-primary" :disabled="!dirty || saving">
{{ saving ? "Saving…" : "Save" }}
</button>
</div>
</form>
</details>
</template>
<style scoped>
/* The box and its heading (.jl-box, .jl-box-heading, .jl-hint, .jl-warn) are
in JobLeads.vue's unscoped block, shared with JobSources.vue. */
.jl-profile {
display: grid;
grid-template-columns: repeat(3, minmax(0, 1fr));
gap: 0.75rem;
margin-top: 0.75rem;
}
.jl-field {
display: flex;
flex-direction: column;
gap: 0.25rem;
font-size: 0.8rem;
color: var(--color-ink-muted);
}
.jl-field-wide {
grid-column: 1 / -1;
}
.jl-textarea {
resize: vertical;
font-family: inherit;
line-height: 1.4;
}
.jl-profile-actions {
display: flex;
align-items: center;
gap: 0.5rem;
}
.jl-inline {
display: flex;
align-items: center;
gap: 0.5rem;
margin-right: auto;
font-size: 0.8rem;
color: var(--color-ink-muted);
}
.jl-num {
flex: 0 0 4.5rem;
min-width: 0;
}
@media (max-width: 640px) {
.jl-profile {
grid-template-columns: 1fr;
}
}
</style>
+199
View File
@@ -0,0 +1,199 @@
<script setup>
/**
* The "Sources" box on `/jobs/leads`: the watch list the lead fetcher polls.
* Rendered only by JobLeads.vue; data comes from stores/jobSources.js.
*
* A source is either one company's job board (Greenhouse, Lever, Ashby —
* identified by the slug in the board's URL) or a keyword search (Adzuna,
* Reed — which need API keys set in the tracker's environment: on the main
* site, the admin panel's Environment tab). The
* kinds are a COPY of the list in internal/services/job_sources.go; the server
* rejects any other.
*
* Like JobReferences.vue it has no error display of its own: failures are
* emitted as `fail` and successes as `ok`, for the page's single banner.
*/
import { ref, computed, onMounted } from "vue";
import { storeToRefs } from "pinia";
import { useJobSourcesStore } from "@/stores/jobSources";
import "./jobs-shared.css";
const emit = defineEmits(["fail", "ok"]);
const KINDS = [
{ value: "greenhouse", label: "Greenhouse", board: true, hint: "boards.greenhouse.io/<slug>" },
{ value: "lever", label: "Lever", board: true, hint: "jobs.lever.co/<slug>" },
{ value: "ashby", label: "Ashby", board: true, hint: "jobs.ashbyhq.com/<slug>" },
{ value: "adzuna", label: "Adzuna search", board: false },
{ value: "reed", label: "Reed search", board: false },
];
const kindOf = (value) => KINDS.find((k) => k.value === value) ?? { label: value, board: true };
const store = useJobSourcesStore();
const { sources } = storeToRefs(store);
const blank = (kind = "greenhouse") => ({ kind, label: "", token: "", query: "", location: "" });
const form = ref(blank());
const formKind = computed(() => kindOf(form.value.kind));
async function fetchSources() {
// The store's fetch() records its failure instead of throwing.
await store.fetch();
if (store.error) emit("fail", store.error);
}
defineExpose({ refresh: fetchSources });
async function createSource() {
try {
await store.create({ ...form.value });
form.value = blank(form.value.kind);
emit("ok");
} catch (err) {
emit("fail", err);
}
}
async function toggleEnabled(source) {
try {
await store.update(source.id, { enabled: !source.enabled });
emit("ok");
} catch (err) {
emit("fail", err);
}
}
async function deleteSource(source) {
// Its leads stay: the server keeps them so that re-adding the source does
// not bring back everything already dismissed.
if (!confirm(`Stop watching ${source.label}? Leads already found are kept.`)) return;
try {
await store.remove(source.id);
emit("ok");
} catch (err) {
emit("fail", err);
}
}
function describe(source) {
if (kindOf(source.kind).board) return source.token;
return source.location ? `"${source.query}" in ${source.location}` : `"${source.query}"`;
}
function lastPoll(source) {
if (!source.lastFetchedAt) return "not polled yet";
const when = new Date(source.lastFetchedAt).toLocaleString(undefined, { dateStyle: "medium", timeStyle: "short" });
return `${source.lastCount} listed · ${when}`;
}
onMounted(fetchSources);
</script>
<template>
<details class="jl-box" :open="!sources.length">
<summary class="jl-box-heading">
Sources
<span class="jl-hint">{{ sources.filter((s) => s.enabled).length }} watched</span>
<span v-if="sources.some((s) => s.lastError)" class="jl-warn">one or more failing</span>
</summary>
<div v-for="source in sources" :key="source.id" class="jl-source" :class="{ 'jl-source-off': !source.enabled }">
<span class="jl-source-kind">{{ kindOf(source.kind).label }}</span>
<span class="jl-source-label">{{ source.label }}</span>
<span class="jl-source-what" :title="describe(source)">{{ describe(source) }}</span>
<span v-if="source.lastError" class="jl-warn jl-source-status" :title="source.lastError">{{ source.lastError }}</span>
<span v-else class="jl-hint jl-source-status">{{ lastPoll(source) }}</span>
<button class="cv-btn cv-btn-sm" @click="toggleEnabled(source)">
{{ source.enabled ? "Pause" : "Resume" }}
</button>
<button class="cv-btn cv-btn-sm cv-btn-danger" @click="deleteSource(source)">Delete</button>
</div>
<p v-if="!sources.length" class="jl-hint">
Nothing is being watched. Add a company's job board, or a keyword search, below.
</p>
<form class="jl-source-form" @submit.prevent="createSource">
<select v-model="form.kind" class="ja-input ja-select">
<option v-for="k in KINDS" :key="k.value" :value="k.value">{{ k.label }}</option>
</select>
<template v-if="formKind.board">
<input v-model="form.label" class="ja-input" placeholder="Company name *" required />
<input v-model="form.token" class="ja-input" :placeholder="`Board slug * — ${formKind.hint}`" required />
</template>
<template v-else>
<input v-model="form.query" class="ja-input" placeholder="Keywords * — e.g. golang backend" required />
<input v-model="form.location" class="ja-input" placeholder="Location — e.g. London" />
</template>
<button type="submit" class="cv-btn cv-btn-primary">Add</button>
</form>
<p v-if="!formKind.board" class="jl-hint">
{{ formKind.label }} needs its API key set under Admin → Environment → Job leads.
</p>
</details>
</template>
<style scoped>
/* The box and its heading (.jl-box, .jl-box-heading, .jl-hint, .jl-warn) are
in JobLeads.vue's unscoped block, shared with JobSearchProfile.vue. */
.jl-source {
display: flex;
align-items: center;
gap: 0.6rem;
padding: 0.3rem 0;
font-size: 0.85rem;
}
.jl-source:first-of-type {
margin-top: 0.75rem;
}
.jl-source-off {
opacity: 0.55;
}
.jl-source-kind {
flex: 0 0 6.5rem;
color: var(--color-ink-muted);
}
.jl-source-label {
flex: 0 0 9rem;
font-weight: 500;
color: var(--color-ink-soft);
}
.jl-source-what {
flex: 1 1 6rem;
min-width: 0;
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
color: var(--color-ink-muted);
}
.jl-source-status {
flex: 1 1 10rem;
min-width: 0;
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
text-align: right;
}
.jl-source-form {
display: flex;
gap: 0.5rem;
margin-top: 0.75rem;
flex-wrap: wrap;
}
@media (max-width: 640px) {
.jl-source {
flex-wrap: wrap;
}
.jl-source-status {
flex-basis: 100%;
text-align: left;
}
}
</style>
+291
View File
@@ -0,0 +1,291 @@
<script setup>
/**
* Route `/jobs/settings` — the tracker's own controls, which used to live on
* the main site's admin panel or only in the server log:
*
* - the job capture token, the credential the userscript
* (public/job-capture.user.js) sends. Only a hash is kept on the server
* (DATA_DIR/job_capture_token.json), so a new token is shown exactly once,
* in the response to generating it, and replacing it needs no restart;
* - the email pipeline: whether it is reading mail, the Microsoft sign-in
* link while it is not, and a manual sync.
*
* Environment settings (API keys, which mailbox, the timers) are not here:
* they are the container's environment, edited on the main site's admin
* panel.
*/
import { ref, onMounted } from "vue";
import { RouterLink } from "vue-router";
import { api } from "@/api";
import "./jobs-shared.css";
const error = ref("");
const busy = ref(false);
// --- capture token ---------------------------------------------------------
const capture = ref(null);
// A just-generated token, kept only in this component's memory: leaving the
// page is the end of it.
const newToken = ref("");
const copied = ref(false);
async function fetchCaptureToken() {
try {
capture.value = await api.get("/admin/capture-token", {
fallback: "Failed to load the capture token state",
});
} catch (err) {
error.value = err.message;
}
}
async function generate() {
// Generating replaces: an installed script stops working until it is
// given the new token, which is worth a pause when one already exists.
if (
capture.value?.set &&
!confirm(
"Replace the existing capture token? The installed userscript will stop working until you paste the new one into it.",
)
)
return;
busy.value = true;
try {
const res = await api.post("/admin/capture-token", undefined, {
fallback: "Failed to generate a token",
});
newToken.value = res.token;
copied.value = false;
capture.value = { set: true, createdAt: res.createdAt };
error.value = "";
} catch (err) {
error.value = err.message;
} finally {
busy.value = false;
}
}
async function revoke() {
if (!confirm("Revoke the capture token? The userscript will stop working.")) return;
busy.value = true;
try {
capture.value = await api.delete("/admin/capture-token", {
fallback: "Failed to revoke the token",
});
newToken.value = "";
error.value = "";
} catch (err) {
error.value = err.message;
} finally {
busy.value = false;
}
}
async function copyToken() {
try {
await navigator.clipboard.writeText(newToken.value);
copied.value = true;
} catch {
// Clipboard access can be refused; the token is on screen to select.
error.value = "Could not copy — select the token and copy it by hand.";
}
}
// --- email -----------------------------------------------------------------
// { backend, enabled, ready, authUrl? } from GET /api/email/status.
const email = ref(null);
const syncResult = ref("");
async function fetchEmail() {
try {
email.value = await api.get("/email/status", { fallback: "Failed to load the email status" });
} catch (err) {
error.value = err.message;
}
}
async function syncNow() {
busy.value = true;
syncResult.value = "";
try {
// Runs the whole sync before answering, so this can take a while.
await api.post("/email/sync", undefined, { fallback: "Sync failed" });
syncResult.value = `Synced at ${new Date().toLocaleTimeString()}.`;
error.value = "";
} catch (err) {
error.value = err.data?.details ? `${err.message}: ${err.data.details}` : err.message;
} finally {
busy.value = false;
}
}
const userscriptUrl = `${import.meta.env.BASE_URL}job-capture.user.js`;
onMounted(() => {
fetchCaptureToken();
fetchEmail();
});
</script>
<template>
<div class="ja-root st-root">
<div class="ja-header">
<div class="ja-header-left">
<RouterLink to="/" class="ja-back">← Tracker</RouterLink>
<h2 class="ja-heading">Settings</h2>
</div>
</div>
<p v-if="error" class="ja-error" @click="error = ''">{{ error }}</p>
<section class="st-box">
<h3 class="st-heading">Job capture</h3>
<p class="st-hint">
The credential for the
<a :href="userscriptUrl" target="_blank" rel="noopener">job capture userscript</a>.
Generate one, then paste it into the script's <em>Configure job capture</em> menu
command. Only a hash is stored, so it takes effect at once and cannot be recovered —
generate again to replace it.
</p>
<template v-if="capture">
<p class="st-hint">
<template v-if="capture.set">
Active, generated {{ new Date(capture.createdAt).toLocaleString() }}.
</template>
<template v-else>No token: capture is switched off.</template>
</p>
<div v-if="newToken" class="st-secret">
<p class="st-hint">Copy this now. It will not be shown again.</p>
<code class="st-token">{{ newToken }}</code>
<button class="cv-btn cv-btn-sm" @click="copyToken">
{{ copied ? "Copied" : "Copy" }}
</button>
</div>
<div class="st-actions">
<button class="cv-btn" :disabled="busy" @click="generate">
{{ capture.set ? "Regenerate" : "Generate token" }}
</button>
<button v-if="capture.set" class="cv-btn cv-btn-danger" :disabled="busy" @click="revoke">
Revoke
</button>
</div>
</template>
</section>
<section class="st-box">
<h3 class="st-heading">Email</h3>
<template v-if="email">
<p v-if="!email.backend" class="st-hint">
Not configured: set <code>EMAIL_BACKEND</code> to <code>graph</code> or
<code>imap</code> and the matching credentials.
</p>
<template v-else>
<p class="st-hint">
Reading mail over <strong>{{ email.backend === "graph" ? "Microsoft Graph" : "IMAP" }}</strong>.
<template v-if="email.ready">
{{ email.enabled ? "Syncs on a timer." : "The timer is off; sync by hand below." }}
</template>
<template v-else-if="email.authUrl">Not signed in yet.</template>
<template v-else>Not ready: check the tracker's log.</template>
</p>
<p v-if="email.authUrl" class="st-hint">
<a :href="email.authUrl" rel="noopener">Sign in to Microsoft</a>. After signing in,
restart the tracker so the timer picks the session up; "Sync now" works at once.
</p>
<div class="st-actions">
<button class="cv-btn" :disabled="busy || !email.ready" @click="syncNow">
{{ busy ? "Syncing…" : "Sync now" }}
</button>
<span class="st-hint">{{ syncResult }}</span>
</div>
</template>
</template>
</section>
</div>
</template>
<style scoped>
/* Page frame, matching JobApplications.vue's (scoped there). */
.ja-root {
padding: 1.5rem;
border-top: 2px solid var(--color-ink-soft);
background: var(--color-paper-tint);
min-height: 100vh;
}
.ja-header {
display: flex;
align-items: center;
justify-content: space-between;
margin-bottom: 1rem;
}
.ja-header-left {
display: flex;
align-items: center;
gap: 1rem;
}
.ja-back {
font-size: 0.85rem;
color: var(--color-ink-muted);
text-decoration: none;
}
.ja-back:hover {
color: var(--color-ink);
}
.ja-heading {
font-size: 1.1rem;
font-weight: 600;
color: var(--color-ink-soft);
}
.ja-error {
margin-bottom: 1rem;
padding: 0.5rem 0.75rem;
border: 1px solid #b91c1c;
border-radius: 4px;
background: #fef2f2;
color: #7f1d1d;
font-size: 0.85rem;
cursor: pointer;
}
.st-box {
background: var(--color-paper);
border: 1px solid var(--color-line-soft);
border-radius: 6px;
padding: 1rem 1.25rem;
margin-bottom: 1.25rem;
display: flex;
flex-direction: column;
gap: 0.6rem;
}
.st-heading {
font-size: 1.1rem;
}
.st-hint {
color: var(--color-ink-muted);
font-size: 0.9rem;
}
.st-hint a {
color: var(--color-ink-link);
}
.st-secret {
display: flex;
flex-wrap: wrap;
align-items: center;
gap: 0.5rem;
padding: 0.6rem;
background: var(--color-paper-tint);
border-radius: 4px;
}
.st-token {
font-size: 0.85rem;
word-break: break-all;
color: var(--color-ink);
}
.st-actions {
display: flex;
align-items: center;
gap: 0.75rem;
}
</style>
+31
View File
@@ -0,0 +1,31 @@
/**
* The job-application status vocabulary, as the tracker at /jobs/ shows it.
*
* This is a COPY. The source of truth is server-side: `enum JobStatus` in
* internal/graph/schema/job_application.graphql, ranked by `statusOrder` in
* internal/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 web/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;
}