@ministryofjustice/hmpps-digital-prison-reporting-frontend 3.9.0 → 3.9.2

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.
@@ -635,7 +635,7 @@ class DprQueryParamClass extends DprClientClass {
635
635
  */
636
636
  initQueryParamsFromInputs (elements) {
637
637
  Array.from(elements).forEach((input) => {
638
- this.setQueryParamFromInput(input);
638
+ if (input.type !== 'hidden') this.setQueryParamFromInput(input);
639
639
  });
640
640
  }
641
641
 
@@ -780,6 +780,8 @@ class AsyncFilters extends DprQueryParamClass {
780
780
 
781
781
  document.getElementById('async-filters-form-pathname').value = window.location.pathname;
782
782
  document.getElementById('async-filters-form-origin').value = window.location.origin;
783
+ document.getElementById('async-filters-form-href').value = window.location.href;
784
+ document.getElementById('async-filters-form-search').value = window.location.search;
783
785
  }
784
786
 
785
787
  initResetButton () {
@@ -6,7 +6,7 @@ const formatCardData = async (requestedReportsData, dataSources, token, asyncRep
6
6
  const { executionId, reportId, variantId } = reportData;
7
7
  let response;
8
8
  try {
9
- response = await dataSources.getAsyncReportStatus(token, reportId, variantId, executionId);
9
+ response = await dataSources.getAsyncReportStatus(token, reportId, variantId, executionId, reportData.dataProductDefinitionsPath);
10
10
  }
11
11
  catch (_a) {
12
12
  response = {
@@ -15,7 +15,13 @@ const formatCardData = async (
15
15
  let response: Dict<string>
16
16
 
17
17
  try {
18
- response = await dataSources.getAsyncReportStatus(token, reportId, variantId, executionId)
18
+ response = await dataSources.getAsyncReportStatus(
19
+ token,
20
+ reportId,
21
+ variantId,
22
+ executionId,
23
+ reportData.dataProductDefinitionsPath,
24
+ )
19
25
  } catch {
20
26
  response = {
21
27
  status: RequestStatus.FAILED,
@@ -25,6 +25,8 @@
25
25
  <input type="hidden" name="variantName" value="{{ variantName }}">
26
26
  <input type="hidden" name="pathname" id="async-filters-form-pathname" value="">
27
27
  <input type="hidden" name="origin" id="async-filters-form-origin" value="">
28
+ <input type="hidden" name="href" id="async-filters-form-href" value="">
29
+ <input type="hidden" name="search" id="async-filters-form-search" value="">
28
30
 
29
31
  <div class="dpr-async-controls__section">
30
32
  <h3 class="govuk-heading-s">Filters</h3>
@@ -8,7 +8,7 @@ exports.default = {
8
8
  const { token } = res.locals.user || 'token';
9
9
  const { reportId, variantId, executionId } = req.params;
10
10
  let reportData = await asyncReportsStore.getReport(executionId);
11
- const statusResponse = await dataSources.getAsyncReportStatus(token, reportId, variantId, executionId);
11
+ const statusResponse = await dataSources.getAsyncReportStatus(token, reportId, variantId, executionId, reportData.dataProductDefinitionsPath);
12
12
  const { status: latestStatus } = statusResponse;
13
13
  if (currentStatus !== latestStatus) {
14
14
  await asyncReportsStore.updateStatus(reportData.executionId, latestStatus);
@@ -9,7 +9,13 @@ export default {
9
9
  const { reportId, variantId, executionId } = req.params
10
10
  let reportData = await asyncReportsStore.getReport(executionId)
11
11
 
12
- const statusResponse = await dataSources.getAsyncReportStatus(token, reportId, variantId, executionId)
12
+ const statusResponse = await dataSources.getAsyncReportStatus(
13
+ token,
14
+ reportId,
15
+ variantId,
16
+ executionId,
17
+ reportData.dataProductDefinitionsPath,
18
+ )
13
19
  const { status: latestStatus } = statusResponse
14
20
 
15
21
  if (currentStatus !== latestStatus) {
@@ -13,14 +13,15 @@ const initDataSources = ({ req, res, next, asyncReportsStore, dataSources }) =>
13
13
  try {
14
14
  const { token } = res.locals.user || 'token';
15
15
  const { reportId, reportVariantId, tableId } = req.params;
16
- const { selectedPage = 1, pageSize = 10, dataProductDefinitionsPath } = req.query;
16
+ const { selectedPage = 1, pageSize = 10 } = req.query;
17
+ const dataProductDefinitionsPath = req.query.dataProductDefinitionsPath;
17
18
  const reportDefinitionPromise = dataSources.getDefinition(token, reportId, reportVariantId, dataProductDefinitionsPath);
18
19
  const reportDataPromise = dataSources.getAsyncReport(token, reportId, reportVariantId, tableId, {
19
20
  selectedPage: +selectedPage,
20
21
  pageSize: +pageSize,
21
- dataProductDefinitionsPath: dataProductDefinitionsPath,
22
+ dataProductDefinitionsPath,
22
23
  });
23
- const reportDataCountPromise = dataSources.getAsyncCount(token, tableId);
24
+ const reportDataCountPromise = dataSources.getAsyncCount(token, tableId, dataProductDefinitionsPath);
24
25
  const stateData = asyncReportsStore.getReportByTableId(tableId);
25
26
  return [reportDefinitionPromise, reportDataPromise, reportDataCountPromise, stateData];
26
27
  }
@@ -14,19 +14,20 @@ const initDataSources = ({ req, res, next, asyncReportsStore, dataSources }: Asy
14
14
  try {
15
15
  const { token } = res.locals.user || 'token'
16
16
  const { reportId, reportVariantId, tableId } = req.params
17
- const { selectedPage = 1, pageSize = 10, dataProductDefinitionsPath } = req.query
17
+ const { selectedPage = 1, pageSize = 10 } = req.query
18
+ const dataProductDefinitionsPath = <string>req.query.dataProductDefinitionsPath
18
19
  const reportDefinitionPromise = dataSources.getDefinition(
19
20
  token,
20
21
  reportId,
21
22
  reportVariantId,
22
- <string>dataProductDefinitionsPath,
23
+ dataProductDefinitionsPath,
23
24
  )
24
25
  const reportDataPromise = dataSources.getAsyncReport(token, reportId, reportVariantId, tableId, {
25
26
  selectedPage: +selectedPage,
26
27
  pageSize: +pageSize,
27
- dataProductDefinitionsPath: <string>dataProductDefinitionsPath,
28
+ dataProductDefinitionsPath,
28
29
  })
29
- const reportDataCountPromise = dataSources.getAsyncCount(token, tableId)
30
+ const reportDataCountPromise = dataSources.getAsyncCount(token, tableId, dataProductDefinitionsPath)
30
31
  const stateData = asyncReportsStore.getReportByTableId(tableId)
31
32
 
32
33
  return [reportDefinitionPromise, reportDataPromise, reportDataCountPromise, stateData]
@@ -10,7 +10,10 @@
10
10
  suffix: {
11
11
  html: "&#x1F50D;"
12
12
  },
13
- classes: "dpr-search-box"
13
+ classes: "dpr-search-box",
14
+ attributes: {
15
+ placeholder: "Type to filter reports"
16
+ }
14
17
  }) }}
15
18
 
16
19
  {{ govukTable({
@@ -99,21 +99,27 @@ class ReportingClient {
99
99
  })
100
100
  .then((response) => response);
101
101
  }
102
- getAsyncReportStatus(token, reportId, variantId, executionId) {
102
+ getAsyncReportStatus(token, reportId, variantId, executionId, dataProductDefinitionsPath) {
103
103
  logger_1.default.info(`Reporting client: Get statementId:${executionId} status`);
104
104
  return this.restClient
105
105
  .get({
106
106
  path: `/reports/${reportId}/${variantId}/statements/${executionId}/status`,
107
107
  token,
108
+ query: {
109
+ dataProductDefinitionsPath,
110
+ },
108
111
  })
109
112
  .then((response) => response);
110
113
  }
111
- getAsyncCount(token, tableId) {
114
+ getAsyncCount(token, tableId, dataProductDefinitionsPath) {
112
115
  logger_1.default.info(`Reporting client: Get tableId:${tableId} count`);
113
116
  return this.restClient
114
117
  .get({
115
118
  path: `/report/tables/${tableId}/count`,
116
119
  token,
120
+ query: {
121
+ dataProductDefinitionsPath,
122
+ },
117
123
  })
118
124
  .then((response) => response.count);
119
125
  }
@@ -144,24 +144,36 @@ export default class ReportingClient {
144
144
  .then((response) => <Array<Dict<string>>>response)
145
145
  }
146
146
 
147
- getAsyncReportStatus(token: string, reportId: string, variantId: string, executionId: string): Promise<Dict<string>> {
147
+ getAsyncReportStatus(
148
+ token: string,
149
+ reportId: string,
150
+ variantId: string,
151
+ executionId: string,
152
+ dataProductDefinitionsPath?: string,
153
+ ): Promise<Dict<string>> {
148
154
  logger.info(`Reporting client: Get statementId:${executionId} status`)
149
155
 
150
156
  return this.restClient
151
157
  .get({
152
158
  path: `/reports/${reportId}/${variantId}/statements/${executionId}/status`,
153
159
  token,
160
+ query: {
161
+ dataProductDefinitionsPath,
162
+ },
154
163
  })
155
164
  .then((response) => <Dict<string>>response)
156
165
  }
157
166
 
158
- getAsyncCount(token: string, tableId: string): Promise<number> {
167
+ getAsyncCount(token: string, tableId: string, dataProductDefinitionsPath?: string): Promise<number> {
159
168
  logger.info(`Reporting client: Get tableId:${tableId} count`)
160
169
 
161
170
  return this.restClient
162
171
  .get({
163
172
  path: `/report/tables/${tableId}/count`,
164
173
  token,
174
+ query: {
175
+ dataProductDefinitionsPath,
176
+ },
165
177
  })
166
178
  .then((response) => (<Count>response).count)
167
179
  }
@@ -22,11 +22,11 @@ class ReportingService {
22
22
  async getAsyncReport(token, reportId, variantId, tableId, query) {
23
23
  return this.reportingClient.getAsyncReport(token, reportId, variantId, tableId, query);
24
24
  }
25
- async getAsyncReportStatus(token, reportId, variantId, executionId) {
26
- return this.reportingClient.getAsyncReportStatus(token, reportId, variantId, executionId);
25
+ async getAsyncReportStatus(token, reportId, variantId, executionId, dataProductDefinitionsPath) {
26
+ return this.reportingClient.getAsyncReportStatus(token, reportId, variantId, executionId, dataProductDefinitionsPath);
27
27
  }
28
- async getAsyncCount(token, tableId) {
29
- return this.reportingClient.getAsyncCount(token, tableId);
28
+ async getAsyncCount(token, tableId, dataProductDefinitionsPath) {
29
+ return this.reportingClient.getAsyncCount(token, tableId, dataProductDefinitionsPath);
30
30
  }
31
31
  }
32
32
  exports.default = ReportingService;
@@ -54,11 +54,18 @@ export default class ReportingService {
54
54
  reportId: string,
55
55
  variantId: string,
56
56
  executionId: string,
57
+ dataProductDefinitionsPath: string,
57
58
  ): Promise<Dict<string>> {
58
- return this.reportingClient.getAsyncReportStatus(token, reportId, variantId, executionId)
59
+ return this.reportingClient.getAsyncReportStatus(
60
+ token,
61
+ reportId,
62
+ variantId,
63
+ executionId,
64
+ dataProductDefinitionsPath,
65
+ )
59
66
  }
60
67
 
61
- async getAsyncCount(token: string, tableId: string): Promise<number> {
62
- return this.reportingClient.getAsyncCount(token, tableId)
68
+ async getAsyncCount(token: string, tableId: string, dataProductDefinitionsPath?: string): Promise<number> {
69
+ return this.reportingClient.getAsyncCount(token, tableId, dataProductDefinitionsPath)
63
70
  }
64
71
  }
@@ -1,6 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  const AsyncReport_1 = require("../types/AsyncReport");
4
+ const urlHelper_1 = require("../utils/urlHelper");
4
5
  class AsyncReportStoreService {
5
6
  constructor(userStore) {
6
7
  this.userStore = userStore;
@@ -51,8 +52,8 @@ class AsyncReportStoreService {
51
52
  search,
52
53
  },
53
54
  polling: {
54
- fullUrl: `${origin}${pathname}/${executionId}`,
55
- pathname: `${pathname}/${executionId}`,
55
+ fullUrl: `${origin}${pathname}/${executionId}${(0, urlHelper_1.getDpdPathSuffix)(dataProductDefinitionsPath)}`,
56
+ pathname: `${pathname}/${executionId}${(0, urlHelper_1.getDpdPathSuffix)(dataProductDefinitionsPath)}`,
56
57
  },
57
58
  report: {},
58
59
  },
@@ -125,11 +126,8 @@ class AsyncReportStoreService {
125
126
  break;
126
127
  case AsyncReport_1.RequestStatus.FINISHED:
127
128
  report.timestamp.completed = `Ready at: ${ts}`;
128
- report.url.report.pathname = `${report.url.request.pathname}/${tableId}/report`;
129
- report.url.report.fullUrl = `${report.url.origin}${report.url.report.pathname}`;
130
- if (report.dataProductDefinitionsPath) {
131
- report.url.report.fullUrl = `${report.url.report.fullUrl}?dataProductDefinitionsPath=${report.dataProductDefinitionsPath}`;
132
- }
129
+ report.url.report.pathname = `${report.url.request.pathname}/${tableId}/report${(0, urlHelper_1.getDpdPathSuffix)(report.dataProductDefinitionsPath)}`;
130
+ report.url.report.fullUrl = `${report.url.origin}${report.url.report.pathname}${(0, urlHelper_1.getDpdPathSuffix)(report.dataProductDefinitionsPath)}`;
133
131
  break;
134
132
  case AsyncReport_1.RequestStatus.SUBMITTED:
135
133
  report.timestamp.requested = `Requested at: ${ts}`;
@@ -2,6 +2,7 @@
2
2
  import UserDataStore, { UserStoreConfig } from '../data/userDataStore'
3
3
  import Dict = NodeJS.Dict
4
4
  import { AsyncReportData, RequestStatus } from '../types/AsyncReport'
5
+ import { getDpdPathSuffix } from '../utils/urlHelper'
5
6
 
6
7
  export default class AsyncReportStoreService {
7
8
  userConfig: UserStoreConfig
@@ -80,8 +81,8 @@ export default class AsyncReportStoreService {
80
81
  search,
81
82
  },
82
83
  polling: {
83
- fullUrl: `${origin}${pathname}/${executionId}`,
84
- pathname: `${pathname}/${executionId}`,
84
+ fullUrl: `${origin}${pathname}/${executionId}${getDpdPathSuffix(dataProductDefinitionsPath)}`,
85
+ pathname: `${pathname}/${executionId}${getDpdPathSuffix(dataProductDefinitionsPath)}`,
85
86
  },
86
87
  report: {},
87
88
  },
@@ -164,11 +165,12 @@ export default class AsyncReportStoreService {
164
165
  break
165
166
  case RequestStatus.FINISHED:
166
167
  report.timestamp.completed = `Ready at: ${ts}`
167
- report.url.report.pathname = `${report.url.request.pathname}/${tableId}/report`
168
- report.url.report.fullUrl = `${report.url.origin}${report.url.report.pathname}`
169
- if (report.dataProductDefinitionsPath) {
170
- report.url.report.fullUrl = `${report.url.report.fullUrl}?dataProductDefinitionsPath=${report.dataProductDefinitionsPath}`
171
- }
168
+ report.url.report.pathname = `${report.url.request.pathname}/${tableId}/report${getDpdPathSuffix(
169
+ report.dataProductDefinitionsPath,
170
+ )}`
171
+ report.url.report.fullUrl = `${report.url.origin}${report.url.report.pathname}${getDpdPathSuffix(
172
+ report.dataProductDefinitionsPath,
173
+ )}`
172
174
  break
173
175
  case RequestStatus.SUBMITTED:
174
176
  report.timestamp.requested = `Requested at: ${ts}`
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.createQuerystringFromObject = exports.clearFilterValue = void 0;
3
+ exports.getDpdPathSuffix = exports.createQuerystringFromObject = exports.clearFilterValue = void 0;
4
4
  exports.clearFilterValue = '~clear~';
5
5
  const createUrlForParameters = (currentQueryParams, updateQueryParams) => {
6
6
  let queryParams;
@@ -46,4 +46,11 @@ const createQuerystringFromObject = (source) => {
46
46
  return `?${querystring}`;
47
47
  };
48
48
  exports.createQuerystringFromObject = createQuerystringFromObject;
49
+ const getDpdPathSuffix = (dpdsPath) => {
50
+ if (dpdsPath && dpdsPath !== '') {
51
+ return `?dataProductDefinitionsPath=${dpdsPath}`;
52
+ }
53
+ return '';
54
+ };
55
+ exports.getDpdPathSuffix = getDpdPathSuffix;
49
56
  exports.default = createUrlForParameters;
@@ -52,4 +52,12 @@ export const createQuerystringFromObject = (source: object) => {
52
52
  return `?${querystring}`
53
53
  }
54
54
 
55
+ export const getDpdPathSuffix = (dpdsPath: string) => {
56
+ if (dpdsPath && dpdsPath !== '') {
57
+ return `?dataProductDefinitionsPath=${dpdsPath}`
58
+ }
59
+
60
+ return ''
61
+ }
62
+
55
63
  export default createUrlForParameters
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@ministryofjustice/hmpps-digital-prison-reporting-frontend",
3
3
  "description": "The Digital Prison Reporting Frontend contains templates and code to help display data effectively in UI applications.",
4
- "version": "3.9.0",
4
+ "version": "3.9.2",
5
5
  "main": "dpr/assets/js/all.mjs",
6
6
  "sass": "dpr/all.scss",
7
7
  "engines": {
package/package.zip CHANGED
Binary file