@ministryofjustice/hmpps-digital-prison-reporting-frontend 4.16.1 → 4.17.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/dpr/components/_catalogue/catalogue/utils.js +1 -1
- package/dpr/components/_catalogue/catalogue/utils.js.map +3 -3
- package/dpr/components/_catalogue/catalogue/utils.test.ts +15 -1
- package/dpr/components/_catalogue/catalogue/utils.ts +22 -4
- package/dpr/components/_catalogue/catalogue/view.njk +2 -1
- package/dpr/components/_catalogue/catalogue-filters/view.njk +2 -2
- package/dpr/components/_catalogue/catalogue-list/utils.js +1 -1
- package/dpr/components/_catalogue/catalogue-list/utils.js.map +3 -3
- package/dpr/components/_catalogue/catalogue-list/utils.ts +4 -5
- package/dpr/components/_catalogue/catalogue-search/clientClass.mjs +14 -0
- package/dpr/components/_catalogue/catalogue-search/view.njk +24 -1
- package/dpr/components/_charts/chart/Buckets.js +1 -1
- package/dpr/components/_charts/chart/Buckets.js.map +3 -3
- package/dpr/components/_charts/chart/Buckets.ts +44 -36
- package/dpr/components/_charts/chart/heatmap/HeatmapChart.js +1 -1
- package/dpr/components/_charts/chart/heatmap/HeatmapChart.js.map +2 -2
- package/dpr/components/_charts/chart/heatmap/HeatmapChart.ts +22 -14
- package/dpr/components/_charts/chart/heatmap/types.js +2 -0
- package/dpr/components/_charts/chart/heatmap/types.js.map +7 -0
- package/dpr/components/_charts/chart/heatmap/types.ts +6 -0
- package/dpr/components/_charts/utils.js +1 -1
- package/dpr/components/_charts/utils.js.map +3 -3
- package/dpr/components/_charts/utils.test.ts +10 -7
- package/dpr/components/_charts/utils.ts +57 -50
- package/dpr/components/_dashboards/dashboard/view.njk +1 -1
- package/dpr/components/_dashboards/dashboard-list/utils.js +1 -1
- package/dpr/components/_dashboards/dashboard-list/utils.js.map +2 -2
- package/dpr/components/_dashboards/dashboard-list/utils.test.ts +3 -3
- package/dpr/components/_dashboards/dashboard-list/utils.ts +16 -12
- package/dpr/components/_dashboards/dashboard-section/view.njk +1 -1
- package/dpr/components/_dashboards/dashboard-visualisation/DashboardVisualisation.js +2 -0
- package/dpr/components/_dashboards/dashboard-visualisation/DashboardVisualisation.js.map +7 -0
- package/dpr/components/_dashboards/dashboard-visualisation/DashboardVisualisation.ts +40 -0
- package/dpr/components/_dashboards/dashboard-visualisation/types.js +2 -0
- package/dpr/components/_dashboards/dashboard-visualisation/types.js.map +7 -0
- package/dpr/components/_dashboards/dashboard-visualisation/types.ts +102 -0
- package/dpr/components/_dashboards/dashboard-visualisation/view.njk +1 -1
- package/dpr/components/_dashboards/scorecard/Scorecard.js +1 -1
- package/dpr/components/_dashboards/scorecard/Scorecard.js.map +2 -2
- package/dpr/components/_dashboards/scorecard/Scorecard.ts +37 -29
- package/dpr/components/_dashboards/scorecard/types.js.map +1 -1
- package/dpr/components/_dashboards/scorecard/types.ts +1 -0
- package/dpr/components/_dashboards/scorecard/utils.js +1 -1
- package/dpr/components/_dashboards/scorecard/utils.js.map +2 -2
- package/dpr/components/_dashboards/scorecard/utils.test.ts +13 -4
- package/dpr/components/_dashboards/scorecard/utils.ts +6 -5
- package/dpr/components/_dashboards/scorecard/view.njk +6 -5
- package/dpr/components/_dashboards/scorecard-group/view.njk +4 -4
- package/dpr/components/_reports/report-actions/types.d.js.map +1 -1
- package/dpr/components/_reports/report-actions/types.d.ts +1 -1
- package/dpr/components/_reports/report-heading/view.njk +1 -1
- package/dpr/data/dashboardClient.js +1 -1
- package/dpr/data/dashboardClient.js.map +2 -2
- package/dpr/data/dashboardClient.ts +8 -7
- package/dpr/data/dprReportingClient.js +1 -1
- package/dpr/data/dprReportingClient.js.map +3 -3
- package/dpr/data/dprReportingClient.ts +2 -0
- package/dpr/data/reportingClient.js +1 -1
- package/dpr/data/reportingClient.js.map +1 -1
- package/dpr/data/reportingClient.ts +1 -1
- package/dpr/middleware/reportAuthoriser.js +1 -1
- package/dpr/middleware/reportAuthoriser.js.map +3 -3
- package/dpr/middleware/reportAuthoriser.ts +9 -20
- package/dpr/middleware/setUpDprResources.js +1 -1
- package/dpr/middleware/setUpDprResources.js.map +3 -3
- package/dpr/middleware/setUpDprResources.test.ts +7 -0
- package/dpr/middleware/setUpDprResources.ts +17 -2
- package/dpr/routes/journeys/download-report/controller.js +1 -1
- package/dpr/routes/journeys/download-report/controller.js.map +3 -3
- package/dpr/routes/journeys/download-report/controller.ts +4 -1
- package/dpr/routes/journeys/download-report/request-download/form/submitted/tests.cy.js +1 -1
- package/dpr/routes/journeys/download-report/request-download/form/submitted/tests.cy.js.map +2 -2
- package/dpr/routes/journeys/download-report/request-download/form/submitted/tests.cy.ts +1 -0
- package/dpr/routes/journeys/download-report/request-download/form/tests.cy.js +1 -1
- package/dpr/routes/journeys/download-report/request-download/form/tests.cy.js.map +2 -2
- package/dpr/routes/journeys/download-report/request-download/form/tests.cy.ts +1 -0
- package/dpr/routes/journeys/download-report/tests.cy.js +1 -1
- package/dpr/routes/journeys/download-report/tests.cy.js.map +2 -2
- package/dpr/routes/journeys/download-report/tests.cy.ts +2 -7
- package/dpr/routes/journeys/download-report/utils.js +1 -1
- package/dpr/routes/journeys/download-report/utils.js.map +3 -3
- package/dpr/routes/journeys/download-report/utils.ts +10 -7
- package/dpr/routes/journeys/my-reports/bookmarks/list/tests.cy.js +1 -1
- package/dpr/routes/journeys/my-reports/bookmarks/list/tests.cy.js.map +2 -2
- package/dpr/routes/journeys/my-reports/bookmarks/list/tests.cy.ts +1 -0
- package/dpr/routes/journeys/my-reports/bookmarks/tests.cy.js +1 -1
- package/dpr/routes/journeys/my-reports/bookmarks/tests.cy.js.map +3 -3
- package/dpr/routes/journeys/my-reports/bookmarks/tests.cy.ts +5 -12
- package/dpr/routes/journeys/my-reports/bookmarks/utils.js +1 -1
- package/dpr/routes/journeys/my-reports/bookmarks/utils.js.map +3 -3
- package/dpr/routes/journeys/my-reports/bookmarks/utils.ts +11 -5
- package/dpr/routes/journeys/my-reports/recently-viewed/list/tests.cy.js +1 -1
- package/dpr/routes/journeys/my-reports/recently-viewed/list/tests.cy.js.map +3 -3
- package/dpr/routes/journeys/my-reports/recently-viewed/list/tests.cy.ts +4 -6
- package/dpr/routes/journeys/my-reports/requested-reports/list/tests.cy.js +1 -1
- package/dpr/routes/journeys/my-reports/requested-reports/list/tests.cy.js.map +2 -2
- package/dpr/routes/journeys/my-reports/requested-reports/list/tests.cy.ts +1 -0
- package/dpr/routes/journeys/product-collection/routes.js +2 -0
- package/dpr/routes/journeys/product-collection/routes.js.map +7 -0
- package/dpr/routes/journeys/product-collection/routes.ts +28 -0
- package/dpr/routes/journeys/product-collection/selected/controller.js +2 -0
- package/dpr/routes/journeys/product-collection/selected/controller.js.map +7 -0
- package/dpr/routes/journeys/product-collection/selected/controller.ts +29 -0
- package/dpr/routes/journeys/product-collection/selected/routes.js +2 -0
- package/dpr/routes/journeys/product-collection/selected/routes.js.map +7 -0
- package/dpr/routes/journeys/product-collection/selected/routes.ts +15 -0
- package/dpr/routes/journeys/product-collection/selected/tests.cy.js +2 -0
- package/dpr/routes/journeys/product-collection/selected/tests.cy.js.map +7 -0
- package/dpr/routes/journeys/product-collection/selected/tests.cy.ts +54 -0
- package/dpr/routes/journeys/product-collection/selected/validation.js +2 -0
- package/dpr/routes/journeys/product-collection/selected/validation.js.map +7 -0
- package/dpr/routes/journeys/product-collection/selected/validation.ts +5 -0
- package/dpr/routes/journeys/request-missing-report/form/tests.cy.js +1 -1
- package/dpr/routes/journeys/request-missing-report/form/tests.cy.js.map +2 -2
- package/dpr/routes/journeys/request-missing-report/form/tests.cy.ts +1 -0
- package/dpr/routes/journeys/request-missing-report/tests.cy.js +1 -1
- package/dpr/routes/journeys/request-missing-report/tests.cy.js.map +2 -2
- package/dpr/routes/journeys/request-missing-report/tests.cy.ts +3 -4
- package/dpr/routes/journeys/request-report/filters/tests.cy.js +1 -1
- package/dpr/routes/journeys/request-report/filters/tests.cy.js.map +3 -3
- package/dpr/routes/journeys/request-report/filters/tests.cy.ts +3 -6
- package/dpr/routes/journeys/request-report/filters/utils.js +1 -1
- package/dpr/routes/journeys/request-report/filters/utils.js.map +2 -2
- package/dpr/routes/journeys/request-report/filters/utils.ts +2 -3
- package/dpr/routes/journeys/request-report/status/tests.cy.js +1 -1
- package/dpr/routes/journeys/request-report/status/tests.cy.js.map +2 -2
- package/dpr/routes/journeys/request-report/status/tests.cy.ts +2 -6
- package/dpr/routes/journeys/request-report/tests.cy.js +1 -1
- package/dpr/routes/journeys/request-report/tests.cy.js.map +3 -3
- package/dpr/routes/journeys/request-report/tests.cy.ts +5 -32
- package/dpr/routes/journeys/routes.js +1 -1
- package/dpr/routes/journeys/routes.js.map +2 -2
- package/dpr/routes/journeys/routes.ts +2 -0
- package/dpr/routes/journeys/view-report/async/controller.js.map +2 -2
- package/dpr/routes/journeys/view-report/async/controller.ts +2 -2
- package/dpr/routes/journeys/view-report/async/dashboard/tests.cy.js +1 -1
- package/dpr/routes/journeys/view-report/async/dashboard/tests.cy.js.map +2 -2
- package/dpr/routes/journeys/view-report/async/dashboard/tests.cy.ts +2 -9
- package/dpr/routes/journeys/view-report/async/dashboard/utils.js +1 -1
- package/dpr/routes/journeys/view-report/async/dashboard/utils.js.map +3 -3
- package/dpr/routes/journeys/view-report/async/dashboard/utils.ts +100 -95
- package/dpr/routes/journeys/view-report/async/report/controller.js +1 -1
- package/dpr/routes/journeys/view-report/async/report/controller.js.map +3 -3
- package/dpr/routes/journeys/view-report/async/report/controller.ts +4 -6
- package/dpr/routes/journeys/view-report/async/report/tests.cy.js +1 -1
- package/dpr/routes/journeys/view-report/async/report/tests.cy.js.map +2 -2
- package/dpr/routes/journeys/view-report/async/report/tests.cy.ts +8 -17
- package/dpr/routes/journeys/view-report/async/report/types.js +2 -0
- package/dpr/routes/journeys/view-report/async/report/types.js.map +7 -0
- package/dpr/routes/journeys/view-report/async/report/types.ts +31 -0
- package/dpr/routes/journeys/view-report/async/report/utils.js +1 -1
- package/dpr/routes/journeys/view-report/async/report/utils.js.map +3 -3
- package/dpr/routes/journeys/view-report/async/report/utils.ts +173 -136
- package/dpr/routes/journeys/view-report/sync/tests.cy.js +1 -1
- package/dpr/routes/journeys/view-report/sync/tests.cy.js.map +3 -3
- package/dpr/routes/journeys/view-report/sync/tests.cy.ts +3 -4
- package/dpr/services/dashboardService.js +1 -1
- package/dpr/services/dashboardService.js.map +2 -2
- package/dpr/services/dashboardService.ts +7 -5
- package/dpr/services/productCollection/productCollectionService.js +2 -0
- package/dpr/services/productCollection/productCollectionService.js.map +7 -0
- package/dpr/services/productCollection/productCollectionService.ts +25 -0
- package/dpr/services/productCollection/productCollectionStoreService.js +2 -0
- package/dpr/services/productCollection/productCollectionStoreService.js.map +7 -0
- package/dpr/services/productCollection/productCollectionStoreService.ts +26 -0
- package/dpr/services/reportingService.js +1 -1
- package/dpr/services/reportingService.js.map +1 -1
- package/dpr/services/reportingService.ts +1 -1
- package/dpr/types/AsyncReportUtils.js.map +1 -1
- package/dpr/types/AsyncReportUtils.ts +3 -4
- package/dpr/types/Charts.js +1 -1
- package/dpr/types/Charts.js.map +3 -3
- package/dpr/types/Charts.ts +0 -82
- package/dpr/types/Metrics.js +1 -1
- package/dpr/types/Metrics.js.map +1 -1
- package/dpr/types/Metrics.ts +7 -0
- package/dpr/types/ReportQuery.js +1 -1
- package/dpr/types/ReportQuery.js.map +3 -3
- package/dpr/types/ReportQuery.ts +24 -15
- package/dpr/types/ReportStore.js +1 -1
- package/dpr/types/ReportStore.js.map +1 -1
- package/dpr/types/ReportStore.ts +1 -0
- package/dpr/types/Services.d.js +1 -1
- package/dpr/types/Services.d.js.map +1 -1
- package/dpr/types/Services.d.ts +15 -0
- package/dpr/types/api.d.js +1 -1
- package/dpr/types/api.d.js.map +1 -1
- package/dpr/types/api.d.ts +197 -6
- package/dpr/utils/Personalisation/personalisationUtils.js +1 -1
- package/dpr/utils/Personalisation/personalisationUtils.js.map +3 -3
- package/dpr/utils/Personalisation/personalisationUtils.ts +15 -6
- package/dpr/utils/ReportStoreServiceUtils.js +1 -1
- package/dpr/utils/ReportStoreServiceUtils.js.map +3 -3
- package/dpr/utils/ReportStoreServiceUtils.ts +7 -0
- package/dpr/utils/UserStoreItemBuilder.js +1 -1
- package/dpr/utils/UserStoreItemBuilder.js.map +1 -1
- package/dpr/utils/UserStoreItemBuilder.ts +2 -2
- package/dpr/utils/datasetHelper.js +1 -1
- package/dpr/utils/datasetHelper.js.map +3 -3
- package/dpr/utils/datasetHelper.test.ts +11 -11
- package/dpr/utils/datasetHelper.ts +23 -8
- package/dpr/utils/logger.js +1 -1
- package/dpr/utils/logger.js.map +3 -3
- package/dpr/utils/logger.ts +6 -1
- package/package.json +2 -1
- package/dpr/components/_charts/chart/DashboardVisualisation.js +0 -2
- package/dpr/components/_charts/chart/DashboardVisualisation.js.map +0 -7
- package/dpr/components/_charts/chart/DashboardVisualisation.ts +0 -43
- package/dpr/components/_dashboards/dashboard/types.js +0 -2
- package/dpr/components/_dashboards/dashboard/types.js.map +0 -7
- package/dpr/components/_dashboards/dashboard/types.ts +0 -120
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../../../../src/dpr/routes/journeys/view-report/async/dashboard/tests.cy.ts"],
|
|
4
|
-
"sourcesContent": ["import { checkA11y } from '../../../../../../../cypress-tests/cypressUtils'\n\ncontext('Viewing a report', () => {\n const path = '/embedded/platform/'\n\n describe('dashboard tests', () => {\n before(() => {\n
|
|
5
|
-
"mappings": "AAAA,IAAAA,
|
|
4
|
+
"sourcesContent": ["import { checkA11y, executeDashboardStubs } from '../../../../../../../cypress-tests/cypressUtils'\n\ncontext('Viewing a report', () => {\n const path = '/embedded/platform/'\n\n describe('dashboard tests', () => {\n before(() => {\n executeDashboardStubs()\n cy.task('stubTestDashboard8')\n cy.task('stubDashboardSuccessResult20')\n })\n\n it('should mark the dashboard as recently viewed', () => {\n // Request and run a report so we can go back to it for each test\n cy.visit(path)\n cy.findByRole('tab', { name: /Viewed \\(0\\)/ }).should('be.visible')\n checkA11y()\n cy.findByLabelText(/Reports catalogue.*/i).within(() => {\n cy.findByRole('row', {\n name: (_, element) => {\n return (\n element.textContent.includes('Test Dashboard') &&\n element.textContent.includes('Dashboard used for testing testing')\n )\n },\n }).within(() => {\n cy.findByRole('link', { name: 'Request dashboard' }).click()\n })\n })\n checkA11y()\n cy.findByRole('button', { name: /Request/ }).click()\n checkA11y()\n cy.findByRole('heading', { level: 1, name: /Test Dashboard/ }).should('be.visible')\n checkA11y()\n cy.visit(path)\n cy.findByRole('tab', { name: /Viewed \\(1\\)/ }).should('be.visible')\n })\n })\n})\n"],
|
|
5
|
+
"mappings": "AAAA,IAAAA,EAAiD,2DAEjD,QAAQ,mBAAoB,IAAM,CAChC,MAAMC,EAAO,sBAEb,SAAS,kBAAmB,IAAM,CAChC,OAAO,IAAM,IACX,yBAAsB,EACtB,GAAG,KAAK,oBAAoB,EAC5B,GAAG,KAAK,8BAA8B,CACxC,CAAC,EAED,GAAG,+CAAgD,IAAM,CAEvD,GAAG,MAAMA,CAAI,EACb,GAAG,WAAW,MAAO,CAAE,KAAM,cAAe,CAAC,EAAE,OAAO,YAAY,KAClE,aAAU,EACV,GAAG,gBAAgB,sBAAsB,EAAE,OAAO,IAAM,CACtD,GAAG,WAAW,MAAO,CACnB,KAAM,CAACC,EAAGC,IAENA,EAAQ,YAAY,SAAS,gBAAgB,GAC7CA,EAAQ,YAAY,SAAS,oCAAoC,CAGvE,CAAC,EAAE,OAAO,IAAM,CACd,GAAG,WAAW,OAAQ,CAAE,KAAM,mBAAoB,CAAC,EAAE,MAAM,CAC7D,CAAC,CACH,CAAC,KACD,aAAU,EACV,GAAG,WAAW,SAAU,CAAE,KAAM,SAAU,CAAC,EAAE,MAAM,KACnD,aAAU,EACV,GAAG,WAAW,UAAW,CAAE,MAAO,EAAG,KAAM,gBAAiB,CAAC,EAAE,OAAO,YAAY,KAClF,aAAU,EACV,GAAG,MAAMF,CAAI,EACb,GAAG,WAAW,MAAO,CAAE,KAAM,cAAe,CAAC,EAAE,OAAO,YAAY,CACpE,CAAC,CACH,CAAC,CACH,CAAC",
|
|
6
6
|
"names": ["import_cypressUtils", "path", "_", "element"]
|
|
7
7
|
}
|
|
@@ -1,20 +1,13 @@
|
|
|
1
|
-
import { checkA11y } from '../../../../../../../cypress-tests/cypressUtils'
|
|
1
|
+
import { checkA11y, executeDashboardStubs } from '../../../../../../../cypress-tests/cypressUtils'
|
|
2
2
|
|
|
3
3
|
context('Viewing a report', () => {
|
|
4
4
|
const path = '/embedded/platform/'
|
|
5
5
|
|
|
6
6
|
describe('dashboard tests', () => {
|
|
7
7
|
before(() => {
|
|
8
|
-
|
|
9
|
-
cy.task('resetRedis')
|
|
10
|
-
cy.task('stubDefinitions')
|
|
8
|
+
executeDashboardStubs()
|
|
11
9
|
cy.task('stubTestDashboard8')
|
|
12
|
-
cy.task('stubMockDashboardsStatusFinished')
|
|
13
|
-
cy.task('stubViewAsyncResults')
|
|
14
10
|
cy.task('stubDashboardSuccessResult20')
|
|
15
|
-
cy.task('stubSingleSummaries')
|
|
16
|
-
cy.task('stubDefinitionUnprintable')
|
|
17
|
-
cy.task('stubDefinitionEmptyReport')
|
|
18
11
|
})
|
|
19
12
|
|
|
20
13
|
it('should mark the dashboard as recently viewed', () => {
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
var
|
|
1
|
+
var O=Object.create;var h=Object.defineProperty;var _=Object.getOwnPropertyDescriptor;var H=Object.getOwnPropertyNames;var Q=Object.getPrototypeOf,G=Object.prototype.hasOwnProperty;var v=(t,e)=>{for(var r in e)h(t,r,{get:e[r],enumerable:!0})},w=(t,e,r,n)=>{if(e&&typeof e=="object"||typeof e=="function")for(let s of H(e))!G.call(t,s)&&s!==r&&h(t,s,{get:()=>e[s],enumerable:!(n=_(e,s))||n.enumerable});return t};var p=(t,e,r)=>(r=t!=null?O(Q(t)):{},w(e||!t||!t.__esModule?h(r,"default",{value:t,enumerable:!0}):r,t)),W=t=>w(h({},"__esModule",{value:!0}),t);var Y={};v(Y,{default:()=>K,renderAsyncDashboard:()=>M});module.exports=W(Y);var V=p(require("parseurl")),l=require("../../../../../components/_dashboards/dashboard-visualisation/types"),y=require("../../../../../types/UserReports"),b=p(require("../../../../../components/_charts/utils")),P=p(require("../../../../../utils/definitionUtils")),q=p(require("../../../../../components/user-reports/utils")),F=p(require("../../../../../components/_dashboards/dashboard-list/utils")),S=p(require("../../../../../components/_filters/utils")),C=p(require("../../../../../components/_dashboards/scorecard/utils")),g=p(require("../../../../../components/_dashboards/scorecard/Scorecard")),x=p(require("../../../../../components/_reports/report-actions/utils")),B=p(require("../../../../../types/ReportQuery")),U=p(require("../../../../../utils/localsHelper")),L=require("../../../../../components/_filters/filtersTypeEnum");const X=(t,e,r)=>{const n=e.name,{name:s}=t,a=r?.url?.request?.fullUrl,c=r?.executionId;let o={};return a&&(o={share:{reportName:n,name:s,url:a},copy:{url:a}},c&&(o={...o,refresh:{url:a,executionId:c}})),x.default.getActions(o)},j=async({req:t,res:e,services:r,next:n})=>{const{token:s}=U.default.getValues(e),{reportId:a,id:c}=t.params,o=t.query.dataProductDefinitionsPath,d=await r.dashboardService.getDefinition(s,a,c,o),i=await P.default.getReportSummary(a,r.reportingService,s,o),u=await S.default.getFilters({fields:d.filterFields||[],req:t,filtersType:L.FiltersType.INTERACTIVE}),f=S.default.setRequestQueryFromFilterValues(u.filters);return{query:new B.default({fields:d.filterFields||[],queryParams:f,definitionsPath:o,reportType:y.ReportType.DASHBOARD}).toRecordWithFilterPrefix(!0),filters:u,dashboardDefinition:d,reportDefinition:i}},z=(t,e,r)=>t.sections.map(n=>{const{id:s,display:a,description:c}=n;let o=!1;const d=n.visualisations.map(i=>{const{type:u,display:f,description:D,id:A}=i;let m;switch(u){case l.DashboardVisualisationType.LIST:m=F.default.createList(i,e);break;case l.DashboardVisualisationType.SCORECARD:o=!0,m=new g.default(e,i).build();break;case l.DashboardVisualisationType.SCORECARD_GROUP:m=new g.default(e,i,!0).build();break;case l.DashboardVisualisationType.BAR:case l.DashboardVisualisationType.LINE:case l.DashboardVisualisationType.DONUT:{m=b.default.createChart(i,e);break}case l.DashboardVisualisationType.MATRIX_TIMESERIES:{m=b.default.createMatrixChart(i,e,r);break}case l.DashboardVisualisationType.BAR_TIMESERIES:case l.DashboardVisualisationType.LINE_TIMESERIES:{m=b.default.createTimeseriesCharts(i,e);break}default:break}return{id:A,title:f,description:D,type:u,data:m}});return o&&C.default.mergeScorecardsIntoGroup(d),{id:s,title:a,description:c,visualisations:d}}),J=async(t,e,r,n,s,a)=>{const{requestedReportService:c}=t,o=c?await c.getReportByTableId(e,r):void 0;return n&&n.length&&o&&q.default.updateLastViewed({services:t,reportStateData:o,userId:r,req:s,filters:a}),o},M=async({req:t,res:e,services:r,next:n})=>{const{token:s,csrfToken:a,dprUser:c,nestedBaseUrl:o}=U.default.getValues(e),{reportId:d,id:i,tableId:u}=t.params,{bookmarkService:f,requestedReportService:D}=r,A=(0,V.default)(t),{query:m,filters:I,reportDefinition:k,dashboardDefinition:R}=await j({req:t,res:e,services:r}),N=(await r.dashboardService.getAsyncDashboard(s,i,d,u,m)).flat(),T=z(R,N,m);let E;return D&&(E=await J(r,u,c.id,T,t,I.filters)),{dashboardData:{token:s,id:i,reportId:d,name:R.name,description:R.description,reportName:k.name,bookmarked:f?await f.isBookmarked(i,d,c.id):!1,nestedBaseUrl:o,csrfToken:a,sections:T,filters:I,type:y.ReportType.DASHBOARD,actions:X(R,k,E)}}};var K={renderAsyncDashboard:M};0&&(module.exports={renderAsyncDashboard});
|
|
2
2
|
//# sourceMappingURL=utils.js.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../../../../src/dpr/routes/journeys/view-report/async/dashboard/utils.ts"],
|
|
4
|
-
"sourcesContent": ["import parseUrl from 'parseurl'\nimport {
|
|
5
|
-
"mappings": "6iBAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,aAAAE,EAAA,yBAAAC,IAAA,eAAAC,EAAAJ,GAAA,IAAAK,EAAqB,
|
|
6
|
-
"names": ["utils_exports", "__export", "utils_default", "renderAsyncDashboard", "__toCommonJS", "import_parseurl", "import_types", "import_UserReports", "import_utils", "import_definitionUtils", "import_Scorecard", "import_ReportQuery", "import_localsHelper", "import_filtersTypeEnum", "setDashboardActions", "dashboardDefinition", "reportDefinition", "requestData", "reportName", "name", "actionsUrl", "executionId", "ReportActionsUtils", "getDefinitionData", "req", "res", "services", "next", "token", "LocalsHelper", "reportId", "id", "dataProductDefinitionsPath", "DefinitionUtils", "filtersData", "FilterUtils", "filtersQuery", "ReportQuery", "getSections", "dashboardData", "query", "section", "title", "description", "hasScorecard", "visualisations", "visDefinition", "type", "display", "visDescription", "visId", "data", "DashboardListUtils", "ScorecardVisualisation", "ChartUtils", "ScorecardsUtils", "updateStore", "tableId", "userId", "sections", "
|
|
4
|
+
"sourcesContent": ["import parseUrl from 'parseurl'\nimport { Request } from 'express'\nimport { Services } from '../../../../../types/Services'\nimport {\n DashboardSection,\n DashboardVisualisation,\n DashboardVisualisationType,\n} from '../../../../../components/_dashboards/dashboard-visualisation/types'\nimport type { AsyncReportUtilsParams } from '../../../../../types/AsyncReportUtils'\n\nimport type { DashboardDataResponse } from '../../../../../types/Metrics'\nimport type { RequestedReport } from '../../../../../types/UserReports'\nimport { ReportType } from '../../../../../types/UserReports'\nimport type { components } from '../../../../../types/api'\n\nimport ChartUtils from '../../../../../components/_charts/utils'\nimport DefinitionUtils from '../../../../../utils/definitionUtils'\nimport UserReportsUtils from '../../../../../components/user-reports/utils'\nimport DashboardListUtils from '../../../../../components/_dashboards/dashboard-list/utils'\nimport FilterUtils from '../../../../../components/_filters/utils'\nimport ScorecardsUtils from '../../../../../components/_dashboards/scorecard/utils'\nimport ScorecardVisualisation from '../../../../../components/_dashboards/scorecard/Scorecard'\nimport ReportActionsUtils from '../../../../../components/_reports/report-actions/utils'\nimport ReportQuery from '../../../../../types/ReportQuery'\nimport LocalsHelper from '../../../../../utils/localsHelper'\nimport { FilterValue } from '../../../../../components/_filters/types'\nimport { FiltersType } from '../../../../../components/_filters/filtersTypeEnum'\n\nconst setDashboardActions = (\n dashboardDefinition: components['schemas']['DashboardDefinition'],\n reportDefinition: components['schemas']['ReportDefinitionSummary'],\n requestData?: RequestedReport,\n) => {\n const reportName = reportDefinition.name\n const { name } = dashboardDefinition\n const actionsUrl = requestData?.url?.request?.fullUrl\n const executionId = requestData?.executionId\n\n let actions = {}\n if (actionsUrl) {\n actions = {\n share: {\n reportName,\n name,\n url: actionsUrl,\n },\n copy: {\n url: actionsUrl,\n },\n }\n if (executionId) {\n actions = {\n ...actions,\n refresh: {\n url: actionsUrl,\n executionId,\n },\n }\n }\n }\n\n return ReportActionsUtils.getActions(actions)\n}\n\nconst getDefinitionData = async ({ req, res, services, next }: AsyncReportUtilsParams) => {\n const { token } = LocalsHelper.getValues(res)\n const { reportId, id } = req.params\n const dataProductDefinitionsPath = <string>req.query.dataProductDefinitionsPath\n\n // Dashboard Definition,\n const dashboardDefinition: components['schemas']['DashboardDefinition'] =\n await services.dashboardService.getDefinition(token, reportId, id, dataProductDefinitionsPath)\n\n // Report summary data\n const reportDefinition = await DefinitionUtils.getReportSummary(\n reportId,\n services.reportingService,\n token,\n <string>dataProductDefinitionsPath,\n )\n\n // Get the filters\n const filtersData = await FilterUtils.getFilters({\n fields: dashboardDefinition.filterFields || [],\n req,\n filtersType: FiltersType.INTERACTIVE,\n })\n\n const filtersQuery = FilterUtils.setRequestQueryFromFilterValues(filtersData.filters)\n\n // Create the query\n const query = new ReportQuery({\n fields: dashboardDefinition.filterFields || [],\n queryParams: filtersQuery,\n definitionsPath: <string>dataProductDefinitionsPath,\n reportType: ReportType.DASHBOARD,\n }).toRecordWithFilterPrefix(true)\n\n return {\n query,\n filters: filtersData,\n dashboardDefinition,\n reportDefinition,\n }\n}\n\nconst getSections = (\n dashboardDefinition: components['schemas']['DashboardDefinition'],\n dashboardData: DashboardDataResponse[],\n query: Record<string, string | string[]>,\n): DashboardSection[] => {\n return dashboardDefinition.sections.map((section: components['schemas']['DashboardSectionDefinition']) => {\n const { id, display: title, description } = section\n\n let hasScorecard = false\n const visualisations: DashboardVisualisation[] = section.visualisations.map(\n (visDefinition: components['schemas']['DashboardVisualisationDefinition']) => {\n const { type, display, description: visDescription, id: visId } = visDefinition\n\n let data: DashboardVisualisation['data'] | undefined\n\n switch (type) {\n case DashboardVisualisationType.LIST:\n data = DashboardListUtils.createList(visDefinition, dashboardData)\n break\n\n case DashboardVisualisationType.SCORECARD:\n hasScorecard = true\n data = new ScorecardVisualisation(dashboardData, visDefinition).build()\n break\n\n case DashboardVisualisationType.SCORECARD_GROUP:\n data = new ScorecardVisualisation(dashboardData, visDefinition, true).build()\n break\n\n case DashboardVisualisationType.BAR:\n case DashboardVisualisationType.LINE:\n case DashboardVisualisationType.DONUT: {\n data = ChartUtils.createChart(visDefinition, dashboardData)\n break\n }\n case DashboardVisualisationType.MATRIX_TIMESERIES: {\n data = ChartUtils.createMatrixChart(visDefinition, dashboardData, query)\n break\n }\n case DashboardVisualisationType.BAR_TIMESERIES:\n case DashboardVisualisationType.LINE_TIMESERIES: {\n data = ChartUtils.createTimeseriesCharts(visDefinition, dashboardData)\n break\n }\n default:\n break\n }\n\n return {\n id: visId,\n title: display,\n description: visDescription,\n type,\n data,\n }\n },\n )\n\n if (hasScorecard) ScorecardsUtils.mergeScorecardsIntoGroup(visualisations)\n\n return { id, title, description, visualisations }\n })\n}\n\nconst updateStore = async (\n services: Services,\n tableId: string,\n userId: string,\n sections: DashboardSection[],\n req: Request,\n filters: FilterValue[],\n): Promise<RequestedReport | undefined> => {\n const { requestedReportService } = services\n const dashboardRequestData = requestedReportService\n ? await requestedReportService.getReportByTableId(tableId, userId)\n : undefined\n\n // Add to recently viewed\n if (sections && sections.length && dashboardRequestData) {\n UserReportsUtils.updateLastViewed({\n services,\n reportStateData: dashboardRequestData,\n userId,\n req,\n filters,\n })\n }\n\n return dashboardRequestData\n}\n\nexport const renderAsyncDashboard = async ({ req, res, services, next }: AsyncReportUtilsParams) => {\n const { token, csrfToken, dprUser, nestedBaseUrl } = LocalsHelper.getValues(res)\n const { reportId, id, tableId } = req.params\n const { bookmarkService, requestedReportService } = services\n const url = parseUrl(req)\n\n // Get the definition Data\n const { query, filters, reportDefinition, dashboardDefinition } = await getDefinitionData({\n req,\n res,\n services,\n })\n\n // Get the results data\n const dashboardData: DashboardDataResponse[][] = await services.dashboardService.getAsyncDashboard(\n token,\n id,\n reportId,\n tableId,\n query,\n )\n\n const flattenedData: DashboardDataResponse[] = dashboardData.flat()\n\n // Get the dashboard parts\n const sections: DashboardSection[] = getSections(dashboardDefinition, flattenedData, query)\n\n // Update the store\n let dashboardRequestData\n if (requestedReportService) {\n dashboardRequestData = await updateStore(services, tableId, dprUser.id, sections, req, filters.filters)\n }\n\n return {\n dashboardData: {\n token,\n id,\n reportId,\n name: dashboardDefinition.name,\n description: dashboardDefinition.description,\n reportName: reportDefinition.name,\n bookmarked: bookmarkService ? await bookmarkService.isBookmarked(id, reportId, dprUser.id) : false,\n nestedBaseUrl,\n csrfToken,\n sections,\n filters,\n type: ReportType.DASHBOARD,\n actions: setDashboardActions(dashboardDefinition, reportDefinition, dashboardRequestData),\n },\n }\n}\n\nexport default {\n renderAsyncDashboard,\n}\n"],
|
|
5
|
+
"mappings": "6iBAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,aAAAE,EAAA,yBAAAC,IAAA,eAAAC,EAAAJ,GAAA,IAAAK,EAAqB,uBAGrBC,EAIO,+EAKPC,EAA2B,4CAG3BC,EAAuB,sDACvBC,EAA4B,mDAC5BD,EAA6B,2DAC7BA,EAA+B,yEAC/BA,EAAwB,uDACxBA,EAA4B,oEAC5BE,EAAmC,wEACnCF,EAA+B,sEAC/BG,EAAwB,+CACxBC,EAAyB,gDAEzBC,EAA4B,8DAE5B,MAAMC,EAAsB,CAC1BC,EACAC,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CACF,CACF,EAEA,IAAO7D,EAAQ,CACb,qBAAAC,CACF",
|
|
6
|
+
"names": ["utils_exports", "__export", "utils_default", "renderAsyncDashboard", "__toCommonJS", "import_parseurl", "import_types", "import_UserReports", "import_utils", "import_definitionUtils", "import_Scorecard", "import_ReportQuery", "import_localsHelper", "import_filtersTypeEnum", "setDashboardActions", "dashboardDefinition", "reportDefinition", "requestData", "reportName", "name", "actionsUrl", "executionId", "actions", "ReportActionsUtils", "getDefinitionData", "req", "res", "services", "next", "token", "LocalsHelper", "reportId", "id", "dataProductDefinitionsPath", "DefinitionUtils", "filtersData", "FilterUtils", "filtersQuery", "ReportQuery", "getSections", "dashboardData", "query", "section", "title", "description", "hasScorecard", "visualisations", "visDefinition", "type", "display", "visDescription", "visId", "data", "DashboardListUtils", "ScorecardVisualisation", "ChartUtils", "ScorecardsUtils", "updateStore", "tableId", "userId", "sections", "filters", "requestedReportService", "dashboardRequestData", "UserReportsUtils", "csrfToken", "dprUser", "nestedBaseUrl", "bookmarkService", "url", "parseUrl", "flattenedData"]
|
|
7
7
|
}
|
|
@@ -1,17 +1,13 @@
|
|
|
1
1
|
import parseUrl from 'parseurl'
|
|
2
|
-
import { Url } from 'url'
|
|
3
2
|
import { Request } from 'express'
|
|
4
|
-
import
|
|
5
|
-
|
|
3
|
+
import { Services } from '../../../../../types/Services'
|
|
6
4
|
import {
|
|
7
|
-
|
|
5
|
+
DashboardSection,
|
|
6
|
+
DashboardVisualisation,
|
|
8
7
|
DashboardVisualisationType,
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
type DashboardUISection,
|
|
13
|
-
type DashboardVisualisation,
|
|
14
|
-
} from '../../../../../components/_dashboards/dashboard/types'
|
|
8
|
+
} from '../../../../../components/_dashboards/dashboard-visualisation/types'
|
|
9
|
+
import type { AsyncReportUtilsParams } from '../../../../../types/AsyncReportUtils'
|
|
10
|
+
|
|
15
11
|
import type { DashboardDataResponse } from '../../../../../types/Metrics'
|
|
16
12
|
import type { RequestedReport } from '../../../../../types/UserReports'
|
|
17
13
|
import { ReportType } from '../../../../../types/UserReports'
|
|
@@ -27,48 +23,53 @@ import ScorecardVisualisation from '../../../../../components/_dashboards/scorec
|
|
|
27
23
|
import ReportActionsUtils from '../../../../../components/_reports/report-actions/utils'
|
|
28
24
|
import ReportQuery from '../../../../../types/ReportQuery'
|
|
29
25
|
import LocalsHelper from '../../../../../utils/localsHelper'
|
|
30
|
-
import { Services } from '../../../../../types/Services'
|
|
31
26
|
import { FilterValue } from '../../../../../components/_filters/types'
|
|
32
27
|
import { FiltersType } from '../../../../../components/_filters/filtersTypeEnum'
|
|
33
28
|
|
|
34
29
|
const setDashboardActions = (
|
|
35
|
-
dashboardDefinition: DashboardDefinition,
|
|
30
|
+
dashboardDefinition: components['schemas']['DashboardDefinition'],
|
|
36
31
|
reportDefinition: components['schemas']['ReportDefinitionSummary'],
|
|
37
|
-
requestData
|
|
32
|
+
requestData?: RequestedReport,
|
|
38
33
|
) => {
|
|
39
34
|
const reportName = reportDefinition.name
|
|
40
35
|
const { name } = dashboardDefinition
|
|
41
|
-
const actionsUrl = requestData
|
|
42
|
-
const
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
36
|
+
const actionsUrl = requestData?.url?.request?.fullUrl
|
|
37
|
+
const executionId = requestData?.executionId
|
|
38
|
+
|
|
39
|
+
let actions = {}
|
|
40
|
+
if (actionsUrl) {
|
|
41
|
+
actions = {
|
|
42
|
+
share: {
|
|
43
|
+
reportName,
|
|
44
|
+
name,
|
|
45
|
+
url: actionsUrl,
|
|
46
|
+
},
|
|
47
|
+
copy: {
|
|
48
|
+
url: actionsUrl,
|
|
49
|
+
},
|
|
50
|
+
}
|
|
51
|
+
if (executionId) {
|
|
52
|
+
actions = {
|
|
53
|
+
...actions,
|
|
54
|
+
refresh: {
|
|
55
|
+
url: actionsUrl,
|
|
56
|
+
executionId,
|
|
57
|
+
},
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
return ReportActionsUtils.getActions(actions)
|
|
58
63
|
}
|
|
59
64
|
|
|
60
65
|
const getDefinitionData = async ({ req, res, services, next }: AsyncReportUtilsParams) => {
|
|
61
66
|
const { token } = LocalsHelper.getValues(res)
|
|
62
67
|
const { reportId, id } = req.params
|
|
63
|
-
const
|
|
68
|
+
const dataProductDefinitionsPath = <string>req.query.dataProductDefinitionsPath
|
|
64
69
|
|
|
65
70
|
// Dashboard Definition,
|
|
66
|
-
const dashboardDefinition: DashboardDefinition =
|
|
67
|
-
token,
|
|
68
|
-
reportId,
|
|
69
|
-
id,
|
|
70
|
-
dataProductDefinitionsPath,
|
|
71
|
-
)
|
|
71
|
+
const dashboardDefinition: components['schemas']['DashboardDefinition'] =
|
|
72
|
+
await services.dashboardService.getDefinition(token, reportId, id, dataProductDefinitionsPath)
|
|
72
73
|
|
|
73
74
|
// Report summary data
|
|
74
75
|
const reportDefinition = await DefinitionUtils.getReportSummary(
|
|
@@ -104,61 +105,62 @@ const getDefinitionData = async ({ req, res, services, next }: AsyncReportUtilsP
|
|
|
104
105
|
}
|
|
105
106
|
|
|
106
107
|
const getSections = (
|
|
107
|
-
dashboardDefinition: DashboardDefinition,
|
|
108
|
+
dashboardDefinition: components['schemas']['DashboardDefinition'],
|
|
108
109
|
dashboardData: DashboardDataResponse[],
|
|
109
110
|
query: Record<string, string | string[]>,
|
|
110
|
-
):
|
|
111
|
-
return dashboardDefinition.sections.map((section:
|
|
111
|
+
): DashboardSection[] => {
|
|
112
|
+
return dashboardDefinition.sections.map((section: components['schemas']['DashboardSectionDefinition']) => {
|
|
112
113
|
const { id, display: title, description } = section
|
|
113
114
|
|
|
114
115
|
let hasScorecard = false
|
|
115
|
-
const visualisations = section.visualisations.map(
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
116
|
+
const visualisations: DashboardVisualisation[] = section.visualisations.map(
|
|
117
|
+
(visDefinition: components['schemas']['DashboardVisualisationDefinition']) => {
|
|
118
|
+
const { type, display, description: visDescription, id: visId } = visDefinition
|
|
119
|
+
|
|
120
|
+
let data: DashboardVisualisation['data'] | undefined
|
|
121
|
+
|
|
122
|
+
switch (type) {
|
|
123
|
+
case DashboardVisualisationType.LIST:
|
|
124
|
+
data = DashboardListUtils.createList(visDefinition, dashboardData)
|
|
125
|
+
break
|
|
126
|
+
|
|
127
|
+
case DashboardVisualisationType.SCORECARD:
|
|
128
|
+
hasScorecard = true
|
|
129
|
+
data = new ScorecardVisualisation(dashboardData, visDefinition).build()
|
|
130
|
+
break
|
|
131
|
+
|
|
132
|
+
case DashboardVisualisationType.SCORECARD_GROUP:
|
|
133
|
+
data = new ScorecardVisualisation(dashboardData, visDefinition, true).build()
|
|
134
|
+
break
|
|
135
|
+
|
|
136
|
+
case DashboardVisualisationType.BAR:
|
|
137
|
+
case DashboardVisualisationType.LINE:
|
|
138
|
+
case DashboardVisualisationType.DONUT: {
|
|
139
|
+
data = ChartUtils.createChart(visDefinition, dashboardData)
|
|
140
|
+
break
|
|
141
|
+
}
|
|
142
|
+
case DashboardVisualisationType.MATRIX_TIMESERIES: {
|
|
143
|
+
data = ChartUtils.createMatrixChart(visDefinition, dashboardData, query)
|
|
144
|
+
break
|
|
145
|
+
}
|
|
146
|
+
case DashboardVisualisationType.BAR_TIMESERIES:
|
|
147
|
+
case DashboardVisualisationType.LINE_TIMESERIES: {
|
|
148
|
+
data = ChartUtils.createTimeseriesCharts(visDefinition, dashboardData)
|
|
149
|
+
break
|
|
150
|
+
}
|
|
151
|
+
default:
|
|
152
|
+
break
|
|
144
153
|
}
|
|
145
|
-
case DashboardVisualisationType.BAR_TIMESERIES:
|
|
146
|
-
case DashboardVisualisationType.LINE_TIMESERIES: {
|
|
147
|
-
data = ChartUtils.createTimeseriesCharts(visDefinition, dashboardData)
|
|
148
|
-
break
|
|
149
|
-
}
|
|
150
|
-
default:
|
|
151
|
-
break
|
|
152
|
-
}
|
|
153
154
|
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
155
|
+
return {
|
|
156
|
+
id: visId,
|
|
157
|
+
title: display,
|
|
158
|
+
description: visDescription,
|
|
159
|
+
type,
|
|
160
|
+
data,
|
|
161
|
+
}
|
|
162
|
+
},
|
|
163
|
+
)
|
|
162
164
|
|
|
163
165
|
if (hasScorecard) ScorecardsUtils.mergeScorecardsIntoGroup(visualisations)
|
|
164
166
|
|
|
@@ -170,15 +172,14 @@ const updateStore = async (
|
|
|
170
172
|
services: Services,
|
|
171
173
|
tableId: string,
|
|
172
174
|
userId: string,
|
|
173
|
-
sections:
|
|
174
|
-
url: Url,
|
|
175
|
+
sections: DashboardSection[],
|
|
175
176
|
req: Request,
|
|
176
177
|
filters: FilterValue[],
|
|
177
|
-
) => {
|
|
178
|
-
const
|
|
179
|
-
|
|
180
|
-
userId
|
|
181
|
-
|
|
178
|
+
): Promise<RequestedReport | undefined> => {
|
|
179
|
+
const { requestedReportService } = services
|
|
180
|
+
const dashboardRequestData = requestedReportService
|
|
181
|
+
? await requestedReportService.getReportByTableId(tableId, userId)
|
|
182
|
+
: undefined
|
|
182
183
|
|
|
183
184
|
// Add to recently viewed
|
|
184
185
|
if (sections && sections.length && dashboardRequestData) {
|
|
@@ -197,6 +198,7 @@ const updateStore = async (
|
|
|
197
198
|
export const renderAsyncDashboard = async ({ req, res, services, next }: AsyncReportUtilsParams) => {
|
|
198
199
|
const { token, csrfToken, dprUser, nestedBaseUrl } = LocalsHelper.getValues(res)
|
|
199
200
|
const { reportId, id, tableId } = req.params
|
|
201
|
+
const { bookmarkService, requestedReportService } = services
|
|
200
202
|
const url = parseUrl(req)
|
|
201
203
|
|
|
202
204
|
// Get the definition Data
|
|
@@ -218,10 +220,13 @@ export const renderAsyncDashboard = async ({ req, res, services, next }: AsyncRe
|
|
|
218
220
|
const flattenedData: DashboardDataResponse[] = dashboardData.flat()
|
|
219
221
|
|
|
220
222
|
// Get the dashboard parts
|
|
221
|
-
const sections:
|
|
223
|
+
const sections: DashboardSection[] = getSections(dashboardDefinition, flattenedData, query)
|
|
222
224
|
|
|
223
225
|
// Update the store
|
|
224
|
-
|
|
226
|
+
let dashboardRequestData
|
|
227
|
+
if (requestedReportService) {
|
|
228
|
+
dashboardRequestData = await updateStore(services, tableId, dprUser.id, sections, req, filters.filters)
|
|
229
|
+
}
|
|
225
230
|
|
|
226
231
|
return {
|
|
227
232
|
dashboardData: {
|
|
@@ -231,7 +236,7 @@ export const renderAsyncDashboard = async ({ req, res, services, next }: AsyncRe
|
|
|
231
236
|
name: dashboardDefinition.name,
|
|
232
237
|
description: dashboardDefinition.description,
|
|
233
238
|
reportName: reportDefinition.name,
|
|
234
|
-
bookmarked: await
|
|
239
|
+
bookmarked: bookmarkService ? await bookmarkService.isBookmarked(id, reportId, dprUser.id) : false,
|
|
235
240
|
nestedBaseUrl,
|
|
236
241
|
csrfToken,
|
|
237
242
|
sections,
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
var
|
|
1
|
+
var R=Object.create;var i=Object.defineProperty;var w=Object.getOwnPropertyDescriptor;var E=Object.getOwnPropertyNames;var S=Object.getPrototypeOf,b=Object.prototype.hasOwnProperty;var H=(t,r)=>{for(var e in r)i(t,e,{get:r[e],enumerable:!0})},m=(t,r,e,s)=>{if(r&&typeof r=="object"||typeof r=="function")for(let o of E(r))!b.call(t,o)&&o!==e&&i(t,o,{get:()=>r[o],enumerable:!(s=w(r,o))||s.enumerable});return t};var p=(t,r,e)=>(e=t!=null?R(S(t)):{},m(r||!t||!t.__esModule?i(e,"default",{value:t,enumerable:!0}):e,t)),I=t=>m(i({},"__esModule",{value:!0}),t);var x={};H(x,{ViewAyncReportController:()=>y,default:()=>P});module.exports=I(x);var u=p(require("../../../../../components/error-summary/utils")),h=p(require("../../../../../utils/localsHelper")),v=p(require("./utils")),n=p(require("../../utils"));class y{constructor(r,e){this.GET=async(r,e,s)=>{const{type:o}=r.params;try{const c={req:r,res:e,services:this.services,next:s},a=await v.default.renderReport(c);e.render("dpr/routes/journeys/view-report/report",{layoutPath:this.layoutPath,...a})}catch(c){const a=u.default.handleError(c,r.params.type);let l;const{recentlyViewedService:d}=this.services;if(a.status==="EXPIRED"&&d){const{dprUser:f}=h.default.getValues(e);l=await d.asyncSetToExpiredByTableId(r.params.tableId,f.id)}r.body.title=`Failed to retrieve ${o}`,r.body.error=a,l&&(r.body.refreshLink=l),s()}};this.applyFilters=async(r,e,s)=>{await n.default.applyReportInteractiveQuery(r,e,this.services,"filters")};this.applyColumns=async(r,e,s)=>{await n.default.applyReportInteractiveQuery(r,e,this.services,"columns")};this.layoutPath=r,this.services=e}}var P=y;0&&(module.exports={ViewAyncReportController});
|
|
2
2
|
//# sourceMappingURL=controller.js.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../../../../src/dpr/routes/journeys/view-report/async/report/controller.ts"],
|
|
4
|
-
"sourcesContent": ["import { RequestHandler } from 'express'\nimport { Services } from '../../../../../types/Services'\nimport ErrorSummaryUtils from '../../../../../components/error-summary/utils'\nimport LocalsHelper from '../../../../../utils/localsHelper'\nimport AsyncReportUtils from './utils'\nimport ViewReportUtils from '../../utils'\n\nclass ViewAyncReportController {\n layoutPath: string\n\n services: Services\n\n constructor(layoutPath: string, services: Services) {\n this.layoutPath = layoutPath\n this.services = services\n }\n\n GET: RequestHandler = async (req, res, next) => {\n const { type } = req.params\n try {\n const params = { req, res, services: this.services, next }\n\n const renderData = await AsyncReportUtils.renderReport(params)\n\n res.render(`dpr/routes/journeys/view-report/report`, {\n layoutPath: this.layoutPath,\n ...renderData,\n })\n } catch (error) {\n const dprError = ErrorSummaryUtils.handleError(error, req.params.type)\n let refreshLink\n if (dprError.status === 'EXPIRED') {\n const { dprUser } = LocalsHelper.getValues(res)\n refreshLink = await
|
|
5
|
-
"mappings": "6iBAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,8BAAAE,EAAA,YAAAC,IAAA,eAAAC,EAAAJ,GAEA,IAAAK,EAA8B,4DAC9BC,EAAyB,gDACzBD,EAA6B,sBAC7BA,EAA4B,0BAE5B,MAAMH,CAAyB,CAK7B,YAAYK,EAAoBC,EAAoB,CAKpD,SAAsB,MAAOC,EAAKC,EAAKC,IAAS,CAC9C,KAAM,CAAE,KAAAC,CAAK,EAAIH,EAAI,OACrB,GAAI,CACF,MAAMI,EAAS,CAAE,IAAAJ,EAAK,IAAAC,EAAK,SAAU,KAAK,SAAU,KAAAC,CAAK,EAEnDG,EAAa,MAAM,EAAAC,QAAiB,aAAaF,CAAM,EAE7DH,EAAI,OAAO,yCAA0C,CACnD,WAAY,KAAK,WACjB,GAAGI,CACL,CAAC,CACH,OAASE,EAAO,CACd,MAAMC,EAAW,EAAAC,QAAkB,
|
|
6
|
-
"names": ["controller_exports", "__export", "ViewAyncReportController", "controller_default", "__toCommonJS", "import_utils", "import_localsHelper", "layoutPath", "services", "req", "res", "next", "type", "params", "renderData", "AsyncReportUtils", "error", "dprError", "ErrorSummaryUtils", "refreshLink", "dprUser", "LocalsHelper", "ViewReportUtils"]
|
|
4
|
+
"sourcesContent": ["import { RequestHandler } from 'express'\nimport { Services } from '../../../../../types/Services'\nimport ErrorSummaryUtils from '../../../../../components/error-summary/utils'\nimport LocalsHelper from '../../../../../utils/localsHelper'\nimport AsyncReportUtils from './utils'\nimport ViewReportUtils from '../../utils'\n\nclass ViewAyncReportController {\n layoutPath: string\n\n services: Services\n\n constructor(layoutPath: string, services: Services) {\n this.layoutPath = layoutPath\n this.services = services\n }\n\n GET: RequestHandler = async (req, res, next) => {\n const { type } = req.params\n try {\n const params = { req, res, services: this.services, next }\n\n const renderData = await AsyncReportUtils.renderReport(params)\n\n res.render(`dpr/routes/journeys/view-report/report`, {\n layoutPath: this.layoutPath,\n ...renderData,\n })\n } catch (error) {\n const dprError = ErrorSummaryUtils.handleError(<Error>error, req.params.type)\n let refreshLink\n const { recentlyViewedService } = this.services\n if (dprError.status === 'EXPIRED' && recentlyViewedService) {\n const { dprUser } = LocalsHelper.getValues(res)\n refreshLink = await recentlyViewedService.asyncSetToExpiredByTableId(req.params.tableId, dprUser.id)\n }\n req.body.title = `Failed to retrieve ${type}`\n req.body.error = dprError\n if (refreshLink) {\n req.body.refreshLink = refreshLink\n }\n next()\n }\n }\n\n applyFilters: RequestHandler = async (req, res, next) => {\n await ViewReportUtils.applyReportInteractiveQuery(req, res, this.services, 'filters')\n }\n\n applyColumns: RequestHandler = async (req, res, next) => {\n await ViewReportUtils.applyReportInteractiveQuery(req, res, this.services, 'columns')\n }\n}\n\nexport { ViewAyncReportController }\nexport default ViewAyncReportController\n"],
|
|
5
|
+
"mappings": "6iBAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,8BAAAE,EAAA,YAAAC,IAAA,eAAAC,EAAAJ,GAEA,IAAAK,EAA8B,4DAC9BC,EAAyB,gDACzBD,EAA6B,sBAC7BA,EAA4B,0BAE5B,MAAMH,CAAyB,CAK7B,YAAYK,EAAoBC,EAAoB,CAKpD,SAAsB,MAAOC,EAAKC,EAAKC,IAAS,CAC9C,KAAM,CAAE,KAAAC,CAAK,EAAIH,EAAI,OACrB,GAAI,CACF,MAAMI,EAAS,CAAE,IAAAJ,EAAK,IAAAC,EAAK,SAAU,KAAK,SAAU,KAAAC,CAAK,EAEnDG,EAAa,MAAM,EAAAC,QAAiB,aAAaF,CAAM,EAE7DH,EAAI,OAAO,yCAA0C,CACnD,WAAY,KAAK,WACjB,GAAGI,CACL,CAAC,CACH,OAASE,EAAO,CACd,MAAMC,EAAW,EAAAC,QAAkB,YAAmBF,EAAOP,EAAI,OAAO,IAAI,EAC5E,IAAIU,EACJ,KAAM,CAAE,sBAAAC,CAAsB,EAAI,KAAK,SACvC,GAAIH,EAAS,SAAW,WAAaG,EAAuB,CAC1D,KAAM,CAAE,QAAAC,CAAQ,EAAI,EAAAC,QAAa,UAAUZ,CAAG,EAC9CS,EAAc,MAAMC,EAAsB,2BAA2BX,EAAI,OAAO,QAASY,EAAQ,EAAE,CACrG,CACAZ,EAAI,KAAK,MAAQ,sBAAsBG,CAAI,GAC3CH,EAAI,KAAK,MAAQQ,EACbE,IACFV,EAAI,KAAK,YAAcU,GAEzBR,EAAK,CACP,CACF,EAEA,kBAA+B,MAAOF,EAAKC,EAAKC,IAAS,CACvD,MAAM,EAAAY,QAAgB,4BAA4Bd,EAAKC,EAAK,KAAK,SAAU,SAAS,CACtF,EAEA,kBAA+B,MAAOD,EAAKC,EAAKC,IAAS,CACvD,MAAM,EAAAY,QAAgB,4BAA4Bd,EAAKC,EAAK,KAAK,SAAU,SAAS,CACtF,EAtCE,KAAK,WAAaH,EAClB,KAAK,SAAWC,CAClB,CAqCF,CAGA,IAAOL,EAAQD",
|
|
6
|
+
"names": ["controller_exports", "__export", "ViewAyncReportController", "controller_default", "__toCommonJS", "import_utils", "import_localsHelper", "layoutPath", "services", "req", "res", "next", "type", "params", "renderData", "AsyncReportUtils", "error", "dprError", "ErrorSummaryUtils", "refreshLink", "recentlyViewedService", "dprUser", "LocalsHelper", "ViewReportUtils"]
|
|
7
7
|
}
|
|
@@ -27,14 +27,12 @@ class ViewAyncReportController {
|
|
|
27
27
|
...renderData,
|
|
28
28
|
})
|
|
29
29
|
} catch (error) {
|
|
30
|
-
const dprError = ErrorSummaryUtils.handleError(error, req.params.type)
|
|
30
|
+
const dprError = ErrorSummaryUtils.handleError(<Error>error, req.params.type)
|
|
31
31
|
let refreshLink
|
|
32
|
-
|
|
32
|
+
const { recentlyViewedService } = this.services
|
|
33
|
+
if (dprError.status === 'EXPIRED' && recentlyViewedService) {
|
|
33
34
|
const { dprUser } = LocalsHelper.getValues(res)
|
|
34
|
-
refreshLink = await
|
|
35
|
-
req.params.tableId,
|
|
36
|
-
dprUser.id,
|
|
37
|
-
)
|
|
35
|
+
refreshLink = await recentlyViewedService.asyncSetToExpiredByTableId(req.params.tableId, dprUser.id)
|
|
38
36
|
}
|
|
39
37
|
req.body.title = `Failed to retrieve ${type}`
|
|
40
38
|
req.body.error = dprError
|