Skip to content
Open
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
1 change: 1 addition & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ POFILES=locale/fr/LC_MESSAGES/loris.po \
modules/mri_violations/locale/es/LC_MESSAGES/mri_violations.po \
modules/statistics/locale/fr/LC_MESSAGES/statistics.po \
modules/statistics/locale/ja/LC_MESSAGES/statistics.po \
modules/statistics/locale/hi/LC_MESSAGES/statistics.po \
modules/server_processes_manager/locale/ja/LC_MESSAGES/server_processes_manager.po \
modules/server_processes_manager/locale/hi/LC_MESSAGES/server_processes_manager.po \
modules/module_manager/locale/fr/LC_MESSAGES/module_manager.po \
Expand Down
11 changes: 10 additions & 1 deletion modules/statistics/css/WidgetIndex.css
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,15 @@
width: 100%;
}

.statistics-empty-state {
margin: 20px;
padding: 32px;
text-align: center;
font-size: 1.8rem;
font-weight: 600;
color: #555;
}

.c3-chart-line.c3-target.c3-target-Total{
display: none !important;
}
Expand Down Expand Up @@ -206,4 +215,4 @@
.filter-grid {
grid-template-columns: 1fr;
}
}
}
86 changes: 74 additions & 12 deletions modules/statistics/jsx/WidgetIndex.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import StudyProgression from './widgets/studyprogression';
import {fetchData} from './Fetch';
import Modal from 'Modal';
import Loader from 'Loader';
import Panel from 'Panel';

import {useTranslation} from 'react-i18next';

Expand All @@ -15,6 +16,33 @@ import {setupCharts, unloadCharts} from './widgets/helpers/chartBuilder';
import jaStrings from '../locale/ja/LC_MESSAGES/statistics.json';
import frStrings from '../locale/fr/LC_MESSAGES/statistics.json';
import zhStrings from '../locale/zh/LC_MESSAGES/statistics.json';
import hiStrings from '../locale/hi/LC_MESSAGES/statistics.json';

/**
* Returns the total number of participants reported by the widget endpoint.
*
* @param {object} data - Widget endpoint data
* @return {number|null} The total participant count, or null before data loads.
*/
const getTotalParticipants = (data) => {
if (!data || !data.recruitment || !data.recruitment.overall) {
return null;
}

return Number(data.recruitment.overall.total_recruitment);
};

/**
* Empty panel content shown when the study has no collected data yet.
*
* @param {Function} t - Translation helper
* @return {JSX.Element}
*/
const emptyState = (t) => (
<div className='statistics-empty-state' role='status'>
{t('No data collected yet', {ns: 'statistics'})}
</div>
);

