From 95232d4d141aaca1d69d43faaf1cb371514b84a0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20Henrik=20=C3=98verland?= Date: Wed, 28 Aug 2024 15:39:25 +0200 Subject: [PATCH 1/8] feat: use new endpoint --- package.json | 2 +- src/api/Layout.js | 16 +++++++++++++--- 2 files changed, 14 insertions(+), 4 deletions(-) diff --git a/package.json b/package.json index eeadbe9f..79332f97 100644 --- a/package.json +++ b/package.json @@ -66,7 +66,7 @@ "dhis": { "href": "..", "auth": "admin:district", - "devHref": "http://localhost:8080" + "devHref": "https://test.e2e.dhis2.org/analytics-41dev/" } } } diff --git a/src/api/Layout.js b/src/api/Layout.js index 5ccdb62e..944a1f1f 100644 --- a/src/api/Layout.js +++ b/src/api/Layout.js @@ -186,9 +186,19 @@ Layout.prototype.getDataTypeUrl = function() { var OUTPUT_TYPE_EVENT = optionConfig.getOutputType('event').id; var OUTPUT_TYPE_ENROLLMENT = optionConfig.getOutputType('enrollment').id; - var url = this.dataType === DATA_TYPE_AGG ? '/events/aggregate' : - this.outputType === OUTPUT_TYPE_EVENT ? '/events/query' : - '/enrollments/query'; + var urlMap = { + [OUTPUT_TYPE_EVENT]: { + [DATA_TYPE_AGG]: '/events/aggregate', + [DATA_TYPE_EVENT]: '/events/query', + }, + [OUTPUT_TYPE_ENROLLMENT]: { + [DATA_TYPE_AGG]: '/enrollments/aggregate', + [DATA_TYPE_EVENT]: '/enrollments/query', + } + } + + var url = urlMap[this.outputType][this.dataType] + console.log(url) return url || dimensionConfig.dataTypeUrl[dimensionConfig.getDefaultDataType()] || ''; }; From 64e2713b7a02d28f3d84ac551340427576a7c626 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20Henrik=20=C3=98verland?= Date: Thu, 29 Aug 2024 17:33:01 +0200 Subject: [PATCH 2/8] distinguish des from attrs and pis --- src/api/Dimension.js | 3 ++- src/api/Layout.js | 23 +++++++++++++++++------ 2 files changed, 19 insertions(+), 7 deletions(-) diff --git a/src/api/Dimension.js b/src/api/Dimension.js index 8f33781d..cde558de 100644 --- a/src/api/Dimension.js +++ b/src/api/Dimension.js @@ -54,7 +54,8 @@ Dimension.prototype.isIgnoreDimension = function() { // dep 1 -const getFullId = dim => (dim.programStage ? dim.programStage.id + '.' : '') + dim.dimension; +const getFullId = dim => (dim.programStage && dim.programStage.id ? + dim.programStage.id + '.' : '') + dim.dimension; Dimension.prototype.url = function(isSorted, response, isFilter) { if (this.isIgnoreDimension()) { diff --git a/src/api/Layout.js b/src/api/Layout.js index 944a1f1f..9b76a2c5 100644 --- a/src/api/Layout.js +++ b/src/api/Layout.js @@ -6,7 +6,7 @@ import isNumeric from 'd2-utilizr/lib/isNumeric'; import isObject from 'd2-utilizr/lib/isObject'; import isString from 'd2-utilizr/lib/isString'; -import { Record, Layout as d2aLayout } from 'd2-analysis'; +import { Record, Layout as d2aLayout, dimensionsInit } from 'd2-analysis'; export var Layout = function(refs, c, applyConfig, forceApplyConfig) { var t = this; @@ -20,6 +20,22 @@ export var Layout = function(refs, c, applyConfig, forceApplyConfig) { // inherit Object.assign(t, new d2aLayout(refs, c, applyConfig)); + // data element dimensions + if (c.dataElementDimensions) { + t.dataElementDimensions = c.dataElementDimensions; + } + + // add isDataElement to distinguish from attributes and program indicators + if (t.dataElementDimensions) { + ([].concat(t.columns, t.rows, t.filters)) + .filter(dimension => dimension) + .forEach(dimension => { + if (c.dataElementDimensions.find(de => de.dataElement.id === dimension.dimension)) { + dimension.isDataElement = true + } + }) + } + // program t.program = isObject(c.program) ? c.program : null; t.programStage = isObject(c.programStage) ? c.programStage : null; @@ -122,11 +138,6 @@ export var Layout = function(refs, c, applyConfig, forceApplyConfig) { ? c.reportParams.paramParentOrganisationUnit : isBoolean(c.parentOrganisationUnit) ? c.parentOrganisationUnit : false; - // data element dimensions - if (c.dataElementDimensions) { - t.dataElementDimensions = c.dataElementDimensions; - } - // force apply Object.assign(t, forceApplyConfig); From 7973538a7be4d5c562e167ac043e9a1f3bf1c763 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20Henrik=20=C3=98verland?= Date: Thu, 17 Oct 2024 16:53:42 +0200 Subject: [PATCH 3/8] chore: remove logs --- src/api/Layout.js | 1 - 1 file changed, 1 deletion(-) diff --git a/src/api/Layout.js b/src/api/Layout.js index 9b76a2c5..b3837238 100644 --- a/src/api/Layout.js +++ b/src/api/Layout.js @@ -209,7 +209,6 @@ Layout.prototype.getDataTypeUrl = function() { } var url = urlMap[this.outputType][this.dataType] - console.log(url) return url || dimensionConfig.dataTypeUrl[dimensionConfig.getDefaultDataType()] || ''; }; From b37a59acd973b94b6ca97ad61f4094be9430bbd6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20Henrik=20=C3=98verland?= Date: Thu, 17 Oct 2024 16:54:43 +0200 Subject: [PATCH 4/8] chore: formatting --- src/api/Layout.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/api/Layout.js b/src/api/Layout.js index b3837238..969d57ba 100644 --- a/src/api/Layout.js +++ b/src/api/Layout.js @@ -207,7 +207,7 @@ Layout.prototype.getDataTypeUrl = function() { [DATA_TYPE_EVENT]: '/enrollments/query', } } - + var url = urlMap[this.outputType][this.dataType] return url || dimensionConfig.dataTypeUrl[dimensionConfig.getDefaultDataType()] || ''; From f41d3b200fdafb90cee8c257ffd33b32616f95a0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20Henrik=20=C3=98verland?= Date: Thu, 17 Oct 2024 16:55:51 +0200 Subject: [PATCH 5/8] chore: dev href --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 79332f97..eeadbe9f 100644 --- a/package.json +++ b/package.json @@ -66,7 +66,7 @@ "dhis": { "href": "..", "auth": "admin:district", - "devHref": "https://test.e2e.dhis2.org/analytics-41dev/" + "devHref": "http://localhost:8080" } } } From ba967d228c4c5a8d6866abf7a9175dd9c5a0b964 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20Henrik=20=C3=98verland?= Date: Tue, 22 Oct 2024 10:42:43 +0200 Subject: [PATCH 6/8] fix: d2-analysis@33.3.3 do not request stage for attr/pr --- package.json | 2 +- yarn.lock | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/package.json b/package.json index eeadbe9f..8ade0a1a 100644 --- a/package.json +++ b/package.json @@ -27,7 +27,7 @@ }, "homepage": "https://github.com/dhis2/event-reports-app#readme", "dependencies": { - "d2-analysis": "^33.3.2", + "d2-analysis": "^33.3.3", "d2-utilizr": "0.2.13" }, "devDependencies": { diff --git a/yarn.lock b/yarn.lock index bb74955b..78d80d95 100644 --- a/yarn.lock +++ b/yarn.lock @@ -1734,10 +1734,10 @@ currently-unhandled@^0.4.1: dependencies: array-find-index "^1.0.1" -d2-analysis@^33.3.2: - version "33.3.2" - resolved "https://registry.yarnpkg.com/d2-analysis/-/d2-analysis-33.3.2.tgz#2497f20a9630a07ca68472496fe44a62e6367700" - integrity sha512-TegC9xvkBcTYnFDxzJoqqLW50kSYSqT8qBzH/4DdeaSbLB0X0h3VLf61nmVux7Vt3jI/lry38FnFWBp70CgODg== +d2-analysis@^33.3.3: + version "33.3.3" + resolved "https://registry.yarnpkg.com/d2-analysis/-/d2-analysis-33.3.3.tgz#cf60f052711111aa46512a1fe0e44462bd20654a" + integrity sha512-TAk3Dqho6vrD/wul/DHR/mW8P89kgOqyR9eiUwBFS7n1BRlvifgFTdzT0mI53DN9I8nuBi+6TWtFHQvjN8lBIQ== dependencies: "@dhis2/d2-ui-rich-text" "^5.1.0" d2-utilizr "^0.2.16" From 37ccb18cf6245df3b7374d679a990e9b6a348d3e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20Henrik=20=C3=98verland?= Date: Tue, 22 Oct 2024 11:14:05 +0200 Subject: [PATCH 7/8] chore: update actions/upload-artifact --- .github/workflows/dhis2-verify-app.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/dhis2-verify-app.yml b/.github/workflows/dhis2-verify-app.yml index 85bf387f..5e0a3559 100644 --- a/.github/workflows/dhis2-verify-app.yml +++ b/.github/workflows/dhis2-verify-app.yml @@ -52,7 +52,7 @@ jobs: - name: Build run: yarn build - - uses: actions/upload-artifact@v2 + - uses: actions/upload-artifact@v3 with: name: app-build path: | From 6552e824481a885620eb0b60909ea999efe5c3c9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20Henrik=20=C3=98verland?= Date: Tue, 22 Oct 2024 11:23:42 +0200 Subject: [PATCH 8/8] chore: update actions/download-artifact --- .github/workflows/dhis2-verify-app.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/dhis2-verify-app.yml b/.github/workflows/dhis2-verify-app.yml index 5e0a3559..01ece80d 100644 --- a/.github/workflows/dhis2-verify-app.yml +++ b/.github/workflows/dhis2-verify-app.yml @@ -73,7 +73,7 @@ jobs: with: node-version: 12.x - - uses: actions/download-artifact@v2 + - uses: actions/download-artifact@v3 with: name: app-build