Skip to content

Commit

Permalink
execution history
Browse files Browse the repository at this point in the history
  • Loading branch information
gpalade committed Jan 12, 2024
1 parent 215c8db commit 894dc5d
Show file tree
Hide file tree
Showing 11 changed files with 106 additions and 13 deletions.
17 changes: 17 additions & 0 deletions gql-bff/src/features/workflowHistory/resolvers.js
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,23 @@ const workflowHistoryResolvers = {
}
return history;
},
allExecutionHistory: async (_parent, _args, context, _info) => {
const { dataSources, tenant } = context;
const allWorkflows = await dataSources.workflowApi.getWorkflowList();
const flows = isMultiTenant
? filterResourcesByTenant(allWorkflows, tenant?.id)
: allWorkflows;

const history = {};
for (const flow of flows) {
const flowHistory = await dataSources?.executionApi?.getExecutionList({size: 1000, sort:
"startTime:DESC", start: 0, freeText: `(workflowType: ${flow.name} AND version: ${flow.version})`});

history[`${flow.name}/${flow.version}`] = flowHistory.totalHits;
}

return history;
},
},
WorkflowHistory: {
definition: (parent, _args, _context, _info) => {
Expand Down
1 change: 1 addition & 0 deletions gql-bff/src/features/workflowHistory/schema.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -20,4 +20,5 @@ type WorkflowHistoryList {
extend type Query {
workflowHistory(workflowName: String!, version: Int!): WorkflowHistoryList
allWorkflowHistory: JSON
allExecutionHistory: JSON
}
7 changes: 6 additions & 1 deletion react-ui/public/static/locales/en/translations.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,8 @@
"EventHandlers": "Event handlers",
"Configurations": "Configurations",
"Schedule": "Schedule",
"History": "History"
"History": "History",
"ExecutionHistory": "Execution history"
},
"Tooltips": {
"Logout": "Logout",
Expand Down Expand Up @@ -540,5 +541,9 @@
"MissingAsyncHandlers": "Missing async handlers",
"WorkflowName": "Workflow name",
"TaskReferenceName": "Task reference name"
},
"History": {
"Flow":"Flow name/version",
"ExecutionCount": "Execution count"
}
}
7 changes: 6 additions & 1 deletion react-ui/public/static/locales/fr/translations.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@
"SystemTasks": "System_Tasks",
"EventHandlers": "Gestionnaires d'événements",
"Configurations": "Configurations",
"History": "History"
"History": "History",
"ExecutionHistory": "Execution history"
},
"Tooltips": {
"Logout": "Déconnexion",
Expand Down Expand Up @@ -496,5 +497,9 @@
"False": "Faux",
"Beautify": "Formater le code"
}
},
"History": {
"Flow":"Flow name/version",
"ExecutionCount": "Execution count"
}
}
7 changes: 6 additions & 1 deletion react-ui/public/static/locales/ro/translations.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@
"SystemTasks": "System_Tasks",
"EventHandlers": "Event handlers",
"Configurations": "Configurari",
"History": "Istoric"
"History": "Istoric",
"ExecutionHistory": "Istoric executii"
},
"Tooltips": {
"Logout": "Iesire",
Expand Down Expand Up @@ -510,5 +511,9 @@
"Import": "Importa workflows",
"ImportButton": "Importa workflows",
"Placeholder": "Valoare"
},
"History": {
"Flow":"Nume workflow/versiune",
"ExecutionCount": "Numar de executii"
}
}
2 changes: 2 additions & 0 deletions react-ui/src/constants/menuConfig.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import PlayCircleFilledIcon from '@mui/icons-material/PlayCircleFilled'
import NotificationsIcon from '@mui/icons-material/Notifications'
import MenuIcon from '@mui/icons-material/Menu'
import HistoryIcon from '@mui/icons-material/History';
import SummarizeIcon from '@mui/icons-material/Summarize';

const menuItems = [
{ icon: <AccountTreeIcon />, text: 'NavBar.Workflows', path: '/workflows', name: 'Workflows' },
Expand All @@ -19,6 +20,7 @@ const menuItems = [
]
},
{ icon: <HistoryIcon />, text: 'NavBar.History', path: '/history', name: 'History' },
{ icon: <SummarizeIcon />, text: 'NavBar.ExecutionHistory', path: '/execution-history', name: 'ExecutionHistory' },
]

export default menuItems
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,15 @@ import { Typography } from '@totalsoft/rocket-ui'
import sortobject from 'deep-sort-object'
import { fieldsToBeRemoved } from 'features/common/constants'

