Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactor frontend #12

Merged
merged 45 commits into from
Nov 27, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
45 commits
Select commit Hold shift + click to select a range
2a8af94
feat: Seperated user database
NanamiNakano Nov 2, 2024
f2ba6d1
feat(database): auth_user
NanamiNakano Nov 2, 2024
9d15e35
feat: Authentication
NanamiNakano Nov 2, 2024
47d7ee2
feat: Change authentication method to access_token
NanamiNakano Nov 3, 2024
b9dcbf4
feat(frontend)!: simple login
NanamiNakano Nov 3, 2024
0564ea6
docs(README): Add instructions for migration, update technical details
NanamiNakano Nov 5, 2024
04a192c
fix(backend): Fix type error
NanamiNakano Nov 14, 2024
3a19584
fix(frontend): Add error handling
NanamiNakano Nov 14, 2024
29a7e45
refactor!: migrator.py
NanamiNakano Nov 15, 2024
e34303e
docs(README): Update technical details
NanamiNakano Nov 15, 2024
89430b3
feat(backend): Add update annotation endpoint
NanamiNakano Nov 15, 2024
2bb0db9
refactor(frontend): Separate UserPopover component
NanamiNakano Nov 15, 2024
db168e4
refactor(frontend):
NanamiNakano Nov 16, 2024
94d90ea
refactor(frontend): Separate ExistingPane component
NanamiNakano Nov 16, 2024
0f885d7
refactor(component): Rewrite ExistingPane component
NanamiNakano Nov 16, 2024
e2601ca
chore(lint): Lint
NanamiNakano Nov 16, 2024
0193e49
fix(bug): Can not load summary slice
NanamiNakano Nov 16, 2024
af1aec4
Merge branch 'sqlite' into feature-edit-annotation
NanamiNakano Nov 16, 2024
441a464
chore: Remove redundant code
NanamiNakano Nov 16, 2024
1edec27
refactor(frontend): Rewrite indexStore data fetching logic
NanamiNakano Nov 16, 2024
69c6d5e
refactor(frontend): Reduce useEffect usage to prevent unnecessary re-…
NanamiNakano Nov 17, 2024
2fa0608
refactor(frontend): Rewrite initialization logic
NanamiNakano Nov 17, 2024
cd4f7c2
chore(frontend): Use immer to improve codes
NanamiNakano Nov 18, 2024
818e184
chore(frontend): Rename store types
NanamiNakano Nov 18, 2024
04d3d2d
docs: Update documentation for user_utils.py
NanamiNakano Nov 19, 2024
ed55a24
Revert "feat(backend): Add update annotation endpoint"
NanamiNakano Nov 20, 2024
6fa4ce9
refactor(frontend): error handling and loading state
NanamiNakano Nov 20, 2024
ef0af1a
chore: Remove redundant code
NanamiNakano Nov 20, 2024
4d564ee
refactor: Rewrite index page's basic features
NanamiNakano Nov 20, 2024
8d75592
style(fallback): Update Loading component's style
NanamiNakano Nov 20, 2024
c4a1340
feat(frontend): Optimize loading state
NanamiNakano Nov 21, 2024
ff7cf09
feat(frontend): Implement user select for rewrited editor
NanamiNakano Nov 21, 2024
ae985c1
fix: null pointer
NanamiNakano Nov 22, 2024
2a75793
refactor: Rewrite renderHighlight function
NanamiNakano Nov 22, 2024
65ed268
fix: create table if not exists
NanamiNakano Nov 22, 2024
d980caa
Merge branch 'sqlite' into refactor/frontend
NanamiNakano Nov 22, 2024
93d000d
refactor(frontend): extract color functions
NanamiNakano Nov 22, 2024
3d83b1c
feat(frontend): Implement server select for rewrited editor
NanamiNakano Nov 22, 2024
c993e12
fix(frontend): Can not select after render server selection
NanamiNakano Nov 22, 2024
e2cd5b7
fix(frontend): Can not dispatch toast
NanamiNakano Nov 22, 2024
179f6d1
refactor(frontend): Replace old page with rewrited one
NanamiNakano Nov 23, 2024
df27e5a
refactor(frontend): combine historyStore and editorStore
NanamiNakano Nov 23, 2024
9a676a5
feat(frontend): Implement view history for rewrited editor
NanamiNakano Nov 23, 2024
3d0453f
fix: Can not compile
NanamiNakano Nov 23, 2024
16ae94d
chore: Code cleanup
NanamiNakano Nov 23, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -55,5 +55,6 @@ mercury_annotations.json
.venv
.idea
mercury.sqlite
users.sqlite

test.jsonl
273 changes: 174 additions & 99 deletions README.md

Large diffs are not rendered by default.

18 changes: 9 additions & 9 deletions app/layout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { FluentProvider, webLightTheme } from "@fluentui/react-components"

export default function RootLayout({ children }) {
return (
<html lang="en">
<html lang="en">
<head>
<title>Mercury</title>
<style>
Expand All @@ -15,16 +15,16 @@ export default function RootLayout({ children }) {
</style>
</head>
<body
style={{
margin: "0",
height: "100vh",
}}
style={{
margin: "0",
height: "100vh",
}}
>
<FluentProvider theme={webLightTheme}>
<div style={{ width: "98%", padding: "1rem", margin: "0 auto" }}>{children}</div>
</FluentProvider>
<FluentProvider theme={webLightTheme}>
<div style={{ width: "98%", padding: "1rem", margin: "0 auto" }}>{children}</div>
</FluentProvider>
</body>
</html>
</html>
)
}

Expand Down
61 changes: 61 additions & 0 deletions app/login/page.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
"use client"

import {
Button,
Field,
Input,
makeResetStyles,
Title1, Toast, Toaster, ToastTitle,
tokens,
useId,
useToastController,
} from "@fluentui/react-components"
import { login } from "../../utils/request"
import { useRouter } from "next/navigation"

const useStackClassName = makeResetStyles({
display: "flex",
flexDirection: "column",
maxWidth: "350px",
rowGap: tokens.spacingVerticalL,
})

export default function Login() {
const router = useRouter()
const toasterId = useId("toaster")
const { dispatchToast } = useToastController(toasterId)

async function formAction(formData) {
if (formData.get("email") && formData.get("password")) {
const success = await login(formData.get("email"), formData.get("password"))
if (success) {
router.push("/")
} else {
dispatchToast(
<Toast>
<ToastTitle>User does not exist or mismatched email and password</ToastTitle>
</Toast>,
{ position: "bottom-start", intent: "error" },
)
}
}
}

return (
<>
<Toaster toasterId={toasterId} />
<Title1>Login</Title1>
<form className={useStackClassName()} action={formAction}>
<Field label="Email" required>
<Input name="email" />
</Field>
<Field label="Password" required>
<Input name="password" />
</Field>
<Button appearance="primary" type="submit">
Login
</Button>
</form>
</>
)
}
12 changes: 0 additions & 12 deletions app/page.css

This file was deleted.

Loading