feat/PMS-453-saved-dashboards #335

Merged
YousifShkara merged 3 commits from feat/PMS-453-saved-dashboards into main 2026-06-23 08:51:44 +02:00
Owner
No description provided.
Migration `063_assets_cmdb_expand.sql` adds the eight fields the QA report flagged as missing on the asset model and the PMS-454 spec called out:

- `assigned_user_id` (FK users, SET NULL on delete) - tech or user the asset is issued to.
- `ip_address` (INET) - primary IPv4/IPv6; Postgres validates the format at write time.
- `hostname` (VARCHAR 255) - DNS name.
- `mac_address` (VARCHAR 50) - free-text so colon / hyphen / dotted formats all round-trip unchanged.
- `installed_date` (DATE) - separate from purchase_date because an asset is often purchased months before deployment.
- `department` (VARCHAR 100) - free-text department tag; FK-ifying when a departments table exists is the documented v2 step.
- `in_transit_ticket_id` (FK tickets, SET NULL on delete) - the ticket tracking the move when an asset is `in_transit`.

The `status` CHECK widens to allow `'in_transit'` alongside the existing five values so an asset on the move can be flagged. Indexes on the new filterable fields (assigned_user_id, tenant+hostname, tenant+department, in_transit_ticket_id) keep the list / search ILIKEs bounded.

Model updates:
- `AssetResponse` gains all eight columns plus a resolved `assigned_user_name` line (first_name + last_name joined via the same pattern `company_name` already uses) so the SPA renders "Issued to Alice Smith" without an extra round trip.
- `CreateAssetRequest` and `UpdateAssetRequest` accept each new field; existing callers stay green because every addition is `Option<...>`.
- IP arrives as text on the wire; the INSERT / UPDATE use `NULLIF($n,'')::inet` so a bad value raises a 400 instead of silently corrupting the column.

Service queries:
- `list_assets`, `get_asset`: SELECT extends with the new columns plus a LEFT JOIN on `users` for the assigned-user name.
- `create_asset`, `update_asset`: INSERT / UPDATE thread the new fields.

The companion mokosh-apps PR surfaces these on the Asset detail page and the edit form; the CI types + relationships taxonomy + dependency-map visualisation tracked under PMS-456 builds on top.

#PMS-454
Introduces `saved_dashboards`: a `(tenant_id, user_id, name, layout JSONB, is_default)` row that the SPA reads on app boot to land the user on their pinned layout. The `layout` blob is SPA-owned and stored opaquely so a UI change can ship without a schema migration.

`GET /api/v1/dashboards` returns the caller's own dashboards default-first, `GET /api/v1/dashboards/default` is the boot fast-path used by the SPA to skip the full list scan, `POST` / `PATCH` swap the default flag inside a transaction so the partial-unique index on `(tenant_id, user_id) WHERE is_default = true` never trips, `DELETE` removes the row (a 404 surfaces a delete miss rather than swallowing it silently).

Phase 2 of PMS-453 (scheduled report delivery) is intentionally NOT in this PR. That work needs its own `scheduled_reports` table plus a cron-draining background worker; both are tracked under the same ticket as a follow-up.

The integration test under `tests/dashboards_crud.rs` drives the route layer through the default-swap ceremony (create non-default + default, promote the non-default row, confirm GET /default surfaces it, confirm the previously-default row is no longer default, delete the default row and confirm GET /default returns null).

#PMS-453
fix(dashboards): use axum 0.8 brace path-capture syntax (PMS-453)
All checks were successful
E2E / Playwright against staging (pull_request) Successful in 31s
Check / fmt + clippy + build + tests (pull_request) Successful in 1m11s
Integration / integration tests (pull_request) Successful in 3m51s
Create release / Create release from merged PR (pull_request) Successful in 4s
99fb6af15f
Same fix as the approvals route registration: axum 0.8 requires `{id}` instead of `:id` for path captures. The leading-colon form panics at router-build time, which any integration test that boots the real router would hit.

#PMS-453
YousifShkara deleted branch feat/PMS-453-saved-dashboards 2026-06-23 08:51:44 +02:00
Sign in to join this conversation.
No reviewers
No labels
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
psa-systems/mokosh-server!335
No description provided.