@kenyaemr/esm-admin-app 5.3.8-pre.1555

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.
Files changed (60) hide show
  1. package/.turbo/turbo-build.log +81 -0
  2. package/README.md +12 -0
  3. package/dist/126.js +1 -0
  4. package/dist/126.js.map +1 -0
  5. package/dist/144.js +2 -0
  6. package/dist/144.js.LICENSE.txt +19 -0
  7. package/dist/144.js.map +1 -0
  8. package/dist/173.js +1 -0
  9. package/dist/173.js.map +1 -0
  10. package/dist/300.js +1 -0
  11. package/dist/372.js +1 -0
  12. package/dist/372.js.map +1 -0
  13. package/dist/41.js +2 -0
  14. package/dist/41.js.LICENSE.txt +9 -0
  15. package/dist/41.js.map +1 -0
  16. package/dist/495.js +1 -0
  17. package/dist/495.js.map +1 -0
  18. package/dist/64.js +1 -0
  19. package/dist/64.js.map +1 -0
  20. package/dist/798.js +2 -0
  21. package/dist/798.js.LICENSE.txt +20 -0
  22. package/dist/798.js.map +1 -0
  23. package/dist/831.js +2 -0
  24. package/dist/831.js.LICENSE.txt +5 -0
  25. package/dist/831.js.map +1 -0
  26. package/dist/876.js +2 -0
  27. package/dist/876.js.LICENSE.txt +9 -0
  28. package/dist/876.js.map +1 -0
  29. package/dist/913.js +2 -0
  30. package/dist/913.js.LICENSE.txt +32 -0
  31. package/dist/913.js.map +1 -0
  32. package/dist/kenyaemr-esm-admin-app.js +1 -0
  33. package/dist/kenyaemr-esm-admin-app.js.buildmanifest.json +406 -0
  34. package/dist/kenyaemr-esm-admin-app.js.map +1 -0
  35. package/dist/main.js +1 -0
  36. package/dist/main.js.map +1 -0
  37. package/dist/routes.json +1 -0
  38. package/jest.config.js +8 -0
  39. package/package.json +55 -0
  40. package/src/components/dashboard/dashboard.component.tsx +29 -0
  41. package/src/components/dashboard/dashboard.scss +26 -0
  42. package/src/components/header/header-illustration.component.tsx +13 -0
  43. package/src/components/header/header.component.tsx +28 -0
  44. package/src/components/header/header.scss +19 -0
  45. package/src/components/logs-table/operation-log-resource-mock-data.ts +24 -0
  46. package/src/components/logs-table/operation-log-table.component.tsx +101 -0
  47. package/src/components/logs-table/operation-log.scss +10 -0
  48. package/src/components/logs-table/operation-log.test.tsx +40 -0
  49. package/src/config-schema.ts +6 -0
  50. package/src/constants.ts +2 -0
  51. package/src/declarations.d.ts +6 -0
  52. package/src/index.ts +16 -0
  53. package/src/root.component.tsx +16 -0
  54. package/src/root.scss +7 -0
  55. package/src/routes.json +16 -0
  56. package/src/setup-tests.ts +1 -0
  57. package/src/types/index.ts +6 -0
  58. package/translations/en.json +14 -0
  59. package/tsconfig.json +5 -0
  60. package/webpack.config.js +1 -0
