@ministryofjustice/hmpps-digital-prison-reporting-frontend 3.12.2 → 3.12.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/assets/js/all.mjs +6 -1
- package/dpr/components/async-filters/utils.js +7 -3
- package/dpr/components/async-filters/utils.ts +8 -3
- package/dpr/components/async-filters/view.njk +1 -0
- package/dpr/components/async-reports-list/utils/recentlyViewedUtils.js +11 -5
- package/dpr/components/async-reports-list/utils/recentlyViewedUtils.ts +10 -5
- package/dpr/components/icon-button-list/utils.js +2 -2
- package/dpr/components/icon-button-list/utils.ts +2 -2
- package/dpr/services/recentlyViewedService.js +7 -6
- package/dpr/services/recentlyViewedService.ts +7 -6
- package/dpr/services/requestedReportsService.js +7 -6
- package/dpr/services/requestedReportsService.ts +7 -6
- package/dpr/types/AsyncReport.ts +1 -0
- package/dpr/types/RecentlyViewed.ts +1 -0
- package/package.json +1 -1
- package/package.zip +0 -0
package/dpr/assets/js/all.mjs
CHANGED
|
@@ -792,6 +792,7 @@ class AsyncFilters extends DprQueryParamClass {
|
|
|
792
792
|
|
|
793
793
|
const params = new URLSearchParams(search);
|
|
794
794
|
params.delete('retryId');
|
|
795
|
+
params.delete('refreshId');
|
|
795
796
|
const href = `${origin}${pathname}?${params.toString()}`;
|
|
796
797
|
|
|
797
798
|
document.getElementById('async-filters-form-href').value = href;
|
|
@@ -816,9 +817,13 @@ class AsyncFilters extends DprQueryParamClass {
|
|
|
816
817
|
initRetryInputFromQueryParams () {
|
|
817
818
|
this.queryParams = new URLSearchParams(window.location.search);
|
|
818
819
|
const retryId = this.queryParams.get('retryId');
|
|
820
|
+
const refreshId = this.queryParams.get('refreshId');
|
|
819
821
|
if (retryId) {
|
|
820
822
|
document.getElementById('async-filters-retry-id').value = retryId;
|
|
821
823
|
}
|
|
824
|
+
if (refreshId) {
|
|
825
|
+
document.getElementById('async-filters-refresh-id').value = refreshId;
|
|
826
|
+
}
|
|
822
827
|
}
|
|
823
828
|
}
|
|
824
829
|
|
|
@@ -992,7 +997,7 @@ class dprAsyncPolling extends DprClientClass {
|
|
|
992
997
|
|
|
993
998
|
async initialise () {
|
|
994
999
|
this.POLLING_STATUSES = ['SUBMITTED', 'STARTED', 'PICKED'];
|
|
995
|
-
this.POLLING_FREQUENCY = '
|
|
1000
|
+
this.POLLING_FREQUENCY = '3000'; // 3 seconds
|
|
996
1001
|
|
|
997
1002
|
this.statusSection = document.getElementById('async-request-polling-status');
|
|
998
1003
|
this.retryRequestButton = document.getElementById('retry-async-request');
|
|
@@ -122,12 +122,16 @@ exports.default = {
|
|
|
122
122
|
}
|
|
123
123
|
});
|
|
124
124
|
const token = ((_a = res.locals.user) === null || _a === void 0 ? void 0 : _a.token) ? res.locals.user.token : 'token';
|
|
125
|
-
const { reportId, variantId, retryId } = req.body;
|
|
125
|
+
const { reportId, variantId, retryId, refreshId } = req.body;
|
|
126
126
|
const response = await dataSources.requestAsyncReport(token, reportId, variantId, query);
|
|
127
127
|
const { executionId, tableId } = response;
|
|
128
128
|
if (retryId) {
|
|
129
|
-
await asyncReportsStore.
|
|
130
|
-
await recentlyViewedStoreService.
|
|
129
|
+
await asyncReportsStore.setReportTimestamp(retryId, 'retry');
|
|
130
|
+
await recentlyViewedStoreService.setReportTimestamp(retryId, 'retry');
|
|
131
|
+
}
|
|
132
|
+
if (refreshId) {
|
|
133
|
+
await asyncReportsStore.setReportTimestamp(refreshId, 'refresh');
|
|
134
|
+
await recentlyViewedStoreService.setReportTimestamp(refreshId, 'refresh');
|
|
131
135
|
}
|
|
132
136
|
if (executionId && tableId) {
|
|
133
137
|
const reportData = await asyncReportsStore.addReport({
|
|
@@ -136,13 +136,18 @@ export default {
|
|
|
136
136
|
})
|
|
137
137
|
|
|
138
138
|
const token = res.locals.user?.token ? res.locals.user.token : 'token'
|
|
139
|
-
const { reportId, variantId, retryId } = req.body
|
|
139
|
+
const { reportId, variantId, retryId, refreshId } = req.body
|
|
140
140
|
const response = await dataSources.requestAsyncReport(token, reportId, variantId, query)
|
|
141
141
|
const { executionId, tableId } = response
|
|
142
142
|
|
|
143
143
|
if (retryId) {
|
|
144
|
-
await asyncReportsStore.
|
|
145
|
-
await recentlyViewedStoreService.
|
|
144
|
+
await asyncReportsStore.setReportTimestamp(retryId, 'retry')
|
|
145
|
+
await recentlyViewedStoreService.setReportTimestamp(retryId, 'retry')
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
if (refreshId) {
|
|
149
|
+
await asyncReportsStore.setReportTimestamp(refreshId, 'refresh')
|
|
150
|
+
await recentlyViewedStoreService.setReportTimestamp(refreshId, 'refresh')
|
|
146
151
|
}
|
|
147
152
|
|
|
148
153
|
if (executionId && tableId) {
|
|
@@ -31,6 +31,7 @@
|
|
|
31
31
|
<input type="hidden" name="href" id="async-filters-form-href" value="">
|
|
32
32
|
<input type="hidden" name="search" id="async-filters-form-search" value="">
|
|
33
33
|
<input type="hidden" name="retryId" id="async-filters-retry-id" value="">
|
|
34
|
+
<input type="hidden" name="refreshId" id="async-filters-refesh-id" value="">
|
|
34
35
|
|
|
35
36
|
<div class="dpr-async-controls__section">
|
|
36
37
|
<h3 class="govuk-heading-s">Filters</h3>
|
|
@@ -9,7 +9,7 @@ const formatCards = async (recentlyViewedStoreService, asyncReportsStore, dataSo
|
|
|
9
9
|
const requestedReportsData = await recentlyViewedStoreService.getAllReports();
|
|
10
10
|
return Promise.all(requestedReportsData
|
|
11
11
|
.filter((report) => {
|
|
12
|
-
return !report.timestamp.retried;
|
|
12
|
+
return !report.timestamp.retried && !report.timestamp.refresh;
|
|
13
13
|
})
|
|
14
14
|
.map((report) => {
|
|
15
15
|
return formatCardData(report, dataSources, token, recentlyViewedStoreService, asyncReportsStore);
|
|
@@ -19,15 +19,21 @@ const formatCardData = async (reportData, dataSources, token, recentlyViewedStor
|
|
|
19
19
|
const { executionId: id, variantName: text, description, query, url, timestamp, executionId, reportId, variantId, dataProductDefinitionsPath, } = reportData;
|
|
20
20
|
let { status } = reportData;
|
|
21
21
|
const statusResponse = await utils_1.default.getStatus(token, reportId, variantId, executionId, status, dataSources, asyncReportsStore, dataProductDefinitionsPath);
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
22
|
+
let href;
|
|
23
|
+
if (statusResponse.status === AsyncReport_1.RequestStatus.EXPIRED) {
|
|
24
|
+
status = statusResponse.status;
|
|
25
|
+
href = `${url.request.fullUrl}&retryId=${executionId}`;
|
|
26
|
+
}
|
|
27
|
+
else {
|
|
28
|
+
status = AsyncReport_1.RequestStatus.READY;
|
|
29
|
+
href = url.report.fullUrl;
|
|
30
|
+
}
|
|
25
31
|
return {
|
|
26
32
|
id,
|
|
27
33
|
text,
|
|
28
34
|
description,
|
|
29
35
|
tag: 'MIS',
|
|
30
|
-
summary,
|
|
36
|
+
summary: query.summary,
|
|
31
37
|
href,
|
|
32
38
|
timestamp: `Last viewed: ${new Date(timestamp.lastViewed).toLocaleString()}`,
|
|
33
39
|
status,
|
|
@@ -17,7 +17,7 @@ const formatCards = async (
|
|
|
17
17
|
return Promise.all(
|
|
18
18
|
requestedReportsData
|
|
19
19
|
.filter((report: RecentlyViewedReportData) => {
|
|
20
|
-
return !report.timestamp.retried
|
|
20
|
+
return !report.timestamp.retried && !report.timestamp.refresh
|
|
21
21
|
})
|
|
22
22
|
.map((report: RecentlyViewedReportData) => {
|
|
23
23
|
return formatCardData(report, dataSources, token, recentlyViewedStoreService, asyncReportsStore)
|
|
@@ -57,16 +57,21 @@ const formatCardData = async (
|
|
|
57
57
|
dataProductDefinitionsPath,
|
|
58
58
|
)
|
|
59
59
|
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
60
|
+
let href
|
|
61
|
+
if (statusResponse.status === RequestStatus.EXPIRED) {
|
|
62
|
+
status = statusResponse.status
|
|
63
|
+
href = `${url.request.fullUrl}&retryId=${executionId}`
|
|
64
|
+
} else {
|
|
65
|
+
status = RequestStatus.READY
|
|
66
|
+
href = url.report.fullUrl
|
|
67
|
+
}
|
|
63
68
|
|
|
64
69
|
return {
|
|
65
70
|
id,
|
|
66
71
|
text,
|
|
67
72
|
description,
|
|
68
73
|
tag: 'MIS',
|
|
69
|
-
summary,
|
|
74
|
+
summary: query.summary as { name: string; value: string }[],
|
|
70
75
|
href,
|
|
71
76
|
timestamp: `Last viewed: ${new Date(timestamp.lastViewed).toLocaleString()}`,
|
|
72
77
|
status,
|
|
@@ -6,7 +6,7 @@ const FULL_BUTTON_LIST = [
|
|
|
6
6
|
icon: 'refresh',
|
|
7
7
|
disabled: false,
|
|
8
8
|
tooltipText: 'Refresh report',
|
|
9
|
-
ariaLabelText: '
|
|
9
|
+
ariaLabelText: 'Refresh report',
|
|
10
10
|
},
|
|
11
11
|
{
|
|
12
12
|
id: 'printable',
|
|
@@ -59,7 +59,7 @@ exports.default = {
|
|
|
59
59
|
actions.push({
|
|
60
60
|
type: 'refresh',
|
|
61
61
|
data: {
|
|
62
|
-
href: reportData.url.request.fullUrl
|
|
62
|
+
href: `${reportData.url.request.fullUrl}&refreshId=${reportData.executionId}`,
|
|
63
63
|
},
|
|
64
64
|
});
|
|
65
65
|
// PRINT
|
|
@@ -8,7 +8,7 @@ const FULL_BUTTON_LIST = [
|
|
|
8
8
|
icon: 'refresh',
|
|
9
9
|
disabled: false,
|
|
10
10
|
tooltipText: 'Refresh report',
|
|
11
|
-
ariaLabelText: '
|
|
11
|
+
ariaLabelText: 'Refresh report',
|
|
12
12
|
},
|
|
13
13
|
{
|
|
14
14
|
id: 'printable',
|
|
@@ -64,7 +64,7 @@ export default {
|
|
|
64
64
|
actions.push({
|
|
65
65
|
type: 'refresh',
|
|
66
66
|
data: {
|
|
67
|
-
href: reportData.url.request.fullUrl
|
|
67
|
+
href: `${reportData.url.request.fullUrl}&refreshId=${reportData.executionId}`,
|
|
68
68
|
},
|
|
69
69
|
})
|
|
70
70
|
|
|
@@ -82,14 +82,15 @@ class RecentlyViewedStoreService extends userStoreService_1.default {
|
|
|
82
82
|
this.recentlyViewedReports[index] = report;
|
|
83
83
|
await this.saveRecentlyViewedState();
|
|
84
84
|
}
|
|
85
|
-
async
|
|
86
|
-
const
|
|
87
|
-
if (
|
|
85
|
+
async setReportTimestamp(executionId, type) {
|
|
86
|
+
const report = await this.getReportByExecutionId(executionId);
|
|
87
|
+
if (report) {
|
|
88
88
|
const timestamp = {
|
|
89
|
-
...
|
|
90
|
-
retried: new Date(),
|
|
89
|
+
...report.timestamp,
|
|
90
|
+
...(type === 'retry' && { retried: new Date() }),
|
|
91
|
+
...(type === 'refresh' && { refresh: new Date() }),
|
|
91
92
|
};
|
|
92
|
-
await this.updateReport(
|
|
93
|
+
await this.updateReport(executionId, { timestamp });
|
|
93
94
|
}
|
|
94
95
|
}
|
|
95
96
|
async setToExpired(id) {
|
|
@@ -106,14 +106,15 @@ export default class RecentlyViewedStoreService extends UserStoreService {
|
|
|
106
106
|
await this.saveRecentlyViewedState()
|
|
107
107
|
}
|
|
108
108
|
|
|
109
|
-
async
|
|
110
|
-
const
|
|
111
|
-
if (
|
|
109
|
+
async setReportTimestamp(executionId: string, type: string) {
|
|
110
|
+
const report = await this.getReportByExecutionId(executionId)
|
|
111
|
+
if (report) {
|
|
112
112
|
const timestamp: AsyncReportsTimestamp = {
|
|
113
|
-
...
|
|
114
|
-
retried: new Date(),
|
|
113
|
+
...report.timestamp,
|
|
114
|
+
...(type === 'retry' && { retried: new Date() }),
|
|
115
|
+
...(type === 'refresh' && { refresh: new Date() }),
|
|
115
116
|
}
|
|
116
|
-
await this.updateReport(
|
|
117
|
+
await this.updateReport(executionId, { timestamp })
|
|
117
118
|
}
|
|
118
119
|
}
|
|
119
120
|
|
|
@@ -97,14 +97,15 @@ class AsyncReportStoreService extends userStoreService_1.default {
|
|
|
97
97
|
this.requestedReports[index] = report;
|
|
98
98
|
await this.saveRequestedReportState();
|
|
99
99
|
}
|
|
100
|
-
async
|
|
101
|
-
const
|
|
102
|
-
if (
|
|
100
|
+
async setReportTimestamp(executionId, type) {
|
|
101
|
+
const report = await this.getReportByExecutionId(executionId);
|
|
102
|
+
if (report) {
|
|
103
103
|
const timestamp = {
|
|
104
|
-
...
|
|
105
|
-
retried: new Date(),
|
|
104
|
+
...report.timestamp,
|
|
105
|
+
...(type === 'retry' && { retried: new Date() }),
|
|
106
|
+
...(type === 'refresh' && { refresh: new Date() }),
|
|
106
107
|
};
|
|
107
|
-
await this.updateReport(
|
|
108
|
+
await this.updateReport(executionId, { timestamp });
|
|
108
109
|
}
|
|
109
110
|
}
|
|
110
111
|
async updateLastViewed(id) {
|
|
@@ -129,14 +129,15 @@ export default class AsyncReportStoreService extends UserStoreService {
|
|
|
129
129
|
await this.saveRequestedReportState()
|
|
130
130
|
}
|
|
131
131
|
|
|
132
|
-
async
|
|
133
|
-
const
|
|
134
|
-
if (
|
|
132
|
+
async setReportTimestamp(executionId: string, type: string) {
|
|
133
|
+
const report = await this.getReportByExecutionId(executionId)
|
|
134
|
+
if (report) {
|
|
135
135
|
const timestamp: AsyncReportsTimestamp = {
|
|
136
|
-
...
|
|
137
|
-
retried: new Date(),
|
|
136
|
+
...report.timestamp,
|
|
137
|
+
...(type === 'retry' && { retried: new Date() }),
|
|
138
|
+
...(type === 'refresh' && { refresh: new Date() }),
|
|
138
139
|
}
|
|
139
|
-
await this.updateReport(
|
|
140
|
+
await this.updateReport(executionId, { timestamp })
|
|
140
141
|
}
|
|
141
142
|
}
|
|
142
143
|
|
package/dpr/types/AsyncReport.ts
CHANGED
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.12.
|
|
4
|
+
"version": "3.12.3",
|
|
5
5
|
"main": "dpr/assets/js/all.mjs",
|
|
6
6
|
"sass": "dpr/all.scss",
|
|
7
7
|
"engines": {
|
package/package.zip
CHANGED
|
Binary file
|