Add application workflow and lead analytics
This commit is contained in:
+124
-13
@@ -19,8 +19,8 @@
|
||||
* 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 { ref, computed, onMounted, onBeforeUnmount, watch } from "vue";
|
||||
import { RouterLink, useRoute, useRouter } from "vue-router";
|
||||
import { storeToRefs } from "pinia";
|
||||
import { useJobLeadsStore } from "@/stores/jobLeads";
|
||||
import { useJobSearchProfileStore } from "@/stores/jobSearchProfile";
|
||||
@@ -38,23 +38,45 @@ const SOURCE_LABELS = { greenhouse: "Greenhouse", lever: "Lever", ashby: "Ashby"
|
||||
const POLL_MS = 3000;
|
||||
|
||||
const store = useJobLeadsStore();
|
||||
const route = useRoute();
|
||||
const router = useRouter();
|
||||
const { leads, status, loading } = storeToRefs(store);
|
||||
const { profile } = storeToRefs(useJobSearchProfileStore());
|
||||
|
||||
const error = ref("");
|
||||
const tab = ref("new");
|
||||
const search = ref("");
|
||||
const tab = ref(["new", "promoted", "dismissed"].includes(route.query.tab) ? route.query.tab : "new");
|
||||
const search = ref(typeof route.query.q === "string" ? route.query.q : "");
|
||||
// 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);
|
||||
const showLowScores = ref(route.query.low === "1");
|
||||
const showUnmatched = ref(route.query.unmatched === "1");
|
||||
// "score" is the order the server sends; "posted" re-sorts here by the
|
||||
// posting's own date.
|
||||
const sortBy = ref("score");
|
||||
const sortBy = ref(route.query.sort === "posted" ? "posted" : "score");
|
||||
const busyId = ref(null);
|
||||
const selected = ref(new Set());
|
||||
const sourceFilter = ref(typeof route.query.source === "string" ? route.query.source : "");
|
||||
const companyFilter = ref(typeof route.query.company === "string" ? route.query.company : "");
|
||||
const locationFilter = ref(typeof route.query.location === "string" ? route.query.location : "");
|
||||
const minFilter = ref(typeof route.query.min === "string" ? route.query.min : "");
|
||||
const maxFilter = ref(typeof route.query.max === "string" ? route.query.max : "");
|
||||
const bulkBusy = ref(false);
|
||||
const sourcesBox = ref(null);
|
||||
|
||||
function leadsQuery() {
|
||||
const query = { ...route.query };
|
||||
const values = { tab, q: search, sort: sortBy, source: sourceFilter, company: companyFilter, location: locationFilter, min: minFilter, max: maxFilter };
|
||||
for (const [key, state] of Object.entries(values)) state.value ? (query[key] = state.value) : delete query[key];
|
||||
showLowScores.value ? (query.low = "1") : delete query.low;
|
||||
showUnmatched.value ? (query.unmatched = "1") : delete query.unmatched;
|
||||
return query;
|
||||
}
|
||||
|
||||
watch([tab, search, sortBy, sourceFilter, companyFilter, locationFilter, minFilter, maxFilter, showLowScores, showUnmatched], () => {
|
||||
router.replace({ query: leadsQuery() });
|
||||
});
|
||||
|
||||
// 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);
|
||||
@@ -71,7 +93,16 @@ function clearError() {
|
||||
|
||||
async function fetchLeads() {
|
||||
// The store's fetch() records its failure instead of throwing.
|
||||
await store.fetch({ includeUnmatched: showUnmatched.value });
|
||||
await store.fetch({
|
||||
includeUnmatched: showUnmatched.value,
|
||||
filters: {
|
||||
sourceKind: sourceFilter.value || undefined,
|
||||
company: companyFilter.value || undefined,
|
||||
location: locationFilter.value || undefined,
|
||||
minScore: minFilter.value === "" ? undefined : Number(minFilter.value),
|
||||
maxScore: maxFilter.value === "" ? undefined : Number(maxFilter.value),
|
||||
},
|
||||
});
|
||||
if (store.error) fail(store.error);
|
||||
}
|
||||
|
||||
@@ -102,6 +133,11 @@ 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 (sourceFilter.value && lead.sourceKind !== sourceFilter.value) return false;
|
||||
if (companyFilter.value && !lead.company.toLowerCase().includes(companyFilter.value.toLowerCase())) return false;
|
||||
if (locationFilter.value && !lead.location.toLowerCase().includes(locationFilter.value.toLowerCase())) return false;
|
||||
if (minFilter.value !== "" && (lead.score == null || lead.score < Number(minFilter.value))) return false;
|
||||
if (maxFilter.value !== "" && (lead.score == null || lead.score > Number(maxFilter.value))) return false;
|
||||
if (!needle) return true;
|
||||
return [lead.jobTitle, lead.company, lead.location, lead.scoreReasons]
|
||||
.some((field) => field?.toLowerCase().includes(needle));
|
||||
@@ -110,6 +146,19 @@ const visibleLeads = computed(() => {
|
||||
return shown;
|
||||
});
|
||||
|
||||
const selectedVisible = computed(() => visibleLeads.value.filter((lead) => selected.value.has(lead.id)));
|
||||
const allVisibleSelected = computed(() => visibleLeads.value.length > 0 && selectedVisible.value.length === visibleLeads.value.length);
|
||||
function toggleSelected(id) { const next = new Set(selected.value); next.has(id) ? next.delete(id) : next.add(id); selected.value = next; }
|
||||
function toggleAllVisible() { selected.value = allVisibleSelected.value ? new Set() : new Set(visibleLeads.value.map((lead) => lead.id)); }
|
||||
function clearSelection() { selected.value = new Set(); }
|
||||
async function bulkAct(action) {
|
||||
if (!selectedVisible.value.length) return;
|
||||
bulkBusy.value = true;
|
||||
try { await store[action](selectedVisible.value.map((lead) => lead.id)); clearSelection(); error.value = ""; }
|
||||
catch (err) { fail(err); }
|
||||
finally { bulkBusy.value = false; }
|
||||
}
|
||||
|
||||
function scoreClass(lead) {
|
||||
if (lead.score == null) return "jl-score-none";
|
||||
if (lead.score >= 80) return "jl-score-high";
|
||||
@@ -165,10 +214,9 @@ async function toggleDescription(lead) {
|
||||
}
|
||||
}
|
||||
|
||||
async function toggleUnmatched() {
|
||||
showUnmatched.value = !showUnmatched.value;
|
||||
await fetchLeads();
|
||||
}
|
||||
watch(showUnmatched, (value, oldValue) => {
|
||||
if (value !== oldValue) fetchLeads();
|
||||
});
|
||||
|
||||
// Run and poll
|
||||
|
||||
@@ -341,16 +389,34 @@ onBeforeUnmount(stopPolling);
|
||||
<option value="score">Best score first</option>
|
||||
<option value="posted">Newest posting first</option>
|
||||
</select>
|
||||
<select v-model="sourceFilter" class="input jl-sort" aria-label="Filter source">
|
||||
<option value="">All sources</option>
|
||||
<option v-for="(label, kind) in SOURCE_LABELS" :key="kind" :value="kind">{{ label }}</option>
|
||||
</select>
|
||||
<input v-model="companyFilter" class="input jl-filter" placeholder="Company" aria-label="Filter company" />
|
||||
<input v-model="locationFilter" class="input jl-filter" placeholder="Location" aria-label="Filter location" />
|
||||
<input v-model="minFilter" class="input jl-score-filter" type="number" min="0" max="100" placeholder="Min score" aria-label="Minimum score" />
|
||||
<input v-model="maxFilter" class="input jl-score-filter" type="number" min="0" max="100" placeholder="Max score" aria-label="Maximum score" />
|
||||
<label v-if="tab === 'new'" class="check">
|
||||
<input v-model="showLowScores" type="checkbox" />
|
||||
Below {{ minScore }}<template v-if="hiddenLow"> ({{ hiddenLow }} hidden)</template>
|
||||
</label>
|
||||
<label v-if="tab === 'new'" class="check" title="Postings the keyword filter rejected. They are never scored.">
|
||||
<input :checked="showUnmatched" type="checkbox" @change="toggleUnmatched" />
|
||||
<input v-model="showUnmatched" type="checkbox" />
|
||||
Filtered out
|
||||
</label>
|
||||
</div>
|
||||
|
||||
<div v-if="visibleLeads.length" class="jl-bulkbar">
|
||||
<label class="check"><input type="checkbox" :checked="allVisibleSelected" @change="toggleAllVisible" /> Select visible</label>
|
||||
<span v-if="selectedVisible.length">{{ selectedVisible.length }} selected</span>
|
||||
<template v-if="selectedVisible.length">
|
||||
<button v-if="tab === 'new'" class="btn btn-sm" :disabled="bulkBusy" @click="bulkAct('bulkDismiss')">Dismiss selected</button>
|
||||
<button v-if="tab === 'dismissed'" class="btn btn-sm" :disabled="bulkBusy" @click="bulkAct('bulkRestore')">Restore selected</button>
|
||||
<button v-if="tab === 'new'" class="btn btn-primary btn-sm" :disabled="bulkBusy" @click="bulkAct('bulkPromote')">Track selected</button>
|
||||
</template>
|
||||
</div>
|
||||
|
||||
<div class="jl-list">
|
||||
<article
|
||||
v-for="lead in visibleLeads"
|
||||
@@ -364,6 +430,7 @@ onBeforeUnmount(stopPolling);
|
||||
:style="{ '--arc': scoreArc(lead) }"
|
||||
:title="scoreTitle(lead)"
|
||||
>
|
||||
<input class="jl-select" type="checkbox" :checked="selected.has(lead.id)" :aria-label="`Select ${lead.jobTitle}`" @change="toggleSelected(lead.id)" />
|
||||
<span>{{ lead.score ?? "–" }}</span>
|
||||
</div>
|
||||
<div class="jl-lead-body">
|
||||
@@ -498,6 +565,30 @@ onBeforeUnmount(stopPolling);
|
||||
margin-bottom: 1rem;
|
||||
}
|
||||
|
||||
.jl-filter {
|
||||
flex: 0 1 10rem;
|
||||
width: auto;
|
||||
}
|
||||
.jl-score-filter {
|
||||
flex: 0 1 7rem;
|
||||
width: auto;
|
||||
}
|
||||
|
||||
.jl-bulkbar {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 0.75rem;
|
||||
flex-wrap: wrap;
|
||||
min-height: 2.5rem;
|
||||
margin-bottom: 0.75rem;
|
||||
padding: 0.5rem 0.75rem;
|
||||
border: 1px solid var(--border);
|
||||
border-radius: 0.4rem;
|
||||
background: var(--surface-2);
|
||||
color: var(--text-2);
|
||||
font-size: 0.875rem;
|
||||
}
|
||||
|
||||
.jl-sort {
|
||||
flex: 0 0 auto;
|
||||
width: auto;
|
||||
@@ -551,6 +642,15 @@ onBeforeUnmount(stopPolling);
|
||||
font-weight: 700;
|
||||
font-variant-numeric: tabular-nums;
|
||||
}
|
||||
.jl-select {
|
||||
position: absolute;
|
||||
top: 0.35rem;
|
||||
left: 0.35rem;
|
||||
z-index: 1;
|
||||
}
|
||||
.jl-score {
|
||||
position: relative;
|
||||
}
|
||||
.jl-score-high {
|
||||
--tone: var(--ok);
|
||||
}
|
||||
@@ -625,6 +725,17 @@ onBeforeUnmount(stopPolling);
|
||||
}
|
||||
|
||||
@media (max-width: 720px) {
|
||||
.jl-toolbar {
|
||||
align-items: stretch;
|
||||
gap: 0.65rem;
|
||||
}
|
||||
.jl-toolbar .search,
|
||||
.jl-sort,
|
||||
.jl-filter,
|
||||
.jl-score-filter {
|
||||
flex: 1 1 calc(50% - 0.65rem);
|
||||
}
|
||||
|
||||
.jl-lead {
|
||||
flex-wrap: wrap;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user