Add administrator role plus manage dashboard and cleanup database migrations

This commit is contained in:
thiloho
2024-10-08 21:20:44 +02:00
parent c4f1bff2a9
commit 1b74e1e6fb
23 changed files with 625 additions and 87 deletions

View File

@@ -46,12 +46,16 @@
const fileUrl = `${apiPrefix}/rpc/retrieve_file?id=${fileId}`;
const target = event.target as HTMLTextAreaElement;
const newContent =
target.value.slice(0, target.selectionStart) +
`![](${fileUrl})` +
target.value.slice(target.selectionStart);
const markdownToInsert = `![](${fileUrl})`;
const cursorPosition = target.selectionStart;
const newContent = target.value.slice(0, target.selectionStart) + markdownToInsert;
target.value.slice(target.selectionStart);
previewContent.value = newContent;
const newCursorPosition = cursorPosition + markdownToInsert.length;
target.setSelectionRange(newCursorPosition, newCursorPosition);
target.focus();
} else {
return;
}

View File

@@ -51,8 +51,7 @@
background-color: var(--bg-primary);
border-radius: var(--border-radius);
border: var(--border-primary);
inline-size: var(--modal-width);
max-inline-size: 100%;
inline-size: min(var(--modal-width), 100%);
max-block-size: calc(100vh - var(--space-m));
overflow-y: auto;
z-index: 20;

View File

@@ -438,19 +438,21 @@ export interface User {
id: string;
username: string;
password_hash: string;
role: string;
user_role: string;
max_number_websites: number;
created_at: Date;
}
export interface UserInput {
id?: string;
username: string;
password_hash: string;
role?: string;
user_role?: string;
max_number_websites?: number;
created_at?: Date;
}
const user = {
tableName: "user",
columns: ["id", "username", "password_hash", "role", "created_at"],
columns: ["id", "username", "password_hash", "user_role", "max_number_websites", "created_at"],
requiredForInsert: ["username", "password_hash"],
primaryKey: "id",
foreignKeys: {},
@@ -464,6 +466,7 @@ export interface Website {
user_id: string;
content_type: string;
title: string;
max_storage_size: number;
is_published: boolean;
created_at: Date;
last_modified_at: Date;
@@ -474,6 +477,7 @@ export interface WebsiteInput {
user_id?: string;
content_type: string;
title: string;
max_storage_size?: number;
is_published?: boolean;
created_at?: Date;
last_modified_at?: Date;
@@ -486,6 +490,7 @@ const website = {
"user_id",
"content_type",
"title",
"max_storage_size",
"is_published",
"created_at",
"last_modified_at",

View File

@@ -151,8 +151,8 @@ export const md = (markdownContent: string, showToc = true) => {
try {
html = DOMPurify.sanitize(marked.parse(markdownContent, { async: false }));
} catch (_) {
html = "Failed to parse markdown";
} catch (error) {
html = JSON.stringify(error);
}
return html;