Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
mediremi committed Mar 2, 2022
1 parent a60b133 commit 4d7d4b3
Show file tree
Hide file tree
Showing 13 changed files with 259 additions and 413 deletions.
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
109 changes: 5 additions & 104 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-02-09T15:18:51.747Z\n"
"PO-Revision-Date: 2022-02-09T15:18:51.747Z\n"
"POT-Creation-Date: 2022-02-14T12:36:03.855Z\n"
"PO-Revision-Date: 2022-02-14T12:36:03.855Z\n"

msgid "Open user guide"
msgstr "Open user guide"
Expand Down Expand Up @@ -408,114 +408,15 @@ 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 "Organisation units violating exclusive group sets"
msgstr "Organisation units violating exclusive group sets"

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

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

msgid "Invalid validation rule left side expressions"
msgstr "Invalid validation rule left side expressions"

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

msgid "Invalid program indicator expressions"
msgstr "Invalid program indicator expressions"

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

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 "Program rule actions with no stage id"
msgstr "Program rule actions with no stage id"

msgid "Program indicators with no expression"
msgstr "Program indicators with no expression"

msgid "Indicators"
msgstr "Indicators"

Expand Down
100 changes: 79 additions & 21 deletions src/pages/data-integrity/DataIntegrity.js
Original file line number Diff line number Diff line change
@@ -1,39 +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'
import { i18nKeys } from '../../i18n-keys'
import Issues from './Issues/Issues'
import { useDataIntegrity } from './use-data-integrity'
import styles from './DataIntegrity.module.css'
import Section from './Section'

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.

40 changes: 0 additions & 40 deletions src/pages/data-integrity/Issues/IssueCard.module.css

This file was deleted.

Loading

0 comments on commit 4d7d4b3

Please sign in to comment.