Two tabs and a cog: settings shell, one ranking, a script per page, the phone frame

The top bar is Roles and Applications plus health's cog. Behind the cog,
/settings/{ranking,searches,companies,pulls,messages,account} share one row
of sub-tabs, an underlined row on a desktop and pills on a phone. The old
paths answer 301 with their query string.

Ranking edits the first enabled agent, or creates one, with the intent,
the weights and the gates under Advanced. The order menu on Roles reads
Newest and Best match with one enabled agent, and names them with several.
config.yaml keeps the Copenhagen starter; the other two are commented
examples in config.example.yaml.

roles.js is split into roles.js, applications.js, ranking.js and
companies.js; count, cell, debounce, the company list and the affinity
control live once in app.js. app.css gets the phone frame after health and
newsdesk: one-row bar, edge-to-edge panels, 44px targets and 16px fields on
a coarse pointer, hover only where there is one, safe areas. The app is
installable from a manifest and roledesk-coloured icons. Every lede touched
is written for the person using the app.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
This commit is contained in:
WolfandClaude Opus 5.5 committed 2026-09-25 21:29:06 +02:00
1 parent 8c4bc3112a
commit 7d31cca394
34 files changed
+848 -565

No files matched your search

+78 -42
View File
@@ -1,31 +1,38 @@
"""The tabs: nine pages, declared once.
"""The pages: two tabs, a cog, and six settings pages behind it.
`TABS` is the whole navigation. `base.html` renders it, every page marks
itself active by its own `path`, and adding a tab is one entry here plus one
template.
`TABS` is the top bar, Roles and Applications, and `SETTINGS` is the row of
sub-tabs under the cog at `/settings/<name>`: the setup pages first (Ranking,
Searches, Companies), the system ones after (Pulls, Messages, Account).
`base.html` renders the first, `settings/_tabs.html` the second, every page
marks itself active by its own `path`, and adding one is one entry here plus
one template. `/settings` itself is Ranking.
Every page is a shell. Roles, Applications, Agents and Companies are filled
and driven by `static/roles.js` from the JSON routes in `web/api.py`, Sources
by `static/sources.js`; Jobs,
Schedules and Account are shells around the modules' own elements. What the
server renders is only what a select needs to offer, so the options cannot
drift from what the store accepts.
Every page is a shell. Each is filled and driven by its own script under
`static/` from the JSON routes in `web/api.py`; Pulls and Account are shells
around the modules' own elements. What the server renders is only what a
select needs to offer, so the options cannot drift from what the store
accepts.
The pages that were tabs before the settings shell (`/agents`, `/companies`,
`/sources`, `/jobs`, `/schedules`, `/messages`, `/account`) answer 301 to
their new place, query string kept, so a bookmark still lands.
`FUNCTIONS` is `plugins.ats`'s, not `app`'s: the nine job functions are the
classifier's vocabulary, and this reaches `plugins/` the same way `app.cli`
does, since a plugin is app-agnostic and never reaches back into `app`. The
Jobindex areas and Adzuna countries on the Sources tab come from
Jobindex areas and Adzuna countries on the Searches page come from
`plugins.search` for the same reason.
"""
from __future__ import annotations
import sys
from collections.abc import Callable
from dataclasses import dataclass
from pathlib import Path
from fastapi import APIRouter, Request
from fastapi.responses import HTMLResponse
from fastapi.responses import HTMLResponse, RedirectResponse
from fastapi.templating import Jinja2Templates
from app.models import REMOTE, STATUSES
@@ -48,19 +55,33 @@ class Tab:
template: str
#: The navigation, in order. One list; `base.html` is its only reader.
#: The top bar, in order. One list; `base.html` is its only reader.
TABS: tuple[Tab, ...] = (
Tab("/", "Roles", "roles.html"),
Tab("/applications", "Applications", "applications.html"),
Tab("/agents", "Agents", "agents.html"),
Tab("/companies", "Companies", "companies.html"),
Tab("/sources", "Sources", "sources.html"),
Tab("/jobs", "Jobs", "jobs.html"),
Tab("/schedules", "Schedules", "schedules.html"),
Tab("/messages", "Messages", "messages.html"),
Tab("/account", "Account", "account.html"),
)
#: The sub-tabs under the cog, in order; `settings/_tabs.html` renders them.
SETTINGS: tuple[Tab, ...] = (
Tab("/settings/ranking", "Ranking", "settings/ranking.html"),
Tab("/settings/searches", "Searches", "settings/searches.html"),
Tab("/settings/companies", "Companies", "settings/companies.html"),
Tab("/settings/pulls", "Pulls", "settings/pulls.html"),
Tab("/settings/messages", "Messages", "settings/messages.html"),
Tab("/settings/account", "Account", "settings/account.html"),
)
#: Where each page that used to be a tab lives now.
MOVED: dict[str, str] = {
"/agents": "/settings/ranking",
"/companies": "/settings/companies",
"/sources": "/settings/searches",
"/jobs": "/settings/pulls",
"/schedules": "/settings/pulls",
"/messages": "/settings/messages",
"/account": "/settings/account",
}
#: `value, label` for each select option. `FUNCTIONS` is already the value a
#: role's `function` column holds; only the label is dressed up.
FUNCTION_OPTIONS = [(f, f.replace("/", " / ").capitalize()) for f in FUNCTIONS]
@@ -83,6 +104,7 @@ def asset(path: str) -> str:
templates = Jinja2Templates(directory=str(TEMPLATE_DIR))
templates.env.globals["TABS"] = TABS
templates.env.globals["SETTINGS"] = SETTINGS
templates.env.globals["asset"] = asset
#: Out of the OpenAPI schema: these are pages.
@@ -104,36 +126,50 @@ def applications(request: Request) -> HTMLResponse:
return page(request, "applications.html", status_options=STATUS_OPTIONS)
@router.get("/agents", response_class=HTMLResponse)
def agents(request: Request) -> HTMLResponse:
return page(request, "agents.html")
@router.get("/settings", response_class=RedirectResponse)
def settings() -> RedirectResponse:
return RedirectResponse(SETTINGS[0].path, status_code=302)
@router.get("/companies", response_class=HTMLResponse)
@router.get("/settings/ranking", response_class=HTMLResponse)
def ranking(request: Request) -> HTMLResponse:
return page(request, "settings/ranking.html")
@router.get("/settings/searches", response_class=HTMLResponse)
def searches(request: Request) -> HTMLResponse:
return page(request, "settings/searches.html", areas=AREA_OPTIONS,
countries=COUNTRY_OPTIONS)
@router.get("/settings/companies", response_class=HTMLResponse)
def companies(request: Request) -> HTMLResponse:
return page(request, "companies.html")
return page(request, "settings/companies.html")
@router.get("/sources", response_class=HTMLResponse)
def sources(request: Request) -> HTMLResponse:
return page(request, "sources.html", areas=AREA_OPTIONS, countries=COUNTRY_OPTIONS)
@router.get("/settings/pulls", response_class=HTMLResponse)
def pulls(request: Request) -> HTMLResponse:
return page(request, "settings/pulls.html")
@router.get("/jobs", response_class=HTMLResponse)
def jobs(request: Request) -> HTMLResponse:
return page(request, "jobs.html")
@router.get("/schedules", response_class=HTMLResponse)
def schedules(request: Request) -> HTMLResponse:
return page(request, "schedules.html")
@router.get("/messages", response_class=HTMLResponse)
@router.get("/settings/messages", response_class=HTMLResponse)
def messages(request: Request) -> HTMLResponse:
return page(request, "messages.html")
return page(request, "settings/messages.html")
@router.get("/account", response_class=HTMLResponse)
@router.get("/settings/account", response_class=HTMLResponse)
def account(request: Request) -> HTMLResponse:
return page(request, "account.html")
return page(request, "settings/account.html")
def _moved(to: str) -> Callable[[Request], RedirectResponse]:
"""A 301 to `to`, carrying the query string, so `/agents?x=1` keeps it."""
def redirect(request: Request) -> RedirectResponse:
query = request.url.query
return RedirectResponse(f"{to}?{query}" if query else to, status_code=301)
return redirect
for _old, _new in MOVED.items():
router.add_api_route(_old, _moved(_new), methods=["GET"],
response_class=RedirectResponse)