Skip to content

Commit

Permalink
Add logic to build report detail page link and send as part of messag…
Browse files Browse the repository at this point in the history
…e for non-email channels (#182)

* forward origin plus basePath to backend

* Add build report link function and forward link as part of message
  • Loading branch information
zhongnansu authored Oct 15, 2021
1 parent 3340e34 commit 64c8e30
Show file tree
Hide file tree
Showing 8 changed files with 1,574 additions and 45 deletions.
23 changes: 17 additions & 6 deletions dashboards-reports/server/routes/report.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,10 @@ import { validateReport } from '../../server/utils/validationHelper';
import { AccessInfoType } from 'server';

export default function (router: IRouter, accessInfo: AccessInfoType) {
const { basePath } = accessInfo;
const {
basePath,
serverInfo: { protocol, port, hostname },
} = accessInfo;
// generate report (with provided metadata)
router.post(
{
Expand All @@ -69,8 +72,7 @@ export default function (router: IRouter, accessInfo: AccessInfoType) {

// input validation
try {
report.report_definition.report_params.core_params.origin =
request.headers.origin;
report.report_definition.report_params.core_params.origin = `${protocol}://${hostname}:${port}${basePath}`;
report = await validateReport(
context.core.opensearch.legacy.client,
report,
Expand Down Expand Up @@ -145,7 +147,10 @@ export default function (router: IRouter, accessInfo: AccessInfoType) {
}
);
// convert report to use UI model
const report = backendToUiReport(opensearchResp.reportInstance, basePath);
const report = backendToUiReport(
opensearchResp.reportInstance,
basePath
);
// generate report
const reportData = await createReport(
request,
Expand Down Expand Up @@ -211,7 +216,10 @@ export default function (router: IRouter, accessInfo: AccessInfoType) {
);
const reportId = opensearchResp.reportInstance.id;
// convert report to use UI model
const report = backendToUiReport(opensearchResp.reportInstance, basePath);
const report = backendToUiReport(
opensearchResp.reportInstance,
basePath
);
// generate report
const reportData = await createReport(
request,
Expand Down Expand Up @@ -324,7 +332,10 @@ export default function (router: IRouter, accessInfo: AccessInfoType) {
}
);

const report = backendToUiReport(opensearchResp.reportInstance, basePath);
const report = backendToUiReport(
opensearchResp.reportInstance,
basePath
);

return response.ok({
body: report,
Expand Down
8 changes: 5 additions & 3 deletions dashboards-reports/server/routes/reportDefinition.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,10 @@ import { validateReportDefinition } from '../../server/utils/validationHelper';
import { AccessInfoType } from 'server';

export default function (router: IRouter, accessInfo: AccessInfoType) {
const { basePath, serverInfo } = accessInfo;
const {
basePath,
serverInfo: { protocol, port, hostname },
} = accessInfo;
// Create report Definition
router.post(
{
Expand All @@ -65,8 +68,7 @@ export default function (router: IRouter, accessInfo: AccessInfoType) {
const logger = context.reporting_plugin.logger;
// input validation
try {
reportDefinition.report_params.core_params.origin =
request.headers.origin;
reportDefinition.report_params.core_params.origin = `${protocol}://${hostname}:${port}${basePath}`;
reportDefinition = await validateReportDefinition(
context.core.opensearch.legacy.client,
reportDefinition,
Expand Down
Loading

0 comments on commit 64c8e30

Please sign in to comment.