-
Notifications
You must be signed in to change notification settings - Fork 9
WC2-805: Save complete logs and display them to the user #2460
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
Merged
Merged
Changes from all commits
Commits
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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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
62 changes: 62 additions & 0 deletions
62
hat/assets/js/apps/Iaso/domains/tasks/components/ActionCell.tsx
This file contains hidden or 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,62 @@ | ||
| import React, { FunctionComponent } from 'react'; | ||
| import ReplayIcon from '@mui/icons-material/Replay'; | ||
| import { IconButton, useSafeIntl } from 'bluesquare-components'; | ||
| import { NotificationImportDetailModal } from 'Iaso/domains/tasks/components/NotificationImportDetailModal'; | ||
| import { TaskLogsModal } from 'Iaso/domains/tasks/components/TaskLogsModal'; | ||
| import { useKillTask, useRelaunchTask } from 'Iaso/domains/tasks/hooks/api'; | ||
| import MESSAGES from 'Iaso/domains/tasks/messages'; | ||
| import { Task } from 'Iaso/domains/tasks/types'; | ||
| import { userHasPermission } from 'Iaso/domains/users/utils'; | ||
| import { POLIO_NOTIFICATIONS } from 'Iaso/utils/permissions'; | ||
| import { useCurrentUser } from 'Iaso/utils/usersUtils'; | ||
|
|
||
| export type Props = { | ||
| task: Task<any>; | ||
| }; | ||
|
|
||
| export const TaskActionCell: FunctionComponent<Props> = ({ task }) => { | ||
| const { formatMessage } = useSafeIntl(); | ||
| const hasPolioNotificationsPerm = userHasPermission( | ||
| POLIO_NOTIFICATIONS, | ||
| useCurrentUser(), | ||
| ); | ||
| const { mutateAsync: killTaskAction } = useKillTask(); | ||
| const { mutateAsync: relaunchTaskAction } = useRelaunchTask(); | ||
| return ( | ||
| <section> | ||
| {['QUEUED', 'RUNNING', 'UNKNOWN'].includes(task.status) && | ||
| !task.should_be_killed && ( | ||
| <IconButton | ||
| onClick={() => | ||
| killTaskAction({ | ||
| id: task.id, | ||
| should_be_killed: true, | ||
| }) | ||
| } | ||
| icon="stop" | ||
| tooltipMessage={MESSAGES.killTask} | ||
| /> | ||
| )} | ||
| {task.status === 'ERRORED' && ( | ||
| <IconButton | ||
| onClick={() => | ||
| relaunchTaskAction({ | ||
| id: task.id, | ||
| }) | ||
| } | ||
| overrideIcon={ReplayIcon} | ||
| tooltipMessage={MESSAGES.relaunch} | ||
| /> | ||
| )} | ||
| {task.should_be_killed && | ||
| task.status === 'RUNNING' && | ||
| formatMessage(MESSAGES.killSignalSent)} | ||
| {hasPolioNotificationsPerm && | ||
| ['SUCCESS', 'ERRORED'].includes(task.status) && | ||
| task.name === 'create_polio_notifications_async' && ( | ||
| <NotificationImportDetailModal task={task} iconProps={{}} /> | ||
| )} | ||
| <TaskLogsModal task={task} iconProps={{}} /> | ||
| </section> | ||
| ); | ||
| }; |
73 changes: 73 additions & 0 deletions
73
hat/assets/js/apps/Iaso/domains/tasks/components/StatusCell.tsx
This file contains hidden or 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,73 @@ | ||
| import React, { FunctionComponent } from 'react'; | ||
| import { Chip } from '@mui/material'; | ||
| import { useSafeIntl } from 'bluesquare-components'; | ||
| import MESSAGES from 'Iaso/domains/tasks/messages'; | ||
| import { Task } from 'Iaso/domains/tasks/types'; | ||
| import { SxStyles } from 'Iaso/types/general'; | ||
|
|
||
| export type Props = { | ||
| task: Task<any>; | ||
| }; | ||
|
|
||
| const getTranslatedStatusMessage = ( | ||
| formatMessage: (record: Record<string, string>) => string, | ||
| status: string, | ||
| ): string => { | ||
| // Return untranslated status if not translation available | ||
| return MESSAGES[status.toLowerCase()] | ||
| ? formatMessage(MESSAGES[status.toLowerCase()]) | ||
| : status; | ||
| }; | ||
|
|
||
| const getStatusColor = ( | ||
| status: string, | ||
| ): 'info' | 'success' | 'error' | 'warning' => { | ||
| if (['QUEUED', 'RUNNING'].includes(status)) { | ||
| return 'info'; | ||
| } | ||
| if (['EXPORTED', 'SUCCESS'].includes(status)) { | ||
| return 'success'; | ||
| } | ||
| if (status === 'ERRORED') { | ||
| return 'error'; | ||
| } | ||
| return 'warning'; | ||
| }; | ||
|
|
||
| const safePercent = (a: number, b: number): string => { | ||
| if (b === 0) { | ||
| return ''; | ||
| } | ||
| const percent = 100 * (a / b); | ||
| return `${percent.toFixed(2)}%`; | ||
| }; | ||
|
|
||
| const styles: SxStyles = { | ||
| chip: { | ||
| color: 'white', | ||
| }, | ||
| }; | ||
|
|
||
| export const StatusCell: FunctionComponent<Props> = ({ task }) => { | ||
| const { formatMessage } = useSafeIntl(); | ||
| return ( | ||
| <span> | ||
| {task.status === 'RUNNING' && task.end_value > 0 ? ( | ||
| `${task.progress_value}/${task.end_value} (${safePercent( | ||
| task.progress_value, | ||
| task.end_value, | ||
| )})` | ||
| ) : ( | ||
| <Chip | ||
| label={getTranslatedStatusMessage( | ||
| formatMessage, | ||
| task.status, | ||
| )} | ||
| color={getStatusColor(task.status)} | ||
| size="small" | ||
| sx={styles.chip} | ||
| /> | ||
| )} | ||
| </span> | ||
| ); | ||
| }; |
73 changes: 73 additions & 0 deletions
73
hat/assets/js/apps/Iaso/domains/tasks/components/TaskBaseInfo.tsx
This file contains hidden or 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,73 @@ | ||
| import React, { FunctionComponent, ReactNode } from 'react'; | ||
| import { Table, TableBody, TableRow, TableCell } from '@mui/material'; | ||
| import { TablePropsSizeOverrides } from '@mui/material/Table/Table'; | ||
| import { makeStyles } from '@mui/styles'; | ||
| import { OverridableStringUnion } from '@mui/types/esm'; | ||
| import { useSafeIntl } from 'bluesquare-components'; | ||
|
|
||
| import moment from 'moment'; | ||
| import { StatusCell } from 'Iaso/domains/tasks/components/StatusCell'; | ||
| import getDisplayName from 'Iaso/utils/usersUtils'; | ||
| import MESSAGES from '../messages'; | ||
|
|
||
| import { Task } from '../types'; | ||
|
|
||
| const useStyles = makeStyles(theme => ({ | ||
| leftCell: { | ||
| // @ts-ignore | ||
| borderRight: `1px solid ${theme.palette.ligthGray.border}`, | ||
| fontWeight: 'bold', | ||
| }, | ||
| })); | ||
|
|
||
| type RowProps = { | ||
| label: string; | ||
| value?: string | ReactNode; | ||
| }; | ||
|
|
||
| const Row: FunctionComponent<RowProps> = ({ label, value }) => { | ||
| const classes = useStyles(); | ||
| return ( | ||
| <TableRow> | ||
| <TableCell className={classes.leftCell}>{label}</TableCell> | ||
| <TableCell>{value}</TableCell> | ||
| </TableRow> | ||
| ); | ||
| }; | ||
|
|
||
| type Props = { | ||
| task: Task<any>; | ||
| size?: OverridableStringUnion<'small' | 'medium', TablePropsSizeOverrides>; | ||
| }; | ||
| export const TaskBaseInfo: FunctionComponent<Props> = ({ task, size }) => { | ||
| const { formatMessage } = useSafeIntl(); | ||
| return ( | ||
| <Table size={size} data-test="task-base-info"> | ||
| <TableBody> | ||
| <Row label={formatMessage(MESSAGES.name)} value={task.name} /> | ||
| <Row | ||
| label={formatMessage(MESSAGES.user)} | ||
| value={getDisplayName(task.launcher)} | ||
| /> | ||
| <Row | ||
| label={formatMessage(MESSAGES.timeCreated)} | ||
| value={moment.unix(task.created_at).format('LTS')} | ||
| /> | ||
| <Row | ||
| label={formatMessage(MESSAGES.timeStart)} | ||
| value={moment.unix(task.started_at).format('LTS')} | ||
| /> | ||
| {task.ended_at && ( | ||
| <Row | ||
| label={formatMessage(MESSAGES.timeEnd)} | ||
| value={moment.unix(task.ended_at).format('LTS')} | ||
| /> | ||
| )} | ||
| <Row | ||
| label={formatMessage(MESSAGES.status)} | ||
| value={task ? <StatusCell task={task} /> : ''} | ||
| /> | ||
| </TableBody> | ||
| </Table> | ||
| ); | ||
| }; |
This file contains hidden or 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.
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.
Uh oh!
There was an error while loading. Please reload this page.