Skip to content
This repository has been archived by the owner on Aug 9, 2022. It is now read-only.

Commit

Permalink
Use kibana server hostname for puppeteer to access pages (#99)
Browse files Browse the repository at this point in the history
* use localhost for puppeteer to access page;

* clean dependencies
  • Loading branch information
zhongnansu authored Sep 29, 2020
1 parent 6bcf94c commit bcc8fab
Show file tree
Hide file tree
Showing 6 changed files with 75 additions and 309 deletions.
31 changes: 13 additions & 18 deletions kibana-reports/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,20 +27,8 @@
"@elastic/elasticsearch": "^7.8.0",
"@elastic/eui": "^26.0.0",
"@nteract/markdown": "^4.5.1",
"@testing-library/jest-dom": "^5.10.1",
"@testing-library/react": "^10.2.1",
"@types/jest": "^26.0.0",
"@types/node": "^14.0.13",
"@types/reach__router": "^1.3.5",
"@types/react": "^16.9.36",
"@types/react-dom": "^16.9.8",
"@types/react-test-renderer": "^16.9.2",
"axios": "^0.20.0",
"babel-polyfill": "^6.26.0",
"jest-cli": "^26.0.1",
"jest-dom": "^4.0.0",
"jquery": "^3.5.0",
"mocha": "^8.0.1",
"moment": "link:../../packages/moment",
"puppeteer": "^5.3.1",
"react-id-generator": "^3.0.1",
Expand All @@ -54,18 +42,25 @@
"regenerator-runtime": "^0.13.7",
"set-interval-async": "1.0.33",
"showdown": "^1.9.1",
"stream-to-blob": "^2.0.1",
"ts-jest": "^26.1.0",
"tsc": "^1.20150623.0",
"typescript": "^3.9.5",
"utf8": "^3.0.0",
"uuid": "^8.1.0",
"ws": "^7.2.3",
"xmlhttprequest": "^1.8.0",
"elastic-builder": "^2.7.1",
"json-2-csv": "^3.7.6"
},
"devDependencies": {
"ts-jest": "^26.1.0",
"tsc": "^1.20150623.0",
"typescript": "^3.9.5",
"jest-cli": "^26.0.1",
"jest-dom": "^4.0.0",
"@testing-library/jest-dom": "^5.10.1",
"@testing-library/react": "^10.2.1",
"@types/jest": "^26.0.0",
"@types/node": "^14.0.13",
"@types/reach__router": "^1.3.5",
"@types/react": "^16.9.36",
"@types/react-dom": "^16.9.8",
"@types/react-test-renderer": "^16.9.2",
"@babel/core": "^7.10.2",
"@babel/preset-env": "^7.10.2",
"@babel/preset-react": "^7.10.1",
Expand Down
2 changes: 2 additions & 0 deletions kibana-reports/server/routes/utils/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -66,3 +66,5 @@ export enum TRIGGER_TYPE {
}
// https://www.elastic.co/guide/en/elasticsearch/reference/6.8/search-request-from-size.html
export const DEFAULT_MAX_SIZE = 10000;

export const LOCAL_HOST = 'http://localhost:5601';
7 changes: 3 additions & 4 deletions kibana-reports/server/routes/utils/dataReportHelpers.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import { async } from 'rxjs/internal/scheduler/async';
/*
* Copyright 2020 Amazon.com, Inc. or its affiliates. All Rights Reserved.
*
Expand All @@ -16,9 +15,9 @@ import { async } from 'rxjs/internal/scheduler/async';

import { DATA_REPORT_CONFIG } from './constants';

const esb = require('elastic-builder');
const moment = require('moment');
const converter = require('json-2-csv');
import esb from 'elastic-builder';
import moment from 'moment';
import converter from 'json-2-csv';

export var metaData = {
saved_search_id: <string>null,
Expand Down
4 changes: 3 additions & 1 deletion kibana-reports/server/routes/utils/reportHelper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import {
REPORT_TYPE,
REPORT_STATE,
CONFIG_INDEX_NAME,
LOCAL_HOST,
} from './constants';
import { RequestParams } from '@elastic/elasticsearch';
import { getFileName, callCluster } from './helpers';
Expand Down Expand Up @@ -154,7 +155,8 @@ export const createReport = async (
reportSource === REPORT_TYPE.dashboard ||
reportSource === REPORT_TYPE.visualization
) {
const queryUrl = report.query_url;
const { origin } = new URL(report.query_url);
const queryUrl = report.query_url.replace(origin, LOCAL_HOST);
createReportResult = await createVisualReport(reportParams, queryUrl);
}
} catch (error) {
Expand Down
1 change: 0 additions & 1 deletion kibana-reports/test/setUpTests.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,3 @@

require('babel-polyfill');
require('core-js/stable');
require('axios/lib/adapters/http');
Loading

0 comments on commit bcc8fab

Please sign in to comment.