feat: several dashboards with a default, icon search and icon upload
Dashboards are separate sets of cards (Home, Work). Settings manages them and sets the one that opens at sign-in, the header and the search bar switch. Migration 0006 puts the existing cards on a dashboard "Home". The link dialog searches dashboard-icons and uploads custom icons (/api/icon, up to 1 MB, SVG served sandboxed). Wallpaper and icons share the upload checks.
This commit is contained in:
+46
-5
@@ -77,9 +77,9 @@ export const verification = pgTable(
|
||||
|
||||
const bytea = customType<{ data: Uint8Array }>({ dataType: () => "bytea" })
|
||||
|
||||
/** A named group of links on the dashboard. */
|
||||
export const card = pgTable(
|
||||
"card",
|
||||
/** A set of cards, for example Home and Work. */
|
||||
export const dashboard = pgTable(
|
||||
"dashboard",
|
||||
{
|
||||
id: uuid("id").primaryKey().defaultRandom(),
|
||||
userId: text("user_id")
|
||||
@@ -88,7 +88,27 @@ export const card = pgTable(
|
||||
name: text("name").notNull(),
|
||||
createdAt: timestamp("created_at").notNull().defaultNow(),
|
||||
},
|
||||
(t) => [index("card_user_id_idx").on(t.userId)]
|
||||
(t) => [index("dashboard_user_id_idx").on(t.userId)]
|
||||
)
|
||||
|
||||
/** A named group of links on a dashboard. */
|
||||
export const card = pgTable(
|
||||
"card",
|
||||
{
|
||||
id: uuid("id").primaryKey().defaultRandom(),
|
||||
userId: text("user_id")
|
||||
.notNull()
|
||||
.references(() => user.id, { onDelete: "cascade" }),
|
||||
dashboardId: uuid("dashboard_id")
|
||||
.notNull()
|
||||
.references(() => dashboard.id, { onDelete: "cascade" }),
|
||||
name: text("name").notNull(),
|
||||
createdAt: timestamp("created_at").notNull().defaultNow(),
|
||||
},
|
||||
(t) => [
|
||||
index("card_user_id_idx").on(t.userId),
|
||||
index("card_dashboard_id_idx").on(t.dashboardId),
|
||||
]
|
||||
)
|
||||
|
||||
export const link = pgTable(
|
||||
@@ -105,7 +125,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,6 +141,11 @@ 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 oldest one
|
||||
defaultDashboardId: uuid("default_dashboard_id").references(
|
||||
() => dashboard.id,
|
||||
{ onDelete: "set null" }
|
||||
),
|
||||
searchEngine: text("search_engine", {
|
||||
enum: ["duckduckgo", "searxng", "google"],
|
||||
})
|
||||
@@ -140,6 +166,21 @@ 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)]
|
||||
)
|
||||
|
||||
export const wallpaper = pgTable("wallpaper", {
|
||||
userId: text("user_id")
|
||||
.primaryKey()
|
||||
|
||||
Reference in New Issue
Block a user