Skip to content

Commit

Permalink
feat: job active
Browse files Browse the repository at this point in the history
  • Loading branch information
zijiren233 committed Sep 23, 2024
1 parent e5aadf0 commit 7364094
Show file tree
Hide file tree
Showing 5 changed files with 29 additions and 8 deletions.
3 changes: 2 additions & 1 deletion frontend/providers/cronjob/public/locales/en/common.json
Original file line number Diff line number Diff line change
Expand Up @@ -200,5 +200,6 @@
"Environment Variables": "Environment Variables",
"implement": "Implement",
"job_implement_success": "Job has been executed",
"job_implement_error": "An error occurred while executing the job"
"job_implement_error": "An error occurred while executing the job",
"Executing": "Executing"
}
3 changes: 2 additions & 1 deletion frontend/providers/cronjob/public/locales/zh/common.json
Original file line number Diff line number Diff line change
Expand Up @@ -246,5 +246,6 @@
"Environment Variables": "环境变量",
"implement": "执行",
"job_implement_success": "Job 执行成功",
"job_implement_error": "Job 执行失败"
"job_implement_error": "Job 执行失败",
"Executing": "执行中"
}
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ export default function AppBaseInfo({
setLogs(typeof err === 'string' ? err : '');
}
},
refetchInterval: !ActivePod?.status ? 1000 : false
refetchInterval: ActivePod?.status === 'active' ? 1000 : false
}
);

Expand Down Expand Up @@ -89,11 +89,23 @@ export default function AppBaseInfo({
backgroundColor: '#fff',
border: '2px solid',
zIndex: 2,
borderColor: jobItem.status ? '#33BABB' : '#FF8492'
borderColor:
jobItem.status === 'succeeded'
? '#33BABB'
: jobItem.status === 'failed'
? '#FF8492'
: '#FF8492'
}}
>
<Flex mb={2} alignItems={'center'} fontWeight={'bold'}>
{jobItem.status ? t('base.Success') : t('Pause Error')}, {t('Executed')}
{jobItem.status === 'succeeded'
? t('base.Success')
: jobItem.status === 'failed'
? t('Pause Error')
: jobItem.status === 'active'
? t('Executing')
: t('Running')}
, {t('Executed')}
{jobItem.startTime}
</Flex>
<Box color={'blackAlpha.700'}>
Expand Down
4 changes: 3 additions & 1 deletion frontend/providers/cronjob/src/types/job.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -89,11 +89,13 @@ export interface JobEvent {
lastTime: string;
}

export type JobStatus = 'active' | 'succeeded' | 'failed';

export type JobList = {
total: number;
successAmount: number;
history: {
status: boolean;
status: JobStatus;
startTime: string;
completionTime: string;
uid: string | undefined;
Expand Down
9 changes: 7 additions & 2 deletions frontend/providers/cronjob/src/utils/adapt.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@ import {
CronJobEditType,
CronJobListItemType,
JobEvent,
JobList
JobList,
JobStatus
} from '@/types/job';
import { cpuFormatToM, cron2Time, formatPodTime, memoryFormatToMi } from '@/utils/tools';
import {
Expand Down Expand Up @@ -161,7 +162,11 @@ export const adaptJobItemList = (jobs: V1Job[]): JobList => {
if (!!item.status?.succeeded) successAmount++;
const startTimeTimestamp = dayjs(item.status?.startTime).unix();
return {
status: !!item.status?.succeeded,
status: !!item.status?.active
? 'active'
: !!item.status?.succeeded
? 'succeeded'
: ('failed' as JobStatus),
startTime: dayjs(item.status?.startTime).format('YYYY-MM-DD HH:mm'),
completionTime: dayjs(item.status?.completionTime).format('YYYY-MM-DD HH:mm'),
uid: item.metadata?.uid,
Expand Down

0 comments on commit 7364094

Please sign in to comment.