Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(data-integrity): load data integrity checks from API [DHIS2-12287] #732

Draft
wants to merge 6 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions d2.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ const config = {
title: 'Data Administration',
coreApp: true,

minDHIS2Version: '2.38',

entryPoints: {
app: './src/App.js',
},
Expand Down
128 changes: 35 additions & 93 deletions i18n/en.pot
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ msgstr ""
"Content-Type: text/plain; charset=utf-8\n"
"Content-Transfer-Encoding: 8bit\n"
"Plural-Forms: nplurals=2; plural=(n != 1)\n"
"POT-Creation-Date: 2022-03-02T11:44:10.658Z\n"
"PO-Revision-Date: 2022-03-02T11:44:10.658Z\n"
"POT-Creation-Date: 2023-01-09T13:31:16.632Z\n"
"PO-Revision-Date: 2023-01-09T13:31:16.632Z\n"

msgid "Open user guide"
msgstr "Open user guide"
Expand Down Expand Up @@ -408,113 +408,55 @@ msgstr "Batch Deletion"
msgid "No lock exceptions to show."
msgstr "No lock exceptions to show."

msgid "Failed to load available data integrity checks"
msgstr "Failed to load available data integrity checks"

msgid "Checking data integrity..."
msgstr "Checking data integrity..."

msgid "Run integrity checks"
msgstr "Run integrity checks"

msgid "{{issueTitle}} ({{issueElementsCount}})"
msgstr "{{issueTitle}} ({{issueElementsCount}})"

msgid "Data elements without data set"
msgstr "Data elements without data set"

msgid "Data elements without groups"
msgstr "Data elements without groups"

msgid "Data elements violating exclusive group sets"
msgstr "Data elements violating exclusive group sets"

msgid "Data elements assigned to data sets with different period types"
msgstr "Data elements assigned to data sets with different period types"

msgid "Data sets not assigned to organisation units"
msgstr "Data sets not assigned to organisation units"

msgid "Indicators with identical formulas"
msgstr "Indicators with identical formulas"

msgid "Indicators without groups"
msgstr "Indicators without groups"

msgid "Invalid indicator numerators"
msgstr "Invalid indicator numerators"

msgid "Invalid indicator denominators"
msgstr "Invalid indicator denominators"

msgid "Indicators violating exclusive group sets"
msgstr "Indicators violating exclusive group sets"

msgid "Organisation units with cyclic references"
msgstr "Organisation units with cyclic references"

msgid "Orphaned organisation units"
msgstr "Orphaned organisation units"

msgid "Organisation units without groups"
msgstr "Organisation units without groups"
msgid "Check"
msgstr "Check"

msgid "Organisation units violating exclusive group sets"
msgstr "Organisation units violating exclusive group sets"
msgid "Description"
msgstr "Description"

msgid "Organisation unit groups without group sets"
msgstr "Organisation unit groups without group sets"
msgid "Severity"
msgstr "Severity"

msgid "Validation rules without groups"
msgstr "Validation rules without groups"
msgid "Information"
msgstr "Information"

msgid "Invalid validation rule left side expressions"
msgstr "Invalid validation rule left side expressions"
msgid "For information only"
msgstr "For information only"

msgid "Invalid validation rule right side expressions"
msgstr "Invalid validation rule right side expressions"
msgid "Warning"
msgstr "Warning"

msgid "Invalid program indicator expressions"
msgstr "Invalid program indicator expressions"
msgid "May be a problem, but not necessarily an error"
msgstr "May be a problem, but not necessarily an error"

msgid "Invalid program indicator filters"
msgstr "Invalid program indicator filters"
msgid "Severe"
msgstr "Severe"

msgid "There are data elements in the form, but not in the form or sections"
msgstr "There are data elements in the form, but not in the form or sections"

msgid "Invalid category combinations"
msgstr "Invalid category combinations"

msgid "Duplicate periods"
msgstr "Duplicate periods"

msgid "Program rules with no condition"
msgstr "Program rules with no condition"

msgid "Program rules with no action"
msgstr "Program rules with no action"

msgid "Program rules with no priority"
msgstr "Program rules with no priority"

msgid "Program rule variables with no data element"
msgstr "Program rule variables with no data element"

msgid "Program rule variables with no attribute"
msgstr "Program rule variables with no attribute"

msgid "Program rule actions with no data object"
msgstr "Program rule actions with no data object"

msgid "Program rule actions with no notification"
msgstr "Program rule actions with no notification"

msgid "Program rule actions with no section id"
msgstr "Program rule actions with no section id"
msgid ""
"An error which should be fixed, but which may not necessarily lead to the "
"system not functioning"
msgstr ""
"An error which should be fixed, but which may not necessarily lead to the "
"system not functioning"

msgid "Program rule actions with no stage id"
msgstr "Program rule actions with no stage id"
msgid "Critical"
msgstr "Critical"

msgid "Program indicators with no expression"
msgstr "Program indicators with no expression"
msgid ""
"An error which must be fixed, and which may lead to end-user error or "
"system crashes"
msgstr ""
"An error which must be fixed, and which may lead to end-user error or "
"system crashes"

msgid "Indicators"
msgstr "Indicators"
Expand Down
3 changes: 1 addition & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,7 @@
"dependencies": {
"@dhis2/app-runtime": "^3.3.0",
"@dhis2/d2-i18n": "^1.1.0",
"@dhis2/prop-types": "^2.0.3",
"@dhis2/ui": "^7.1.1",
"@dhis2/ui": "^7.16.1",
"prop-types": "^15.6.0",
"react-router-dom": "^5.0.0"
}
Expand Down
96 changes: 79 additions & 17 deletions src/pages/data-integrity/DataIntegrity.js
Original file line number Diff line number Diff line change
@@ -1,35 +1,97 @@
import { useDataQuery } from '@dhis2/app-runtime'
import i18n from '@dhis2/d2-i18n'
import { Button, NoticeBox } from '@dhis2/ui'
import { CenteredContent, CircularLoader, Button, NoticeBox } from '@dhis2/ui'
import PropTypes from 'prop-types'
import React from 'react'
import React, { useState } from 'react'
import PageHeader from '../../components/PageHeader/PageHeader.js'
import { i18nKeys } from '../../i18n-keys.js'
import Issues from './Issues/Issues.js'
import { useDataIntegrity } from './use-data-integrity.js'
import styles from './DataIntegrity.module.css'
import Section from './Section.js'

const DataIntegrity = ({ sectionKey }) => {
const { startDataIntegrityCheck, loading, error, issues } =
useDataIntegrity()
const query = {
checks: {
resource: 'dataIntegrity',
},
}

const groupChecks = (checks) =>
checks.reduce((groupedChecks, check) => {
if (!(check.section in groupedChecks)) {
groupedChecks[check.section] = []
}
groupedChecks[check.section].push(check)
return groupedChecks
}, {})

const DataIntegrity = () => {
const { loading, error, data } = useDataQuery(query)
const [selectedChecks, setSelectedChecks] = useState(new Set())
// XXX
const [submitting, setSubmitting] = useState(false)

const startDataIntegrityCheck = () => {
setSubmitting(true)
}

if (loading) {
return (
<CenteredContent>
<CircularLoader />
</CenteredContent>
)
}

if (error) {
return (
<NoticeBox
title={i18n.t('Failed to load available data integrity checks')}
error
className={styles.noticeBox}
>
{error.message}
</NoticeBox>
)
}

const groupedChecks = groupChecks(data.checks)

return (
<>
<PageHeader
sectionKey={sectionKey}
title={i18nKeys.dataIntegrity.title}
/>
{error && <NoticeBox error>{error.message}</NoticeBox>}
{issues && <Issues issues={issues} />}
<Button primary loading={loading} onClick={startDataIntegrityCheck}>
{loading
{Object.entries(groupedChecks).map(([section, checks]) => (
<Section
key={section}
name={section}
checks={checks}
selectedChecks={selectedChecks}
setSelectedChecks={setSelectedChecks}
/>
))}
<Button
primary
disabled={selectedChecks.size === 0}
loading={submitting}
onClick={startDataIntegrityCheck}
>
{submitting
? i18n.t('Checking data integrity...')
: i18n.t('Run integrity checks')}
</Button>
</>
)
}

DataIntegrity.propTypes = {
const DataIntegrityPage = ({ sectionKey }) => (
<>
<PageHeader
sectionKey={sectionKey}
title={i18nKeys.dataIntegrity.title}
/>
<DataIntegrity />
</>
)

DataIntegrityPage.propTypes = {
sectionKey: PropTypes.string.isRequired,
}

export default DataIntegrity
export default DataIntegrityPage
3 changes: 3 additions & 0 deletions src/pages/data-integrity/DataIntegrity.module.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
.noticeBox {
max-width: 400px;
}
97 changes: 0 additions & 97 deletions src/pages/data-integrity/Issues/IssueCard.js

This file was deleted.

Loading