Compare commits
11
Commits
7798432de6
...
main
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
e31d787769 | ||
|
|
51b52abb15 | ||
|
|
af73a386ed | ||
|
|
b6e5d81dc0 | ||
|
|
cba6eddc56 | ||
|
|
56ed40e8b0 | ||
|
|
c3225a7b91 | ||
|
|
5001cae163 | ||
|
|
dacd374946 | ||
|
|
e85244e820 | ||
|
|
4b9690e064 |
@@ -19,5 +19,10 @@ OIDC_CLIENT_ID=
|
||||
OIDC_CLIENT_SECRET=
|
||||
OIDC_PROVIDER_NAME=SSO
|
||||
|
||||
# Set to "true" to show on every link whether its address answers. The server then
|
||||
# calls the addresses that users save as links, once a minute. Leave it off when
|
||||
# people you do not trust can sign up: they could probe your network with it.
|
||||
STATUS_CHECKS=false
|
||||
|
||||
# SearXNG instance (must be reachable from the browser and from this server)
|
||||
SEARXNG_URL=
|
||||
|
||||
Generated
+12
@@ -0,0 +1,12 @@
|
||||
# Default ignored files
|
||||
/shelf/
|
||||
/workspace.xml
|
||||
# Markdown personal settings
|
||||
/markdown.xml
|
||||
# Editor-based HTTP Client requests
|
||||
/httpRequests/
|
||||
# Ignored default folder with query files
|
||||
/queries/
|
||||
# Datasource local storage ignored files
|
||||
/dataSources/
|
||||
/dataSources.local.xml
|
||||
Generated
+60
@@ -0,0 +1,60 @@
|
||||
<component name="ProjectCodeStyleConfiguration">
|
||||
<code_scheme name="Project" version="173">
|
||||
<option name="LINE_SEPARATOR" value=" " />
|
||||
<HTMLCodeStyleSettings>
|
||||
<option name="HTML_SPACE_INSIDE_EMPTY_TAG" value="true" />
|
||||
</HTMLCodeStyleSettings>
|
||||
<JSCodeStyleSettings version="0">
|
||||
<option name="USE_SEMICOLON_AFTER_STATEMENT" value="false" />
|
||||
<option name="FORCE_SEMICOLON_STYLE" value="true" />
|
||||
<option name="SPACE_BEFORE_FUNCTION_LEFT_PARENTH" value="false" />
|
||||
<option name="FORCE_QUOTE_STYlE" value="true" />
|
||||
<option name="ENFORCE_TRAILING_COMMA" value="WhenMultiline" />
|
||||
<option name="SPACES_WITHIN_OBJECT_LITERAL_BRACES" value="true" />
|
||||
<option name="SPACES_WITHIN_IMPORTS" value="true" />
|
||||
</JSCodeStyleSettings>
|
||||
<TypeScriptCodeStyleSettings version="0">
|
||||
<option name="USE_SEMICOLON_AFTER_STATEMENT" value="false" />
|
||||
<option name="FORCE_SEMICOLON_STYLE" value="true" />
|
||||
<option name="SPACE_BEFORE_FUNCTION_LEFT_PARENTH" value="false" />
|
||||
<option name="FORCE_QUOTE_STYlE" value="true" />
|
||||
<option name="ENFORCE_TRAILING_COMMA" value="WhenMultiline" />
|
||||
<option name="SPACES_WITHIN_OBJECT_LITERAL_BRACES" value="true" />
|
||||
<option name="SPACES_WITHIN_IMPORTS" value="true" />
|
||||
</TypeScriptCodeStyleSettings>
|
||||
<VueCodeStyleSettings>
|
||||
<option name="INTERPOLATION_NEW_LINE_AFTER_START_DELIMITER" value="false" />
|
||||
<option name="INTERPOLATION_NEW_LINE_BEFORE_END_DELIMITER" value="false" />
|
||||
</VueCodeStyleSettings>
|
||||
<codeStyleSettings language="HTML">
|
||||
<option name="SOFT_MARGINS" value="80" />
|
||||
<indentOptions>
|
||||
<option name="INDENT_SIZE" value="2" />
|
||||
<option name="CONTINUATION_INDENT_SIZE" value="2" />
|
||||
<option name="TAB_SIZE" value="2" />
|
||||
</indentOptions>
|
||||
</codeStyleSettings>
|
||||
<codeStyleSettings language="JavaScript">
|
||||
<option name="SOFT_MARGINS" value="80" />
|
||||
<indentOptions>
|
||||
<option name="INDENT_SIZE" value="2" />
|
||||
<option name="CONTINUATION_INDENT_SIZE" value="2" />
|
||||
<option name="TAB_SIZE" value="2" />
|
||||
</indentOptions>
|
||||
</codeStyleSettings>
|
||||
<codeStyleSettings language="TypeScript">
|
||||
<option name="SOFT_MARGINS" value="80" />
|
||||
<indentOptions>
|
||||
<option name="INDENT_SIZE" value="2" />
|
||||
<option name="CONTINUATION_INDENT_SIZE" value="2" />
|
||||
<option name="TAB_SIZE" value="2" />
|
||||
</indentOptions>
|
||||
</codeStyleSettings>
|
||||
<codeStyleSettings language="Vue">
|
||||
<option name="SOFT_MARGINS" value="80" />
|
||||
<indentOptions>
|
||||
<option name="CONTINUATION_INDENT_SIZE" value="2" />
|
||||
</indentOptions>
|
||||
</codeStyleSettings>
|
||||
</code_scheme>
|
||||
</component>
|
||||
Generated
+5
@@ -0,0 +1,5 @@
|
||||
<component name="ProjectCodeStyleConfiguration">
|
||||
<state>
|
||||
<option name="USE_PER_PROJECT_SETTINGS" value="true" />
|
||||
</state>
|
||||
</component>
|
||||
Generated
+8
@@ -0,0 +1,8 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<module type="WEB_MODULE" version="4">
|
||||
<component name="NewModuleRootManager">
|
||||
<content url="file://$MODULE_DIR$" />
|
||||
<orderEntry type="inheritedJdk" />
|
||||
<orderEntry type="sourceFolder" forTests="false" />
|
||||
</component>
|
||||
</module>
|
||||
+6
@@ -0,0 +1,6 @@
|
||||
<component name="InspectionProjectProfileManager">
|
||||
<profile version="1.0">
|
||||
<option name="myName" value="Project Default" />
|
||||
<inspection_tool class="Eslint" enabled="true" level="WARNING" enabled_by_default="true" />
|
||||
</profile>
|
||||
</component>
|
||||
Generated
+8
@@ -0,0 +1,8 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="ProjectModuleManager">
|
||||
<modules>
|
||||
<module fileurl="file://$PROJECT_DIR$/.idea/dahoam.iml" filepath="$PROJECT_DIR$/.idea/dahoam.iml" />
|
||||
</modules>
|
||||
</component>
|
||||
</project>
|
||||
Generated
+6
@@ -0,0 +1,6 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="PrettierConfiguration">
|
||||
<option name="myConfigurationMode" value="AUTOMATIC" />
|
||||
</component>
|
||||
</project>
|
||||
Generated
+6
@@ -0,0 +1,6 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="VcsDirectoryMappings">
|
||||
<mapping directory="" vcs="Git" />
|
||||
</component>
|
||||
</project>
|
||||
@@ -89,12 +89,42 @@ scripts/sync-collabry.sh copies them from upstream at a pinned commit
|
||||
the migrations on start (`src/db/index.ts`).
|
||||
- [x] 12. Renamed from "Home Dashboard" to Dahoam (slug `dahoam`): package, compose project, tab title,
|
||||
default dashboard name, docs, CI examples.
|
||||
- [x] 13. Dashboards: table `dashboard`, `card.dashboardId`, `settings.defaultDashboardId`
|
||||
(migration `0006_dashboards_icons` puts the existing cards on a dashboard "Home"). `/?d=<id>`
|
||||
opens one, `/` the default. Switcher in the header, managed in Settings → Dashboards.
|
||||
- [x] 14. Icons: the link dialog searches dashboard-icons (`src/lib/icons.ts` and its test) and
|
||||
uploads custom icons (table `icon`, `/api/icon`, ≤ 1 MB, SVG allowed because it is served
|
||||
sandboxed). `src/lib/upload.ts` holds the upload checks that wallpaper and icons share.
|
||||
- [x] 15. A wallpaper per dashboard: `wallpaperUrl` and `wallpaperDim` move from `settings` to
|
||||
`dashboard`, the `wallpaper` table is keyed by dashboard (migration `0007_dashboard_wallpaper`
|
||||
copies what each user had to all their dashboards). `/settings?d=<id>` is the dashboard whose
|
||||
wallpaper is shown, and where "Back to dashboard" goes.
|
||||
- [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.
|
||||
- [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)
|
||||
|
||||
- Unraid version/uptime chip and the Sonarr/Plex notification pills from the screenshot
|
||||
- Inline SearXNG result rendering (search opens the engine's result page)
|
||||
- Reordering the cards themselves (they stay in the order they were made), free placement 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), remembering the last opened
|
||||
dashboard (it would work against the default dashboard, which opens)
|
||||
- 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)
|
||||
- In CI: version tags and releases, a Helm chart, an image vulnerability scan (typst-workspace has all three)
|
||||
|
||||
@@ -49,23 +49,48 @@ Build it yourself: `docker build -t dahoam .`
|
||||
| `DISABLE_SIGNUP` | `true` closes email/password registration. Set it after you made your account. |
|
||||
| `OIDC_DISCOVERY_URL`, `OIDC_CLIENT_ID`, `OIDC_CLIENT_SECRET` | Turns on the SSO button. Redirect URI: `<BETTER_AUTH_URL>/api/auth/callback/sso` |
|
||||
| `OIDC_PROVIDER_NAME` | Text on the SSO button ("Continue with …") |
|
||||
| `STATUS_CHECKS` | `true` shows on every link whether its address answers. Off by default, see Notes. |
|
||||
| `SEARXNG_URL` | Your SearXNG instance. Makes SearXNG selectable in Settings. |
|
||||
|
||||
## Use
|
||||
|
||||
- **Dashboards** are separate sets of cards, for example Home and Work. Settings → Dashboards
|
||||
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
|
||||
of a dashboard (`/?d=…`) can be bookmarked. Every dashboard has its own wallpaper, clock
|
||||
and search are the same on all.
|
||||
- **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
|
||||
edit or delete it.
|
||||
- **Move links** by dragging, inside a card or to another card. Touch: press and hold first.
|
||||
Keyboard: focus a link, Space picks it up, arrow keys move it, Space puts it down.
|
||||
- **Move cards** by dragging their title bar, the links come along. Touch: press and hold
|
||||
first. Keyboard: Space on the grip next to the plus, arrow keys, Space.
|
||||
- **Icons**: leave the field empty and the icon is looked up by name in
|
||||
[dashboard-icons](https://github.com/homarr-labs/dashboard-icons), then from the
|
||||
site's `/favicon.ico`. Or enter an icon name (`home-assistant`) or an image URL.
|
||||
- **Search**: `/` focuses the bar. `!w cats` uses DuckDuckGo bangs. `/plex` jumps to
|
||||
a link, `/settings`, `/add link`, `/add card` and `/sign out` run commands.
|
||||
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,
|
||||
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
|
||||
answers, a red ring that it does not. Checked once a minute.
|
||||
- **Search**: `/` focuses the bar. `!w cats` uses DuckDuckGo bangs. `/settings`, `/add link`,
|
||||
`/add card`, `/add dashboard` and `/sign out` run commands.
|
||||
- **Open a link from the search bar**: type the start of its name (`jel` for Jellyfin). The
|
||||
link is highlighted and Enter opens it. To search the web for the same word, press the up
|
||||
arrow first, so that no row is highlighted. `/jel` shows only your links and commands.
|
||||
- **Wallpaper**: Settings (or the pencil at the bottom right) takes an image URL or an
|
||||
upload (JPEG, PNG, WebP, AVIF, up to 10 MB).
|
||||
upload (JPEG, PNG, WebP, AVIF, up to 10 MB). A slider sets how much it is darkened.
|
||||
Each dashboard has its own: the pencil opens the one of the dashboard you are on, and
|
||||
Settings → Wallpaper has a switch for the others.
|
||||
- **Export and import**: Settings → Export and import downloads all dashboards with their
|
||||
cards and links as one JSON file, and loads such a file again. It also takes the bookmarks
|
||||
file that a browser exports (HTML) and makes a dashboard "Bookmarks" of it, with a card per
|
||||
folder. An import adds dashboards and replaces nothing. Uploaded wallpapers and icons are
|
||||
not part of an export.
|
||||
- **Password**: Settings → Account changes it. That signs you out on your other devices.
|
||||
- **Clock**: Settings has five fonts and three styles. Glass shows the wallpaper blurred
|
||||
through the digits, Tinted takes its color from the wallpaper.
|
||||
|
||||
@@ -73,9 +98,17 @@ Build it yourself: `docker build -t dahoam .`
|
||||
|
||||
- Suggestions come from DuckDuckGo, or from SearXNG (`/autocompleter`) when it is the
|
||||
selected engine. The server fetches them, the browser never calls those hosts directly.
|
||||
- Status checks: the server requests each link's address (a GET, redirects are not
|
||||
followed, the answer is thrown away) and tells the browser only up or down. Up is any
|
||||
answer below 500, and also a certificate that the server does not trust. Because users
|
||||
choose the addresses, a user can find out which hosts and ports the server can reach.
|
||||
Turn it on for people you trust, together with `DISABLE_SIGNUP=true`.
|
||||
- SSO does not take over an existing password account with the same email
|
||||
(Better Auth blocks it, because password emails are not verified). Use one or the other per email.
|
||||
- Icon lookups send the link name to the jsDelivr CDN.
|
||||
- Icon lookups send the link name to the jsDelivr CDN. The link dialog also loads the
|
||||
library's list of icons from there, and so does the server, once a day.
|
||||
- Uploaded icons are stored in Postgres and only their owner can load them. One that no
|
||||
link uses any more is deleted with that user's next upload.
|
||||
- UI components come from [collabry-components](https://git.nhaiden.io/niklas/collabry-components),
|
||||
copied into `src/vendor/collabry` at a pinned commit. Add or update one with
|
||||
`scripts/sync-collabry.sh` (see `src/vendor/collabry/UPSTREAM.md`). The glass look is
|
||||
|
||||
@@ -0,0 +1 @@
|
||||
ALTER TABLE "settings" ADD COLUMN "wallpaper_dim" integer DEFAULT 40 NOT NULL;
|
||||
@@ -0,0 +1,30 @@
|
||||
CREATE TABLE "dashboard" (
|
||||
"id" uuid PRIMARY KEY DEFAULT gen_random_uuid() NOT NULL,
|
||||
"user_id" text NOT NULL,
|
||||
"name" text NOT NULL,
|
||||
"created_at" timestamp DEFAULT now() NOT NULL
|
||||
);
|
||||
--> statement-breakpoint
|
||||
CREATE TABLE "icon" (
|
||||
"id" uuid PRIMARY KEY DEFAULT gen_random_uuid() NOT NULL,
|
||||
"user_id" text NOT NULL,
|
||||
"mime" text NOT NULL,
|
||||
"data" "bytea" NOT NULL,
|
||||
"created_at" timestamp DEFAULT now() NOT NULL
|
||||
);
|
||||
--> statement-breakpoint
|
||||
ALTER TABLE "card" ADD COLUMN "dashboard_id" uuid;--> statement-breakpoint
|
||||
-- Hand-written: the cards a user already has become that user's first dashboard, "Home".
|
||||
INSERT INTO "dashboard" ("user_id", "name")
|
||||
SELECT DISTINCT "user_id", 'Home' FROM "card";--> statement-breakpoint
|
||||
UPDATE "card" SET "dashboard_id" = "dashboard"."id" FROM "dashboard"
|
||||
WHERE "dashboard"."user_id" = "card"."user_id";--> statement-breakpoint
|
||||
ALTER TABLE "card" ALTER COLUMN "dashboard_id" SET NOT NULL;--> statement-breakpoint
|
||||
ALTER TABLE "settings" ADD COLUMN "default_dashboard_id" uuid;--> statement-breakpoint
|
||||
ALTER TABLE "dashboard" ADD CONSTRAINT "dashboard_user_id_user_id_fk" FOREIGN KEY ("user_id") REFERENCES "public"."user"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint
|
||||
ALTER TABLE "icon" ADD CONSTRAINT "icon_user_id_user_id_fk" FOREIGN KEY ("user_id") REFERENCES "public"."user"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint
|
||||
CREATE INDEX "dashboard_user_id_idx" ON "dashboard" USING btree ("user_id");--> statement-breakpoint
|
||||
CREATE INDEX "icon_user_id_idx" ON "icon" USING btree ("user_id");--> statement-breakpoint
|
||||
ALTER TABLE "card" ADD CONSTRAINT "card_dashboard_id_dashboard_id_fk" FOREIGN KEY ("dashboard_id") REFERENCES "public"."dashboard"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint
|
||||
ALTER TABLE "settings" ADD CONSTRAINT "settings_default_dashboard_id_dashboard_id_fk" FOREIGN KEY ("default_dashboard_id") REFERENCES "public"."dashboard"("id") ON DELETE set null ON UPDATE no action;--> statement-breakpoint
|
||||
CREATE INDEX "card_dashboard_id_idx" ON "card" USING btree ("dashboard_id");
|
||||
@@ -0,0 +1,26 @@
|
||||
-- Hand-written: the wallpaper moves from the user to the dashboard. Every dashboard of a
|
||||
-- user starts with the wallpaper that the user had, so nothing looks different.
|
||||
ALTER TABLE "dashboard" ADD COLUMN "wallpaper_url" text;--> statement-breakpoint
|
||||
ALTER TABLE "dashboard" ADD COLUMN "wallpaper_dim" integer DEFAULT 40 NOT NULL;--> statement-breakpoint
|
||||
-- a user who chose a wallpaper but has no dashboard yet keeps it too
|
||||
INSERT INTO "dashboard" ("user_id", "name")
|
||||
SELECT "user_id", 'Home' FROM "settings"
|
||||
WHERE NOT EXISTS (SELECT 1 FROM "dashboard" WHERE "dashboard"."user_id" = "settings"."user_id");--> statement-breakpoint
|
||||
-- the address of an upload now names its dashboard: /api/wallpaper?d=<id>&v=<upload time>
|
||||
UPDATE "dashboard" SET
|
||||
"wallpaper_dim" = "settings"."wallpaper_dim",
|
||||
"wallpaper_url" = CASE WHEN "settings"."wallpaper_url" LIKE '/api/wallpaper?v=%'
|
||||
THEN replace("settings"."wallpaper_url", '?v=', '?d=' || "dashboard"."id" || '&v=')
|
||||
ELSE "settings"."wallpaper_url" END
|
||||
FROM "settings" WHERE "settings"."user_id" = "dashboard"."user_id";--> statement-breakpoint
|
||||
ALTER TABLE "wallpaper" DROP CONSTRAINT "wallpaper_pkey";--> statement-breakpoint
|
||||
ALTER TABLE "wallpaper" ADD COLUMN "dashboard_id" uuid;--> statement-breakpoint
|
||||
-- one upload per user becomes one copy per dashboard of that user
|
||||
INSERT INTO "wallpaper" ("dashboard_id", "user_id", "mime", "data")
|
||||
SELECT "dashboard"."id", "wallpaper"."user_id", "wallpaper"."mime", "wallpaper"."data"
|
||||
FROM "wallpaper" JOIN "dashboard" ON "dashboard"."user_id" = "wallpaper"."user_id";--> statement-breakpoint
|
||||
DELETE FROM "wallpaper" WHERE "dashboard_id" IS NULL;--> statement-breakpoint
|
||||
ALTER TABLE "wallpaper" ADD PRIMARY KEY ("dashboard_id");--> statement-breakpoint
|
||||
ALTER TABLE "wallpaper" ADD CONSTRAINT "wallpaper_dashboard_id_dashboard_id_fk" FOREIGN KEY ("dashboard_id") REFERENCES "public"."dashboard"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint
|
||||
ALTER TABLE "settings" DROP COLUMN "wallpaper_url";--> statement-breakpoint
|
||||
ALTER TABLE "settings" DROP COLUMN "wallpaper_dim";
|
||||
@@ -0,0 +1 @@
|
||||
ALTER TABLE "card" ADD COLUMN "position" integer DEFAULT 0 NOT NULL;
|
||||
@@ -0,0 +1 @@
|
||||
ALTER TABLE "dashboard" ADD COLUMN "position" integer DEFAULT 0 NOT NULL;
|
||||
@@ -0,0 +1,686 @@
|
||||
{
|
||||
"id": "4df576be-2fef-462c-affd-4aff0ab26918",
|
||||
"prevId": "ac3af713-2f43-44c7-8e48-d840cfee12c0",
|
||||
"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
|
||||
},
|
||||
"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": {}
|
||||
}
|
||||
},
|
||||
"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"
|
||||
}
|
||||
},
|
||||
"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'"
|
||||
},
|
||||
"search_engine": {
|
||||
"name": "search_engine",
|
||||
"type": "text",
|
||||
"primaryKey": false,
|
||||
"notNull": true,
|
||||
"default": "'duckduckgo'"
|
||||
},
|
||||
"wallpaper_url": {
|
||||
"name": "wallpaper_url",
|
||||
"type": "text",
|
||||
"primaryKey": false,
|
||||
"notNull": false
|
||||
},
|
||||
"wallpaper_dim": {
|
||||
"name": "wallpaper_dim",
|
||||
"type": "integer",
|
||||
"primaryKey": false,
|
||||
"notNull": true,
|
||||
"default": 40
|
||||
},
|
||||
"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"
|
||||
}
|
||||
},
|
||||
"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": {
|
||||
"user_id": {
|
||||
"name": "user_id",
|
||||
"type": "text",
|
||||
"primaryKey": true,
|
||||
"notNull": true
|
||||
},
|
||||
"mime": {
|
||||
"name": "mime",
|
||||
"type": "text",
|
||||
"primaryKey": false,
|
||||
"notNull": true
|
||||
},
|
||||
"data": {
|
||||
"name": "data",
|
||||
"type": "bytea",
|
||||
"primaryKey": false,
|
||||
"notNull": true
|
||||
}
|
||||
},
|
||||
"indexes": {},
|
||||
"foreignKeys": {
|
||||
"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": {}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,883 @@
|
||||
{
|
||||
"id": "7a2af09b-64c1-4ae0-8b47-a669a9e399f0",
|
||||
"prevId": "4df576be-2fef-462c-affd-4aff0ab26918",
|
||||
"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
|
||||
},
|
||||
"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
|
||||
},
|
||||
"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'"
|
||||
},
|
||||
"wallpaper_url": {
|
||||
"name": "wallpaper_url",
|
||||
"type": "text",
|
||||
"primaryKey": false,
|
||||
"notNull": false
|
||||
},
|
||||
"wallpaper_dim": {
|
||||
"name": "wallpaper_dim",
|
||||
"type": "integer",
|
||||
"primaryKey": false,
|
||||
"notNull": true,
|
||||
"default": 40
|
||||
},
|
||||
"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": {
|
||||
"user_id": {
|
||||
"name": "user_id",
|
||||
"type": "text",
|
||||
"primaryKey": true,
|
||||
"notNull": true
|
||||
},
|
||||
"mime": {
|
||||
"name": "mime",
|
||||
"type": "text",
|
||||
"primaryKey": false,
|
||||
"notNull": true
|
||||
},
|
||||
"data": {
|
||||
"name": "data",
|
||||
"type": "bytea",
|
||||
"primaryKey": false,
|
||||
"notNull": true
|
||||
}
|
||||
},
|
||||
"indexes": {},
|
||||
"foreignKeys": {
|
||||
"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": {}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,902 @@
|
||||
{
|
||||
"id": "c89fef31-f0cf-4f87-8683-df4f9eb49fa8",
|
||||
"prevId": "7a2af09b-64c1-4ae0-8b47-a669a9e399f0",
|
||||
"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
|
||||
},
|
||||
"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
|
||||
},
|
||||
"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": {}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,909 @@
|
||||
{
|
||||
"id": "eddd02da-41ed-40a6-b0b0-e5976ea2c371",
|
||||
"prevId": "c89fef31-f0cf-4f87-8683-df4f9eb49fa8",
|
||||
"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
|
||||
},
|
||||
"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": {}
|
||||
}
|
||||
}
|
||||
@@ -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": {}
|
||||
}
|
||||
}
|
||||
@@ -36,6 +36,41 @@
|
||||
"when": 1795017311884,
|
||||
"tag": "0004_clock",
|
||||
"breakpoints": true
|
||||
},
|
||||
{
|
||||
"idx": 5,
|
||||
"version": "7",
|
||||
"when": 1795017884385,
|
||||
"tag": "0005_wallpaper_dim",
|
||||
"breakpoints": true
|
||||
},
|
||||
{
|
||||
"idx": 6,
|
||||
"version": "7",
|
||||
"when": 1795020380796,
|
||||
"tag": "0006_dashboards_icons",
|
||||
"breakpoints": true
|
||||
},
|
||||
{
|
||||
"idx": 7,
|
||||
"version": "7",
|
||||
"when": 1795021173823,
|
||||
"tag": "0007_dashboard_wallpaper",
|
||||
"breakpoints": true
|
||||
},
|
||||
{
|
||||
"idx": 8,
|
||||
"version": "7",
|
||||
"when": 1795106775546,
|
||||
"tag": "0008_card_position",
|
||||
"breakpoints": true
|
||||
},
|
||||
{
|
||||
"idx": 9,
|
||||
"version": "7",
|
||||
"when": 1795285309906,
|
||||
"tag": "0009_dashboard_position",
|
||||
"breakpoints": true
|
||||
}
|
||||
]
|
||||
}
|
||||
@@ -9,6 +9,8 @@ import {
|
||||
FieldError,
|
||||
FieldLabel,
|
||||
Input,
|
||||
Select,
|
||||
SelectOption,
|
||||
} from "@/vendor/collabry/components/Field/Field"
|
||||
import {
|
||||
Dialog,
|
||||
@@ -21,19 +23,34 @@ import {
|
||||
|
||||
export type CardTarget = { id: string; name: string; links: unknown[] } | "new"
|
||||
|
||||
/** `card` is the card to edit, "new" to add one, or null when closed. */
|
||||
type Dashboards = { id: string; name: string }[]
|
||||
|
||||
/**
|
||||
* `card` is the card to edit, "new" to add one, or null when closed.
|
||||
* `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({
|
||||
card,
|
||||
dashboardId,
|
||||
dashboards,
|
||||
onClose,
|
||||
}: {
|
||||
card: CardTarget | null
|
||||
dashboardId: string
|
||||
dashboards: Dashboards
|
||||
onClose: () => void
|
||||
}) {
|
||||
return (
|
||||
<Dialog open={!!card} onOpenChange={(open) => !open && onClose()}>
|
||||
<GlassDialogContent>
|
||||
{card && (
|
||||
<CardForm card={card === "new" ? null : card} onClose={onClose} />
|
||||
<CardForm
|
||||
card={card === "new" ? null : card}
|
||||
dashboardId={dashboardId}
|
||||
dashboards={dashboards}
|
||||
onClose={onClose}
|
||||
/>
|
||||
)}
|
||||
</GlassDialogContent>
|
||||
</Dialog>
|
||||
@@ -42,9 +59,13 @@ export function CardDialog({
|
||||
|
||||
function CardForm({
|
||||
card,
|
||||
dashboardId,
|
||||
dashboards,
|
||||
onClose,
|
||||
}: {
|
||||
card: Exclude<CardTarget, "new"> | null
|
||||
dashboardId: string
|
||||
dashboards: Dashboards
|
||||
onClose: () => void
|
||||
}) {
|
||||
const router = useRouter()
|
||||
@@ -71,8 +92,17 @@ function CardForm({
|
||||
<form
|
||||
onSubmit={(e) => {
|
||||
e.preventDefault()
|
||||
const name = String(new FormData(e.currentTarget).get("name"))
|
||||
void submit(() => saveCard({ data: { id: card?.id, name } }))
|
||||
const form = new FormData(e.currentTarget)
|
||||
void submit(() =>
|
||||
saveCard({
|
||||
data: {
|
||||
id: card?.id,
|
||||
name: String(form.get("name")),
|
||||
// without the field there is only one dashboard
|
||||
dashboardId: String(form.get("dashboardId") ?? dashboardId),
|
||||
},
|
||||
})
|
||||
)
|
||||
}}
|
||||
>
|
||||
<DialogHeader>
|
||||
@@ -92,6 +122,18 @@ function CardForm({
|
||||
required
|
||||
/>
|
||||
</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>}
|
||||
</DialogBody>
|
||||
<DialogFooter className="justify-between">
|
||||
|
||||
+110
-44
@@ -8,7 +8,6 @@ import {
|
||||
TouchSensor,
|
||||
closestCenter,
|
||||
pointerWithin,
|
||||
useDroppable,
|
||||
useSensor,
|
||||
useSensors,
|
||||
} from "@dnd-kit/core"
|
||||
@@ -21,13 +20,14 @@ import {
|
||||
SortableContext,
|
||||
rectSortingStrategy,
|
||||
sortableKeyboardCoordinates,
|
||||
useSortable,
|
||||
} from "@dnd-kit/sortable"
|
||||
import { Plus } from "lucide-react"
|
||||
import { GripVertical, Plus } from "lucide-react"
|
||||
import { glass } from "@/components/glass"
|
||||
import { LinkTile, TileFace } from "@/components/link-tile"
|
||||
import type { HomeLink } from "@/components/link-tile"
|
||||
import { moveLinks } from "@/lib/dashboard.functions"
|
||||
import { drop, moveOver, order } from "@/lib/layout"
|
||||
import { saveLayout } from "@/lib/dashboard.functions"
|
||||
import { drop, moveCard, moveOver, order } from "@/lib/layout"
|
||||
import { Button } from "@/vendor/collabry/components/Button/Button"
|
||||
import { cn } from "@/vendor/collabry/lib/cn"
|
||||
|
||||
@@ -39,20 +39,25 @@ type Handlers = {
|
||||
onEditCard: (card: DashCard) => void
|
||||
}
|
||||
|
||||
/** The cards with their links. Links can be dragged inside a card and between cards. */
|
||||
/**
|
||||
* The cards with their links. Links can be dragged inside a card and between cards,
|
||||
* cards by their title bar.
|
||||
*/
|
||||
export function CardGrid({
|
||||
cards: saved,
|
||||
onAddCard,
|
||||
...handlers
|
||||
}: { cards: DashCard[]; onAddCard: () => void } & Handlers) {
|
||||
const router = useRouter()
|
||||
// the layout while a link is dragged, and until the server has stored it
|
||||
// the layout while a link or a card is dragged, and until the server has stored it
|
||||
const [dragged, setDragged] = useState<DashCard[] | null>(null)
|
||||
const [activeId, setActiveId] = useState<UniqueIdentifier | null>(null)
|
||||
const drags = useRef(0)
|
||||
const cards = dragged ?? saved
|
||||
const links = cards.flatMap((c) => c.links)
|
||||
const active = links.find((l) => l.id === activeId)
|
||||
const activeCard = cards.find((c) => c.id === activeId)
|
||||
const isCard = (id: UniqueIdentifier) => cards.some((c) => c.id === id)
|
||||
|
||||
const sensors = useSensors(
|
||||
// a few pixels of slack, so a plain click still opens the link
|
||||
@@ -82,10 +87,17 @@ export function CardGrid({
|
||||
),
|
||||
})
|
||||
const cardArgs = only(cards.map((c) => c.id))
|
||||
// the keyboard has no pointer: take the nearest card then
|
||||
const hit = pointerWithin(cardArgs).at(0) ?? closestCenter(cardArgs).at(0)
|
||||
const dragsCard = isCard(args.active.id)
|
||||
// The keyboard has no pointer: take the nearest card then. A dragged card waits
|
||||
// while the pointer is between cards: the nearest one could swap it back and forth.
|
||||
const hit =
|
||||
pointerWithin(cardArgs).at(0) ??
|
||||
(dragsCard && args.pointerCoordinates
|
||||
? undefined
|
||||
: closestCenter(cardArgs).at(0))
|
||||
const card = cards.find((c) => c.id === hit?.id)
|
||||
if (!hit || !card) return []
|
||||
if (dragsCard) return [hit]
|
||||
const nearest = closestCenter(only(card.links.map((l) => l.id)))
|
||||
return nearest.length ? nearest : [hit]
|
||||
}
|
||||
@@ -97,7 +109,7 @@ export function CardGrid({
|
||||
setDragged(next)
|
||||
const drag = drags.current
|
||||
// on failure the reload below puts the links back where they were
|
||||
await moveLinks({ data: { cards: order(next) } }).catch(() => {})
|
||||
await saveLayout({ data: { cards: order(next) } }).catch(() => {})
|
||||
await router.invalidate()
|
||||
// a newer drag owns the layout by now
|
||||
if (drags.current === drag) setDragged(null)
|
||||
@@ -110,12 +122,18 @@ export function CardGrid({
|
||||
cards.find((c) => c.id === id || c.links.some((l) => l.id === id))?.name
|
||||
const announcements: Announcements = {
|
||||
onDragStart: ({ active: a }) => `Picked up ${name(a.id)}.`,
|
||||
onDragOver: ({ active: a, over }) =>
|
||||
over ? `${name(a.id)} is in ${cardName(over.id)}.` : undefined,
|
||||
onDragOver: ({ active: a, over }) => {
|
||||
if (!over || over.id === a.id) return
|
||||
return isCard(a.id)
|
||||
? `${name(a.id)} took the place of ${name(over.id)}.`
|
||||
: `${name(a.id)} is in ${cardName(over.id)}.`
|
||||
},
|
||||
onDragEnd: ({ active: a, over }) =>
|
||||
over
|
||||
? `${name(a.id)} was put down in ${cardName(over.id)}.`
|
||||
: `${name(a.id)} was put back.`,
|
||||
isCard(a.id)
|
||||
? `${name(a.id)} was put down.`
|
||||
: over
|
||||
? `${name(a.id)} was put down in ${cardName(over.id)}.`
|
||||
: `${name(a.id)} was put back.`,
|
||||
onDragCancel: ({ active: a }) => `${name(a.id)} was put back.`,
|
||||
}
|
||||
|
||||
@@ -132,7 +150,10 @@ export function CardGrid({
|
||||
setDragged(cards)
|
||||
}}
|
||||
onDragOver={({ active: a, over }) => {
|
||||
if (over) setDragged(moveOver(cards, String(a.id), String(over.id)))
|
||||
if (!over) return
|
||||
// each of the two leaves the other kind of drag alone
|
||||
const [id, overId] = [String(a.id), String(over.id)]
|
||||
setDragged(moveCard(moveOver(cards, id, overId), id, overId))
|
||||
}}
|
||||
onDragEnd={({ active: a, over }) =>
|
||||
finish(over ? drop(cards, String(a.id), String(over.id)) : cards)
|
||||
@@ -142,18 +163,22 @@ export function CardGrid({
|
||||
setDragged(null)
|
||||
}}
|
||||
>
|
||||
{/* cards in a row share a height, so their edges line up */}
|
||||
<div className="flex w-full max-w-6xl flex-wrap justify-center gap-4">
|
||||
{cards.map((card) => (
|
||||
<CardPanel
|
||||
key={card.id}
|
||||
card={card}
|
||||
// the card the dragged link would land in
|
||||
target={card.links.some((l) => l.id === activeId)}
|
||||
{...handlers}
|
||||
/>
|
||||
))}
|
||||
</div>
|
||||
{/* A dragged card moves in the list itself (onDragOver), so no strategy shifts
|
||||
the others: cards differ in size, and a shifted one would not fit its slot. */}
|
||||
<SortableContext items={cards.map((c) => c.id)} strategy={() => null}>
|
||||
{/* cards in a row share a height, so their edges line up */}
|
||||
<div className="flex w-full max-w-6xl flex-wrap justify-center gap-4">
|
||||
{cards.map((card) => (
|
||||
<CardPanel
|
||||
key={card.id}
|
||||
card={card}
|
||||
// the card the dragged link would land in
|
||||
target={card.links.some((l) => l.id === activeId)}
|
||||
{...handlers}
|
||||
/>
|
||||
))}
|
||||
</div>
|
||||
</SortableContext>
|
||||
<Button
|
||||
variant="ghost"
|
||||
className="mt-4 rounded-full text-white/60 hover:bg-white/10 hover:text-white"
|
||||
@@ -162,17 +187,46 @@ export function CardGrid({
|
||||
<Plus className="size-4" /> New card
|
||||
</Button>
|
||||
<DragOverlay>
|
||||
{active && (
|
||||
{/* one expression: an array of two empty ones would still count as a child */}
|
||||
{active ? (
|
||||
<TileFace
|
||||
link={active}
|
||||
className="cursor-grabbing rounded-2xl bg-white/15 shadow-2xl"
|
||||
/>
|
||||
) : (
|
||||
activeCard && <CardFace card={activeCard} />
|
||||
)}
|
||||
</DragOverlay>
|
||||
</DndContext>
|
||||
)
|
||||
}
|
||||
|
||||
// 6rem is a tile's width. On a narrow screen fewer columns fit: they stay
|
||||
// centered in the card, and a last row that is not full starts at the left.
|
||||
const tiles =
|
||||
"mx-auto grid max-w-full grid-cols-[repeat(auto-fill,6rem)] justify-center gap-y-2"
|
||||
/** One column per link, at most 8. An empty card is as wide as two links. */
|
||||
const tilesWidth = (card: DashCard) => ({
|
||||
width: `${(Math.min(card.links.length, 8) || 2) * 6}rem`,
|
||||
})
|
||||
|
||||
/** What follows the pointer while a card is dragged: the card without its buttons. */
|
||||
function CardFace({ card }: { card: DashCard }) {
|
||||
return (
|
||||
// the overlay is as large as the card, h-full fills it for an empty card too
|
||||
<div className={cn(glass, "h-full cursor-grabbing rounded-3xl p-2")}>
|
||||
<div className="h-10 truncate pr-3.5 pl-5 text-sm leading-10 font-bold text-white/70">
|
||||
{card.name}
|
||||
</div>
|
||||
<div style={tilesWidth(card)} className={tiles}>
|
||||
{card.links.map((link) => (
|
||||
<TileFace key={link.id} link={link} />
|
||||
))}
|
||||
</div>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
|
||||
function CardPanel({
|
||||
card,
|
||||
target,
|
||||
@@ -181,11 +235,16 @@ function CardPanel({
|
||||
onEditCard,
|
||||
}: { card: DashCard; target: boolean } & Handlers) {
|
||||
const titleId = useId()
|
||||
const { setNodeRef } = useDroppable({ id: card.id })
|
||||
// one column per link, at most 8. An empty card is as wide as two links.
|
||||
const columns = Math.min(card.links.length, 8) || 2
|
||||
// `card` tells the link tiles that a card is dragged, see LinkTile
|
||||
const { setNodeRef, setActivatorNodeRef, attributes, listeners, isDragging } =
|
||||
useSortable({ id: card.id, data: { card: true } })
|
||||
const subtle =
|
||||
"rounded-lg outline-none focus-visible:ring-2 focus-visible:ring-white/60"
|
||||
// shown on hover, always on touch
|
||||
const action = cn(
|
||||
subtle,
|
||||
"grid size-7 flex-none place-items-center text-white/70 opacity-0 transition-opacity group-hover/card:opacity-100 hover:bg-white/10 hover:text-white focus-visible:opacity-100 pointer-coarse:opacity-100"
|
||||
)
|
||||
return (
|
||||
<section
|
||||
ref={setNodeRef}
|
||||
@@ -193,11 +252,16 @@ function CardPanel({
|
||||
className={cn(
|
||||
glass,
|
||||
"group/card max-w-full rounded-3xl p-2 transition-colors",
|
||||
target && "border-white/30"
|
||||
target && "border-white/30",
|
||||
isDragging && "opacity-40"
|
||||
)}
|
||||
>
|
||||
{/* the title starts where the first icon does, the plus ends where the last one does */}
|
||||
<header className="flex h-10 min-w-48 items-center gap-2 pr-3.5 pl-5">
|
||||
{/* The title starts where the first icon does, the plus ends where the last one does.
|
||||
The whole bar drags the card. The keyboard picks it up on the grip only. */}
|
||||
<header
|
||||
{...listeners}
|
||||
className="flex h-10 min-w-48 cursor-grab touch-manipulation items-center gap-2 pr-3.5 pl-5 select-none [-webkit-touch-callout:none]"
|
||||
>
|
||||
<h2 id={titleId} className="m-0 min-w-0 text-sm">
|
||||
<button
|
||||
type="button"
|
||||
@@ -211,14 +275,21 @@ function CardPanel({
|
||||
{card.name}
|
||||
</button>
|
||||
</h2>
|
||||
<button
|
||||
type="button"
|
||||
ref={setActivatorNodeRef}
|
||||
{...attributes}
|
||||
aria-label={`Move ${card.name}`}
|
||||
title="Drag to move this card"
|
||||
className={cn(action, "ml-auto cursor-grab")}
|
||||
>
|
||||
<GripVertical className="size-4" />
|
||||
</button>
|
||||
<button
|
||||
type="button"
|
||||
aria-label={`Add a link to ${card.name}`}
|
||||
onClick={() => onAddLink(card)}
|
||||
className={cn(
|
||||
subtle,
|
||||
"ml-auto grid size-7 flex-none place-items-center text-white/70 opacity-0 transition-opacity group-hover/card:opacity-100 hover:bg-white/10 hover:text-white focus-visible:opacity-100 pointer-coarse:opacity-100"
|
||||
)}
|
||||
className={action}
|
||||
>
|
||||
<Plus className="size-4" />
|
||||
</button>
|
||||
@@ -227,12 +298,7 @@ function CardPanel({
|
||||
items={card.links.map((l) => l.id)}
|
||||
strategy={rectSortingStrategy}
|
||||
>
|
||||
{/* 6rem is a tile's width. On a narrow screen fewer columns fit: they stay
|
||||
centered in the card, and a last row that is not full starts at the left. */}
|
||||
<div
|
||||
style={{ width: `${columns * 6}rem` }}
|
||||
className="mx-auto grid max-w-full grid-cols-[repeat(auto-fill,6rem)] justify-center gap-y-2"
|
||||
>
|
||||
<div style={tilesWidth(card)} className={tiles}>
|
||||
{card.links.map((link) => (
|
||||
<LinkTile
|
||||
key={link.id}
|
||||
|
||||
+166
-14
@@ -1,9 +1,16 @@
|
||||
import { useState } from "react"
|
||||
import { useEffect, useRef, useState } from "react"
|
||||
import { useRouter } from "@tanstack/react-router"
|
||||
import { Trash2 } from "lucide-react"
|
||||
import { Trash2, Upload, X } from "lucide-react"
|
||||
import { GlassDialogContent } from "@/components/glass"
|
||||
import type { HomeLink } from "@/components/link-tile"
|
||||
import { deleteLink, saveLink } from "@/lib/dashboard.functions"
|
||||
import { deleteLink, getIcons, saveLink } from "@/lib/dashboard.functions"
|
||||
import {
|
||||
LIBRARY_INDEX,
|
||||
UPLOADED_ICON,
|
||||
isImageAddress,
|
||||
libraryIcon,
|
||||
searchIcons,
|
||||
} from "@/lib/icons"
|
||||
import { Button } from "@/vendor/collabry/components/Button/Button"
|
||||
import {
|
||||
Field,
|
||||
@@ -24,6 +31,51 @@ import {
|
||||
DialogTitle,
|
||||
} 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. */
|
||||
export type LinkTarget = HomeLink | { cardId: string }
|
||||
|
||||
@@ -38,7 +90,8 @@ export function LinkDialog({
|
||||
}) {
|
||||
return (
|
||||
<Dialog open={!!target} onOpenChange={(open) => !open && onClose()}>
|
||||
<GlassDialogContent>
|
||||
{/* taller than a small screen since it shows icons: scroll inside */}
|
||||
<GlassDialogContent className="max-h-[86vh] overflow-y-auto">
|
||||
{target && <LinkForm target={target} cards={cards} onClose={onClose} />}
|
||||
</GlassDialogContent>
|
||||
</Dialog>
|
||||
@@ -58,6 +111,49 @@ function LinkForm({
|
||||
const router = useRouter()
|
||||
const [busy, setBusy] = useState(false)
|
||||
const [error, setError] = useState("")
|
||||
const [name, setName] = useState(link?.name ?? "")
|
||||
const [icon, setIcon] = useState(link?.icon ?? "")
|
||||
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)
|
||||
|
||||
// Without the library's index the field still takes a name or an address.
|
||||
useEffect(() => {
|
||||
fetch(LIBRARY_INDEX)
|
||||
.then((res) => res.json())
|
||||
.then((index: { png: string[] }) =>
|
||||
setLibrary(index.png.map((f) => f.replace(/\.png$/, "")))
|
||||
)
|
||||
.catch(() => {})
|
||||
getIcons()
|
||||
.then(setUploads)
|
||||
.catch(() => {})
|
||||
}, [])
|
||||
|
||||
const uploaded = icon.startsWith(UPLOADED_ICON)
|
||||
// what the field holds, or what an empty field would look up
|
||||
const matches = isImageAddress(icon) ? [] : searchIcons(library, icon || name)
|
||||
|
||||
const upload = async (image: File) => {
|
||||
setBusy(true)
|
||||
setError("")
|
||||
try {
|
||||
const res = await fetch("/api/icon", {
|
||||
method: "POST",
|
||||
headers: { "Content-Type": image.type },
|
||||
body: image,
|
||||
})
|
||||
if (res.ok) {
|
||||
const added: string = (await res.json()).icon
|
||||
setIcon(added)
|
||||
setUploads((before) => [added, ...before])
|
||||
} else setError(await res.text())
|
||||
} catch {
|
||||
setError("Could not upload. Try again.")
|
||||
}
|
||||
setBusy(false)
|
||||
}
|
||||
|
||||
const submit = async (action: () => Promise<void>) => {
|
||||
setBusy(true)
|
||||
@@ -82,9 +178,9 @@ function LinkForm({
|
||||
data: {
|
||||
id: link?.id,
|
||||
cardId: String(form.get("cardId")),
|
||||
name: String(form.get("name")),
|
||||
name,
|
||||
url: String(form.get("url")),
|
||||
icon: String(form.get("icon")).trim() || null,
|
||||
icon: icon.trim() || null,
|
||||
},
|
||||
})
|
||||
)
|
||||
@@ -100,8 +196,8 @@ function LinkForm({
|
||||
<Field>
|
||||
<FieldLabel>Name</FieldLabel>
|
||||
<Input
|
||||
name="name"
|
||||
defaultValue={link?.name}
|
||||
value={name}
|
||||
onChange={(e) => setName(e.target.value)}
|
||||
placeholder="Plex"
|
||||
maxLength={60}
|
||||
required
|
||||
@@ -123,13 +219,69 @@ function LinkForm({
|
||||
<FieldLabel>
|
||||
Icon <FieldNote>(optional)</FieldNote>
|
||||
</FieldLabel>
|
||||
<Input
|
||||
name="icon"
|
||||
defaultValue={link?.icon ?? ""}
|
||||
placeholder="Image URL or icon name, e.g. plex"
|
||||
/>
|
||||
<div className="flex items-center gap-2">
|
||||
{uploaded && (
|
||||
<img
|
||||
src={icon}
|
||||
alt=""
|
||||
className="size-9 flex-none rounded-lg object-contain"
|
||||
/>
|
||||
)}
|
||||
<Input
|
||||
className="min-w-0 flex-1"
|
||||
value={uploaded ? "" : icon}
|
||||
onChange={(e) => setIcon(e.target.value)}
|
||||
placeholder={
|
||||
uploaded ? "Your image" : "Search icons or paste a URL"
|
||||
}
|
||||
autoComplete="off"
|
||||
/>
|
||||
{uploaded && (
|
||||
<Button
|
||||
variant="ghost"
|
||||
iconOnly
|
||||
aria-label="Remove your image"
|
||||
onClick={() => setIcon("")}
|
||||
>
|
||||
<X size={15} />
|
||||
</Button>
|
||||
)}
|
||||
<input
|
||||
ref={file}
|
||||
type="file"
|
||||
accept="image/png,image/jpeg,image/webp,image/avif,image/svg+xml"
|
||||
className="hidden"
|
||||
onChange={(e) => {
|
||||
const image = e.target.files?.[0]
|
||||
if (image) void upload(image)
|
||||
e.target.value = ""
|
||||
}}
|
||||
/>
|
||||
<Button disabled={busy} onClick={() => file.current?.click()}>
|
||||
<Upload size={15} /> Upload
|
||||
</Button>
|
||||
</div>
|
||||
{matches.length > 0 && (
|
||||
<IconChoices
|
||||
label="Icons from the library"
|
||||
icons={matches}
|
||||
chosen={icon}
|
||||
named
|
||||
onChoose={setIcon}
|
||||
/>
|
||||
)}
|
||||
{uploads.length > 0 && (
|
||||
<IconChoices
|
||||
label="Your images"
|
||||
icons={uploads}
|
||||
chosen={icon}
|
||||
onChoose={setIcon}
|
||||
/>
|
||||
)}
|
||||
<FieldDescription>
|
||||
Empty: found from the name, then from the site's favicon.
|
||||
Empty: found from the name (the light version, when the library has
|
||||
one), then from the site's favicon. Upload a PNG, JPEG, WebP, AVIF
|
||||
or SVG, up to 1 MB.
|
||||
</FieldDescription>
|
||||
</Field>
|
||||
<Field>
|
||||
|
||||
@@ -1,7 +1,9 @@
|
||||
import { useEffect, useRef, useState } from "react"
|
||||
import { createContext, useContext, useEffect, useRef, useState } from "react"
|
||||
import { useDndContext } from "@dnd-kit/core"
|
||||
import { useSortable } from "@dnd-kit/sortable"
|
||||
import { CSS } from "@dnd-kit/utilities"
|
||||
import { Pencil } from "lucide-react"
|
||||
import { iconSources } from "@/lib/icons"
|
||||
import { cn } from "@/vendor/collabry/lib/cn"
|
||||
|
||||
export type HomeLink = {
|
||||
@@ -10,29 +12,19 @@ export type HomeLink = {
|
||||
name: string
|
||||
url: string
|
||||
icon: string | null
|
||||
/** the library's light version of the icon, when the link has no icon of its own */
|
||||
lightIcon: string | null
|
||||
}
|
||||
|
||||
const dashboardIcon = (name: string) =>
|
||||
`https://cdn.jsdelivr.net/gh/homarr-labs/dashboard-icons/png/${name
|
||||
.trim()
|
||||
.toLowerCase()
|
||||
.replace(/[^a-z0-9]+/g, "-")
|
||||
.replace(/^-|-$/g, "")}.png`
|
||||
|
||||
/** Icon sources to try in order; the letter tile is the last resort. */
|
||||
function iconSources({ name, url, icon }: HomeLink) {
|
||||
return [
|
||||
icon && /^https?:\/\//.test(icon) ? icon : dashboardIcon(icon || name),
|
||||
`${new URL(url).origin}/favicon.ico`,
|
||||
]
|
||||
}
|
||||
/** Per link id: does its address answer? No entry: not checked (yet). */
|
||||
export const StatusContext = createContext<Partial<Record<string, boolean>>>({})
|
||||
|
||||
type IconProps = { link: HomeLink; className?: string }
|
||||
|
||||
/** Starts the fallback chain again when the link changes. */
|
||||
export function LinkIcon(props: IconProps) {
|
||||
const { id, name, url, icon } = props.link
|
||||
return <Icon key={[id, name, url, icon].join("|")} {...props} />
|
||||
const { id, name, url, icon, lightIcon } = props.link
|
||||
return <Icon key={[id, name, url, icon, lightIcon].join("|")} {...props} />
|
||||
}
|
||||
|
||||
function Icon({ link, className }: IconProps) {
|
||||
@@ -99,6 +91,8 @@ export function LinkTile({
|
||||
link: HomeLink
|
||||
onEdit: () => void
|
||||
}) {
|
||||
// while a card is dragged, the arrow keys go from card to card, not through the links
|
||||
const cardDragged = !!useDndContext().active?.data.current?.card
|
||||
const {
|
||||
attributes,
|
||||
listeners,
|
||||
@@ -106,7 +100,8 @@ export function LinkTile({
|
||||
transform,
|
||||
transition,
|
||||
isDragging,
|
||||
} = useSortable({ id: link.id })
|
||||
} = useSortable({ id: link.id, disabled: { droppable: cardDragged } })
|
||||
const up = useContext(StatusContext)[link.id]
|
||||
return (
|
||||
<div
|
||||
ref={setNodeRef}
|
||||
@@ -124,6 +119,19 @@ export function LinkTile({
|
||||
className="block touch-manipulation rounded-2xl transition-colors outline-none select-none [-webkit-touch-callout:none] hover:bg-white/10 focus-visible:bg-white/10 focus-visible:ring-2 focus-visible:ring-white/60"
|
||||
>
|
||||
<TileFace link={link} />
|
||||
{up !== undefined && (
|
||||
// at the lower right corner of the icon. Filled green or a red ring:
|
||||
// the shape differs too, not only the color.
|
||||
<span
|
||||
title={up ? "Reachable" : "Not reachable"}
|
||||
className={cn(
|
||||
"absolute top-[58px] right-[18px] size-3 rounded-full border-2",
|
||||
up ? "border-black/70 bg-success" : "border-danger bg-black/80"
|
||||
)}
|
||||
>
|
||||
{!up && <span className="sr-only">, not reachable</span>}
|
||||
</span>
|
||||
)}
|
||||
</a>
|
||||
<button
|
||||
type="button"
|
||||
|
||||
@@ -7,7 +7,12 @@ import { cn } from "@/vendor/collabry/lib/cn"
|
||||
import { LinkIcon } from "@/components/link-tile"
|
||||
import type { HomeLink } from "@/components/link-tile"
|
||||
import { suggest } from "@/lib/dashboard.functions"
|
||||
import { ENGINE_NAMES, effectiveEngine, searchUrl } from "@/lib/search"
|
||||
import {
|
||||
ENGINE_NAMES,
|
||||
effectiveEngine,
|
||||
matchLinks,
|
||||
searchUrl,
|
||||
} from "@/lib/search"
|
||||
import type { Engine } from "@/lib/search"
|
||||
|
||||
export type Command = { label: string; icon: ReactNode; run: () => void }
|
||||
@@ -25,7 +30,8 @@ export function SearchBar({
|
||||
}) {
|
||||
const [value, setValue] = useState("")
|
||||
const [fetched, setFetched] = useState<string[]>([])
|
||||
const [active, setActive] = useState(-1)
|
||||
// the row that the arrow keys or the mouse chose, null until then
|
||||
const [moved, setMoved] = useState<number | null>(null)
|
||||
const [focused, setFocused] = useState(false)
|
||||
const input = useRef<HTMLInputElement>(null)
|
||||
|
||||
@@ -57,7 +63,7 @@ export function SearchBar({
|
||||
}).catch(() => [])
|
||||
if (stale) return
|
||||
setFetched(result)
|
||||
setActive(-1) // the highlighted row now holds another suggestion
|
||||
setMoved(null) // the highlighted row now holds another suggestion
|
||||
}, 150)
|
||||
return () => {
|
||||
stale = true
|
||||
@@ -66,23 +72,34 @@ export function SearchBar({
|
||||
}, [query, commandMode, used])
|
||||
|
||||
const needle = value.slice(1).trim().toLowerCase()
|
||||
const matched = matchLinks(links, commandMode ? needle : query)
|
||||
const linkItem = (link: HomeLink): Command => ({
|
||||
label: link.name,
|
||||
icon: <LinkIcon link={link} className="size-5 rounded-md" />,
|
||||
run: () => window.location.assign(link.url),
|
||||
})
|
||||
const items: Command[] = commandMode
|
||||
? [
|
||||
...links.map((link) => ({
|
||||
label: link.name,
|
||||
icon: <LinkIcon link={link} className="size-5 rounded-md" />,
|
||||
run: () => window.location.assign(link.url),
|
||||
})),
|
||||
...commands,
|
||||
].filter((item) => item.label.toLowerCase().includes(needle))
|
||||
...matched.links.map(linkItem),
|
||||
...commands.filter((c) => c.label.toLowerCase().includes(needle)),
|
||||
]
|
||||
: query
|
||||
? fetched.map((s) => ({
|
||||
label: s,
|
||||
icon: <Search className="size-4 opacity-60" />,
|
||||
run: () => search(s),
|
||||
}))
|
||||
? [
|
||||
// a few, so the suggestions stay in view
|
||||
...matched.links.slice(0, 4).map(linkItem),
|
||||
...fetched.map((s) => ({
|
||||
label: s,
|
||||
icon: <Search className="size-4 opacity-60" />,
|
||||
run: () => search(s),
|
||||
})),
|
||||
]
|
||||
: []
|
||||
const open = focused && items.length > 0
|
||||
// Enter takes the highlighted row. Until the user moves, that is the best match:
|
||||
// with / the first row, else a link whose name starts with what was typed.
|
||||
// Without one, Enter searches the web.
|
||||
const best = commandMode ? items.length > 0 : matched.starts > 0
|
||||
const active = moved ?? (best ? 0 : -1)
|
||||
|
||||
const run = (item: Command) => {
|
||||
setValue("")
|
||||
@@ -96,9 +113,7 @@ export function SearchBar({
|
||||
className="relative w-full max-w-[680px]"
|
||||
onSubmit={(e) => {
|
||||
e.preventDefault()
|
||||
// in command mode Enter takes the best match
|
||||
const item =
|
||||
active >= 0 ? items[active] : commandMode ? items[0] : undefined
|
||||
const item = active >= 0 ? items[active] : undefined
|
||||
if (item) run(item)
|
||||
else if (query && !commandMode) search(query)
|
||||
}}
|
||||
@@ -115,7 +130,7 @@ export function SearchBar({
|
||||
value={value}
|
||||
onChange={(e) => {
|
||||
setValue(e.target.value)
|
||||
setActive(-1)
|
||||
setMoved(null)
|
||||
}}
|
||||
onFocus={() => setFocused(true)}
|
||||
onBlur={() => setFocused(false)}
|
||||
@@ -124,7 +139,10 @@ export function SearchBar({
|
||||
if (!open || (e.key !== "ArrowDown" && e.key !== "ArrowUp")) return
|
||||
e.preventDefault()
|
||||
const step = e.key === "ArrowDown" ? 1 : -1
|
||||
setActive((active + step + items.length) % items.length)
|
||||
// the rows and, between the last and the first, no row: Enter then
|
||||
// searches what was typed, also when a link matches it
|
||||
const stops = items.length + 1
|
||||
setMoved(((active + 1 + step + stops) % stops) - 1)
|
||||
}}
|
||||
placeholder={`Search ${ENGINE_NAMES[used]}, or type / for commands`}
|
||||
aria-label="Search"
|
||||
@@ -159,7 +177,7 @@ export function SearchBar({
|
||||
role="option"
|
||||
aria-selected={i === active}
|
||||
onClick={() => run(item)}
|
||||
onMouseMove={() => setActive(i)}
|
||||
onMouseMove={() => setMoved(i)}
|
||||
className={cn(
|
||||
"flex cursor-pointer items-center gap-3 rounded-xl px-3.5 py-2.5",
|
||||
i === active && "bg-white/10"
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
import { cn } from "@/vendor/collabry/lib/cn"
|
||||
|
||||
export const DEFAULT_WALLPAPER = "/wallpaper.jpg"
|
||||
/** How dark the wallpaper is made until the user moves the slider, in percent. */
|
||||
export const DEFAULT_WALLPAPER_DIM = 40
|
||||
|
||||
function showDefault(img: HTMLImageElement) {
|
||||
if (!img.src.endsWith(DEFAULT_WALLPAPER)) img.src = DEFAULT_WALLPAPER
|
||||
@@ -28,11 +30,21 @@ export function WallpaperImage({
|
||||
)
|
||||
}
|
||||
|
||||
export function Wallpaper({ src }: { src?: string | null }) {
|
||||
export function Wallpaper({
|
||||
src,
|
||||
dim = DEFAULT_WALLPAPER_DIM,
|
||||
}: {
|
||||
src?: string | null
|
||||
/** 0 shows the picture as it is, 100 is black */
|
||||
dim?: number
|
||||
}) {
|
||||
return (
|
||||
<div className="fixed inset-0 -z-10 bg-black" aria-hidden>
|
||||
<WallpaperImage src={src} />
|
||||
<div className="absolute inset-0 wallpaper-dither" />
|
||||
<div
|
||||
className="absolute inset-0 bg-black"
|
||||
style={{ opacity: dim / 100 }}
|
||||
/>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
|
||||
+57
-6
@@ -77,7 +77,27 @@ export const verification = pgTable(
|
||||
|
||||
const bytea = customType<{ data: Uint8Array }>({ dataType: () => "bytea" })
|
||||
|
||||
/** A named group of links on the dashboard. */
|
||||
/** A set of cards, for example Home and Work. */
|
||||
export const dashboard = pgTable(
|
||||
"dashboard",
|
||||
{
|
||||
id: uuid("id").primaryKey().defaultRandom(),
|
||||
userId: text("user_id")
|
||||
.notNull()
|
||||
.references(() => user.id, { onDelete: "cascade" }),
|
||||
name: text("name").notNull(),
|
||||
// order in the switcher and in the settings
|
||||
position: integer("position").notNull().default(0),
|
||||
// null = bundled default wallpaper
|
||||
wallpaperUrl: text("wallpaper_url"),
|
||||
// percent of black over the wallpaper, see DEFAULT_WALLPAPER_DIM
|
||||
wallpaperDim: integer("wallpaper_dim").notNull().default(40),
|
||||
createdAt: timestamp("created_at").notNull().defaultNow(),
|
||||
},
|
||||
(t) => [index("dashboard_user_id_idx").on(t.userId)]
|
||||
)
|
||||
|
||||
/** A named group of links on a dashboard. */
|
||||
export const card = pgTable(
|
||||
"card",
|
||||
{
|
||||
@@ -85,10 +105,18 @@ export const card = pgTable(
|
||||
userId: text("user_id")
|
||||
.notNull()
|
||||
.references(() => user.id, { onDelete: "cascade" }),
|
||||
dashboardId: uuid("dashboard_id")
|
||||
.notNull()
|
||||
.references(() => dashboard.id, { onDelete: "cascade" }),
|
||||
// order on the dashboard
|
||||
position: integer("position").notNull().default(0),
|
||||
name: text("name").notNull(),
|
||||
createdAt: timestamp("created_at").notNull().defaultNow(),
|
||||
},
|
||||
(t) => [index("card_user_id_idx").on(t.userId)]
|
||||
(t) => [
|
||||
index("card_user_id_idx").on(t.userId),
|
||||
index("card_dashboard_id_idx").on(t.dashboardId),
|
||||
]
|
||||
)
|
||||
|
||||
export const link = pgTable(
|
||||
@@ -105,7 +133,8 @@ export const link = pgTable(
|
||||
position: integer("position").notNull().default(0),
|
||||
name: text("name").notNull(),
|
||||
url: text("url").notNull(),
|
||||
// image URL or a dashboard-icons name ("plex"); null = guess from name
|
||||
// image URL, an upload ("/api/icon?id=…") or a dashboard-icons name ("plex");
|
||||
// null = guess from name
|
||||
icon: text("icon"),
|
||||
createdAt: timestamp("created_at").notNull().defaultNow(),
|
||||
},
|
||||
@@ -120,13 +149,16 @@ export const settings = pgTable("settings", {
|
||||
.primaryKey()
|
||||
.references(() => user.id, { onDelete: "cascade" }),
|
||||
title: text("title").notNull().default("Dahoam"),
|
||||
// the dashboard that opens after sign-in; null = the first one
|
||||
defaultDashboardId: uuid("default_dashboard_id").references(
|
||||
() => dashboard.id,
|
||||
{ onDelete: "set null" }
|
||||
),
|
||||
searchEngine: text("search_engine", {
|
||||
enum: ["duckduckgo", "searxng", "google"],
|
||||
})
|
||||
.notNull()
|
||||
.default("duckduckgo"),
|
||||
// null = bundled default wallpaper
|
||||
wallpaperUrl: text("wallpaper_url"),
|
||||
// the big clock, see src/lib/clock.ts
|
||||
clockFont: text("clock_font", {
|
||||
enum: ["serif", "sans", "light", "rounded", "slab"],
|
||||
@@ -138,9 +170,28 @@ export const settings = pgTable("settings", {
|
||||
.default("solid"),
|
||||
})
|
||||
|
||||
/** A link icon that the user uploaded, served from /api/icon. */
|
||||
export const icon = pgTable(
|
||||
"icon",
|
||||
{
|
||||
id: uuid("id").primaryKey().defaultRandom(),
|
||||
userId: text("user_id")
|
||||
.notNull()
|
||||
.references(() => user.id, { onDelete: "cascade" }),
|
||||
mime: text("mime").notNull(),
|
||||
data: bytea("data").notNull(),
|
||||
createdAt: timestamp("created_at").notNull().defaultNow(),
|
||||
},
|
||||
(t) => [index("icon_user_id_idx").on(t.userId)]
|
||||
)
|
||||
|
||||
/** The wallpaper that was uploaded for a dashboard, served from /api/wallpaper. */
|
||||
export const wallpaper = pgTable("wallpaper", {
|
||||
userId: text("user_id")
|
||||
dashboardId: uuid("dashboard_id")
|
||||
.primaryKey()
|
||||
.references(() => dashboard.id, { onDelete: "cascade" }),
|
||||
userId: text("user_id")
|
||||
.notNull()
|
||||
.references(() => user.id, { onDelete: "cascade" }),
|
||||
mime: text("mime").notNull(),
|
||||
data: bytea("data").notNull(),
|
||||
|
||||
+322
-34
@@ -1,12 +1,25 @@
|
||||
import { createServerFn } from "@tanstack/react-start"
|
||||
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 { db } from "@/db"
|
||||
import { card, link, settings, wallpaper } from "@/db/schema"
|
||||
import {
|
||||
account,
|
||||
card,
|
||||
dashboard,
|
||||
icon,
|
||||
link,
|
||||
settings,
|
||||
wallpaper,
|
||||
} from "@/db/schema"
|
||||
import { auth, requireUser, signUpEnabled, ssoName } from "@/lib/auth"
|
||||
import { CLOCK_FONTS, CLOCK_STYLES } from "@/lib/clock"
|
||||
import { libraryNames } from "@/lib/icon-library"
|
||||
import { UPLOADED_ICON, lightVariant } from "@/lib/icons"
|
||||
import { ENGINES, parseSuggestions } from "@/lib/search"
|
||||
import { isReachable, statusChecks } from "@/lib/status"
|
||||
import { backupSchema, portable } from "@/lib/transfer"
|
||||
import type { Backup } from "@/lib/transfer"
|
||||
|
||||
const httpUrl = z.url({ protocol: /^https?$/ }).max(2000)
|
||||
|
||||
@@ -18,10 +31,29 @@ async function requireCard(userId: string, cardId: string) {
|
||||
if (!found.length) throw new Error("Unknown card")
|
||||
}
|
||||
|
||||
async function requireDashboard(userId: string, dashboardId: string) {
|
||||
const found = await db
|
||||
.select({ id: dashboard.id })
|
||||
.from(dashboard)
|
||||
.where(and(eq(dashboard.id, dashboardId), eq(dashboard.userId, userId)))
|
||||
if (!found.length) throw new Error("Unknown dashboard")
|
||||
}
|
||||
|
||||
/** The position after the last link of a card. */
|
||||
const endOf = (cardId: string) =>
|
||||
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(
|
||||
async () => ({
|
||||
signedIn: !!(await auth.api.getSession({ headers: getRequestHeaders() })),
|
||||
@@ -30,18 +62,61 @@ export const getAuthInfo = createServerFn({ method: "GET" }).handler(
|
||||
})
|
||||
)
|
||||
|
||||
/** Everything the dashboard renders, or null when signed out. */
|
||||
export const getDashboard = createServerFn({ method: "GET" }).handler(
|
||||
async () => {
|
||||
/** What the pages need of a dashboard. */
|
||||
const shown = {
|
||||
id: dashboard.id,
|
||||
name: dashboard.name,
|
||||
wallpaperUrl: dashboard.wallpaperUrl,
|
||||
wallpaperDim: dashboard.wallpaperDim,
|
||||
}
|
||||
|
||||
/**
|
||||
* Everything the dashboard renders, or null when signed out. Without a
|
||||
* `dashboardId`, or with one that does not exist, it is the default dashboard.
|
||||
*/
|
||||
export const getDashboard = createServerFn({ method: "GET" })
|
||||
// any string: the id comes from the address bar, a wrong one is not an error
|
||||
.validator(z.object({ dashboardId: z.string().optional() }).optional())
|
||||
.handler(async ({ data }) => {
|
||||
const session = await auth.api.getSession({ headers: getRequestHeaders() })
|
||||
if (!session) return null
|
||||
const userId = session.user.id
|
||||
const [cards, links, rows] = await Promise.all([
|
||||
const [dashboards, rows, passwords] = await Promise.all([
|
||||
db
|
||||
.select(shown)
|
||||
.from(dashboard)
|
||||
.where(eq(dashboard.userId, userId))
|
||||
.orderBy(...dashboardOrder),
|
||||
db.select().from(settings).where(eq(settings.userId, userId)),
|
||||
// someone who only ever signed in with SSO has no password to change
|
||||
db.$count(
|
||||
account,
|
||||
and(eq(account.userId, userId), eq(account.providerId, "credential"))
|
||||
),
|
||||
])
|
||||
// Cards need a dashboard and links need a card, so nobody is left without one.
|
||||
// shortcut: two first loads at the same moment make two of each, add a unique
|
||||
// constraint if that ever shows up
|
||||
if (!dashboards.length)
|
||||
dashboards.push(
|
||||
...(await db
|
||||
.insert(dashboard)
|
||||
.values({ userId, name: "Home" })
|
||||
.returning(shown))
|
||||
)
|
||||
const s = rows.at(0) // no row until the first save
|
||||
const find = (id?: string | null) => dashboards.find((d) => d.id === id)
|
||||
const byDefault = find(s?.defaultDashboardId) ?? dashboards[0]
|
||||
const current = find(data?.dashboardId) ?? byDefault
|
||||
const dashboardId = current.id
|
||||
const [library, cards, links] = await Promise.all([
|
||||
libraryNames(),
|
||||
db
|
||||
.select({ id: card.id, name: card.name })
|
||||
.from(card)
|
||||
.where(eq(card.userId, userId))
|
||||
.orderBy(asc(card.createdAt)),
|
||||
.where(and(eq(card.userId, userId), eq(card.dashboardId, dashboardId)))
|
||||
// cards that were never moved all have position 0: oldest first
|
||||
.orderBy(asc(card.position), asc(card.createdAt)),
|
||||
db
|
||||
.select({
|
||||
id: link.id,
|
||||
@@ -51,36 +126,66 @@ export const getDashboard = createServerFn({ method: "GET" }).handler(
|
||||
icon: link.icon,
|
||||
})
|
||||
.from(link)
|
||||
.where(eq(link.userId, userId))
|
||||
.innerJoin(card, eq(card.id, link.cardId))
|
||||
.where(and(eq(link.userId, userId), eq(card.dashboardId, dashboardId)))
|
||||
.orderBy(asc(link.position), asc(link.createdAt)),
|
||||
db.select().from(settings).where(eq(settings.userId, userId)),
|
||||
])
|
||||
// Links need a card to live in, so nobody is left without one.
|
||||
// shortcut: two first loads at the same moment make two cards, add a unique
|
||||
// constraint if that ever shows up
|
||||
if (!cards.length)
|
||||
cards.push(
|
||||
...(await db
|
||||
.insert(card)
|
||||
.values({ userId, name: "Apps" })
|
||||
.values({ userId, dashboardId, name: "Apps" })
|
||||
.returning({ id: card.id, name: card.name }))
|
||||
)
|
||||
const s = rows.at(0) // no row until the first save
|
||||
return {
|
||||
user: { name: session.user.name, email: session.user.email },
|
||||
user: {
|
||||
name: session.user.name,
|
||||
email: session.user.email,
|
||||
hasPassword: passwords > 0,
|
||||
},
|
||||
dashboards,
|
||||
dashboardId,
|
||||
defaultDashboardId: byDefault.id,
|
||||
cards: cards.map((c) => ({
|
||||
...c,
|
||||
links: links.filter((l) => l.cardId === c.id),
|
||||
links: links
|
||||
.filter((l) => l.cardId === c.id)
|
||||
.map((l) => ({
|
||||
...l,
|
||||
// an icon that the user chose stays as it is
|
||||
lightIcon: l.icon ? null : lightVariant(library, l.name),
|
||||
})),
|
||||
})),
|
||||
title: s?.title ?? "Dahoam",
|
||||
searchEngine: s?.searchEngine ?? "duckduckgo",
|
||||
wallpaperUrl: s?.wallpaperUrl ?? null,
|
||||
wallpaperUrl: current.wallpaperUrl,
|
||||
wallpaperDim: current.wallpaperDim,
|
||||
clockFont: s?.clockFont ?? "serif",
|
||||
clockStyle: s?.clockStyle ?? "solid",
|
||||
searxngUrl: process.env.SEARXNG_URL || null,
|
||||
statusChecks,
|
||||
}
|
||||
}
|
||||
)
|
||||
})
|
||||
|
||||
/** For every link of a dashboard: does its address answer? Empty when the checks are off. */
|
||||
export const getStatuses = createServerFn({ method: "GET" })
|
||||
.validator(z.object({ dashboardId: z.uuid() }))
|
||||
.handler(async ({ data }): Promise<Record<string, boolean>> => {
|
||||
const user = await requireUser()
|
||||
if (!statusChecks) return {}
|
||||
// only addresses that this user saved as links, never one from the request
|
||||
const links = await db
|
||||
.select({ id: link.id, url: link.url })
|
||||
.from(link)
|
||||
.innerJoin(card, eq(card.id, link.cardId))
|
||||
.where(
|
||||
and(eq(link.userId, user.id), eq(card.dashboardId, data.dashboardId))
|
||||
)
|
||||
// one request must not make the server call thousands of addresses
|
||||
.limit(200)
|
||||
const up = await Promise.all(links.map((l) => isReachable(l.url)))
|
||||
return Object.fromEntries(links.map((l, i) => [l.id, up[i]]))
|
||||
})
|
||||
|
||||
export const saveLink = createServerFn({ method: "POST" })
|
||||
.validator(
|
||||
@@ -113,6 +218,36 @@ export const saveLink = createServerFn({ method: "POST" })
|
||||
})
|
||||
|
||||
export const saveCard = createServerFn({ method: "POST" })
|
||||
.validator(
|
||||
z.object({
|
||||
id: z.uuid().optional(),
|
||||
name: z.string().trim().min(1).max(40),
|
||||
// the dashboard of the card. Another one than before moves the card there.
|
||||
dashboardId: z.uuid(),
|
||||
})
|
||||
)
|
||||
.handler(async ({ data: { id, name, dashboardId } }) => {
|
||||
const user = await requireUser()
|
||||
await requireDashboard(user.id, dashboardId)
|
||||
const end = endOfDashboard(dashboardId)
|
||||
if (id) {
|
||||
await db
|
||||
.update(card)
|
||||
.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)))
|
||||
} else {
|
||||
await db
|
||||
.insert(card)
|
||||
.values({ name, dashboardId, userId: user.id, position: end })
|
||||
}
|
||||
})
|
||||
|
||||
export const saveDashboard = createServerFn({ method: "POST" })
|
||||
.validator(
|
||||
z.object({
|
||||
id: z.uuid().optional(),
|
||||
@@ -123,14 +258,53 @@ export const saveCard = createServerFn({ method: "POST" })
|
||||
const user = await requireUser()
|
||||
if (id) {
|
||||
await db
|
||||
.update(card)
|
||||
.update(dashboard)
|
||||
.set({ name })
|
||||
.where(and(eq(card.id, id), eq(card.userId, user.id)))
|
||||
.where(and(eq(dashboard.id, id), eq(dashboard.userId, user.id)))
|
||||
} else {
|
||||
await db.insert(card).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. */
|
||||
export const deleteDashboard = createServerFn({ method: "POST" })
|
||||
.validator(z.object({ id: z.uuid() }))
|
||||
.handler(async ({ data }) => {
|
||||
const user = await requireUser()
|
||||
const mine = eq(dashboard.userId, user.id)
|
||||
if ((await db.$count(dashboard, mine)) < 2)
|
||||
throw new Error("The last dashboard stays")
|
||||
await db.delete(dashboard).where(and(eq(dashboard.id, data.id), mine))
|
||||
})
|
||||
|
||||
/** Deletes the card and, through the foreign key, its links. */
|
||||
export const deleteCard = createServerFn({ method: "POST" })
|
||||
.validator(z.object({ id: z.uuid() }))
|
||||
@@ -141,8 +315,8 @@ export const deleteCard = createServerFn({ method: "POST" })
|
||||
.where(and(eq(card.id, data.id), eq(card.userId, user.id)))
|
||||
})
|
||||
|
||||
/** Stores the result of a drag: for each card, its links in order. */
|
||||
export const moveLinks = createServerFn({ method: "POST" })
|
||||
/** Stores the result of a drag: the cards in order and, for each card, its links in order. */
|
||||
export const saveLayout = createServerFn({ method: "POST" })
|
||||
.validator(
|
||||
z.object({
|
||||
cards: z
|
||||
@@ -158,15 +332,20 @@ export const moveLinks = createServerFn({ method: "POST" })
|
||||
.from(card)
|
||||
.where(and(eq(card.userId, user.id), inArray(card.id, cardIds)))
|
||||
if (owned.length !== cardIds.length) throw new Error("Unknown card")
|
||||
// shortcut: one UPDATE per link, fine for a few hundred links; switch to a
|
||||
// single UPDATE ... FROM (VALUES ...) if a save gets slow
|
||||
// shortcut: one UPDATE per card and link, fine for a few hundred links; switch
|
||||
// to a single UPDATE ... FROM (VALUES ...) if a save gets slow
|
||||
await db.transaction(async (tx) => {
|
||||
for (const c of data.cards)
|
||||
for (const [at, c] of data.cards.entries()) {
|
||||
await tx
|
||||
.update(card)
|
||||
.set({ position: at })
|
||||
.where(and(eq(card.id, c.id), eq(card.userId, user.id)))
|
||||
for (const [position, id] of c.linkIds.entries())
|
||||
await tx
|
||||
.update(link)
|
||||
.set({ cardId: c.id, position })
|
||||
.where(and(eq(link.id, id), eq(link.userId, user.id)))
|
||||
}
|
||||
})
|
||||
})
|
||||
|
||||
@@ -185,11 +364,8 @@ export const saveSettings = createServerFn({ method: "POST" })
|
||||
z
|
||||
.object({
|
||||
title: z.string().trim().min(1).max(40),
|
||||
defaultDashboardId: z.uuid(),
|
||||
searchEngine: z.enum(ENGINES),
|
||||
// external image, the user's own upload, or null for the default
|
||||
wallpaperUrl: z
|
||||
.union([httpUrl, z.string().regex(/^\/api\/wallpaper\?v=\d+$/)])
|
||||
.nullable(),
|
||||
clockFont: z.enum(CLOCK_FONTS),
|
||||
clockStyle: z.enum(CLOCK_STYLES),
|
||||
})
|
||||
@@ -198,13 +374,125 @@ export const saveSettings = createServerFn({ method: "POST" })
|
||||
)
|
||||
.handler(async ({ data }) => {
|
||||
const user = await requireUser()
|
||||
if (data.defaultDashboardId)
|
||||
await requireDashboard(user.id, data.defaultDashboardId)
|
||||
await db
|
||||
.insert(settings)
|
||||
.values({ ...data, userId: user.id })
|
||||
.onConflictDoUpdate({ target: settings.userId, set: data })
|
||||
})
|
||||
|
||||
/** The wallpaper of one dashboard. An upload goes to /api/wallpaper instead. */
|
||||
export const saveWallpaper = createServerFn({ method: "POST" })
|
||||
.validator(
|
||||
z
|
||||
.object({
|
||||
dashboardId: z.uuid(),
|
||||
// an image on the web, or null for the default photo
|
||||
wallpaperUrl: httpUrl.nullable().optional(),
|
||||
wallpaperDim: z.int().min(0).max(100).optional(),
|
||||
})
|
||||
.refine((patch) => Object.keys(patch).length > 1)
|
||||
)
|
||||
.handler(async ({ data: { dashboardId, ...patch } }) => {
|
||||
const user = await requireUser()
|
||||
const saved = await db
|
||||
.update(dashboard)
|
||||
.set(patch)
|
||||
.where(and(eq(dashboard.id, dashboardId), eq(dashboard.userId, user.id)))
|
||||
.returning({ id: dashboard.id })
|
||||
if (!saved.length) throw new Error("Unknown dashboard")
|
||||
// the stored upload is no longer shown
|
||||
if (data.wallpaperUrl !== undefined && !data.wallpaperUrl?.startsWith("/"))
|
||||
await db.delete(wallpaper).where(eq(wallpaper.userId, user.id))
|
||||
if (patch.wallpaperUrl !== undefined)
|
||||
await db.delete(wallpaper).where(eq(wallpaper.dashboardId, dashboardId))
|
||||
})
|
||||
|
||||
/** Every dashboard of the user with its cards and links, see backupSchema. */
|
||||
export const exportData = createServerFn({ method: "GET" }).handler(
|
||||
async (): Promise<Backup> => {
|
||||
const user = await requireUser()
|
||||
const [dashboards, cards, links] = await Promise.all([
|
||||
db
|
||||
.select()
|
||||
.from(dashboard)
|
||||
.where(eq(dashboard.userId, user.id))
|
||||
.orderBy(...dashboardOrder),
|
||||
db
|
||||
.select()
|
||||
.from(card)
|
||||
.where(eq(card.userId, user.id))
|
||||
.orderBy(asc(card.position), asc(card.createdAt)),
|
||||
db
|
||||
.select()
|
||||
.from(link)
|
||||
.where(eq(link.userId, user.id))
|
||||
.orderBy(asc(link.position), asc(link.createdAt)),
|
||||
])
|
||||
return {
|
||||
dashboards: dashboards.map((d) => ({
|
||||
name: d.name,
|
||||
wallpaperUrl: portable(d.wallpaperUrl),
|
||||
wallpaperDim: d.wallpaperDim,
|
||||
cards: cards
|
||||
.filter((c) => c.dashboardId === d.id)
|
||||
.map((c) => ({
|
||||
name: c.name,
|
||||
links: links
|
||||
.filter((l) => l.cardId === c.id)
|
||||
.map((l) => ({
|
||||
name: l.name,
|
||||
url: l.url,
|
||||
icon: portable(l.icon),
|
||||
})),
|
||||
})),
|
||||
})),
|
||||
}
|
||||
}
|
||||
)
|
||||
|
||||
/** Adds the dashboards of an export or of a bookmarks file. Nothing is replaced. */
|
||||
export const importData = createServerFn({ method: "POST" })
|
||||
.validator(backupSchema)
|
||||
.handler(async ({ data }) => {
|
||||
const user = await requireUser()
|
||||
const userId = user.id
|
||||
const added = { dashboards: data.dashboards.length, cards: 0, links: 0 }
|
||||
// all of the file or nothing of it
|
||||
await db.transaction(async (tx) => {
|
||||
for (const d of data.dashboards) {
|
||||
const [{ id: dashboardId }] = await tx
|
||||
.insert(dashboard)
|
||||
.values({
|
||||
userId,
|
||||
name: d.name,
|
||||
position: lastDashboard(userId),
|
||||
wallpaperUrl: d.wallpaperUrl,
|
||||
wallpaperDim: d.wallpaperDim,
|
||||
})
|
||||
.returning({ id: dashboard.id })
|
||||
for (const [position, c] of d.cards.entries()) {
|
||||
const [{ id: cardId }] = await tx
|
||||
.insert(card)
|
||||
.values({ userId, dashboardId, position, name: c.name })
|
||||
.returning({ id: card.id })
|
||||
added.cards++
|
||||
added.links += c.links.length
|
||||
if (c.links.length)
|
||||
await tx.insert(link).values(
|
||||
c.links.map((l, at) => ({
|
||||
userId,
|
||||
cardId,
|
||||
position: at,
|
||||
name: l.name,
|
||||
url: l.url,
|
||||
// an upload of another account would not load here
|
||||
icon: portable(l.icon),
|
||||
}))
|
||||
)
|
||||
}
|
||||
}
|
||||
})
|
||||
return added
|
||||
})
|
||||
|
||||
export const suggest = createServerFn({ method: "GET" })
|
||||
|
||||
@@ -0,0 +1,31 @@
|
||||
// Server side: what the icon library has. The link dialog loads the same index in the browser.
|
||||
import { LIBRARY_INDEX } from "@/lib/icons"
|
||||
|
||||
const DAY = 24 * 60 * 60 * 1000
|
||||
let known: { names: Set<string>; at: number } | undefined
|
||||
|
||||
/**
|
||||
* The names of the library's icons, kept in memory for a day. Empty when the
|
||||
* library cannot be reached: the dashboard then shows the plain icons.
|
||||
*/
|
||||
export async function libraryNames() {
|
||||
if (known && Date.now() - known.at < DAY) return known.names
|
||||
try {
|
||||
const res = await fetch(LIBRARY_INDEX, {
|
||||
// the page waits for this once a day at most, so not for long
|
||||
signal: AbortSignal.timeout(2000),
|
||||
})
|
||||
const index = (await res.json()) as { png: string[] }
|
||||
known = {
|
||||
names: new Set(index.png.map((file) => file.replace(/\.png$/, ""))),
|
||||
at: Date.now(),
|
||||
}
|
||||
} catch {
|
||||
// what was known before, and the next try in five minutes
|
||||
known = {
|
||||
names: known?.names ?? new Set(),
|
||||
at: Date.now() - DAY + 5 * 60 * 1000,
|
||||
}
|
||||
}
|
||||
return known.names
|
||||
}
|
||||
@@ -0,0 +1,57 @@
|
||||
import assert from "node:assert/strict"
|
||||
import { test } from "node:test"
|
||||
import {
|
||||
UPLOADED_ICON,
|
||||
iconSources,
|
||||
lightVariant,
|
||||
searchIcons,
|
||||
} from "./icons.ts"
|
||||
|
||||
const link = { name: "Home Assistant", url: "https://ha.example.com/lovelace" }
|
||||
const first = (icon: string | null) => iconSources({ ...link, icon })[0]
|
||||
|
||||
test("no icon: looked up by name, then the site's favicon", () => {
|
||||
assert.deepEqual(iconSources({ ...link, icon: null }), [
|
||||
"https://cdn.jsdelivr.net/gh/homarr-labs/dashboard-icons/png/home-assistant.png",
|
||||
"https://ha.example.com/favicon.ico",
|
||||
])
|
||||
})
|
||||
|
||||
test("the light version is used for a link without an icon of its own", () => {
|
||||
const library = new Set(["github", "github-light", "plex"])
|
||||
assert.equal(lightVariant(library, " GitHub "), "github-light")
|
||||
assert.equal(lightVariant(library, "Plex"), null)
|
||||
const github = { name: "GitHub", url: "https://github.com" }
|
||||
const lightIcon = "github-light"
|
||||
assert.match(
|
||||
iconSources({ ...github, icon: null, lightIcon })[0],
|
||||
/\/png\/github-light\.png$/
|
||||
)
|
||||
// the user chose the dark one
|
||||
assert.match(
|
||||
iconSources({ ...github, icon: "github", lightIcon })[0],
|
||||
/\/png\/github\.png$/
|
||||
)
|
||||
})
|
||||
|
||||
test("an icon name is looked up in the library", () => {
|
||||
assert.match(first(" Plex "), /\/png\/plex\.png$/)
|
||||
})
|
||||
|
||||
test("an image address and an upload are used as they are", () => {
|
||||
assert.equal(first("https://example.com/a.png"), "https://example.com/a.png")
|
||||
assert.equal(first(`${UPLOADED_ICON}abc`), "/api/icon?id=abc")
|
||||
})
|
||||
|
||||
test("searchIcons: names that start with the query first, the shortest first", () => {
|
||||
// the order of the library's index: "plex-alt" is before "plex" there
|
||||
const names = ["a-plex", "jellyfin", "plex-alt", "plex", "plexamp"]
|
||||
assert.deepEqual(searchIcons(names, "Plex"), [
|
||||
"plex",
|
||||
"plexamp",
|
||||
"plex-alt",
|
||||
"a-plex",
|
||||
])
|
||||
assert.deepEqual(searchIcons(names, "plex", 2), ["plex", "plexamp"])
|
||||
assert.deepEqual(searchIcons(names, "nothing"), [])
|
||||
})
|
||||
@@ -0,0 +1,65 @@
|
||||
// Where a link's icon comes from. Pure, so it can be tested without a browser.
|
||||
|
||||
const LIBRARY = "https://cdn.jsdelivr.net/gh/homarr-labs/dashboard-icons"
|
||||
|
||||
/** JSON with the file names of every icon in the library: `{ png: ["plex.png", …] }`. */
|
||||
export const LIBRARY_INDEX = `${LIBRARY}/tree.json`
|
||||
|
||||
/** How a link stores an icon that the user uploaded: this plus the icon's id. */
|
||||
export const UPLOADED_ICON = "/api/icon?id="
|
||||
|
||||
const slug = (name: string) =>
|
||||
name
|
||||
.trim()
|
||||
.toLowerCase()
|
||||
.replace(/[^a-z0-9]+/g, "-")
|
||||
.replace(/^-|-$/g, "")
|
||||
|
||||
export const libraryIcon = (name: string) => `${LIBRARY}/png/${slug(name)}.png`
|
||||
|
||||
/**
|
||||
* The library has a light version of some icons (`github-light`), made for dark
|
||||
* backgrounds like the cards. Its name for a link that is called `name`, or null.
|
||||
*/
|
||||
export function lightVariant(libraryNames: Set<string>, name: string) {
|
||||
const light = `${slug(name)}-light`
|
||||
return libraryNames.has(light) ? light : null
|
||||
}
|
||||
|
||||
/** An image address or an upload, not a name in the library. */
|
||||
export const isImageAddress = (icon: string) =>
|
||||
/^https?:\/\//.test(icon) || icon.startsWith(UPLOADED_ICON)
|
||||
|
||||
/** Icon sources to try in order; the letter tile is the last resort. */
|
||||
export function iconSources({
|
||||
name,
|
||||
url,
|
||||
icon,
|
||||
lightIcon,
|
||||
}: {
|
||||
name: string
|
||||
url: string
|
||||
icon: string | null
|
||||
/** see lightVariant; only used when the link has no icon of its own */
|
||||
lightIcon?: string | null
|
||||
}) {
|
||||
return [
|
||||
icon && isImageAddress(icon)
|
||||
? icon
|
||||
: libraryIcon(icon || lightIcon || name),
|
||||
`${new URL(url).origin}/favicon.ico`,
|
||||
]
|
||||
}
|
||||
|
||||
/**
|
||||
* Library icons for what the user typed: names that start with it, then names that
|
||||
* contain it. In both groups the shortest first, so "plex" is before "plex-alt".
|
||||
*/
|
||||
export function searchIcons(names: string[], query: string, limit = 42) {
|
||||
const q = slug(query)
|
||||
const rank = (n: string) => (n.startsWith(q) ? 0 : 1000) + n.length
|
||||
return names
|
||||
.filter((n) => n.includes(q))
|
||||
.sort((a, b) => rank(a) - rank(b))
|
||||
.slice(0, limit)
|
||||
}
|
||||
+13
-1
@@ -1,6 +1,6 @@
|
||||
import assert from "node:assert/strict"
|
||||
import { test } from "node:test"
|
||||
import { drop, moveOver, order } from "./layout.ts"
|
||||
import { drop, moveCard, moveOver, order } from "./layout.ts"
|
||||
|
||||
const cards = () => [
|
||||
{ id: "apps", links: [{ id: "a" }, { id: "b" }, { id: "c" }] },
|
||||
@@ -31,6 +31,18 @@ test("a link dropped on a card goes to its end", () => {
|
||||
assert.deepEqual(ids(drop(cards(), "a", "empty")), ["bc", "x", "a"])
|
||||
})
|
||||
|
||||
test("a card takes the place of the card it is over, with its links", () => {
|
||||
assert.deepEqual(ids(moveCard(cards(), "apps", "empty")), ["x", "", "abc"])
|
||||
assert.deepEqual(ids(moveCard(cards(), "empty", "apps")), ["", "abc", "x"])
|
||||
})
|
||||
|
||||
test("a card over itself, or a link over a card, moves no card", () => {
|
||||
const before = cards()
|
||||
assert.equal(moveCard(before, "apps", "apps"), before)
|
||||
assert.equal(moveCard(before, "a", "web"), before)
|
||||
assert.equal(drop(before, "apps", "web"), before)
|
||||
})
|
||||
|
||||
test("unknown ids change nothing", () => {
|
||||
const before = cards()
|
||||
assert.equal(drop(before, "nope", "x"), before)
|
||||
|
||||
+16
-2
@@ -1,4 +1,4 @@
|
||||
// Where links sit in their cards. Pure, so drag and drop can be tested without a browser.
|
||||
// Where the cards sit, and the links in them. Pure, so drag and drop can be tested without a browser.
|
||||
|
||||
type Card = { id: string; links: { id: string }[] }
|
||||
|
||||
@@ -28,6 +28,20 @@ export function moveOver<TCard extends Card>(
|
||||
)
|
||||
}
|
||||
|
||||
/** While dragging a card: it takes the place of the card it hovers over. */
|
||||
export function moveCard<TCard extends Card>(
|
||||
cards: TCard[],
|
||||
cardId: string,
|
||||
overId: string
|
||||
): TCard[] {
|
||||
const from = cards.findIndex((c) => c.id === cardId)
|
||||
const to = cards.findIndex((c) => c.id === overId)
|
||||
if (from < 0 || to < 0 || from === to) return cards
|
||||
const next = [...cards]
|
||||
next.splice(to, 0, ...next.splice(from, 1))
|
||||
return next
|
||||
}
|
||||
|
||||
/** On drop: the link takes the place of the link it was dropped on. */
|
||||
export function drop<TCard extends Card>(
|
||||
cards: TCard[],
|
||||
@@ -45,6 +59,6 @@ export function drop<TCard extends Card>(
|
||||
return cards.map((c) => (c === card ? { ...c, links } : c))
|
||||
}
|
||||
|
||||
/** What the server stores: per card, its link ids in order. */
|
||||
/** What the server stores: the cards in order and, per card, its link ids in order. */
|
||||
export const order = (cards: Card[]) =>
|
||||
cards.map((c) => ({ id: c.id, linkIds: c.links.map((l) => l.id) }))
|
||||
|
||||
+22
-1
@@ -1,6 +1,27 @@
|
||||
import assert from "node:assert/strict"
|
||||
import { test } from "node:test"
|
||||
import { parseSuggestions, searchUrl } from "./search.ts"
|
||||
import { matchLinks, parseSuggestions, searchUrl } from "./search.ts"
|
||||
|
||||
test("matchLinks", () => {
|
||||
const links = ["Grafana", "Home Assistant", "IT-Tools", "Sonarr"].map(
|
||||
(name) => ({ name })
|
||||
)
|
||||
const names = (typed: string) => {
|
||||
const { links: found, starts } = matchLinks(links, typed)
|
||||
return [found.map((l) => l.name).join(","), starts]
|
||||
}
|
||||
// the start of the name or of a word in it comes first and counts as a start
|
||||
assert.deepEqual(names("so"), ["Sonarr", 1])
|
||||
assert.deepEqual(names(" ASSIST "), ["Home Assistant", 1])
|
||||
assert.deepEqual(names("tools"), ["IT-Tools", 1])
|
||||
// only inside a word: listed, but Enter does not open it
|
||||
assert.deepEqual(names("ana"), ["Grafana", 0])
|
||||
assert.deepEqual(names("a"), ["Home Assistant,Grafana,Sonarr", 1])
|
||||
assert.deepEqual(names("plex"), ["", 0])
|
||||
// a query with a space is one phrase
|
||||
assert.deepEqual(names("home a"), ["Home Assistant", 1])
|
||||
assert.deepEqual(names("grafana docs"), ["", 0])
|
||||
})
|
||||
|
||||
test("searchUrl", () => {
|
||||
assert.equal(
|
||||
|
||||
@@ -29,6 +29,26 @@ export function searchUrl(
|
||||
return `https://duckduckgo.com/?q=${q}`
|
||||
}
|
||||
|
||||
/**
|
||||
* The links for what was typed. First the ones where the name or a word of it starts
|
||||
* with it (`starts` of them: Enter opens the first), then the ones that contain it.
|
||||
*/
|
||||
export function matchLinks<TLink extends { name: string }>(
|
||||
links: TLink[],
|
||||
typed: string
|
||||
) {
|
||||
const q = typed.trim().toLowerCase()
|
||||
const starts: TLink[] = []
|
||||
const contains: TLink[] = []
|
||||
for (const link of links) {
|
||||
const name = link.name.toLowerCase()
|
||||
const words = [name, ...name.split(/[^\p{L}\p{N}]+/u)]
|
||||
if (words.some((word) => word.startsWith(q))) starts.push(link)
|
||||
else if (name.includes(q)) contains.push(link)
|
||||
}
|
||||
return { links: [...starts, ...contains], starts: starts.length }
|
||||
}
|
||||
|
||||
/** Both DuckDuckGo and SearXNG answer in OpenSearch form: [query, [suggestions]] */
|
||||
export function parseSuggestions(body: unknown): string[] {
|
||||
const list = Array.isArray(body) && Array.isArray(body[1]) ? body[1] : body
|
||||
|
||||
@@ -0,0 +1,52 @@
|
||||
import assert from "node:assert/strict"
|
||||
import { createServer } from "node:http"
|
||||
import { test } from "node:test"
|
||||
import { isReachable, isUp } from "./status.ts"
|
||||
|
||||
test("isUp: any answer below 500", () => {
|
||||
assert.equal(isUp({ status: 200 }), true)
|
||||
assert.equal(isUp({ status: 302 }), true)
|
||||
assert.equal(isUp({ status: 401 }), true) // a login page is an app that runs
|
||||
assert.equal(isUp({ status: 404 }), true)
|
||||
assert.equal(isUp({ status: 500 }), false)
|
||||
assert.equal(isUp({ status: 502 }), false)
|
||||
})
|
||||
|
||||
test("isUp: a certificate that this server does not trust is still an answer", () => {
|
||||
const failed = (code: string) =>
|
||||
Object.assign(new TypeError("fetch failed"), { cause: { code } })
|
||||
assert.equal(isUp({ error: failed("DEPTH_ZERO_SELF_SIGNED_CERT") }), true)
|
||||
assert.equal(isUp({ error: failed("UNABLE_TO_VERIFY_LEAF_SIGNATURE") }), true)
|
||||
assert.equal(isUp({ error: failed("ERR_TLS_CERT_ALTNAME_INVALID") }), true)
|
||||
assert.equal(isUp({ error: failed("ECONNREFUSED") }), false)
|
||||
assert.equal(isUp({ error: failed("ENOTFOUND") }), false)
|
||||
assert.equal(
|
||||
isUp({ error: new DOMException("timeout", "TimeoutError") }),
|
||||
false
|
||||
)
|
||||
assert.equal(isUp({ error: null }), false)
|
||||
})
|
||||
|
||||
test("isReachable: asks the address, once per minute", async () => {
|
||||
let requests = 0
|
||||
const server = createServer((req, res) => {
|
||||
requests++
|
||||
res.writeHead(req.url === "/broken" ? 503 : 302, {
|
||||
Location: "http://127.0.0.1:1/",
|
||||
})
|
||||
res.end()
|
||||
})
|
||||
await new Promise<void>((resolve) => server.listen(0, "127.0.0.1", resolve))
|
||||
const { port } = server.address() as { port: number }
|
||||
const base = `http://127.0.0.1:${port}`
|
||||
try {
|
||||
// the redirect is not followed: its target does not answer
|
||||
assert.equal(await isReachable(`${base}/`), true)
|
||||
assert.equal(await isReachable(`${base}/`), true)
|
||||
assert.equal(requests, 1)
|
||||
assert.equal(await isReachable(`${base}/broken`), false)
|
||||
} finally {
|
||||
server.close()
|
||||
}
|
||||
assert.equal(await isReachable("http://127.0.0.1:1/"), false) // nothing listens
|
||||
})
|
||||
@@ -0,0 +1,45 @@
|
||||
// Is the address of a link reachable? Server side: the server asks, not the browser,
|
||||
// so it also works for apps that do not allow requests from other pages.
|
||||
|
||||
/** Off unless the operator turns it on: users make the server call addresses they typed. */
|
||||
export const statusChecks = process.env.STATUS_CHECKS === "true"
|
||||
|
||||
const TTL = 60_000
|
||||
const TIMEOUT = 4000
|
||||
/** Per address the last check, also while it runs, so one address is asked once a minute. */
|
||||
const checks = new Map<string, { at: number; up: Promise<boolean> }>()
|
||||
|
||||
// A server answered, only this server does not trust its certificate (self-signed,
|
||||
// private CA). The browser of the user may well trust it.
|
||||
const CERTIFICATE = /CERT|SELF_SIGNED|UNABLE_TO_VERIFY|ALTNAME/
|
||||
|
||||
/** Up: any answer below 500. An app behind a proxy that is down answers 502 to 504. */
|
||||
export function isUp(result: { status: number } | { error: unknown }) {
|
||||
if ("status" in result) return result.status < 500
|
||||
const cause = (result.error as { cause?: { code?: unknown } } | null)?.cause
|
||||
return typeof cause?.code === "string" && CERTIFICATE.test(cause.code)
|
||||
}
|
||||
|
||||
async function check(url: string) {
|
||||
try {
|
||||
const res = await fetch(url, {
|
||||
// a redirect is an answer: do not follow it to another host
|
||||
redirect: "manual",
|
||||
signal: AbortSignal.timeout(TIMEOUT),
|
||||
})
|
||||
void res.body?.cancel() // the page itself is of no interest
|
||||
return isUp(res)
|
||||
} catch (error) {
|
||||
return isUp({ error })
|
||||
}
|
||||
}
|
||||
|
||||
export function isReachable(url: string) {
|
||||
const now = Date.now()
|
||||
if (checks.size > 1000)
|
||||
for (const [key, { at }] of checks) if (now - at > TTL) checks.delete(key)
|
||||
let last = checks.get(url)
|
||||
if (!last || now - last.at > TTL)
|
||||
checks.set(url, (last = { at: now, up: check(url) }))
|
||||
return last.up
|
||||
}
|
||||
@@ -0,0 +1,109 @@
|
||||
import assert from "node:assert/strict"
|
||||
import { test } from "node:test"
|
||||
import { backupSchema, parseBookmarks, portable } from "./transfer.ts"
|
||||
|
||||
// what Firefox and Chrome write, shortened
|
||||
const BOOKMARKS = `<!DOCTYPE NETSCAPE-Bookmark-file-1>
|
||||
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=UTF-8">
|
||||
<TITLE>Bookmarks</TITLE>
|
||||
<H1>Bookmarks</H1>
|
||||
<DL><p>
|
||||
<DT><A HREF="https://example.com/top" ADD_DATE="1">Top level</A>
|
||||
<DT><H3 ADD_DATE="1" PERSONAL_TOOLBAR_FOLDER="true">Bookmarks bar</H3>
|
||||
<DL><p>
|
||||
<DT><A HREF="https://git.example.com/?a=1&b=2" ICON="data:image/png;base64,AAAA">Git & "CI" ü</A>
|
||||
<DT><H3>Media</H3>
|
||||
<DL><p>
|
||||
<DT><A HREF="http://plex.lan:32400/web">Plex</A>
|
||||
<DT><A HREF="javascript:alert(1)">A bookmarklet</A>
|
||||
<DT><A HREF="https://nameless.example.com/x"></A>
|
||||
</DL><p>
|
||||
<DT><A HREF="place:sort=8">Most visited</A>
|
||||
</DL><p>
|
||||
<DT><H3>Empty folder</H3>
|
||||
<DL><p>
|
||||
</DL><p>
|
||||
</DL><p>`
|
||||
|
||||
test("parseBookmarks: a card per folder that has bookmarks", () => {
|
||||
const found = parseBookmarks(BOOKMARKS)
|
||||
assert.ok(found)
|
||||
assert.equal(found.skipped, 2) // the bookmarklet and place:
|
||||
assert.deepEqual(found.backup, {
|
||||
dashboards: [
|
||||
{
|
||||
name: "Bookmarks",
|
||||
cards: [
|
||||
{
|
||||
name: "Bookmarks",
|
||||
links: [{ name: "Top level", url: "https://example.com/top" }],
|
||||
},
|
||||
{
|
||||
name: "Bookmarks bar",
|
||||
links: [
|
||||
{ name: 'Git & "CI" ü', url: "https://git.example.com/?a=1&b=2" },
|
||||
],
|
||||
},
|
||||
{
|
||||
name: "Media",
|
||||
links: [
|
||||
{ name: "Plex", url: "http://plex.lan:32400/web" },
|
||||
{
|
||||
name: "nameless.example.com",
|
||||
url: "https://nameless.example.com/x",
|
||||
},
|
||||
],
|
||||
},
|
||||
],
|
||||
},
|
||||
],
|
||||
})
|
||||
// what it makes is what an import takes
|
||||
assert.ok(backupSchema.safeParse(found.backup).success)
|
||||
})
|
||||
|
||||
test("parseBookmarks: limits, long names, files without bookmarks", () => {
|
||||
assert.equal(parseBookmarks("<html><body>Hello</body></html>"), null)
|
||||
assert.equal(parseBookmarks('{"dashboards": []}'), null)
|
||||
const many = Array.from(
|
||||
{ length: 502 },
|
||||
(_, i) => `<DT><A HREF="https://example.com/${i}">${"n".repeat(70)}</A>`
|
||||
).join("")
|
||||
const found = parseBookmarks(`<DL>${many}</DL>`)
|
||||
assert.ok(found)
|
||||
assert.equal(found.backup.dashboards[0].cards[0].links.length, 500)
|
||||
assert.equal(found.backup.dashboards[0].cards[0].links[0].name.length, 60)
|
||||
assert.equal(found.skipped, 2)
|
||||
assert.ok(backupSchema.safeParse(found.backup).success)
|
||||
})
|
||||
|
||||
test("backupSchema refuses what is not a web address", () => {
|
||||
const withUrl = (url: string) => ({
|
||||
dashboards: [
|
||||
{ name: "D", cards: [{ name: "C", links: [{ name: "L", url }] }] },
|
||||
],
|
||||
})
|
||||
assert.ok(backupSchema.safeParse(withUrl("https://example.com")).success)
|
||||
assert.ok(!backupSchema.safeParse(withUrl("javascript:alert(1)")).success)
|
||||
assert.ok(!backupSchema.safeParse({ dashboards: [] }).success)
|
||||
// 11 cards with 500 links each are more than one file may hold
|
||||
const links = Array.from({ length: 500 }, () => ({
|
||||
name: "L",
|
||||
url: "https://example.com",
|
||||
}))
|
||||
const cards = (n: number) =>
|
||||
Array.from({ length: n }, () => ({ name: "C", links }))
|
||||
const file = (n: number) => ({ dashboards: [{ name: "D", cards: cards(n) }] })
|
||||
assert.ok(backupSchema.safeParse(file(10)).success)
|
||||
assert.ok(!backupSchema.safeParse(file(11)).success)
|
||||
})
|
||||
|
||||
test("portable: uploads stay with their account", () => {
|
||||
assert.equal(portable("/api/icon?id=1"), null)
|
||||
assert.equal(portable("plex"), "plex")
|
||||
assert.equal(
|
||||
portable("https://example.com/a.png"),
|
||||
"https://example.com/a.png"
|
||||
)
|
||||
assert.equal(portable(null), null)
|
||||
})
|
||||
@@ -0,0 +1,126 @@
|
||||
// Export and import: the shape of the file, and how a browser's bookmarks become one.
|
||||
import { z } from "zod"
|
||||
|
||||
const httpUrl = z.url({ protocol: /^https?$/ }).max(2000)
|
||||
const MAX_CARDS = 100
|
||||
const MAX_LINKS = 500 // per card
|
||||
const MAX_TOTAL = 5000 // links in one file
|
||||
|
||||
/**
|
||||
* What an export holds and an import takes: dashboards with their cards and links.
|
||||
* Uploaded wallpapers and icons are not in it, they belong to one account.
|
||||
*/
|
||||
export const backupSchema = z.object({
|
||||
dashboards: z
|
||||
.array(
|
||||
z.object({
|
||||
name: z.string().trim().min(1).max(40),
|
||||
// an image on the web; null or missing: the default photo
|
||||
wallpaperUrl: httpUrl.nullish(),
|
||||
wallpaperDim: z.int().min(0).max(100).optional(),
|
||||
cards: z
|
||||
.array(
|
||||
z.object({
|
||||
name: z.string().trim().min(1).max(40),
|
||||
links: z
|
||||
.array(
|
||||
z.object({
|
||||
name: z.string().trim().min(1).max(60),
|
||||
url: httpUrl,
|
||||
// an image on the web or a name in the icon library
|
||||
icon: z.string().trim().max(2000).nullish(),
|
||||
})
|
||||
)
|
||||
.max(MAX_LINKS),
|
||||
})
|
||||
)
|
||||
.max(MAX_CARDS),
|
||||
})
|
||||
)
|
||||
.min(1)
|
||||
.max(20)
|
||||
// one import is one transaction: keep it small enough for that
|
||||
.refine(
|
||||
(dashboards) =>
|
||||
dashboards.flatMap((d) => d.cards.flatMap((c) => c.links)).length <=
|
||||
MAX_TOTAL
|
||||
),
|
||||
})
|
||||
export type Backup = z.infer<typeof backupSchema>
|
||||
|
||||
/** An upload ("/api/icon?id=…") only works for the account that made it. */
|
||||
export const portable = (address?: string | null) =>
|
||||
!address || address.startsWith("/") ? null : address
|
||||
|
||||
const ENTITIES: Record<string, string> = {
|
||||
amp: "&",
|
||||
lt: "<",
|
||||
gt: ">",
|
||||
quot: '"',
|
||||
apos: "'",
|
||||
}
|
||||
const text = (html: string) =>
|
||||
html
|
||||
.replace(/<[^>]*>/g, "")
|
||||
.replace(/&(#x?[0-9a-f]+|[a-z]+);/gi, (entity, code: string) => {
|
||||
if (code[0] !== "#") return ENTITIES[code.toLowerCase()] ?? entity
|
||||
const point =
|
||||
code[1].toLowerCase() === "x"
|
||||
? parseInt(code.slice(2), 16)
|
||||
: parseInt(code.slice(1), 10)
|
||||
return point <= 0x10ffff ? String.fromCodePoint(point) : entity
|
||||
})
|
||||
.trim()
|
||||
|
||||
/**
|
||||
* The bookmarks file that every browser exports (HTML) as one dashboard: a card per
|
||||
* folder that has bookmarks, named like the folder. `skipped` counts what was left out:
|
||||
* addresses that are not http(s), and what is over the limits of an import.
|
||||
* Null when the file has no bookmark in it.
|
||||
*/
|
||||
export function parseBookmarks(html: string) {
|
||||
const cards = new Map<string, Backup["dashboards"][0]["cards"][0]>()
|
||||
const folders: string[] = [] // the path to where we are
|
||||
let heading: string | null = null // a folder name that waits for its <DL>
|
||||
let skipped = 0
|
||||
let total = 0
|
||||
const tags =
|
||||
/<DL\b|<\/DL>|<H3\b[^>]*>([\s\S]*?)<\/H3>|<A\b([^>]*)>([\s\S]*?)<\/A>/gi
|
||||
for (const [tag, folder, attributes, title] of html.matchAll(tags)) {
|
||||
if (/^<DL/i.test(tag)) {
|
||||
folders.push(heading ?? "")
|
||||
heading = null
|
||||
} else if (/^<\/DL/i.test(tag)) folders.pop()
|
||||
else if (/^<H3/i.test(tag)) heading = text(folder)
|
||||
else {
|
||||
const href = /\bHREF\s*=\s*"([^"]*)"/i.exec(attributes)
|
||||
const url = httpUrl.safeParse(text(href?.[1] ?? ""))
|
||||
// two folders with the same name stay two cards
|
||||
const path = folders.join("\n")
|
||||
const card = cards.get(path) ?? {
|
||||
name: (folders.filter(Boolean).at(-1) ?? "Bookmarks").slice(0, 40),
|
||||
links: [],
|
||||
}
|
||||
if (
|
||||
!url.success ||
|
||||
total >= MAX_TOTAL ||
|
||||
card.links.length >= MAX_LINKS ||
|
||||
(!cards.has(path) && cards.size >= MAX_CARDS)
|
||||
) {
|
||||
skipped++
|
||||
continue
|
||||
}
|
||||
cards.set(path, card)
|
||||
total++
|
||||
card.links.push({
|
||||
name: (text(title) || new URL(url.data).hostname).slice(0, 60),
|
||||
url: url.data,
|
||||
})
|
||||
}
|
||||
}
|
||||
if (!cards.size) return null
|
||||
const backup: Backup = {
|
||||
dashboards: [{ name: "Bookmarks", cards: [...cards.values()] }],
|
||||
}
|
||||
return { backup, skipped }
|
||||
}
|
||||
@@ -0,0 +1,49 @@
|
||||
// Shared by the routes that store images in the database (wallpaper, link icons).
|
||||
import { auth } from "@/lib/auth"
|
||||
|
||||
export async function userId(request: Request) {
|
||||
const session = await auth.api.getSession({ headers: request.headers })
|
||||
return session?.user.id
|
||||
}
|
||||
|
||||
/** The image in the body of an upload, or the response that says why it was refused. */
|
||||
export async function readImage(
|
||||
request: Request,
|
||||
limits: { types: string[]; formats: string; maxMb: number }
|
||||
) {
|
||||
const id = await userId(request)
|
||||
if (!id) return new Response("Unauthorized", { status: 401 })
|
||||
const mime = request.headers.get("content-type") ?? ""
|
||||
if (!limits.types.includes(mime))
|
||||
return new Response(`Use a ${limits.formats} image`, { status: 415 })
|
||||
const maxBytes = limits.maxMb * 1024 * 1024
|
||||
const tooLarge = () =>
|
||||
new Response(`Image is empty or larger than ${limits.maxMb} MB`, {
|
||||
status: 413,
|
||||
})
|
||||
// a chunked body has no declared size and could fill the memory
|
||||
const declared = Number(request.headers.get("content-length"))
|
||||
if (
|
||||
!(declared > 0 && declared <= maxBytes) ||
|
||||
request.headers.has("transfer-encoding")
|
||||
)
|
||||
return tooLarge()
|
||||
const data = new Uint8Array(await request.arrayBuffer())
|
||||
if (!data.length || data.length > maxBytes) return tooLarge()
|
||||
return { userId: id, mime, data }
|
||||
}
|
||||
|
||||
/** Answers with a stored image. Its URL has to change when the image does. */
|
||||
export const serveImage = (row?: { mime: string; data: Uint8Array }) =>
|
||||
row
|
||||
? new Response(new Uint8Array(row.data), {
|
||||
headers: {
|
||||
"Content-Type": row.mime,
|
||||
"X-Content-Type-Options": "nosniff",
|
||||
// an SVG that is opened in its own tab must not run scripts on this origin
|
||||
"Content-Security-Policy":
|
||||
"default-src 'none'; style-src 'unsafe-inline'; sandbox",
|
||||
"Cache-Control": "private, max-age=31536000, immutable",
|
||||
},
|
||||
})
|
||||
: new Response("Not found", { status: 404 })
|
||||
+39
-3
@@ -12,6 +12,7 @@ import { Route as rootRouteImport } from './routes/__root'
|
||||
import { Route as IndexRouteImport } from './routes/index'
|
||||
import { Route as LoginRouteImport } from './routes/login'
|
||||
import { Route as SettingsRouteImport } from './routes/settings'
|
||||
import { Route as ApiIconRouteImport } from './routes/api/icon'
|
||||
import { Route as ApiWallpaperRouteImport } from './routes/api/wallpaper'
|
||||
import { Route as ApiAuthSplatRouteImport } from './routes/api/auth/$'
|
||||
|
||||
@@ -30,6 +31,11 @@ const SettingsRoute = SettingsRouteImport.update({
|
||||
path: '/settings',
|
||||
getParentRoute: () => rootRouteImport,
|
||||
} as any)
|
||||
const ApiIconRoute = ApiIconRouteImport.update({
|
||||
id: '/api/icon',
|
||||
path: '/api/icon',
|
||||
getParentRoute: () => rootRouteImport,
|
||||
} as any)
|
||||
const ApiWallpaperRoute = ApiWallpaperRouteImport.update({
|
||||
id: '/api/wallpaper',
|
||||
path: '/api/wallpaper',
|
||||
@@ -45,6 +51,7 @@ export interface FileRoutesByFullPath {
|
||||
'/': typeof IndexRoute
|
||||
'/login': typeof LoginRoute
|
||||
'/settings': typeof SettingsRoute
|
||||
'/api/icon': typeof ApiIconRoute
|
||||
'/api/wallpaper': typeof ApiWallpaperRoute
|
||||
'/api/auth/$': typeof ApiAuthSplatRoute
|
||||
}
|
||||
@@ -52,6 +59,7 @@ export interface FileRoutesByTo {
|
||||
'/': typeof IndexRoute
|
||||
'/login': typeof LoginRoute
|
||||
'/settings': typeof SettingsRoute
|
||||
'/api/icon': typeof ApiIconRoute
|
||||
'/api/wallpaper': typeof ApiWallpaperRoute
|
||||
'/api/auth/$': typeof ApiAuthSplatRoute
|
||||
}
|
||||
@@ -60,22 +68,42 @@ export interface FileRoutesById {
|
||||
'/': typeof IndexRoute
|
||||
'/login': typeof LoginRoute
|
||||
'/settings': typeof SettingsRoute
|
||||
'/api/icon': typeof ApiIconRoute
|
||||
'/api/wallpaper': typeof ApiWallpaperRoute
|
||||
'/api/auth/$': typeof ApiAuthSplatRoute
|
||||
}
|
||||
export interface FileRouteTypes {
|
||||
fileRoutesByFullPath: FileRoutesByFullPath
|
||||
fullPaths: '/' | '/login' | '/settings' | '/api/wallpaper' | '/api/auth/$'
|
||||
fullPaths:
|
||||
| '/'
|
||||
| '/login'
|
||||
| '/settings'
|
||||
| '/api/icon'
|
||||
| '/api/wallpaper'
|
||||
| '/api/auth/$'
|
||||
fileRoutesByTo: FileRoutesByTo
|
||||
to: '/' | '/login' | '/settings' | '/api/wallpaper' | '/api/auth/$'
|
||||
to:
|
||||
| '/'
|
||||
| '/login'
|
||||
| '/settings'
|
||||
| '/api/icon'
|
||||
| '/api/wallpaper'
|
||||
| '/api/auth/$'
|
||||
id:
|
||||
'__root__' | '/' | '/login' | '/settings' | '/api/wallpaper' | '/api/auth/$'
|
||||
| '__root__'
|
||||
| '/'
|
||||
| '/login'
|
||||
| '/settings'
|
||||
| '/api/icon'
|
||||
| '/api/wallpaper'
|
||||
| '/api/auth/$'
|
||||
fileRoutesById: FileRoutesById
|
||||
}
|
||||
export interface RootRouteChildren {
|
||||
IndexRoute: typeof IndexRoute
|
||||
LoginRoute: typeof LoginRoute
|
||||
SettingsRoute: typeof SettingsRoute
|
||||
ApiIconRoute: typeof ApiIconRoute
|
||||
ApiWallpaperRoute: typeof ApiWallpaperRoute
|
||||
ApiAuthSplatRoute: typeof ApiAuthSplatRoute
|
||||
}
|
||||
@@ -103,6 +131,13 @@ declare module '@tanstack/react-router' {
|
||||
preLoaderRoute: typeof SettingsRouteImport
|
||||
parentRoute: typeof rootRouteImport
|
||||
}
|
||||
'/api/icon': {
|
||||
id: '/api/icon'
|
||||
path: '/api/icon'
|
||||
fullPath: '/api/icon'
|
||||
preLoaderRoute: typeof ApiIconRouteImport
|
||||
parentRoute: typeof rootRouteImport
|
||||
}
|
||||
'/api/wallpaper': {
|
||||
id: '/api/wallpaper'
|
||||
path: '/api/wallpaper'
|
||||
@@ -124,6 +159,7 @@ const rootRouteChildren: RootRouteChildren = {
|
||||
IndexRoute: IndexRoute,
|
||||
LoginRoute: LoginRoute,
|
||||
SettingsRoute: SettingsRoute,
|
||||
ApiIconRoute: ApiIconRoute,
|
||||
ApiWallpaperRoute: ApiWallpaperRoute,
|
||||
ApiAuthSplatRoute: ApiAuthSplatRoute,
|
||||
}
|
||||
|
||||
@@ -0,0 +1,63 @@
|
||||
import { createFileRoute } from "@tanstack/react-router"
|
||||
import { and, eq, sql } from "drizzle-orm"
|
||||
import { z } from "zod"
|
||||
import { db } from "@/db"
|
||||
import { icon, link } from "@/db/schema"
|
||||
import { UPLOADED_ICON } from "@/lib/icons"
|
||||
import { readImage, serveImage, userId } from "@/lib/upload"
|
||||
|
||||
const LIMITS = {
|
||||
// SVG is safe here: serveImage sandboxes it
|
||||
types: [
|
||||
"image/png",
|
||||
"image/jpeg",
|
||||
"image/webp",
|
||||
"image/avif",
|
||||
"image/svg+xml",
|
||||
],
|
||||
formats: "PNG, JPEG, WebP, AVIF or SVG",
|
||||
maxMb: 1,
|
||||
}
|
||||
|
||||
export const Route = createFileRoute("/api/icon")({
|
||||
server: {
|
||||
handlers: {
|
||||
GET: async ({ request }) => {
|
||||
const user = await userId(request)
|
||||
if (!user) return new Response("Unauthorized", { status: 401 })
|
||||
const id = z
|
||||
.uuid()
|
||||
.safeParse(new URL(request.url).searchParams.get("id"))
|
||||
if (!id.success) return new Response("Not found", { status: 404 })
|
||||
return serveImage(
|
||||
(
|
||||
await db
|
||||
.select()
|
||||
.from(icon)
|
||||
.where(and(eq(icon.id, id.data), eq(icon.userId, user)))
|
||||
).at(0)
|
||||
)
|
||||
},
|
||||
POST: async ({ request }) => {
|
||||
const image = await readImage(request, LIMITS)
|
||||
if (image instanceof Response) return image
|
||||
// Icons that no link uses any more go away with the next upload. An hour of
|
||||
// grace, because a new icon has no link until its dialog is saved.
|
||||
// shortcut: no limit on uploads per user, add one if strangers can sign up
|
||||
await db.execute(sql`
|
||||
delete from ${icon}
|
||||
where ${icon.userId} = ${image.userId}
|
||||
and ${icon.createdAt} < now() - interval '1 hour'
|
||||
and not exists (
|
||||
select 1 from ${link}
|
||||
where ${link.icon} = ${UPLOADED_ICON} || ${icon.id}::text
|
||||
)`)
|
||||
const [row] = await db
|
||||
.insert(icon)
|
||||
.values(image)
|
||||
.returning({ id: icon.id })
|
||||
return Response.json({ icon: UPLOADED_ICON + row.id })
|
||||
},
|
||||
},
|
||||
},
|
||||
})
|
||||
+43
-55
@@ -1,76 +1,64 @@
|
||||
import { createFileRoute } from "@tanstack/react-router"
|
||||
import { eq } from "drizzle-orm"
|
||||
import { and, eq } from "drizzle-orm"
|
||||
import { z } from "zod"
|
||||
import { db } from "@/db"
|
||||
import { settings, wallpaper } from "@/db/schema"
|
||||
import { auth } from "@/lib/auth"
|
||||
import { dashboard, wallpaper } from "@/db/schema"
|
||||
import { readImage, serveImage, userId } from "@/lib/upload"
|
||||
|
||||
const MAX_BYTES = 10 * 1024 * 1024
|
||||
// no SVG: it can carry scripts
|
||||
const TYPES = ["image/jpeg", "image/png", "image/webp", "image/avif"]
|
||||
|
||||
async function userId(request: Request) {
|
||||
const session = await auth.api.getSession({ headers: request.headers })
|
||||
return session?.user.id
|
||||
const LIMITS = {
|
||||
// no SVG: a wallpaper is a photo
|
||||
types: ["image/jpeg", "image/png", "image/webp", "image/avif"],
|
||||
formats: "JPEG, PNG, WebP or AVIF",
|
||||
maxMb: 10,
|
||||
}
|
||||
|
||||
/** ?d=<dashboard id>: every dashboard has its own wallpaper. */
|
||||
const dashboardOf = (request: Request) =>
|
||||
z.uuid().safeParse(new URL(request.url).searchParams.get("d")).data
|
||||
|
||||
export const Route = createFileRoute("/api/wallpaper")({
|
||||
server: {
|
||||
handlers: {
|
||||
// the URL carries ?v=<upload time>, so it never changes
|
||||
GET: async ({ request }) => {
|
||||
const id = await userId(request)
|
||||
if (!id) return new Response("Unauthorized", { status: 401 })
|
||||
const row = (
|
||||
await db.select().from(wallpaper).where(eq(wallpaper.userId, id))
|
||||
).at(0)
|
||||
if (!row) return new Response("Not found", { status: 404 })
|
||||
return new Response(new Uint8Array(row.data), {
|
||||
headers: {
|
||||
"Content-Type": row.mime,
|
||||
"X-Content-Type-Options": "nosniff",
|
||||
// the URL carries ?v=<upload time>, so it never changes
|
||||
"Cache-Control": "private, max-age=31536000, immutable",
|
||||
},
|
||||
})
|
||||
const d = dashboardOf(request)
|
||||
if (!d) return new Response("Not found", { status: 404 })
|
||||
return serveImage(
|
||||
(
|
||||
await db
|
||||
.select()
|
||||
.from(wallpaper)
|
||||
.where(
|
||||
and(eq(wallpaper.dashboardId, d), eq(wallpaper.userId, id))
|
||||
)
|
||||
).at(0)
|
||||
)
|
||||
},
|
||||
POST: async ({ request }) => {
|
||||
const id = await userId(request)
|
||||
if (!id) return new Response("Unauthorized", { status: 401 })
|
||||
const mime = request.headers.get("content-type") ?? ""
|
||||
if (!TYPES.includes(mime))
|
||||
return new Response("Use a JPEG, PNG, WebP or AVIF image", {
|
||||
status: 415,
|
||||
})
|
||||
// a chunked body has no declared size and could fill the memory
|
||||
const declared = Number(request.headers.get("content-length"))
|
||||
if (
|
||||
!(declared > 0 && declared <= MAX_BYTES) ||
|
||||
request.headers.has("transfer-encoding")
|
||||
)
|
||||
return new Response("Image is empty or larger than 10 MB", {
|
||||
status: 413,
|
||||
})
|
||||
const data = new Uint8Array(await request.arrayBuffer())
|
||||
if (!data.length || data.length > MAX_BYTES)
|
||||
return new Response("Image is empty or larger than 10 MB", {
|
||||
status: 413,
|
||||
})
|
||||
const wallpaperUrl = `/api/wallpaper?v=${Date.now()}`
|
||||
await db.transaction(async (tx) => {
|
||||
const image = await readImage(request, LIMITS)
|
||||
if (image instanceof Response) return image
|
||||
const d = dashboardOf(request)
|
||||
if (!d) return new Response("Not found", { status: 404 })
|
||||
const wallpaperUrl = `/api/wallpaper?d=${d}&v=${Date.now()}`
|
||||
const saved = await db.transaction(async (tx) => {
|
||||
const mine = await tx
|
||||
.update(dashboard)
|
||||
.set({ wallpaperUrl })
|
||||
.where(and(eq(dashboard.id, d), eq(dashboard.userId, image.userId)))
|
||||
.returning({ id: dashboard.id })
|
||||
if (!mine.length) return false
|
||||
await tx
|
||||
.insert(wallpaper)
|
||||
.values({ userId: id, mime, data })
|
||||
.values({ ...image, dashboardId: d })
|
||||
.onConflictDoUpdate({
|
||||
target: wallpaper.userId,
|
||||
set: { mime, data },
|
||||
})
|
||||
await tx
|
||||
.insert(settings)
|
||||
.values({ userId: id, wallpaperUrl })
|
||||
.onConflictDoUpdate({
|
||||
target: settings.userId,
|
||||
set: { wallpaperUrl },
|
||||
target: wallpaper.dashboardId,
|
||||
set: { mime: image.mime, data: image.data },
|
||||
})
|
||||
return true
|
||||
})
|
||||
if (!saved) return new Response("Not found", { status: 404 })
|
||||
return Response.json({ wallpaperUrl })
|
||||
},
|
||||
},
|
||||
|
||||
+113
-19
@@ -1,28 +1,40 @@
|
||||
import { useState } from "react"
|
||||
import { useEffect, useState } from "react"
|
||||
import {
|
||||
Link,
|
||||
createFileRoute,
|
||||
redirect,
|
||||
useRouter,
|
||||
} from "@tanstack/react-router"
|
||||
import { LayoutGrid, LogOut, Pencil, Plus, Settings2 } from "lucide-react"
|
||||
import {
|
||||
LayoutDashboard,
|
||||
LayoutGrid,
|
||||
LogOut,
|
||||
Pencil,
|
||||
Plus,
|
||||
Settings2,
|
||||
} from "lucide-react"
|
||||
import { CardDialog } from "@/components/card-dialog"
|
||||
import type { CardTarget } from "@/components/card-dialog"
|
||||
import { CardGrid } from "@/components/card-grid"
|
||||
import { Clock } from "@/components/clock"
|
||||
import { LinkDialog } from "@/components/link-dialog"
|
||||
import type { LinkTarget } from "@/components/link-dialog"
|
||||
import { StatusContext } from "@/components/link-tile"
|
||||
import { Logo } from "@/components/logo"
|
||||
import { SearchBar } from "@/components/search-bar"
|
||||
import { Wallpaper } from "@/components/wallpaper"
|
||||
import { authClient } from "@/lib/auth-client"
|
||||
import { getDashboard } from "@/lib/dashboard.functions"
|
||||
import { getDashboard, getStatuses } from "@/lib/dashboard.functions"
|
||||
import { Button } from "@/vendor/collabry/components/Button/Button"
|
||||
import { cn } from "@/vendor/collabry/lib/cn"
|
||||
|
||||
export const Route = createFileRoute("/")({
|
||||
loader: async () => {
|
||||
const data = await getDashboard()
|
||||
// ?d=<dashboard id>. Without it the default dashboard opens.
|
||||
validateSearch: (search): { d?: string } =>
|
||||
typeof search.d === "string" ? { d: search.d } : {},
|
||||
loaderDeps: ({ search }) => search,
|
||||
loader: async ({ deps }) => {
|
||||
const data = await getDashboard({ data: { dashboardId: deps.d } })
|
||||
if (!data) throw redirect({ to: "/login" })
|
||||
return data
|
||||
},
|
||||
@@ -33,37 +45,90 @@ export const Route = createFileRoute("/")({
|
||||
const onWallpaper =
|
||||
"rounded-full text-white/80 hover:bg-white/10 hover:text-white"
|
||||
|
||||
/**
|
||||
* Which links answer, asked again every minute and when the tab is opened again.
|
||||
* `links` is their ids: a new link is checked at once.
|
||||
*/
|
||||
function useStatuses(on: boolean, dashboardId: string, links: string) {
|
||||
const [statuses, setStatuses] = useState<Record<string, boolean>>({})
|
||||
useEffect(() => {
|
||||
if (!on) return
|
||||
let stale = false
|
||||
const load = () => {
|
||||
if (document.hidden) return
|
||||
getStatuses({ data: { dashboardId } })
|
||||
.then((found) => !stale && setStatuses(found))
|
||||
.catch(() => {}) // the dots stay as they were
|
||||
}
|
||||
load()
|
||||
const timer = setInterval(load, 60_000)
|
||||
document.addEventListener("visibilitychange", load)
|
||||
return () => {
|
||||
stale = true
|
||||
clearInterval(timer)
|
||||
document.removeEventListener("visibilitychange", load)
|
||||
}
|
||||
}, [on, dashboardId, links])
|
||||
return statuses
|
||||
}
|
||||
|
||||
function Dashboard() {
|
||||
const data = Route.useLoaderData()
|
||||
const router = useRouter()
|
||||
const statuses = useStatuses(
|
||||
data.statusChecks,
|
||||
data.dashboardId,
|
||||
data.cards.flatMap((c) => c.links.map((l) => l.id)).join()
|
||||
)
|
||||
const [link, setLink] = useState<LinkTarget | null>(null)
|
||||
const [card, setCard] = useState<CardTarget | null>(null)
|
||||
|
||||
// settings open for this dashboard: its wallpaper, and back to it
|
||||
const here = { d: data.dashboardId }
|
||||
// the server makes sure there is always a card
|
||||
const addLink = () => setLink({ cardId: data.cards[0].id })
|
||||
|
||||
return (
|
||||
<div className="relative isolate text-white">
|
||||
<Wallpaper src={data.wallpaperUrl} />
|
||||
<Wallpaper src={data.wallpaperUrl} dim={data.wallpaperDim} />
|
||||
|
||||
<main className="flex min-h-svh flex-col items-center px-4">
|
||||
<header className="flex h-20 w-full max-w-[1200px] items-center gap-4 px-2 sm:px-8">
|
||||
<Logo className="size-6" />
|
||||
<h1 className="m-0 text-md font-semibold">{data.title}</h1>
|
||||
<span className="hidden font-mono text-sm text-white/50 sm:inline">
|
||||
{data.dashboards.length > 1 && (
|
||||
<nav
|
||||
aria-label="Dashboards"
|
||||
className="flex min-w-0 gap-1 overflow-x-auto p-1"
|
||||
>
|
||||
{data.dashboards.map((d) => (
|
||||
<Link
|
||||
key={d.id}
|
||||
to="/"
|
||||
search={{ d: d.id }}
|
||||
aria-current={d.id === data.dashboardId ? "page" : undefined}
|
||||
className="rounded-full px-3 py-1 text-sm whitespace-nowrap text-white/60 outline-none hover:bg-white/10 hover:text-white focus-visible:ring-2 focus-visible:ring-white/60 aria-[current=page]:bg-white/15 aria-[current=page]:text-white"
|
||||
>
|
||||
{d.name}
|
||||
</Link>
|
||||
))}
|
||||
</nav>
|
||||
)}
|
||||
{/* at the right, so it does not read as one more dashboard */}
|
||||
<span className="ml-auto hidden font-mono text-sm text-white/50 sm:inline">
|
||||
{data.user.name}
|
||||
</span>
|
||||
<Button
|
||||
variant="ghost"
|
||||
iconOnly
|
||||
aria-label="Add link"
|
||||
className={cn(onWallpaper, "ml-auto")}
|
||||
className={cn(onWallpaper, "ml-auto sm:ml-0")}
|
||||
onClick={addLink}
|
||||
>
|
||||
<Plus className="size-5" />
|
||||
</Button>
|
||||
<Button asChild variant="ghost" iconOnly className={onWallpaper}>
|
||||
<Link to="/settings" aria-label="Settings">
|
||||
<Link to="/settings" search={here} aria-label="Settings">
|
||||
<Settings2 className="size-5" />
|
||||
</Link>
|
||||
</Button>
|
||||
@@ -94,10 +159,27 @@ function Dashboard() {
|
||||
icon: <LayoutGrid className="size-4" />,
|
||||
run: () => setCard("new"),
|
||||
},
|
||||
...data.dashboards
|
||||
.filter((d) => d.id !== data.dashboardId)
|
||||
.map((d) => ({
|
||||
label: `Switch to ${d.name}`,
|
||||
icon: <LayoutDashboard className="size-4" />,
|
||||
run: () => router.navigate({ to: "/", search: { d: d.id } }),
|
||||
})),
|
||||
{
|
||||
label: "Add dashboard",
|
||||
icon: <LayoutDashboard className="size-4" />,
|
||||
run: () =>
|
||||
router.navigate({
|
||||
to: "/settings",
|
||||
search: here,
|
||||
hash: "dashboards",
|
||||
}),
|
||||
},
|
||||
{
|
||||
label: "Settings",
|
||||
icon: <Settings2 className="size-4" />,
|
||||
run: () => router.navigate({ to: "/settings" }),
|
||||
run: () => router.navigate({ to: "/settings", search: here }),
|
||||
},
|
||||
{
|
||||
label: "Sign out",
|
||||
@@ -112,13 +194,15 @@ function Dashboard() {
|
||||
</div>
|
||||
|
||||
<div className="mt-[7vh] flex w-full flex-col items-center">
|
||||
<CardGrid
|
||||
cards={data.cards}
|
||||
onAddCard={() => setCard("new")}
|
||||
onAddLink={(c) => setLink({ cardId: c.id })}
|
||||
onEditLink={setLink}
|
||||
onEditCard={setCard}
|
||||
/>
|
||||
<StatusContext value={statuses}>
|
||||
<CardGrid
|
||||
cards={data.cards}
|
||||
onAddCard={() => setCard("new")}
|
||||
onAddLink={(c) => setLink({ cardId: c.id })}
|
||||
onEditLink={setLink}
|
||||
onEditCard={setCard}
|
||||
/>
|
||||
</StatusContext>
|
||||
</div>
|
||||
|
||||
<div className="flex-[3]" />
|
||||
@@ -137,7 +221,12 @@ function Dashboard() {
|
||||
</span>
|
||||
)}
|
||||
<Button asChild variant="ghost" iconOnly className={onWallpaper}>
|
||||
<Link to="/settings" hash="wallpaper" aria-label="Change wallpaper">
|
||||
<Link
|
||||
to="/settings"
|
||||
search={here}
|
||||
hash="wallpaper"
|
||||
aria-label="Change wallpaper"
|
||||
>
|
||||
<Pencil className="size-4" />
|
||||
</Link>
|
||||
</Button>
|
||||
@@ -149,7 +238,12 @@ function Dashboard() {
|
||||
cards={data.cards}
|
||||
onClose={() => setLink(null)}
|
||||
/>
|
||||
<CardDialog card={card} onClose={() => setCard(null)} />
|
||||
<CardDialog
|
||||
card={card}
|
||||
dashboardId={data.dashboardId}
|
||||
dashboards={data.dashboards}
|
||||
onClose={() => setCard(null)}
|
||||
/>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
|
||||
+449
-31
@@ -1,4 +1,5 @@
|
||||
import { useRef, useState } from "react"
|
||||
import type { ComponentProps } from "react"
|
||||
import {
|
||||
Link,
|
||||
createFileRoute,
|
||||
@@ -7,14 +8,21 @@ import {
|
||||
useRouter,
|
||||
} from "@tanstack/react-router"
|
||||
import {
|
||||
ArrowDown,
|
||||
ArrowDownUp,
|
||||
ArrowLeft,
|
||||
ArrowUp,
|
||||
Check,
|
||||
CircleUser,
|
||||
Clock,
|
||||
Download,
|
||||
Image,
|
||||
LayoutDashboard,
|
||||
LogOut,
|
||||
Plus,
|
||||
Search,
|
||||
SlidersHorizontal,
|
||||
Trash2,
|
||||
Upload,
|
||||
} from "lucide-react"
|
||||
import { Logo } from "@/components/logo"
|
||||
@@ -27,9 +35,20 @@ import {
|
||||
CLOCK_STYLE_NAMES,
|
||||
} from "@/lib/clock"
|
||||
import type { ClockFont, ClockStyle } from "@/lib/clock"
|
||||
import { getDashboard, saveSettings } from "@/lib/dashboard.functions"
|
||||
import {
|
||||
deleteDashboard,
|
||||
exportData,
|
||||
getDashboard,
|
||||
importData,
|
||||
orderDashboards,
|
||||
saveDashboard,
|
||||
saveSettings,
|
||||
saveWallpaper,
|
||||
} from "@/lib/dashboard.functions"
|
||||
import { ENGINES, ENGINE_NAMES } from "@/lib/search"
|
||||
import type { Engine } from "@/lib/search"
|
||||
import { parseBookmarks } from "@/lib/transfer"
|
||||
import type { Backup } from "@/lib/transfer"
|
||||
import { Button } from "@/vendor/collabry/components/Button/Button"
|
||||
import {
|
||||
Field,
|
||||
@@ -65,33 +84,72 @@ import { Spinner } from "@/vendor/collabry/components/Spinner/Spinner"
|
||||
import { cn } from "@/vendor/collabry/lib/cn"
|
||||
|
||||
export const Route = createFileRoute("/settings")({
|
||||
loader: async () => {
|
||||
const data = await getDashboard()
|
||||
// ?d=<dashboard id>: the dashboard you came from, and whose wallpaper is shown
|
||||
validateSearch: (search): { d?: string } =>
|
||||
typeof search.d === "string" ? { d: search.d } : {},
|
||||
loaderDeps: ({ search }) => search,
|
||||
loader: async ({ deps }) => {
|
||||
const data = await getDashboard({ data: { dashboardId: deps.d } })
|
||||
if (!data) throw redirect({ to: "/login" })
|
||||
return data
|
||||
},
|
||||
head: () => ({ meta: [{ title: "Settings" }] }),
|
||||
component: Settings,
|
||||
// a new key per dashboard: the page starts again with that dashboard's wallpaper
|
||||
component: () => <Settings key={Route.useLoaderData().dashboardId} />,
|
||||
})
|
||||
|
||||
const SECTIONS = [
|
||||
{ id: "general", label: "General", icon: SlidersHorizontal },
|
||||
{ id: "dashboards", label: "Dashboards", icon: LayoutDashboard },
|
||||
{ id: "clock", label: "Clock", icon: Clock },
|
||||
{ id: "search", label: "Search", icon: Search },
|
||||
{ id: "wallpaper", label: "Wallpaper", icon: Image },
|
||||
{ id: "transfer", label: "Export and import", icon: ArrowDownUp },
|
||||
{ id: "account", label: "Account", icon: CircleUser },
|
||||
]
|
||||
|
||||
// the nav links jump to a section; keep its title clear of the window edge
|
||||
const section = "[&>section]:scroll-mt-24"
|
||||
|
||||
/** A name that is saved when the field is left. An empty one goes back to what it was. */
|
||||
function NameInput({
|
||||
value,
|
||||
onSave,
|
||||
...props
|
||||
}: { value: string; onSave: (name: string) => void } & ComponentProps<
|
||||
typeof Input
|
||||
>) {
|
||||
return (
|
||||
<Input
|
||||
className="w-64"
|
||||
defaultValue={value}
|
||||
maxLength={40}
|
||||
onKeyDown={(e) => e.key === "Enter" && e.currentTarget.blur()}
|
||||
onBlur={(e) => {
|
||||
const name = e.target.value.trim()
|
||||
if (name && name !== value) onSave(name)
|
||||
else e.target.value = value
|
||||
}}
|
||||
{...props}
|
||||
/>
|
||||
)
|
||||
}
|
||||
|
||||
function Settings() {
|
||||
const data = Route.useLoaderData()
|
||||
const router = useRouter()
|
||||
const hash = useLocation({ select: (l) => l.hash }) || SECTIONS[0].id
|
||||
const file = useRef<HTMLInputElement>(null)
|
||||
const importFile = useRef<HTMLInputElement>(null)
|
||||
// what the last import added
|
||||
const [imported, setImported] = useState("")
|
||||
const [status, setStatus] = useState<"idle" | "saving" | "saved">("idle")
|
||||
const [error, setError] = useState("")
|
||||
// follows the slider at once, the save comes a moment later
|
||||
const [dim, setDim] = useState(data.wallpaperDim)
|
||||
const dimSave = useRef<ReturnType<typeof setTimeout>>(undefined)
|
||||
// deleting a dashboard deletes its cards and links, so it takes a second click
|
||||
const [confirming, setConfirming] = useState<string | null>(null)
|
||||
|
||||
// Every control saves on its own. `action` returns a message when it failed.
|
||||
const run = async (action: () => Promise<string | void>) => {
|
||||
@@ -104,14 +162,22 @@ function Settings() {
|
||||
}
|
||||
const save = (patch: {
|
||||
title?: string
|
||||
defaultDashboardId?: string
|
||||
searchEngine?: Engine
|
||||
wallpaperUrl?: string | null
|
||||
clockFont?: ClockFont
|
||||
clockStyle?: ClockStyle
|
||||
}) => run(() => saveSettings({ data: patch }))
|
||||
// the wallpaper belongs to the dashboard that is chosen in its section
|
||||
const saveWall = (patch: {
|
||||
wallpaperUrl?: string | null
|
||||
wallpaperDim?: number
|
||||
}) =>
|
||||
run(() =>
|
||||
saveWallpaper({ data: { dashboardId: data.dashboardId, ...patch } })
|
||||
)
|
||||
const upload = (image: File) =>
|
||||
run(async () => {
|
||||
const res = await fetch("/api/wallpaper", {
|
||||
const res = await fetch(`/api/wallpaper?d=${data.dashboardId}`, {
|
||||
method: "POST",
|
||||
headers: { "Content-Type": image.type },
|
||||
body: image,
|
||||
@@ -121,6 +187,54 @@ function Settings() {
|
||||
|
||||
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 backup = await exportData()
|
||||
const url = URL.createObjectURL(
|
||||
new Blob([JSON.stringify(backup, null, 2)], { type: "application/json" })
|
||||
)
|
||||
const a = document.createElement("a")
|
||||
a.href = url
|
||||
a.download = `dahoam-${new Date().toISOString().slice(0, 10)}.json`
|
||||
a.click()
|
||||
URL.revokeObjectURL(url)
|
||||
}
|
||||
// an export of this app (JSON) or the bookmarks file of a browser (HTML)
|
||||
const importFrom = (chosen: File) =>
|
||||
run(async () => {
|
||||
setImported("")
|
||||
if (chosen.size > 5 * 1024 * 1024) return "The file is larger than 5 MB."
|
||||
const content = await chosen.text()
|
||||
let backup: unknown
|
||||
let skipped = 0
|
||||
try {
|
||||
backup = JSON.parse(content)
|
||||
} catch {
|
||||
const bookmarks = parseBookmarks(content)
|
||||
if (!bookmarks) return "This file has no dashboards or bookmarks in it."
|
||||
;({ backup, skipped } = bookmarks)
|
||||
}
|
||||
// whether it really is one, the server checks
|
||||
const added = await importData({ data: backup as Backup }).catch(
|
||||
() => null
|
||||
)
|
||||
if (!added) return "This file is not an export of Dahoam."
|
||||
const count = (n: number, thing: string) =>
|
||||
`${n} ${thing}${n === 1 ? "" : "s"}`
|
||||
setImported(
|
||||
`Added ${count(added.dashboards, "dashboard")} with ${count(added.cards, "card")} and ${count(added.links, "link")}.` +
|
||||
(skipped
|
||||
? ` ${count(skipped, "bookmark")} left out: not a web address, or more than a card holds.`
|
||||
: "")
|
||||
)
|
||||
})
|
||||
|
||||
return (
|
||||
// A page of its own: solid Collabry surfaces, no wallpaper behind it
|
||||
<div className="min-h-svh bg-app">
|
||||
@@ -129,7 +243,7 @@ function Settings() {
|
||||
<Logo className="size-5 text-fg" />
|
||||
<span className="min-w-0 truncate font-bold">{data.title}</span>
|
||||
<Button asChild size="sm" className="ml-auto">
|
||||
<Link to="/">
|
||||
<Link to="/" search={{ d: data.dashboardId }}>
|
||||
<ArrowLeft size={14} aria-hidden /> Back to dashboard
|
||||
</Link>
|
||||
</Button>
|
||||
@@ -180,6 +294,7 @@ function Settings() {
|
||||
<Link
|
||||
to="/settings"
|
||||
hash={id}
|
||||
search
|
||||
// without this every link counts as the current page
|
||||
activeOptions={{ includeHash: true }}
|
||||
>
|
||||
@@ -195,37 +310,132 @@ function Settings() {
|
||||
<SettingsSectionHeader>
|
||||
<SettingsSectionTitle>General</SettingsSectionTitle>
|
||||
<SettingsSectionDescription>
|
||||
How this dashboard is called.
|
||||
How this start page is called.
|
||||
</SettingsSectionDescription>
|
||||
</SettingsSectionHeader>
|
||||
<SettingsRow>
|
||||
<SettingsRowText>
|
||||
<SettingsRowLabel htmlFor="settings-title">
|
||||
Dashboard name
|
||||
Title
|
||||
</SettingsRowLabel>
|
||||
<SettingsRowDescription>
|
||||
Shown at the top left of the dashboard.
|
||||
Shown at the top left of every dashboard.
|
||||
</SettingsRowDescription>
|
||||
</SettingsRowText>
|
||||
<SettingsRowControl>
|
||||
<Input
|
||||
<NameInput
|
||||
id="settings-title"
|
||||
className="w-64"
|
||||
defaultValue={data.title}
|
||||
maxLength={40}
|
||||
onKeyDown={(e) =>
|
||||
e.key === "Enter" && e.currentTarget.blur()
|
||||
}
|
||||
onBlur={(e) => {
|
||||
const title = e.target.value.trim()
|
||||
if (title && title !== data.title) void save({ title })
|
||||
else e.target.value = data.title
|
||||
}}
|
||||
value={data.title}
|
||||
onSave={(title) => save({ title })}
|
||||
/>
|
||||
</SettingsRowControl>
|
||||
</SettingsRow>
|
||||
</SettingsSection>
|
||||
|
||||
<SettingsSection id="dashboards" className={section}>
|
||||
<SettingsSectionHeader>
|
||||
<SettingsSectionTitle>Dashboards</SettingsSectionTitle>
|
||||
<SettingsSectionDescription>
|
||||
Each dashboard has its own cards, for example Home and Work.
|
||||
With more than one, you switch between them at the top of
|
||||
the dashboard, in the order that the arrows here set. The
|
||||
default one opens when you sign in.
|
||||
</SettingsSectionDescription>
|
||||
</SettingsSectionHeader>
|
||||
{data.dashboards.map((d, i) => {
|
||||
const isDefault = d.id === data.defaultDashboardId
|
||||
return (
|
||||
<SettingsRow key={d.id}>
|
||||
<SettingsRowText>
|
||||
<NameInput
|
||||
aria-label="Dashboard name"
|
||||
value={d.name}
|
||||
onSave={(name) =>
|
||||
run(() =>
|
||||
saveDashboard({ data: { id: d.id, name } })
|
||||
)
|
||||
}
|
||||
/>
|
||||
</SettingsRowText>
|
||||
<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
|
||||
disabled={isDefault}
|
||||
onClick={() => save({ defaultDashboardId: d.id })}
|
||||
>
|
||||
{isDefault && <Check size={15} />}
|
||||
{isDefault ? "Default" : "Make default"}
|
||||
</Button>
|
||||
<Button
|
||||
variant={
|
||||
confirming === d.id ? "danger" : "danger-outline"
|
||||
}
|
||||
disabled={data.dashboards.length < 2}
|
||||
onClick={() =>
|
||||
confirming === d.id
|
||||
? run(() =>
|
||||
deleteDashboard({ data: { id: d.id } })
|
||||
)
|
||||
: setConfirming(d.id)
|
||||
}
|
||||
>
|
||||
<Trash2 size={15} />
|
||||
{confirming === d.id
|
||||
? "Yes, delete it with its cards and links"
|
||||
: "Delete"}
|
||||
</Button>
|
||||
</SettingsRowControl>
|
||||
</SettingsRow>
|
||||
)
|
||||
})}
|
||||
<SettingsRow>
|
||||
<form
|
||||
className="flex flex-wrap gap-2"
|
||||
onSubmit={(e) => {
|
||||
e.preventDefault()
|
||||
const form = e.currentTarget
|
||||
const name = String(new FormData(form).get("name"))
|
||||
void run(() => saveDashboard({ data: { name } })).then(
|
||||
() => form.reset()
|
||||
)
|
||||
}}
|
||||
>
|
||||
<Input
|
||||
name="name"
|
||||
aria-label="Name of the new dashboard"
|
||||
className="w-64"
|
||||
placeholder="New dashboard"
|
||||
maxLength={40}
|
||||
required
|
||||
/>
|
||||
<Button type="submit">
|
||||
<Plus size={15} /> Add dashboard
|
||||
</Button>
|
||||
</form>
|
||||
</SettingsRow>
|
||||
</SettingsSection>
|
||||
|
||||
<SettingsSection id="clock" className={section}>
|
||||
<SettingsSectionHeader>
|
||||
<SettingsSectionTitle>Clock</SettingsSectionTitle>
|
||||
@@ -333,17 +543,62 @@ function Settings() {
|
||||
<SettingsSectionHeader>
|
||||
<SettingsSectionTitle>Wallpaper</SettingsSectionTitle>
|
||||
<SettingsSectionDescription>
|
||||
The picture behind your dashboard. Upload one (JPEG, PNG,
|
||||
WebP or AVIF, up to 10 MB) or use any image on the web.
|
||||
The picture behind a dashboard, every dashboard has its own.
|
||||
Upload one (JPEG, PNG, WebP or AVIF, up to 10 MB) or use any
|
||||
image on the web.
|
||||
</SettingsSectionDescription>
|
||||
</SettingsSectionHeader>
|
||||
{data.dashboards.length > 1 && (
|
||||
<SettingsRow>
|
||||
<SettingsRowText>
|
||||
<div
|
||||
id="settings-wallpaper-of"
|
||||
className="leading-tight font-bold"
|
||||
>
|
||||
Dashboard
|
||||
</div>
|
||||
<SettingsRowDescription>
|
||||
Whose wallpaper you change here.
|
||||
</SettingsRowDescription>
|
||||
</SettingsRowText>
|
||||
<SettingsRowControl>
|
||||
<SegmentedControl
|
||||
aria-labelledby="settings-wallpaper-of"
|
||||
size="md"
|
||||
// many dashboards on a narrow screen: scroll, not overflow
|
||||
className="max-w-full overflow-x-auto"
|
||||
value={data.dashboardId}
|
||||
onValueChange={(d) =>
|
||||
router.navigate({
|
||||
to: "/settings",
|
||||
search: { d },
|
||||
hash: "wallpaper",
|
||||
})
|
||||
}
|
||||
>
|
||||
{data.dashboards.map((d) => (
|
||||
<SegmentedControlItem key={d.id} value={d.id}>
|
||||
{d.name}
|
||||
</SegmentedControlItem>
|
||||
))}
|
||||
</SegmentedControl>
|
||||
</SettingsRowControl>
|
||||
</SettingsRow>
|
||||
)}
|
||||
<SettingsRow stacked>
|
||||
<div className="flex flex-wrap items-start gap-x-6 gap-y-4">
|
||||
<img
|
||||
src={data.wallpaperUrl ?? DEFAULT_WALLPAPER}
|
||||
alt="Current wallpaper"
|
||||
className="aspect-video w-60 flex-none rounded-xl border border-line object-cover"
|
||||
/>
|
||||
<div className="relative w-60 flex-none overflow-hidden rounded-xl border border-line">
|
||||
<img
|
||||
src={data.wallpaperUrl ?? DEFAULT_WALLPAPER}
|
||||
alt="Current wallpaper"
|
||||
className="aspect-video w-full object-cover"
|
||||
/>
|
||||
{/* as dark as on the dashboard */}
|
||||
<div
|
||||
className="absolute inset-0 bg-black"
|
||||
style={{ opacity: dim / 100 }}
|
||||
/>
|
||||
</div>
|
||||
<div className="flex min-w-0 flex-[1_1_260px] flex-col gap-3.5">
|
||||
<Field>
|
||||
<FieldLabel>Image address</FieldLabel>
|
||||
@@ -363,7 +618,7 @@ function Settings() {
|
||||
const url = e.target.value.trim()
|
||||
if (!url || url === data.wallpaperUrl) return
|
||||
if (e.target.checkValidity())
|
||||
void save({ wallpaperUrl: url })
|
||||
void saveWall({ wallpaperUrl: url })
|
||||
else
|
||||
setError(
|
||||
"The image address must start with http:// or https://"
|
||||
@@ -399,7 +654,7 @@ function Settings() {
|
||||
<Button
|
||||
variant="ghost"
|
||||
disabled={status === "saving" || !data.wallpaperUrl}
|
||||
onClick={() => save({ wallpaperUrl: null })}
|
||||
onClick={() => saveWall({ wallpaperUrl: null })}
|
||||
>
|
||||
Use default
|
||||
</Button>
|
||||
@@ -407,6 +662,110 @@ function Settings() {
|
||||
</div>
|
||||
</div>
|
||||
</SettingsRow>
|
||||
<SettingsRow>
|
||||
<SettingsRowText>
|
||||
<SettingsRowLabel htmlFor="settings-dim">
|
||||
Darken
|
||||
</SettingsRowLabel>
|
||||
<SettingsRowDescription>
|
||||
How much the wallpaper is darkened, so that the text on it
|
||||
stays readable.
|
||||
</SettingsRowDescription>
|
||||
</SettingsRowText>
|
||||
<SettingsRowControl className="flex items-center gap-3">
|
||||
<input
|
||||
id="settings-dim"
|
||||
type="range"
|
||||
min={0}
|
||||
max={100}
|
||||
step={5}
|
||||
value={dim}
|
||||
onChange={(e) => {
|
||||
const wallpaperDim = Number(e.target.value)
|
||||
setDim(wallpaperDim)
|
||||
// one save when the slider rests, not one per step
|
||||
clearTimeout(dimSave.current)
|
||||
dimSave.current = setTimeout(
|
||||
() => saveWall({ wallpaperDim }),
|
||||
400
|
||||
)
|
||||
}}
|
||||
className="w-48 accent-accent scheme-dark"
|
||||
/>
|
||||
<output
|
||||
htmlFor="settings-dim"
|
||||
className="w-10 text-right text-sm text-fg-subtle tabular-nums"
|
||||
>
|
||||
{dim}%
|
||||
</output>
|
||||
</SettingsRowControl>
|
||||
</SettingsRow>
|
||||
</SettingsSection>
|
||||
|
||||
<SettingsSection id="transfer" className={section}>
|
||||
<SettingsSectionHeader>
|
||||
<SettingsSectionTitle>Export and import</SettingsSectionTitle>
|
||||
<SettingsSectionDescription>
|
||||
Keep a copy of your dashboards, move them to another
|
||||
account, or start from the bookmarks of your browser.
|
||||
</SettingsSectionDescription>
|
||||
</SettingsSectionHeader>
|
||||
<SettingsRow>
|
||||
<SettingsRowText>
|
||||
<div className="leading-tight font-bold">Export</div>
|
||||
<SettingsRowDescription>
|
||||
One file with all dashboards, their cards and links.
|
||||
Images that you uploaded are not in it.
|
||||
</SettingsRowDescription>
|
||||
</SettingsRowText>
|
||||
<SettingsRowControl>
|
||||
<Button
|
||||
onClick={() =>
|
||||
download().catch(() => setError("Could not export."))
|
||||
}
|
||||
>
|
||||
<Download size={15} /> Export
|
||||
</Button>
|
||||
</SettingsRowControl>
|
||||
</SettingsRow>
|
||||
<SettingsRow>
|
||||
<SettingsRowText>
|
||||
<div className="leading-tight font-bold">Import</div>
|
||||
<SettingsRowDescription>
|
||||
An export of Dahoam, or the bookmarks file that your
|
||||
browser exports (HTML): a dashboard "Bookmarks" with a
|
||||
card per folder. An import adds dashboards, it replaces
|
||||
nothing.
|
||||
</SettingsRowDescription>
|
||||
{imported && (
|
||||
<SettingsRowDescription
|
||||
role="status"
|
||||
className="text-success-fg"
|
||||
>
|
||||
{imported}
|
||||
</SettingsRowDescription>
|
||||
)}
|
||||
</SettingsRowText>
|
||||
<SettingsRowControl>
|
||||
<input
|
||||
ref={importFile}
|
||||
type="file"
|
||||
accept=".json,.html,.htm,application/json,text/html"
|
||||
className="hidden"
|
||||
onChange={(e) => {
|
||||
const chosen = e.target.files?.[0]
|
||||
if (chosen) void importFrom(chosen)
|
||||
e.target.value = ""
|
||||
}}
|
||||
/>
|
||||
<Button
|
||||
disabled={status === "saving"}
|
||||
onClick={() => importFile.current?.click()}
|
||||
>
|
||||
<Upload size={15} /> Choose a file
|
||||
</Button>
|
||||
</SettingsRowControl>
|
||||
</SettingsRow>
|
||||
</SettingsSection>
|
||||
|
||||
<SettingsSection id="account" className={section}>
|
||||
@@ -433,6 +792,65 @@ function Settings() {
|
||||
</Button>
|
||||
</SettingsRowControl>
|
||||
</SettingsRow>
|
||||
{data.user.hasPassword && (
|
||||
<SettingsRow stacked>
|
||||
<SettingsRowText>
|
||||
<div className="leading-tight font-bold">Password</div>
|
||||
<SettingsRowDescription>
|
||||
A new password signs you out on your other devices.
|
||||
</SettingsRowDescription>
|
||||
</SettingsRowText>
|
||||
<SettingsRowControl>
|
||||
<form
|
||||
className="flex flex-wrap items-end gap-3"
|
||||
onSubmit={(e) => {
|
||||
e.preventDefault()
|
||||
const form = e.currentTarget
|
||||
const fields = new FormData(form)
|
||||
void run(async () => {
|
||||
// Better Auth returns { error } instead of throwing
|
||||
const { error: failure } =
|
||||
await authClient.changePassword({
|
||||
currentPassword: String(fields.get("current")),
|
||||
newPassword: String(fields.get("new")),
|
||||
revokeOtherSessions: true,
|
||||
})
|
||||
if (failure)
|
||||
return (
|
||||
failure.message ||
|
||||
"Could not change the password."
|
||||
)
|
||||
form.reset()
|
||||
})
|
||||
}}
|
||||
>
|
||||
<Field className="w-56">
|
||||
<FieldLabel>Current password</FieldLabel>
|
||||
<Input
|
||||
name="current"
|
||||
type="password"
|
||||
autoComplete="current-password"
|
||||
required
|
||||
/>
|
||||
</Field>
|
||||
<Field className="w-56">
|
||||
<FieldLabel>New password</FieldLabel>
|
||||
<Input
|
||||
name="new"
|
||||
type="password"
|
||||
autoComplete="new-password"
|
||||
minLength={8}
|
||||
maxLength={128}
|
||||
required
|
||||
/>
|
||||
</Field>
|
||||
<Button type="submit" disabled={status === "saving"}>
|
||||
Change password
|
||||
</Button>
|
||||
</form>
|
||||
</SettingsRowControl>
|
||||
</SettingsRow>
|
||||
)}
|
||||
</SettingsSection>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -25,19 +25,3 @@
|
||||
background: black;
|
||||
}
|
||||
}
|
||||
|
||||
/* Halftone dots plus a fade to black, as on the reference start page */
|
||||
@utility wallpaper-dither {
|
||||
background-image:
|
||||
linear-gradient(
|
||||
to bottom,
|
||||
rgb(0 0 0 / 0.45),
|
||||
rgb(0 0 0 / 0.25) 30%,
|
||||
rgb(0 0 0 / 0.4) 65%,
|
||||
rgb(0 0 0 / 0.95) 100%
|
||||
),
|
||||
radial-gradient(rgb(0 0 0 / 0.45) 1px, transparent 1.5px);
|
||||
background-size:
|
||||
auto,
|
||||
4px 4px;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user