changed stuff
This commit is contained in:
		
							parent
							
								
									de212c367f
								
							
						
					
					
						commit
						2dca4a5a80
					
				| @ -1,9 +1,9 @@ | |||||||
| 'use server' | 'use server' | ||||||
| 
 | 
 | ||||||
| import { APIError, attemptAPIAction } from "@/util/api/error"; | import { APIError, attemptAPIAction } from "@/util/api/error"; | ||||||
| import { sequelize, Bucket, Auth, Post, PostTag, Tag, User, dbSync } from "@/model/Models"; | import { sequelize, Bucket, Auth, Post, PostTag, Tag, User, dbSync } from "@/models"; | ||||||
| import { cookies } from "next/headers"; | import { cookies } from "next/headers"; | ||||||
| import { Attachment } from "@/model/Attachment"; | import { Attachment } from "@/models"; | ||||||
| import { UUID, randomUUID } from "crypto"; | import { UUID, randomUUID } from "crypto"; | ||||||
| import { mkdir, mkdirSync, writeFile } from "fs"; | import { mkdir, mkdirSync, writeFile } from "fs"; | ||||||
| import { where } from "@sequelize/core"; | import { where } from "@sequelize/core"; | ||||||
|  | |||||||
| @ -4,7 +4,7 @@ import { cookies } from "next/headers"; | |||||||
| 
 | 
 | ||||||
| import { APIError} from "@/util/api/error" | import { APIError} from "@/util/api/error" | ||||||
| import { UserAuth, parseBasicAuth, getAssociatedUser } from "@/util/api/user" | import { UserAuth, parseBasicAuth, getAssociatedUser } from "@/util/api/user" | ||||||
| import { Auth, User } from "@/model/Models"; | import { Auth, User } from "@/models"; | ||||||
| 
 | 
 | ||||||
| 
 | 
 | ||||||
