-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
2fcf888
commit c45211a
Showing
3 changed files
with
160 additions
and
0 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 |
---|---|---|
@@ -0,0 +1,76 @@ | ||
import { | ||
Switch, | ||
Table, | ||
Text, | ||
Tooltip, | ||
useMantineColorScheme, | ||
useMantineTheme, | ||
} from '@mantine/core'; | ||
|
||
import { serverSideTranslations } from 'next-i18next/serverSideTranslations'; | ||
import useSWR from 'swr'; | ||
import thumbnail from '../../../public/images/thumbnails/teams.png'; | ||
import Page from '../../components/Page'; | ||
import { AdminSettingsTabs } from '../../components/SettingsTabs'; | ||
import { useUser } from '../../hooks/useUser'; | ||
|
||
var vagueTime = require('vague-time'); | ||
const Settings = ({ data: tempData }: any) => { | ||
const theme = useMantineTheme(); | ||
const scheme = useMantineColorScheme(); | ||
const user = useUser(); | ||
const { data } = useSWR('/admin/cron'); | ||
|
||
return ( | ||
<Page | ||
smallPadding | ||
head={{ | ||
title: 'Cron Jobs', | ||
image: thumbnail, | ||
}} | ||
seo={{ nofollow: true, noindex: true }} | ||
requiredPermissions={['admin.admin']} | ||
loading={!data} | ||
> | ||
<AdminSettingsTabs loading={!data}> | ||
<Table> | ||
<Table.Thead> | ||
<Table.Th>Name</Table.Th> | ||
<Table.Th>Running</Table.Th> | ||
<Table.Th>Next Run</Table.Th> | ||
<Table.Th>Cron String</Table.Th> | ||
</Table.Thead> | ||
<Table.Tbody> | ||
{data.map((job: any) => ( | ||
<Table.Tr key={job.id}> | ||
<Table.Td>{job.id}</Table.Td> | ||
<Table.Td> | ||
<Switch readOnly checked={job.running} /> | ||
</Table.Td> | ||
<Table.Td> | ||
<Tooltip | ||
label={ | ||
job.nextExecution ? vagueTime.get({ to: new Date(job.nextExecution) }) : '' | ||
} | ||
> | ||
<Text>{new Date(job.nextExecution).toLocaleString()}</Text> | ||
</Tooltip> | ||
</Table.Td> | ||
<Table.Td>{job.cronTime}</Table.Td> | ||
</Table.Tr> | ||
))} | ||
</Table.Tbody> | ||
</Table> | ||
</AdminSettingsTabs> | ||
</Page> | ||
); | ||
}; | ||
|
||
export default Settings; | ||
export async function getStaticProps({ locale, params }: any) { | ||
return { | ||
props: { | ||
...(await serverSideTranslations(locale, ['common', 'teams'])), | ||
}, | ||
}; | ||
} |