/**
* WidgetIndex - the main window.
Expand All @@ -25,12 +53,17 @@ import zhStrings from '../locale/zh/LC_MESSAGES/statistics.json';
const WidgetIndex = (props) => {
const [recruitmentData, setRecruitmentData] = useState({});
const [studyProgressionData, setStudyProgressionData] = useState({});
const [widgetsLoaded, setWidgetsLoaded] = useState(false);
const [modalChart, setModalChart] = useState(null);
const {t, i18n} = useTranslation();
const totalParticipants = getTotalParticipants(recruitmentData);
const hasNoCollectedData = widgetsLoaded && totalParticipants === 0;

useEffect( () => {
i18n.addResourceBundle('ja', 'statistics', jaStrings);
i18n.addResourceBundle('fr', 'statistics', frStrings);
i18n.addResourceBundle('zh', 'statistics', zhStrings);
i18n.addResourceBundle('hi', 'statistics', hiStrings);
}, []);

// used by recruitment.js and studyprogression.js to display each chart.
Expand Down Expand Up @@ -261,6 +294,7 @@ const WidgetIndex = (props) => {
);
setRecruitmentData(data);
setStudyProgressionData(data);
setWidgetsLoaded(true);
};
setup().catch(
(error) => {
Expand Down Expand Up @@ -344,18 +378,46 @@ const WidgetIndex = (props) => {
</a>
}
</Modal>
<Recruitment
data ={recruitmentData}
baseURL ={props.baseURL}
showChart ={showChart}
updateFilters ={updateFilters}
/>
<StudyProgression
data ={studyProgressionData}
baseURL ={props.baseURL}
showChart ={showChart}
updateFilters ={updateFilters}
/>
{hasNoCollectedData ? (
<>
<Panel
title={
t('Recruitment', {ns: 'statistics'})
+ ' — '
+ t('Overall', {ns: 'statistics'})
+ ' | '
+ t(
'Total Participants: {{count}}',
{ns: 'statistics', count: totalParticipants}
)
}
id='statistics_recruitment'
>
{emptyState(t)}
</Panel>
<Panel
title={t('Study Progression', {ns: 'statistics'})}
id='statistics_studyprogression'
>
{emptyState(t)}
</Panel>
</>
) : (
<>
<Recruitment
data ={recruitmentData}
baseURL ={props.baseURL}
showChart ={showChart}
updateFilters ={updateFilters}
/>
<StudyProgression
data ={studyProgressionData}
baseURL ={props.baseURL}
showChart ={showChart}
updateFilters ={updateFilters}
/>
</>
)}
</>
);
};
Expand Down
2 changes: 2 additions & 0 deletions modules/statistics/jsx/widgets/recruitment.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import {useTranslation} from 'react-i18next';
import {setupCharts} from './helpers/chartBuilder';
import jaStrings from '../../locale/ja/LC_MESSAGES/statistics.json';
import frStrings from '../../locale/fr/LC_MESSAGES/statistics.json';
import hiStrings from '../../locale/hi/LC_MESSAGES/statistics.json';

/**
* Recruitment - a widget containing statistics for recruitment data.
Expand Down Expand Up @@ -85,6 +86,7 @@ const Recruitment = (props) => {
useEffect( () => {
i18n.addResourceBundle('ja', 'statistics', jaStrings);
i18n.addResourceBundle('fr', 'statistics', frStrings);
i18n.addResourceBundle('hi', 'statistics', hiStrings);

// Re-set default state that depended on the translation
let newdetails = {...chartDetails};
Expand Down
2 changes: 2 additions & 0 deletions modules/statistics/jsx/widgets/studyprogression.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import {setupCharts} from './helpers/chartBuilder';
import {useTranslation} from 'react-i18next';
import jaStrings from '../../locale/ja/LC_MESSAGES/statistics.json';
import frStrings from '../../locale/fr/LC_MESSAGES/statistics.json';
import hiStrings from '../../locale/hi/LC_MESSAGES/statistics.json';

/**
* StudyProgression - a widget containing statistics for study data.
Expand All @@ -23,6 +24,7 @@ const StudyProgression = (props) => {
useEffect( () => {
i18n.addResourceBundle('ja', 'statistics', jaStrings);
i18n.addResourceBundle('fr', 'statistics', frStrings);
i18n.addResourceBundle('hi', 'statistics', hiStrings);

// Re-set default state that depended on the translation
let newdetails = {...chartDetails};
Expand Down
3 changes: 3 additions & 0 deletions modules/statistics/locale/fr/LC_MESSAGES/statistics.po
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,9 @@ msgstr "Répartition par cohorte"
msgid "Total Participants: {{count}}"
msgstr "Nombre total de participants : {{count}}"

msgid "No data collected yet"
msgstr "Aucune donnée collectée pour le moment"

msgid "Projects: {{count}}"
msgstr "Projets : {{count}}"

Expand Down
133 changes: 133 additions & 0 deletions modules/statistics/locale/hi/LC_MESSAGES/statistics.po
Original file line number Diff line number Diff line change
@@ -0,0 +1,133 @@
# Default LORIS strings to be translated (English).
# Copyright (C) 2025
# This file is distributed under the same license as the LORIS package.
#
msgid ""
msgstr ""
"Project-Id-Version: LORIS 27\n"
"Report-Msgid-Bugs-To: https://github.com/aces/Loris/issues\n"
"POT-Creation-Date: 2025-04-08 14:37-0400\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <LL@li.org>\n"
"Language: hi\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"

msgid "Statistics"
msgstr "आंकड़े"

msgid "Study Progression"
msgstr "अध्ययन प्रगति"

msgid "Summary"
msgstr "सारांश"

msgid "Site Scans"
msgstr "साइट स्कैन"

msgid "Site Recruitment"
msgstr "साइट भर्ती"

msgid "-- Clear Selection --"
msgstr "-- चयन साफ़ करें --"

msgid "Scan sessions per site"
msgstr "प्रति साइट स्कैन सत्र"

msgid "Recruitment per site"
msgstr "प्रति साइट भर्ती"

msgid "Download as PNG"
msgstr "PNG के रूप में डाउनलोड करें"

msgid "Labels"
msgstr "लेबल"

msgid "Date Registered"
msgstr "पंजीकरण तिथि"

msgid "Range Start"
msgstr "श्रेणी आरंभ"

msgid "Range End"
msgstr "श्रेणी समाप्ति"

msgid "Total recruitment by Age"
msgstr "आयु के अनुसार कुल भर्ती"

msgid "Ethnicity at Screening"
msgstr "स्क्रीनिंग के समय जातीयता"

msgid "Total Recruitment per Site"
msgstr "प्रति साइट कुल भर्ती"

msgid "Biological sex breakdown by site"
msgstr "साइट के अनुसार जैविक लिंग विवरण"

msgid "Candidate Age at Registration"
msgstr "पंजीकरण के समय उम्मीदवार की आयु"

msgid "Candidates registered"
msgstr "पंजीकृत उम्मीदवार"

msgid "Target: {{target}}"
msgstr "लक्ष्य: {{target}}"

msgid "Recruitment target of {{target}} was reached."
msgstr "{{target}} का भर्ती लक्ष्य प्राप्त हो गया।"

msgid "Recruitment target of {{target}} was not reached."
msgstr "{{target}} का भर्ती लक्ष्य प्राप्त नहीं हुआ।"

msgid "No target set"
msgstr "कोई लक्ष्य निर्धारित नहीं"

msgid "{{total}} total participants."
msgstr "कुल {{total}} प्रतिभागी।"

msgid "Overall Recruitment"
msgstr "समग्र भर्ती"

msgid "Recruitment"
msgstr "भर्ती"

msgid "Overall"
msgstr "समग्र"

msgid "Site Breakdown"
msgstr "साइट विवरण"

msgid "Project Breakdown"
msgstr "परियोजना विवरण"

msgid "Cohort Breakdown"
msgstr "कोहोर्ट विवरण"

msgid "Total Participants: {{count}}"
msgstr "कुल प्रतिभागी: {{count}}"

msgid "No data collected yet"
msgstr "अभी तक कोई डेटा एकत्र नहीं किया गया"

msgid "Projects: {{count}}"
msgstr "परियोजनाएं: {{count}}"

msgid "Cohorts: {{count}}"
msgstr "कोहोर्ट: {{count}}"

msgid "Age (Years)"
msgstr "आयु (वर्ष)"

msgid "Participants"
msgstr "प्रतिभागी"

msgid "Unknown"
msgstr "अज्ञात"

msgid "Pie"
msgstr "पाई"

msgid "Bar"
msgstr "बार"
3 changes: 3 additions & 0 deletions modules/statistics/locale/ja/LC_MESSAGES/statistics.po
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,9 @@ msgstr "コホートの内訳"
msgid "Total Participants: {{count}}"
msgstr "参加者総数: {{count}}"

msgid "No data collected yet"
msgstr "まだデータが収集されていません"

msgid "Projects: {{count}}"
msgstr "プロジェクト: {{count}}"

Expand Down
3 changes: 3 additions & 0 deletions modules/statistics/locale/statistics.pot
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,9 @@ msgstr ""
msgid "Total Participants: {{count}}"
msgstr ""

msgid "No data collected yet"
msgstr ""

msgid "Projects: {{count}}"
msgstr ""

Expand Down
3 changes: 3 additions & 0 deletions modules/statistics/locale/zh/LC_MESSAGES/statistics.po
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,9 @@ msgstr "群组细分"
msgid "Total Participants: {{count}}"
msgstr "参与者总数:{{count}}"

msgid "No data collected yet"
msgstr "尚未收集数据"

msgid "Projects: {{count}}"
msgstr "项目:{{count}}"

Expand Down
Loading