Skip to content

Commit

Permalink
Merge branch 'CORE-4902-USRN-Certification' of github.com:oacore/dash…
Browse files Browse the repository at this point in the history
…board into CORE-4902-USRN-Certification
  • Loading branch information
mcancellieri committed Sep 2, 2024
2 parents f57bc46 + 11b9d9d commit 9626d02
Show file tree
Hide file tree
Showing 2 changed files with 103 additions and 62 deletions.
153 changes: 94 additions & 59 deletions components/usrn-stat/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,9 @@ import LinkDoc from '../usrn-text/linkDoc'
import { overview as textIrusUk } from 'texts/irus-uk/index'

const StatUSRN = ({ className, content, usrnParams }) => {
const STATUS_NO = 0
const STATUS_YES = 1
const STATUS_DEVELOP = 2
const {
doiCount,
totalDoiCount,
Expand All @@ -28,7 +31,6 @@ const StatUSRN = ({ className, content, usrnParams }) => {
rorId,
} = usrnParams
const { description: descriptionIrus } = textIrusUk

const enrichmentChart = ({ coveredCount, totalCount }) => {
let isLoading = true
if (
Expand Down Expand Up @@ -63,85 +65,107 @@ const StatUSRN = ({ className, content, usrnParams }) => {

let statCreated = ''
let statTextCreated = ''
let statusClass = false
let statusClass = STATUS_NO
switch (content.id) {
case 'accessibilityStatements':
statusClass = STATUS_DEVELOP
break
case 'ORCID':
statusClass = STATUS_DEVELOP
break
case 'repositoryOAIPMH':
// Just text layout
statusClass = true
statusClass = STATUS_NO
break
case 'applicationProfile':
statusClass = !!(rioxxTotalCount && rioxxPartiallyCompliantCount)
statCreated = statusClass
? enrichmentChart({
coveredCount: rioxxPartiallyCompliantCount,
totalCount: rioxxTotalCount,
})
: ''
statusClass =
rioxxTotalCount && rioxxPartiallyCompliantCount ? STATUS_YES : STATUS_NO
statCreated =
statusClass === STATUS_YES
? enrichmentChart({
coveredCount: rioxxPartiallyCompliantCount,
totalCount: rioxxTotalCount,
})
: ''
break
case 'accessFullTexts':
statCreated = enrichmentChart({
coveredCount: countFulltext,
totalCount: countMetadata,
})
statusClass = true
statusClass = countFulltext && countMetadata ? STATUS_YES : STATUS_NO
statCreated =
statusClass === STATUS_YES
? enrichmentChart({
coveredCount: countFulltext,
totalCount: countMetadata,
})
: ''
break
case 'embargoedDocuments':
statusClass = !!embargoedDocuments
statTextCreated = statusClass ? (
<NumericValue
value={valueOrDefault(embargoedDocuments, 'Loading...')}
size="extra-small"
/>
) : (
''
)
statusClass = embargoedDocuments ? STATUS_YES : STATUS_NO
statTextCreated =
statusClass === STATUS_YES ? (
<NumericValue
value={valueOrDefault(embargoedDocuments, 'Loading...')}
size="extra-small"
/>
) : (
''
)
break
case 'vocabulariesCOAR':
statusClass = usrnVocabulariesCOAR && usrnVocabulariesCOAR > 0
statCreated =
statusClass =
usrnVocabulariesCOAR && usrnVocabulariesCOAR > 0
? usrnVocabulariesCOAR
: ''
? STATUS_YES
: STATUS_NO

statCreated = statusClass === STATUS_YES ? usrnVocabulariesCOAR : ''
break
case 'webAccessibility':
statusClass = supportsBetterMetadata ? STATUS_YES : STATUS_NO
statCreated = ''
statusClass = supportsBetterMetadata
break
case 'signpostingFAIR':
statusClass = supportSignposting ? STATUS_YES : STATUS_NO
statCreated = ''
statusClass = supportSignposting
break
case 'licensingMetadata':
statTextCreated = (
<NumericValue
value={valueOrDefault(usrnLicense, 'Loading...')}
size="extra-small"
/>
)
statusClass = true
statusClass = usrnLicense ? STATUS_YES : STATUS_NO
statTextCreated =
statusClass === STATUS_YES ? (
<NumericValue
value={valueOrDefault(usrnLicense, 'Loading...')}
size="extra-small"
/>
) : (
''
)
break
case 'ROR':
statusClass = !!rorId
statusClass = rorId ? STATUS_YES : STATUS_NO
break
case 'doi':
statCreated = enrichmentChart({
coveredCount: doiCount,
totalCount: totalDoiCount,
})
statusClass = true
statusClass = doiCount && totalDoiCount ? STATUS_YES : STATUS_NO
statCreated =
statusClass === STATUS_YES
? enrichmentChart({
coveredCount: doiCount,
totalCount: totalDoiCount,
})
: ''
break
case 'indexedContent':
statTextCreated = (
<NumericValue
value={valueOrDefault(countMetadata, 'Loading...')}
size="extra-small"
/>
)
statusClass = true
statusClass = countMetadata ? STATUS_YES : STATUS_NO
statTextCreated =
statusClass === STATUS_YES ? (
<NumericValue
value={valueOrDefault(countMetadata, 'Loading...')}
size="extra-small"
/>
) : (
''
)
break
case 'statisticIRUS':
statusClass = statisticsIrus != null ? STATUS_YES : STATUS_NO
statCreated =
statisticsIrus != null ? (
statusClass === STATUS_YES ? (
<div>
<StatisticsChart
data={statisticsIrus.map(({ date, coreViewCount: count }) => ({
Expand All @@ -158,16 +182,15 @@ const StatUSRN = ({ className, content, usrnParams }) => {
</Markdown>
</div>
) : (
'Loading...'
''
)
statusClass = true
break
default:
statCreated = ''
}

const descriptionCreated = content.description ? (
<div className={styles.description}>{content.description}</div>
<Markdown className={styles.description}>{content.description}</Markdown>
) : (
<div className={styles.descriptionEmpty} />
)
Expand All @@ -190,9 +213,9 @@ const StatUSRN = ({ className, content, usrnParams }) => {
<img src={infoLight} alt="info" />
<span className={styles.text}>Recommendation</span>
</div>
<div className={styles.recommendationContent}>
<Markdown className={styles.recommendationContent}>
{content.recommendation}
</div>
</Markdown>
</div>
) : (
''
Expand All @@ -208,10 +231,22 @@ const StatUSRN = ({ className, content, usrnParams }) => {
<div
className={classNames.use(
styles.status,
statusClass ? styles.statusSuccess : styles.statusFail
// eslint-disable-next-line no-nested-ternary
statusClass === STATUS_NO
? styles.status0
: statusClass === STATUS_YES
? styles.status1
: styles.status2
)}
>
{statusClass ? 'Yes' : 'No'}
{
// eslint-disable-next-line no-nested-ternary
statusClass === STATUS_NO
? 'No'
: statusClass === STATUS_YES
? 'Yes'
: 'Develop'
}
</div>
</div>
<div className={styles.statusRow}>
Expand Down
12 changes: 9 additions & 3 deletions components/usrn-stat/styles.module.css
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@
padding: 15px 0 15px 20px;
font-size: 16px;
font-weight: 500;
text-align: left;
letter-spacing: 0.0006em;
background-color: #f5f5f5;
text-align: left;
}

.status-row {
Expand Down Expand Up @@ -91,18 +91,24 @@
text-align: left;
}

.status-success {
.status-2 {
color: #939393;
background-color: #f5f5f5;
}

.status-1 {
color: #5a9216;
background-color: #ecf6df;
}

.status-fail {
.status-0 {
color: #c62828;
background-color: #fcc;
}

.status {
padding: 15px 5px;
font-size: 14px;
font-weight: 500;
}

Expand Down

0 comments on commit 9626d02

Please sign in to comment.