@ministryofjustice/hmpps-digital-prison-reporting-frontend 3.26.3 → 3.26.5
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 +1 -0
- package/dpr/components/async-filters/utils.js +10 -7
- package/dpr/components/async-filters/utils.ts +10 -6
- package/dpr/components/async-polling/utils.js +7 -5
- package/dpr/components/async-polling/utils.ts +4 -2
- package/dpr/components/async-request-list/utils.js +10 -4
- package/dpr/components/async-request-list/utils.ts +7 -3
- package/dpr/components/recently-viewed-list/utils.js +3 -1
- package/dpr/components/recently-viewed-list/utils.ts +3 -1
- package/dpr/components/reports-list/utils.js +9 -7
- package/dpr/components/reports-list/utils.ts +49 -40
- package/dpr/data/metricsClient.js +1 -1
- package/dpr/data/metricsClient.ts +1 -1
- package/dpr/routes/asyncReports.js +3 -1
- package/dpr/routes/asyncReports.ts +3 -1
- package/dpr/routes/bookmarks.js +6 -2
- package/dpr/routes/bookmarks.ts +4 -2
- package/dpr/routes/recentlyViewed.js +3 -1
- package/dpr/routes/recentlyViewed.ts +2 -1
- package/dpr/services/bookmarkService.js +19 -36
- package/dpr/services/bookmarkService.ts +19 -42
- package/dpr/services/recentlyViewedService.js +27 -70
- package/dpr/services/recentlyViewedService.ts +30 -81
- package/dpr/services/requestedReportsService.js +41 -73
- package/dpr/services/requestedReportsService.ts +44 -80
- package/dpr/services/userStoreService.js +7 -8
- package/dpr/services/userStoreService.ts +7 -12
- package/dpr/utils/bookmarkListUtils.js +21 -13
- package/dpr/utils/bookmarkListUtils.ts +25 -12
- package/dpr/utils/renderAsyncReport.js +9 -6
- package/dpr/utils/renderAsyncReport.ts +7 -5
- package/dpr/utils/reportsListHelper.js +1 -1
- package/dpr/utils/reportsListHelper.ts +2 -1
- package/dpr/views/dashboard.njk +0 -5
- package/package.json +1 -1
- package/package.zip +0 -0
package/dpr/assets/js/all.mjs
CHANGED
|
@@ -188,6 +188,7 @@ const getFiltersFromDefinition = (definition) => {
|
|
|
188
188
|
* Updates the store with the request details
|
|
189
189
|
*
|
|
190
190
|
* @param {Request} req
|
|
191
|
+
* @param {Response} res
|
|
191
192
|
* @param {Services} services
|
|
192
193
|
* @param {components['schemas']['FieldDefinition'][]} fields
|
|
193
194
|
* @param {querySummaryResult} querySummaryData
|
|
@@ -195,22 +196,24 @@ const getFiltersFromDefinition = (definition) => {
|
|
|
195
196
|
* @param {string} tableId
|
|
196
197
|
* @return {*} {Promise<string>}
|
|
197
198
|
*/
|
|
198
|
-
const updateStore = async (req, services, fields, querySummaryData, executionId, tableId) => {
|
|
199
|
+
const updateStore = async (req, res, services, fields, querySummaryData, executionId, tableId) => {
|
|
200
|
+
var _a;
|
|
199
201
|
const { search, variantId } = req.body;
|
|
200
202
|
const { query, filterData, querySummary, sortData } = querySummaryData;
|
|
203
|
+
const userId = ((_a = res.locals.user) === null || _a === void 0 ? void 0 : _a.uuid) ? res.locals.user.uuid : 'userId';
|
|
201
204
|
// 1. check for duplicate requests and remove them from the request list
|
|
202
|
-
const requestedReports = await services.asyncReportsStore.getAllReportsByVariantId(variantId);
|
|
203
|
-
const viewedReports = await services.recentlyViewedStoreService.getAllReportsByVariantId(variantId);
|
|
205
|
+
const requestedReports = await services.asyncReportsStore.getAllReportsByVariantId(variantId, userId);
|
|
206
|
+
const viewedReports = await services.recentlyViewedStoreService.getAllReportsByVariantId(variantId, userId);
|
|
204
207
|
const duplicateRequestIds = (0, reportSummaryHelper_1.getDuplicateRequestIds)(search, requestedReports);
|
|
205
208
|
if (duplicateRequestIds.length) {
|
|
206
209
|
await Promise.all(duplicateRequestIds.map(async (id) => {
|
|
207
|
-
await await services.asyncReportsStore.removeReport(id);
|
|
210
|
+
await await services.asyncReportsStore.removeReport(id, userId);
|
|
208
211
|
}));
|
|
209
212
|
}
|
|
210
213
|
const duplicateViewedReportIds = (0, reportSummaryHelper_1.getDuplicateRequestIds)(search, viewedReports);
|
|
211
214
|
if (duplicateViewedReportIds.length) {
|
|
212
215
|
await Promise.all(duplicateViewedReportIds.map(async (id) => {
|
|
213
|
-
await await services.recentlyViewedStoreService.removeReport(id);
|
|
216
|
+
await await services.recentlyViewedStoreService.removeReport(id, userId);
|
|
214
217
|
}));
|
|
215
218
|
}
|
|
216
219
|
// 2. Add the new request data to the store
|
|
@@ -218,7 +221,7 @@ const updateStore = async (req, services, fields, querySummaryData, executionId,
|
|
|
218
221
|
...req.body,
|
|
219
222
|
executionId,
|
|
220
223
|
tableId,
|
|
221
|
-
}, filterData, sortData, query, querySummary);
|
|
224
|
+
}, filterData, sortData, query, querySummary, userId);
|
|
222
225
|
return reportData.url.polling.pathname;
|
|
223
226
|
};
|
|
224
227
|
exports.updateStore = updateStore;
|
|
@@ -353,7 +356,7 @@ exports.default = {
|
|
|
353
356
|
});
|
|
354
357
|
let redirect = '';
|
|
355
358
|
if (executionId && tableId) {
|
|
356
|
-
redirect = await (0, exports.updateStore)(req, services, fields, querySummaryData, executionId, tableId);
|
|
359
|
+
redirect = await (0, exports.updateStore)(req, res, services, fields, querySummaryData, executionId, tableId);
|
|
357
360
|
}
|
|
358
361
|
return redirect;
|
|
359
362
|
},
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/* eslint-disable no-param-reassign */
|
|
2
|
-
import { Request } from 'express'
|
|
2
|
+
import { Request, Response } from 'express'
|
|
3
3
|
import moment from 'moment'
|
|
4
4
|
import dayjs from 'dayjs'
|
|
5
5
|
import isBetween from 'dayjs/plugin/isBetween'
|
|
@@ -204,6 +204,7 @@ const getFiltersFromDefinition = (definition: components['schemas']['VariantDefi
|
|
|
204
204
|
* Updates the store with the request details
|
|
205
205
|
*
|
|
206
206
|
* @param {Request} req
|
|
207
|
+
* @param {Response} res
|
|
207
208
|
* @param {Services} services
|
|
208
209
|
* @param {components['schemas']['FieldDefinition'][]} fields
|
|
209
210
|
* @param {querySummaryResult} querySummaryData
|
|
@@ -213,6 +214,7 @@ const getFiltersFromDefinition = (definition: components['schemas']['VariantDefi
|
|
|
213
214
|
*/
|
|
214
215
|
export const updateStore = async (
|
|
215
216
|
req: Request,
|
|
217
|
+
res: Response,
|
|
216
218
|
services: Services,
|
|
217
219
|
fields: components['schemas']['FieldDefinition'][],
|
|
218
220
|
querySummaryData: querySummaryResult,
|
|
@@ -221,16 +223,17 @@ export const updateStore = async (
|
|
|
221
223
|
): Promise<string> => {
|
|
222
224
|
const { search, variantId } = req.body
|
|
223
225
|
const { query, filterData, querySummary, sortData } = querySummaryData
|
|
226
|
+
const userId = res.locals.user?.uuid ? res.locals.user.uuid : 'userId'
|
|
224
227
|
|
|
225
228
|
// 1. check for duplicate requests and remove them from the request list
|
|
226
|
-
const requestedReports = await services.asyncReportsStore.getAllReportsByVariantId(variantId)
|
|
227
|
-
const viewedReports = await services.recentlyViewedStoreService.getAllReportsByVariantId(variantId)
|
|
229
|
+
const requestedReports = await services.asyncReportsStore.getAllReportsByVariantId(variantId, userId)
|
|
230
|
+
const viewedReports = await services.recentlyViewedStoreService.getAllReportsByVariantId(variantId, userId)
|
|
228
231
|
|
|
229
232
|
const duplicateRequestIds = getDuplicateRequestIds(search, requestedReports)
|
|
230
233
|
if (duplicateRequestIds.length) {
|
|
231
234
|
await Promise.all(
|
|
232
235
|
duplicateRequestIds.map(async (id: string) => {
|
|
233
|
-
await await services.asyncReportsStore.removeReport(id)
|
|
236
|
+
await await services.asyncReportsStore.removeReport(id, userId)
|
|
234
237
|
}),
|
|
235
238
|
)
|
|
236
239
|
}
|
|
@@ -239,7 +242,7 @@ export const updateStore = async (
|
|
|
239
242
|
if (duplicateViewedReportIds.length) {
|
|
240
243
|
await Promise.all(
|
|
241
244
|
duplicateViewedReportIds.map(async (id: string) => {
|
|
242
|
-
await await services.recentlyViewedStoreService.removeReport(id)
|
|
245
|
+
await await services.recentlyViewedStoreService.removeReport(id, userId)
|
|
243
246
|
}),
|
|
244
247
|
)
|
|
245
248
|
}
|
|
@@ -255,6 +258,7 @@ export const updateStore = async (
|
|
|
255
258
|
sortData,
|
|
256
259
|
query,
|
|
257
260
|
querySummary,
|
|
261
|
+
userId,
|
|
258
262
|
)
|
|
259
263
|
|
|
260
264
|
return reportData.url.polling.pathname
|
|
@@ -436,7 +440,7 @@ export default {
|
|
|
436
440
|
|
|
437
441
|
let redirect = ''
|
|
438
442
|
if (executionId && tableId) {
|
|
439
|
-
redirect = await updateStore(req, services, fields, querySummaryData, executionId, tableId)
|
|
443
|
+
redirect = await updateStore(req, res, services, fields, querySummaryData, executionId, tableId)
|
|
440
444
|
}
|
|
441
445
|
return redirect
|
|
442
446
|
},
|
|
@@ -3,20 +3,22 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
const AsyncReport_1 = require("../../types/AsyncReport");
|
|
4
4
|
exports.default = {
|
|
5
5
|
cancelRequest: async ({ req, res, services }) => {
|
|
6
|
-
var _a;
|
|
6
|
+
var _a, _b;
|
|
7
7
|
const token = ((_a = res.locals.user) === null || _a === void 0 ? void 0 : _a.token) ? res.locals.user.token : 'token';
|
|
8
|
+
const userId = ((_b = res.locals.user) === null || _b === void 0 ? void 0 : _b.uuid) ? res.locals.user.uuid : 'userId';
|
|
8
9
|
const { reportId, variantId, executionId } = req.body;
|
|
9
10
|
const response = await services.reportingService.cancelAsyncRequest(token, reportId, variantId, executionId);
|
|
10
11
|
if (response && response.cancellationSucceeded) {
|
|
11
|
-
await services.asyncReportsStore.updateStatus(executionId, AsyncReport_1.RequestStatus.ABORTED);
|
|
12
|
+
await services.asyncReportsStore.updateStatus(executionId, userId, AsyncReport_1.RequestStatus.ABORTED);
|
|
12
13
|
}
|
|
13
14
|
},
|
|
14
15
|
renderPolling: async ({ req, res, services }) => {
|
|
15
|
-
var _a;
|
|
16
|
+
var _a, _b;
|
|
16
17
|
const csrfToken = res.locals.csrfToken || 'csrfToken';
|
|
18
|
+
const userId = ((_a = res.locals.user) === null || _a === void 0 ? void 0 : _a.uuid) ? res.locals.user.uuid : 'userId';
|
|
17
19
|
const { dataProductDefinitionsPath: definitionPath } = req.query;
|
|
18
20
|
const { reportId, variantId, executionId } = req.params;
|
|
19
|
-
const reportData = await services.asyncReportsStore.getReportByExecutionId(executionId);
|
|
21
|
+
const reportData = await services.asyncReportsStore.getReportByExecutionId(executionId, userId);
|
|
20
22
|
const { reportName, name, description, status, tableId, query, timestamp, url, errorMessage } = reportData;
|
|
21
23
|
return {
|
|
22
24
|
pollingRenderData: {
|
|
@@ -32,7 +34,7 @@ exports.default = {
|
|
|
32
34
|
querySummary: query.summary,
|
|
33
35
|
requestedAt: timestamp.requested,
|
|
34
36
|
csrfToken,
|
|
35
|
-
...(((
|
|
37
|
+
...(((_b = url.report) === null || _b === void 0 ? void 0 : _b.fullUrl) && { reportUrl: url.report.fullUrl }),
|
|
36
38
|
...(url.request.fullUrl && { requestUrl: url.request.fullUrl }),
|
|
37
39
|
...(errorMessage && { errorMessage }),
|
|
38
40
|
},
|
|
@@ -4,20 +4,22 @@ import { AsyncReportUtilsParams } from '../../types/AsyncReportUtils'
|
|
|
4
4
|
export default {
|
|
5
5
|
cancelRequest: async ({ req, res, services }: AsyncReportUtilsParams) => {
|
|
6
6
|
const token = res.locals.user?.token ? res.locals.user.token : 'token'
|
|
7
|
+
const userId = res.locals.user?.uuid ? res.locals.user.uuid : 'userId'
|
|
7
8
|
const { reportId, variantId, executionId } = req.body
|
|
8
9
|
|
|
9
10
|
const response = await services.reportingService.cancelAsyncRequest(token, reportId, variantId, executionId)
|
|
10
11
|
if (response && response.cancellationSucceeded) {
|
|
11
|
-
await services.asyncReportsStore.updateStatus(executionId, RequestStatus.ABORTED)
|
|
12
|
+
await services.asyncReportsStore.updateStatus(executionId, userId, RequestStatus.ABORTED)
|
|
12
13
|
}
|
|
13
14
|
},
|
|
14
15
|
|
|
15
16
|
renderPolling: async ({ req, res, services }: AsyncReportUtilsParams) => {
|
|
16
17
|
const csrfToken = (res.locals.csrfToken as unknown as string) || 'csrfToken'
|
|
18
|
+
const userId = res.locals.user?.uuid ? res.locals.user.uuid : 'userId'
|
|
17
19
|
const { dataProductDefinitionsPath: definitionPath } = req.query
|
|
18
20
|
const { reportId, variantId, executionId } = req.params
|
|
19
21
|
|
|
20
|
-
const reportData = await services.asyncReportsStore.getReportByExecutionId(executionId)
|
|
22
|
+
const reportData = await services.asyncReportsStore.getReportByExecutionId(executionId, userId)
|
|
21
23
|
const { reportName, name, description, status, tableId, query, timestamp, url, errorMessage } = reportData
|
|
22
24
|
|
|
23
25
|
return {
|
|
@@ -98,24 +98,30 @@ const filterReports = (report) => {
|
|
|
98
98
|
exports.filterReports = filterReports;
|
|
99
99
|
exports.default = {
|
|
100
100
|
getRequestStatus: async ({ req, res, services }) => {
|
|
101
|
+
var _a;
|
|
101
102
|
const { executionId, status: currentStatus } = req.body;
|
|
103
|
+
const userId = ((_a = res.locals.user) === null || _a === void 0 ? void 0 : _a.uuid) ? res.locals.user.uuid : 'userId';
|
|
102
104
|
const response = await (0, reportStatusHelper_1.getStatus)({ req, res, services });
|
|
103
105
|
if (currentStatus !== response.status) {
|
|
104
|
-
await services.asyncReportsStore.updateStatus(executionId, response.status, response.errorMessage);
|
|
105
|
-
response.reportData = await services.asyncReportsStore.getReportByExecutionId(executionId);
|
|
106
|
+
await services.asyncReportsStore.updateStatus(executionId, userId, response.status, response.errorMessage);
|
|
107
|
+
response.reportData = await services.asyncReportsStore.getReportByExecutionId(executionId, userId);
|
|
106
108
|
}
|
|
107
109
|
return response;
|
|
108
110
|
},
|
|
109
111
|
getExpiredStatus: async ({ req, res, services }) => {
|
|
112
|
+
var _a;
|
|
113
|
+
const userId = ((_a = res.locals.user) === null || _a === void 0 ? void 0 : _a.uuid) ? res.locals.user.uuid : 'userId';
|
|
110
114
|
const report = await (0, reportStatusHelper_1.getExpiredStatus)({ req, res, services });
|
|
111
115
|
if (report.isExpired) {
|
|
112
|
-
await services.asyncReportsStore.setToExpired(report.executionId);
|
|
116
|
+
await services.asyncReportsStore.setToExpired(report.executionId, userId);
|
|
113
117
|
}
|
|
114
118
|
return report.isExpired;
|
|
115
119
|
},
|
|
116
120
|
renderList: async ({ services, res, maxRows, }) => {
|
|
121
|
+
var _a;
|
|
117
122
|
const csrfToken = res.locals.csrfToken || 'csrfToken';
|
|
118
|
-
const
|
|
123
|
+
const userId = ((_a = res.locals.user) === null || _a === void 0 ? void 0 : _a.uuid) ? res.locals.user.uuid : 'userId';
|
|
124
|
+
const requestedReportsData = await services.asyncReportsStore.getAllReports(userId);
|
|
119
125
|
let cardData = await ReportListHelper.formatCards(requestedReportsData, exports.filterReports, exports.formatCardData);
|
|
120
126
|
if (maxRows)
|
|
121
127
|
cardData = cardData.slice(0, maxRows);
|
|
@@ -89,24 +89,27 @@ export const filterReports = (report: AsyncReportData) => {
|
|
|
89
89
|
export default {
|
|
90
90
|
getRequestStatus: async ({ req, res, services }: AsyncReportUtilsParams) => {
|
|
91
91
|
const { executionId, status: currentStatus } = req.body
|
|
92
|
+
const userId = res.locals.user?.uuid ? res.locals.user.uuid : 'userId'
|
|
92
93
|
const response = await getStatus({ req, res, services })
|
|
93
94
|
|
|
94
95
|
if (currentStatus !== response.status) {
|
|
95
96
|
await services.asyncReportsStore.updateStatus(
|
|
96
97
|
executionId,
|
|
98
|
+
userId,
|
|
97
99
|
response.status as RequestStatus,
|
|
98
100
|
response.errorMessage,
|
|
99
101
|
)
|
|
100
|
-
response.reportData = await services.asyncReportsStore.getReportByExecutionId(executionId)
|
|
102
|
+
response.reportData = await services.asyncReportsStore.getReportByExecutionId(executionId, userId)
|
|
101
103
|
}
|
|
102
104
|
|
|
103
105
|
return response
|
|
104
106
|
},
|
|
105
107
|
|
|
106
108
|
getExpiredStatus: async ({ req, res, services }: AsyncReportUtilsParams) => {
|
|
109
|
+
const userId = res.locals.user?.uuid ? res.locals.user.uuid : 'userId'
|
|
107
110
|
const report = await getExpiredStatus({ req, res, services })
|
|
108
111
|
if (report.isExpired) {
|
|
109
|
-
await services.asyncReportsStore.setToExpired(report.executionId)
|
|
112
|
+
await services.asyncReportsStore.setToExpired(report.executionId, userId)
|
|
110
113
|
}
|
|
111
114
|
return report.isExpired
|
|
112
115
|
},
|
|
@@ -117,7 +120,8 @@ export default {
|
|
|
117
120
|
maxRows,
|
|
118
121
|
}: { maxRows?: number } & AsyncReportUtilsParams): Promise<RenderTableListResponse> => {
|
|
119
122
|
const csrfToken = (res.locals.csrfToken as unknown as string) || 'csrfToken'
|
|
120
|
-
const
|
|
123
|
+
const userId = res.locals.user?.uuid ? res.locals.user.uuid : 'userId'
|
|
124
|
+
const requestedReportsData: AsyncReportData[] = await services.asyncReportsStore.getAllReports(userId)
|
|
121
125
|
|
|
122
126
|
let cardData = await ReportListHelper.formatCards(requestedReportsData, filterReports, formatCardData)
|
|
123
127
|
if (maxRows) cardData = cardData.slice(0, maxRows)
|
|
@@ -67,9 +67,11 @@ const filterReports = (report) => {
|
|
|
67
67
|
exports.filterReports = filterReports;
|
|
68
68
|
exports.default = {
|
|
69
69
|
getExpiredStatus: async ({ req, res, services }) => {
|
|
70
|
+
var _a;
|
|
70
71
|
const report = await (0, reportStatusHelper_1.getExpiredStatus)({ req, res, services });
|
|
72
|
+
const userId = ((_a = res.locals.user) === null || _a === void 0 ? void 0 : _a.uuid) ? res.locals.user.uuid : 'userId';
|
|
71
73
|
if (report.isExpired) {
|
|
72
|
-
await services.recentlyViewedStoreService.setToExpired(report.executionId);
|
|
74
|
+
await services.recentlyViewedStoreService.setToExpired(report.executionId, userId);
|
|
73
75
|
}
|
|
74
76
|
return report.isExpired;
|
|
75
77
|
},
|
|
@@ -59,8 +59,10 @@ export const filterReports = (report: RecentlyViewedReportData) => {
|
|
|
59
59
|
export default {
|
|
60
60
|
getExpiredStatus: async ({ req, res, services }: AsyncReportUtilsParams) => {
|
|
61
61
|
const report = await getExpiredStatus({ req, res, services })
|
|
62
|
+
const userId = res.locals.user?.uuid ? res.locals.user.uuid : 'userId'
|
|
63
|
+
|
|
62
64
|
if (report.isExpired) {
|
|
63
|
-
await services.recentlyViewedStoreService.setToExpired(report.executionId)
|
|
65
|
+
await services.recentlyViewedStoreService.setToExpired(report.executionId, userId)
|
|
64
66
|
}
|
|
65
67
|
return report.isExpired
|
|
66
68
|
},
|
|
@@ -2,9 +2,11 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
const reportsListHelper_1 = require("../../utils/reportsListHelper");
|
|
4
4
|
exports.default = {
|
|
5
|
-
mapReportsList: (res, services) => {
|
|
5
|
+
mapReportsList: async (res, services) => {
|
|
6
|
+
var _a;
|
|
6
7
|
const { definitions, csrfToken } = res.locals;
|
|
7
8
|
const pathSuffix = res.locals.pathSuffix || '';
|
|
9
|
+
const userId = ((_a = res.locals.user) === null || _a === void 0 ? void 0 : _a.uuid) ? res.locals.user.uuid : 'userId';
|
|
8
10
|
// Sort report Definitions by product name
|
|
9
11
|
const sortedDefinitions = definitions.sort((a, b) => {
|
|
10
12
|
if (a.name < b.name)
|
|
@@ -29,7 +31,7 @@ exports.default = {
|
|
|
29
31
|
name,
|
|
30
32
|
description,
|
|
31
33
|
type: 'report',
|
|
32
|
-
reportDescription,
|
|
34
|
+
...(reportDescription && reportDescription.length && { reportDescription }),
|
|
33
35
|
};
|
|
34
36
|
});
|
|
35
37
|
let dashboardsArray = [];
|
|
@@ -57,7 +59,7 @@ exports.default = {
|
|
|
57
59
|
});
|
|
58
60
|
return mergedArray;
|
|
59
61
|
});
|
|
60
|
-
const rows = sortedVariants.map((v) => {
|
|
62
|
+
const rows = await Promise.all(sortedVariants.map(async (v) => {
|
|
61
63
|
const { id, name, description, reportName, reportId, reportDescription, type } = v;
|
|
62
64
|
const desc = description || reportDescription;
|
|
63
65
|
let hrefHtml;
|
|
@@ -65,9 +67,9 @@ exports.default = {
|
|
|
65
67
|
let listType;
|
|
66
68
|
switch (type) {
|
|
67
69
|
case 'report':
|
|
68
|
-
hrefHtml = `<a href=
|
|
70
|
+
hrefHtml = `<a href='/async-reports/${reportId}/${id}/request${pathSuffix}'>${name}</a>`;
|
|
69
71
|
bookmarkColumn = {
|
|
70
|
-
html: services.bookmarkService.createBookMarkToggleHtml(reportId, id, csrfToken, 'reports-list'),
|
|
72
|
+
html: await services.bookmarkService.createBookMarkToggleHtml(userId, reportId, id, csrfToken, 'reports-list'),
|
|
71
73
|
attributes: {
|
|
72
74
|
tabindex: 0,
|
|
73
75
|
},
|
|
@@ -75,7 +77,7 @@ exports.default = {
|
|
|
75
77
|
listType = (0, reportsListHelper_1.createTag)(type);
|
|
76
78
|
break;
|
|
77
79
|
case 'dashboard':
|
|
78
|
-
hrefHtml = `<a href=
|
|
80
|
+
hrefHtml = `<a href='/dashboards/${reportId}/load/${id}${pathSuffix}'>${name}</a>`;
|
|
79
81
|
bookmarkColumn = {};
|
|
80
82
|
listType = (0, reportsListHelper_1.createTag)(type);
|
|
81
83
|
break;
|
|
@@ -93,7 +95,7 @@ exports.default = {
|
|
|
93
95
|
...bookmarkColumn,
|
|
94
96
|
},
|
|
95
97
|
];
|
|
96
|
-
});
|
|
98
|
+
}));
|
|
97
99
|
const head = [
|
|
98
100
|
{ text: 'Product', classes: 'dpr-product-head' },
|
|
99
101
|
{ text: 'Name', classes: 'dpr-name-head' },
|
|
@@ -15,12 +15,13 @@ interface definitionData {
|
|
|
15
15
|
}
|
|
16
16
|
|
|
17
17
|
export default {
|
|
18
|
-
mapReportsList: (
|
|
18
|
+
mapReportsList: async (
|
|
19
19
|
res: Response,
|
|
20
20
|
services: Services,
|
|
21
|
-
): { head: { text: string }[]; rows: { text?: string; html?: string }[] } => {
|
|
21
|
+
): Promise<{ head: { text: string }[]; rows: { text?: string; html?: string }[] }> => {
|
|
22
22
|
const { definitions, csrfToken } = res.locals
|
|
23
23
|
const pathSuffix = res.locals.pathSuffix || ''
|
|
24
|
+
const userId = res.locals.user?.uuid ? res.locals.user.uuid : 'userId'
|
|
24
25
|
|
|
25
26
|
// Sort report Definitions by product name
|
|
26
27
|
const sortedDefinitions = definitions.sort(
|
|
@@ -48,7 +49,7 @@ export default {
|
|
|
48
49
|
name,
|
|
49
50
|
description,
|
|
50
51
|
type: 'report',
|
|
51
|
-
reportDescription,
|
|
52
|
+
...(reportDescription && reportDescription.length && { reportDescription }),
|
|
52
53
|
}
|
|
53
54
|
})
|
|
54
55
|
|
|
@@ -80,45 +81,53 @@ export default {
|
|
|
80
81
|
},
|
|
81
82
|
)
|
|
82
83
|
|
|
83
|
-
const rows =
|
|
84
|
-
|
|
85
|
-
|
|
84
|
+
const rows = await Promise.all(
|
|
85
|
+
sortedVariants.map(async (v: definitionData) => {
|
|
86
|
+
const { id, name, description, reportName, reportId, reportDescription, type } = v
|
|
87
|
+
const desc = description || reportDescription
|
|
86
88
|
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
89
|
+
let hrefHtml
|
|
90
|
+
let bookmarkColumn
|
|
91
|
+
let listType
|
|
92
|
+
switch (type) {
|
|
93
|
+
case 'report':
|
|
94
|
+
hrefHtml = `<a href='/async-reports/${reportId}/${id}/request${pathSuffix}'>${name}</a>`
|
|
95
|
+
bookmarkColumn = {
|
|
96
|
+
html: await services.bookmarkService.createBookMarkToggleHtml(
|
|
97
|
+
userId,
|
|
98
|
+
reportId,
|
|
99
|
+
id,
|
|
100
|
+
csrfToken,
|
|
101
|
+
'reports-list',
|
|
102
|
+
),
|
|
103
|
+
attributes: {
|
|
104
|
+
tabindex: 0,
|
|
105
|
+
},
|
|
106
|
+
}
|
|
107
|
+
listType = createTag(type)
|
|
108
|
+
break
|
|
109
|
+
case 'dashboard':
|
|
110
|
+
hrefHtml = `<a href='/dashboards/${reportId}/load/${id}${pathSuffix}'>${name}</a>`
|
|
111
|
+
bookmarkColumn = {}
|
|
112
|
+
listType = createTag(type)
|
|
113
|
+
break
|
|
114
|
+
default:
|
|
115
|
+
hrefHtml = ''
|
|
116
|
+
bookmarkColumn = {}
|
|
117
|
+
break
|
|
118
|
+
}
|
|
111
119
|
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
120
|
+
return [
|
|
121
|
+
{ text: reportName },
|
|
122
|
+
{ html: hrefHtml },
|
|
123
|
+
{ html: createShowMoreHtml(desc) },
|
|
124
|
+
{ html: listType },
|
|
125
|
+
{
|
|
126
|
+
...bookmarkColumn,
|
|
127
|
+
},
|
|
128
|
+
]
|
|
129
|
+
}),
|
|
130
|
+
)
|
|
122
131
|
|
|
123
132
|
const head = [
|
|
124
133
|
{ text: 'Product', classes: 'dpr-product-head' },
|
|
@@ -39,7 +39,7 @@ class MetricsClient {
|
|
|
39
39
|
logger_1.default.info(`Metrics client: Get metricId:${metricId} data`);
|
|
40
40
|
return this.restClient
|
|
41
41
|
.get({
|
|
42
|
-
path:
|
|
42
|
+
path: `/reports/${dpdId}/metrics/${metricId}`,
|
|
43
43
|
token,
|
|
44
44
|
})
|
|
45
45
|
.then((response) => response);
|
|
@@ -111,8 +111,10 @@ function routes({ router, services, layoutPath, templatePath = 'dpr/views/', })
|
|
|
111
111
|
}
|
|
112
112
|
};
|
|
113
113
|
const removeRequestedItemHandler = async (req, res, next) => {
|
|
114
|
+
var _a;
|
|
115
|
+
const userId = ((_a = res.locals.user) === null || _a === void 0 ? void 0 : _a.uuid) ? res.locals.user.uuid : 'userId';
|
|
114
116
|
try {
|
|
115
|
-
await services.asyncReportsStore.removeReport(req.body.executionId);
|
|
117
|
+
await services.asyncReportsStore.removeReport(req.body.executionId, userId);
|
|
116
118
|
res.end();
|
|
117
119
|
}
|
|
118
120
|
catch (error) {
|
|
@@ -99,8 +99,10 @@ export default function routes({
|
|
|
99
99
|
}
|
|
100
100
|
|
|
101
101
|
const removeRequestedItemHandler: RequestHandler = async (req, res, next) => {
|
|
102
|
+
const userId = res.locals.user?.uuid ? res.locals.user.uuid : 'userId'
|
|
103
|
+
|
|
102
104
|
try {
|
|
103
|
-
await services.asyncReportsStore.removeReport(req.body.executionId)
|
|
105
|
+
await services.asyncReportsStore.removeReport(req.body.executionId, userId)
|
|
104
106
|
res.end()
|
|
105
107
|
} catch (error) {
|
|
106
108
|
req.body.title = 'Failed to abort request'
|
package/dpr/routes/bookmarks.js
CHANGED
|
@@ -7,12 +7,16 @@ exports.default = routes;
|
|
|
7
7
|
const bookmarkListUtils_1 = __importDefault(require("../utils/bookmarkListUtils"));
|
|
8
8
|
function routes({ router, services, layoutPath, templatePath = 'dpr/views/', }) {
|
|
9
9
|
router.post('/addBookmark/', async (req, res) => {
|
|
10
|
+
var _a;
|
|
11
|
+
const userId = ((_a = res.locals.user) === null || _a === void 0 ? void 0 : _a.uuid) ? res.locals.user.uuid : 'userId';
|
|
10
12
|
const { reportId, variantId } = req.body;
|
|
11
|
-
await services.bookmarkService.addBookmark(reportId, variantId);
|
|
13
|
+
await services.bookmarkService.addBookmark(userId, reportId, variantId);
|
|
12
14
|
res.end();
|
|
13
15
|
});
|
|
14
16
|
router.post('/removeBookmark/', async (req, res) => {
|
|
15
|
-
|
|
17
|
+
var _a;
|
|
18
|
+
const userId = ((_a = res.locals.user) === null || _a === void 0 ? void 0 : _a.uuid) ? res.locals.user.uuid : 'userId';
|
|
19
|
+
await services.bookmarkService.removeBookmark(userId, req.body.variantId);
|
|
16
20
|
res.end();
|
|
17
21
|
});
|
|
18
22
|
router.get('/async-reports/bookmarks', async (req, res) => {
|
package/dpr/routes/bookmarks.ts
CHANGED
|
@@ -14,13 +14,15 @@ export default function routes({
|
|
|
14
14
|
templatePath?: string
|
|
15
15
|
}) {
|
|
16
16
|
router.post('/addBookmark/', async (req, res) => {
|
|
17
|
+
const userId = res.locals.user?.uuid ? res.locals.user.uuid : 'userId'
|
|
17
18
|
const { reportId, variantId } = req.body
|
|
18
|
-
await services.bookmarkService.addBookmark(reportId, variantId)
|
|
19
|
+
await services.bookmarkService.addBookmark(userId, reportId, variantId)
|
|
19
20
|
res.end()
|
|
20
21
|
})
|
|
21
22
|
|
|
22
23
|
router.post('/removeBookmark/', async (req, res) => {
|
|
23
|
-
|
|
24
|
+
const userId = res.locals.user?.uuid ? res.locals.user.uuid : 'userId'
|
|
25
|
+
await services.bookmarkService.removeBookmark(userId, req.body.variantId)
|
|
24
26
|
res.end()
|
|
25
27
|
})
|
|
26
28
|
|
|
@@ -16,7 +16,9 @@ function routes({ router, services, layoutPath, templatePath = 'dpr/views/', })
|
|
|
16
16
|
}
|
|
17
17
|
};
|
|
18
18
|
const removeViewedItemHandler = async (req, res, next) => {
|
|
19
|
-
|
|
19
|
+
var _a;
|
|
20
|
+
const userId = ((_a = res.locals.user) === null || _a === void 0 ? void 0 : _a.uuid) ? res.locals.user.uuid : 'userId';
|
|
21
|
+
await services.recentlyViewedStoreService.removeReport(req.body.executionId, userId);
|
|
20
22
|
res.end();
|
|
21
23
|
};
|
|
22
24
|
router.get('/async-reports/recently-viewed', async (req, res) => {
|
|
@@ -23,7 +23,8 @@ export default function routes({
|
|
|
23
23
|
}
|
|
24
24
|
|
|
25
25
|
const removeViewedItemHandler: RequestHandler = async (req, res, next) => {
|
|
26
|
-
|
|
26
|
+
const userId = res.locals.user?.uuid ? res.locals.user.uuid : 'userId'
|
|
27
|
+
await services.recentlyViewedStoreService.removeReport(req.body.executionId, userId)
|
|
27
28
|
res.end()
|
|
28
29
|
}
|
|
29
30
|
|