-
Notifications
You must be signed in to change notification settings - Fork 57
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
Admin UI and minor fixes #469
Closed
Closed
Changes from all commits
Commits
Show all changes
55 commits
Select commit
Hold shift + click to select a range
63191cb
Replaced Icon in Daily Summary with new Icon component
marsian83 014bd6d
removed fontawesome as it is no longer needed - also removed redundan…
marsian83 8a42307
Merge branch 'main' of https://github.com/marsian83/arewefastyet
marsian83 0973cbb
Merge branch 'main' of https://github.com/marsian83/arewefastyet
marsian83 83bcc79
fix table gap of Macro Benchmark component
marsian83 417e2c9
Merge branch 'vitessio:main' into main
marsian83 395e663
Restructure layouts and add admin layout
marsian83 f104569
Add theme button to admin layout and added 'temp' routes for testing
marsian83 725c725
Added form implementation with automatic data handling
marsian83 cf07e17
Added icons - Person, Key
marsian83 d230171
Add nesting support to DataForm
marsian83 6373924
Added Admin Login Page
marsian83 1fc307f
Merge branch 'main' of https://github.com/marsian83/arewefastyet
marsian83 06dd918
Added license to layout/index.ts
marsian83 8c08d35
Added license to admin login page
marsian83 e5bbce2
fix transition in theme when loading first time
marsian83 96521f8
updated admin login page
marsian83 c87c676
Add nav to Admin layout and updated admin routes
marsian83 b787e33
Made Admin Navbar - sidenav
marsian83 1426e11
add pages to admin panel
marsian83 cd9f112
Add icon - ssidChart
marsian83 bb61a35
Add icon - description
marsian83 4e4ff91
Add icon - logout
marsian83 ecb77d5
add icon to logout in admin side nav
marsian83 b61545b
fix props requirement in DataForm
marsian83 5176d1e
Add Dropdown support to DataForm
marsian83 e0dca32
update DataForm types
marsian83 43f4e94
Add name prop to Dropdown
marsian83 7331d9b
fix button type in Dropdown
marsian83 f0197fe
Add request section to benchmak admin page
marsian83 f97bb83
Benchmarking page for admins with dummyData
marsian83 bf9a96f
Fix the Side Nav
marsian83 30fe49f
Add type declarations for later use in api calls and ts migration
marsian83 b80389f
Add types for env
marsian83 f7aa587
add package - axios
marsian83 b186d0f
add ts config
marsian83 c72cdef
add api types
marsian83 71cbc60
Add implementation for useFetch hook
marsian83 7b7308f
Add testing page for api calls
marsian83 94cd8bd
swithced api imeplementation method
marsian83 555f359
fix rendering issue for execution queue
marsian83 ac54625
move utils and StatusPage in ts
marsian83 ba57ace
implement type safe api
marsian83 5170090
typescript
marsian83 598796c
synchronization
marsian83 a19fa2c
Add server side functionality for admin and verification methods in c…
marsian83 80bd310
incorporate admin functions for delete and request
marsian83 329d6c3
bugfix
marsian83 bbfeb64
Merge branch 'vitessio:main' into main
marsian83 bff4ee4
Fix api endpoints for following pages
harry-sandhu cfb698b
fix remaining api endpoints
harry-sandhu 5d28439
Merge suggestion from code review
marsian83 fdd9458
Suggestion from code review
marsian83 aab56fa
removed console.log in useApiCall.ts file
harry-sandhu ac86dd8
Merge branch 'main' of https://github.com/marsian83/arewefastyet
harry-sandhu File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
/* | ||
Copyright 2023 The Vitess Authors. | ||
|
||
Licensed under the Apache License, Version 2.0 (the "License"); | ||
you may not use this file except in compliance with the License. | ||
You may obtain a copy of the License at | ||
|
||
http://www.apache.org/licenses/LICENSE-2.0 | ||
|
||
Unless required by applicable law or agreed to in writing, software | ||
distributed under the License is distributed on an "AS IS" BASIS, | ||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
See the License for the specific language governing permissions and | ||
limitations under the License. | ||
*/ | ||
|
||
import { BrowserRouter, Route, Routes } from "react-router-dom"; | ||
import React from "react"; | ||
import PublicRoute from "./pages/PublicRoute"; | ||
import { GlobalProvider } from "./contexts/GlobalContext"; | ||
|
||
function App() { | ||
return ( | ||
<> | ||
<GlobalProvider> | ||
<BrowserRouter> | ||
<Routes> | ||
<Route path="/*" element={<PublicRoute />} /> | ||
</Routes> | ||
</BrowserRouter> | ||
</GlobalProvider> | ||
</> | ||
); | ||
} | ||
|
||
export default App; |
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,91 @@ | ||
import React, { useEffect, useRef, useState } from "react"; | ||
import { NavLink } from "react-router-dom"; | ||
import { twMerge } from "tailwind-merge"; | ||
import Icon from "./Icon"; | ||
import admin from "../utils/admin"; | ||
|
||
// path relative to "/admin" | ||
const navItems = [ | ||
{ title: "Dashboard", to: "/", icon: "person" }, | ||
{ title: "Benchmarks", to: "/benchmarks", icon: "ssidChart" }, | ||
{ title: "Logs", to: "/logs", icon: "description" }, | ||
// { title: "Dummy", to: "/dummy", icon: "key" }, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. let's remove this line if unused |
||
] as const; | ||
|
||
export default function AdminSideNav() { | ||
const [width, setWidth] = useState(0); | ||
|
||
const navRef = useRef() as React.MutableRefObject<HTMLElement>; | ||
|
||
useEffect(() => setWidth(navRef.current.offsetWidth), []); | ||
|
||
return ( | ||
<> | ||
<div style={{ width }} /> | ||
<nav | ||
ref={navRef} | ||
className="h-screen flex flex-col p-6 bg-foreground bg-opacity-10 fixed" | ||
> | ||
<div className="flex items-center gap-x-1 text-3xl pl-3"> | ||
<img | ||
src="/logo.png" | ||
alt="vitess logo" | ||
className="h-[1.23em] aspect-square" | ||
/> | ||
<h3 className="font-medium tracking-tight text-primary font-opensans relative after:absolute after:top-full after:right-1 after:content-['admin'] after:text-xs"> | ||
arewefastyet | ||
</h3> | ||
</div> | ||
|
||
<div className="flex-1 flex flex-col gap-y-1 my-8"> | ||
{navItems.map((item, key) => ( | ||
<AdminNavLink | ||
to={`/admin${item.to}`} | ||
key={key} | ||
className="flex gap-x-3 items-center" | ||
icon={item.icon} | ||
> | ||
{item.title} | ||
</AdminNavLink> | ||
))} | ||
</div> | ||
|
||
<button | ||
onClick={() => admin.logout()} | ||
className="bg-red-600 text-white shadow w-full px-5 py-2 rounded-xl duration-150 flex items-center gap-x-3" | ||
> | ||
<Icon icon={"logout"} className="text-2xl" /> Logout | ||
</button> | ||
</nav> | ||
</> | ||
); | ||
} | ||
|
||
interface AdminNavLinkProps { | ||
children?: React.ReactNode; | ||
className?: string; | ||
icon?: React.ComponentPropsWithoutRef<typeof Icon>["icon"]; | ||
to: string; | ||
} | ||
|
||
function AdminNavLink(props: AdminNavLinkProps) { | ||
return ( | ||
<NavLink | ||
className={({ isActive, isPending }) => | ||
twMerge( | ||
"w-full px-5 py-2 rounded-xl duration-150 flex items-center gap-x-3", | ||
isPending | ||
? "pointer-events-none opacity-50" | ||
: isActive | ||
? "bg-primary pointer-events-none" | ||
: "hover:bg-background", | ||
props.className | ||
) | ||
} | ||
to={props.to} | ||
> | ||
{props.icon && <Icon icon={props.icon} className="text-2xl" />} | ||
{props.children} | ||
</NavLink> | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,118 @@ | ||
/* | ||
Copyright 2023 The Vitess Authors. | ||
|
||
Licensed under the Apache License, Version 2.0 (the "License"); | ||
you may not use this file except in compliance with the License. | ||
You may obtain a copy of the License at | ||
|
||
http://www.apache.org/licenses/LICENSE-2.0 | ||
|
||
Unless required by applicable law or agreed to in writing, software | ||
distributed under the License is distributed on an "AS IS" BASIS, | ||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
See the License for the specific language governing permissions and | ||
limitations under the License. | ||
*/ | ||
|
||
import React, { useEffect, useState } from "react"; | ||
import Dropdown from "./Dropdown"; | ||
|
||
interface ContainerProps { | ||
children?: React.ReactNode; | ||
onSubmit?: (data: Record<string, string>) => void; | ||
} | ||
|
||
//Form implementation by @marsian83 (https://github.com/marsian83) | ||
function Container( | ||
props: ContainerProps & Omit<React.FormHTMLAttributes<HTMLFormElement>, "onSubmit"> | ||
) { | ||
const [data, setData] = useState<Record<string, string>>({}); | ||
|
||
function submitHandler(event: React.FormEvent<HTMLFormElement>) { | ||
event.preventDefault(); | ||
props.onSubmit && props.onSubmit(data); | ||
} | ||
|
||
return ( | ||
<form {...props} onSubmit={submitHandler}> | ||
<MappedInputs setData={setData}>{props.children}</MappedInputs> | ||
</form> | ||
); | ||
} | ||
|
||
function MappedInputs(props: { | ||
children: React.ReactNode; | ||
setData: React.Dispatch<React.SetStateAction<Record<string, string>>>; | ||
}) { | ||
useEffect(() => { | ||
React.Children.forEach(props.children, (child) => { | ||
if ( | ||
React.isValidElement(child) && | ||
child.type === Input && | ||
child.props.type !== "submit" && | ||
child.props.name | ||
) { | ||
props.setData((p) => ({ | ||
...p, | ||
[child.props.name]: | ||
child.props.defaultValue || child.props.value || "", | ||
})); | ||
} | ||
}); | ||
}, []); | ||
|
||
return ( | ||
<> | ||
{React.Children.map(props.children, (child, key) => { | ||
if (React.isValidElement(child)) | ||
if (child.type === Input) | ||
return React.cloneElement(child as React.ReactElement, { | ||
key, | ||
onChange: (event: React.ChangeEvent<HTMLInputElement>) => { | ||
props.setData((p) => ({ | ||
...p, | ||
[child.props.name]: event.target.value, | ||
})); | ||
}, | ||
}); | ||
else if (child.type === Dropdown.Container) { | ||
return React.cloneElement(child as React.ReactElement, { | ||
key, | ||
onChange: (event: { value: string }) => { | ||
props.setData((p) => ({ | ||
...p, | ||
[child.props.name]: event.value, | ||
})); | ||
}, | ||
}); | ||
} else if (child.props.children) | ||
return React.cloneElement(child as React.ReactElement, { | ||
key, | ||
children: ( | ||
<MappedInputs setData={props.setData}> | ||
{child.props.children} | ||
</MappedInputs> | ||
), | ||
}); | ||
return child; | ||
})} | ||
</> | ||
); | ||
} | ||
|
||
type InputProps = | ||
| { | ||
type?: React.InputHTMLAttributes<HTMLInputElement>["type"]; | ||
name: string; | ||
} | ||
| { type: "submit"; name?: string }; | ||
|
||
type InputAttributes = React.InputHTMLAttributes<HTMLInputElement>; | ||
|
||
function Input(props: InputProps & Partial<InputAttributes>) { | ||
return <input {...props} />; | ||
} | ||
|
||
const DataForm = { Container, Input }; | ||
|
||
export default DataForm; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Header is missing