@ministryofjustice/hmpps-digital-prison-reporting-frontend 4.22.2 → 4.22.3
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/DprPollingStatusClass.mjs +2 -2
- package/dpr/components/_async/async-filters-form/types.d.js +1 -1
- package/dpr/components/_async/async-filters-form/types.d.js.map +1 -1
- package/dpr/components/_async/async-filters-form/types.d.ts +0 -1
- 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 +2 -1
- package/dpr/components/_charts/utils.test.ts +0 -3
- package/dpr/components/bookmark-toggle/clientClass.mjs +3 -4
- package/dpr/components/bookmark-toggle/view.njk +1 -1
- package/dpr/components/user-reports/bookmarks/utils.js +1 -1
- package/dpr/components/user-reports/bookmarks/utils.js.map +3 -3
- package/dpr/components/user-reports/bookmarks/utils.ts +13 -3
- package/dpr/components/user-reports/requested/clientClass.mjs +18 -6
- package/dpr/components/user-reports/utils.js.map +2 -2
- package/dpr/components/user-reports/utils.test.ts +24 -24
- package/dpr/components/user-reports/utils.ts +2 -0
- package/dpr/components/user-reports/viewed/clientClass.mjs +3 -2
- package/dpr/middleware/setUpDprResources.js +1 -1
- package/dpr/middleware/setUpDprResources.js.map +3 -3
- package/dpr/middleware/setUpDprResources.test.ts +1 -0
- package/dpr/middleware/setUpDprResources.ts +3 -1
- package/dpr/routes/journeys/my-reports/bookmarks/controller.js +1 -1
- package/dpr/routes/journeys/my-reports/bookmarks/controller.js.map +3 -3
- package/dpr/routes/journeys/my-reports/bookmarks/controller.ts +6 -9
- package/dpr/routes/journeys/my-reports/bookmarks/routes.js +1 -1
- package/dpr/routes/journeys/my-reports/bookmarks/routes.js.map +2 -2
- package/dpr/routes/journeys/my-reports/bookmarks/routes.ts +0 -3
- package/dpr/routes/journeys/my-reports/bookmarks/service.js +3 -3
- package/dpr/routes/journeys/my-reports/bookmarks/service.js.map +3 -3
- package/dpr/routes/journeys/my-reports/bookmarks/service.ts +4 -1
- package/dpr/routes/journeys/my-reports/recently-viewed/controller.js +1 -1
- package/dpr/routes/journeys/my-reports/recently-viewed/controller.js.map +2 -2
- package/dpr/routes/journeys/my-reports/recently-viewed/controller.ts +1 -0
- package/dpr/routes/journeys/my-reports/requested-reports/service.js +1 -1
- package/dpr/routes/journeys/my-reports/requested-reports/service.js.map +3 -3
- package/dpr/routes/journeys/my-reports/requested-reports/service.ts +37 -1
- 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 +3 -1
- package/dpr/routes/journeys/request-report/tests.cy.js +1 -1
- package/dpr/routes/journeys/request-report/tests.cy.js.map +2 -2
- package/dpr/routes/journeys/request-report/tests.cy.ts +22 -1
- package/package.json +1 -1
|
@@ -28,13 +28,13 @@ class DprPollingStatusClass extends DprClientClass {
|
|
|
28
28
|
}
|
|
29
29
|
|
|
30
30
|
shouldPollStatus(data) {
|
|
31
|
-
return
|
|
31
|
+
return data.some((item) => {
|
|
32
32
|
return !this.END_STATUSES.includes(item.status)
|
|
33
33
|
})
|
|
34
34
|
}
|
|
35
35
|
|
|
36
36
|
shouldPollExpired(data) {
|
|
37
|
-
return
|
|
37
|
+
return data.some((item) => {
|
|
38
38
|
return !this.EXPIRED_END_STATUSES.includes(item.status)
|
|
39
39
|
})
|
|
40
40
|
}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";var n=Object.defineProperty;var
|
|
1
|
+
"use strict";var n=Object.defineProperty;var a=Object.getOwnPropertyDescriptor;var o=Object.getOwnPropertyNames;var l=Object.prototype.hasOwnProperty;var u=(t,r,s,i)=>{if(r&&typeof r=="object"||typeof r=="function")for(let e of o(r))!l.call(t,e)&&e!==s&&n(t,e,{get:()=>r[e],enumerable:!(i=a(r,e))||i.enumerable});return t};var g=t=>u(n({},"__esModule",{value:!0}),t);var f={};module.exports=g(f);
|
|
2
2
|
//# sourceMappingURL=types.d.js.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../../src/dpr/components/_async/async-filters-form/types.d.ts"],
|
|
4
|
-
"sourcesContent": ["import { FilterValue } from '../../_filters/types'\
|
|
4
|
+
"sourcesContent": ["import { FilterValue } from '../../_filters/types'\n\nexport interface requestAsyncReportParams {\n apiTimeout: number\n apiUrl: string\n token: string\n reportId: string\n reportVariantId: string\n query: Query\n}\n\n// todo update to correct type\ninterface Query {\n sortColumn: string\n sortedAsc: boolean\n filters: filter[]\n dataProductDefinitionsPath: string\n}\n\ninterface filter {\n [filterId: string]: string\n}\n\nexport interface SortByDefaults {\n options: { text: string; value: string }[]\n value: string\n}\n\nexport interface RenderFiltersReturnValue {\n filters: FilterValue[]\n sortBy?: FilterValue[]\n}\n\nexport interface SetQueryFromFiltersResult {\n query: Record<string, string>\n filterData: Record<string, string>\n querySummary: Array<Record<string, string>>\n sortData: Record<string, string>\n}\n"],
|
|
5
5
|
"mappings": "+WAAA,IAAAA,EAAA,kBAAAC,EAAAD",
|
|
6
6
|
"names": ["types_d_exports", "__toCommonJS"]
|
|
7
7
|
}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";var
|
|
1
|
+
"use strict";var E=Object.create;var k=Object.defineProperty;var U=Object.getOwnPropertyDescriptor;var V=Object.getOwnPropertyNames;var F=Object.getPrototypeOf,O=Object.prototype.hasOwnProperty;var Y=(e,t)=>{for(var o in t)k(e,o,{get:t[o],enumerable:!0})},R=(e,t,o,h)=>{if(t&&typeof t=="object"||typeof t=="function")for(let s of V(t))!O.call(e,s)&&s!==o&&k(e,s,{get:()=>t[s],enumerable:!(h=U(t,s))||h.enumerable});return e};var w=(e,t,o)=>(o=e!=null?E(F(e)):{},R(t||!e||!e.__esModule?k(o,"default",{value:e,enumerable:!0}):o,e)),$=e=>R(k({},"__esModule",{value:!0}),e);var q={};Y(q,{default:()=>j,getReportsList:()=>B});module.exports=$(q);var d=require("../../../types/UserReports"),x=w(require("../../show-more/utils")),l=require("../../../utils/reportListsHelper"),A=w(require("../../../utils/localsHelper"));const B=async(e,t,o)=>{const{definitions:h,csrfToken:s,bookmarkingEnabled:L,dprUser:v,nestedBaseUrl:H}=A.default.getValues(e),C=h.sort((m,n)=>m.name<n.name?-1:m.name>n.name?1:0).flatMap(m=>{const{id:n,name:T,description:S,variants:g,dashboards:f,authorised:b}=m,a={reportName:T,reportId:n,authorised:b,reportDescription:S||""};let u=[];g&&(u=g.map(r=>{const{id:i,name:c,description:y,isMissing:M,loadType:P}=r;return{...a,type:d.ReportType.REPORT,loadType:P||d.LoadType.ASYNC,id:i,name:c,description:y||"",isMissing:M}}));let D=[];f&&(D=f.map(r=>{const{id:i,name:c,description:y,loadType:M}=r;return{...a,type:d.ReportType.DASHBOARD,loadType:M||d.LoadType.ASYNC,id:i,name:c,description:y||"",isMissing:!1}}));const p=[...D,...u];return p.sort((r,i)=>r.name<i.name?-1:r.name>i.name?1:0),p}),I=await t.bookmarkService.getState(v.id),N=await Promise.all(C.map(async m=>{const{id:n,name:T,description:S,reportName:g,reportId:f,reportDescription:b,type:a,loadType:u,authorised:D,isMissing:p}=m,r=S||b||"",i=(0,l.setInitialHref)(u,a,f,n,e,p);let c;return(o?.bookmarkingEnabled!==void 0?o?.bookmarkingEnabled:L)&&(c=await t.bookmarkService.createBookMarkToggleHtml({userConfig:I,reportId:f,id:n,csrfToken:s,ctxId:"reports-list",reportType:a,isMissing:!!p,nestedBaseUrl:H})),[{html:`<p class="govuk-body-s">${g}</p>`},{html:(0,l.createListItemProductMin)(T,a)},{html:x.default.createShowMoreHtml(r)},{html:(0,l.createListActions)(i,a,u,c,D,p)}]}));return{head:[{text:"Product",classes:"dpr-product-head"},{text:"Name",classes:"dpr-name-head"},{text:"Description",classes:"dpr-description-head"},{text:"Actions",classes:"dpr-bookmark-head"}],rows:N,id:"dpr-reports-catalogue"}};var j={getReportsList:B};0&&(module.exports={getReportsList});
|
|
2
2
|
//# sourceMappingURL=utils.js.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../../src/dpr/components/_catalogue/catalogue-list/utils.ts"],
|
|
4
|
-
"sourcesContent": ["import { Response } from 'express'\nimport { components } from '../../../types/api'\nimport { Services } from '../../../types/Services'\nimport { DefinitionData, LoadType, ReportType } from '../../../types/UserReports'\nimport ShowMoreUtils from '../../show-more/utils'\nimport { createListItemProductMin, createListActions, setInitialHref } from '../../../utils/reportListsHelper'\nimport { CatalogueFeatures } from '../catalogue/types'\nimport LocalsHelper from '../../../utils/localsHelper'\n\nexport const getReportsList = async (\n res: Response,\n services: Services,\n features?: CatalogueFeatures,\n): Promise<{ head: { text: string }[]; rows: { text?: string; html?: string }[]; id: string }> => {\n const { definitions, csrfToken, bookmarkingEnabled, dprUser } = LocalsHelper.getValues(res)\n\n // Sort report Definitions by product name\n const sortedDefinitions = definitions.sort(\n (a: components['schemas']['ReportDefinitionSummary'], b: components['schemas']['ReportDefinitionSummary']) => {\n if (a.name < b.name) return -1\n if (a.name > b.name) return 1\n return 0\n },\n )\n\n // Sort by variant/dashboard name\n const sortedVariants = sortedDefinitions.flatMap((def: components['schemas']['ReportDefinitionSummary']) => {\n const { id: reportId, name: reportName, description: reportDescription, variants, dashboards, authorised } = def\n\n const productBase = {\n reportName,\n reportId,\n authorised,\n reportDescription: reportDescription || '',\n }\n\n let variantsArray: DefinitionData[] = []\n if (variants) {\n variantsArray = variants.map((variant: components['schemas']['VariantDefinitionSummary']) => {\n const { id, name, description, isMissing, loadType } = variant\n\n return {\n ...productBase,\n type: ReportType.REPORT,\n loadType: <LoadType>loadType || LoadType.ASYNC,\n id,\n name,\n description: description || '',\n isMissing,\n }\n })\n }\n\n let dashboardsArray: DefinitionData[] = []\n if (dashboards) {\n dashboardsArray = dashboards.map((dashboard: components['schemas']['DashboardDefinitionSummary']) => {\n const { id, name, description, loadType } = dashboard\n\n return {\n ...productBase,\n type: ReportType.DASHBOARD,\n loadType: <LoadType>loadType || LoadType.ASYNC,\n id,\n name,\n description: description || '',\n isMissing: false,\n }\n })\n }\n\n const mergedArray = [...dashboardsArray, ...variantsArray]\n\n mergedArray.sort((a: DefinitionData, b: DefinitionData) => {\n if (a.name < b.name) return -1\n if (a.name > b.name) return 1\n return 0\n })\n\n return mergedArray\n })\n\n const userConfig = await services.bookmarkService.getState(dprUser.id)\n const rows = await Promise.all(\n sortedVariants.map(async (v: DefinitionData) => {\n const { id, name, description, reportName, reportId, reportDescription, type, loadType, authorised, isMissing } =\n v\n const desc = description || reportDescription || ''\n\n const href = setInitialHref(loadType, type, reportId, id, res, isMissing)\n\n let bookmarkHtml\n const showBookMarkToggle =\n features?.bookmarkingEnabled !== undefined ? features?.bookmarkingEnabled : bookmarkingEnabled\n\n if (showBookMarkToggle) {\n bookmarkHtml = await services.bookmarkService.createBookMarkToggleHtml({\n userConfig,\n reportId,\n id,\n csrfToken,\n ctxId: 'reports-list',\n reportType: type,\n isMissing: Boolean(isMissing),\n })\n }\n\n return [\n { html: `<p class=\"govuk-body-s\">${reportName}</p>` },\n { html: createListItemProductMin(name, <ReportType>type) },\n { html: ShowMoreUtils.createShowMoreHtml(desc) },\n { html: createListActions(href, type, loadType, bookmarkHtml, authorised, isMissing) },\n ]\n }),\n )\n\n const head = [\n { text: 'Product', classes: 'dpr-product-head' },\n { text: 'Name', classes: 'dpr-name-head' },\n { text: 'Description', classes: 'dpr-description-head' },\n { text: 'Actions', classes: 'dpr-bookmark-head' },\n ]\n\n return {\n head,\n rows,\n id: 'dpr-reports-catalogue',\n }\n}\n\nexport default {\n getReportsList,\n}\n"],
|
|
5
|
-
"mappings": "0jBAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,aAAAE,EAAA,mBAAAC,IAAA,eAAAC,EAAAJ,GAGA,IAAAK,EAAqD,sCACrDC,EAA0B,oCAC1BC,EAA4E,4CAE5EC,EAAyB,0CAElB,MAAML,EAAiB,MAC5BM,EACAC,EACAC,IACgG,CAChG,KAAM,CAAE,YAAAC,EAAa,UAAAC,EAAW,mBAAAC,EAAoB,QAAAC,
|
|
6
|
-
"names": ["utils_exports", "__export", "utils_default", "getReportsList", "__toCommonJS", "import_UserReports", "import_utils", "import_reportListsHelper", "import_localsHelper", "res", "services", "features", "definitions", "csrfToken", "bookmarkingEnabled", "dprUser", "LocalsHelper", "sortedVariants", "a", "b", "def", "reportId", "reportName", "reportDescription", "variants", "dashboards", "authorised", "productBase", "variantsArray", "variant", "id", "name", "description", "isMissing", "loadType", "dashboardsArray", "dashboard", "mergedArray", "userConfig", "rows", "v", "type", "desc", "href", "bookmarkHtml", "ShowMoreUtils"]
|
|
4
|
+
"sourcesContent": ["import { Response } from 'express'\nimport { components } from '../../../types/api'\nimport { Services } from '../../../types/Services'\nimport { DefinitionData, LoadType, ReportType } from '../../../types/UserReports'\nimport ShowMoreUtils from '../../show-more/utils'\nimport { createListItemProductMin, createListActions, setInitialHref } from '../../../utils/reportListsHelper'\nimport { CatalogueFeatures } from '../catalogue/types'\nimport LocalsHelper from '../../../utils/localsHelper'\n\nexport const getReportsList = async (\n res: Response,\n services: Services,\n features?: CatalogueFeatures,\n): Promise<{ head: { text: string }[]; rows: { text?: string; html?: string }[]; id: string }> => {\n const { definitions, csrfToken, bookmarkingEnabled, dprUser, nestedBaseUrl } = LocalsHelper.getValues(res)\n\n // Sort report Definitions by product name\n const sortedDefinitions = definitions.sort(\n (a: components['schemas']['ReportDefinitionSummary'], b: components['schemas']['ReportDefinitionSummary']) => {\n if (a.name < b.name) return -1\n if (a.name > b.name) return 1\n return 0\n },\n )\n\n // Sort by variant/dashboard name\n const sortedVariants = sortedDefinitions.flatMap((def: components['schemas']['ReportDefinitionSummary']) => {\n const { id: reportId, name: reportName, description: reportDescription, variants, dashboards, authorised } = def\n\n const productBase = {\n reportName,\n reportId,\n authorised,\n reportDescription: reportDescription || '',\n }\n\n let variantsArray: DefinitionData[] = []\n if (variants) {\n variantsArray = variants.map((variant: components['schemas']['VariantDefinitionSummary']) => {\n const { id, name, description, isMissing, loadType } = variant\n\n return {\n ...productBase,\n type: ReportType.REPORT,\n loadType: <LoadType>loadType || LoadType.ASYNC,\n id,\n name,\n description: description || '',\n isMissing,\n }\n })\n }\n\n let dashboardsArray: DefinitionData[] = []\n if (dashboards) {\n dashboardsArray = dashboards.map((dashboard: components['schemas']['DashboardDefinitionSummary']) => {\n const { id, name, description, loadType } = dashboard\n\n return {\n ...productBase,\n type: ReportType.DASHBOARD,\n loadType: <LoadType>loadType || LoadType.ASYNC,\n id,\n name,\n description: description || '',\n isMissing: false,\n }\n })\n }\n\n const mergedArray = [...dashboardsArray, ...variantsArray]\n\n mergedArray.sort((a: DefinitionData, b: DefinitionData) => {\n if (a.name < b.name) return -1\n if (a.name > b.name) return 1\n return 0\n })\n\n return mergedArray\n })\n\n const userConfig = await services.bookmarkService.getState(dprUser.id)\n const rows = await Promise.all(\n sortedVariants.map(async (v: DefinitionData) => {\n const { id, name, description, reportName, reportId, reportDescription, type, loadType, authorised, isMissing } =\n v\n const desc = description || reportDescription || ''\n\n const href = setInitialHref(loadType, type, reportId, id, res, isMissing)\n\n let bookmarkHtml\n const showBookMarkToggle =\n features?.bookmarkingEnabled !== undefined ? features?.bookmarkingEnabled : bookmarkingEnabled\n\n if (showBookMarkToggle) {\n bookmarkHtml = await services.bookmarkService.createBookMarkToggleHtml({\n userConfig,\n reportId,\n id,\n csrfToken,\n ctxId: 'reports-list',\n reportType: type,\n isMissing: Boolean(isMissing),\n nestedBaseUrl,\n })\n }\n\n return [\n { html: `<p class=\"govuk-body-s\">${reportName}</p>` },\n { html: createListItemProductMin(name, <ReportType>type) },\n { html: ShowMoreUtils.createShowMoreHtml(desc) },\n { html: createListActions(href, type, loadType, bookmarkHtml, authorised, isMissing) },\n ]\n }),\n )\n\n const head = [\n { text: 'Product', classes: 'dpr-product-head' },\n { text: 'Name', classes: 'dpr-name-head' },\n { text: 'Description', classes: 'dpr-description-head' },\n { text: 'Actions', classes: 'dpr-bookmark-head' },\n ]\n\n return {\n head,\n rows,\n id: 'dpr-reports-catalogue',\n }\n}\n\nexport default {\n getReportsList,\n}\n"],
|
|
5
|
+
"mappings": "0jBAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,aAAAE,EAAA,mBAAAC,IAAA,eAAAC,EAAAJ,GAGA,IAAAK,EAAqD,sCACrDC,EAA0B,oCAC1BC,EAA4E,4CAE5EC,EAAyB,0CAElB,MAAML,EAAiB,MAC5BM,EACAC,EACAC,IACgG,CAChG,KAAM,CAAE,YAAAC,EAAa,UAAAC,EAAW,mBAAAC,EAAoB,QAAAC,EAAS,cAAAC,CAAc,EAAI,EAAAC,QAAa,UAAUR,CAAG,EAYnGS,EAToBN,EAAY,KACpC,CAACO,EAAqDC,IAChDD,EAAE,KAAOC,EAAE,KAAa,GACxBD,EAAE,KAAOC,EAAE,KAAa,EACrB,CAEX,EAGyC,QAASC,GAA0D,CAC1G,KAAM,CAAE,GAAIC,EAAU,KAAMC,EAAY,YAAaC,EAAmB,SAAAC,EAAU,WAAAC,EAAY,WAAAC,CAAW,EAAIN,EAEvGO,EAAc,CAClB,WAAAL,EACA,SAAAD,EACA,WAAAK,EACA,kBAAmBH,GAAqB,EAC1C,EAEA,IAAIK,EAAkC,CAAC,EACnCJ,IACFI,EAAgBJ,EAAS,IAAKK,GAA+D,CAC3F,KAAM,CAAE,GAAAC,EAAI,KAAAC,EAAM,YAAAC,EAAa,UAAAC,EAAW,SAAAC,CAAS,EAAIL,EAEvD,MAAO,CACL,GAAGF,EACH,KAAM,aAAW,OACjB,SAAoBO,GAAY,WAAS,MACzC,GAAAJ,EACA,KAAAC,EACA,YAAaC,GAAe,GAC5B,UAAAC,CACF,CACF,CAAC,GAGH,IAAIE,EAAoC,CAAC,EACrCV,IACFU,EAAkBV,EAAW,IAAK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AAclB,EAAYO,CAAS,CAAE,CACvF,CACF,CAAC,CACH,EASA,MAAO,CACL,KARW,CACX,CAAE,KAAM,UAAW,QAAS,kBAAmB,EAC/C,CAAE,KAAM,OAAQ,QAAS,eAAgB,EACzC,CAAE,KAAM,cAAe,QAAS,sBAAuB,EACvD,CAAE,KAAM,UAAW,QAAS,mBAAoB,CAClD,EAIE,KAAAM,EACA,GAAI,uBACN,CACF,EAEA,IAAOtC,EAAQ,CACb,eAAAC,CACF",
|
|
6
|
+
"names": ["utils_exports", "__export", "utils_default", "getReportsList", "__toCommonJS", "import_UserReports", "import_utils", "import_reportListsHelper", "import_localsHelper", "res", "services", "features", "definitions", "csrfToken", "bookmarkingEnabled", "dprUser", "nestedBaseUrl", "LocalsHelper", "sortedVariants", "a", "b", "def", "reportId", "reportName", "reportDescription", "variants", "dashboards", "authorised", "productBase", "variantsArray", "variant", "id", "name", "description", "isMissing", "loadType", "dashboardsArray", "dashboard", "mergedArray", "userConfig", "rows", "v", "type", "desc", "href", "bookmarkHtml", "ShowMoreUtils"]
|
|
7
7
|
}
|
|
@@ -12,7 +12,7 @@ export const getReportsList = async (
|
|
|
12
12
|
services: Services,
|
|
13
13
|
features?: CatalogueFeatures,
|
|
14
14
|
): Promise<{ head: { text: string }[]; rows: { text?: string; html?: string }[]; id: string }> => {
|
|
15
|
-
const { definitions, csrfToken, bookmarkingEnabled, dprUser } = LocalsHelper.getValues(res)
|
|
15
|
+
const { definitions, csrfToken, bookmarkingEnabled, dprUser, nestedBaseUrl } = LocalsHelper.getValues(res)
|
|
16
16
|
|
|
17
17
|
// Sort report Definitions by product name
|
|
18
18
|
const sortedDefinitions = definitions.sort(
|
|
@@ -101,6 +101,7 @@ export const getReportsList = async (
|
|
|
101
101
|
ctxId: 'reports-list',
|
|
102
102
|
reportType: type,
|
|
103
103
|
isMissing: Boolean(isMissing),
|
|
104
|
+
nestedBaseUrl,
|
|
104
105
|
})
|
|
105
106
|
}
|
|
106
107
|
|
|
@@ -39,7 +39,6 @@ describe('ChartCard Utils', () => {
|
|
|
39
39
|
it('should get the snapshot chart data', async () => {
|
|
40
40
|
const expectedResult = barChartDataHasEthnicity
|
|
41
41
|
const result = ChartCardUtils.createChart(snapshotVisualisationDefinition, dashboardMetricsData.flat(), 'bar')
|
|
42
|
-
console.log(JSON.stringify(result, null, 2))
|
|
43
42
|
expect(result).toEqual(expectedResult)
|
|
44
43
|
})
|
|
45
44
|
|
|
@@ -64,8 +63,6 @@ describe('ChartCard Utils', () => {
|
|
|
64
63
|
'line-timeseries',
|
|
65
64
|
{},
|
|
66
65
|
)
|
|
67
|
-
|
|
68
|
-
console.log(JSON.stringify(result, null, 2))
|
|
69
66
|
expect(result).toEqual(expectedResult)
|
|
70
67
|
})
|
|
71
68
|
})
|
|
@@ -69,17 +69,16 @@ class BookmarkToggle extends DprClientClass {
|
|
|
69
69
|
}
|
|
70
70
|
|
|
71
71
|
async toggleBookmark(type, id, reportId, reportType, csrfToken) {
|
|
72
|
-
const
|
|
73
|
-
const endpoint = this.baseUrl ? `${this.baseUrl}/dpr/my-reports/bookmarks/` : `dpr/my-reports/bookmarks/`
|
|
74
|
-
|
|
72
|
+
const endpoint = this.baseUrl ? `${this.baseUrl}/dpr/my-reports/bookmarks/` : `/dpr/my-reports/bookmarks/`
|
|
75
73
|
await fetch(endpoint, {
|
|
76
|
-
method,
|
|
74
|
+
method: 'post',
|
|
77
75
|
headers: {
|
|
78
76
|
Accept: 'application/json',
|
|
79
77
|
'Content-Type': 'application/json',
|
|
80
78
|
'CSRF-Token': csrfToken,
|
|
81
79
|
},
|
|
82
80
|
body: JSON.stringify({
|
|
81
|
+
type,
|
|
83
82
|
id,
|
|
84
83
|
reportId,
|
|
85
84
|
reportType,
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
{% set tooltip %}{{ 'Remove bookmark' if bookmarked else 'Add bookmark' }}{% endset %}
|
|
5
5
|
|
|
6
6
|
<button class='dpr-bookmark dpr-bookmark-inline dpr-bookmark-component' data-dpr-module="bookmark-toggle">
|
|
7
|
-
<input class="bookmark-input" arial-labelledby="{{id}}-{{reportId}}-{{ ctxId }}-bookmark-label" type='checkbox' id='{{ reportId }}-{{ id }}-{{ ctxId }}' data-id='{{ id }}' data-report-id='{{ reportId }}' data-report-type='{{ type }}' data-csrf-token='{{ csrfToken }}' data-base-url="{{ nestedBaseUrl }}"{{ checked }}/>
|
|
7
|
+
<input class="bookmark-input" arial-labelledby="{{id}}-{{reportId}}-{{ ctxId }}-bookmark-label" type='checkbox' id='{{ reportId }}-{{ id }}-{{ ctxId }}' data-id='{{ id }}' data-report-id='{{ reportId }}' data-report-type='{{ type }}' data-csrf-token='{{ csrfToken }}' data-base-url="{{ nestedBaseUrl }}" {{ checked }}/>
|
|
8
8
|
<label id="{{id}}-{{reportId}}-{{ ctxId }}-bookmark-label" tabindex="0" for='{{ reportId }}-{{ id }}-{{ ctxId }}' class=''><span class="govuk-link--no-visited-state dpr-bookmark-label dpr-bookmark-label--component govuk-body-xs">{{tooltip}}</span></label>
|
|
9
9
|
</button>
|
|
10
10
|
{% endmacro %}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";var N=Object.create;var
|
|
1
|
+
"use strict";var N=Object.create;var D=Object.defineProperty;var A=Object.getOwnPropertyDescriptor;var M=Object.getOwnPropertyNames;var O=Object.getPrototypeOf,U=Object.prototype.hasOwnProperty;var q=(o,t)=>{for(var e in t)D(o,e,{get:t[e],enumerable:!0})},R=(o,t,e,n)=>{if(t&&typeof t=="object"||typeof t=="function")for(let r of M(t))!U.call(o,r)&&r!==e&&D(o,r,{get:()=>t[r],enumerable:!(n=A(t,r))||n.enumerable});return o};var B=(o,t,e)=>(e=o!=null?N(O(o)):{},R(t||!o||!o.__esModule?D(e,"default",{value:o,enumerable:!0}):e,o)),F=o=>R(D({},"__esModule",{value:!0}),o);var _={};q(_,{default:()=>Y,formatBookmark:()=>P,formatBookmarks:()=>w,renderBookmarkList:()=>x});module.exports=F(_);var y=require("../../../types/UserReports"),b=B(require("../../show-more/utils")),T=B(require("../../../utils/logger")),v=B(require("../../../utils/definitionUtils")),u=require("../../../utils/reportListsHelper"),S=B(require("../../../utils/localsHelper"));const w=async o=>o.map(t=>P(t)).sort((t,e)=>t.text.localeCompare(e.text)),P=o=>{const t=JSON.parse(JSON.stringify(o)),{id:e,name:n,description:r,href:m,reportName:p,type:a}=t;return{id:e,reportName:p,text:n,description:r,href:m,type:a}},V=async(o,t,e,n,r,m)=>{const p=await t.getState(n),a=await Promise.all(o.sort((i,s)=>i.name.localeCompare(s.name)).map(async i=>E(i,t,e,p,m)));return{rows:r?a.slice(0,r):a,head:[{text:"Product",classes:"dpr-req-product-head"},{text:"Description",classes:"dpr-bm-description-head"},{text:"Actions",classes:"dpr-bm-actions-head"}]}},E=async(o,t,e,n,r)=>{const{description:m,reportName:p,reportId:a,id:i,href:s,name:l,type:c,loadType:k}=o,d=await t.createBookMarkToggleHtml({userConfig:n,reportId:a,id:i,csrfToken:e,ctxId:"bookmark-list",reportType:c,isMissing:!1,nestedBaseUrl:r});return[{html:(0,u.createListItemProduct)(p,l,c)},{html:b.default.createShowMoreHtml(m),classes:"dpr-req-cell"},{html:(0,u.createListActions)(s,c,k,d),classes:"dpr-req-cell dpr-req-cell__status"}]},J=async(o,t,e,n)=>{const r=[],{definitionsPath:m}=S.default.getValues(t);return await Promise.all(o.map(async p=>{let a;const{reportId:i,id:s,automatic:l,type:c}=p,k=c||y.ReportType.REPORT;try{let d="",f="",g=y.LoadType.ASYNC;const C=(0,u.setInitialHref)(g,k,i,s,t),h=await v.default.getReportSummary(i,n.reportingService,e,m),H=h.name;if(k===y.ReportType.REPORT){const I=h.variants.find(L=>L.id===s);a=await n.reportingService.getDefinition(e,i,s,m),d=a.variant.name,f=a.variant.description||a.description||"",g=I?.loadType||g}k===y.ReportType.DASHBOARD&&(a=await n.dashboardService.getDefinition(e,i,s,m),d=a.name,f=a.description||""),a&&r.push({reportId:i,id:s,reportName:H,name:d,description:f,type:k,href:C,loadType:g,automatic:l})}catch{T.default.warn(`Failed to map bookmark for: Report ${i}, variant ${s}`);const{dprUser:f}=S.default.getValues(t);await n.bookmarkService.removeBookmark(f.id,s,i)}})),r},x=async({services:o,maxRows:t=20,res:e})=>{const{token:n,csrfToken:r,dprUser:m,bookmarks:p,nestedBaseUrl:a}=S.default.getValues(e),i=await J(p,e,n,o);let s=await w(i);const l=s.length;t&&(s=s.slice(0,t));const c=await V(i,o.bookmarkService,r,m.id,t,a),k={...s.length&&{href:"/dpr/my-reports/bookmarks/list"},...!s.length&&{emptyMessage:"You have 0 bookmarked reports"}},d={amount:l,shown:l>t?t:l,max:t};return{head:k,tableData:c,total:d,csrfToken:r,type:"bookmark"}};var Y={renderBookmarkList:x};0&&(module.exports={formatBookmark,formatBookmarks,renderBookmarkList});
|
|
2
2
|
//# sourceMappingURL=utils.js.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../../src/dpr/components/user-reports/bookmarks/utils.ts"],
|
|
4
|
-
"sourcesContent": ["import { Response } from 'express'\nimport { BookmarkService } from '../../../services'\nimport { BookmarkedReportData, BookmarkStoreData } from '../../../types/Bookmark'\nimport { FormattedBookmarkData, LoadType, ReportType } from '../../../types/UserReports'\nimport { Services } from '../../../types/Services'\nimport ShowMoreUtils from '../../show-more/utils'\nimport logger from '../../../utils/logger'\nimport DefinitionUtils from '../../../utils/definitionUtils'\nimport { createListItemProduct, createListActions, setInitialHref } from '../../../utils/reportListsHelper'\nimport LocalsHelper from '../../../utils/localsHelper'\nimport { ReportStoreConfig } from '../../../types/ReportStore'\n\nexport const formatBookmarks = async (bookmarksData: BookmarkedReportData[]): Promise<FormattedBookmarkData[]> => {\n return bookmarksData\n .map((report: BookmarkedReportData) => {\n return formatBookmark(report)\n })\n .sort((a, b) => a.text.localeCompare(b.text))\n}\n\nexport const formatBookmark = (bookmarkData: BookmarkedReportData): FormattedBookmarkData => {\n const reportData: BookmarkedReportData = JSON.parse(JSON.stringify(bookmarkData))\n const { id, name, description, href, reportName, type } = reportData\n\n return {\n id,\n reportName,\n text: name,\n description,\n href,\n type: type as ReportType,\n }\n}\n\nconst formatTable = async (\n bookmarksData: BookmarkedReportData[],\n bookmarkService: BookmarkService,\n csrfToken: string,\n userId: string,\n maxRows?: number,\n) => {\n const userConfig = await bookmarkService.getState(userId)\n const rows = await Promise.all(\n bookmarksData\n .sort((a, b) => a.name.localeCompare(b.name))\n .map(async (bookmark: BookmarkedReportData) => {\n return formatTableData(bookmark, bookmarkService, csrfToken, userConfig)\n }),\n )\n\n return {\n rows: maxRows ? rows.slice(0, maxRows) : rows,\n head: [\n { text: 'Product', classes: 'dpr-req-product-head' },\n { text: 'Description', classes: 'dpr-bm-description-head' },\n { text: 'Actions', classes: 'dpr-bm-actions-head' },\n ],\n }\n}\n\nconst formatTableData = async (\n bookmarksData: BookmarkedReportData,\n bookmarkService: BookmarkService,\n csrfToken: string,\n userConfig: ReportStoreConfig,\n) => {\n const { description, reportName, reportId, id, href, name, type, loadType } = bookmarksData\n const bookmarkHtml = await bookmarkService.createBookMarkToggleHtml({\n userConfig,\n reportId,\n id,\n csrfToken,\n ctxId: 'bookmark-list',\n reportType: type,\n // We don't have the data here, and missing reports should never get into bookmarked, viewed or requested\n isMissing: false,\n })\n return [\n {\n html: createListItemProduct(reportName, name, type),\n },\n { html: ShowMoreUtils.createShowMoreHtml(description), classes: 'dpr-req-cell' },\n {\n html: createListActions(href, type, loadType, bookmarkHtml),\n classes: 'dpr-req-cell dpr-req-cell__status',\n },\n ]\n}\n\nconst mapBookmarkIdsToDefinition = async (\n bookmarks: BookmarkStoreData[],\n res: Response,\n token: string,\n services: Services,\n): Promise<BookmarkedReportData[]> => {\n const bookmarkData: BookmarkedReportData[] = []\n const { definitionsPath } = LocalsHelper.getValues(res)\n\n await Promise.all(\n bookmarks.map(async (bookmark) => {\n let definition\n const { reportId, id, automatic, type } = bookmark\n const reportType: ReportType = type ? (type as ReportType) : ReportType.REPORT\n\n try {\n let name = ''\n let description = ''\n let loadType = LoadType.ASYNC\n const href = setInitialHref(loadType, reportType, reportId, id, res)\n\n const procuctSummary = await DefinitionUtils.getReportSummary(\n reportId,\n services.reportingService,\n token,\n definitionsPath,\n )\n const reportName = procuctSummary.name\n\n if (reportType === ReportType.REPORT) {\n const variantSummary = procuctSummary.variants.find((v) => v.id === id)\n definition = await services.reportingService.getDefinition(token, reportId, id, definitionsPath)\n name = definition.variant.name\n description = definition.variant.description || definition.description || ''\n loadType = (variantSummary?.loadType as LoadType) || loadType\n }\n\n if (reportType === ReportType.DASHBOARD) {\n definition = await services.dashboardService.getDefinition(token, reportId, id, definitionsPath)\n name = definition.name\n description = definition.description || ''\n }\n\n if (definition) {\n bookmarkData.push({\n reportId,\n id,\n reportName,\n name,\n description,\n type: reportType,\n href,\n loadType,\n automatic,\n })\n }\n } catch (error) {\n // DPD has been deleted so API throws error\n logger.warn(`Failed to map bookmark for: Report ${reportId}, variant ${id}`)\n const { dprUser } = LocalsHelper.getValues(res)\n await services.bookmarkService.removeBookmark(dprUser.id, id, reportId)\n }\n }),\n )\n return bookmarkData\n}\n\nexport const renderBookmarkList = async ({\n services,\n maxRows = 20,\n res,\n}: {\n services: Services\n maxRows?: number\n res: Response\n}) => {\n const { token, csrfToken, dprUser, bookmarks } = LocalsHelper.getValues(res)\n const bookmarksData: BookmarkedReportData[] = await mapBookmarkIdsToDefinition(bookmarks, res, token, services)\n\n let formatted = await formatBookmarks(bookmarksData)\n const formattedCount = formatted.length\n\n if (maxRows) formatted = formatted.slice(0, maxRows)\n const tableData = await formatTable(bookmarksData
|
|
5
|
-
"mappings": "0jBAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,aAAAE,EAAA,mBAAAC,EAAA,oBAAAC,EAAA,uBAAAC,IAAA,eAAAC,EAAAN,GAGA,IAAAO,EAA4D,sCAE5DC,EAA0B,oCAC1BC,EAAmB,oCACnBC,EAA4B,6CAC5BC,EAAyE,4CACzEC,EAAyB,0CAGlB,MAAMR,EAAkB,MAAOS,GAC7BA,EACJ,IAAKC,GACGX,EAAeW,CAAM,CAC7B,EACA,KAAK,CAACC,EAAGC,IAAMD,EAAE,KAAK,cAAcC,EAAE,IAAI,CAAC,EAGnCb,EAAkBc,GAA8D,CAC3F,MAAMC,EAAmC,KAAK,MAAM,KAAK,UAAUD,CAAY,CAAC,EAC1E,CAAE,GAAAE,EAAI,KAAAC,EAAM,YAAAC,EAAa,KAAAC,EAAM,WAAAC,EAAY,KAAAC,CAAK,EAAIN,EAE1D,MAAO,CACL,GAAAC,EACA,WAAAI,EACA,KAAMH,EACN,YAAAC,EACA,KAAAC,EACA,KAAME,CACR,CACF,EAEMC,EAAc,MAClBZ,EACAa,EACAC,EACAC,EACAC,IACG,CACH,MAAMC,EAAa,
|
|
6
|
-
"names": ["utils_exports", "__export", "utils_default", "formatBookmark", "formatBookmarks", "renderBookmarkList", "__toCommonJS", "import_UserReports", "import_utils", "import_logger", "import_definitionUtils", "import_reportListsHelper", "import_localsHelper", "bookmarksData", "report", "a", "b", "bookmarkData", "reportData", "id", "name", "description", "href", "reportName", "type", "formatTable", "bookmarkService", "csrfToken", "userId", "maxRows", "userConfig", "rows", "bookmark", "formatTableData", "reportId", "loadType", "bookmarkHtml", "ShowMoreUtils", "mapBookmarkIdsToDefinition", "bookmarks", "res", "token", "services", "definitionsPath", "LocalsHelper", "definition", "automatic", "reportType", "procuctSummary", "DefinitionUtils", "variantSummary", "v", "logger", "dprUser", "formatted", "formattedCount", "tableData", "head", "total"]
|
|
4
|
+
"sourcesContent": ["import { Response } from 'express'\nimport { BookmarkService } from '../../../services'\nimport { BookmarkedReportData, BookmarkStoreData } from '../../../types/Bookmark'\nimport { FormattedBookmarkData, LoadType, ReportType } from '../../../types/UserReports'\nimport { Services } from '../../../types/Services'\nimport ShowMoreUtils from '../../show-more/utils'\nimport logger from '../../../utils/logger'\nimport DefinitionUtils from '../../../utils/definitionUtils'\nimport { createListItemProduct, createListActions, setInitialHref } from '../../../utils/reportListsHelper'\nimport LocalsHelper from '../../../utils/localsHelper'\nimport { ReportStoreConfig } from '../../../types/ReportStore'\n\nexport const formatBookmarks = async (bookmarksData: BookmarkedReportData[]): Promise<FormattedBookmarkData[]> => {\n return bookmarksData\n .map((report: BookmarkedReportData) => {\n return formatBookmark(report)\n })\n .sort((a, b) => a.text.localeCompare(b.text))\n}\n\nexport const formatBookmark = (bookmarkData: BookmarkedReportData): FormattedBookmarkData => {\n const reportData: BookmarkedReportData = JSON.parse(JSON.stringify(bookmarkData))\n const { id, name, description, href, reportName, type } = reportData\n\n return {\n id,\n reportName,\n text: name,\n description,\n href,\n type: type as ReportType,\n }\n}\n\nconst formatTable = async (\n bookmarksData: BookmarkedReportData[],\n bookmarkService: BookmarkService,\n csrfToken: string,\n userId: string,\n maxRows?: number,\n nestedBaseUrl?: string,\n) => {\n const userConfig = await bookmarkService.getState(userId)\n const rows = await Promise.all(\n bookmarksData\n .sort((a, b) => a.name.localeCompare(b.name))\n .map(async (bookmark: BookmarkedReportData) => {\n return formatTableData(bookmark, bookmarkService, csrfToken, userConfig, nestedBaseUrl)\n }),\n )\n\n return {\n rows: maxRows ? rows.slice(0, maxRows) : rows,\n head: [\n { text: 'Product', classes: 'dpr-req-product-head' },\n { text: 'Description', classes: 'dpr-bm-description-head' },\n { text: 'Actions', classes: 'dpr-bm-actions-head' },\n ],\n }\n}\n\nconst formatTableData = async (\n bookmarksData: BookmarkedReportData,\n bookmarkService: BookmarkService,\n csrfToken: string,\n userConfig: ReportStoreConfig,\n nestedBaseUrl?: string,\n) => {\n const { description, reportName, reportId, id, href, name, type, loadType } = bookmarksData\n const bookmarkHtml = await bookmarkService.createBookMarkToggleHtml({\n userConfig,\n reportId,\n id,\n csrfToken,\n ctxId: 'bookmark-list',\n reportType: type,\n // We don't have the data here, and missing reports should never get into bookmarked, viewed or requested\n isMissing: false,\n nestedBaseUrl,\n })\n return [\n {\n html: createListItemProduct(reportName, name, type),\n },\n { html: ShowMoreUtils.createShowMoreHtml(description), classes: 'dpr-req-cell' },\n {\n html: createListActions(href, type, loadType, bookmarkHtml),\n classes: 'dpr-req-cell dpr-req-cell__status',\n },\n ]\n}\n\nconst mapBookmarkIdsToDefinition = async (\n bookmarks: BookmarkStoreData[],\n res: Response,\n token: string,\n services: Services,\n): Promise<BookmarkedReportData[]> => {\n const bookmarkData: BookmarkedReportData[] = []\n const { definitionsPath } = LocalsHelper.getValues(res)\n\n await Promise.all(\n bookmarks.map(async (bookmark) => {\n let definition\n const { reportId, id, automatic, type } = bookmark\n const reportType: ReportType = type ? (type as ReportType) : ReportType.REPORT\n\n try {\n let name = ''\n let description = ''\n let loadType = LoadType.ASYNC\n const href = setInitialHref(loadType, reportType, reportId, id, res)\n\n const procuctSummary = await DefinitionUtils.getReportSummary(\n reportId,\n services.reportingService,\n token,\n definitionsPath,\n )\n const reportName = procuctSummary.name\n\n if (reportType === ReportType.REPORT) {\n const variantSummary = procuctSummary.variants.find((v) => v.id === id)\n definition = await services.reportingService.getDefinition(token, reportId, id, definitionsPath)\n name = definition.variant.name\n description = definition.variant.description || definition.description || ''\n loadType = (variantSummary?.loadType as LoadType) || loadType\n }\n\n if (reportType === ReportType.DASHBOARD) {\n definition = await services.dashboardService.getDefinition(token, reportId, id, definitionsPath)\n name = definition.name\n description = definition.description || ''\n }\n\n if (definition) {\n bookmarkData.push({\n reportId,\n id,\n reportName,\n name,\n description,\n type: reportType,\n href,\n loadType,\n automatic,\n })\n }\n } catch (error) {\n // DPD has been deleted so API throws error\n logger.warn(`Failed to map bookmark for: Report ${reportId}, variant ${id}`)\n const { dprUser } = LocalsHelper.getValues(res)\n await services.bookmarkService.removeBookmark(dprUser.id, id, reportId)\n }\n }),\n )\n return bookmarkData\n}\n\nexport const renderBookmarkList = async ({\n services,\n maxRows = 20,\n res,\n}: {\n services: Services\n maxRows?: number\n res: Response\n}) => {\n const { token, csrfToken, dprUser, bookmarks, nestedBaseUrl } = LocalsHelper.getValues(res)\n const bookmarksData: BookmarkedReportData[] = await mapBookmarkIdsToDefinition(bookmarks, res, token, services)\n\n let formatted = await formatBookmarks(bookmarksData)\n const formattedCount = formatted.length\n\n if (maxRows) formatted = formatted.slice(0, maxRows)\n const tableData = await formatTable(\n bookmarksData,\n services.bookmarkService,\n csrfToken,\n dprUser.id,\n maxRows,\n nestedBaseUrl,\n )\n\n const head = {\n ...(formatted.length && { href: '/dpr/my-reports/bookmarks/list' }),\n ...(!formatted.length && { emptyMessage: 'You have 0 bookmarked reports' }),\n }\n\n const total = {\n amount: formattedCount,\n shown: formattedCount > maxRows ? maxRows : formattedCount,\n max: maxRows,\n }\n\n const result = {\n head,\n tableData,\n total,\n csrfToken,\n type: 'bookmark',\n }\n\n return result\n}\n\nexport default {\n renderBookmarkList,\n}\n"],
|
|
5
|
+
"mappings": "0jBAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,aAAAE,EAAA,mBAAAC,EAAA,oBAAAC,EAAA,uBAAAC,IAAA,eAAAC,EAAAN,GAGA,IAAAO,EAA4D,sCAE5DC,EAA0B,oCAC1BC,EAAmB,oCACnBC,EAA4B,6CAC5BC,EAAyE,4CACzEC,EAAyB,0CAGlB,MAAMR,EAAkB,MAAOS,GAC7BA,EACJ,IAAKC,GACGX,EAAeW,CAAM,CAC7B,EACA,KAAK,CAACC,EAAGC,IAAMD,EAAE,KAAK,cAAcC,EAAE,IAAI,CAAC,EAGnCb,EAAkBc,GAA8D,CAC3F,MAAMC,EAAmC,KAAK,MAAM,KAAK,UAAUD,CAAY,CAAC,EAC1E,CAAE,GAAAE,EAAI,KAAAC,EAAM,YAAAC,EAAa,KAAAC,EAAM,WAAAC,EAAY,KAAAC,CAAK,EAAIN,EAE1D,MAAO,CACL,GAAAC,EACA,WAAAI,EACA,KAAMH,EACN,YAAAC,EACA,KAAAC,EACA,KAAME,CACR,CACF,EAEMC,EAAc,MAClBZ,EACAa,EACAC,EACAC,EACAC,EACAC,IACG,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,EAAW,QAAA2B,EAAS,UAAAd,EAAW,cAAAV,CAAc,EAAI,EAAAe,QAAa,UAAUJ,CAAG,EACpF5B,EAAwC,MAAM0B,EAA2BC,EAAWC,EAAKC,EAAOC,CAAQ,EAE9G,IAAIY,EAAY,MAAMnD,EAAgBS,CAAa,EACnD,MAAM2C,EAAiBD,EAAU,OAE7B1B,IAAS0B,EAAYA,EAAU,MAAM,EAAG1B,CAAO,GACnD,MAAM4B,EAAY,MAAMhC,EACtBZ,EACA8B,EAAS,gBACThB,EACA2B,EAAQ,GACRzB,EACAC,CACF,EAEM4B,EAAO,CACX,GAAIH,EAAU,QAAU,CAAE,KAAM,gCAAiC,EACjE,GAAI,CAACA,EAAU,QAAU,CAAE,aAAc,+BAAgC,CAC3E,EAEMI,EAAQ,CACZ,OAAQH,EACR,MAAOA,EAAiB3B,EAAUA,EAAU2B,EAC5C,IAAK3B,CACP,EAUA,MARe,CACb,KAAA6B,EACA,UAAAD,EACA,MAAAE,EACA,UAAAhC,EACA,KAAM,UACR,CAGF,EAEA,IAAOzB,EAAQ,CACb,mBAAAG,CACF",
|
|
6
|
+
"names": ["utils_exports", "__export", "utils_default", "formatBookmark", "formatBookmarks", "renderBookmarkList", "__toCommonJS", "import_UserReports", "import_utils", "import_logger", "import_definitionUtils", "import_reportListsHelper", "import_localsHelper", "bookmarksData", "report", "a", "b", "bookmarkData", "reportData", "id", "name", "description", "href", "reportName", "type", "formatTable", "bookmarkService", "csrfToken", "userId", "maxRows", "nestedBaseUrl", "userConfig", "rows", "bookmark", "formatTableData", "reportId", "loadType", "bookmarkHtml", "ShowMoreUtils", "mapBookmarkIdsToDefinition", "bookmarks", "res", "token", "services", "definitionsPath", "LocalsHelper", "definition", "automatic", "reportType", "procuctSummary", "DefinitionUtils", "variantSummary", "v", "logger", "dprUser", "formatted", "formattedCount", "tableData", "head", "total"]
|
|
7
7
|
}
|
|
@@ -38,13 +38,14 @@ const formatTable = async (
|
|
|
38
38
|
csrfToken: string,
|
|
39
39
|
userId: string,
|
|
40
40
|
maxRows?: number,
|
|
41
|
+
nestedBaseUrl?: string,
|
|
41
42
|
) => {
|
|
42
43
|
const userConfig = await bookmarkService.getState(userId)
|
|
43
44
|
const rows = await Promise.all(
|
|
44
45
|
bookmarksData
|
|
45
46
|
.sort((a, b) => a.name.localeCompare(b.name))
|
|
46
47
|
.map(async (bookmark: BookmarkedReportData) => {
|
|
47
|
-
return formatTableData(bookmark, bookmarkService, csrfToken, userConfig)
|
|
48
|
+
return formatTableData(bookmark, bookmarkService, csrfToken, userConfig, nestedBaseUrl)
|
|
48
49
|
}),
|
|
49
50
|
)
|
|
50
51
|
|
|
@@ -63,6 +64,7 @@ const formatTableData = async (
|
|
|
63
64
|
bookmarkService: BookmarkService,
|
|
64
65
|
csrfToken: string,
|
|
65
66
|
userConfig: ReportStoreConfig,
|
|
67
|
+
nestedBaseUrl?: string,
|
|
66
68
|
) => {
|
|
67
69
|
const { description, reportName, reportId, id, href, name, type, loadType } = bookmarksData
|
|
68
70
|
const bookmarkHtml = await bookmarkService.createBookMarkToggleHtml({
|
|
@@ -74,6 +76,7 @@ const formatTableData = async (
|
|
|
74
76
|
reportType: type,
|
|
75
77
|
// We don't have the data here, and missing reports should never get into bookmarked, viewed or requested
|
|
76
78
|
isMissing: false,
|
|
79
|
+
nestedBaseUrl,
|
|
77
80
|
})
|
|
78
81
|
return [
|
|
79
82
|
{
|
|
@@ -163,14 +166,21 @@ export const renderBookmarkList = async ({
|
|
|
163
166
|
maxRows?: number
|
|
164
167
|
res: Response
|
|
165
168
|
}) => {
|
|
166
|
-
const { token, csrfToken, dprUser, bookmarks } = LocalsHelper.getValues(res)
|
|
169
|
+
const { token, csrfToken, dprUser, bookmarks, nestedBaseUrl } = LocalsHelper.getValues(res)
|
|
167
170
|
const bookmarksData: BookmarkedReportData[] = await mapBookmarkIdsToDefinition(bookmarks, res, token, services)
|
|
168
171
|
|
|
169
172
|
let formatted = await formatBookmarks(bookmarksData)
|
|
170
173
|
const formattedCount = formatted.length
|
|
171
174
|
|
|
172
175
|
if (maxRows) formatted = formatted.slice(0, maxRows)
|
|
173
|
-
const tableData = await formatTable(
|
|
176
|
+
const tableData = await formatTable(
|
|
177
|
+
bookmarksData,
|
|
178
|
+
services.bookmarkService,
|
|
179
|
+
csrfToken,
|
|
180
|
+
dprUser.id,
|
|
181
|
+
maxRows,
|
|
182
|
+
nestedBaseUrl,
|
|
183
|
+
)
|
|
174
184
|
|
|
175
185
|
const head = {
|
|
176
186
|
...(formatted.length && { href: '/dpr/my-reports/bookmarks/list' }),
|
|
@@ -12,7 +12,8 @@ class DprAsyncRequestList extends DprPollingStatusClass {
|
|
|
12
12
|
this.POLLING_FREQUENCY = this.getPollingFrquency()
|
|
13
13
|
|
|
14
14
|
this.requestList = document.getElementById('dpr-async-request-component')
|
|
15
|
-
|
|
15
|
+
const requestData = this.requestList.getAttribute('data-request-data')
|
|
16
|
+
this.requestData = requestData ? JSON.parse(requestData) : undefined
|
|
16
17
|
this.csrfToken = this.requestList.getAttribute('data-csrf-token')
|
|
17
18
|
this.removeActions = document.querySelectorAll('.dpr-remove-requested-report-button')
|
|
18
19
|
|
|
@@ -23,7 +24,7 @@ class DprAsyncRequestList extends DprPollingStatusClass {
|
|
|
23
24
|
async initPollingIntervals() {
|
|
24
25
|
await this.checkIfExpired()
|
|
25
26
|
|
|
26
|
-
if (this.requestData) {
|
|
27
|
+
if (this.requestData && !this.allHaveInvalidIds()) {
|
|
27
28
|
if (this.shouldPollExpired(this.requestData)) {
|
|
28
29
|
this.expiredInterval = setInterval(async () => {
|
|
29
30
|
await this.checkIfExpired()
|
|
@@ -38,11 +39,22 @@ class DprAsyncRequestList extends DprPollingStatusClass {
|
|
|
38
39
|
}
|
|
39
40
|
}
|
|
40
41
|
|
|
42
|
+
hasValidIds(metaData) {
|
|
43
|
+
const { id, reportId, executionId, tableId } = metaData
|
|
44
|
+
return id !== undefined && reportId !== undefined && executionId !== undefined && tableId !== undefined
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
allHaveInvalidIds() {
|
|
48
|
+
return this.requestData.every((meta) => {
|
|
49
|
+
return !this.hasValidIds(meta)
|
|
50
|
+
})
|
|
51
|
+
}
|
|
52
|
+
|
|
41
53
|
async checkIfExpired() {
|
|
42
54
|
await Promise.all(
|
|
43
|
-
|
|
55
|
+
this.requestData.map(async (metaData) => {
|
|
44
56
|
const { status, reportUrl } = metaData
|
|
45
|
-
if (!this.EXPIRED_END_STATUSES.includes(status)) {
|
|
57
|
+
if (this.hasValidIds(metaData) && !this.EXPIRED_END_STATUSES.includes(status)) {
|
|
46
58
|
const response = await this.getExpiredStatus(reportUrl, metaData, this.csrfToken)
|
|
47
59
|
|
|
48
60
|
if (response && response.isExpired) {
|
|
@@ -56,9 +68,9 @@ class DprAsyncRequestList extends DprPollingStatusClass {
|
|
|
56
68
|
|
|
57
69
|
async pollStatus() {
|
|
58
70
|
await Promise.all(
|
|
59
|
-
|
|
71
|
+
this.requestData.map(async (metaData) => {
|
|
60
72
|
// Don't poll if current state is an end state
|
|
61
|
-
if (!this.END_STATUSES.includes(metaData.status)) {
|
|
73
|
+
if (this.hasValidIds(metaData) && !this.END_STATUSES.includes(metaData.status)) {
|
|
62
74
|
const response = await this.getRequestStatus(metaData, this.csrfToken)
|
|
63
75
|
|
|
64
76
|
// Reload if new status is an end state
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../src/dpr/components/user-reports/utils.ts"],
|
|
4
|
-
"sourcesContent": ["import { Response, Request } from 'express'\nimport dayjs from 'dayjs'\nimport { RenderTableListResponse } from './types'\nimport Dict = NodeJS.Dict\nimport {\n FormattedUserReportData,\n UserReportData,\n RequestStatus,\n ReportType,\n RequestedReport,\n StoredReportData,\n meta,\n} from '../../types/UserReports'\nimport { FilterValue } from '../_filters/types'\nimport { Services } from '../../types/Services'\n\nimport { AsyncReportUtilsParams } from '../../types/AsyncReportUtils'\nimport { getExpiredStatus } from '../../utils/requestStatusHelper'\nimport SelectedFiltersUtils from '../_filters/filters-selected/utils'\nimport FiltersUtils from '../_filters/utils'\nimport { itemActionsHtml, createListItemProduct } from '../../utils/reportListsHelper'\nimport RequestedReportUtils from './requested/utils'\nimport RecentlyViewedCardGroupUtils from './viewed/utils'\nimport BookmarklistUtils from './bookmarks/utils'\nimport LocalsHelper from '../../utils/localsHelper'\nimport DateMapper from '../../utils/DateMapper/DateMapper'\nimport UserStoreItemBuilder from '../../utils/UserStoreItemBuilder'\n\nconst formatData = (reportData: UserReportData): FormattedUserReportData => {\n const reportDataCopy: UserReportData = JSON.parse(JSON.stringify(reportData))\n\n const {\n executionId,\n tableId,\n variantName,\n name,\n reportId,\n variantId,\n id,\n description,\n query,\n interactiveQuery,\n status,\n reportName,\n dataProductDefinitionsPath,\n type: reportType,\n url,\n } = reportDataCopy\n\n let summary: { name: string; value: string }[] = []\n if (query) {\n summary = query.summary as { name: string; value: string }[]\n }\n let interactiveSummary: { name: string; value: string }[] = []\n if (interactiveQuery) {\n interactiveSummary = interactiveQuery.summary as { name: string; value: string }[]\n }\n\n const type = reportType || ReportType.REPORT\n\n return {\n id: executionId,\n text: name || variantName || '',\n reportName,\n description,\n tag: 'MIS',\n summary,\n interactiveSummary,\n status,\n type,\n ...(status && setDataFromStatus(status, reportDataCopy)),\n meta: {\n reportId,\n id: variantId || id,\n executionId,\n tableId,\n status,\n type,\n dataProductDefinitionsPath,\n pollingUrl: url?.polling?.pathname,\n reportUrl: url?.report?.pathname,\n },\n }\n}\n\nconst formatTable = (data: FormattedUserReportData[], type: 'requested' | 'viewed') => {\n const rows = data.map((card: FormattedUserReportData) => {\n return formatTableRow(card, type)\n })\n\n return {\n rows,\n head: [\n { text: 'Product', classes: 'dpr-req-product-head' },\n { text: 'Filters', classes: 'dpr-req-filters-head' },\n { text: 'Status', classes: 'dpr-req-status-head' },\n { text: 'Actions', classes: 'dpr-req-actions-head' },\n ],\n }\n}\n\nconst formatTableRow = (data: FormattedUserReportData, type: 'requested' | 'viewed') => {\n let statusClass\n let itemActions = ''\n\n const { href, id, reportName, text, timestamp, type: reportType, status } = data\n if (href) {\n switch (status) {\n case RequestStatus.FAILED:\n statusClass = 'govuk-tag--red'\n itemActions = id ? itemActionsHtml(href, id, type, status) : ''\n break\n case RequestStatus.EXPIRED:\n statusClass = 'govuk-tag--grey'\n itemActions = id ? itemActionsHtml(href, id, type, status) : ''\n break\n case RequestStatus.ABORTED:\n statusClass = 'govuk-tag--orange'\n itemActions = id ? itemActionsHtml(href, id, type, status) : ''\n break\n case RequestStatus.READY:\n case RequestStatus.FINISHED:\n itemActions = `<a class=govuk-link govuk-link--no-visited-state dpr-type__${reportType}' href=\"${href}\">Go to ${reportType}</a>`\n statusClass = 'govuk-tag--green'\n break\n case RequestStatus.PICKED:\n case RequestStatus.SUBMITTED:\n case RequestStatus.STARTED:\n itemActions = `<a class='govuk-link govuk-link--no-visited-state dpr-type__${reportType}' href=\"${href}\">Go to status</a>`\n break\n default:\n break\n }\n }\n\n let filtersSummary = ''\n if (data.summary || data.interactiveSummary) {\n filtersSummary = createSummaryHtml(data)\n }\n\n return [\n {\n html: createListItemProduct(reportName, text, reportType, timestamp),\n },\n { html: filtersSummary },\n {\n html: `<strong class=\"govuk-tag dpr-request-status-tag ${statusClass}\">${status}</strong>`,\n classes: 'dpr-req-cell dpr-req-cell__status',\n },\n {\n html: `${itemActions}`,\n classes: 'dpr-req-cell dpr-req-cell__status',\n },\n ]\n}\n\nconst getTotals = (formattedCount: number, maxRows = 20) => {\n return {\n amount: formattedCount,\n shown: maxRows && formattedCount > maxRows ? maxRows : formattedCount,\n max: maxRows,\n }\n}\n\nconst createSummaryHtml = (data: FormattedUserReportData) => {\n const summaryHtml = data.summary\n ?.map((item) => `<li class=\"govuk-body-s dpr-query-summary\"><strong>${item.name}</strong>: ${item.value}</li>`)\n .join('')\n\n const interactiveSummaryHtml = data.interactiveSummary\n ?.map(\n (item) =>\n `<li class=\"govuk-body-s dpr-interactive-query-summary\"><strong>${item.name}</strong>: ${item.value}</li>`,\n )\n .join('')\n\n return `<ul class=\"dpr-card-group__item__filters-list govuk-!-margin-top-0 govuk-!-margin-bottom-0\">${summaryHtml}${interactiveSummaryHtml}</ul>`\n}\n\nconst getMeta = (formattedData: FormattedUserReportData[], res: Response): meta[] => {\n const { nestedBaseUrl } = LocalsHelper.getValues(res)\n\n return formattedData.map((d) => {\n return {\n reportId: d.meta?.reportId,\n id: d.meta.id,\n executionId: d.meta.executionId,\n tableId: d.meta.tableId,\n status: d.meta.status,\n requestedAt: d.meta.requestedAt,\n type: d.meta.type,\n dataProductDefinitionsPath: d.meta.dataProductDefinitionsPath,\n pollingUrl: d.meta.pollingUrl,\n reportUrl: d.meta.reportUrl,\n nestedBaseUrl,\n }\n })\n}\n\nexport const setDataFromStatus = (status: RequestStatus, reportsData: UserReportData) => {\n let timestamp\n let href\n let formattedDate\n const { url, timestamp: time } = reportsData\n const polling = url?.polling\n const request = url?.request\n const report = url?.report\n\n const dateMapper = new DateMapper()\n switch (status) {\n case RequestStatus.FAILED: {\n formattedDate = time.failed\n ? dateMapper.toDateString(<string>(<unknown>time.failed), 'local-date')\n : dayjs().format('DD/MM/YYYY')\n href = polling?.fullUrl\n timestamp = `Failed at: ${formattedDate}`\n break\n }\n case RequestStatus.ABORTED: {\n href = request?.fullUrl\n formattedDate = dateMapper.toDateString(<string>(<unknown>time.aborted), 'local-date')\n timestamp = `Aborted at: ${formattedDate}`\n break\n }\n case RequestStatus.FINISHED:\n href = report?.fullUrl\n formattedDate = dateMapper.toDateString(<string>(<unknown>time.completed), 'local-date')\n timestamp = `Ready at: ${formattedDate}`\n break\n case RequestStatus.EXPIRED: {\n href = request?.fullUrl\n formattedDate = dateMapper.toDateString(<string>(<unknown>time.expired), 'local-date')\n timestamp = `Expired at: ${formattedDate}`\n break\n }\n case RequestStatus.READY: {\n href = report?.fullUrl\n formattedDate = dateMapper.toDateString(<string>(<unknown>time.lastViewed), 'local-date')\n timestamp = `Last viewed: ${formattedDate}`\n break\n }\n case RequestStatus.SUBMITTED:\n case RequestStatus.STARTED:\n case RequestStatus.PICKED:\n href = polling?.fullUrl\n formattedDate = dateMapper.toDateString(<string>(<unknown>time.requested), 'local-date')\n timestamp = `Requested at: ${formattedDate}`\n break\n default:\n formattedDate = dateMapper.toDateString(<string>(<unknown>time.lastViewed), 'local-date')\n timestamp = `Last viewed: ${formattedDate}`\n break\n }\n\n return {\n timestamp,\n href,\n }\n}\n\nexport const renderList = async ({\n res,\n reportsData,\n maxRows,\n filterFunction,\n type,\n}: {\n res: Response\n reportsData: StoredReportData[]\n maxRows?: number\n filterFunction: (report: UserReportData) => boolean\n type: 'requested' | 'viewed'\n}): Promise<RenderTableListResponse> => {\n const { csrfToken } = LocalsHelper.getValues(res)\n\n let formatted = reportsData.filter(filterFunction).map(formatData)\n const formattedCount = formatted.length\n\n if (maxRows) formatted = formatted.slice(0, maxRows)\n const tableData = formatTable(formatted, type)\n\n const path = type === 'requested' ? 'requested-reports' : 'recently-viewed'\n const head = {\n ...(formatted.length && { href: `dpr/my-reports/${path}/list` }),\n ...(!formatted.length && { emptyMessage: `You have 0 ${type} reports` }),\n }\n\n const result: RenderTableListResponse = {\n head,\n tableData,\n total: getTotals(formattedCount, maxRows),\n meta: getMeta(formatted, res),\n csrfToken,\n ...(maxRows && { maxRows }),\n }\n\n return result\n}\n\nexport const updateExpiredStatus = async ({ req, res, services }: AsyncReportUtilsParams) => {\n const { dprUser } = LocalsHelper.getValues(res)\n const report = await getExpiredStatus({ req, res, services })\n\n if (report && report.isExpired) {\n await services.recentlyViewedService.setToExpired(report.executionId, dprUser.id)\n await services.requestedReportService.setToExpired(report.executionId, dprUser.id)\n }\n\n return report ? report.isExpired : false\n}\n\nexport const init = async ({ services, res, maxRows = 6 }: { services: Services; res: Response; maxRows?: number }) => {\n const { requestedReports, recentlyViewedReports, bookmarkingEnabled } = LocalsHelper.getValues(res)\n const requestedReportsList = await renderList({\n res,\n reportsData: requestedReports,\n filterFunction: RequestedReportUtils.filterReports,\n maxRows,\n type: 'requested',\n })\n const viewedReportsList = await renderList({\n res,\n reportsData: recentlyViewedReports,\n filterFunction: RecentlyViewedCardGroupUtils.filterReports,\n maxRows,\n type: 'viewed',\n })\n\n let bookmarks\n if (bookmarkingEnabled) {\n bookmarks = await BookmarklistUtils.renderBookmarkList({\n res,\n services,\n maxRows,\n })\n }\n\n return {\n requestedReports: requestedReportsList,\n viewedReports: viewedReportsList,\n bookmarks,\n }\n}\n\nexport const updateLastViewed = async ({\n req,\n services,\n reportStateData,\n userId,\n filters,\n}: {\n req: Request\n services: Services\n reportStateData: RequestedReport\n userId: string\n filters: FilterValue[]\n}) => {\n const { type, reportId, reportName, description, id, name, executionId, tableId, query, url } = reportStateData\n const reportData = { type, reportId, reportName, description, id, name }\n const executionData = { executionId, tableId }\n const queryData = query ? { query: query.data, querySummary: query.summary } : { query: {}, querySummary: [] }\n\n const columns = <string[]>req.query?.['columns']\n const { selectedPage, pageSize, sortColumn, sortedAsc } = <Dict<string>>req.query\n const filtersQuery = FiltersUtils.setRequestQueryFromFilterValues(filters, true)\n const reqQuery = {\n ...filtersQuery,\n ...(columns && { columns }),\n ...(selectedPage && { selectedPage }),\n ...(pageSize && { pageSize }),\n ...(sortColumn && { sortColumn }),\n ...(sortedAsc && { sortedAsc }),\n }\n const interactiveQueryData: { query: Dict<string | string[]>; querySummary: Array<Dict<string>> } = {\n query: reqQuery,\n querySummary: SelectedFiltersUtils.getQuerySummary(filtersQuery, filters),\n }\n\n const recentlyViewedData = new UserStoreItemBuilder(reportData)\n .addExecutionData(executionData)\n .addQuery(queryData)\n .addInteractiveQuery(interactiveQueryData)\n .addStatus(RequestStatus.READY)\n .addTimestamp()\n .addAsyncUrls(url)\n .addReportUrls(req)\n .build()\n\n if (executionId) await services.requestedReportService.updateLastViewed(executionId, userId)\n await services.recentlyViewedService.setRecentlyViewed(recentlyViewedData, userId)\n}\n\nexport default {\n renderList,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,EAAYnC,GAAYkC,EAAWnC,CAAI,EAEvCqC,EAAOrC,IAAS,YAAc,oBAAsB,kBAe1D,MATwC,CACtC,KANW,CACX,GAAImC,EAAU,QAAU,CAAE,KAAM,kBAAkBE,CAAI,OAAQ,EAC9D,GAAI,CAACF,EAAU,QAAU,CAAE,aAAc,cAAcnC,CAAI,UAAW,CACxE,EAIE,UAAAoC,EACA,MAAOxB,GAAUC,EAAgBC,CAAO,EACxC,KAAMI,GAAQiB,EAAWf,CAAG,EAC5B,UAAAc,EACA,GAAIpB,GAAW,CAAE,QAAAA,CAAQ,CAC3B,CAGF,EAEa7C,EAAsB,MAAO,CAAE,IAAAqE,EAAK,IAAAlB,EAAK,SAAAmB,CAAS,IAA8B,CAC3F,KAAM,CAAE,QAAAC,CAAQ,EAAI,EAAAlB,QAAa,UAAUF,CAAG,EACxCS,EAAS,QAAM,oBAAiB,CAAE,IAAAS,EAAK,IAAAlB,EAAK,SAAAmB,CAAS,CAAC,EAE5D,OAAIV,GAAUA,EAAO,YACnB,MAAMU,EAAS,sBAAsB,aAAaV,EAAO,YAAaW,EAAQ,EAAE,EAChF,MAAMD,EAAS,uBAAuB,aAAaV,EAAO,YAAaW,EAAQ,EAAE,GAG5EX,EAASA,EAAO,UAAY,EACrC,EAEa/D,EAAO,MAAO,CAAE,SAAAyE,EAAU,IAAAnB,EAAK,QAAAN,EAAU,CAAE,IAA+D,CACrH,KAAM,CAAE,iBAAA2B,EAAkB,sBAAAC,EAAuB,mBAAAC,CAAmB,EAAI,EAAArB,QAAa,UAAUF,CAAG,
|
|
4
|
+
"sourcesContent": ["import { Response, Request } from 'express'\nimport dayjs from 'dayjs'\nimport { RenderTableListResponse } from './types'\nimport Dict = NodeJS.Dict\nimport {\n FormattedUserReportData,\n UserReportData,\n RequestStatus,\n ReportType,\n RequestedReport,\n StoredReportData,\n meta,\n} from '../../types/UserReports'\nimport { FilterValue } from '../_filters/types'\nimport { Services } from '../../types/Services'\n\nimport { AsyncReportUtilsParams } from '../../types/AsyncReportUtils'\nimport { getExpiredStatus } from '../../utils/requestStatusHelper'\nimport SelectedFiltersUtils from '../_filters/filters-selected/utils'\nimport FiltersUtils from '../_filters/utils'\nimport { itemActionsHtml, createListItemProduct } from '../../utils/reportListsHelper'\nimport RequestedReportUtils from './requested/utils'\nimport RecentlyViewedCardGroupUtils from './viewed/utils'\nimport BookmarklistUtils from './bookmarks/utils'\nimport LocalsHelper from '../../utils/localsHelper'\nimport DateMapper from '../../utils/DateMapper/DateMapper'\nimport UserStoreItemBuilder from '../../utils/UserStoreItemBuilder'\n\nconst formatData = (reportData: UserReportData): FormattedUserReportData => {\n const reportDataCopy: UserReportData = JSON.parse(JSON.stringify(reportData))\n\n const {\n executionId,\n tableId,\n variantName,\n name,\n reportId,\n variantId,\n id,\n description,\n query,\n interactiveQuery,\n status,\n reportName,\n dataProductDefinitionsPath,\n type: reportType,\n url,\n } = reportDataCopy\n\n let summary: { name: string; value: string }[] = []\n if (query) {\n summary = query.summary as { name: string; value: string }[]\n }\n let interactiveSummary: { name: string; value: string }[] = []\n if (interactiveQuery) {\n interactiveSummary = interactiveQuery.summary as { name: string; value: string }[]\n }\n\n const type = reportType || ReportType.REPORT\n\n return {\n id: executionId,\n text: name || variantName || '',\n reportName,\n description,\n tag: 'MIS',\n summary,\n interactiveSummary,\n status,\n type,\n ...(status && setDataFromStatus(status, reportDataCopy)),\n meta: {\n reportId,\n id: variantId || id,\n executionId,\n tableId,\n status,\n type,\n dataProductDefinitionsPath,\n pollingUrl: url?.polling?.pathname,\n reportUrl: url?.report?.pathname,\n },\n }\n}\n\nconst formatTable = (data: FormattedUserReportData[], type: 'requested' | 'viewed') => {\n const rows = data.map((card: FormattedUserReportData) => {\n return formatTableRow(card, type)\n })\n\n return {\n rows,\n head: [\n { text: 'Product', classes: 'dpr-req-product-head' },\n { text: 'Filters', classes: 'dpr-req-filters-head' },\n { text: 'Status', classes: 'dpr-req-status-head' },\n { text: 'Actions', classes: 'dpr-req-actions-head' },\n ],\n }\n}\n\nconst formatTableRow = (data: FormattedUserReportData, type: 'requested' | 'viewed') => {\n let statusClass\n let itemActions = ''\n\n const { href, id, reportName, text, timestamp, type: reportType, status } = data\n if (href) {\n switch (status) {\n case RequestStatus.FAILED:\n statusClass = 'govuk-tag--red'\n itemActions = id ? itemActionsHtml(href, id, type, status) : ''\n break\n case RequestStatus.EXPIRED:\n statusClass = 'govuk-tag--grey'\n itemActions = id ? itemActionsHtml(href, id, type, status) : ''\n break\n case RequestStatus.ABORTED:\n statusClass = 'govuk-tag--orange'\n itemActions = id ? itemActionsHtml(href, id, type, status) : ''\n break\n case RequestStatus.READY:\n case RequestStatus.FINISHED:\n itemActions = `<a class=govuk-link govuk-link--no-visited-state dpr-type__${reportType}' href=\"${href}\">Go to ${reportType}</a>`\n statusClass = 'govuk-tag--green'\n break\n case RequestStatus.PICKED:\n case RequestStatus.SUBMITTED:\n case RequestStatus.STARTED:\n itemActions = `<a class='govuk-link govuk-link--no-visited-state dpr-type__${reportType}' href=\"${href}\">Go to status</a>`\n break\n default:\n break\n }\n }\n\n let filtersSummary = ''\n if (data.summary || data.interactiveSummary) {\n filtersSummary = createSummaryHtml(data)\n }\n\n return [\n {\n html: createListItemProduct(reportName, text, reportType, timestamp),\n },\n { html: filtersSummary },\n {\n html: `<strong class=\"govuk-tag dpr-request-status-tag ${statusClass}\">${status}</strong>`,\n classes: 'dpr-req-cell dpr-req-cell__status',\n },\n {\n html: `${itemActions}`,\n classes: 'dpr-req-cell dpr-req-cell__status',\n },\n ]\n}\n\nconst getTotals = (formattedCount: number, maxRows = 20) => {\n return {\n amount: formattedCount,\n shown: maxRows && formattedCount > maxRows ? maxRows : formattedCount,\n max: maxRows,\n }\n}\n\nconst createSummaryHtml = (data: FormattedUserReportData) => {\n const summaryHtml = data.summary\n ?.map((item) => `<li class=\"govuk-body-s dpr-query-summary\"><strong>${item.name}</strong>: ${item.value}</li>`)\n .join('')\n\n const interactiveSummaryHtml = data.interactiveSummary\n ?.map(\n (item) =>\n `<li class=\"govuk-body-s dpr-interactive-query-summary\"><strong>${item.name}</strong>: ${item.value}</li>`,\n )\n .join('')\n\n return `<ul class=\"dpr-card-group__item__filters-list govuk-!-margin-top-0 govuk-!-margin-bottom-0\">${summaryHtml}${interactiveSummaryHtml}</ul>`\n}\n\nconst getMeta = (formattedData: FormattedUserReportData[], res: Response): meta[] => {\n const { nestedBaseUrl } = LocalsHelper.getValues(res)\n\n return formattedData.map((d) => {\n return {\n reportId: d.meta?.reportId,\n id: d.meta.id,\n executionId: d.meta.executionId,\n tableId: d.meta.tableId,\n status: d.meta.status,\n requestedAt: d.meta.requestedAt,\n type: d.meta.type,\n dataProductDefinitionsPath: d.meta.dataProductDefinitionsPath,\n pollingUrl: d.meta.pollingUrl,\n reportUrl: d.meta.reportUrl,\n nestedBaseUrl,\n }\n })\n}\n\nexport const setDataFromStatus = (status: RequestStatus, reportsData: UserReportData) => {\n let timestamp\n let href\n let formattedDate\n const { url, timestamp: time } = reportsData\n const polling = url?.polling\n const request = url?.request\n const report = url?.report\n\n const dateMapper = new DateMapper()\n switch (status) {\n case RequestStatus.FAILED: {\n formattedDate = time.failed\n ? dateMapper.toDateString(<string>(<unknown>time.failed), 'local-date')\n : dayjs().format('DD/MM/YYYY')\n href = polling?.fullUrl\n timestamp = `Failed at: ${formattedDate}`\n break\n }\n case RequestStatus.ABORTED: {\n href = request?.fullUrl\n formattedDate = dateMapper.toDateString(<string>(<unknown>time.aborted), 'local-date')\n timestamp = `Aborted at: ${formattedDate}`\n break\n }\n case RequestStatus.FINISHED:\n href = report?.fullUrl\n formattedDate = dateMapper.toDateString(<string>(<unknown>time.completed), 'local-date')\n timestamp = `Ready at: ${formattedDate}`\n break\n case RequestStatus.EXPIRED: {\n href = request?.fullUrl\n formattedDate = dateMapper.toDateString(<string>(<unknown>time.expired), 'local-date')\n timestamp = `Expired at: ${formattedDate}`\n break\n }\n case RequestStatus.READY: {\n href = report?.fullUrl\n formattedDate = dateMapper.toDateString(<string>(<unknown>time.lastViewed), 'local-date')\n timestamp = `Last viewed: ${formattedDate}`\n break\n }\n case RequestStatus.SUBMITTED:\n case RequestStatus.STARTED:\n case RequestStatus.PICKED:\n href = polling?.fullUrl\n formattedDate = dateMapper.toDateString(<string>(<unknown>time.requested), 'local-date')\n timestamp = `Requested at: ${formattedDate}`\n break\n default:\n formattedDate = dateMapper.toDateString(<string>(<unknown>time.lastViewed), 'local-date')\n timestamp = `Last viewed: ${formattedDate}`\n break\n }\n\n return {\n timestamp,\n href,\n }\n}\n\nexport const renderList = async ({\n res,\n reportsData,\n maxRows,\n filterFunction,\n type,\n}: {\n res: Response\n reportsData: StoredReportData[]\n maxRows?: number\n filterFunction: (report: UserReportData) => boolean\n type: 'requested' | 'viewed'\n}): Promise<RenderTableListResponse> => {\n const { csrfToken } = LocalsHelper.getValues(res)\n\n let formatted = reportsData.filter(filterFunction).map(formatData)\n const formattedCount = formatted.length\n\n if (maxRows) formatted = formatted.slice(0, maxRows)\n const tableData = formatTable(formatted, type)\n\n const path = type === 'requested' ? 'requested-reports' : 'recently-viewed'\n const head = {\n ...(formatted.length && { href: `dpr/my-reports/${path}/list` }),\n ...(!formatted.length && { emptyMessage: `You have 0 ${type} reports` }),\n }\n\n const result: RenderTableListResponse = {\n head,\n tableData,\n total: getTotals(formattedCount, maxRows),\n meta: getMeta(formatted, res),\n csrfToken,\n ...(maxRows && { maxRows }),\n }\n\n return result\n}\n\nexport const updateExpiredStatus = async ({ req, res, services }: AsyncReportUtilsParams) => {\n const { dprUser } = LocalsHelper.getValues(res)\n const report = await getExpiredStatus({ req, res, services })\n\n if (report && report.isExpired) {\n await services.recentlyViewedService.setToExpired(report.executionId, dprUser.id)\n await services.requestedReportService.setToExpired(report.executionId, dprUser.id)\n }\n\n return report ? report.isExpired : false\n}\n\nexport const init = async ({ services, res, maxRows = 6 }: { services: Services; res: Response; maxRows?: number }) => {\n const { requestedReports, recentlyViewedReports, bookmarkingEnabled } = LocalsHelper.getValues(res)\n\n const requestedReportsList = await renderList({\n res,\n reportsData: requestedReports,\n filterFunction: RequestedReportUtils.filterReports,\n maxRows,\n type: 'requested',\n })\n\n const viewedReportsList = await renderList({\n res,\n reportsData: recentlyViewedReports,\n filterFunction: RecentlyViewedCardGroupUtils.filterReports,\n maxRows,\n type: 'viewed',\n })\n\n let bookmarks\n if (bookmarkingEnabled) {\n bookmarks = await BookmarklistUtils.renderBookmarkList({\n res,\n services,\n maxRows,\n })\n }\n\n return {\n requestedReports: requestedReportsList,\n viewedReports: viewedReportsList,\n bookmarks,\n }\n}\n\nexport const updateLastViewed = async ({\n req,\n services,\n reportStateData,\n userId,\n filters,\n}: {\n req: Request\n services: Services\n reportStateData: RequestedReport\n userId: string\n filters: FilterValue[]\n}) => {\n const { type, reportId, reportName, description, id, name, executionId, tableId, query, url } = reportStateData\n const reportData = { type, reportId, reportName, description, id, name }\n const executionData = { executionId, tableId }\n const queryData = query ? { query: query.data, querySummary: query.summary } : { query: {}, querySummary: [] }\n\n const columns = <string[]>req.query?.['columns']\n const { selectedPage, pageSize, sortColumn, sortedAsc } = <Dict<string>>req.query\n const filtersQuery = FiltersUtils.setRequestQueryFromFilterValues(filters, true)\n const reqQuery = {\n ...filtersQuery,\n ...(columns && { columns }),\n ...(selectedPage && { selectedPage }),\n ...(pageSize && { pageSize }),\n ...(sortColumn && { sortColumn }),\n ...(sortedAsc && { sortedAsc }),\n }\n const interactiveQueryData: { query: Dict<string | string[]>; querySummary: Array<Dict<string>> } = {\n query: reqQuery,\n querySummary: SelectedFiltersUtils.getQuerySummary(filtersQuery, filters),\n }\n\n const recentlyViewedData = new UserStoreItemBuilder(reportData)\n .addExecutionData(executionData)\n .addQuery(queryData)\n .addInteractiveQuery(interactiveQueryData)\n .addStatus(RequestStatus.READY)\n .addTimestamp()\n .addAsyncUrls(url)\n .addReportUrls(req)\n .build()\n\n if (executionId) await services.requestedReportService.updateLastViewed(executionId, userId)\n await services.recentlyViewedService.setRecentlyViewed(recentlyView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CAAa,EAC9B,SAASC,CAAS,EAClB,oBAAoBQ,CAAoB,EACxC,UAAU,gBAAc,KAAK,EAC7B,aAAa,EACb,aAAajE,CAAG,EAChB,cAAcyC,CAAG,EACjB,MAAM,EAELvD,GAAa,MAAMwD,EAAS,uBAAuB,iBAAiBxD,EAAaoE,CAAM,EAC3F,MAAMZ,EAAS,sBAAsB,kBAAkByB,EAAoBb,CAAM,CACnF,EAEA,IAAOtF,GAAQ,CACb,WAAAE,EACA,oBAAAE,EACA,KAAAH,EACA,iBAAAI,CACF",
|
|
6
6
|
"names": ["utils_exports", "__export", "utils_default", "init", "renderList", "setDataFromStatus", "updateExpiredStatus", "updateLastViewed", "__toCommonJS", "import_dayjs", "import_UserReports", "import_requestStatusHelper", "import_utils", "import_reportListsHelper", "import_localsHelper", "import_DateMapper", "import_UserStoreItemBuilder", "formatData", "reportData", "reportDataCopy", "executionId", "tableId", "variantName", "name", "reportId", "variantId", "id", "description", "query", "interactiveQuery", "status", "reportName", "dataProductDefinitionsPath", "reportType", "url", "summary", "interactiveSummary", "type", "formatTable", "data", "card", "formatTableRow", "statusClass", "itemActions", "href", "text", "timestamp", "filtersSummary", "createSummaryHtml", "getTotals", "formattedCount", "maxRows", "summaryHtml", "item", "interactiveSummaryHtml", "getMeta", "formattedData", "res", "nestedBaseUrl", "LocalsHelper", "d", "reportsData", "formattedDate", "time", "polling", "request", "report", "dateMapper", "DateMapper", "dayjs", "filterFunction", "csrfToken", "formatted", "tableData", "path", "req", "services", "dprUser", "requestedReports", "recentlyViewedReports", "bookmarkingEnabled", "requestedReportsList", "RequestedReportUtils", "viewedReportsList", "RecentlyViewedCardGroupUtils", "bookmarks", "BookmarklistUtils", "reportStateData", "userId", "filters", "executionData", "queryData", "columns", "selectedPage", "pageSize", "sortColumn", "sortedAsc", "filtersQuery", "FiltersUtils", "interactiveQueryData", "SelectedFiltersUtils", "recentlyViewedData", "UserStoreItemBuilder"]
|
|
7
7
|
}
|
|
@@ -144,31 +144,31 @@ describe('AsyncRequestListUtils', () => {
|
|
|
144
144
|
expect(result.meta?.length).toEqual(7)
|
|
145
145
|
|
|
146
146
|
const v1Ready = <NodeJS.Dict<string>[]>result.tableData.rows[0]
|
|
147
|
-
expect(v1Ready[3]
|
|
147
|
+
expect(v1Ready[3]['html']).toContain(
|
|
148
148
|
'http://localhost:3010/embedded/platform/dpr/view-report/async/report/request-examples/request-example-success/tblId_1729765628165/report',
|
|
149
149
|
)
|
|
150
|
-
expect(v1Ready[2]
|
|
150
|
+
expect(v1Ready[2]['html']).toContain('FINISHED')
|
|
151
151
|
|
|
152
152
|
const v1Failed = <NodeJS.Dict<string>[]>result.tableData.rows[1]
|
|
153
153
|
const v1FailedRetryUrl =
|
|
154
154
|
'http://localhost:3010/embedded/platform/async/report/request-examples/request-example-fail-status/request/exId_238947923'
|
|
155
|
-
expect(v1Failed[2]
|
|
156
|
-
expect(v1Failed[3]
|
|
157
|
-
expect(v1Failed[3]
|
|
155
|
+
expect(v1Failed[2]['html']).toContain('FAILED')
|
|
156
|
+
expect(v1Failed[3]['html']).toContain(v1FailedRetryUrl)
|
|
157
|
+
expect(v1Failed[3]['html']).toContain('remove')
|
|
158
158
|
|
|
159
159
|
const v1Expired = <NodeJS.Dict<string>[]>result.tableData.rows[2]
|
|
160
160
|
const v1ExpiredRetryUrl =
|
|
161
161
|
'http://localhost:3010/embedded/platform/async/report/request-examples/request-example-expire/request?filters.field1=value1.3&filters.field3.start=2003-02-01&filters.field3.end=2006-05-04&sortColumn=field1&sortedAsc=true&filters.field2=value2.1'
|
|
162
|
-
expect(v1Expired[2]
|
|
163
|
-
expect(v1Expired[3]
|
|
164
|
-
expect(v1Expired[3]
|
|
162
|
+
expect(v1Expired[2]['html']).toContain('EXPIRED')
|
|
163
|
+
expect(v1Expired[3]['html']).toContain(v1ExpiredRetryUrl)
|
|
164
|
+
expect(v1Expired[3]['html']).toContain('remove')
|
|
165
165
|
|
|
166
166
|
const v1Aborted = <NodeJS.Dict<string>[]>result.tableData.rows[3]
|
|
167
167
|
const v1AbortedRetryUrl =
|
|
168
168
|
'http://localhost:3010/embedded/platform/async/report/request-examples/request-example-success/request?filters.field1=value1.1&filters.field2=value2.3&filters.field3.start=2003-02-01&filters.field3.end=2006-05-04&filters.field7=2007-05-04&sortColumn=field1&sortedAsc=true&filters.field6=Value+6.1'
|
|
169
|
-
expect(v1Aborted[2]
|
|
170
|
-
expect(v1Aborted[3]
|
|
171
|
-
expect(v1Aborted[3]
|
|
169
|
+
expect(v1Aborted[2]['html']).toContain('ABORTED')
|
|
170
|
+
expect(v1Aborted[3]['html']).toContain(v1AbortedRetryUrl)
|
|
171
|
+
expect(v1Aborted[3]['html']).toContain('remove')
|
|
172
172
|
})
|
|
173
173
|
|
|
174
174
|
it('should return the render list with dashboards', async () => {
|
|
@@ -185,24 +185,24 @@ describe('AsyncRequestListUtils', () => {
|
|
|
185
185
|
expect(result.meta?.length).toEqual(7)
|
|
186
186
|
|
|
187
187
|
const v2Ready = <NodeJS.Dict<string>[]>result.tableData.rows[4]
|
|
188
|
-
expect(v2Ready[3]
|
|
188
|
+
expect(v2Ready[3]['html']).toContain(
|
|
189
189
|
'http://localhost:3010/embedded/platform/async/dashboard/request-examples/test-dashboard-1/request/exId_238947923',
|
|
190
190
|
)
|
|
191
|
-
expect(v2Ready[2]
|
|
191
|
+
expect(v2Ready[2]['html']).toContain('SUBMITTED')
|
|
192
192
|
|
|
193
193
|
const v2Failed = <NodeJS.Dict<string>[]>result.tableData.rows[5]
|
|
194
194
|
const v2FailedRetryUrl =
|
|
195
195
|
'http://localhost:3010/embedded/platform/async/dashboard/request-examples/test-dashboard-2/request/exId_238947923'
|
|
196
|
-
expect(v2Failed[2]
|
|
197
|
-
expect(v2Failed[3]
|
|
198
|
-
expect(v2Failed[3]
|
|
196
|
+
expect(v2Failed[2]['html']).toContain('FAILED')
|
|
197
|
+
expect(v2Failed[3]['html']).toContain(v2FailedRetryUrl)
|
|
198
|
+
expect(v2Failed[3]['html']).toContain('remove')
|
|
199
199
|
|
|
200
200
|
const v2Expired = <NodeJS.Dict<string>[]>result.tableData.rows[6]
|
|
201
201
|
const v2ExpiredRetryUrl =
|
|
202
202
|
'http://localhost:3010/embedded/platform/async/dashboard/request-examples/test-dashboard-3/request'
|
|
203
|
-
expect(v2Expired[2]
|
|
204
|
-
expect(v2Expired[3]
|
|
205
|
-
expect(v2Expired[3]
|
|
203
|
+
expect(v2Expired[2]['html']).toContain('EXPIRED')
|
|
204
|
+
expect(v2Expired[3]['html']).toContain(v2ExpiredRetryUrl)
|
|
205
|
+
expect(v2Expired[3]['html']).toContain('remove')
|
|
206
206
|
})
|
|
207
207
|
})
|
|
208
208
|
|
|
@@ -221,17 +221,17 @@ describe('AsyncRequestListUtils', () => {
|
|
|
221
221
|
expect(result.meta?.length).toEqual(2)
|
|
222
222
|
|
|
223
223
|
const v1Ready = <NodeJS.Dict<string>[]>result.tableData.rows[0]
|
|
224
|
-
expect(v1Ready[3]
|
|
224
|
+
expect(v1Ready[3]['html']).toContain(
|
|
225
225
|
'http://localhost:3010/embedded/platform/async/report/request-examples/request-example-success/request/tblId_1729766362362/report',
|
|
226
226
|
)
|
|
227
|
-
expect(v1Ready[2]
|
|
227
|
+
expect(v1Ready[2]['html']).toContain('READY')
|
|
228
228
|
|
|
229
229
|
const v1Expired = <NodeJS.Dict<string>[]>result.tableData.rows[1]
|
|
230
230
|
const v1ExpiredRetryUrl =
|
|
231
231
|
'http://localhost:3010/embedded/platform/async/report/request-examples/request-example-success/request?filters.field2=value2.3&filters.field3.start=2003-09-05&filters.field3.end=2007-05-01&filters.field7=2007-05-04&sortColumn=field1&sortedAsc=true&filters.field4=Inigo+Montoya'
|
|
232
|
-
expect(v1Expired[2]
|
|
233
|
-
expect(v1Expired[3]
|
|
234
|
-
expect(v1Expired[3]
|
|
232
|
+
expect(v1Expired[2]['html']).toContain('EXPIRED')
|
|
233
|
+
expect(v1Expired[3]['html']).toContain(v1ExpiredRetryUrl)
|
|
234
|
+
expect(v1Expired[3]['html']).toContain('remove')
|
|
235
235
|
})
|
|
236
236
|
})
|
|
237
237
|
})
|