-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Add usage charts and tables --------- Co-authored-by: arihanv <arihanvaranasi@gmail.com> Co-authored-by: Arihan Varanasi <63890951+arihanv@users.noreply.github.com>
- Loading branch information
1 parent
624b11e
commit e35df34
Showing
43 changed files
with
1,423 additions
and
213 deletions.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,19 +1,21 @@ | ||
import {ApplicationProvider} from 'lib/components/dashboard/ApplicationProvider' | ||
import {Toaster} from 'sonner' | ||
import {MainNavigation} from '~/components/dashboard/Navigation' | ||
import Feedback from '~/components/feedback/feedback' | ||
|
||
export default async function RootLayout({ | ||
children | ||
}: { | ||
children: React.ReactNode | ||
}) { | ||
return ( | ||
<div className='flex flex-col gap-8'> | ||
<Toaster /> | ||
<div className='space-y-4'> | ||
<Toaster position='top-right' /> | ||
<ApplicationProvider> | ||
<MainNavigation /> | ||
<div className='z-10 grid h-full w-full'>{children}</div> | ||
</ApplicationProvider> | ||
<Feedback /> | ||
</div> | ||
) | ||
} |
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,35 @@ | ||
import {notFound} from 'next/navigation' | ||
import z from 'zod' | ||
import {UsageCharts} from '~/components/dashboard/usage/charts' | ||
import ChartsLinks from '~/components/dashboard/usage/charts-links' | ||
|
||
const paramsSchema = z.enum(['runs', 'tokens']) | ||
|
||
export default async function RootLayout({ | ||
children, | ||
params | ||
}: { | ||
children: React.ReactNode | ||
params: { | ||
metric: string[] | undefined | ||
} | ||
}) { | ||
if ( | ||
params.metric && | ||
(params.metric.length > 1 || | ||
!paramsSchema.safeParse(params?.metric[0]).success) | ||
) | ||
return notFound() | ||
|
||
const route = params.metric ? params.metric[0] : '' | ||
|
||
return ( | ||
<div className='space-y-2'> | ||
<ChartsLinks route={route} /> | ||
<div className='space-y-5'> | ||
<UsageCharts route={route} /> | ||
{children} | ||
</div> | ||
</div> | ||
) | ||
} |
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,12 @@ | ||
import {Skeleton} from '~/components/ui/skeleton' | ||
|
||
type Props = {} | ||
|
||
export default function Loading({}: Props) { | ||
return ( | ||
<div className='space-y-2'> | ||
<Skeleton className='h-10' /> | ||
<Skeleton className='h-56' /> | ||
</div> | ||
) | ||
} |
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,20 @@ | ||
import UsageTable from '~/components/dashboard/usage/table-wrapper' | ||
|
||
export default async function Usage({ | ||
searchParams, | ||
params | ||
}: { | ||
searchParams: {[key: string]: string | string[] | undefined} | ||
params: { | ||
metric: string[] | undefined | ||
} | ||
}) { | ||
const route = params.metric ? params.metric[0] : '' | ||
|
||
return ( | ||
<UsageTable | ||
route={route} | ||
searchParams={searchParams} | ||
/> | ||
) | ||
} |
This file was deleted.
Oops, something went wrong.
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,26 @@ | ||
'use server' | ||
|
||
import {revalidatePath} from 'next/cache' | ||
import {redirect} from 'next/navigation' | ||
|
||
export async function createInstruction(projectId: string, content: string) { | ||
const req = await prisma.instruction.create({ | ||
data: { | ||
projectId: projectId, | ||
content: content, | ||
creatorUsername: 'Dashboard' | ||
} | ||
}) | ||
revalidatePath(`/dashboard/repo/${projectId}/instructions`) | ||
redirect(`/dashboard/repo/${projectId}/instructions#${req.id}`) | ||
} | ||
|
||
export async function deleteInstruction(projectId: string, id: string) { | ||
await prisma.instruction.delete({ | ||
where: { | ||
id: id | ||
} | ||
}) | ||
revalidatePath(`/dashboard/repo/${projectId}/instructions`) | ||
redirect(`/dashboard/repo/${projectId}/instructions`) | ||
} |
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
Oops, something went wrong.