-
Notifications
You must be signed in to change notification settings - Fork 97
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' into better-flowable-flow-log
- Loading branch information
Showing
6 changed files
with
256 additions
and
9 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
import prisma from '@/app/utils/prisma'; | ||
|
||
export const dynamic = 'force-dynamic'; | ||
|
||
export async function POST(request: Request) { | ||
const { flowName } = await request.json(); | ||
const errCount = await prisma.flow_errors.count({ | ||
where: { | ||
flow_name: flowName, | ||
error_type: 'error', | ||
ack: false, | ||
}, | ||
}); | ||
let mirrorStatus: 'healthy' | 'failed'; | ||
if (errCount > 0) { | ||
mirrorStatus = 'failed'; | ||
} else { | ||
mirrorStatus = 'healthy'; | ||
} | ||
return new Response(JSON.stringify(mirrorStatus)); | ||
} |
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,75 @@ | ||
import { AlertErr } from '@/app/dto/MirrorsDTO'; | ||
import prisma from '@/app/utils/prisma'; | ||
import TimeLabel from '@/components/TimeComponent'; | ||
import { Label } from '@/lib/Label'; | ||
import { Table, TableCell, TableRow } from '@/lib/Table'; | ||
|
||
type MirrorErrorProps = { | ||
params: { mirrorName: string }; | ||
}; | ||
|
||
const MirrorError = async ({ params: { mirrorName } }: MirrorErrorProps) => { | ||
const mirrorErrors: AlertErr[] = await prisma.flow_errors.findMany({ | ||
where: { | ||
flow_name: mirrorName, | ||
error_type: 'error', | ||
}, | ||
distinct: ['error_message'], | ||
}); | ||
|
||
return ( | ||
<div style={{ padding: '2rem' }}> | ||
<Label variant='title2'>Error Log</Label> | ||
<hr></hr> | ||
<div style={{ marginTop: '1rem' }}> | ||
<Label variant='body'> | ||
<b>Mirror name</b>: | ||
</Label> | ||
<Label variant='body'>{mirrorName}</Label> | ||
<div | ||
style={{ | ||
fontSize: 15, | ||
marginTop: '1rem', | ||
width: '100%', | ||
border: '1px solid rgba(0,0,0,0.1)', | ||
padding: '1rem', | ||
borderRadius: '1rem', | ||
}} | ||
> | ||
<Table | ||
header={ | ||
<TableRow style={{ textAlign: 'left' }}> | ||
<TableCell>Type</TableCell> | ||
<TableCell>Message</TableCell> | ||
<TableCell> | ||
<Label as='label' style={{ fontSize: 15 }}> | ||
Timestamp | ||
</Label> | ||
</TableCell> | ||
</TableRow> | ||
} | ||
> | ||
{mirrorErrors.map((mirrorError) => ( | ||
<TableRow key={mirrorError.error_message}> | ||
<TableCell style={{ color: '#F45156', width: '10%' }}> | ||
{mirrorError.error_type.toUpperCase()} | ||
</TableCell> | ||
<TableCell style={{ width: '70%', fontSize: 13 }}> | ||
{mirrorError.error_message} | ||
</TableCell> | ||
<TableCell style={{ width: '30%' }}> | ||
<TimeLabel | ||
fontSize={14} | ||
timeVal={mirrorError.error_timestamp.toLocaleString()} | ||
/> | ||
</TableCell> | ||
</TableRow> | ||
))} | ||
</Table> | ||
</div> | ||
</div> | ||
</div> | ||
); | ||
}; | ||
|
||
export default MirrorError; |
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,83 @@ | ||
'use client'; | ||
|
||
import { Button } from '@/lib/Button'; | ||
import { Icon } from '@/lib/Icon'; | ||
import { Label } from '@/lib/Label'; | ||
import { ProgressCircle } from '@/lib/ProgressCircle'; | ||
import Link from 'next/link'; | ||
import { useRouter } from 'next/navigation'; | ||
import { useEffect, useState } from 'react'; | ||
export const ErrorModal = ({ flowName }: { flowName: string }) => { | ||
const router = useRouter(); | ||
return ( | ||
<Link href={`/mirrors/errors/${flowName}`}> | ||
<Button | ||
style={{ | ||
backgroundColor: 'rgba(240, 128, 128, 0.5)', | ||
height: '2rem', | ||
boxShadow: '0 2px 4px rgba(0, 0, 0, 0.2)', | ||
}} | ||
> | ||
<Label as='label' style={{ fontSize: 13, color: 'darkred' }}> | ||
Show errors | ||
</Label> | ||
</Button> | ||
</Link> | ||
); | ||
}; | ||
|
||
export const MirrorError = ({ flowName }: { flowName: string }) => { | ||
const [flowStatus, setFlowStatus] = useState<string>(); | ||
const [isLoading, setIsLoading] = useState<boolean>(true); | ||
const [error, setError] = useState<string | null>(null); | ||
|
||
useEffect(() => { | ||
const fetchData = async () => { | ||
setIsLoading(true); | ||
try { | ||
const response = await fetch(`/api/mirrors/alerts`, { | ||
method: 'POST', | ||
headers: { | ||
'Content-Type': 'application/json', | ||
}, | ||
body: JSON.stringify({ flowName }), | ||
}); | ||
|
||
if (!response.ok) { | ||
throw new Error('Network response was not ok'); | ||
} | ||
|
||
const flowStatus = await response.json(); | ||
setFlowStatus(flowStatus); | ||
} catch (err: any) { | ||
setError(err.message); | ||
} finally { | ||
setIsLoading(false); | ||
} | ||
}; | ||
|
||
fetchData(); | ||
}, [flowName]); | ||
|
||
if (isLoading) { | ||
return ( | ||
<div> | ||
<ProgressCircle variant='intermediate_progress_circle' /> | ||
</div> | ||
); | ||
} | ||
|
||
if (error) { | ||
return ( | ||
<div> | ||
<Icon name='error' /> | ||
</div> | ||
); | ||
} | ||
|
||
if (flowStatus == 'healthy') { | ||
return <Icon name='check_circle' fill={true} />; | ||
} | ||
|
||
return <ErrorModal flowName={flowName} />; | ||
}; |
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