@ministryofjustice/hmpps-digital-prison-reporting-frontend
Version:
The Digital Prison Reporting Frontend contains templates and code to help display data effectively in UI applications.
46 lines (42 loc) • 1.7 kB
JavaScript
;
var ErrorHandler = require('../../../../../utils/ErrorHandler/ErrorHandler.js');
var UserReports = require('../../../../../types/UserReports.js');
var utils$1 = require('./utils.js');
var utils = require('../../utils.js');
class ViewSyncDashboardController {
layoutPath;
services;
constructor(layoutPath, services) {
this.layoutPath = layoutPath;
this.services = services;
}
GET = async (req, res, next) => {
try {
// Redirect the same path to attach query string
if (utils.default.redirectWithDefaults(res, req)) {
return;
}
// Get the validation errors
const validationErrors = res.locals['validationErrors'] || [];
// Render the dashaboad
const renderData = await utils$1.renderDashboard({ req, res, services: this.services });
res.render(`dpr/routes/journeys/view-report/dashboard`, {
layoutPath: this.layoutPath,
...renderData,
validationErrors,
});
}
catch (error) {
req.body ??= {};
req.body.title = `Dashboard Failed`;
req.body.errorDescription = 'We were unable to show this dashboard for the following reason:';
req.body.error = new ErrorHandler.ErrorHandler(error).formatError();
next(error);
}
};
applyFilters = async (req, res, _next) => {
await utils.default.applyDashboardInteractiveQuery(req, res, 'filters', UserReports.LoadType.SYNC);
};
}
exports.ViewSyncDashboardController = ViewSyncDashboardController;
//# sourceMappingURL=controller.js.map