const CompareDefinition = ({ definition, currentDefinition }) => {
const CompareDefinition = ({ definition, currentDefinition , showDates}) => {
const { t } = useTranslation()

const old = sortobject({ ...omitDeep(definition, fieldsToBeRemoved) })
const current = sortobject(omitDeep(currentDefinition, fieldsToBeRemoved))

return (
<ReactDiffViewer
styles={{ diffContainer: { wordBreak: 'break-all' } }}
styles={{ diffContainer: { wordBreak: 'break-all' } }}
oldValue={JSON.stringify(old, null, 2)}
newValue={JSON.stringify(current, null, 2)}
extraLinesSurroundingDiff={0}
Expand All @@ -26,12 +26,12 @@ const CompareDefinition = ({ definition, currentDefinition }) => {
compareMethod={DiffMethod.WORDS}
leftTitle={
<Typography variant='h5' align='center'>
{t('WorkflowHistory.Dialog.Compare.OldDefinition')}
{t('WorkflowHistory.Dialog.Compare.OldDefinition')} {showDates && `(${new Date(definition?.updateTime).toLocaleString()})`}
</Typography>
}
rightTitle={
<Typography variant='h5' align='center'>
{t('WorkflowHistory.Dialog.Compare.CurrentDefinition')}
{t('WorkflowHistory.Dialog.Compare.CurrentDefinition')} {showDates && `(${new Date(currentDefinition?.updateTime).toLocaleString()})`}
</Typography>
}
/>
Expand All @@ -40,7 +40,8 @@ const CompareDefinition = ({ definition, currentDefinition }) => {

CompareDefinition.propTypes = {
definition: PropTypes.object.isRequired,
currentDefinition: PropTypes.object
currentDefinition: PropTypes.object,
showDates: PropTypes.bool
}

export default CompareDefinition
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
import React from 'react'
import { useQueryWithErrorHandling } from 'hooks/errorHandling'
import { EXECUTION_HISTORY_QUERY } from '../queries/HistoryQuery'
import { FakeText } from '@totalsoft/rocket-ui'
import Table from '@mui/material/Table'
import TableBody from '@mui/material/TableBody'
import TableCell from '@mui/material/TableCell'
import TableContainer from '@mui/material/TableContainer'
import TableHead from '@mui/material/TableHead'
import TableRow from '@mui/material/TableRow'
import Paper from '@mui/material/Paper'
import { useTranslation } from 'react-i18next'

const ExecutionHistoryContainer = () => {
const { t } = useTranslation()
const { loading, data } = useQueryWithErrorHandling(EXECUTION_HISTORY_QUERY, { variables: {} })

const flows = data?.allExecutionHistory
? Object.keys(data?.allExecutionHistory).map(a => ({ name: a, value: data?.allExecutionHistory[a] }))
: []

if (loading) return <FakeText lines={8} />

return (
<TableContainer component={Paper}>
<Table sx={{ minWidth: 650 }} size='small' aria-label='simple table'>
<TableHead>
<TableRow>
<TableCell>{t("History.Flow")}</TableCell>
<TableCell align='right'>{t("History.ExecutionCount")}</TableCell>
</TableRow>
</TableHead>
<TableBody>
{flows.map((flow, index) => (
<TableRow key={index} sx={{ '&:last-child td, &:last-child th': { border: 0 } }}>
<TableCell component='th' scope='row'>
{flow.name}
</TableCell>
<TableCell align='right'>{flow.value}</TableCell>
</TableRow>
))}
</TableBody>
</Table>
</TableContainer>
)
}

export default ExecutionHistoryContainer
Original file line number Diff line number Diff line change
@@ -1,17 +1,16 @@
import React, { useCallback, useState } from 'react'
import { useTranslation } from 'react-i18next'
import { useQueryWithErrorHandling } from 'hooks/errorHandling'
import { HISTORY_QUERY } from '../queries/HistoryQuery'
import List from '@mui/material/List'
import ListItem from '@mui/material/ListItem'
import ListItemText from '@mui/material/ListItemText'
import ListItemButton from '@mui/material/ListItemButton'
import Grid from '@mui/material/Grid'
import { FakeText } from '@totalsoft/rocket-ui'
import CompareDefinition from 'features/workflow/edit/components/workflowHistory/modals/CompareDefinition'

const HistoryContainer = () => {
const [flow, setFlow] = useState(null)
const { t } = useTranslation()
const { loading, data } = useQueryWithErrorHandling(HISTORY_QUERY, { variables: {} })

const flows = data?.allWorkflowHistory || []
Expand All @@ -24,10 +23,12 @@ const HistoryContainer = () => {
[setFlow, data?.allWorkflowHistory]
)

if (loading) return <FakeText lines={8} />

return (
<>
<Grid container>
<Grid item xs={2} style={{overflowY: 'scroll', maxHeight: 'calc(100vh - 150px)'}}>
<Grid item xs={2} style={{ overflowY: 'scroll', maxHeight: 'calc(100vh - 150px)' }}>
<List>
{Object.keys(flows).map((flow, index) => (
<ListItem key={index} disablePadding>
Expand All @@ -38,8 +39,8 @@ const HistoryContainer = () => {
))}
</List>
</Grid>
<Grid item xs={10} style={{overflowY: 'scroll', maxHeight: 'calc(100vh - 150px)'}}>
{flow && <CompareDefinition definition={flow?.latest?.definition} currentDefinition={flow?.current} />}
<Grid item xs={10} style={{ overflowY: 'scroll', maxHeight: 'calc(100vh - 150px)' }}>
{flow && <CompareDefinition definition={flow?.latest?.definition} currentDefinition={flow?.current} showDates={true} />}
</Grid>
</Grid>
</>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,9 @@ export const HISTORY_QUERY = gql`
allWorkflowHistory
}
`

export const EXECUTION_HISTORY_QUERY = gql`
query allExecutionHistory {
allExecutionHistory
}
`
2 changes: 2 additions & 0 deletions react-ui/src/routes/AppRoutes.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import WorkflowContainer from 'features/workflow/edit/components/WorkflowContain
import ScheduleListContainer from 'features/schedule/list/components/ScheduleListContainer'
import ScheduleContainer from 'features/schedule/edit/components/ScheduleContainer'
import HistoryContainer from 'features/workflow/history/components/HistoryContainer'
import ExecutionHistoryContainer from 'features/workflow/history/components/ExecutionHistoryContainer'

export default function AppRoutes() {
return (
Expand All @@ -41,6 +42,7 @@ export default function AppRoutes() {
<Route exact path='/schedule/:name' element={<CustomRoute isPrivate={true} component={ScheduleContainer} />} />

<Route exact path='/history' element={<CustomRoute isPrivate={true} component={HistoryContainer} />} />
<Route exact path='/execution-history' element={<CustomRoute isPrivate={true} component={ExecutionHistoryContainer} />} />
<Route
isPrivate={true}
exact
Expand Down

0 comments on commit 894dc5d

Please sign in to comment.