@epcare/esm-report-builder 0.1.1-pre.13
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.eslintignore +5 -0
- package/.eslintrc.js +19 -0
- package/.prettierrc +8 -0
- package/LICENSE +401 -0
- package/README.md +317 -0
- package/dist/184.js +2 -0
- package/dist/184.js.LICENSE.txt +14 -0
- package/dist/184.js.map +1 -0
- package/dist/211.js +1 -0
- package/dist/211.js.map +1 -0
- package/dist/300.js +1 -0
- package/dist/311.js +1 -0
- package/dist/311.js.map +1 -0
- package/dist/44.js +2 -0
- package/dist/44.js.LICENSE.txt +30 -0
- package/dist/44.js.map +1 -0
- package/dist/478.js +2 -0
- package/dist/478.js.LICENSE.txt +9 -0
- package/dist/478.js.map +1 -0
- package/dist/535.js +1 -0
- package/dist/535.js.map +1 -0
- package/dist/540.js +2 -0
- package/dist/540.js.LICENSE.txt +9 -0
- package/dist/540.js.map +1 -0
- package/dist/710.js +1 -0
- package/dist/710.js.map +1 -0
- package/dist/729.js +1 -0
- package/dist/729.js.map +1 -0
- package/dist/872.js +1 -0
- package/dist/872.js.map +1 -0
- package/dist/917.js +1 -0
- package/dist/917.js.map +1 -0
- package/dist/961.js +2 -0
- package/dist/961.js.LICENSE.txt +19 -0
- package/dist/961.js.map +1 -0
- package/dist/972.js +2 -0
- package/dist/972.js.LICENSE.txt +21 -0
- package/dist/972.js.map +1 -0
- package/dist/main.js +1 -0
- package/dist/main.js.map +1 -0
- package/dist/openmrs-esm-report-builder.js +1 -0
- package/dist/openmrs-esm-report-builder.js.buildmanifest.json +482 -0
- package/dist/openmrs-esm-report-builder.js.map +1 -0
- package/dist/routes.json +1 -0
- package/e2e/core/env.ts +5 -0
- package/e2e/core/global-setup.ts +34 -0
- package/e2e/core/test.ts +21 -0
- package/e2e/pages/app-shell.page.ts +34 -0
- package/e2e/pages/etl-sources.page.ts +35 -0
- package/e2e/pages/report-sections.page.ts +20 -0
- package/e2e/pages/section-preview.modal.ts +29 -0
- package/e2e/specs/etl-sources.spec.ts +51 -0
- package/e2e/specs/navigation.spec.ts +13 -0
- package/e2e/specs/section-preview-validation.spec.ts +38 -0
- package/e2e/specs/section-preview.spec.ts +94 -0
- package/e2e/tsconfig.json +11 -0
- package/example.env +5 -0
- package/jest.config.js +28 -0
- package/package.json +102 -0
- package/playwright.config.ts +28 -0
- package/src/admin-card-link.extension.module.scss +55 -0
- package/src/admin-card-link.extension.tsx +24 -0
- package/src/components/admin/admin-page.component.tsx +31 -0
- package/src/components/admin/age-categories-page.component.tsx +109 -0
- package/src/components/admin/age-groups-page.component.tsx +146 -0
- package/src/components/admin/etl-sources-page.component.tsx +344 -0
- package/src/components/admin/report-categories-page.component.tsx +256 -0
- package/src/components/admin/report-library-page.component.tsx +540 -0
- package/src/components/ai-support/ai-assist-button.component.tsx +30 -0
- package/src/components/ai-support/ai-assist-modal.component.tsx +81 -0
- package/src/components/ai-support/ai.service.ts +21 -0
- package/src/components/ai-support/ai.types.ts +12 -0
- package/src/components/app-shell/report-builder-shell.component.tsx +120 -0
- package/src/components/app-shell/report-builder-shell.scss +15 -0
- package/src/components/data-themes/data-theme-form.component.tsx +59 -0
- package/src/components/data-themes/data-theme-modal.component.tsx +349 -0
- package/src/components/data-themes/data-themes-page.component.tsx +132 -0
- package/src/components/data-themes/data-themes-table.component.tsx +91 -0
- package/src/components/data-themes/icon-registry.ts +35 -0
- package/src/components/data-themes/sections/data-theme-basics.section.tsx +63 -0
- package/src/components/data-themes/sections/data-theme-condition-columns.section.tsx +397 -0
- package/src/components/data-themes/sections/data-theme-fields-editor.section.tsx +125 -0
- package/src/components/data-themes/sections/data-theme-metadata.section.tsx +245 -0
- package/src/components/data-themes/sections/data-theme-preview.section.tsx +115 -0
- package/src/components/data-themes/sections/data-theme-source.section.tsx +184 -0
- package/src/components/indicators/README.md +24 -0
- package/src/components/indicators/base-indicator-basic-fields.component.tsx +18 -0
- package/src/components/indicators/base-indicator-basics.section.tsx +54 -0
- package/src/components/indicators/base-indicator-countby.section.tsx +25 -0
- package/src/components/indicators/base-indicator-criteria.section.tsx +83 -0
- package/src/components/indicators/base-indicator-details-form.component.tsx +80 -0
- package/src/components/indicators/base-indicator-theme-unit-fields.component.tsx +39 -0
- package/src/components/indicators/create-base-indicator-modal.component.tsx +501 -0
- package/src/components/indicators/create-composite-base-indicator-modal.component.tsx +297 -0
- package/src/components/indicators/create-final-indicator-modal.component.tsx +260 -0
- package/src/components/indicators/diagnosis-filters-form.component.tsx +101 -0
- package/src/components/indicators/disaggregation-panel.component.tsx +93 -0
- package/src/components/indicators/handler/concept-search-multiselect.component.tsx +153 -0
- package/src/components/indicators/handler/question-answer-concept-search.component.tsx +336 -0
- package/src/components/indicators/indicator-status-tag.component.tsx +9 -0
- package/src/components/indicators/indicators-page.component.tsx +481 -0
- package/src/components/indicators/indicators-page.scss +121 -0
- package/src/components/indicators/indicators-table.component.tsx +166 -0
- package/src/components/indicators/preview-table.component.tsx +31 -0
- package/src/components/indicators/sections/composite-indicator-basics.section.tsx +36 -0
- package/src/components/indicators/sections/composite-indicator-picker.section.tsx +161 -0
- package/src/components/indicators/sections/composite-indicator-sql-preview.section.tsx +31 -0
- package/src/components/indicators/sections/final-indicator-basics.section.tsx +46 -0
- package/src/components/indicators/sections/final-indicator-disaggregation.section.tsx +47 -0
- package/src/components/indicators/sections/final-indicator-picker.section.tsx +92 -0
- package/src/components/indicators/sections/final-indicator-preview.section.tsx +20 -0
- package/src/components/indicators/sections/final-indicator-results-preview.section.tsx +65 -0
- package/src/components/indicators/sections/indicator-basics.section.tsx +40 -0
- package/src/components/indicators/sections/indicator-conditions.section.tsx +194 -0
- package/src/components/indicators/sections/indicator-sql-preview.section.tsx +26 -0
- package/src/components/indicators/sections/indicator-theme.section.tsx +48 -0
- package/src/components/indicators/sql-preview.component.tsx +19 -0
- package/src/components/indicators/types/base-indicator-form.types.ts +17 -0
- package/src/components/indicators/types/base-indicator-theme.constants.ts +8 -0
- package/src/components/indicators/types/composite-indicator.types.ts +21 -0
- package/src/components/indicators/types/condition-ui.types.ts +11 -0
- package/src/components/indicators/types/data-theme-config.types.ts +88 -0
- package/src/components/indicators/types/indicator-types.ts +56 -0
- package/src/components/indicators/types/sql-builders.ts +43 -0
- package/src/components/indicators/utils/composite-indicator-sql.utils.ts +206 -0
- package/src/components/indicators/utils/concept-preload.utils.ts +21 -0
- package/src/components/indicators/utils/final-indicator-sql.utils.ts +124 -0
- package/src/components/indicators/utils/indicator-conditions-hydration.utils.ts +254 -0
- package/src/components/indicators/utils/indicator-sql.utils.ts +185 -0
- package/src/components/landing/landing-action-item.component.tsx +50 -0
- package/src/components/landing/landing-action-list.component.tsx +12 -0
- package/src/components/landing/landing-activity-list.component.tsx +47 -0
- package/src/components/landing/landing-footer-grid.component.tsx +45 -0
- package/src/components/landing/landing-hero.component.tsx +18 -0
- package/src/components/landing/landing-section-card.component.tsx +33 -0
- package/src/components/landing/report-builder-landing-page.component.tsx +103 -0
- package/src/components/landing/report-builder-landing-page.scss +131 -0
- package/src/components/report/dashboard/reports-table.component.tsx +145 -0
- package/src/components/report/definition/panels/properties-panel.component.tsx +38 -0
- package/src/components/report/definition/panels/report-structure-panel.component.tsx +61 -0
- package/src/components/report/definition/panels/selection-panel.component.tsx +58 -0
- package/src/components/report/definition/report-definition-editor.component.tsx +99 -0
- package/src/components/report/definition/report-definition.types.ts +66 -0
- package/src/components/report/design/panels/IndicatorPropertiesPanel.scss +33 -0
- package/src/components/report/design/panels/IndicatorPropertiesPanel.tsx +389 -0
- package/src/components/report/design/panels/JsonPreviewPanel.scss +32 -0
- package/src/components/report/design/panels/JsonPreviewPanel.tsx +104 -0
- package/src/components/report/design/panels/mapping-preview-panel.component.tsx +82 -0
- package/src/components/report/design/panels/mapping-preview-panel.scss +55 -0
- package/src/components/report/design/panels/template-structure-panel.component.tsx +296 -0
- package/src/components/report/design/panels/template-structure-panel.scss +81 -0
- package/src/components/report/design/report-design-editor.component.tsx +894 -0
- package/src/components/report/design/report-design.types.ts +43 -0
- package/src/components/report/design/report-design.utils.ts +86 -0
- package/src/components/report/panels/report-detail.component.tsx +71 -0
- package/src/components/report/panels/report-panel-shell.component.tsx +60 -0
- package/src/components/report/report-dashboard.page.component.tsx +75 -0
- package/src/components/report/report-editor.page.component.tsx +466 -0
- package/src/components/report/report.routes.tsx +30 -0
- package/src/components/report-sections/create-report-section-modal.component.tsx +278 -0
- package/src/components/report-sections/hooks/useAgeCategories.ts +25 -0
- package/src/components/report-sections/hooks/useSectionEditorState.ts +306 -0
- package/src/components/report-sections/panels/Dhis2MappingPanel.tsx +157 -0
- package/src/components/report-sections/panels/DisaggregationPanel.tsx +97 -0
- package/src/components/report-sections/panels/IndicatorPickerPanel.tsx +143 -0
- package/src/components/report-sections/panels/SectionBasicsPanel.tsx +27 -0
- package/src/components/report-sections/report-section-preview-modal.component.tsx +418 -0
- package/src/components/report-sections/report-sections-page.component.tsx +313 -0
- package/src/components/report-sections/section-types.ts +55 -0
- package/src/components/report-sections/section-utils.ts +46 -0
- package/src/components/report-sections/sections-page.scss +79 -0
- package/src/components/run-reports/run-reports-page.component.tsx +23 -0
- package/src/components/shared/header/builder-header-actions.component.tsx +38 -0
- package/src/components/shared/header/header.component.tsx +85 -0
- package/src/components/shared/header/header.scss +150 -0
- package/src/components/shared/header/illustration.component.tsx +34 -0
- package/src/components/shared/indicator-properties-panel/IndicatorPropertiesPanel.scss +33 -0
- package/src/components/shared/indicator-properties-panel/IndicatorPropertiesPanel.tsx +389 -0
- package/src/components/shared/json-preview-panel/JsonPreviewPanel.scss +32 -0
- package/src/components/shared/json-preview-panel/JsonPreviewPanel.tsx +104 -0
- package/src/components/shared/mapping-preview-panel/mapping-preview-panel.component.tsx +82 -0
- package/src/components/shared/mapping-preview-panel/mapping-preview-panel.scss +55 -0
- package/src/components/shared/preview/query-results-preview.component.tsx +204 -0
- package/src/components/shared/template-structure-panel/template-structure-panel.component.tsx +296 -0
- package/src/components/shared/template-structure-panel/template-structure-panel.scss +81 -0
- package/src/config-schema.ts +23 -0
- package/src/globals.d.ts +14 -0
- package/src/hooks/theme/useDataThemes.ts +28 -0
- package/src/hooks/theme/useMambaTableMeta.ts +34 -0
- package/src/hooks/theme/useMambaTables.ts +63 -0
- package/src/index.ts +23 -0
- package/src/resources/agegroup/agegroups.api.ts +58 -0
- package/src/resources/concepts/concept-mapper.ts +21 -0
- package/src/resources/concepts/concept-types.ts +31 -0
- package/src/resources/concepts/concepts.resource.ts +44 -0
- package/src/resources/concepts/useConceptSearch.ts +41 -0
- package/src/resources/etl-source/etl-source.api.ts +65 -0
- package/src/resources/indicator/indicators.api.ts +125 -0
- package/src/resources/openmrs-api.ts +24 -0
- package/src/resources/preview/sql-preview.api.ts +54 -0
- package/src/resources/report/reports.api.ts +117 -0
- package/src/resources/report-category/report-category.api.ts +41 -0
- package/src/resources/report-library/report-library.api.ts +63 -0
- package/src/resources/report-section/report-sections.api.ts +73 -0
- package/src/resources/report-section/section-preview.api.ts +21 -0
- package/src/resources/theme/data-theme.api.ts +88 -0
- package/src/resources/theme/mamba-schema.api.ts +31 -0
- package/src/resources/theme/mamba-table-meta.api.ts +45 -0
- package/src/root.component.tsx +20 -0
- package/src/routes/report-builder.routes.tsx +66 -0
- package/src/routes/report-builder.scss +56 -0
- package/src/routes.json +21 -0
- package/src/sample-template.ts +121 -0
- package/src/template-utils.ts +110 -0
- package/src/types/carbon-react-inert.d.ts +13 -0
- package/src/types/condition-operators.ts +49 -0
- package/src/types/theme/data-theme.types.ts +88 -0
- package/src/utils/html-entities.utils.ts +23 -0
- package/tools/setup-tests.ts +1 -0
- package/translations/en.json +4 -0
- package/tsconfig.json +43 -0
- package/webpack.config.js +14 -0
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
export type DesignDimensionOption = {
|
|
2
|
+
id: string;
|
|
3
|
+
label: string;
|
|
4
|
+
};
|
|
5
|
+
|
|
6
|
+
export type DesignDimension = {
|
|
7
|
+
id: string;
|
|
8
|
+
label: string;
|
|
9
|
+
options: DesignDimensionOption[];
|
|
10
|
+
};
|
|
11
|
+
|
|
12
|
+
export type DesignRowType = 'section-label' | 'group-label' | 'indicator' | 'label' | 'spacer';
|
|
13
|
+
|
|
14
|
+
export type DesignRow = {
|
|
15
|
+
id: string;
|
|
16
|
+
type: DesignRowType;
|
|
17
|
+
code?: string;
|
|
18
|
+
label: string;
|
|
19
|
+
indent: number;
|
|
20
|
+
keyPattern?: string;
|
|
21
|
+
dims?: Record<string, string | undefined>;
|
|
22
|
+
showTotal?: boolean;
|
|
23
|
+
showDisaggregation?: boolean;
|
|
24
|
+
|
|
25
|
+
// presentation hints
|
|
26
|
+
span?: 'all' | 'label-only';
|
|
27
|
+
emphasis?: 'section' | 'group' | 'normal' | 'summary';
|
|
28
|
+
};
|
|
29
|
+
|
|
30
|
+
export type DesignGroup = {
|
|
31
|
+
id: string;
|
|
32
|
+
title: string;
|
|
33
|
+
rows: DesignRow[];
|
|
34
|
+
};
|
|
35
|
+
|
|
36
|
+
export type ReportDesignDraft = {
|
|
37
|
+
version: 1;
|
|
38
|
+
template: 'section-tabular';
|
|
39
|
+
arrayName: string;
|
|
40
|
+
defaultValue: number;
|
|
41
|
+
dimensions: Record<string, DesignDimension>;
|
|
42
|
+
groups: DesignGroup[];
|
|
43
|
+
};
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
import type { ReportDefinitionDraft } from '../definition/report-definition.types';
|
|
2
|
+
import type {
|
|
3
|
+
DesignDimension,
|
|
4
|
+
DesignGroup,
|
|
5
|
+
DesignRow,
|
|
6
|
+
ReportDesignDraft,
|
|
7
|
+
} from './report-design.types';
|
|
8
|
+
|
|
9
|
+
function makeId(prefix: string) {
|
|
10
|
+
return `${prefix}-${Math.random().toString(36).slice(2, 10)}`;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
export function createEmptyReportDesignDraft(): ReportDesignDraft {
|
|
14
|
+
return {
|
|
15
|
+
version: 1,
|
|
16
|
+
template: 'section-tabular',
|
|
17
|
+
arrayName: 'results',
|
|
18
|
+
defaultValue: 0,
|
|
19
|
+
dimensions: {},
|
|
20
|
+
groups: [],
|
|
21
|
+
};
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
export function createDefaultDimensions(): Record<string, DesignDimension> {
|
|
25
|
+
return {
|
|
26
|
+
sex: {
|
|
27
|
+
id: 'sex',
|
|
28
|
+
label: 'Sex',
|
|
29
|
+
options: [
|
|
30
|
+
{ id: 'M', label: 'Male' },
|
|
31
|
+
{ id: 'F', label: 'Female' },
|
|
32
|
+
],
|
|
33
|
+
},
|
|
34
|
+
};
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
export function createEmptyDesignGroup(title = 'New Group'): DesignGroup {
|
|
38
|
+
return {
|
|
39
|
+
id: makeId('group'),
|
|
40
|
+
title,
|
|
41
|
+
rows: [],
|
|
42
|
+
};
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
export function createEmptyDesignRow(): DesignRow {
|
|
46
|
+
return {
|
|
47
|
+
id: makeId('row'),
|
|
48
|
+
type: 'indicator',
|
|
49
|
+
code: '',
|
|
50
|
+
label: '',
|
|
51
|
+
indent: 0,
|
|
52
|
+
keyPattern: '{code}_{age}_{sex}',
|
|
53
|
+
dims: {},
|
|
54
|
+
showTotal: true,
|
|
55
|
+
showDisaggregation: true,
|
|
56
|
+
};
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
/**
|
|
60
|
+
* First-pass bootstrap from report definition.
|
|
61
|
+
* For now, this creates one group per selected section ref.
|
|
62
|
+
* Since the definition draft does not yet carry full section metadata here,
|
|
63
|
+
* labels default to section UUID and can be refined later.
|
|
64
|
+
*/
|
|
65
|
+
export function buildDesignFromDefinition(
|
|
66
|
+
definition: ReportDefinitionDraft,
|
|
67
|
+
sectionNameLookup?: Record<string, string>,
|
|
68
|
+
): ReportDesignDraft {
|
|
69
|
+
const groups: DesignGroup[] = (definition.sections ?? []).map((sectionRef) => ({
|
|
70
|
+
id: makeId('group'),
|
|
71
|
+
title:
|
|
72
|
+
sectionRef.titleOverride?.trim() ||
|
|
73
|
+
sectionNameLookup?.[sectionRef.sectionUuid] ||
|
|
74
|
+
sectionRef.sectionUuid,
|
|
75
|
+
rows: [],
|
|
76
|
+
}));
|
|
77
|
+
|
|
78
|
+
return {
|
|
79
|
+
version: 1,
|
|
80
|
+
template: 'section-tabular',
|
|
81
|
+
arrayName: 'results',
|
|
82
|
+
defaultValue: 0,
|
|
83
|
+
dimensions: createDefaultDimensions(),
|
|
84
|
+
groups,
|
|
85
|
+
};
|
|
86
|
+
}
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
|
|
2
|
+
import React from 'react';
|
|
3
|
+
import { Button, CopyButton, Stack, TextArea, TextInput } from '@carbon/react';
|
|
4
|
+
import { useTranslation } from 'react-i18next';
|
|
5
|
+
|
|
6
|
+
import styles from '../../../routes/report-builder.scss';
|
|
7
|
+
|
|
8
|
+
export type ReportDetailModel = {
|
|
9
|
+
name: string;
|
|
10
|
+
description: string;
|
|
11
|
+
uuid: string;
|
|
12
|
+
};
|
|
13
|
+
|
|
14
|
+
type Props = {
|
|
15
|
+
value: ReportDetailModel;
|
|
16
|
+
onChange: (next: ReportDetailModel) => void;
|
|
17
|
+
onCancel?: () => void;
|
|
18
|
+
onSaveDraft?: () => void;
|
|
19
|
+
isSaving?: boolean;
|
|
20
|
+
};
|
|
21
|
+
|
|
22
|
+
const ReportDetail: React.FC<Props> = ({ value, onChange, onCancel, onSaveDraft, isSaving }) => {
|
|
23
|
+
const { t } = useTranslation();
|
|
24
|
+
|
|
25
|
+
const set = (patch: Partial<ReportDetailModel>) => onChange({ ...value, ...patch });
|
|
26
|
+
|
|
27
|
+
return (
|
|
28
|
+
<div className={styles.designWorkspace}>
|
|
29
|
+
<h3 className={styles.workspaceTitle}>{t('reportDetails', 'Report Details')}</h3>
|
|
30
|
+
<p className={styles.workspaceHint}>
|
|
31
|
+
{t('reportDetailsHint', 'Provide minimum report information such as name and description.')}
|
|
32
|
+
</p>
|
|
33
|
+
|
|
34
|
+
<div className={styles.panel}>
|
|
35
|
+
<Stack gap={6} style={{ marginTop: '0.75rem', maxWidth: '64rem' }}>
|
|
36
|
+
<TextInput
|
|
37
|
+
id="rb-report-name"
|
|
38
|
+
labelText={<>{t('name', 'Name')} <span style={{ color: 'var(--cds-support-error, #da1e28)' }}>*</span></>}
|
|
39
|
+
value={value.name}
|
|
40
|
+
onChange={(e) => set({ name: (e.target as HTMLInputElement).value })}
|
|
41
|
+
/>
|
|
42
|
+
|
|
43
|
+
<TextArea
|
|
44
|
+
id="rb-report-description"
|
|
45
|
+
labelText={t('description', 'Description')}
|
|
46
|
+
value={value.description}
|
|
47
|
+
onChange={(e) => set({ description: (e.target as HTMLTextAreaElement).value })}
|
|
48
|
+
rows={4}
|
|
49
|
+
/>
|
|
50
|
+
|
|
51
|
+
<div style={{ display: 'grid', gridTemplateColumns: '1fr auto', gap: '0.5rem', alignItems: 'end' }}>
|
|
52
|
+
<TextInput id="rb-report-uuid" labelText={t('uuid', 'UUID')} value={value.uuid} readOnly />
|
|
53
|
+
<CopyButton
|
|
54
|
+
iconDescription={t('copyUuid', 'Copy UUID')}
|
|
55
|
+
feedback={t('copied', 'Copied')}
|
|
56
|
+
feedbackTimeout={1500}
|
|
57
|
+
onClick={() => { if (value.uuid) void navigator.clipboard?.writeText(value.uuid); }}
|
|
58
|
+
/>
|
|
59
|
+
</div>
|
|
60
|
+
</Stack>
|
|
61
|
+
|
|
62
|
+
<div style={{ marginTop: '1.25rem', paddingTop: '1rem', borderTop: '1px solid var(--cds-border-subtle, #e0e0e0)', display: 'flex', justifyContent: 'flex-end', gap: '0.75rem' }}>
|
|
63
|
+
<Button kind="secondary" onClick={onCancel}>{t('cancel', 'Cancel')}</Button>
|
|
64
|
+
<Button kind="primary" onClick={onSaveDraft} disabled={!value.name.trim() || isSaving}>{t('saveDraft', 'Save Draft')}</Button>
|
|
65
|
+
</div>
|
|
66
|
+
</div>
|
|
67
|
+
</div>
|
|
68
|
+
);
|
|
69
|
+
};
|
|
70
|
+
|
|
71
|
+
export default ReportDetail;
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
|
|
3
|
+
type Props = {
|
|
4
|
+
title: React.ReactNode;
|
|
5
|
+
right?: React.ReactNode;
|
|
6
|
+
children: React.ReactNode;
|
|
7
|
+
bottom?: React.ReactNode;
|
|
8
|
+
minHeight?: number;
|
|
9
|
+
};
|
|
10
|
+
|
|
11
|
+
const ReportPanelShell: React.FC<Props> = ({ title, right, children, bottom, minHeight = 560 }) => {
|
|
12
|
+
return (
|
|
13
|
+
<div
|
|
14
|
+
style={{
|
|
15
|
+
background: '#fff',
|
|
16
|
+
border: '1px solid var(--cds-border-subtle, #e0e0e0)',
|
|
17
|
+
borderRadius: 12,
|
|
18
|
+
overflow: 'hidden',
|
|
19
|
+
display: 'flex',
|
|
20
|
+
flexDirection: 'column',
|
|
21
|
+
minHeight,
|
|
22
|
+
}}
|
|
23
|
+
>
|
|
24
|
+
<div
|
|
25
|
+
style={{
|
|
26
|
+
padding: '0.9rem 1rem',
|
|
27
|
+
borderBottom: '1px solid var(--cds-border-subtle, #e0e0e0)',
|
|
28
|
+
display: 'flex',
|
|
29
|
+
alignItems: 'center',
|
|
30
|
+
justifyContent: 'space-between',
|
|
31
|
+
gap: '0.75rem',
|
|
32
|
+
}}
|
|
33
|
+
>
|
|
34
|
+
<div style={{ fontWeight: 600 }}>{title}</div>
|
|
35
|
+
{right ?? null}
|
|
36
|
+
</div>
|
|
37
|
+
|
|
38
|
+
<div style={{ padding: '1rem', display: 'flex', flexDirection: 'column', gap: '0.75rem', flex: 1 }}>
|
|
39
|
+
{children}
|
|
40
|
+
</div>
|
|
41
|
+
|
|
42
|
+
{bottom ? (
|
|
43
|
+
<div
|
|
44
|
+
style={{
|
|
45
|
+
padding: '0.9rem 1rem',
|
|
46
|
+
borderTop: '1px solid var(--cds-border-subtle, #e0e0e0)',
|
|
47
|
+
display: 'flex',
|
|
48
|
+
alignItems: 'center',
|
|
49
|
+
justifyContent: 'space-between',
|
|
50
|
+
gap: '0.75rem',
|
|
51
|
+
}}
|
|
52
|
+
>
|
|
53
|
+
{bottom}
|
|
54
|
+
</div>
|
|
55
|
+
) : null}
|
|
56
|
+
</div>
|
|
57
|
+
);
|
|
58
|
+
};
|
|
59
|
+
|
|
60
|
+
export default ReportPanelShell;
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { useTranslation } from 'react-i18next';
|
|
3
|
+
import { useNavigate } from 'react-router-dom';
|
|
4
|
+
|
|
5
|
+
import Header from '../shared/header/header.component';
|
|
6
|
+
import ReportsTable, { type ReportSummary } from './dashboard/reports-table.component';
|
|
7
|
+
import { listReports } from '../../resources/report/reports.api';
|
|
8
|
+
|
|
9
|
+
const ReportDashboardPage: React.FC = () => {
|
|
10
|
+
const { t } = useTranslation();
|
|
11
|
+
const navigate = useNavigate();
|
|
12
|
+
|
|
13
|
+
const [search, setSearch] = React.useState('');
|
|
14
|
+
const [reports, setReports] = React.useState<ReportSummary[]>([]);
|
|
15
|
+
|
|
16
|
+
React.useEffect(() => {
|
|
17
|
+
const ac = new AbortController();
|
|
18
|
+
|
|
19
|
+
listReports({ v: 'default', includeRetired: false }, ac.signal)
|
|
20
|
+
.then((data) =>
|
|
21
|
+
setReports(
|
|
22
|
+
data.map((r) => ({
|
|
23
|
+
id: r.uuid,
|
|
24
|
+
name: r.name,
|
|
25
|
+
status: r.retired ? 'Retired' : 'Draft',
|
|
26
|
+
updatedAt: '',
|
|
27
|
+
})),
|
|
28
|
+
),
|
|
29
|
+
)
|
|
30
|
+
.catch(() => setReports([]));
|
|
31
|
+
|
|
32
|
+
return () => ac.abort();
|
|
33
|
+
}, []);
|
|
34
|
+
|
|
35
|
+
const headers = React.useMemo(
|
|
36
|
+
() => [
|
|
37
|
+
{ key: 'name', header: t('reportName', 'Report') },
|
|
38
|
+
{ key: 'status', header: t('status', 'Status') },
|
|
39
|
+
{ key: 'updatedAt', header: t('lastUpdated', 'Last updated') },
|
|
40
|
+
],
|
|
41
|
+
[t],
|
|
42
|
+
);
|
|
43
|
+
|
|
44
|
+
const filteredReports = React.useMemo(() => {
|
|
45
|
+
if (!search.trim()) return reports;
|
|
46
|
+
const q = search.toLowerCase();
|
|
47
|
+
return reports.filter((r) => r.name.toLowerCase().includes(q) || r.status.toLowerCase().includes(q));
|
|
48
|
+
}, [search, reports]);
|
|
49
|
+
|
|
50
|
+
return (
|
|
51
|
+
<div>
|
|
52
|
+
<Header
|
|
53
|
+
title={t('reports', 'Manage Reports')}
|
|
54
|
+
subtitle={t('manageReports', 'Manage and create reports')}
|
|
55
|
+
/>
|
|
56
|
+
|
|
57
|
+
<ReportsTable
|
|
58
|
+
reports={filteredReports}
|
|
59
|
+
headers={headers}
|
|
60
|
+
searchValue={search}
|
|
61
|
+
onSearchChange={setSearch}
|
|
62
|
+
onCreateReport={() => navigate('/new')}
|
|
63
|
+
onRowClick={(id) => navigate(`/edit/${id}`)}
|
|
64
|
+
/>
|
|
65
|
+
|
|
66
|
+
{filteredReports.length === 0 ? (
|
|
67
|
+
<div style={{ opacity: 0.7, marginTop: '1rem' }}>
|
|
68
|
+
{t('noReportsFound', 'No reports match your search')}
|
|
69
|
+
</div>
|
|
70
|
+
) : null}
|
|
71
|
+
</div>
|
|
72
|
+
);
|
|
73
|
+
};
|
|
74
|
+
|
|
75
|
+
export default ReportDashboardPage;
|