diff --git a/Makefile b/Makefile index 6bd91b2e52..204b93c325 100755 --- a/Makefile +++ b/Makefile @@ -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 \ diff --git a/modules/statistics/css/WidgetIndex.css b/modules/statistics/css/WidgetIndex.css index eb3179bc69..5d61ae8d23 100644 --- a/modules/statistics/css/WidgetIndex.css +++ b/modules/statistics/css/WidgetIndex.css @@ -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; } @@ -206,4 +215,4 @@ .filter-grid { grid-template-columns: 1fr; } -} \ No newline at end of file +} diff --git a/modules/statistics/jsx/WidgetIndex.js b/modules/statistics/jsx/WidgetIndex.js index 62184b37f6..bb0d4b41b9 100644 --- a/modules/statistics/jsx/WidgetIndex.js +++ b/modules/statistics/jsx/WidgetIndex.js @@ -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'; @@ -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) => ( +
+ {t('No data collected yet', {ns: 'statistics'})} +
+); /** * WidgetIndex - the main window. @@ -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. @@ -261,6 +294,7 @@ const WidgetIndex = (props) => { ); setRecruitmentData(data); setStudyProgressionData(data); + setWidgetsLoaded(true); }; setup().catch( (error) => { @@ -344,18 +378,46 @@ const WidgetIndex = (props) => { } - - + {hasNoCollectedData ? ( + <> + + {emptyState(t)} + + + {emptyState(t)} + + + ) : ( + <> + + + + )} ); }; diff --git a/modules/statistics/jsx/widgets/recruitment.js b/modules/statistics/jsx/widgets/recruitment.js index 5fd2f3455e..8e545de31a 100644 --- a/modules/statistics/jsx/widgets/recruitment.js +++ b/modules/statistics/jsx/widgets/recruitment.js @@ -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. @@ -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}; diff --git a/modules/statistics/jsx/widgets/studyprogression.js b/modules/statistics/jsx/widgets/studyprogression.js index d7bcf75e83..97619eeace 100644 --- a/modules/statistics/jsx/widgets/studyprogression.js +++ b/modules/statistics/jsx/widgets/studyprogression.js @@ -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. @@ -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}; diff --git a/modules/statistics/locale/fr/LC_MESSAGES/statistics.po b/modules/statistics/locale/fr/LC_MESSAGES/statistics.po index 95a2bd54f9..ef8ae974de 100644 --- a/modules/statistics/locale/fr/LC_MESSAGES/statistics.po +++ b/modules/statistics/locale/fr/LC_MESSAGES/statistics.po @@ -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}}" diff --git a/modules/statistics/locale/hi/LC_MESSAGES/statistics.po b/modules/statistics/locale/hi/LC_MESSAGES/statistics.po new file mode 100644 index 0000000000..d54b59fa91 --- /dev/null +++ b/modules/statistics/locale/hi/LC_MESSAGES/statistics.po @@ -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 \n" +"Language-Team: LANGUAGE \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 "बार" diff --git a/modules/statistics/locale/ja/LC_MESSAGES/statistics.po b/modules/statistics/locale/ja/LC_MESSAGES/statistics.po index 27f16d3005..bc4e9df655 100644 --- a/modules/statistics/locale/ja/LC_MESSAGES/statistics.po +++ b/modules/statistics/locale/ja/LC_MESSAGES/statistics.po @@ -112,6 +112,9 @@ msgstr "コホートの内訳" msgid "Total Participants: {{count}}" msgstr "参加者総数: {{count}}" +msgid "No data collected yet" +msgstr "まだデータが収集されていません" + msgid "Projects: {{count}}" msgstr "プロジェクト: {{count}}" diff --git a/modules/statistics/locale/statistics.pot b/modules/statistics/locale/statistics.pot index 8c0663063b..6305be48a9 100644 --- a/modules/statistics/locale/statistics.pot +++ b/modules/statistics/locale/statistics.pot @@ -111,6 +111,9 @@ msgstr "" msgid "Total Participants: {{count}}" msgstr "" +msgid "No data collected yet" +msgstr "" + msgid "Projects: {{count}}" msgstr "" diff --git a/modules/statistics/locale/zh/LC_MESSAGES/statistics.po b/modules/statistics/locale/zh/LC_MESSAGES/statistics.po index b5793d5774..5ad094a299 100644 --- a/modules/statistics/locale/zh/LC_MESSAGES/statistics.po +++ b/modules/statistics/locale/zh/LC_MESSAGES/statistics.po @@ -112,6 +112,9 @@ msgstr "群组细分" msgid "Total Participants: {{count}}" msgstr "参与者总数:{{count}}" +msgid "No data collected yet" +msgstr "尚未收集数据" + msgid "Projects: {{count}}" msgstr "项目:{{count}}"