| async function tryAuth(request:Request){ | async function tryAuth(request:Request){ | ||||||
|  | |||||||
| @ -4,7 +4,7 @@ import { Model } from "@sequelize/core"; | |||||||
| import { cookies } from "next/headers"; | import { cookies } from "next/headers"; | ||||||
| 
 | 
 | ||||||
| 
 | 
 | ||||||
| import { Auth } from "@/model/Models"; | import { Auth } from "@/models"; | ||||||
| 
 | 
 | ||||||
| 
 | 
 | ||||||
| import { APIError} from "@/util/api/error" | import { APIError} from "@/util/api/error" | ||||||
|  | |||||||
| @ -1,7 +1,7 @@ | |||||||
| 'use server' | 'use server' | ||||||
| 
 | 
 | ||||||
| import { APIError } from "@/util/api/error"; | import { APIError } from "@/util/api/error"; | ||||||
| import { Post } from "@/model/Models"; | import { Post } from "@/models"; | ||||||
| 
 | 
 | ||||||
| 
 | 
 | ||||||
| export async function tryFetchPost(request:Request, { params }: {params:{slug: string}}){ | export async function tryFetchPost(request:Request, { params }: {params:{slug: string}}){ | ||||||
|  | |||||||
| @ -1,7 +1,7 @@ | |||||||
| 'use server' | 'use server' | ||||||
| 
 | 
 | ||||||
| import { APIError, attemptAPIAction } from "@/util/api/error"; | import { APIError, attemptAPIAction } from "@/util/api/error"; | ||||||
| import { Auth, Post, PostTag, Tag, User, dbSync } from "@/model/Models"; | import { Auth, Post, PostTag, Tag, User, dbSync } from "@/models"; | ||||||
| import { cookies } from "next/headers"; | import { cookies } from "next/headers"; | ||||||
| 
 | 
 | ||||||
| 
 | 
 | ||||||
|  | |||||||
| @ -4,7 +4,7 @@ import { cookies } from "next/headers"; | |||||||
| 
 | 
 | ||||||
| import { APIError} from "@/util/api/error" | import { APIError} from "@/util/api/error" | ||||||
| import { UserAuth, parseBasicAuth, getAssociatedUser } from "@/util/api/user" | import { UserAuth, parseBasicAuth, getAssociatedUser } from "@/util/api/user" | ||||||
| import { Attachment, Auth, Bucket, DBState, Post, PostTag, Project, Tag, User, UserPerms,dbSync,sequelize} from "@/model/Models"; | import { Attachment, Auth, Bucket, DBState, Post, PostTag, Project, Tag, User, UserPerms,dbSync,sequelize} from "@/models"; | ||||||
| import Sequelize, { DataTypes } from "@sequelize/core"; | import Sequelize, { DataTypes } from "@sequelize/core"; | ||||||
| import { SqliteColumnsDescription, SqliteDialect, SqliteQueryInterface } from "@sequelize/sqlite3"; | import { SqliteColumnsDescription, SqliteDialect, SqliteQueryInterface } from "@sequelize/sqlite3"; | ||||||
| import { hashPassword } from "@/util/Auth"; | import { hashPassword } from "@/util/Auth"; | ||||||
|  | |||||||
| @ -10,9 +10,8 @@ | |||||||
| 
 | 
 | ||||||
| import { APIError } from "@/util/api/error"; | import { APIError } from "@/util/api/error"; | ||||||
| import { UserAuth } from "@/util/api/user"; | import { UserAuth } from "@/util/api/user"; | ||||||
| import { Attachment, Auth, Bucket, DBState, Post, PostTag, Project, Tag, User, UserPerms,dbSync,sequelize} from "@/model/Models"; | import { Attachment, Auth, Bucket, DBState, Post, PostTag, Project, Tag, User, UserPerms, addUserScopes, dbSync,sequelize} from "@/models"; | ||||||
| import { hashPassword } from "@/util/Auth"; | import { hashPassword } from "@/util/Auth"; | ||||||
| import { addUserScopes } from "@/model/User"; |  | ||||||
| 
 | 
 | ||||||
| 
 | 
 | ||||||
| // Attempt to register a new User
 | // Attempt to register a new User
 | ||||||
|  | |||||||
| @ -10,7 +10,7 @@ import ReactDOM from "react"; | |||||||
| import "/public/global.css" | import "/public/global.css" | ||||||
| import "@/app/index.css" | import "@/app/index.css" | ||||||
| 
 | 
 | ||||||
| import { Post } from "@/model/Post"; | import { Post } from "@/models"; | ||||||
| import { Attributes } from "@sequelize/core"; | import { Attributes } from "@sequelize/core"; | ||||||
| import { DeepPartial } from "@/util/DeepPartial"; | import { DeepPartial } from "@/util/DeepPartial"; | ||||||
| 
 | 
 | ||||||
|  | |||||||
| @ -1,4 +1,5 @@ | |||||||
| import type { GetStaticProps } from 'next' | import type { GetStaticProps } from 'next' | ||||||
|  | // @ts-ignore
 | ||||||
| import { MDXRemote } from 'next-mdx-remote/rsc' | import { MDXRemote } from 'next-mdx-remote/rsc' | ||||||
| import ExampleComponent from './example.mdx' | import ExampleComponent from './example.mdx' | ||||||
| 
 | 
 | ||||||
|  | |||||||
| @ -6,9 +6,8 @@ import { parseSetCookie } from "@/util/parseSetCookie"; | |||||||
| import makeFetchCookie    from 'fetch-cookie'; | import makeFetchCookie    from 'fetch-cookie'; | ||||||
| import fetchCookie        from "fetch-cookie"; | import fetchCookie        from "fetch-cookie"; | ||||||
| import { Attribute, Attributes }     from "@sequelize/core"; | import { Attribute, Attributes }     from "@sequelize/core"; | ||||||
| import { User }           from "@/model/User"; | import { User, Auth }           from "@/models"; | ||||||
| import { AuthProps } from "@/providers/providers"; | import { AuthProps } from "@/providers/providers"; | ||||||
| import { Auth } from "@/model/Auth"; |  | ||||||
| import { ActionResult } from "./ActionResult"; | import { ActionResult } from "./ActionResult"; | ||||||
| 
 | 
 | ||||||
| type LoginReturn = { | type LoginReturn = { | ||||||
|  | |||||||
| @ -1,11 +1,11 @@ | |||||||
| 'use server'; | 'use server'; | ||||||
| 
 | 
 | ||||||
| import { revalidatePath, revalidateTag } from 'next/cache' | import { revalidatePath, revalidateTag } from 'next/cache' | ||||||
| import { Bucket, Post, PostBucket, Project, User, dbSync } from "@/model/Models"; | import { Bucket, Post, PostBucket, Project, User, dbSync } from "@/models"; | ||||||
| import { Attributes, where } from "@sequelize/core"; | import { Attributes, where } from "@sequelize/core"; | ||||||
| import { getCookieAuth, userIsAdmin } from '../actions'; | import { getCookieAuth, userIsAdmin } from '../actions'; | ||||||
| import { ActionResult } from '../ActionResult'; | import { ActionResult } from '../ActionResult'; | ||||||
| import { PostAttributesWithBuckets } from '@/model/Post'; | import { PostAttributesWithBuckets } from '@/models'; | ||||||
| 
 | 
 | ||||||
| export async function deletePost(postID: number): Promise<ActionResult<boolean>> { | export async function deletePost(postID: number): Promise<ActionResult<boolean>> { | ||||||
|   await dbSync; |   await dbSync; | ||||||
|  | |||||||
| @ -1,5 +1,5 @@ | |||||||
| 'use server'; | 'use server'; | ||||||
| import { Project } from "@/model/Project"; | import { Project } from "@/models"; | ||||||
| import { ActionResult } from "../ActionResult"; | import { ActionResult } from "../ActionResult"; | ||||||
| import { Attributes } from "@sequelize/core"; | import { Attributes } from "@sequelize/core"; | ||||||
| import { userIsAdmin } from "../actions"; | import { userIsAdmin } from "../actions"; | ||||||
|  | |||||||
| @ -33,9 +33,7 @@ export default function Page(props: Props) { | |||||||
|                     <ul><li>filter 1</li><li>filter 2</li><li>filter 3</li></ul> |                     <ul><li>filter 1</li><li>filter 2</li><li>filter 3</li></ul> | ||||||
|                 </Sidebar> |                 </Sidebar> | ||||||
|                 <main> |                 <main> | ||||||
|                     <ArticlePreview /> |                      | ||||||
|                     <ArticlePreview /> |  | ||||||
|                     <ArticlePreview /> |  | ||||||
|                 </main> |                 </main> | ||||||
|             </PageContainer> |             </PageContainer> | ||||||
|         </div>); |         </div>); | ||||||
|  | |||||||
| @ -1,8 +1,8 @@ | |||||||
| import { ActionResult } from "@/app/lib/actions/ActionResult"; | import { ActionResult } from "@/app/lib/actions/ActionResult"; | ||||||
| import { handleActionResult } from "@/app/lib/actions/clientActionHandler"; | import { handleActionResult } from "@/app/lib/actions/clientActionHandler"; | ||||||
| import { GetPostsAttributes } from "@/app/lib/actions/entityManagement/postActions"; | import { GetPostsAttributes } from "@/app/lib/actions/entityManagement/postActions"; | ||||||
| import { Post, Project, Bucket, PostBucket, Attachment } from "@/model/Models"; | import { Post, Project, Bucket, PostBucket, Attachment } from "@/models" | ||||||
| import { PostAttributesWithBuckets } from "@/model/Post"; | import { PostAttributesWithBuckets } from "@/models"; | ||||||
| import { DeepPartial } from "@/util/DeepPartial"; | import { DeepPartial } from "@/util/DeepPartial"; | ||||||
| import { Attributes } from "@sequelize/core"; | import { Attributes } from "@sequelize/core"; | ||||||
| import { UUID } from "crypto"; | import { UUID } from "crypto"; | ||||||
| @ -17,9 +17,9 @@ export type PostTableCallbacks = { | |||||||
| 
 | 
 | ||||||
| export type EditorProps = { | export type EditorProps = { | ||||||
|     editorOpenState:boolean; |     editorOpenState:boolean; | ||||||
|     openedPost:GetPostsAttributes; |     openedPost?:GetPostsAttributes; | ||||||
|     projects?:Attributes<Project>[]; |     projects?:Attributes<Project>[]; | ||||||
|     callbacks:PostTableCallbacks; |     callbacks?:PostTableCallbacks; | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| 
 | 
 | ||||||
| @ -40,14 +40,14 @@ export default function PostEditor(props:EditorProps){ | |||||||
|     const onTextAreaChange:ChangeEventHandler<HTMLTextAreaElement> = (e) => {setContent(e.target.value);adjustHeight()}; |     const onTextAreaChange:ChangeEventHandler<HTMLTextAreaElement> = (e) => {setContent(e.target.value);adjustHeight()}; | ||||||
|     const projectSelectionChange:ChangeEventHandler<HTMLSelectElement> = (e)=>setProjectID(parseInt(e.target.value)); |     const projectSelectionChange:ChangeEventHandler<HTMLSelectElement> = (e)=>setProjectID(parseInt(e.target.value)); | ||||||
|     const onClickSaveButton:MouseEventHandler<HTMLButtonElement> = (e)=>{ |     const onClickSaveButton:MouseEventHandler<HTMLButtonElement> = (e)=>{ | ||||||
|         props.callbacks.savePost({ |         props.callbacks?.savePost({ | ||||||
|             id: props.openedPost.id as number, |             id: props.openedPost?.id as number, | ||||||
|             content:content as string, |             content:content as string, | ||||||
|             title:title as string, |             title:title as string, | ||||||
|             project_id: projectID |             project_id: projectID | ||||||
|         }); |         }); | ||||||
|     } |     } | ||||||
|     const onClickCancelButton:MouseEventHandler<HTMLButtonElement> = (e)=>{props.callbacks.closeEditor();} |     const onClickCancelButton:MouseEventHandler<HTMLButtonElement> = (e)=>{props.callbacks?.closeEditor();} | ||||||
| 
 | 
 | ||||||
|     return <> |     return <> | ||||||
|     <form className="bg-light w-[100%] h-content p-1"> |     <form className="bg-light w-[100%] h-content p-1"> | ||||||
| @ -81,7 +81,7 @@ export default function PostEditor(props:EditorProps){ | |||||||
|             </thead> |             </thead> | ||||||
|             <tbody> |             <tbody> | ||||||
|                 { |                 { | ||||||
|                     props.openedPost.buckets  |                     props.openedPost?.buckets  | ||||||
|                     ? (()=>{ |                     ? (()=>{ | ||||||
|                         let bucketMap:Map<UUID,Attributes<Bucket>> = new Map(props.openedPost.buckets.map((b)=>[b.id as UUID,b])); |                         let bucketMap:Map<UUID,Attributes<Bucket>> = new Map(props.openedPost.buckets.map((b)=>[b.id as UUID,b])); | ||||||
|                         let bucketList = [...props.openedPost.buckets.map((b)=>b.id)]; |                         let bucketList = [...props.openedPost.buckets.map((b)=>b.id)]; | ||||||
| @ -125,3 +125,29 @@ export default function PostEditor(props:EditorProps){ | |||||||
|     </form> |     </form> | ||||||
|     </> |     </> | ||||||
| } | } | ||||||
|  | type EditorRendererProps = { | ||||||
|  |     postData: GetPostsAttributes, | ||||||
|  |     headings: string[], | ||||||
|  |     editorState: EditorProps, | ||||||
|  |     editorControls: any, | ||||||
|  |     callbacks: any, | ||||||
|  |     projects: any | ||||||
|  | } | ||||||
|  | export function EditorRenderer(props:EditorRendererProps){ | ||||||
|  |     const {postData, headings, editorState, editorControls, callbacks, projects} = props | ||||||
|  | 
 | ||||||
|  |     return (props.editorState.editorOpenState | ||||||
|  |         && editorState.openedPost | ||||||
|  |         && editorState.openedPost.id == postData.id) | ||||||
|  | 
 | ||||||
|  |         ? <tr> | ||||||
|  |             <th scope="row" colSpan={headings.length}> | ||||||
|  |                 <PostEditor callbacks={callbacks} | ||||||
|  |                     editorOpenState={editorState.editorOpenState} | ||||||
|  |                     openedPost={editorState.openedPost} | ||||||
|  |                     projects={projects} /> | ||||||
|  |             </th> | ||||||
|  |         </tr> | ||||||
|  | 
 | ||||||
|  |         : "" | ||||||
|  | } | ||||||
| @ -11,17 +11,17 @@ import React, { | |||||||
| } from "react"; | } from "react"; | ||||||
| import EntityManagementTable from "../EntityManagementTable"; | import EntityManagementTable from "../EntityManagementTable"; | ||||||
| import toast from "react-hot-toast"; | import toast from "react-hot-toast"; | ||||||
| import PostEditor, { EditorProps } from "./PostEditor"; | import PostEditor, { EditorProps, EditorRenderer } from "./PostEditor"; | ||||||
| import { | import { | ||||||
|     Attributes, |     Attributes, | ||||||
|     CreationAttributes |     CreationAttributes | ||||||
| } from "@sequelize/core"; | } from "@sequelize/core"; | ||||||
| import { useState } from "react"; | import { useState } from "react"; | ||||||
| import { Project, Post, Bucket } from "@/model/Models"; | import { Project, Post, Bucket } from "@/models"; | ||||||
| import { ActionResult } from "@/app/lib/actions/ActionResult"; | import { ActionResult } from "@/app/lib/actions/ActionResult"; | ||||||
| import { handleActionResult } from "@/app/lib/actions/clientActionHandler"; | import { handleActionResult } from "@/app/lib/actions/clientActionHandler"; | ||||||
| import { getPostsWithBucketsAndProject, GetPostsAttributes } from "@/app/lib/actions/entityManagement/postActions"; | import { getPostsWithBucketsAndProject, GetPostsAttributes } from "@/app/lib/actions/entityManagement/postActions"; | ||||||
| import { PostAttributesWithBuckets } from "@/model/Post"; | import { PostAttributesWithBuckets } from "@/models"; | ||||||
| 
 | 
 | ||||||
| export type PostTableActions = { | export type PostTableActions = { | ||||||
|     deletePost: (id: number) => Promise<ActionResult<boolean>> |     deletePost: (id: number) => Promise<ActionResult<boolean>> | ||||||
| @ -43,30 +43,35 @@ const aifa = (a: ReactNode, b: ReactNode) => a ? a : b | |||||||
| 
 | 
 | ||||||
| export default function PostTable(props: Props) { | export default function PostTable(props: Props) { | ||||||
| 
 | 
 | ||||||
| 
 |     const initEditorState: EditorProps = { | ||||||
| 
 |         ...{ | ||||||
|     const initEditorState: Partial<EditorProps> = { |  | ||||||
|             editorOpenState: false |             editorOpenState: false | ||||||
|  |         }, ...{ | ||||||
|  |             callbacks: undefined, | ||||||
|  |             openedPost: undefined, | ||||||
|  |             projects: undefined, | ||||||
|         } |         } | ||||||
|  |     }; | ||||||
| 
 | 
 | ||||||
|     // Set up required state hooks
 |     // Set up required state hooks
 | ||||||
|     const [posts, setPosts] = useState(props.data); |     const [posts, setPosts] = useState(props.data); | ||||||
|     const [editor, setEditor] = useState(initEditorState) |     const [editorState, setEditorState] = useState(initEditorState) | ||||||
|     const [projects, setProjects] = useState(props.projects); |     const [projects, setProjects] = useState(props.projects); | ||||||
| 
 | 
 | ||||||
|     // Define editor controls
 |     // Define editor controls
 | ||||||
| 
 |     const editorControls = { | ||||||
|     function closeEditor(): void { |         closeEditor: () => { | ||||||
|         setEditor({ |             setEditorState({ | ||||||
|                 editorOpenState: false |                 editorOpenState: false | ||||||
|             }) |             }) | ||||||
|     } |         }, | ||||||
|     function showEditor(entry: GetPostsAttributes): void { |         showEditor: (entry: GetPostsAttributes) => { | ||||||
|         setEditor({ |             setEditorState({ | ||||||
|                 editorOpenState: true, |                 editorOpenState: true, | ||||||
|                 openedPost: entry |                 openedPost: entry | ||||||
|             }) |             }) | ||||||
|         } |         } | ||||||
|  |     } | ||||||
| 
 | 
 | ||||||
|     function deletePost(entry: GetPostsAttributes) { |     function deletePost(entry: GetPostsAttributes) { | ||||||
|         if (!entry.id) return; |         if (!entry.id) return; | ||||||
| @ -85,7 +90,8 @@ export default function PostTable(props: Props) { | |||||||
|             .then((p) => { |             .then((p) => { | ||||||
|                 const result = handleActionResult(p) |                 const result = handleActionResult(p) | ||||||
|                 if (result) setPosts(result) |                 if (result) setPosts(result) | ||||||
|             }).then(props.actions.getProjects) |             }) | ||||||
|  |             .then(props.actions.getProjects) | ||||||
|             .then(e => { |             .then(e => { | ||||||
|                 const result = handleActionResult(e); |                 const result = handleActionResult(e); | ||||||
|                 if (result) setProjects(result) |                 if (result) setProjects(result) | ||||||
| @ -105,68 +111,61 @@ export default function PostTable(props: Props) { | |||||||
|                 const result = handleActionResult(res); |                 const result = handleActionResult(res); | ||||||
|                 if (result) setPosts(result); |                 if (result) setPosts(result); | ||||||
|             }) |             }) | ||||||
|         closeEditor(); |         editorControls.closeEditor(); | ||||||
|     }; |     }; | ||||||
| 
 | 
 | ||||||
|     function TableFields({ postData }: { postData: GetPostsAttributes }) { |     function TableRow(props: { postData: GetPostsAttributes, headings: string[] }) { | ||||||
|         return [ |         return <> | ||||||
|             { |             <tr key={props.postData.id}> | ||||||
|                 key: 'post-title', |  | ||||||
|                 content: postData.title |  | ||||||
|             }, { |  | ||||||
|                 key: 'post-content', |  | ||||||
|                 content: |  | ||||||
|                     !postData.content ? "No Content Found" : |  | ||||||
|                         postData.content.length < 255 ? postData.content : |  | ||||||
|                             `${postData.content.substring(0, 255)}...` |  | ||||||
| 
 |  | ||||||
|             }, { |  | ||||||
|                 key: 'post-project', |  | ||||||
|                 content: aifa((projects.find((e) => { |  | ||||||
|                     console.log(e.id) |  | ||||||
|                     return (e.id == postData.project.id) |  | ||||||
|                 })?.readableIdentifier), 'uncategorized') |  | ||||||
|             }, { |  | ||||||
|                 key: 'post-createdat', |  | ||||||
|                 content: postData.createdAt?.toString() |  | ||||||
|             }, { |  | ||||||
|                 key: 'post-updatedat', |  | ||||||
|                 content: postData.updatedAt?.toString() |  | ||||||
|             }, { |  | ||||||
|                 key: 'post-editbutton', |  | ||||||
|                 content: <button key="editbutton" type="button" className="btn btn-primary" onClick={() => showEditor(postData)}>Edit</button> |  | ||||||
|             }, { |  | ||||||
|                 key: 'post-deletebutton', |  | ||||||
|                 content: <button key="deletebutton" type="button" className="btn btn-danger" onClick={() => deletePost(postData)}> Delete</button> |  | ||||||
|             } |  | ||||||
|         ].map(field => |  | ||||||
|             <td key={field.key}>{field.content}</td> |  | ||||||
|         ); |  | ||||||
|     } |  | ||||||
| 
 |  | ||||||
|     function TableRow(props: { postData: GetPostsAttributes, headings: string | any[] }) { |  | ||||||
|         return <><tr key={props.postData.id}> |  | ||||||
|                 <th key={`rowheading-post-${props.postData.id}`} scope="row">{props.postData.id}</th> |                 <th key={`rowheading-post-${props.postData.id}`} scope="row">{props.postData.id}</th> | ||||||
|             <TableFields key={`tableFields-${props.postData.id}`} postData={props.postData} /> |                 <td key='title'>{props.postData.title}</td> | ||||||
|  |                 <td key='content'> | ||||||
|  |                     { | ||||||
|  |                         !props.postData.content ? "No Content Found" : | ||||||
|  |                             props.postData.content.length < 255 ? props.postData.content : | ||||||
|  |                                 `${props.postData.content.substring(0, 255)}...` | ||||||
|  |                     } | ||||||
|  |                 </td> | ||||||
|  |                 <td key='project'> | ||||||
|  |                     { | ||||||
|  |                         aifa((projects.find((e) => { | ||||||
|  |                             console.log(e.id) | ||||||
|  |                             return (e.id == props.postData.project.id) | ||||||
|  |                         })?.readableIdentifier), 'uncategorized') | ||||||
|  |                     } | ||||||
|  |                 </td> | ||||||
|  |                 <td key='createdAt'> | ||||||
|  |                     { | ||||||
|  |                         props.postData.createdAt?.toString() | ||||||
|  |                     } | ||||||
|  |                 </td> | ||||||
|  |                 <td key='updatedAt'> | ||||||
|  |                     { | ||||||
|  |                         props.postData.updatedAt?.toString() | ||||||
|  |                     } | ||||||
|  |                 </td> | ||||||
|  |                 <td key='edit'> | ||||||
|  |                     { | ||||||
|  |                         <button key="editbutton" type="button" className="btn btn-primary" onClick={() => editorControls.showEditor(props.postData)}>Edit</button> | ||||||
|  |                     } | ||||||
|  |                 </td> | ||||||
|  |                 <td key='delete'> | ||||||
|  |                     { | ||||||
|  |                         <button key="deletebutton" type="button" className="btn btn-danger" onClick={() => deletePost(props.postData)}> Delete</button> | ||||||
|  |                     } | ||||||
|  |                 </td> | ||||||
|             </tr> |             </tr> | ||||||
|             {(editor.editorOpenState |             <EditorRenderer headings={props.headings} | ||||||
|                 && editor.openedPost |                 postData={props.postData} | ||||||
|                 && editor.openedPost.id == props.postData.id) |                 editorControls={editorControls} | ||||||
| 
 |                 editorState={editorState} | ||||||
|                 ? <tr> |                 callbacks={{ | ||||||
|                     <th scope="row" colSpan={props.headings.length}> |  | ||||||
|                         <PostEditor callbacks={{ |  | ||||||
|                     savePost: savePost, |                     savePost: savePost, | ||||||
|                             closeEditor: closeEditor, |                     closeEditor: editorControls.closeEditor, | ||||||
|                     uploadAttachment: () => { } |                     uploadAttachment: () => { } | ||||||
|                 }} |                 }} | ||||||
|                             editorOpenState={editor.editorOpenState} |                 projects={projects} | ||||||
|                             openedPost={editor.openedPost} |             /> | ||||||
|                             projects={projects} /> |  | ||||||
|                     </th> |  | ||||||
|                 </tr> |  | ||||||
| 
 |  | ||||||
|                 : ""} |  | ||||||
|         </> |         </> | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|  | |||||||
| @ -1,16 +0,0 @@ | |||||||
| import { AuthContext, AuthProps } from "@/providers/providers"; |  | ||||||
| import { ReactNode, useContext } from "react"; |  | ||||||
| 
 |  | ||||||
| interface Props { |  | ||||||
|     children?: ReactNode; |  | ||||||
|     auth?: AuthProps; |  | ||||||
| } |  | ||||||
| 
 |  | ||||||
| export default function SomeServerSubComponent(props:Props){ |  | ||||||
|     let { test, auth } = useContext(AuthContext); |  | ||||||
| 
 |  | ||||||
|      |  | ||||||
|     return ( |  | ||||||
|         <span>{test}{JSON.stringify(auth)}</span> |  | ||||||
|     ); |  | ||||||
| } |  | ||||||
| @ -7,7 +7,7 @@ import EntityManagementTable from "../../../client/EntityManagementTable"; | |||||||
| import PostTable, { PostTableActions } from "@/components/client/admin/PostTable"; | import PostTable, { PostTableActions } from "@/components/client/admin/PostTable"; | ||||||
| import { deletePost, getPostsWithBucketsAndProject, GetPostsAttributes, updatePost } from "@/app/lib/actions/entityManagement/postActions"; | import { deletePost, getPostsWithBucketsAndProject, GetPostsAttributes, updatePost } from "@/app/lib/actions/entityManagement/postActions"; | ||||||
| import { getProjects } from "@/app/lib/actions/entityManagement/projectActions"; | import { getProjects } from "@/app/lib/actions/entityManagement/projectActions"; | ||||||
| import { Bucket, Project, Post, dbSync, Attachment } from "@/model/Models"; | import { Bucket, Project, Post, dbSync, Attachment } from "@/models"; | ||||||
| import { tryCreateAttachment } from "@/app/api/attachment/route"; | import { tryCreateAttachment } from "@/app/api/attachment/route"; | ||||||
| import { handleActionResult } from '../../../../app/lib/actions/clientActionHandler'; | import { handleActionResult } from '../../../../app/lib/actions/clientActionHandler'; | ||||||
| 
 | 
 | ||||||
|  | |||||||
| @ -7,7 +7,7 @@ import EntityManagementTable from "../../../client/EntityManagementTable"; | |||||||
| import PostTable from "@/components/client/admin/PostTable"; | import PostTable from "@/components/client/admin/PostTable"; | ||||||
| import { deletePost, getPostsWithBucketsAndProject, updatePost } from "@/app/lib/actions/entityManagement/postActions"; | import { deletePost, getPostsWithBucketsAndProject, updatePost } from "@/app/lib/actions/entityManagement/postActions"; | ||||||
| import { getProjects } from "@/app/lib/actions/entityManagement/projectActions"; | import { getProjects } from "@/app/lib/actions/entityManagement/projectActions"; | ||||||
| import { Bucket, Project, Post, dbSync, Attachment } from "@/model/Models"; | import { Bucket, Project, Post, dbSync, Attachment } from "@/models"; | ||||||
| import { tryCreateAttachment } from "@/app/api/attachment/route"; | import { tryCreateAttachment } from "@/app/api/attachment/route"; | ||||||
| import { Attributes } from '@sequelize/core'; | import { Attributes } from '@sequelize/core'; | ||||||
| import * as util from 'util' | import * as util from 'util' | ||||||
|  | |||||||
| @ -9,15 +9,19 @@ import { redirect } from 'next/navigation'; | |||||||
| import { Router } from "next/router"; | import { Router } from "next/router"; | ||||||
| import { useRouter } from 'next/navigation' | import { useRouter } from 'next/navigation' | ||||||
| import { truncateString } from "@/util/Utils"; | import { truncateString } from "@/util/Utils"; | ||||||
|  | // @ts-ignore
 | ||||||
| import { MDXRemote } from "next-mdx-remote/rsc"; | import { MDXRemote } from "next-mdx-remote/rsc"; | ||||||
| import { ExampleComponent } from "./article"; | import { ExampleComponent } from "./article"; | ||||||
| import ReactDOM from "react-dom"; | import ReactDOM from "react-dom"; | ||||||
| import renderToString from 'react-dom/server' | import renderToString from 'react-dom/server' | ||||||
| import { jsxToString } from "@/app/lib/jsxtostring"; | import { jsxToString } from "@/app/lib/jsxtostring"; | ||||||
|  | // @ts-ignore
 | ||||||
| import remarkMdx from "remark-mdx"; | import remarkMdx from "remark-mdx"; | ||||||
|  | // @ts-ignore
 | ||||||
| import { remark } from "remark"; | import { remark } from "remark"; | ||||||
|  | // @ts-ignore
 | ||||||
| import strip from 'remark-mdx-to-plain-text'; | import strip from 'remark-mdx-to-plain-text'; | ||||||
| import { Post } from "@/model/Post"; | import { Post } from "@/models"; | ||||||
| import { Attributes } from "@sequelize/core"; | import { Attributes } from "@sequelize/core"; | ||||||
| 
 | 
 | ||||||
| type ArticlePreviewPost = Attributes<Post> | type ArticlePreviewPost = Attributes<Post> | ||||||
|  | |||||||
| @ -1,30 +1,37 @@ | |||||||
| import { Auth } from './Auth'; | import Sequelize from '@sequelize/core'; | ||||||
|  | import { SqliteDialect } from '@sequelize/sqlite3'; | ||||||
| import { Attachment } from './Attachment'; | import { Attachment } from './Attachment'; | ||||||
|  | import { Auth } from './Auth'; | ||||||
| import { Bucket } from './Bucket'; | import { Bucket } from './Bucket'; | ||||||
| import { DBState } from './DBState'; | import { DBState } from './DBState'; | ||||||
| import { addPostScopes, Post, PostBucket } from './Post'; | import { Post, PostBucket, addPostScopes } from './Post'; | ||||||
| import { PostTag } from './PostTag'; | import { PostTag } from './PostTag'; | ||||||
| import { Project } from './Project'; | import { Project } from './Project'; | ||||||
| import { Tag } from './Tag'; | import { Tag } from './Tag'; | ||||||
| import { User, addUserScopes } from './User'; | import { User, addUserScopes } from './User'; | ||||||
| import { UserPerms, addUserPermsScopes } from './UserPerms'; | import { UserPerms, addUserPermsScopes } from './UserPerms'; | ||||||
| import { SqliteDialect } from '@sequelize/sqlite3'; |  | ||||||
| import Sequelize from '@sequelize/core'; |  | ||||||
| 
 | 
 | ||||||
|  | export * from './APIKey'; | ||||||
|  | export * from './Attachment'; | ||||||
|  | export * from './Auth'; | ||||||
|  | export * from './Bucket'; | ||||||
|  | export * from './DBState'; | ||||||
|  | export * from './Post'; | ||||||
|  | export * from './PostTag'; | ||||||
|  | export * from './Project'; | ||||||
|  | export * from './Tag'; | ||||||
|  | export * from './User'; | ||||||
|  | export * from './UserPerms'; | ||||||
| 
 | 
 | ||||||
| const sequelize = new Sequelize({ | export const sequelize = new Sequelize({ | ||||||
|     dialect: SqliteDialect, |     dialect: SqliteDialect, | ||||||
|     storage: 'db.sqlite', |     storage: 'db.sqlite', | ||||||
|     models: [Auth, Attachment, Bucket, DBState, Post, PostBucket, PostTag, Project, Tag, User, UserPerms], |     models: [Auth, Attachment, Bucket, DBState, Post, PostBucket, PostTag, Project, Tag, User, UserPerms], | ||||||
| 
 |  | ||||||
| }); | }); | ||||||
| 
 | 
 | ||||||
| 
 | 
 | ||||||
| const dbSync = (async ()=> await sequelize.sync())().then(()=>{ | export const dbSync = (async ()=> await sequelize.sync())().then(()=>{ | ||||||
|     addUserScopes(); |     addUserScopes(); | ||||||
|     addUserPermsScopes(); |     addUserPermsScopes(); | ||||||
|     addPostScopes(); |     addPostScopes(); | ||||||
| }); | }); | ||||||
| 
 |  | ||||||
| 
 |  | ||||||
| export { sequelize, dbSync, Auth, Attachment, Bucket, DBState, Post, PostBucket, PostTag, Project, Tag, User, UserPerms } |  | ||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user