some updates for process instance reports and metadata w/ burnettk

This commit is contained in:
jasquat 2022-11-30 17:20:34 -05:00
parent 69c62cfdcb
commit 98c775db8e
6 changed files with 145 additions and 110 deletions

View File

@ -76,17 +76,7 @@ class ProcessInstanceReportService:
# TODO replace with system reports that are loaded on launch (or similar) # TODO replace with system reports that are loaded on launch (or similar)
temp_system_metadata_map = { temp_system_metadata_map = {
"default": { "default": {
"columns": [ "columns": cls.builtin_column_options()
{"Header": "id", "accessor": "id"},
{
"Header": "process_model_display_name",
"accessor": "process_model_display_name",
},
{"Header": "start_in_seconds", "accessor": "start_in_seconds"},
{"Header": "end_in_seconds", "accessor": "end_in_seconds"},
{"Header": "username", "accessor": "username"},
{"Header": "status", "accessor": "status"},
],
}, },
"system_report_instances_initiated_by_me": { "system_report_instances_initiated_by_me": {
"columns": [ "columns": [
@ -102,33 +92,13 @@ class ProcessInstanceReportService:
"filter_by": [{"field_name": "initiated_by_me", "field_value": True}], "filter_by": [{"field_name": "initiated_by_me", "field_value": True}],
}, },
"system_report_instances_with_tasks_completed_by_me": { "system_report_instances_with_tasks_completed_by_me": {
"columns": [ "columns": cls.builtin_column_options(),
{"Header": "id", "accessor": "id"},
{
"Header": "process_model_display_name",
"accessor": "process_model_display_name",
},
{"Header": "start_in_seconds", "accessor": "start_in_seconds"},
{"Header": "end_in_seconds", "accessor": "end_in_seconds"},
{"Header": "username", "accessor": "username"},
{"Header": "status", "accessor": "status"},
],
"filter_by": [ "filter_by": [
{"field_name": "with_tasks_completed_by_me", "field_value": True} {"field_name": "with_tasks_completed_by_me", "field_value": True}
], ],
}, },
"system_report_instances_with_tasks_completed_by_my_groups": { "system_report_instances_with_tasks_completed_by_my_groups": {
"columns": [ "columns": cls.builtin_column_options(),
{"Header": "id", "accessor": "id"},
{
"Header": "process_model_display_name",
"accessor": "process_model_display_name",
},
{"Header": "start_in_seconds", "accessor": "start_in_seconds"},
{"Header": "end_in_seconds", "accessor": "end_in_seconds"},
{"Header": "username", "accessor": "username"},
{"Header": "status", "accessor": "status"},
],
"filter_by": [ "filter_by": [
{ {
"field_name": "with_tasks_completed_by_my_group", "field_name": "with_tasks_completed_by_my_group",
@ -273,13 +243,13 @@ class ProcessInstanceReportService:
def builtin_column_options(cls) -> list[dict]: def builtin_column_options(cls) -> list[dict]:
"""Builtin_column_options.""" """Builtin_column_options."""
return [ return [
{"Header": "id", "accessor": "id"}, {"Header": "Id", "accessor": "id"},
{ {
"Header": "process_model_display_name", "Header": "Process",
"accessor": "process_model_display_name", "accessor": "process_model_display_name",
}, },
{"Header": "start_in_seconds", "accessor": "start_in_seconds"}, {"Header": "Start", "accessor": "start_in_seconds"},
{"Header": "end_in_seconds", "accessor": "end_in_seconds"}, {"Header": "End", "accessor": "end_in_seconds"},
{"Header": "username", "accessor": "username"}, {"Header": "Username", "accessor": "username"},
{"Header": "status", "accessor": "status"}, {"Header": "Status", "accessor": "status"},
] ]

View File

@ -115,7 +115,6 @@ export default function ProcessGroupForm({
labelText="Display Name*" labelText="Display Name*"
value={processGroup.display_name} value={processGroup.display_name}
onChange={(event: any) => onDisplayNameChanged(event.target.value)} onChange={(event: any) => onDisplayNameChanged(event.target.value)}
onBlur={(event: any) => console.log('event', event)}
/>, />,
]; ];

View File

@ -1,12 +1,11 @@
import { useState } from 'react'; import { useState } from 'react';
// TODO: carbon controls
/*
import { import {
Button, Button,
Textbox, TextInput,
Form,
Stack,
// @ts-ignore // @ts-ignore
} from '@carbon/react'; } from '@carbon/react';
*/
import { ProcessModel } from '../interfaces'; import { ProcessModel } from '../interfaces';
import HttpService from '../services/HttpService'; import HttpService from '../services/HttpService';
@ -112,20 +111,21 @@ export default function ProcessInstanceListSaveAsReport({
}; };
return ( return (
<form onSubmit={addProcessInstanceReport}> <Form onSubmit={addProcessInstanceReport}>
<label htmlFor="identifier"> <Stack gap={5} orientation="horizontal">
identifier: <TextInput
<input
name="identifier"
id="identifier" id="identifier"
type="text" name="identifier"
labelText="Identifier"
className="no-wrap"
inline
value={identifier} value={identifier}
onChange={(e) => setIdentifier(e.target.value)} onChange={(e: any) => setIdentifier(e.target.value)}
/> />
</label> <Button disabled={!hasIdentifier()} size="sm">
<button disabled={!hasIdentifier()} type="submit"> {buttonText}
{buttonText} </Button>
</button> </Stack>
</form> </Form>
); );
} }

View File

@ -7,7 +7,7 @@ import {
} from 'react-router-dom'; } from 'react-router-dom';
// @ts-ignore // @ts-ignore
import { Filter } from '@carbon/icons-react'; import { Filter, Close } from '@carbon/icons-react';
import { import {
Button, Button,
ButtonSet, ButtonSet,
@ -21,6 +21,7 @@ import {
TableHead, TableHead,
TableRow, TableRow,
TimePicker, TimePicker,
Tag,
// @ts-ignore // @ts-ignore
} from '@carbon/react'; } from '@carbon/react';
import { PROCESS_STATUSES, DATE_FORMAT, DATE_FORMAT_CARBON } from '../config'; import { PROCESS_STATUSES, DATE_FORMAT, DATE_FORMAT_CARBON } from '../config';
@ -49,6 +50,7 @@ import {
ProcessModel, ProcessModel,
ProcessInstanceReport, ProcessInstanceReport,
ProcessInstance, ProcessInstance,
ReportColumn,
} from '../interfaces'; } from '../interfaces';
import ProcessModelSearch from './ProcessModelSearch'; import ProcessModelSearch from './ProcessModelSearch';
import ProcessInstanceReportSearch from './ProcessInstanceReportSearch'; import ProcessInstanceReportSearch from './ProcessInstanceReportSearch';
@ -127,6 +129,10 @@ export default function ProcessInstanceListTable({
const [processInstanceReportSelection, setProcessInstanceReportSelection] = const [processInstanceReportSelection, setProcessInstanceReportSelection] =
useState<ProcessInstanceReport | null>(null); useState<ProcessInstanceReport | null>(null);
const [availableReportColumns, setAvailableReportColumns] = useState<
ReportColumn[]
>([]);
const dateParametersToAlwaysFilterBy: dateParameters = useMemo(() => { const dateParametersToAlwaysFilterBy: dateParameters = useMemo(() => {
return { return {
start_from: [setStartFromDate, setStartFromTime], start_from: [setStartFromDate, setStartFromTime],
@ -554,12 +560,99 @@ export default function ProcessInstanceListTable({
setEndToTime(''); setEndToTime('');
}; };
const processInstanceReportDidChange = (selection: any) => {
clearFilters();
const selectedReport = selection.selectedItem;
setProcessInstanceReportSelection(selectedReport);
const queryParamString = selectedReport
? `&report_identifier=${selectedReport.id}`
: '';
setErrorMessage(null);
navigate(`/admin/process-instances?${queryParamString}`);
};
const reportColumns = () => {
return (reportMetadata as any).columns;
};
const saveAsReportComponent = () => {
// TODO onSuccess reload/select the new report in the report search
const callback = (identifier: string) => {
processInstanceReportDidChange({
selectedItem: { id: identifier, display_name: identifier },
});
};
const {
valid,
startFromSeconds,
startToSeconds,
endFromSeconds,
endToSeconds,
} = calculateStartAndEndSeconds();
if (!valid) {
return null;
}
return (
<ProcessInstanceListSaveAsReport
onSuccess={callback}
columnArray={reportColumns()}
orderBy=""
processModelSelection={processModelSelection}
processStatusSelection={processStatusSelection}
startFromSeconds={startFromSeconds}
startToSeconds={startToSeconds}
endFromSeconds={endFromSeconds}
endToSeconds={endToSeconds}
/>
);
};
const columnSelections = () => {
if (reportColumns()) {
const tags: any = [];
(reportColumns() as any).forEach((reportColumn: ReportColumn) => {
tags.push(
<Tag type="cool-gray" size="sm" title={reportColumn.accessor}>
<Button
kind="ghost"
size="sm"
className="button-tag-icon"
title="Edit Header"
>
{reportColumn.Header}
</Button>
<Button
data-qa="remove-report-column"
renderIcon={Close}
iconDescription="Remove Column"
className="button-tag-icon"
hasIconOnly
size="sm"
kind="ghost"
onClick={toggleShowFilterOptions}
/>
</Tag>
);
});
return tags;
}
return null;
};
const filterOptions = () => { const filterOptions = () => {
if (!showFilterOptions) { if (!showFilterOptions) {
return null; return null;
} }
return ( return (
<> <>
<Grid fullWidth className="with-bottom-margin">
<Column md={8}>{columnSelections()}</Column>
</Grid>
<Grid fullWidth className="with-bottom-margin"> <Grid fullWidth className="with-bottom-margin">
<Column md={8}> <Column md={8}>
<ProcessModelSearch <ProcessModelSearch
@ -642,14 +735,15 @@ export default function ProcessInstanceListTable({
</ButtonSet> </ButtonSet>
</Column> </Column>
</Grid> </Grid>
<Grid fullWidth className="with-bottom-margin">
<Column md={7} lg={13} sm={3}>
{saveAsReportComponent()}
</Column>
</Grid>
</> </>
); );
}; };
const reportColumns = () => {
return (reportMetadata as any).columns;
};
const buildTable = () => { const buildTable = () => {
const headerLabels: Record<string, string> = { const headerLabels: Record<string, string> = {
id: 'Id', id: 'Id',
@ -749,20 +843,10 @@ export default function ProcessInstanceListTable({
const toggleShowFilterOptions = () => { const toggleShowFilterOptions = () => {
setShowFilterOptions(!showFilterOptions); setShowFilterOptions(!showFilterOptions);
}; HttpService.makeCallToBackend({
path: `/process-instances/reports/columns`,
const processInstanceReportDidChange = (selection: any) => { successCallback: setAvailableReportColumns,
clearFilters(); });
const selectedReport = selection.selectedItem;
setProcessInstanceReportSelection(selectedReport);
const queryParamString = selectedReport
? `&report_identifier=${selectedReport.id}`
: '';
setErrorMessage(null);
navigate(`/admin/process-instances?${queryParamString}`);
}; };
const reportSearchComponent = () => { const reportSearchComponent = () => {
@ -777,39 +861,6 @@ export default function ProcessInstanceListTable({
return null; return null;
}; };
const saveAsReportComponent = () => {
// TODO onSuccess reload/select the new report in the report search
const callback = (identifier: string) => {
processInstanceReportDidChange({
selectedItem: { id: identifier, display_name: identifier },
});
};
const {
valid,
startFromSeconds,
startToSeconds,
endFromSeconds,
endToSeconds,
} = calculateStartAndEndSeconds();
if (!valid) {
return null;
}
return (
<ProcessInstanceListSaveAsReport
onSuccess={callback}
columnArray={reportColumns()}
orderBy=""
processModelSelection={processModelSelection}
processStatusSelection={processStatusSelection}
startFromSeconds={startFromSeconds}
startToSeconds={startToSeconds}
endFromSeconds={endFromSeconds}
endToSeconds={endToSeconds}
/>
);
};
const filterComponent = () => { const filterComponent = () => {
if (!filtersEnabled) { if (!filtersEnabled) {
return null; return null;
@ -834,7 +885,6 @@ export default function ProcessInstanceListTable({
</Column> </Column>
</Grid> </Grid>
{filterOptions()} {filterOptions()}
{saveAsReportComponent()}
</> </>
); );
}; };

View File

@ -316,10 +316,21 @@ td.actions-cell {
padding-bottom: 10px; padding-bottom: 10px;
} }
.cds--btn--ghost:not([disabled]) svg { .cds--btn--ghost:not([disabled]) svg.red-icon {
fill: red; fill: red;
} }
.failure-string { .failure-string {
color: red; color: red;
} }
.cds--btn--ghost.cds--btn--sm.button-tag-icon {
padding-left: 0;
padding-right: 0;
padding-top: 0;
}
/* .no-wrap cds--label cds--label--inline cds--label--inline--md{ */
.no-wrap .cds--label--inline{
word-break: normal;
}

View File

@ -152,3 +152,8 @@ export interface FormField {
type: string; type: string;
enum: string[]; enum: string[];
} }
export interface ReportColumn {
Header: string;
accessor: string;
}