-
Notifications
You must be signed in to change notification settings - Fork 25
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
124 changed files
with
27,940 additions
and
0 deletions.
There are no files selected for viewing
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file contains 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,5 @@ | ||
const { config } = require('@dhis2/cli-style') | ||
|
||
module.exports = { | ||
extends: [config.eslintReact], | ||
} |
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file contains 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,5 @@ | ||
const { config } = require('@dhis2/cli-style') | ||
|
||
module.exports = { | ||
extends: [config.eslintReact], | ||
} |
This file contains 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,5 @@ | ||
const { config } = require('@dhis2/cli-style') | ||
|
||
module.exports = { | ||
extends: [config.eslintReact], | ||
} |
This file contains 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,5 @@ | ||
# DHIS2 Platform | ||
node_modules | ||
.d2 | ||
src/locales | ||
build |
This file contains 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,4 @@ | ||
#!/bin/sh | ||
. "$(dirname "$0")/_/husky.sh" | ||
|
||
yarn d2-style check --staged |
This file contains 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,5 @@ | ||
const { config } = require('@dhis2/cli-style') | ||
|
||
module.exports = { | ||
...require(config.prettier), | ||
} |
This file contains 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,45 @@ | ||
This project was bootstrapped with [DHIS2 Application Platform](https://github.com/dhis2/app-platform). | ||
|
||
## Available Scripts | ||
|
||
In the project directory, you can run: | ||
|
||
### `yarn start` | ||
|
||
Runs the app in the development mode.<br /> | ||
Open [http://localhost:3000](http://localhost:3000) to view it in the browser. | ||
|
||
The page will reload if you make edits.<br /> | ||
You will also see any lint errors in the console. | ||
|
||
### `yarn test` | ||
|
||
Launches the test runner and runs all available tests found in `/src`.<br /> | ||
|
||
See the section about [running tests](https://platform.dhis2.nu/#/scripts/test) for more information. | ||
|
||
### `yarn build` | ||
|
||
Builds the app for production to the `build` folder.<br /> | ||
It correctly bundles React in production mode and optimizes the build for the best performance. | ||
|
||
The build is minified and the filenames include the hashes.<br /> | ||
A deployable `.zip` file can be found in `build/bundle`! | ||
|
||
See the section about [building](https://platform.dhis2.nu/#/scripts/build) for more information. | ||
|
||
### `yarn deploy` | ||
|
||
Deploys the built app in the `build` folder to a running DHIS2 instance.<br /> | ||
This command will prompt you to enter a server URL as well as the username and password of a DHIS2 user with the App Management authority.<br/> | ||
You must run `yarn build` before running `yarn deploy`.<br /> | ||
|
||
See the section about [deploying](https://platform.dhis2.nu/#/scripts/deploy) for more information. | ||
|
||
## Learn More | ||
|
||
You can learn more about the platform in the [DHIS2 Application Platform Documentation](https://platform.dhis2.nu/). | ||
|
||
You can learn more about the runtime in the [DHIS2 Application Runtime Documentation](https://runtime.dhis2.nu/). | ||
|
||
To learn React, check out the [React documentation](https://reactjs.org/). |
This file contains 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,9 @@ | ||
const config = { | ||
type: 'app', | ||
|
||
entryPoints: { | ||
app: './src/App.js', | ||
}, | ||
} | ||
|
||
module.exports = config |
This file contains 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,23 @@ | ||
{ | ||
"name": "solutions", | ||
"version": "1.0.0", | ||
"description": "", | ||
"license": "BSD-3-Clause", | ||
"private": true, | ||
"scripts": { | ||
"build": "d2-app-scripts build", | ||
"start": "d2-app-scripts start", | ||
"test": "d2-app-scripts test", | ||
"deploy": "d2-app-scripts deploy", | ||
"lint": "d2-style check", | ||
"format": "d2-style apply" | ||
}, | ||
"devDependencies": { | ||
"@dhis2/cli-app-scripts": "^11.1.0", | ||
"@dhis2/cli-style": "^10.5.1" | ||
}, | ||
"dependencies": { | ||
"@dhis2/app-runtime": "^3.10.3", | ||
"react-router-dom": "^6.22.3" | ||
} | ||
} |
This file contains 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,57 @@ | ||
import React from 'react' | ||
import { HashRouter, Navigate, Route, Routes } from 'react-router-dom' | ||
import styles from './App.module.css' | ||
import { Navigation } from './navigation/index.js' | ||
import { Form, Home, Attributes } from './views/index.js' | ||
|
||
const MyApp = () => ( | ||
<HashRouter | ||
// HashRouter is used as there is not integration with DHIS2 server | ||
> | ||
<div className={styles.container}> | ||
<div className={styles.left}> | ||
<Navigation | ||
// This component has to be inside the `BrowserRouter` | ||
// because it will use the router's information | ||
// (It will access the react context through hooks) | ||
/> | ||
</div> | ||
|
||
<div className={styles.right}> | ||
<Routes> | ||
<Route | ||
// Home route, will render "Home" component | ||
// when "/" is the current url | ||
exact | ||
path="/" | ||
element={<Home />} | ||
/> | ||
|
||
<Route | ||
// Form route, will render "Form" component | ||
// when "/form" is the current url | ||
exact | ||
path="/form" | ||
element={<Form />} | ||
/> | ||
|
||
<Route | ||
// Attributes route, will render "Attributes" component | ||
// when "/attributes" is the current url | ||
exact | ||
path="/attributes" | ||
element={<Attributes />} | ||
/> | ||
<Route | ||
// functions as default route, redirects to home | ||
// when invalid path is provided | ||
path="*" | ||
element={<Navigate to="/" />} | ||
/> | ||
</Routes> | ||
</div> | ||
</div> | ||
</HashRouter> | ||
) | ||
|
||
export default MyApp |
This file contains 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,18 @@ | ||
.container { | ||
display: flex; | ||
min-height: 100vh; | ||
} | ||
|
||
.left { | ||
min-width: 200px; | ||
max-width: 200px; | ||
min-height: 100vh; | ||
padding-top: 20px; | ||
} | ||
|
||
.right { | ||
flex-grow: 1; | ||
min-height: 100vh; | ||
padding: 26px 16px 0; | ||
background: #f0f0f0; | ||
} |
This file contains 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,9 @@ | ||
import React from 'react' | ||
import ReactDOM from 'react-dom' | ||
import App from './App.js' | ||
|
||
it('renders without crashing', () => { | ||
const div = document.createElement('div') | ||
ReactDOM.render(<App />, div) | ||
ReactDOM.unmountComponentAtNode(div) | ||
}) |
This file contains 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 @@ | ||
export { useGetAttributes } from './useGetAttributes.js' |
This file contains 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,83 @@ | ||
import { useEffect, useState } from 'react' | ||
|
||
const ATTRIBUTES = { | ||
attributes: { | ||
attributes: [ | ||
{ | ||
unique: false, | ||
displayName: 'Alternative name', | ||
id: 'DnrLSdo4hMl', | ||
}, | ||
{ | ||
unique: false, | ||
displayName: 'Catchment area', | ||
id: 'ihn1wb9eho8', | ||
}, | ||
{ | ||
unique: false, | ||
displayName: 'Classification', | ||
id: 'Z4X3J7jMLYV', | ||
}, | ||
{ | ||
unique: false, | ||
displayName: 'Collection method', | ||
id: 'qXS2NDUEAOS', | ||
}, | ||
{ | ||
unique: true, | ||
displayName: 'HR identifier', | ||
id: 'UKNKz1H10EE', | ||
}, | ||
{ | ||
unique: true, | ||
displayName: 'KE code', | ||
id: 'l1VmqIHKk6t', | ||
}, | ||
{ | ||
unique: false, | ||
displayName: 'NGO ID', | ||
id: 'n2xYlNbsfko', | ||
}, | ||
{ | ||
unique: false, | ||
displayName: 'PEPFAR ID', | ||
id: 'dLHLR5O4YFI', | ||
}, | ||
{ | ||
unique: false, | ||
displayName: 'Rationale', | ||
id: 'AhsCAtM3L0g', | ||
}, | ||
{ | ||
unique: true, | ||
displayName: 'TZ code', | ||
id: 'xqWyz9jNCA5', | ||
}, | ||
{ | ||
unique: false, | ||
displayName: 'Unit of measure', | ||
id: 'Y1LUDU8sWBR', | ||
}, | ||
], | ||
}, | ||
} | ||
|
||
const sleep = (ms) => { | ||
return new Promise((resolve) => setTimeout(resolve, ms)) | ||
} | ||
|
||
export const useGetAttributes = () => { | ||
const [loading, setLoading] = useState(true) | ||
const error = null | ||
const data = ATTRIBUTES | ||
|
||
useEffect(() => { | ||
const delayLoading = async () => { | ||
await sleep(1000) | ||
setLoading(false) | ||
} | ||
delayLoading() | ||
}, []) | ||
|
||
return { loading, error, data } | ||
} |
This file contains 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,46 @@ | ||
import { Menu, MenuItem } from '@dhis2/ui' | ||
import PropTypes from 'prop-types' | ||
import React from 'react' | ||
import { useNavigate, useMatch } from 'react-router-dom' | ||
|
||
const NavigationItem = ({ path, label }) => { | ||
// function to navigate to different route | ||
const navigate = useNavigate() | ||
|
||
// "null" when not active, "object" when active | ||
const routeMatch = useMatch(path) | ||
|
||
// path is matched if routeMatch is not null | ||
const isActive = Boolean(routeMatch) | ||
|
||
const onClick = () => navigate(path) | ||
|
||
return <MenuItem label={label} active={isActive} onClick={onClick} /> | ||
} | ||
|
||
NavigationItem.propTypes = { | ||
label: PropTypes.string.isRequired, | ||
path: PropTypes.string.isRequired, | ||
} | ||
|
||
export const Navigation = () => ( | ||
<Menu> | ||
<NavigationItem | ||
// Menu item for the home page | ||
label="Home" | ||
path="/" | ||
/> | ||
|
||
<NavigationItem | ||
// Menu item for the meta data page | ||
label="Attributes" | ||
path="/attributes" | ||
/> | ||
|
||
<NavigationItem | ||
// Menu item for the Form page | ||
label="Form" | ||
path="/form" | ||
/> | ||
</Menu> | ||
) |
This file contains 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 @@ | ||
export * from './Navigation.js' |
Oops, something went wrong.