@@ -0,0 +1,28 @@
1
+ import React from 'react';
2
+ import { useTranslation } from 'react-i18next';
3
+ import { Calendar, Location } from '@carbon/react/icons';
4
+ import { formatDate, useSession, PageHeader } from '@openmrs/esm-framework';
5
+ import styles from './header.scss';
6
+ import ETLIllustration from './header-illustration.component';
7
+
8
+ interface HeaderProps {
9
+ title: string;
10
+ }
11
+
12
+ const Header: React.FC<HeaderProps> = ({ title }) => {
13
+ const { t } = useTranslation();
14
+ const session = useSession();
15
+ const location = session?.sessionLocation?.display;
16
+
17
+ return (
18
+ <div className={styles.header}>
19
+ <PageHeader
20
+ title={t('etlAdministration', 'ETL Administration')}
21
+ illustration={<ETLIllustration />}
22
+ className={styles.header}
23
+ />
24
+ </div>
25
+ );
26
+ };
27
+
28
+ export default Header;
@@ -0,0 +1,19 @@
1
+ @use '@carbon/layout';
2
+ @use '@carbon/type';
3
+ @use '@carbon/colors';
4
+
5
+ .header {
6
+ @include type.type-style('body-compact-02');
7
+ height: layout.$spacing-12;
8
+ display: flex;
9
+ justify-content: space-between;
10
+ padding: layout.$spacing-05;
11
+ background: white;
12
+ border: 1px solid colors.$gray-20;
13
+ }
14
+ .svgContainer svg {
15
+ width: layout.$spacing-10;
16
+ height: layout.$spacing-10;
17
+ margin-right: layout.$spacing-06;
18
+ fill: var(--brand-03);
19
+ }
@@ -0,0 +1,24 @@
1
+ import { ETLLogs } from '../../types';
2
+
3
+ export const LogMsg = [
4
+ {
5
+ procedure: 'initial population of tables',
6
+ startTime: '2024-11-28T09:30:12',
7
+ endTime: '2024-11-28T09:33:15',
8
+ completionStatus: 'Success',
9
+ },
10
+ {
11
+ procedure: 'initial creation of tables',
12
+ startTime: '2024-11-28T09:30:12',
13
+ endTime: '2024-11-28T09:33:15',
14
+ completionStatus: 'Failed',
15
+ },
16
+ ] as Array<ETLLogs>;
17
+
18
+ export const useLogData = () =>
19
+ LogMsg.map(({ procedure, startTime, endTime, completionStatus }) => ({
20
+ procedure,
21
+ startTime,
22
+ endTime,
23
+ completionStatus,
24
+ }));
@@ -0,0 +1,101 @@
1
+ import React from 'react';
2
+ import classNames from 'classnames';
3
+ import { useTranslation } from 'react-i18next';
4
+ import {
5
+ DataTable,
6
+ Table,
7
+ TableCell,
8
+ TableContainer,
9
+ TableBody,
10
+ TableHead,
11
+ TableHeader,
12
+ TableRow,
13
+ Tag,
14
+ } from '@carbon/react';
15
+ import { CardHeader, PatientChartPagination } from '@openmrs/esm-patient-common-lib';
16
+ import { useLayoutType, usePagination } from '@openmrs/esm-framework';
17
+ import styles from './operation-log.scss';
18
+ import { useLogData } from './operation-log-resource-mock-data';
19
+
20
+ interface LogData {
21
+ id: string;
22
+ procedure: string;
23
+ startTime: string;
24
+ endTime: string;
25
+ completionStatus: string;
26
+ }
27
+
28
+ const LogTable: React.FC = () => {
29
+ const { t } = useTranslation();
30
+ const pageSize = 10;
31
+ const isTablet = useLayoutType() === 'tablet';
32
+
33
+ const logData: LogData[] = useLogData().map((item, index) => ({
34
+ ...item,
35
+ id: `row-${index}`,
36
+ }));
37
+
38
+ const headers = [
39
+ { header: t('procedure', 'Procedure'), key: 'procedure' },
40
+ { header: t('startTime', 'Start time'), key: 'startTime' },
41
+ { header: t('endTime', 'End time'), key: 'endTime' },
42
+ { header: t('completionStatus', 'Completion status'), key: 'completionStatus' },
43
+ ];
44
+
45
+ const { results: paginatedData, currentPage, totalPages, goTo } = usePagination<LogData>(logData, pageSize);
46
+
47
+ return (
48
+ <div className={styles.table}>
49
+ <CardHeader title={t('etlOperationLog', 'ETL Operations Log')} children={''} />
50
+ <div className={styles.logTable}>
51
+ <DataTable rows={paginatedData} headers={headers} isSortable size={isTablet ? 'lg' : 'sm'} useZebraStyles>
52
+ {({ rows, headers, getHeaderProps, getTableProps }) => (
53
+ <TableContainer className={styles.tableContainer}>
54
+ <Table {...getTableProps()}>
55
+ <TableHead>
56
+ <TableRow>
57
+ {headers.map((header) => (
58
+ <TableHeader
59
+ key={header.key}
60
+ className={classNames(styles.productiveHeading01, styles.text02)}
61
+ {...getHeaderProps({ header })}>
62
+ {header.header}
63
+ </TableHeader>
64
+ ))}
65
+ </TableRow>
66
+ </TableHead>
67
+ <TableBody>
68
+ {rows.map((row) => (
69
+ <TableRow key={row.id}>
70
+ {row.cells.map((cell) => {
71
+ if (cell.info.header === 'completionStatus') {
72
+ return (
73
+ <TableCell key={cell.id}>
74
+ <Tag size="md" type={cell.value === 'Success' ? 'green' : 'red'}>
75
+ {cell.value}
76
+ </Tag>
77
+ </TableCell>
78
+ );
79
+ }
80
+ return <TableCell key={cell.id}>{cell.value}</TableCell>;
81
+ })}
82
+ </TableRow>
83
+ ))}
84
+ </TableBody>
85
+ </Table>
86
+ </TableContainer>
87
+ )}
88
+ </DataTable>
89
+ <PatientChartPagination
90
+ currentItems={paginatedData.length}
91
+ totalItems={logData.length}
92
+ onPageNumberChange={({ page }) => goTo(page)}
93
+ pageNumber={currentPage}
94
+ pageSize={pageSize}
95
+ />
96
+ </div>
97
+ </div>
98
+ );
99
+ };
100
+
101
+ export default LogTable;
@@ -0,0 +1,10 @@
1
+ @use '@carbon/layout';
2
+ @use '@carbon/type';
3
+ @use '@carbon/colors';
4
+
5
+ .logTable {
6
+ margin: 0 auto;
7
+ }
8
+ .table {
9
+ border: 1px solid colors.$gray-30;
10
+ }
@@ -0,0 +1,40 @@
1
+ import React from 'react';
2
+ import { render, screen, fireEvent } from '@testing-library/react';
3
+ import '@testing-library/jest-dom';
4
+ import { useLogData } from './operation-log-resource-mock-data';
5
+ import LogTable from './operation-log-table.component';
6
+
7
+ jest.mock('./operation-log-resource-mock-data', () => ({
8
+ useLogData: jest.fn(),
9
+ }));
10
+
11
+ describe('LogTable Component', () => {
12
+ beforeEach(() => {
13
+ (useLogData as jest.Mock).mockReturnValue([
14
+ {
15
+ procedure: 'Initial Population of Tables',
16
+ startTime: '2024-11-28T09:30:12',
17
+ endTime: '2024-11-28T09:33:15',
18
+ completionStatus: 'Success',
19
+ },
20
+ {
21
+ procedure: 'Initial Creation of Tables',
22
+ startTime: '2024-11-28T09:30:12',
23
+ endTime: '2024-11-28T09:33:15',
24
+ completionStatus: 'Failed',
25
+ },
26
+ ]);
27
+ });
28
+
29
+ it('renders the table with correct headers and rows', () => {
30
+ render(<LogTable />);
31
+
32
+ const headers = ['Procedure', 'Start time', 'End time', 'Completion status'];
33
+ headers.forEach((header) => {
34
+ expect(screen.getByText(header)).toBeInTheDocument();
35
+ });
36
+
37
+ const rows = screen.getAllByRole('row');
38
+ expect(rows.length).toBe(3);
39
+ });
40
+ });
@@ -0,0 +1,6 @@
1
+ import { Type } from '@openmrs/esm-framework';
2
+ import _default from 'react-hook-form/dist/logic/appendErrors';
3
+
4
+ export const configSchema = {};
5
+
6
+ export interface ConfigObject {}
@@ -0,0 +1,2 @@
1
+ export const moduleName = '@kenyaemr/esm-admin-app';
2
+ export const etlBasePath = `${window.spaBase}/admin`;
@@ -0,0 +1,6 @@
1
+ declare module '@carbon/react';
2
+ declare module '*.css';
3
+ declare module '*.scss';
4
+ declare module '*.png';
5
+
6
+ declare type SideNavProps = object;
package/src/index.ts ADDED
@@ -0,0 +1,16 @@
1
+ import { getAsyncLifecycle, defineConfigSchema, getSyncLifecycle, registerBreadcrumbs } from '@openmrs/esm-framework';
2
+ import { configSchema } from './config-schema';
3
+ import { moduleName } from './constants';
4
+
5
+ const options = {
6
+ featureName: 'esm-admin-app',
7
+ moduleName,
8
+ };
9
+
10
+ export const importTranslation = require.context('../translations', false, /.json$/, 'lazy');
11
+
12
+ export function startupApp() {
13
+ defineConfigSchema(moduleName, configSchema);
14
+ }
15
+
16
+ export const root = getAsyncLifecycle(() => import('./root.component'), options);
@@ -0,0 +1,16 @@
1
+ import React from 'react';
2
+ import { BrowserRouter, Route, Routes } from 'react-router-dom';
3
+ import { etlBasePath } from './constants';
4
+ import Dashboard from './components/dashboard/dashboard.component';
5
+
6
+ const Root: React.FC = () => {
7
+ return (
8
+ <BrowserRouter basename={etlBasePath}>
9
+ <Routes>
10
+ <Route path="/" element={<Dashboard />} />
11
+ </Routes>
12
+ </BrowserRouter>
13
+ );
14
+ };
15
+
16
+ export default Root;
package/src/root.scss ADDED
@@ -0,0 +1,7 @@
1
+ @use '@carbon/layout';
2
+ @use '@carbon/type';
3
+ @use '@carbon/colors';
4
+
5
+ .container {
6
+ padding: layout.$spacing-07;
7
+ }
@@ -0,0 +1,16 @@
1
+ {
2
+ "$schema": "https://json.openmrs.org/routes.schema.json",
3
+ "backendDependencies": {
4
+ "kenyaemrCharts": "^1.6.7"
5
+ },
6
+ "extensions": [
7
+ ],
8
+ "pages": [
9
+ {
10
+ "component": "root",
11
+ "route": "admin",
12
+ "online": true,
13
+ "offline": true
14
+ }
15
+ ]
16
+ }
@@ -0,0 +1 @@
1
+ import '@testing-library/jest-dom/extend-expect';
@@ -0,0 +1,6 @@
1
+ export interface ETLLogs {
2
+ procedure: string;
3
+ startTime: string;
4
+ endTime: string;
5
+ completionStatus: string;
6
+ }
@@ -0,0 +1,14 @@
1
+ {
2
+ "completionStatus": "Completion status",
3
+ "endTime": "End time",
4
+ "etlAdministration": "ETL Administration",
5
+ "etlOperation": "ETL operations",
6
+ "etlOperationLog": "ETL Operations Log",
7
+ "home": "Home",
8
+ "procedure": "Procedure",
9
+ "recreateDatatools": "Recreate datatools",
10
+ "recreateTables": "Recreate tables",
11
+ "refreshDwapi": "Refresh DWAPI tables",
12
+ "refreshTables": "Refresh tables",
13
+ "startTime": "Start time"
14
+ }
package/tsconfig.json ADDED
@@ -0,0 +1,5 @@
1
+ {
2
+ "extends": "../../tsconfig.json",
3
+ "include": ["src/**/*"],
4
+ "exclude": ["src/**/*.test.tsx"]
5
+ }
@@ -0,0 +1 @@
1
+ module.exports = require('openmrs/default-webpack-config');