@dhis2/analytics 22.0.0-alpha.2 → 23.0.0-alpha.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/build/cjs/__demo__/FileMenu.stories.js +9 -17
- package/build/cjs/__demo__/OpenFileDialog.stories.js +39 -6
- package/build/cjs/__fixtures__/fixtures.js +1 -0
- package/build/cjs/__fixtures__/json/api/analytics/enrollments.json +206 -0
- package/build/cjs/api/analytics/Analytics.js +6 -0
- package/build/cjs/api/analytics/AnalyticsEnrollments.js +48 -0
- package/build/cjs/api/analytics/__tests__/AnalyticsEnrollments.spec.js +50 -0
- package/build/cjs/api/analytics/__tests__/__snapshots__/AnalyticsEnrollments.spec.js.snap +3 -0
- package/build/cjs/components/CachedDataQueryProvider.js +70 -0
- package/build/cjs/components/FileMenu/FileMenu.js +3 -4
- package/build/cjs/components/FileMenu/__tests__/FileMenu.spec.js +3 -5
- package/build/cjs/components/FileMenu/utils.js +1 -1
- package/build/cjs/components/OpenFileDialog/CustomSelectOption.js +2 -2
- package/build/cjs/components/OpenFileDialog/OpenFileDialog.js +12 -8
- package/build/cjs/components/OpenFileDialog/OpenFileDialog.styles.js +2 -2
- package/build/cjs/components/OpenFileDialog/utils.js +37 -59
- package/build/cjs/index.js +14 -0
- package/build/cjs/locales/ar/translations.json +9 -0
- package/build/cjs/locales/ar_EG/translations.json +9 -0
- package/build/cjs/locales/ar_IQ/translations.json +9 -0
- package/build/cjs/locales/ckb/translations.json +9 -0
- package/build/cjs/locales/cs/translations.json +17 -8
- package/build/cjs/locales/da/translations.json +9 -0
- package/build/cjs/locales/en/translations.json +9 -7
- package/build/cjs/locales/es/translations.json +9 -0
- package/build/cjs/locales/fr/translations.json +9 -0
- package/build/cjs/locales/id/translations.json +9 -0
- package/build/cjs/locales/km/translations.json +9 -0
- package/build/cjs/locales/lo/translations.json +9 -0
- package/build/cjs/locales/my/translations.json +9 -0
- package/build/cjs/locales/nb/translations.json +9 -0
- package/build/cjs/locales/nl/translations.json +9 -0
- package/build/cjs/locales/prs/translations.json +9 -0
- package/build/cjs/locales/ps/translations.json +9 -0
- package/build/cjs/locales/pt/translations.json +9 -0
- package/build/cjs/locales/pt_BR/translations.json +9 -0
- package/build/cjs/locales/ru/translations.json +9 -0
- package/build/cjs/locales/sv/translations.json +9 -0
- package/build/cjs/locales/tet/translations.json +9 -0
- package/build/cjs/locales/tg/translations.json +9 -0
- package/build/cjs/locales/uk/translations.json +9 -0
- package/build/cjs/locales/ur/translations.json +9 -0
- package/build/cjs/locales/uz/translations.json +9 -0
- package/build/cjs/locales/uz_Latn/translations.json +9 -0
- package/build/cjs/locales/vi/translations.json +9 -0
- package/build/cjs/locales/zh/translations.json +10 -1
- package/build/cjs/locales/zh_CN/translations.json +9 -0
- package/build/cjs/modules/layoutUiRules/rules.js +5 -1
- package/build/es/__demo__/FileMenu.stories.js +9 -17
- package/build/es/__demo__/OpenFileDialog.stories.js +38 -6
- package/build/es/__fixtures__/fixtures.js +1 -0
- package/build/es/__fixtures__/json/api/analytics/enrollments.json +206 -0
- package/build/es/api/analytics/Analytics.js +5 -0
- package/build/es/api/analytics/AnalyticsEnrollments.js +38 -0
- package/build/es/api/analytics/__tests__/AnalyticsEnrollments.spec.js +40 -0
- package/build/es/api/analytics/__tests__/__snapshots__/AnalyticsEnrollments.spec.js.snap +3 -0
- package/build/es/components/CachedDataQueryProvider.js +50 -0
- package/build/es/components/FileMenu/FileMenu.js +3 -4
- package/build/es/components/FileMenu/__tests__/FileMenu.spec.js +3 -5
- package/build/es/components/FileMenu/utils.js +1 -1
- package/build/es/components/OpenFileDialog/CustomSelectOption.js +2 -2
- package/build/es/components/OpenFileDialog/OpenFileDialog.js +12 -8
- package/build/es/components/OpenFileDialog/OpenFileDialog.styles.js +2 -2
- package/build/es/components/OpenFileDialog/utils.js +35 -56
- package/build/es/index.js +2 -1
- package/build/es/locales/ar/translations.json +9 -0
- package/build/es/locales/ar_EG/translations.json +9 -0
- package/build/es/locales/ar_IQ/translations.json +9 -0
- package/build/es/locales/ckb/translations.json +9 -0
- package/build/es/locales/cs/translations.json +17 -8
- package/build/es/locales/da/translations.json +9 -0
- package/build/es/locales/en/translations.json +9 -7
- package/build/es/locales/es/translations.json +9 -0
- package/build/es/locales/fr/translations.json +9 -0
- package/build/es/locales/id/translations.json +9 -0
- package/build/es/locales/km/translations.json +9 -0
- package/build/es/locales/lo/translations.json +9 -0
- package/build/es/locales/my/translations.json +9 -0
- package/build/es/locales/nb/translations.json +9 -0
- package/build/es/locales/nl/translations.json +9 -0
- package/build/es/locales/prs/translations.json +9 -0
- package/build/es/locales/ps/translations.json +9 -0
- package/build/es/locales/pt/translations.json +9 -0
- package/build/es/locales/pt_BR/translations.json +9 -0
- package/build/es/locales/ru/translations.json +9 -0
- package/build/es/locales/sv/translations.json +9 -0
- package/build/es/locales/tet/translations.json +9 -0
- package/build/es/locales/tg/translations.json +9 -0
- package/build/es/locales/uk/translations.json +9 -0
- package/build/es/locales/ur/translations.json +9 -0
- package/build/es/locales/uz/translations.json +9 -0
- package/build/es/locales/uz_Latn/translations.json +9 -0
- package/build/es/locales/vi/translations.json +9 -0
- package/build/es/locales/zh/translations.json +10 -1
- package/build/es/locales/zh_CN/translations.json +9 -0
- package/build/es/modules/layoutUiRules/rules.js +6 -2
- package/package.json +2 -2
|
@@ -0,0 +1,206 @@
|
|
|
1
|
+
{
|
|
2
|
+
"headers": [
|
|
3
|
+
{
|
|
4
|
+
"name": "pi",
|
|
5
|
+
"column": "Enrollment",
|
|
6
|
+
"valueType": "TEXT",
|
|
7
|
+
"type": "java.lang.String",
|
|
8
|
+
"hidden": false,
|
|
9
|
+
"meta": true
|
|
10
|
+
},
|
|
11
|
+
{
|
|
12
|
+
"name": "tei",
|
|
13
|
+
"column": "Tracked entity instance",
|
|
14
|
+
"valueType": "TEXT",
|
|
15
|
+
"type": "java.lang.String",
|
|
16
|
+
"hidden": false,
|
|
17
|
+
"meta": true
|
|
18
|
+
},
|
|
19
|
+
{
|
|
20
|
+
"name": "enrollmentdate",
|
|
21
|
+
"column": "Enrollment date",
|
|
22
|
+
"valueType": "DATE",
|
|
23
|
+
"type": "java.util.Date",
|
|
24
|
+
"hidden": false,
|
|
25
|
+
"meta": true
|
|
26
|
+
},
|
|
27
|
+
{
|
|
28
|
+
"name": "incidentdate",
|
|
29
|
+
"column": "Incident date",
|
|
30
|
+
"valueType": "DATE",
|
|
31
|
+
"type": "java.util.Date",
|
|
32
|
+
"hidden": false,
|
|
33
|
+
"meta": true
|
|
34
|
+
},
|
|
35
|
+
{
|
|
36
|
+
"name": "geometry",
|
|
37
|
+
"column": "Geometry",
|
|
38
|
+
"valueType": "TEXT",
|
|
39
|
+
"type": "java.lang.String",
|
|
40
|
+
"hidden": false,
|
|
41
|
+
"meta": true
|
|
42
|
+
},
|
|
43
|
+
{
|
|
44
|
+
"name": "longitude",
|
|
45
|
+
"column": "Longitude",
|
|
46
|
+
"valueType": "NUMBER",
|
|
47
|
+
"type": "java.lang.Double",
|
|
48
|
+
"hidden": false,
|
|
49
|
+
"meta": true
|
|
50
|
+
},
|
|
51
|
+
{
|
|
52
|
+
"name": "latitude",
|
|
53
|
+
"column": "Latitude",
|
|
54
|
+
"valueType": "NUMBER",
|
|
55
|
+
"type": "java.lang.Double",
|
|
56
|
+
"hidden": false,
|
|
57
|
+
"meta": true
|
|
58
|
+
},
|
|
59
|
+
{
|
|
60
|
+
"name": "ouname",
|
|
61
|
+
"column": "Organisation unit name",
|
|
62
|
+
"valueType": "TEXT",
|
|
63
|
+
"type": "java.lang.String",
|
|
64
|
+
"hidden": false,
|
|
65
|
+
"meta": true
|
|
66
|
+
},
|
|
67
|
+
{
|
|
68
|
+
"name": "oucode",
|
|
69
|
+
"column": "Organisation unit code",
|
|
70
|
+
"valueType": "TEXT",
|
|
71
|
+
"type": "java.lang.String",
|
|
72
|
+
"hidden": false,
|
|
73
|
+
"meta": true
|
|
74
|
+
},
|
|
75
|
+
{
|
|
76
|
+
"name": "ou",
|
|
77
|
+
"column": "Organisation unit",
|
|
78
|
+
"valueType": "TEXT",
|
|
79
|
+
"type": "java.lang.String",
|
|
80
|
+
"hidden": false,
|
|
81
|
+
"meta": true
|
|
82
|
+
},
|
|
83
|
+
{
|
|
84
|
+
"name": "de0FEHSIoxh",
|
|
85
|
+
"column": "WHOMCH Chronic conditions",
|
|
86
|
+
"valueType": "BOOLEAN",
|
|
87
|
+
"type": "java.lang.Boolean",
|
|
88
|
+
"hidden": false,
|
|
89
|
+
"meta": true
|
|
90
|
+
},
|
|
91
|
+
{
|
|
92
|
+
"name": "sWoqcoByYmD",
|
|
93
|
+
"column": "WHOMCH Smoking",
|
|
94
|
+
"valueType": "BOOLEAN",
|
|
95
|
+
"type": "java.lang.Boolean",
|
|
96
|
+
"hidden": false,
|
|
97
|
+
"meta": true
|
|
98
|
+
}
|
|
99
|
+
],
|
|
100
|
+
"metaData": {
|
|
101
|
+
"pager": {
|
|
102
|
+
"page": 2,
|
|
103
|
+
"total": 163,
|
|
104
|
+
"pageSize": 4,
|
|
105
|
+
"pageCount": 41
|
|
106
|
+
},
|
|
107
|
+
"items": {
|
|
108
|
+
"ImspTQPwCqd": {
|
|
109
|
+
"name": "Sierra Leone"
|
|
110
|
+
},
|
|
111
|
+
"PFDfvmGpsR3": {
|
|
112
|
+
"name": "Care at birth"
|
|
113
|
+
},
|
|
114
|
+
"bbKtnxRZKEP": {
|
|
115
|
+
"name": "Postpartum care visit"
|
|
116
|
+
},
|
|
117
|
+
"ou": {
|
|
118
|
+
"name": "Organisation unit"
|
|
119
|
+
},
|
|
120
|
+
"PUZaKR0Jh2k": {
|
|
121
|
+
"name": "Previous deliveries"
|
|
122
|
+
},
|
|
123
|
+
"edqlbukwRfQ": {
|
|
124
|
+
"name": "Antenatal care visit"
|
|
125
|
+
},
|
|
126
|
+
"WZbXY0S00lP": {
|
|
127
|
+
"name": "First antenatal care visit"
|
|
128
|
+
},
|
|
129
|
+
"sWoqcoByYmD": {
|
|
130
|
+
"name": "WHOMCH Smoking"
|
|
131
|
+
},
|
|
132
|
+
"WSGAb5XwJ3Y": {
|
|
133
|
+
"name": "WHO RMNCH Tracker"
|
|
134
|
+
},
|
|
135
|
+
"de0FEHSIoxh": {
|
|
136
|
+
"name": "WHOMCH Chronic conditions"
|
|
137
|
+
}
|
|
138
|
+
},
|
|
139
|
+
"dimensions": {
|
|
140
|
+
"pe": [],
|
|
141
|
+
"ou": ["ImspTQPwCqd"],
|
|
142
|
+
"sWoqcoByYmD": [],
|
|
143
|
+
"de0FEHSIoxh": []
|
|
144
|
+
}
|
|
145
|
+
},
|
|
146
|
+
"width": 12,
|
|
147
|
+
"rows": [
|
|
148
|
+
[
|
|
149
|
+
"A0cP533hIQv",
|
|
150
|
+
"to8G9jAprnx",
|
|
151
|
+
"2019-02-02 12:05:00.0",
|
|
152
|
+
"2019-02-02 12:05:00.0",
|
|
153
|
+
"",
|
|
154
|
+
"0.0",
|
|
155
|
+
"0.0",
|
|
156
|
+
"Tonkomba MCHP",
|
|
157
|
+
"OU_193264",
|
|
158
|
+
"xIMxph4NMP1",
|
|
159
|
+
"0",
|
|
160
|
+
"1"
|
|
161
|
+
],
|
|
162
|
+
[
|
|
163
|
+
"ZqiUn2uXmBi",
|
|
164
|
+
"SJtv0WzoYki",
|
|
165
|
+
"2019-02-02 12:05:00.0",
|
|
166
|
+
"2019-02-02 12:05:00.0",
|
|
167
|
+
"",
|
|
168
|
+
"0.0",
|
|
169
|
+
"0.0",
|
|
170
|
+
"Mawoma MCHP",
|
|
171
|
+
"OU_254973",
|
|
172
|
+
"Srnpwq8jKbp",
|
|
173
|
+
"0",
|
|
174
|
+
"0"
|
|
175
|
+
],
|
|
176
|
+
[
|
|
177
|
+
"lE747mUAtbz",
|
|
178
|
+
"PGzTv2A1xzn",
|
|
179
|
+
"2019-02-02 12:05:00.0",
|
|
180
|
+
"2019-02-02 12:05:00.0",
|
|
181
|
+
"",
|
|
182
|
+
"0.0",
|
|
183
|
+
"0.0",
|
|
184
|
+
"Kunsho CHP",
|
|
185
|
+
"OU_193254",
|
|
186
|
+
"tdhB1JXYBx2",
|
|
187
|
+
"",
|
|
188
|
+
"0"
|
|
189
|
+
],
|
|
190
|
+
[
|
|
191
|
+
"nmcqu9QF8ow",
|
|
192
|
+
"pav3tGLjYuq",
|
|
193
|
+
"2019-02-03 12:05:00.0",
|
|
194
|
+
"2019-02-03 12:05:00.0",
|
|
195
|
+
"",
|
|
196
|
+
"0.0",
|
|
197
|
+
"0.0",
|
|
198
|
+
"Korbu MCHP",
|
|
199
|
+
"OU_678893",
|
|
200
|
+
"m73lWmo5BDG",
|
|
201
|
+
"",
|
|
202
|
+
"1"
|
|
203
|
+
]
|
|
204
|
+
],
|
|
205
|
+
"height": 4
|
|
206
|
+
}
|
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
* @module analytics
|
|
3
3
|
*/
|
|
4
4
|
import AnalyticsAggregate from './AnalyticsAggregate.js';
|
|
5
|
+
import AnalyticsEnrollments from './AnalyticsEnrollments.js';
|
|
5
6
|
import AnalyticsEvents from './AnalyticsEvents.js';
|
|
6
7
|
import AnalyticsRequest from './AnalyticsRequest.js';
|
|
7
8
|
import AnalyticsResponse from './AnalyticsResponse.js';
|
|
@@ -30,17 +31,20 @@ import AnalyticsResponse from './AnalyticsResponse.js';
|
|
|
30
31
|
class Analytics {
|
|
31
32
|
/**
|
|
32
33
|
* @param {!module:analytics.AnalyticsAggregate} analyticsAggregate The AnalyticsAggregate instance
|
|
34
|
+
* @param {!module:analytics.AnalyticsEnrollments} analyticsEnrollments The AnalyticsEnrollments instance
|
|
33
35
|
* @param {!module:analytics.AnalyticsEvents} analyticsEvents The AnalyticsEvents instance
|
|
34
36
|
* @param {!module:analytics.AnalyticsRequest} analyticsRequest The AnalyticsRequest class
|
|
35
37
|
* @param {!module:analytics.AnalyticsResponse} analyticsResponse The AnalyticsResponse class
|
|
36
38
|
*/
|
|
37
39
|
constructor({
|
|
38
40
|
aggregate,
|
|
41
|
+
enrollments,
|
|
39
42
|
events,
|
|
40
43
|
request,
|
|
41
44
|
response
|
|
42
45
|
}) {
|
|
43
46
|
this.aggregate = aggregate;
|
|
47
|
+
this.enrollments = enrollments;
|
|
44
48
|
this.events = events;
|
|
45
49
|
this.request = request;
|
|
46
50
|
this.response = response;
|
|
@@ -63,6 +67,7 @@ class Analytics {
|
|
|
63
67
|
if (!Analytics.getAnalytics.analytics) {
|
|
64
68
|
Analytics.getAnalytics.analytics = new Analytics({
|
|
65
69
|
aggregate: new AnalyticsAggregate(dataEngine),
|
|
70
|
+
enrollments: new AnalyticsEnrollments(dataEngine),
|
|
66
71
|
events: new AnalyticsEvents(dataEngine),
|
|
67
72
|
request: AnalyticsRequest,
|
|
68
73
|
response: AnalyticsResponse
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import AnalyticsBase from './AnalyticsBase.js';
|
|
2
|
+
/**
|
|
3
|
+
* @extends module:analytics.AnalyticsBase
|
|
4
|
+
*
|
|
5
|
+
* @description
|
|
6
|
+
* Analytics enrollments class used to request analytics enrollments data from Web API.
|
|
7
|
+
*
|
|
8
|
+
* @memberof module:analytics
|
|
9
|
+
*
|
|
10
|
+
* @see https://docs.dhis2.org/en/develop/using-the-api/dhis-core-version-236/analytics.html#webapi_enrollment_analytics
|
|
11
|
+
*/
|
|
12
|
+
|
|
13
|
+
class AnalyticsEnrollments extends AnalyticsBase {
|
|
14
|
+
/**
|
|
15
|
+
* @param {!AnalyticsRequest} req Request object
|
|
16
|
+
*
|
|
17
|
+
* @returns {Promise} Promise that resolves with the analytics query data from the api.
|
|
18
|
+
*
|
|
19
|
+
* @example
|
|
20
|
+
* const req = new analytics.request()
|
|
21
|
+
* .withProgram('eBAyeGv0exc')
|
|
22
|
+
* .addDataDimension(['Uvn6LCg7dVU','OdiHJayrsKo'])
|
|
23
|
+
* .addPeriodDimension('LAST_4_QUARTERS')
|
|
24
|
+
* .addOrgUnitDimension(['lc3eMKXaEfw','PMa2VCrupOd'])
|
|
25
|
+
* .addOrgUnitFilter('O6uvpzGd5pu')
|
|
26
|
+
* .withStartDate('2017-10-01')
|
|
27
|
+
* .withEndDate('2017-10-31');
|
|
28
|
+
*
|
|
29
|
+
* analytics.enrollments.getQuery(req)
|
|
30
|
+
* .then(console.log);
|
|
31
|
+
*/
|
|
32
|
+
getQuery(req) {
|
|
33
|
+
return this.fetch(req.withPath('enrollments/query'));
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
export default AnalyticsEnrollments;
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import fixtures from '../../../__fixtures__/fixtures.js';
|
|
2
|
+
import DataEngineMock from '../__mocks__/DataEngine.js';
|
|
3
|
+
import AnalyticsEnrollments from '../AnalyticsEnrollments.js';
|
|
4
|
+
import AnalyticsRequest from '../AnalyticsRequest.js';
|
|
5
|
+
describe('analytics.enrollments', () => {
|
|
6
|
+
let enrollments;
|
|
7
|
+
let request;
|
|
8
|
+
let dataEngineMock;
|
|
9
|
+
let fixture;
|
|
10
|
+
beforeEach(() => {
|
|
11
|
+
dataEngineMock = new DataEngineMock();
|
|
12
|
+
DataEngineMock.mockClear();
|
|
13
|
+
enrollments = new AnalyticsEnrollments();
|
|
14
|
+
});
|
|
15
|
+
it('should not be allowed to be called without new', () => {
|
|
16
|
+
expect(() => AnalyticsEnrollments()).toThrowErrorMatchingSnapshot();
|
|
17
|
+
});
|
|
18
|
+
it('should use the dataEngine object when it is passed', () => {
|
|
19
|
+
const dataEngineMockObject = {};
|
|
20
|
+
enrollments = new AnalyticsEnrollments(dataEngineMockObject);
|
|
21
|
+
expect(enrollments.dataEngine).toBe(dataEngineMockObject);
|
|
22
|
+
});
|
|
23
|
+
describe('.getQuery()', () => {
|
|
24
|
+
beforeEach(() => {
|
|
25
|
+
enrollments = new AnalyticsEnrollments(new DataEngineMock());
|
|
26
|
+
request = new AnalyticsRequest().addOrgUnitDimension('ImspTQPwCqd').addDimension('WZbXY0S00lP.de0FEHSIoxh').addDimension('WZbXY0S00lP.sWoqcoByYmD').addPeriodFilter('LAST_MONTH').withProgram('WSGAb5XwJ3Y').withStage('WZbXY0S00lP').withAsc('ENROLLMENTDATE').withOuMode('DESCENDANTS').withColumns('w75KJ2mc4zz').withPage(1).withPageSize(10);
|
|
27
|
+
fixture = fixtures.get('/api/analytics/enrollments');
|
|
28
|
+
dataEngineMock.query.mockReturnValue(Promise.resolve({
|
|
29
|
+
data: fixture
|
|
30
|
+
}));
|
|
31
|
+
});
|
|
32
|
+
it('should be a function', () => {
|
|
33
|
+
expect(enrollments.getQuery).toBeInstanceOf(Function);
|
|
34
|
+
});
|
|
35
|
+
it('should resolve a promise with data', () => enrollments.getQuery(request).then(data => {
|
|
36
|
+
expect(data.width).toEqual(fixture.width);
|
|
37
|
+
expect(data.height).toEqual(fixture.height);
|
|
38
|
+
}));
|
|
39
|
+
});
|
|
40
|
+
});
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import { useDataQuery } from '@dhis2/app-runtime';
|
|
2
|
+
import i18n from '@dhis2/d2-i18n';
|
|
3
|
+
import { Layer, CenteredContent, CircularLoader, NoticeBox } from '@dhis2/ui';
|
|
4
|
+
import PropTypes from 'prop-types';
|
|
5
|
+
import React, { createContext, useContext } from 'react';
|
|
6
|
+
const CachedDataQueryCtx = /*#__PURE__*/createContext({});
|
|
7
|
+
|
|
8
|
+
const CachedDataQueryProvider = ({
|
|
9
|
+
query,
|
|
10
|
+
dataTransformation,
|
|
11
|
+
children
|
|
12
|
+
}) => {
|
|
13
|
+
const {
|
|
14
|
+
data: rawData,
|
|
15
|
+
...rest
|
|
16
|
+
} = useDataQuery(query);
|
|
17
|
+
const {
|
|
18
|
+
error,
|
|
19
|
+
loading
|
|
20
|
+
} = rest;
|
|
21
|
+
const data = rawData && dataTransformation ? dataTransformation(rawData) : rawData;
|
|
22
|
+
|
|
23
|
+
if (loading) {
|
|
24
|
+
return /*#__PURE__*/React.createElement(Layer, {
|
|
25
|
+
translucent: true
|
|
26
|
+
}, /*#__PURE__*/React.createElement(CenteredContent, null, /*#__PURE__*/React.createElement(CircularLoader, null)));
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
if (error) {
|
|
30
|
+
const fallbackMsg = i18n.t('This app could not retrieve required data.');
|
|
31
|
+
return /*#__PURE__*/React.createElement(NoticeBox, {
|
|
32
|
+
error: true,
|
|
33
|
+
title: i18n.t('Network error')
|
|
34
|
+
}, error.message || fallbackMsg);
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
return /*#__PURE__*/React.createElement(CachedDataQueryCtx.Provider, {
|
|
38
|
+
value: data
|
|
39
|
+
}, children);
|
|
40
|
+
};
|
|
41
|
+
|
|
42
|
+
CachedDataQueryProvider.propTypes = {
|
|
43
|
+
children: PropTypes.node.isRequired,
|
|
44
|
+
query: PropTypes.object.isRequired,
|
|
45
|
+
dataTransformation: PropTypes.func
|
|
46
|
+
};
|
|
47
|
+
|
|
48
|
+
const useCachedDataQuery = () => useContext(CachedDataQueryCtx);
|
|
49
|
+
|
|
50
|
+
export { CachedDataQueryProvider, useCachedDataQuery };
|
|
@@ -12,8 +12,7 @@ import { RenameDialog } from './RenameDialog.js';
|
|
|
12
12
|
import { SaveAsDialog } from './SaveAsDialog.js';
|
|
13
13
|
import { supportedFileTypes } from './utils.js';
|
|
14
14
|
export const FileMenu = ({
|
|
15
|
-
|
|
16
|
-
// to be removed as soon as TranslateDialog and FavoritesDialog are rewritten
|
|
15
|
+
currentUser,
|
|
17
16
|
defaultFilterVisType,
|
|
18
17
|
fileType,
|
|
19
18
|
fileObject,
|
|
@@ -140,7 +139,7 @@ export const FileMenu = ({
|
|
|
140
139
|
onDialogClose();
|
|
141
140
|
},
|
|
142
141
|
onNew: onNew,
|
|
143
|
-
currentUser:
|
|
142
|
+
currentUser: currentUser
|
|
144
143
|
}), menuIsOpen && /*#__PURE__*/React.createElement(Layer, {
|
|
145
144
|
onClick: toggleMenu,
|
|
146
145
|
position: "fixed",
|
|
@@ -241,7 +240,7 @@ FileMenu.defaultProps = {
|
|
|
241
240
|
onTranslate: Function.prototype
|
|
242
241
|
};
|
|
243
242
|
FileMenu.propTypes = {
|
|
244
|
-
|
|
243
|
+
currentUser: PropTypes.object,
|
|
245
244
|
defaultFilterVisType: PropTypes.string,
|
|
246
245
|
fileObject: PropTypes.object,
|
|
247
246
|
fileType: PropTypes.oneOf(supportedFileTypes),
|
|
@@ -32,11 +32,9 @@ describe('The FileMenu component ', () => {
|
|
|
32
32
|
beforeEach(() => {
|
|
33
33
|
shallowFileMenu = undefined;
|
|
34
34
|
props = {
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
displayName: 'Test user'
|
|
39
|
-
}
|
|
35
|
+
currentUser: {
|
|
36
|
+
id: 'u1',
|
|
37
|
+
displayName: 'Test user'
|
|
40
38
|
},
|
|
41
39
|
fileType: 'visualization',
|
|
42
40
|
fileObject: undefined,
|
|
@@ -28,9 +28,9 @@ const CustomSelectOptionItem = ({
|
|
|
28
28
|
}) || "")
|
|
29
29
|
}, label), /*#__PURE__*/React.createElement(_JSXStyle, {
|
|
30
30
|
id: styles.__hash
|
|
31
|
-
}, styles)), insertDivider
|
|
31
|
+
}, styles)), insertDivider && /*#__PURE__*/React.createElement(MenuDivider, {
|
|
32
32
|
dense: true
|
|
33
|
-
})
|
|
33
|
+
}));
|
|
34
34
|
|
|
35
35
|
export const CustomSelectOption = props => props.disabled ? /*#__PURE__*/React.createElement(Tooltip, {
|
|
36
36
|
content: i18n.t('Not supported by this app yet')
|
|
@@ -127,18 +127,22 @@ export const OpenFileDialog = ({
|
|
|
127
127
|
refetch({
|
|
128
128
|
page,
|
|
129
129
|
sortField,
|
|
130
|
-
sortDirection
|
|
130
|
+
sortDirection,
|
|
131
|
+
filters: formatFilters()
|
|
131
132
|
});
|
|
132
133
|
}
|
|
133
134
|
}, [open, page, sortField, sortDirection]);
|
|
134
135
|
useEffect(() => {
|
|
135
|
-
//
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
136
|
+
// avoid fetching data when the dialog is first rendered (hidden)
|
|
137
|
+
if (open) {
|
|
138
|
+
// reset pagination when filters are applied/changed
|
|
139
|
+
setPage(1);
|
|
140
|
+
refetch({
|
|
141
|
+
sortField,
|
|
142
|
+
sortDirection,
|
|
143
|
+
filters: formatFilters()
|
|
144
|
+
});
|
|
145
|
+
}
|
|
142
146
|
}, [filters]);
|
|
143
147
|
const headers = [{
|
|
144
148
|
field: 'displayName',
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import { colors, spacers } from '@dhis2/ui';
|
|
2
|
-
export const styles = [".data-table-body.jsx-
|
|
3
|
-
styles.__hash = "
|
|
2
|
+
export const styles = [".data-table-body.jsx-1047699013{min-height:465px;}", ".pagination-controls.jsx-1047699013{width:100%;display:-webkit-box;display:-webkit-flex;display:-ms-flexbox;display:flex;-webkit-box-pack:end;-webkit-justify-content:flex-end;-ms-flex-pack:end;justify-content:flex-end;}", ".search-and-filter-bar.jsx-1047699013{display:-webkit-box;display:-webkit-flex;display:-ms-flexbox;display:flex;gap:".concat(spacers.dp4, ";-webkit-align-items:center;-webkit-box-align:center;-ms-flex-align:center;align-items:center;margin-bottom:").concat(spacers.dp8, ";}"), ".search-field-container.jsx-1047699013{min-width:220px;}", ".type-field-container.jsx-1047699013,.created-by-field-container.jsx-1047699013{min-width:180px;}", ".info-cell.jsx-1047699013{display:-webkit-box;display:-webkit-flex;display:-ms-flexbox;display:flex;-webkit-align-items:center;-webkit-box-align:center;-ms-flex-align:center;align-items:center;-webkit-box-pack:center;-webkit-justify-content:center;-ms-flex-pack:center;justify-content:center;margin:".concat(spacers.dp32, " 0;}"), ".info-container.jsx-1047699013{max-width:400px;display:-webkit-box;display:-webkit-flex;display:-ms-flexbox;display:flex;-webkit-flex-direction:column;-ms-flex-direction:column;flex-direction:column;-webkit-align-items:center;-webkit-box-align:center;-ms-flex-align:center;align-items:center;-webkit-box-pack:center;-webkit-justify-content:center;-ms-flex-pack:center;justify-content:center;}", ".info-text.jsx-1047699013{text-align:center;font-size:14px;line-height:19px;color:".concat(colors.grey700, ";}"), ".info-button.jsx-1047699013{margin-top:".concat(spacers.dp12, ";}")];
|
|
3
|
+
styles.__hash = "1047699013";
|
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
import i18n from '@dhis2/d2-i18n';
|
|
2
2
|
export const AO_TYPE_VISUALIZATION = 'visualization';
|
|
3
3
|
export const AO_TYPE_MAP = 'map';
|
|
4
|
-
export const
|
|
5
|
-
export const AO_TYPE_EVENT_REPORT = 'eventReport';
|
|
4
|
+
export const AO_TYPE_EVENT_VISUALIZATION = 'eventVisualization';
|
|
6
5
|
export const AOTypeMap = {
|
|
7
6
|
[AO_TYPE_VISUALIZATION]: {
|
|
8
7
|
apiEndpoint: 'visualizations'
|
|
@@ -10,15 +9,13 @@ export const AOTypeMap = {
|
|
|
10
9
|
[AO_TYPE_MAP]: {
|
|
11
10
|
apiEndpoint: 'maps'
|
|
12
11
|
},
|
|
13
|
-
[
|
|
14
|
-
apiEndpoint: '
|
|
15
|
-
},
|
|
16
|
-
[AO_TYPE_EVENT_REPORT]: {
|
|
17
|
-
apiEndpoint: 'eventReports'
|
|
12
|
+
[AO_TYPE_EVENT_VISUALIZATION]: {
|
|
13
|
+
apiEndpoint: 'eventVisualizations'
|
|
18
14
|
}
|
|
19
15
|
};
|
|
20
|
-
|
|
21
|
-
|
|
16
|
+
const NO_TYPE = 'NO_TYPE';
|
|
17
|
+
const texts = {
|
|
18
|
+
[NO_TYPE]: {
|
|
22
19
|
modalTitle: i18n.t('Open'),
|
|
23
20
|
loadingText: i18n.t('Loading'),
|
|
24
21
|
errorTitle: i18n.t("Couldn't load items"),
|
|
@@ -26,51 +23,33 @@ export const getTranslatedString = (type, key) => {
|
|
|
26
23
|
noDataText: i18n.t('No items found. Create a new to get started.'),
|
|
27
24
|
noFilteredDataText: i18n.t("No items found. Try adjusting your search or filter options to find what you're looking for."),
|
|
28
25
|
newButtonLabel: i18n.t('Create new')
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
};
|
|
57
|
-
break;
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
case 'eventReport':
|
|
61
|
-
{
|
|
62
|
-
texts = {
|
|
63
|
-
modalTitle: i18n.t('Open an event report'),
|
|
64
|
-
loadingText: i18n.t('Loading event reports'),
|
|
65
|
-
errorTitle: i18n.t("Couldn't load event reports"),
|
|
66
|
-
errorText: i18n.t('There was a problem loading event reports. Try again or contact your system administrator.'),
|
|
67
|
-
noDataText: i18n.t('No event reports found. Click New event report to get started.'),
|
|
68
|
-
noFilteredDataText: i18n.t("No event reports found. Try adjusting your search or filter options to find what you're looking for."),
|
|
69
|
-
newButtonLabel: i18n.t('New event report')
|
|
70
|
-
};
|
|
71
|
-
break;
|
|
72
|
-
}
|
|
26
|
+
},
|
|
27
|
+
[AO_TYPE_VISUALIZATION]: {
|
|
28
|
+
modalTitle: i18n.t('Open a visualization'),
|
|
29
|
+
loadingText: i18n.t('Loading visualizations'),
|
|
30
|
+
errorTitle: i18n.t("Couldn't load visualizations"),
|
|
31
|
+
errorText: i18n.t('There was a problem loading visualizations. Try again or contact your system administrator.'),
|
|
32
|
+
noDataText: i18n.t('No visualizations found. Click New visualization to get started.'),
|
|
33
|
+
noFilteredDataText: i18n.t("No visualizations found. Try adjusting your search or filter options to find what you're looking for."),
|
|
34
|
+
newButtonLabel: i18n.t('New visualization')
|
|
35
|
+
},
|
|
36
|
+
[AO_TYPE_MAP]: {
|
|
37
|
+
modalTitle: i18n.t('Open a map'),
|
|
38
|
+
loadingText: i18n.t('Loading maps'),
|
|
39
|
+
errorTitle: i18n.t("Couldn't load maps"),
|
|
40
|
+
errorText: i18n.t('There was a problem loading maps. Try again or contact your system administrator.'),
|
|
41
|
+
noDataText: i18n.t('No maps found. Click New map to get started.'),
|
|
42
|
+
noFilteredDataText: i18n.t("No maps found. Try adjusting your search or filter options to find what you're looking for."),
|
|
43
|
+
newButtonLabel: i18n.t('New map')
|
|
44
|
+
},
|
|
45
|
+
[AO_TYPE_EVENT_VISUALIZATION]: {
|
|
46
|
+
modalTitle: i18n.t('Open an event visualization'),
|
|
47
|
+
loadingText: i18n.t('Loading event visualizations'),
|
|
48
|
+
errorTitle: i18n.t("Couldn't load event visualizations"),
|
|
49
|
+
errorText: i18n.t('There was a problem loading event visualizations. Try again or contact your system administrator.'),
|
|
50
|
+
noDataText: i18n.t('No event visualizations found. Click New event visualization to get started.'),
|
|
51
|
+
noFilteredDataText: i18n.t("No event visualizations found. Try adjusting your search or filter options to find what you're looking for."),
|
|
52
|
+
newButtonLabel: i18n.t('New event visualization')
|
|
73
53
|
}
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
};
|
|
54
|
+
};
|
|
55
|
+
export const getTranslatedString = (type, key) => (texts[type] || texts[NO_TYPE])[key];
|
package/build/es/index.js
CHANGED
|
@@ -13,7 +13,8 @@ export { default as PivotTable } from './components/PivotTable/PivotTable.js';
|
|
|
13
13
|
export { default as FileMenu } from './components/FileMenu/FileMenu.js';
|
|
14
14
|
export { default as VisTypeIcon } from './components/VisTypeIcon.js';
|
|
15
15
|
export { default as LegendKey } from './components/LegendKey/LegendKey.js';
|
|
16
|
-
export { default as AboutAOUnit } from './components/AboutAOUnit/AboutAOUnit.js';
|
|
16
|
+
export { default as AboutAOUnit } from './components/AboutAOUnit/AboutAOUnit.js';
|
|
17
|
+
export { CachedDataQueryProvider, useCachedDataQuery } from './components/CachedDataQueryProvider.js'; // Api
|
|
17
18
|
|
|
18
19
|
export { default as Analytics } from './api/analytics/Analytics.js';
|
|
19
20
|
export { apiFetchDimensions, apiFetchRecommendedIds } from './api/dimensions.js';
|
|
@@ -20,6 +20,8 @@
|
|
|
20
20
|
"Unsubscribe": "",
|
|
21
21
|
"Subscribe to get updates about new interpretations.": "",
|
|
22
22
|
"Subscribe": "",
|
|
23
|
+
"This app could not retrieve required data.": "",
|
|
24
|
+
"Network error": "",
|
|
23
25
|
"Data Type": "نوع البيانات",
|
|
24
26
|
"All types": "جميع الأنواع",
|
|
25
27
|
"Totals only": "",
|
|
@@ -119,6 +121,13 @@
|
|
|
119
121
|
"No event reports found. Click New event report to get started.": "",
|
|
120
122
|
"No event reports found. Try adjusting your search or filter options to find what you're looking for.": "",
|
|
121
123
|
"New event report": "",
|
|
124
|
+
"Open an event visualization": "",
|
|
125
|
+
"Loading event visualizations": "",
|
|
126
|
+
"Couldn't load event visualizations": "",
|
|
127
|
+
"There was a problem loading event visualizations. Try again or contact your system administrator.": "",
|
|
128
|
+
"No event visualizations found. Click New event visualization to get started.": "",
|
|
129
|
+
"No event visualizations found. Try adjusting your search or filter options to find what you're looking for.": "",
|
|
130
|
+
"New event visualization": "",
|
|
122
131
|
"Options": "الخيارات",
|
|
123
132
|
"Hide": "إخفاء",
|
|
124
133
|
"Update": "تحديث",
|
|
@@ -20,6 +20,8 @@
|
|
|
20
20
|
"Unsubscribe": "",
|
|
21
21
|
"Subscribe to get updates about new interpretations.": "",
|
|
22
22
|
"Subscribe": "",
|
|
23
|
+
"This app could not retrieve required data.": "",
|
|
24
|
+
"Network error": "",
|
|
23
25
|
"Data Type": "",
|
|
24
26
|
"All types": "",
|
|
25
27
|
"Totals only": "",
|
|
@@ -119,6 +121,13 @@
|
|
|
119
121
|
"No event reports found. Click New event report to get started.": "",
|
|
120
122
|
"No event reports found. Try adjusting your search or filter options to find what you're looking for.": "",
|
|
121
123
|
"New event report": "",
|
|
124
|
+
"Open an event visualization": "",
|
|
125
|
+
"Loading event visualizations": "",
|
|
126
|
+
"Couldn't load event visualizations": "",
|
|
127
|
+
"There was a problem loading event visualizations. Try again or contact your system administrator.": "",
|
|
128
|
+
"No event visualizations found. Click New event visualization to get started.": "",
|
|
129
|
+
"No event visualizations found. Try adjusting your search or filter options to find what you're looking for.": "",
|
|
130
|
+
"New event visualization": "",
|
|
122
131
|
"Options": "",
|
|
123
132
|
"Hide": "",
|
|
124
133
|
"Update": "",
|