@ministryofjustice/hmpps-digital-prison-reporting-frontend
Version:
The Digital Prison Reporting Frontend contains templates and code to help display data effectively in UI applications.
92 lines (87 loc) • 3.2 kB
JavaScript
;
Object.defineProperty(exports, '__esModule', { value: true });
var logger = require('../utils/logger.js');
var restClient = require('./restClient.js');
class DashboardClient {
restClient;
constructor(config) {
this.restClient = new restClient.RestClient('Dashboard API Client', config);
}
getDefinition(token, dashboardId, dpdId, definitionsPath, queryData) {
const query = {
...queryData,
dataProductDefinitionsPath: definitionsPath,
};
this.logInfo('Get definition:', { dpdId, dashboardId, ...query });
return this.restClient
.get({
path: `/definitions/${dpdId}/dashboards/${dashboardId}`,
query,
token,
})
.then(response => response);
}
requestAsyncDashboard(token, reportId, dashboardId, query) {
this.logInfo('Request dashboard:', { reportId, dashboardId });
return this.restClient
.get({
path: `/async/dashboards/${reportId}/${dashboardId}`,
token,
query,
})
.then(response => response);
}
getAsyncDashboard(token, reportId, dashboardId, tableId, query) {
this.logInfo('Get dashboard:', { reportId, dashboardId, tableId });
return this.restClient
.get({
path: `/reports/${reportId}/dashboards/${dashboardId}/tables/${tableId}/result`,
token,
query,
})
.then(response => response);
}
getAsyncStatus(token, reportId, dashboardId, executionId, tableId, dataProductDefinitionsPath) {
this.logInfo('Get status:', { reportId, dashboardId, executionId, tableId });
return this.restClient
.get({
path: `/reports/${reportId}/dashboards/${dashboardId}/statements/${executionId}/status`,
token,
query: {
dataProductDefinitionsPath,
tableId,
},
})
.then(response => response);
}
cancelAsyncRequest(token, reportId, dashboardId, executionId, dataProductDefinitionsPath) {
this.logInfo('Cancel request:', { reportId, dashboardId, executionId });
return this.restClient
.delete({
path: `/reports/${reportId}/dashboards/${dashboardId}/statements/${executionId}`,
token,
query: {
dataProductDefinitionsPath,
},
})
.then(response => response);
}
getSyncDashboard(token, reportId, dashboardId, query) {
this.logInfo('Get dashboard:', { reportId, dashboardId });
return this.restClient
.get({
path: `/reports/${reportId}/dashboards/${dashboardId}`,
token,
query,
})
.then(response => response);
}
logInfo(title, args) {
logger.default.info(`Dashboard client: ${title}:`);
if (args && Object.keys(args).length)
logger.default.info(JSON.stringify(args));
}
}
exports.DashboardClient = DashboardClient;
exports.default = DashboardClient;
//# sourceMappingURL=dashboardClient.js.map