feat: move cards between dashboards, order dashboards, reuse uploaded icons
The card dialog has a dashboard field. Settings orders the dashboards with arrows. The link dialog offers the images that were uploaded before.
This commit is contained in:
@@ -101,14 +101,30 @@ scripts/sync-collabry.sh copies them from upstream at a pinned commit
|
|||||||
wallpaper is shown, and where "Back to dashboard" goes.
|
wallpaper is shown, and where "Back to dashboard" goes.
|
||||||
- [x] 16. Cards are dragged by their title bar: `card.position` (migration `0008_card_position`),
|
- [x] 16. Cards are dragged by their title bar: `card.position` (migration `0008_card_position`),
|
||||||
`saveLayout` (was `moveLinks`) stores the order of the cards and of their links.
|
`saveLayout` (was `moveLinks`) stores the order of the cards and of their links.
|
||||||
|
- [x] 17. Password change in Settings → Account (Better Auth `changePassword`, other sessions are
|
||||||
|
revoked). Hidden for accounts without a password (SSO only).
|
||||||
|
- [x] 18. The search bar opens links by name: `matchLinks` in `src/lib/search.ts`. A link whose name
|
||||||
|
or a word of it starts with the text is preselected, Enter opens it.
|
||||||
|
- [x] 19. Light icons: a link without an icon of its own uses the library's `-light` version when
|
||||||
|
there is one. The server keeps the library's names for a day (`src/lib/icon-library.ts`) and
|
||||||
|
sends `lightIcon` with each link.
|
||||||
|
- [x] 20. Status dots: `STATUS_CHECKS=true` turns them on (`src/lib/status.ts`, `getStatuses`).
|
||||||
|
Off by default, because the server then requests addresses that users chose.
|
||||||
|
- [x] 21. Export and import: `exportData` / `importData`, the file format and the bookmarks parser
|
||||||
|
in `src/lib/transfer.ts`. An import only adds dashboards.
|
||||||
|
- [x] 22. Cards move to another dashboard in the card dialog, dashboards are ordered with arrows
|
||||||
|
in Settings (`dashboard.position`, migration `0009_dashboard_position`), uploaded icons are
|
||||||
|
offered again in the link dialog (`getIcons`).
|
||||||
|
|
||||||
## Not doing (not asked)
|
## Not doing (not asked)
|
||||||
|
|
||||||
- Unraid version/uptime chip and the Sonarr/Plex notification pills from the screenshot
|
- Unraid version/uptime chip and the Sonarr/Plex notification pills from the screenshot
|
||||||
- Inline SearXNG result rendering (search opens the engine's result page)
|
- Inline SearXNG result rendering (search opens the engine's result page)
|
||||||
- Free placement of cards with gaps in the grid, per-user SearXNG URL (SSRF risk — it is a server env)
|
- Free placement of cards with gaps in the grid, per-user SearXNG URL (SSRF risk — it is a server env)
|
||||||
- Per dashboard clock or search engine (they stay per user), moving a card to another dashboard,
|
- Per dashboard clock or search engine (they stay per user), remembering the last opened
|
||||||
reordering dashboards, remembering the last opened dashboard (the default opens)
|
dashboard (it would work against the default dashboard, which opens)
|
||||||
- A list of the icons a user uploaded, to use one again for another link
|
- Links of other dashboards in the search bar, a keyword per link, a status history or alerts
|
||||||
|
- Info pills (Sonarr, SABnzbd, server status) and a Home Assistant card: each needs its own
|
||||||
|
integration and an API key on the server
|
||||||
- Email verification / password reset mail (needs an SMTP setup)
|
- Email verification / password reset mail (needs an SMTP setup)
|
||||||
- In CI: version tags and releases, a Helm chart, an image vulnerability scan (typst-workspace has all three)
|
- In CI: version tags and releases, a Helm chart, an image vulnerability scan (typst-workspace has all three)
|
||||||
|
|||||||
@@ -55,12 +55,13 @@ Build it yourself: `docker build -t dahoam .`
|
|||||||
## Use
|
## Use
|
||||||
|
|
||||||
- **Dashboards** are separate sets of cards, for example Home and Work. Settings → Dashboards
|
- **Dashboards** are separate sets of cards, for example Home and Work. Settings → Dashboards
|
||||||
adds, renames and deletes them and sets the default, the one that opens when you sign in.
|
adds, renames, orders and deletes them and sets the default, the one that opens when you
|
||||||
|
sign in.
|
||||||
With more than one, switch at the top of the page or with `/switch to work`. The address
|
With more than one, switch at the top of the page or with `/switch to work`. The address
|
||||||
of a dashboard (`/?d=…`) can be bookmarked. Every dashboard has its own wallpaper, clock
|
of a dashboard (`/?d=…`) can be bookmarked. Every dashboard has its own wallpaper, clock
|
||||||
and search are the same on all.
|
and search are the same on all.
|
||||||
- **Cards** group your links (Apps, Media, Bookmarks, ...). "New card" under the cards adds
|
- **Cards** group your links (Apps, Media, Bookmarks, ...). "New card" under the cards adds
|
||||||
one. Click a card's name to rename or delete it.
|
one. Click a card's name to rename or delete it, or to move it to another dashboard.
|
||||||
- **Links**: **+** at the top or on a card adds a link. Hover a link and click the pencil to
|
- **Links**: **+** at the top or on a card adds a link. Hover a link and click the pencil to
|
||||||
edit or delete it.
|
edit or delete it.
|
||||||
- **Move links** by dragging, inside a card or to another card. Touch: press and hold first.
|
- **Move links** by dragging, inside a card or to another card. Touch: press and hold first.
|
||||||
@@ -72,6 +73,7 @@ Build it yourself: `docker build -t dahoam .`
|
|||||||
site's `/favicon.ico`. When the library has a light version of the icon (`github-light`),
|
site's `/favicon.ico`. When the library has a light version of the icon (`github-light`),
|
||||||
that one is used, because the cards are dark. Or type in the field to search that library and click an icon,
|
that one is used, because the cards are dark. Or type in the field to search that library and click an icon,
|
||||||
paste an image URL, or upload your own image (PNG, JPEG, WebP, AVIF or SVG, up to 1 MB).
|
paste an image URL, or upload your own image (PNG, JPEG, WebP, AVIF or SVG, up to 1 MB).
|
||||||
|
The images that you uploaded before are offered again under "Your images".
|
||||||
- **Status** (with `STATUS_CHECKS=true`): a green dot on a link means that its address
|
- **Status** (with `STATUS_CHECKS=true`): a green dot on a link means that its address
|
||||||
answers, a red ring that it does not. Checked once a minute.
|
answers, a red ring that it does not. Checked once a minute.
|
||||||
- **Search**: `/` focuses the bar. `!w cats` uses DuckDuckGo bangs. `/settings`, `/add link`,
|
- **Search**: `/` focuses the bar. `!w cats` uses DuckDuckGo bangs. `/settings`, `/add link`,
|
||||||
|
|||||||
@@ -0,0 +1 @@
|
|||||||
|
ALTER TABLE "dashboard" ADD COLUMN "position" integer DEFAULT 0 NOT NULL;
|
||||||
@@ -0,0 +1,916 @@
|
|||||||
|
{
|
||||||
|
"id": "c4525c58-c6aa-4d91-a377-92f7483f75fd",
|
||||||
|
"prevId": "eddd02da-41ed-40a6-b0b0-e5976ea2c371",
|
||||||
|
"version": "7",
|
||||||
|
"dialect": "postgresql",
|
||||||
|
"tables": {
|
||||||
|
"public.account": {
|
||||||
|
"name": "account",
|
||||||
|
"schema": "",
|
||||||
|
"columns": {
|
||||||
|
"id": {
|
||||||
|
"name": "id",
|
||||||
|
"type": "text",
|
||||||
|
"primaryKey": true,
|
||||||
|
"notNull": true
|
||||||
|
},
|
||||||
|
"account_id": {
|
||||||
|
"name": "account_id",
|
||||||
|
"type": "text",
|
||||||
|
"primaryKey": false,
|
||||||
|
"notNull": true
|
||||||
|
},
|
||||||
|
"provider_id": {
|
||||||
|
"name": "provider_id",
|
||||||
|
"type": "text",
|
||||||
|
"primaryKey": false,
|
||||||
|
"notNull": true
|
||||||
|
},
|
||||||
|
"user_id": {
|
||||||
|
"name": "user_id",
|
||||||
|
"type": "text",
|
||||||
|
"primaryKey": false,
|
||||||
|
"notNull": true
|
||||||
|
},
|
||||||
|
"access_token": {
|
||||||
|
"name": "access_token",
|
||||||
|
"type": "text",
|
||||||
|
"primaryKey": false,
|
||||||
|
"notNull": false
|
||||||
|
},
|
||||||
|
"refresh_token": {
|
||||||
|
"name": "refresh_token",
|
||||||
|
"type": "text",
|
||||||
|
"primaryKey": false,
|
||||||
|
"notNull": false
|
||||||
|
},
|
||||||
|
"id_token": {
|
||||||
|
"name": "id_token",
|
||||||
|
"type": "text",
|
||||||
|
"primaryKey": false,
|
||||||
|
"notNull": false
|
||||||
|
},
|
||||||
|
"access_token_expires_at": {
|
||||||
|
"name": "access_token_expires_at",
|
||||||
|
"type": "timestamp",
|
||||||
|
"primaryKey": false,
|
||||||
|
"notNull": false
|
||||||
|
},
|
||||||
|
"refresh_token_expires_at": {
|
||||||
|
"name": "refresh_token_expires_at",
|
||||||
|
"type": "timestamp",
|
||||||
|
"primaryKey": false,
|
||||||
|
"notNull": false
|
||||||
|
},
|
||||||
|
"scope": {
|
||||||
|
"name": "scope",
|
||||||
|
"type": "text",
|
||||||
|
"primaryKey": false,
|
||||||
|
"notNull": false
|
||||||
|
},
|
||||||
|
"password": {
|
||||||
|
"name": "password",
|
||||||
|
"type": "text",
|
||||||
|
"primaryKey": false,
|
||||||
|
"notNull": false
|
||||||
|
},
|
||||||
|
"created_at": {
|
||||||
|
"name": "created_at",
|
||||||
|
"type": "timestamp",
|
||||||
|
"primaryKey": false,
|
||||||
|
"notNull": true,
|
||||||
|
"default": "now()"
|
||||||
|
},
|
||||||
|
"updated_at": {
|
||||||
|
"name": "updated_at",
|
||||||
|
"type": "timestamp",
|
||||||
|
"primaryKey": false,
|
||||||
|
"notNull": true,
|
||||||
|
"default": "now()"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"indexes": {
|
||||||
|
"account_user_id_idx": {
|
||||||
|
"name": "account_user_id_idx",
|
||||||
|
"columns": [
|
||||||
|
{
|
||||||
|
"expression": "user_id",
|
||||||
|
"isExpression": false,
|
||||||
|
"asc": true,
|
||||||
|
"nulls": "last"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"isUnique": false,
|
||||||
|
"concurrently": false,
|
||||||
|
"method": "btree",
|
||||||
|
"with": {}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"foreignKeys": {
|
||||||
|
"account_user_id_user_id_fk": {
|
||||||
|
"name": "account_user_id_user_id_fk",
|
||||||
|
"tableFrom": "account",
|
||||||
|
"tableTo": "user",
|
||||||
|
"columnsFrom": [
|
||||||
|
"user_id"
|
||||||
|
],
|
||||||
|
"columnsTo": [
|
||||||
|
"id"
|
||||||
|
],
|
||||||
|
"onDelete": "cascade",
|
||||||
|
"onUpdate": "no action"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"compositePrimaryKeys": {},
|
||||||
|
"uniqueConstraints": {},
|
||||||
|
"policies": {},
|
||||||
|
"checkConstraints": {},
|
||||||
|
"isRLSEnabled": false
|
||||||
|
},
|
||||||
|
"public.card": {
|
||||||
|
"name": "card",
|
||||||
|
"schema": "",
|
||||||
|
"columns": {
|
||||||
|
"id": {
|
||||||
|
"name": "id",
|
||||||
|
"type": "uuid",
|
||||||
|
"primaryKey": true,
|
||||||
|
"notNull": true,
|
||||||
|
"default": "gen_random_uuid()"
|
||||||
|
},
|
||||||
|
"user_id": {
|
||||||
|
"name": "user_id",
|
||||||
|
"type": "text",
|
||||||
|
"primaryKey": false,
|
||||||
|
"notNull": true
|
||||||
|
},
|
||||||
|
"dashboard_id": {
|
||||||
|
"name": "dashboard_id",
|
||||||
|
"type": "uuid",
|
||||||
|
"primaryKey": false,
|
||||||
|
"notNull": true
|
||||||
|
},
|
||||||
|
"position": {
|
||||||
|
"name": "position",
|
||||||
|
"type": "integer",
|
||||||
|
"primaryKey": false,
|
||||||
|
"notNull": true,
|
||||||
|
"default": 0
|
||||||
|
},
|
||||||
|
"name": {
|
||||||
|
"name": "name",
|
||||||
|
"type": "text",
|
||||||
|
"primaryKey": false,
|
||||||
|
"notNull": true
|
||||||
|
},
|
||||||
|
"created_at": {
|
||||||
|
"name": "created_at",
|
||||||
|
"type": "timestamp",
|
||||||
|
"primaryKey": false,
|
||||||
|
"notNull": true,
|
||||||
|
"default": "now()"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"indexes": {
|
||||||
|
"card_user_id_idx": {
|
||||||
|
"name": "card_user_id_idx",
|
||||||
|
"columns": [
|
||||||
|
{
|
||||||
|
"expression": "user_id",
|
||||||
|
"isExpression": false,
|
||||||
|
"asc": true,
|
||||||
|
"nulls": "last"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"isUnique": false,
|
||||||
|
"concurrently": false,
|
||||||
|
"method": "btree",
|
||||||
|
"with": {}
|
||||||
|
},
|
||||||
|
"card_dashboard_id_idx": {
|
||||||
|
"name": "card_dashboard_id_idx",
|
||||||
|
"columns": [
|
||||||
|
{
|
||||||
|
"expression": "dashboard_id",
|
||||||
|
"isExpression": false,
|
||||||
|
"asc": true,
|
||||||
|
"nulls": "last"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"isUnique": false,
|
||||||
|
"concurrently": false,
|
||||||
|
"method": "btree",
|
||||||
|
"with": {}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"foreignKeys": {
|
||||||
|
"card_user_id_user_id_fk": {
|
||||||
|
"name": "card_user_id_user_id_fk",
|
||||||
|
"tableFrom": "card",
|
||||||
|
"tableTo": "user",
|
||||||
|
"columnsFrom": [
|
||||||
|
"user_id"
|
||||||
|
],
|
||||||
|
"columnsTo": [
|
||||||
|
"id"
|
||||||
|
],
|
||||||
|
"onDelete": "cascade",
|
||||||
|
"onUpdate": "no action"
|
||||||
|
},
|
||||||
|
"card_dashboard_id_dashboard_id_fk": {
|
||||||
|
"name": "card_dashboard_id_dashboard_id_fk",
|
||||||
|
"tableFrom": "card",
|
||||||
|
"tableTo": "dashboard",
|
||||||
|
"columnsFrom": [
|
||||||
|
"dashboard_id"
|
||||||
|
],
|
||||||
|
"columnsTo": [
|
||||||
|
"id"
|
||||||
|
],
|
||||||
|
"onDelete": "cascade",
|
||||||
|
"onUpdate": "no action"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"compositePrimaryKeys": {},
|
||||||
|
"uniqueConstraints": {},
|
||||||
|
"policies": {},
|
||||||
|
"checkConstraints": {},
|
||||||
|
"isRLSEnabled": false
|
||||||
|
},
|
||||||
|
"public.dashboard": {
|
||||||
|
"name": "dashboard",
|
||||||
|
"schema": "",
|
||||||
|
"columns": {
|
||||||
|
"id": {
|
||||||
|
"name": "id",
|
||||||
|
"type": "uuid",
|
||||||
|
"primaryKey": true,
|
||||||
|
"notNull": true,
|
||||||
|
"default": "gen_random_uuid()"
|
||||||
|
},
|
||||||
|
"user_id": {
|
||||||
|
"name": "user_id",
|
||||||
|
"type": "text",
|
||||||
|
"primaryKey": false,
|
||||||
|
"notNull": true
|
||||||
|
},
|
||||||
|
"name": {
|
||||||
|
"name": "name",
|
||||||
|
"type": "text",
|
||||||
|
"primaryKey": false,
|
||||||
|
"notNull": true
|
||||||
|
},
|
||||||
|
"position": {
|
||||||
|
"name": "position",
|
||||||
|
"type": "integer",
|
||||||
|
"primaryKey": false,
|
||||||
|
"notNull": true,
|
||||||
|
"default": 0
|
||||||
|
},
|
||||||
|
"wallpaper_url": {
|
||||||
|
"name": "wallpaper_url",
|
||||||
|
"type": "text",
|
||||||
|
"primaryKey": false,
|
||||||
|
"notNull": false
|
||||||
|
},
|
||||||
|
"wallpaper_dim": {
|
||||||
|
"name": "wallpaper_dim",
|
||||||
|
"type": "integer",
|
||||||
|
"primaryKey": false,
|
||||||
|
"notNull": true,
|
||||||
|
"default": 40
|
||||||
|
},
|
||||||
|
"created_at": {
|
||||||
|
"name": "created_at",
|
||||||
|
"type": "timestamp",
|
||||||
|
"primaryKey": false,
|
||||||
|
"notNull": true,
|
||||||
|
"default": "now()"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"indexes": {
|
||||||
|
"dashboard_user_id_idx": {
|
||||||
|
"name": "dashboard_user_id_idx",
|
||||||
|
"columns": [
|
||||||
|
{
|
||||||
|
"expression": "user_id",
|
||||||
|
"isExpression": false,
|
||||||
|
"asc": true,
|
||||||
|
"nulls": "last"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"isUnique": false,
|
||||||
|
"concurrently": false,
|
||||||
|
"method": "btree",
|
||||||
|
"with": {}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"foreignKeys": {
|
||||||
|
"dashboard_user_id_user_id_fk": {
|
||||||
|
"name": "dashboard_user_id_user_id_fk",
|
||||||
|
"tableFrom": "dashboard",
|
||||||
|
"tableTo": "user",
|
||||||
|
"columnsFrom": [
|
||||||
|
"user_id"
|
||||||
|
],
|
||||||
|
"columnsTo": [
|
||||||
|
"id"
|
||||||
|
],
|
||||||
|
"onDelete": "cascade",
|
||||||
|
"onUpdate": "no action"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"compositePrimaryKeys": {},
|
||||||
|
"uniqueConstraints": {},
|
||||||
|
"policies": {},
|
||||||
|
"checkConstraints": {},
|
||||||
|
"isRLSEnabled": false
|
||||||
|
},
|
||||||
|
"public.icon": {
|
||||||
|
"name": "icon",
|
||||||
|
"schema": "",
|
||||||
|
"columns": {
|
||||||
|
"id": {
|
||||||
|
"name": "id",
|
||||||
|
"type": "uuid",
|
||||||
|
"primaryKey": true,
|
||||||
|
"notNull": true,
|
||||||
|
"default": "gen_random_uuid()"
|
||||||
|
},
|
||||||
|
"user_id": {
|
||||||
|
"name": "user_id",
|
||||||
|
"type": "text",
|
||||||
|
"primaryKey": false,
|
||||||
|
"notNull": true
|
||||||
|
},
|
||||||
|
"mime": {
|
||||||
|
"name": "mime",
|
||||||
|
"type": "text",
|
||||||
|
"primaryKey": false,
|
||||||
|
"notNull": true
|
||||||
|
},
|
||||||
|
"data": {
|
||||||
|
"name": "data",
|
||||||
|
"type": "bytea",
|
||||||
|
"primaryKey": false,
|
||||||
|
"notNull": true
|
||||||
|
},
|
||||||
|
"created_at": {
|
||||||
|
"name": "created_at",
|
||||||
|
"type": "timestamp",
|
||||||
|
"primaryKey": false,
|
||||||
|
"notNull": true,
|
||||||
|
"default": "now()"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"indexes": {
|
||||||
|
"icon_user_id_idx": {
|
||||||
|
"name": "icon_user_id_idx",
|
||||||
|
"columns": [
|
||||||
|
{
|
||||||
|
"expression": "user_id",
|
||||||
|
"isExpression": false,
|
||||||
|
"asc": true,
|
||||||
|
"nulls": "last"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"isUnique": false,
|
||||||
|
"concurrently": false,
|
||||||
|
"method": "btree",
|
||||||
|
"with": {}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"foreignKeys": {
|
||||||
|
"icon_user_id_user_id_fk": {
|
||||||
|
"name": "icon_user_id_user_id_fk",
|
||||||
|
"tableFrom": "icon",
|
||||||
|
"tableTo": "user",
|
||||||
|
"columnsFrom": [
|
||||||
|
"user_id"
|
||||||
|
],
|
||||||
|
"columnsTo": [
|
||||||
|
"id"
|
||||||
|
],
|
||||||
|
"onDelete": "cascade",
|
||||||
|
"onUpdate": "no action"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"compositePrimaryKeys": {},
|
||||||
|
"uniqueConstraints": {},
|
||||||
|
"policies": {},
|
||||||
|
"checkConstraints": {},
|
||||||
|
"isRLSEnabled": false
|
||||||
|
},
|
||||||
|
"public.link": {
|
||||||
|
"name": "link",
|
||||||
|
"schema": "",
|
||||||
|
"columns": {
|
||||||
|
"id": {
|
||||||
|
"name": "id",
|
||||||
|
"type": "uuid",
|
||||||
|
"primaryKey": true,
|
||||||
|
"notNull": true,
|
||||||
|
"default": "gen_random_uuid()"
|
||||||
|
},
|
||||||
|
"user_id": {
|
||||||
|
"name": "user_id",
|
||||||
|
"type": "text",
|
||||||
|
"primaryKey": false,
|
||||||
|
"notNull": true
|
||||||
|
},
|
||||||
|
"card_id": {
|
||||||
|
"name": "card_id",
|
||||||
|
"type": "uuid",
|
||||||
|
"primaryKey": false,
|
||||||
|
"notNull": true
|
||||||
|
},
|
||||||
|
"position": {
|
||||||
|
"name": "position",
|
||||||
|
"type": "integer",
|
||||||
|
"primaryKey": false,
|
||||||
|
"notNull": true,
|
||||||
|
"default": 0
|
||||||
|
},
|
||||||
|
"name": {
|
||||||
|
"name": "name",
|
||||||
|
"type": "text",
|
||||||
|
"primaryKey": false,
|
||||||
|
"notNull": true
|
||||||
|
},
|
||||||
|
"url": {
|
||||||
|
"name": "url",
|
||||||
|
"type": "text",
|
||||||
|
"primaryKey": false,
|
||||||
|
"notNull": true
|
||||||
|
},
|
||||||
|
"icon": {
|
||||||
|
"name": "icon",
|
||||||
|
"type": "text",
|
||||||
|
"primaryKey": false,
|
||||||
|
"notNull": false
|
||||||
|
},
|
||||||
|
"created_at": {
|
||||||
|
"name": "created_at",
|
||||||
|
"type": "timestamp",
|
||||||
|
"primaryKey": false,
|
||||||
|
"notNull": true,
|
||||||
|
"default": "now()"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"indexes": {
|
||||||
|
"link_user_id_idx": {
|
||||||
|
"name": "link_user_id_idx",
|
||||||
|
"columns": [
|
||||||
|
{
|
||||||
|
"expression": "user_id",
|
||||||
|
"isExpression": false,
|
||||||
|
"asc": true,
|
||||||
|
"nulls": "last"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"isUnique": false,
|
||||||
|
"concurrently": false,
|
||||||
|
"method": "btree",
|
||||||
|
"with": {}
|
||||||
|
},
|
||||||
|
"link_card_id_idx": {
|
||||||
|
"name": "link_card_id_idx",
|
||||||
|
"columns": [
|
||||||
|
{
|
||||||
|
"expression": "card_id",
|
||||||
|
"isExpression": false,
|
||||||
|
"asc": true,
|
||||||
|
"nulls": "last"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"isUnique": false,
|
||||||
|
"concurrently": false,
|
||||||
|
"method": "btree",
|
||||||
|
"with": {}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"foreignKeys": {
|
||||||
|
"link_user_id_user_id_fk": {
|
||||||
|
"name": "link_user_id_user_id_fk",
|
||||||
|
"tableFrom": "link",
|
||||||
|
"tableTo": "user",
|
||||||
|
"columnsFrom": [
|
||||||
|
"user_id"
|
||||||
|
],
|
||||||
|
"columnsTo": [
|
||||||
|
"id"
|
||||||
|
],
|
||||||
|
"onDelete": "cascade",
|
||||||
|
"onUpdate": "no action"
|
||||||
|
},
|
||||||
|
"link_card_id_card_id_fk": {
|
||||||
|
"name": "link_card_id_card_id_fk",
|
||||||
|
"tableFrom": "link",
|
||||||
|
"tableTo": "card",
|
||||||
|
"columnsFrom": [
|
||||||
|
"card_id"
|
||||||
|
],
|
||||||
|
"columnsTo": [
|
||||||
|
"id"
|
||||||
|
],
|
||||||
|
"onDelete": "cascade",
|
||||||
|
"onUpdate": "no action"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"compositePrimaryKeys": {},
|
||||||
|
"uniqueConstraints": {},
|
||||||
|
"policies": {},
|
||||||
|
"checkConstraints": {},
|
||||||
|
"isRLSEnabled": false
|
||||||
|
},
|
||||||
|
"public.session": {
|
||||||
|
"name": "session",
|
||||||
|
"schema": "",
|
||||||
|
"columns": {
|
||||||
|
"id": {
|
||||||
|
"name": "id",
|
||||||
|
"type": "text",
|
||||||
|
"primaryKey": true,
|
||||||
|
"notNull": true
|
||||||
|
},
|
||||||
|
"expires_at": {
|
||||||
|
"name": "expires_at",
|
||||||
|
"type": "timestamp",
|
||||||
|
"primaryKey": false,
|
||||||
|
"notNull": true
|
||||||
|
},
|
||||||
|
"token": {
|
||||||
|
"name": "token",
|
||||||
|
"type": "text",
|
||||||
|
"primaryKey": false,
|
||||||
|
"notNull": true
|
||||||
|
},
|
||||||
|
"created_at": {
|
||||||
|
"name": "created_at",
|
||||||
|
"type": "timestamp",
|
||||||
|
"primaryKey": false,
|
||||||
|
"notNull": true,
|
||||||
|
"default": "now()"
|
||||||
|
},
|
||||||
|
"updated_at": {
|
||||||
|
"name": "updated_at",
|
||||||
|
"type": "timestamp",
|
||||||
|
"primaryKey": false,
|
||||||
|
"notNull": true,
|
||||||
|
"default": "now()"
|
||||||
|
},
|
||||||
|
"ip_address": {
|
||||||
|
"name": "ip_address",
|
||||||
|
"type": "text",
|
||||||
|
"primaryKey": false,
|
||||||
|
"notNull": false
|
||||||
|
},
|
||||||
|
"user_agent": {
|
||||||
|
"name": "user_agent",
|
||||||
|
"type": "text",
|
||||||
|
"primaryKey": false,
|
||||||
|
"notNull": false
|
||||||
|
},
|
||||||
|
"user_id": {
|
||||||
|
"name": "user_id",
|
||||||
|
"type": "text",
|
||||||
|
"primaryKey": false,
|
||||||
|
"notNull": true
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"indexes": {
|
||||||
|
"session_user_id_idx": {
|
||||||
|
"name": "session_user_id_idx",
|
||||||
|
"columns": [
|
||||||
|
{
|
||||||
|
"expression": "user_id",
|
||||||
|
"isExpression": false,
|
||||||
|
"asc": true,
|
||||||
|
"nulls": "last"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"isUnique": false,
|
||||||
|
"concurrently": false,
|
||||||
|
"method": "btree",
|
||||||
|
"with": {}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"foreignKeys": {
|
||||||
|
"session_user_id_user_id_fk": {
|
||||||
|
"name": "session_user_id_user_id_fk",
|
||||||
|
"tableFrom": "session",
|
||||||
|
"tableTo": "user",
|
||||||
|
"columnsFrom": [
|
||||||
|
"user_id"
|
||||||
|
],
|
||||||
|
"columnsTo": [
|
||||||
|
"id"
|
||||||
|
],
|
||||||
|
"onDelete": "cascade",
|
||||||
|
"onUpdate": "no action"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"compositePrimaryKeys": {},
|
||||||
|
"uniqueConstraints": {
|
||||||
|
"session_token_unique": {
|
||||||
|
"name": "session_token_unique",
|
||||||
|
"nullsNotDistinct": false,
|
||||||
|
"columns": [
|
||||||
|
"token"
|
||||||
|
]
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"policies": {},
|
||||||
|
"checkConstraints": {},
|
||||||
|
"isRLSEnabled": false
|
||||||
|
},
|
||||||
|
"public.settings": {
|
||||||
|
"name": "settings",
|
||||||
|
"schema": "",
|
||||||
|
"columns": {
|
||||||
|
"user_id": {
|
||||||
|
"name": "user_id",
|
||||||
|
"type": "text",
|
||||||
|
"primaryKey": true,
|
||||||
|
"notNull": true
|
||||||
|
},
|
||||||
|
"title": {
|
||||||
|
"name": "title",
|
||||||
|
"type": "text",
|
||||||
|
"primaryKey": false,
|
||||||
|
"notNull": true,
|
||||||
|
"default": "'Dahoam'"
|
||||||
|
},
|
||||||
|
"default_dashboard_id": {
|
||||||
|
"name": "default_dashboard_id",
|
||||||
|
"type": "uuid",
|
||||||
|
"primaryKey": false,
|
||||||
|
"notNull": false
|
||||||
|
},
|
||||||
|
"search_engine": {
|
||||||
|
"name": "search_engine",
|
||||||
|
"type": "text",
|
||||||
|
"primaryKey": false,
|
||||||
|
"notNull": true,
|
||||||
|
"default": "'duckduckgo'"
|
||||||
|
},
|
||||||
|
"clock_font": {
|
||||||
|
"name": "clock_font",
|
||||||
|
"type": "text",
|
||||||
|
"primaryKey": false,
|
||||||
|
"notNull": true,
|
||||||
|
"default": "'serif'"
|
||||||
|
},
|
||||||
|
"clock_style": {
|
||||||
|
"name": "clock_style",
|
||||||
|
"type": "text",
|
||||||
|
"primaryKey": false,
|
||||||
|
"notNull": true,
|
||||||
|
"default": "'solid'"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"indexes": {},
|
||||||
|
"foreignKeys": {
|
||||||
|
"settings_user_id_user_id_fk": {
|
||||||
|
"name": "settings_user_id_user_id_fk",
|
||||||
|
"tableFrom": "settings",
|
||||||
|
"tableTo": "user",
|
||||||
|
"columnsFrom": [
|
||||||
|
"user_id"
|
||||||
|
],
|
||||||
|
"columnsTo": [
|
||||||
|
"id"
|
||||||
|
],
|
||||||
|
"onDelete": "cascade",
|
||||||
|
"onUpdate": "no action"
|
||||||
|
},
|
||||||
|
"settings_default_dashboard_id_dashboard_id_fk": {
|
||||||
|
"name": "settings_default_dashboard_id_dashboard_id_fk",
|
||||||
|
"tableFrom": "settings",
|
||||||
|
"tableTo": "dashboard",
|
||||||
|
"columnsFrom": [
|
||||||
|
"default_dashboard_id"
|
||||||
|
],
|
||||||
|
"columnsTo": [
|
||||||
|
"id"
|
||||||
|
],
|
||||||
|
"onDelete": "set null",
|
||||||
|
"onUpdate": "no action"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"compositePrimaryKeys": {},
|
||||||
|
"uniqueConstraints": {},
|
||||||
|
"policies": {},
|
||||||
|
"checkConstraints": {},
|
||||||
|
"isRLSEnabled": false
|
||||||
|
},
|
||||||
|
"public.user": {
|
||||||
|
"name": "user",
|
||||||
|
"schema": "",
|
||||||
|
"columns": {
|
||||||
|
"id": {
|
||||||
|
"name": "id",
|
||||||
|
"type": "text",
|
||||||
|
"primaryKey": true,
|
||||||
|
"notNull": true
|
||||||
|
},
|
||||||
|
"name": {
|
||||||
|
"name": "name",
|
||||||
|
"type": "text",
|
||||||
|
"primaryKey": false,
|
||||||
|
"notNull": true
|
||||||
|
},
|
||||||
|
"email": {
|
||||||
|
"name": "email",
|
||||||
|
"type": "text",
|
||||||
|
"primaryKey": false,
|
||||||
|
"notNull": true
|
||||||
|
},
|
||||||
|
"email_verified": {
|
||||||
|
"name": "email_verified",
|
||||||
|
"type": "boolean",
|
||||||
|
"primaryKey": false,
|
||||||
|
"notNull": true,
|
||||||
|
"default": false
|
||||||
|
},
|
||||||
|
"image": {
|
||||||
|
"name": "image",
|
||||||
|
"type": "text",
|
||||||
|
"primaryKey": false,
|
||||||
|
"notNull": false
|
||||||
|
},
|
||||||
|
"created_at": {
|
||||||
|
"name": "created_at",
|
||||||
|
"type": "timestamp",
|
||||||
|
"primaryKey": false,
|
||||||
|
"notNull": true,
|
||||||
|
"default": "now()"
|
||||||
|
},
|
||||||
|
"updated_at": {
|
||||||
|
"name": "updated_at",
|
||||||
|
"type": "timestamp",
|
||||||
|
"primaryKey": false,
|
||||||
|
"notNull": true,
|
||||||
|
"default": "now()"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"indexes": {},
|
||||||
|
"foreignKeys": {},
|
||||||
|
"compositePrimaryKeys": {},
|
||||||
|
"uniqueConstraints": {
|
||||||
|
"user_email_unique": {
|
||||||
|
"name": "user_email_unique",
|
||||||
|
"nullsNotDistinct": false,
|
||||||
|
"columns": [
|
||||||
|
"email"
|
||||||
|
]
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"policies": {},
|
||||||
|
"checkConstraints": {},
|
||||||
|
"isRLSEnabled": false
|
||||||
|
},
|
||||||
|
"public.verification": {
|
||||||
|
"name": "verification",
|
||||||
|
"schema": "",
|
||||||
|
"columns": {
|
||||||
|
"id": {
|
||||||
|
"name": "id",
|
||||||
|
"type": "text",
|
||||||
|
"primaryKey": true,
|
||||||
|
"notNull": true
|
||||||
|
},
|
||||||
|
"identifier": {
|
||||||
|
"name": "identifier",
|
||||||
|
"type": "text",
|
||||||
|
"primaryKey": false,
|
||||||
|
"notNull": true
|
||||||
|
},
|
||||||
|
"value": {
|
||||||
|
"name": "value",
|
||||||
|
"type": "text",
|
||||||
|
"primaryKey": false,
|
||||||
|
"notNull": true
|
||||||
|
},
|
||||||
|
"expires_at": {
|
||||||
|
"name": "expires_at",
|
||||||
|
"type": "timestamp",
|
||||||
|
"primaryKey": false,
|
||||||
|
"notNull": true
|
||||||
|
},
|
||||||
|
"created_at": {
|
||||||
|
"name": "created_at",
|
||||||
|
"type": "timestamp",
|
||||||
|
"primaryKey": false,
|
||||||
|
"notNull": true,
|
||||||
|
"default": "now()"
|
||||||
|
},
|
||||||
|
"updated_at": {
|
||||||
|
"name": "updated_at",
|
||||||
|
"type": "timestamp",
|
||||||
|
"primaryKey": false,
|
||||||
|
"notNull": true,
|
||||||
|
"default": "now()"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"indexes": {
|
||||||
|
"verification_identifier_idx": {
|
||||||
|
"name": "verification_identifier_idx",
|
||||||
|
"columns": [
|
||||||
|
{
|
||||||
|
"expression": "identifier",
|
||||||
|
"isExpression": false,
|
||||||
|
"asc": true,
|
||||||
|
"nulls": "last"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"isUnique": false,
|
||||||
|
"concurrently": false,
|
||||||
|
"method": "btree",
|
||||||
|
"with": {}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"foreignKeys": {},
|
||||||
|
"compositePrimaryKeys": {},
|
||||||
|
"uniqueConstraints": {},
|
||||||
|
"policies": {},
|
||||||
|
"checkConstraints": {},
|
||||||
|
"isRLSEnabled": false
|
||||||
|
},
|
||||||
|
"public.wallpaper": {
|
||||||
|
"name": "wallpaper",
|
||||||
|
"schema": "",
|
||||||
|
"columns": {
|
||||||
|
"dashboard_id": {
|
||||||
|
"name": "dashboard_id",
|
||||||
|
"type": "uuid",
|
||||||
|
"primaryKey": true,
|
||||||
|
"notNull": true
|
||||||
|
},
|
||||||
|
"user_id": {
|
||||||
|
"name": "user_id",
|
||||||
|
"type": "text",
|
||||||
|
"primaryKey": false,
|
||||||
|
"notNull": true
|
||||||
|
},
|
||||||
|
"mime": {
|
||||||
|
"name": "mime",
|
||||||
|
"type": "text",
|
||||||
|
"primaryKey": false,
|
||||||
|
"notNull": true
|
||||||
|
},
|
||||||
|
"data": {
|
||||||
|
"name": "data",
|
||||||
|
"type": "bytea",
|
||||||
|
"primaryKey": false,
|
||||||
|
"notNull": true
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"indexes": {},
|
||||||
|
"foreignKeys": {
|
||||||
|
"wallpaper_dashboard_id_dashboard_id_fk": {
|
||||||
|
"name": "wallpaper_dashboard_id_dashboard_id_fk",
|
||||||
|
"tableFrom": "wallpaper",
|
||||||
|
"tableTo": "dashboard",
|
||||||
|
"columnsFrom": [
|
||||||
|
"dashboard_id"
|
||||||
|
],
|
||||||
|
"columnsTo": [
|
||||||
|
"id"
|
||||||
|
],
|
||||||
|
"onDelete": "cascade",
|
||||||
|
"onUpdate": "no action"
|
||||||
|
},
|
||||||
|
"wallpaper_user_id_user_id_fk": {
|
||||||
|
"name": "wallpaper_user_id_user_id_fk",
|
||||||
|
"tableFrom": "wallpaper",
|
||||||
|
"tableTo": "user",
|
||||||
|
"columnsFrom": [
|
||||||
|
"user_id"
|
||||||
|
],
|
||||||
|
"columnsTo": [
|
||||||
|
"id"
|
||||||
|
],
|
||||||
|
"onDelete": "cascade",
|
||||||
|
"onUpdate": "no action"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"compositePrimaryKeys": {},
|
||||||
|
"uniqueConstraints": {},
|
||||||
|
"policies": {},
|
||||||
|
"checkConstraints": {},
|
||||||
|
"isRLSEnabled": false
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"enums": {},
|
||||||
|
"schemas": {},
|
||||||
|
"sequences": {},
|
||||||
|
"roles": {},
|
||||||
|
"policies": {},
|
||||||
|
"views": {},
|
||||||
|
"_meta": {
|
||||||
|
"columns": {},
|
||||||
|
"schemas": {},
|
||||||
|
"tables": {}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -64,6 +64,13 @@
|
|||||||
"when": 1795106775546,
|
"when": 1795106775546,
|
||||||
"tag": "0008_card_position",
|
"tag": "0008_card_position",
|
||||||
"breakpoints": true
|
"breakpoints": true
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"idx": 9,
|
||||||
|
"version": "7",
|
||||||
|
"when": 1795285309906,
|
||||||
|
"tag": "0009_dashboard_position",
|
||||||
|
"breakpoints": true
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
@@ -9,6 +9,8 @@ import {
|
|||||||
FieldError,
|
FieldError,
|
||||||
FieldLabel,
|
FieldLabel,
|
||||||
Input,
|
Input,
|
||||||
|
Select,
|
||||||
|
SelectOption,
|
||||||
} from "@/vendor/collabry/components/Field/Field"
|
} from "@/vendor/collabry/components/Field/Field"
|
||||||
import {
|
import {
|
||||||
Dialog,
|
Dialog,
|
||||||
@@ -21,17 +23,22 @@ import {
|
|||||||
|
|
||||||
export type CardTarget = { id: string; name: string; links: unknown[] } | "new"
|
export type CardTarget = { id: string; name: string; links: unknown[] } | "new"
|
||||||
|
|
||||||
|
type Dashboards = { id: string; name: string }[]
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* `card` is the card to edit, "new" to add one, or null when closed.
|
* `card` is the card to edit, "new" to add one, or null when closed.
|
||||||
* A new card goes on the dashboard `dashboardId`.
|
* `dashboardId` is the open dashboard: where a new card goes, and where a card is
|
||||||
|
* until another of `dashboards` is chosen for it.
|
||||||
*/
|
*/
|
||||||
export function CardDialog({
|
export function CardDialog({
|
||||||
card,
|
card,
|
||||||
dashboardId,
|
dashboardId,
|
||||||
|
dashboards,
|
||||||
onClose,
|
onClose,
|
||||||
}: {
|
}: {
|
||||||
card: CardTarget | null
|
card: CardTarget | null
|
||||||
dashboardId: string
|
dashboardId: string
|
||||||
|
dashboards: Dashboards
|
||||||
onClose: () => void
|
onClose: () => void
|
||||||
}) {
|
}) {
|
||||||
return (
|
return (
|
||||||
@@ -41,6 +48,7 @@ export function CardDialog({
|
|||||||
<CardForm
|
<CardForm
|
||||||
card={card === "new" ? null : card}
|
card={card === "new" ? null : card}
|
||||||
dashboardId={dashboardId}
|
dashboardId={dashboardId}
|
||||||
|
dashboards={dashboards}
|
||||||
onClose={onClose}
|
onClose={onClose}
|
||||||
/>
|
/>
|
||||||
)}
|
)}
|
||||||
@@ -52,10 +60,12 @@ export function CardDialog({
|
|||||||
function CardForm({
|
function CardForm({
|
||||||
card,
|
card,
|
||||||
dashboardId,
|
dashboardId,
|
||||||
|
dashboards,
|
||||||
onClose,
|
onClose,
|
||||||
}: {
|
}: {
|
||||||
card: Exclude<CardTarget, "new"> | null
|
card: Exclude<CardTarget, "new"> | null
|
||||||
dashboardId: string
|
dashboardId: string
|
||||||
|
dashboards: Dashboards
|
||||||
onClose: () => void
|
onClose: () => void
|
||||||
}) {
|
}) {
|
||||||
const router = useRouter()
|
const router = useRouter()
|
||||||
@@ -82,9 +92,16 @@ function CardForm({
|
|||||||
<form
|
<form
|
||||||
onSubmit={(e) => {
|
onSubmit={(e) => {
|
||||||
e.preventDefault()
|
e.preventDefault()
|
||||||
const name = String(new FormData(e.currentTarget).get("name"))
|
const form = new FormData(e.currentTarget)
|
||||||
void submit(() =>
|
void submit(() =>
|
||||||
saveCard({ data: { id: card?.id, name, dashboardId } })
|
saveCard({
|
||||||
|
data: {
|
||||||
|
id: card?.id,
|
||||||
|
name: String(form.get("name")),
|
||||||
|
// without the field there is only one dashboard
|
||||||
|
dashboardId: String(form.get("dashboardId") ?? dashboardId),
|
||||||
|
},
|
||||||
|
})
|
||||||
)
|
)
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
@@ -105,6 +122,18 @@ function CardForm({
|
|||||||
required
|
required
|
||||||
/>
|
/>
|
||||||
</Field>
|
</Field>
|
||||||
|
{dashboards.length > 1 && (
|
||||||
|
<Field>
|
||||||
|
<FieldLabel>Dashboard</FieldLabel>
|
||||||
|
<Select name="dashboardId" defaultValue={dashboardId}>
|
||||||
|
{dashboards.map((d) => (
|
||||||
|
<SelectOption key={d.id} value={d.id}>
|
||||||
|
{d.name}
|
||||||
|
</SelectOption>
|
||||||
|
))}
|
||||||
|
</Select>
|
||||||
|
</Field>
|
||||||
|
)}
|
||||||
{error && <FieldError role="alert">{error}</FieldError>}
|
{error && <FieldError role="alert">{error}</FieldError>}
|
||||||
</DialogBody>
|
</DialogBody>
|
||||||
<DialogFooter className="justify-between">
|
<DialogFooter className="justify-between">
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ import { useRouter } from "@tanstack/react-router"
|
|||||||
import { Trash2, Upload, X } from "lucide-react"
|
import { Trash2, Upload, X } from "lucide-react"
|
||||||
import { GlassDialogContent } from "@/components/glass"
|
import { GlassDialogContent } from "@/components/glass"
|
||||||
import type { HomeLink } from "@/components/link-tile"
|
import type { HomeLink } from "@/components/link-tile"
|
||||||
import { deleteLink, saveLink } from "@/lib/dashboard.functions"
|
import { deleteLink, getIcons, saveLink } from "@/lib/dashboard.functions"
|
||||||
import {
|
import {
|
||||||
LIBRARY_INDEX,
|
LIBRARY_INDEX,
|
||||||
UPLOADED_ICON,
|
UPLOADED_ICON,
|
||||||
@@ -31,6 +31,51 @@ import {
|
|||||||
DialogTitle,
|
DialogTitle,
|
||||||
} from "@/vendor/collabry/components/ui/dialog"
|
} from "@/vendor/collabry/components/ui/dialog"
|
||||||
|
|
||||||
|
/** A grid of icons to click. Two and a half rows, so it shows that there is more to scroll to. */
|
||||||
|
function IconChoices({
|
||||||
|
label,
|
||||||
|
icons,
|
||||||
|
chosen,
|
||||||
|
named,
|
||||||
|
onChoose,
|
||||||
|
}: {
|
||||||
|
label: string
|
||||||
|
icons: string[]
|
||||||
|
chosen: string
|
||||||
|
/** names in the icon library. Without it: image addresses. */
|
||||||
|
named?: boolean
|
||||||
|
onChoose: (icon: string) => void
|
||||||
|
}) {
|
||||||
|
return (
|
||||||
|
<div
|
||||||
|
role="group"
|
||||||
|
aria-label={label}
|
||||||
|
className="grid max-h-29 grid-cols-7 gap-1 overflow-y-auto rounded-xl bg-white/5 p-1"
|
||||||
|
>
|
||||||
|
{icons.map((icon, i) => (
|
||||||
|
<button
|
||||||
|
key={icon}
|
||||||
|
type="button"
|
||||||
|
title={named ? icon : undefined}
|
||||||
|
// an upload has no name: "Your images 2"
|
||||||
|
aria-label={named ? icon : `${label} ${i + 1}`}
|
||||||
|
aria-pressed={icon === chosen}
|
||||||
|
onClick={() => onChoose(icon)}
|
||||||
|
className="grid h-11 place-items-center rounded-lg outline-none hover:bg-white/10 focus-visible:ring-2 focus-visible:ring-white/60 aria-pressed:bg-white/15"
|
||||||
|
>
|
||||||
|
<img
|
||||||
|
src={named ? libraryIcon(icon) : icon}
|
||||||
|
alt=""
|
||||||
|
loading="lazy"
|
||||||
|
referrerPolicy="no-referrer"
|
||||||
|
className="size-8 object-contain"
|
||||||
|
/>
|
||||||
|
</button>
|
||||||
|
))}
|
||||||
|
</div>
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
/** A link to edit, or only the card that a new link starts in. */
|
/** A link to edit, or only the card that a new link starts in. */
|
||||||
export type LinkTarget = HomeLink | { cardId: string }
|
export type LinkTarget = HomeLink | { cardId: string }
|
||||||
|
|
||||||
@@ -69,6 +114,8 @@ function LinkForm({
|
|||||||
const [name, setName] = useState(link?.name ?? "")
|
const [name, setName] = useState(link?.name ?? "")
|
||||||
const [icon, setIcon] = useState(link?.icon ?? "")
|
const [icon, setIcon] = useState(link?.icon ?? "")
|
||||||
const [library, setLibrary] = useState<string[]>([])
|
const [library, setLibrary] = useState<string[]>([])
|
||||||
|
// the images that this user uploaded before, to use one again
|
||||||
|
const [uploads, setUploads] = useState<string[]>([])
|
||||||
const file = useRef<HTMLInputElement>(null)
|
const file = useRef<HTMLInputElement>(null)
|
||||||
|
|
||||||
// Without the library's index the field still takes a name or an address.
|
// Without the library's index the field still takes a name or an address.
|
||||||
@@ -79,6 +126,9 @@ function LinkForm({
|
|||||||
setLibrary(index.png.map((f) => f.replace(/\.png$/, "")))
|
setLibrary(index.png.map((f) => f.replace(/\.png$/, "")))
|
||||||
)
|
)
|
||||||
.catch(() => {})
|
.catch(() => {})
|
||||||
|
getIcons()
|
||||||
|
.then(setUploads)
|
||||||
|
.catch(() => {})
|
||||||
}, [])
|
}, [])
|
||||||
|
|
||||||
const uploaded = icon.startsWith(UPLOADED_ICON)
|
const uploaded = icon.startsWith(UPLOADED_ICON)
|
||||||
@@ -94,8 +144,11 @@ function LinkForm({
|
|||||||
headers: { "Content-Type": image.type },
|
headers: { "Content-Type": image.type },
|
||||||
body: image,
|
body: image,
|
||||||
})
|
})
|
||||||
if (res.ok) setIcon((await res.json()).icon)
|
if (res.ok) {
|
||||||
else setError(await res.text())
|
const added: string = (await res.json()).icon
|
||||||
|
setIcon(added)
|
||||||
|
setUploads((before) => [added, ...before])
|
||||||
|
} else setError(await res.text())
|
||||||
} catch {
|
} catch {
|
||||||
setError("Could not upload. Try again.")
|
setError("Could not upload. Try again.")
|
||||||
}
|
}
|
||||||
@@ -209,32 +262,21 @@ function LinkForm({
|
|||||||
</Button>
|
</Button>
|
||||||
</div>
|
</div>
|
||||||
{matches.length > 0 && (
|
{matches.length > 0 && (
|
||||||
// two and a half rows, so it shows that there is more to scroll to
|
<IconChoices
|
||||||
<div
|
label="Icons from the library"
|
||||||
role="group"
|
icons={matches}
|
||||||
aria-label="Icons from the library"
|
chosen={icon}
|
||||||
className="grid max-h-29 grid-cols-7 gap-1 overflow-y-auto rounded-xl bg-white/5 p-1"
|
named
|
||||||
>
|
onChoose={setIcon}
|
||||||
{matches.map((match) => (
|
/>
|
||||||
<button
|
)}
|
||||||
key={match}
|
{uploads.length > 0 && (
|
||||||
type="button"
|
<IconChoices
|
||||||
title={match}
|
label="Your images"
|
||||||
aria-label={match}
|
icons={uploads}
|
||||||
aria-pressed={match === icon}
|
chosen={icon}
|
||||||
onClick={() => setIcon(match)}
|
onChoose={setIcon}
|
||||||
className="grid h-11 place-items-center rounded-lg outline-none hover:bg-white/10 focus-visible:ring-2 focus-visible:ring-white/60 aria-pressed:bg-white/15"
|
/>
|
||||||
>
|
|
||||||
<img
|
|
||||||
src={libraryIcon(match)}
|
|
||||||
alt=""
|
|
||||||
loading="lazy"
|
|
||||||
referrerPolicy="no-referrer"
|
|
||||||
className="size-8 object-contain"
|
|
||||||
/>
|
|
||||||
</button>
|
|
||||||
))}
|
|
||||||
</div>
|
|
||||||
)}
|
)}
|
||||||
<FieldDescription>
|
<FieldDescription>
|
||||||
Empty: found from the name (the light version, when the library has
|
Empty: found from the name (the light version, when the library has
|
||||||
|
|||||||
+3
-1
@@ -86,6 +86,8 @@ export const dashboard = pgTable(
|
|||||||
.notNull()
|
.notNull()
|
||||||
.references(() => user.id, { onDelete: "cascade" }),
|
.references(() => user.id, { onDelete: "cascade" }),
|
||||||
name: text("name").notNull(),
|
name: text("name").notNull(),
|
||||||
|
// order in the switcher and in the settings
|
||||||
|
position: integer("position").notNull().default(0),
|
||||||
// null = bundled default wallpaper
|
// null = bundled default wallpaper
|
||||||
wallpaperUrl: text("wallpaper_url"),
|
wallpaperUrl: text("wallpaper_url"),
|
||||||
// percent of black over the wallpaper, see DEFAULT_WALLPAPER_DIM
|
// percent of black over the wallpaper, see DEFAULT_WALLPAPER_DIM
|
||||||
@@ -147,7 +149,7 @@ export const settings = pgTable("settings", {
|
|||||||
.primaryKey()
|
.primaryKey()
|
||||||
.references(() => user.id, { onDelete: "cascade" }),
|
.references(() => user.id, { onDelete: "cascade" }),
|
||||||
title: text("title").notNull().default("Dahoam"),
|
title: text("title").notNull().default("Dahoam"),
|
||||||
// the dashboard that opens after sign-in; null = the oldest one
|
// the dashboard that opens after sign-in; null = the first one
|
||||||
defaultDashboardId: uuid("default_dashboard_id").references(
|
defaultDashboardId: uuid("default_dashboard_id").references(
|
||||||
() => dashboard.id,
|
() => dashboard.id,
|
||||||
{ onDelete: "set null" }
|
{ onDelete: "set null" }
|
||||||
|
|||||||
@@ -1,12 +1,13 @@
|
|||||||
import { createServerFn } from "@tanstack/react-start"
|
import { createServerFn } from "@tanstack/react-start"
|
||||||
import { getRequestHeaders } from "@tanstack/react-start/server"
|
import { getRequestHeaders } from "@tanstack/react-start/server"
|
||||||
import { and, asc, eq, inArray, sql } from "drizzle-orm"
|
import { and, asc, desc, eq, inArray, sql } from "drizzle-orm"
|
||||||
import { z } from "zod"
|
import { z } from "zod"
|
||||||
import { db } from "@/db"
|
import { db } from "@/db"
|
||||||
import {
|
import {
|
||||||
account,
|
account,
|
||||||
card,
|
card,
|
||||||
dashboard,
|
dashboard,
|
||||||
|
icon,
|
||||||
link,
|
link,
|
||||||
settings,
|
settings,
|
||||||
wallpaper,
|
wallpaper,
|
||||||
@@ -14,7 +15,7 @@ import {
|
|||||||
import { auth, requireUser, signUpEnabled, ssoName } from "@/lib/auth"
|
import { auth, requireUser, signUpEnabled, ssoName } from "@/lib/auth"
|
||||||
import { CLOCK_FONTS, CLOCK_STYLES } from "@/lib/clock"
|
import { CLOCK_FONTS, CLOCK_STYLES } from "@/lib/clock"
|
||||||
import { libraryNames } from "@/lib/icon-library"
|
import { libraryNames } from "@/lib/icon-library"
|
||||||
import { lightVariant } from "@/lib/icons"
|
import { UPLOADED_ICON, lightVariant } from "@/lib/icons"
|
||||||
import { ENGINES, parseSuggestions } from "@/lib/search"
|
import { ENGINES, parseSuggestions } from "@/lib/search"
|
||||||
import { isReachable, statusChecks } from "@/lib/status"
|
import { isReachable, statusChecks } from "@/lib/status"
|
||||||
import { backupSchema, portable } from "@/lib/transfer"
|
import { backupSchema, portable } from "@/lib/transfer"
|
||||||
@@ -42,6 +43,17 @@ async function requireDashboard(userId: string, dashboardId: string) {
|
|||||||
const endOf = (cardId: string) =>
|
const endOf = (cardId: string) =>
|
||||||
sql<number>`(select coalesce(max(${link.position}) + 1, 0) from ${link} where ${link.cardId} = ${cardId})`
|
sql<number>`(select coalesce(max(${link.position}) + 1, 0) from ${link} where ${link.cardId} = ${cardId})`
|
||||||
|
|
||||||
|
/** The position after the last card of a dashboard. */
|
||||||
|
const endOfDashboard = (dashboardId: string) =>
|
||||||
|
sql<number>`(select coalesce(max(${card.position}) + 1, 0) from ${card} where ${card.dashboardId} = ${dashboardId})`
|
||||||
|
|
||||||
|
/** The position after the last dashboard of a user. */
|
||||||
|
const lastDashboard = (userId: string) =>
|
||||||
|
sql<number>`(select coalesce(max(${dashboard.position}) + 1, 0) from ${dashboard} where ${dashboard.userId} = ${userId})`
|
||||||
|
|
||||||
|
// dashboards that were never moved all have position 0: oldest first
|
||||||
|
const dashboardOrder = [asc(dashboard.position), asc(dashboard.createdAt)]
|
||||||
|
|
||||||
export const getAuthInfo = createServerFn({ method: "GET" }).handler(
|
export const getAuthInfo = createServerFn({ method: "GET" }).handler(
|
||||||
async () => ({
|
async () => ({
|
||||||
signedIn: !!(await auth.api.getSession({ headers: getRequestHeaders() })),
|
signedIn: !!(await auth.api.getSession({ headers: getRequestHeaders() })),
|
||||||
@@ -74,7 +86,7 @@ export const getDashboard = createServerFn({ method: "GET" })
|
|||||||
.select(shown)
|
.select(shown)
|
||||||
.from(dashboard)
|
.from(dashboard)
|
||||||
.where(eq(dashboard.userId, userId))
|
.where(eq(dashboard.userId, userId))
|
||||||
.orderBy(asc(dashboard.createdAt)),
|
.orderBy(...dashboardOrder),
|
||||||
db.select().from(settings).where(eq(settings.userId, userId)),
|
db.select().from(settings).where(eq(settings.userId, userId)),
|
||||||
// someone who only ever signed in with SSO has no password to change
|
// someone who only ever signed in with SSO has no password to change
|
||||||
db.$count(
|
db.$count(
|
||||||
@@ -208,26 +220,28 @@ export const saveCard = createServerFn({ method: "POST" })
|
|||||||
z.object({
|
z.object({
|
||||||
id: z.uuid().optional(),
|
id: z.uuid().optional(),
|
||||||
name: z.string().trim().min(1).max(40),
|
name: z.string().trim().min(1).max(40),
|
||||||
// where a new card goes. A card that exists stays on its dashboard.
|
// the dashboard of the card. Another one than before moves the card there.
|
||||||
dashboardId: z.uuid(),
|
dashboardId: z.uuid(),
|
||||||
})
|
})
|
||||||
)
|
)
|
||||||
.handler(async ({ data: { id, name, dashboardId } }) => {
|
.handler(async ({ data: { id, name, dashboardId } }) => {
|
||||||
const user = await requireUser()
|
const user = await requireUser()
|
||||||
|
await requireDashboard(user.id, dashboardId)
|
||||||
|
const end = endOfDashboard(dashboardId)
|
||||||
if (id) {
|
if (id) {
|
||||||
await db
|
await db
|
||||||
.update(card)
|
.update(card)
|
||||||
.set({ name })
|
.set({
|
||||||
|
name,
|
||||||
|
dashboardId,
|
||||||
|
// a card that changes dashboards goes after the last card there
|
||||||
|
position: sql`case when ${card.dashboardId} = ${dashboardId} then ${card.position} else ${end} end`,
|
||||||
|
})
|
||||||
.where(and(eq(card.id, id), eq(card.userId, user.id)))
|
.where(and(eq(card.id, id), eq(card.userId, user.id)))
|
||||||
} else {
|
} else {
|
||||||
await requireDashboard(user.id, dashboardId)
|
await db
|
||||||
await db.insert(card).values({
|
.insert(card)
|
||||||
name,
|
.values({ name, dashboardId, userId: user.id, position: end })
|
||||||
dashboardId,
|
|
||||||
userId: user.id,
|
|
||||||
// after the last card of the dashboard
|
|
||||||
position: sql`(select coalesce(max(${card.position}) + 1, 0) from ${card} where ${card.dashboardId} = ${dashboardId})`,
|
|
||||||
})
|
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
@@ -246,10 +260,38 @@ export const saveDashboard = createServerFn({ method: "POST" })
|
|||||||
.set({ name })
|
.set({ name })
|
||||||
.where(and(eq(dashboard.id, id), eq(dashboard.userId, user.id)))
|
.where(and(eq(dashboard.id, id), eq(dashboard.userId, user.id)))
|
||||||
} else {
|
} else {
|
||||||
await db.insert(dashboard).values({ name, userId: user.id })
|
await db
|
||||||
|
.insert(dashboard)
|
||||||
|
.values({ name, userId: user.id, position: lastDashboard(user.id) })
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
|
/** Stores the order of the dashboards: all of the user's, as they should appear. */
|
||||||
|
export const orderDashboards = createServerFn({ method: "POST" })
|
||||||
|
.validator(z.object({ ids: z.array(z.uuid()).max(500) }))
|
||||||
|
.handler(async ({ data }) => {
|
||||||
|
const user = await requireUser()
|
||||||
|
await db.transaction(async (tx) => {
|
||||||
|
for (const [position, id] of data.ids.entries())
|
||||||
|
await tx
|
||||||
|
.update(dashboard)
|
||||||
|
.set({ position })
|
||||||
|
.where(and(eq(dashboard.id, id), eq(dashboard.userId, user.id)))
|
||||||
|
})
|
||||||
|
})
|
||||||
|
|
||||||
|
/** The images that the user uploaded as icons, the newest first, as link icons. */
|
||||||
|
export const getIcons = createServerFn({ method: "GET" }).handler(async () => {
|
||||||
|
const user = await requireUser()
|
||||||
|
const icons = await db
|
||||||
|
.select({ id: icon.id })
|
||||||
|
.from(icon)
|
||||||
|
.where(eq(icon.userId, user.id))
|
||||||
|
.orderBy(desc(icon.createdAt))
|
||||||
|
.limit(60)
|
||||||
|
return icons.map((i) => UPLOADED_ICON + i.id)
|
||||||
|
})
|
||||||
|
|
||||||
/** Deletes the dashboard and, through the foreign keys, its cards and their links. */
|
/** Deletes the dashboard and, through the foreign keys, its cards and their links. */
|
||||||
export const deleteDashboard = createServerFn({ method: "POST" })
|
export const deleteDashboard = createServerFn({ method: "POST" })
|
||||||
.validator(z.object({ id: z.uuid() }))
|
.validator(z.object({ id: z.uuid() }))
|
||||||
@@ -372,7 +414,7 @@ export const exportData = createServerFn({ method: "GET" }).handler(
|
|||||||
.select()
|
.select()
|
||||||
.from(dashboard)
|
.from(dashboard)
|
||||||
.where(eq(dashboard.userId, user.id))
|
.where(eq(dashboard.userId, user.id))
|
||||||
.orderBy(asc(dashboard.createdAt)),
|
.orderBy(...dashboardOrder),
|
||||||
db
|
db
|
||||||
.select()
|
.select()
|
||||||
.from(card)
|
.from(card)
|
||||||
@@ -421,6 +463,7 @@ export const importData = createServerFn({ method: "POST" })
|
|||||||
.values({
|
.values({
|
||||||
userId,
|
userId,
|
||||||
name: d.name,
|
name: d.name,
|
||||||
|
position: lastDashboard(userId),
|
||||||
wallpaperUrl: d.wallpaperUrl,
|
wallpaperUrl: d.wallpaperUrl,
|
||||||
wallpaperDim: d.wallpaperDim,
|
wallpaperDim: d.wallpaperDim,
|
||||||
})
|
})
|
||||||
|
|||||||
@@ -241,6 +241,7 @@ function Dashboard() {
|
|||||||
<CardDialog
|
<CardDialog
|
||||||
card={card}
|
card={card}
|
||||||
dashboardId={data.dashboardId}
|
dashboardId={data.dashboardId}
|
||||||
|
dashboards={data.dashboards}
|
||||||
onClose={() => setCard(null)}
|
onClose={() => setCard(null)}
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
+35
-2
@@ -8,8 +8,10 @@ import {
|
|||||||
useRouter,
|
useRouter,
|
||||||
} from "@tanstack/react-router"
|
} from "@tanstack/react-router"
|
||||||
import {
|
import {
|
||||||
|
ArrowDown,
|
||||||
ArrowDownUp,
|
ArrowDownUp,
|
||||||
ArrowLeft,
|
ArrowLeft,
|
||||||
|
ArrowUp,
|
||||||
Check,
|
Check,
|
||||||
CircleUser,
|
CircleUser,
|
||||||
Clock,
|
Clock,
|
||||||
@@ -38,6 +40,7 @@ import {
|
|||||||
exportData,
|
exportData,
|
||||||
getDashboard,
|
getDashboard,
|
||||||
importData,
|
importData,
|
||||||
|
orderDashboards,
|
||||||
saveDashboard,
|
saveDashboard,
|
||||||
saveSettings,
|
saveSettings,
|
||||||
saveWallpaper,
|
saveWallpaper,
|
||||||
@@ -184,6 +187,13 @@ function Settings() {
|
|||||||
|
|
||||||
const uploaded = !!data.wallpaperUrl?.startsWith("/")
|
const uploaded = !!data.wallpaperUrl?.startsWith("/")
|
||||||
|
|
||||||
|
/** Swaps a dashboard with the one before (-1) or after it (1). */
|
||||||
|
const moveDashboard = (index: number, by: -1 | 1) => {
|
||||||
|
const ids = data.dashboards.map((d) => d.id)
|
||||||
|
;[ids[index], ids[index + by]] = [ids[index + by], ids[index]]
|
||||||
|
return run(() => orderDashboards({ data: { ids } }))
|
||||||
|
}
|
||||||
|
|
||||||
const download = async () => {
|
const download = async () => {
|
||||||
const backup = await exportData()
|
const backup = await exportData()
|
||||||
const url = URL.createObjectURL(
|
const url = URL.createObjectURL(
|
||||||
@@ -328,10 +338,11 @@ function Settings() {
|
|||||||
<SettingsSectionDescription>
|
<SettingsSectionDescription>
|
||||||
Each dashboard has its own cards, for example Home and Work.
|
Each dashboard has its own cards, for example Home and Work.
|
||||||
With more than one, you switch between them at the top of
|
With more than one, you switch between them at the top of
|
||||||
the dashboard. The default one opens when you sign in.
|
the dashboard, in the order that the arrows here set. The
|
||||||
|
default one opens when you sign in.
|
||||||
</SettingsSectionDescription>
|
</SettingsSectionDescription>
|
||||||
</SettingsSectionHeader>
|
</SettingsSectionHeader>
|
||||||
{data.dashboards.map((d) => {
|
{data.dashboards.map((d, i) => {
|
||||||
const isDefault = d.id === data.defaultDashboardId
|
const isDefault = d.id === data.defaultDashboardId
|
||||||
return (
|
return (
|
||||||
<SettingsRow key={d.id}>
|
<SettingsRow key={d.id}>
|
||||||
@@ -347,6 +358,28 @@ function Settings() {
|
|||||||
/>
|
/>
|
||||||
</SettingsRowText>
|
</SettingsRowText>
|
||||||
<SettingsRowControl className="flex flex-wrap gap-2">
|
<SettingsRowControl className="flex flex-wrap gap-2">
|
||||||
|
{data.dashboards.length > 1 && (
|
||||||
|
<>
|
||||||
|
<Button
|
||||||
|
variant="ghost"
|
||||||
|
iconOnly
|
||||||
|
aria-label={`Move ${d.name} up`}
|
||||||
|
disabled={i === 0}
|
||||||
|
onClick={() => moveDashboard(i, -1)}
|
||||||
|
>
|
||||||
|
<ArrowUp size={15} />
|
||||||
|
</Button>
|
||||||
|
<Button
|
||||||
|
variant="ghost"
|
||||||
|
iconOnly
|
||||||
|
aria-label={`Move ${d.name} down`}
|
||||||
|
disabled={i === data.dashboards.length - 1}
|
||||||
|
onClick={() => moveDashboard(i, 1)}
|
||||||
|
>
|
||||||
|
<ArrowDown size={15} />
|
||||||
|
</Button>
|
||||||
|
</>
|
||||||
|
)}
|
||||||
<Button
|
<Button
|
||||||
disabled={isDefault}
|
disabled={isDefault}
|
||||||
onClick={() => save({ defaultDashboardId: d.id })}
|
onClick={() => save({ defaultDashboardId: d.id })}
|
||||||
|
|||||||
Reference in New Issue
Block a user