-
Notifications
You must be signed in to change notification settings - Fork 8.5k
TypeScript Reporting Layouts #22454
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
stacey-gammon
merged 13 commits into
elastic:master
from
bgaddis56:typescript-reporting-layouts
Sep 4, 2018
Merged
TypeScript Reporting Layouts #22454
Changes from all commits
Commits
Show all changes
13 commits
Select commit
Hold shift + click to select a range
6e7c5fb
wip
bgaddis56 f2108a3
Changed any ypes to actual types
bgaddis56 704d79f
Changes recommended from code review
bgaddis56 b9e7482
Merge branch 'master' of https://github.com/elastic/kibana into types…
bgaddis56 6d805c5
Latest Code Review Changes
bgaddis56 9e83af3
Name Changes and spacing
bgaddis56 8979f2e
Name Change
bgaddis56 4d0d3d0
Changes for typescript import and direct reference to layout_factory
bgaddis56 af4257a
Merge branch 'master' of https://github.com/elastic/kibana into types…
bgaddis56 4464fb2
Move types locally
bgaddis56 ca4b974
Evaluate function changes for puppeteer
bgaddis56 a285cbf
Removed String as a type and renamed index.d.ts to types.d.ts for con…
bgaddis56 ced32f9
Changed layout_factoy to create_layout
bgaddis56 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -7,4 +7,4 @@ | |
| export const LayoutTypes = { | ||
| PRESERVE_LAYOUT: 'preserve_layout', | ||
| PRINT: 'print', | ||
| }; | ||
| }; | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
24 changes: 24 additions & 0 deletions
24
x-pack/plugins/reporting/export_types/printable_pdf/server/lib/layouts/create_layout.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,24 @@ | ||
| /* | ||
| * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
| * or more contributor license agreements. Licensed under the Elastic License; | ||
| * you may not use this file except in compliance with the Elastic License. | ||
| */ | ||
| import { KbnServer, Size } from '../../../../../types'; | ||
| import { LayoutTypes } from '../../../common/constants'; | ||
| import { Layout } from './layout'; | ||
| import { PreserveLayout } from './preserve_layout'; | ||
| import { PrintLayout } from './print_layout'; | ||
|
|
||
| interface LayoutParams { | ||
| id: string; | ||
| dimensions: Size; | ||
| } | ||
|
|
||
| export function createLayout(server: KbnServer, layoutParams: LayoutParams): Layout { | ||
| if (layoutParams && layoutParams.id === LayoutTypes.PRESERVE_LAYOUT) { | ||
| return new PreserveLayout(layoutParams.id, layoutParams.dimensions); | ||
| } | ||
|
|
||
| // this is the default because some jobs won't have anything specified | ||
| return new PrintLayout(server, layoutParams.id); | ||
| } |
20 changes: 0 additions & 20 deletions
20
x-pack/plugins/reporting/export_types/printable_pdf/server/lib/layouts/index.js
This file was deleted.
Oops, something went wrong.
9 changes: 9 additions & 0 deletions
9
x-pack/plugins/reporting/export_types/printable_pdf/server/lib/layouts/index.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,9 @@ | ||
| /* | ||
| * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
| * or more contributor license agreements. Licensed under the Elastic License; | ||
| * you may not use this file except in compliance with the Elastic License. | ||
| */ | ||
|
|
||
| export { createLayout } from './create_layout'; | ||
| export { PrintLayout } from './print_layout'; | ||
| export { PreserveLayout } from './preserve_layout'; |
43 changes: 43 additions & 0 deletions
43
x-pack/plugins/reporting/export_types/printable_pdf/server/lib/layouts/layout.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,43 @@ | ||
| /* | ||
| * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
| * or more contributor license agreements. Licensed under the Elastic License; | ||
| * you may not use this file except in compliance with the Elastic License. | ||
| */ | ||
| import { Size } from '../../../../../types'; | ||
| import { ViewZoomWidthHeight } from './types'; | ||
|
|
||
| export interface PageSizeParams { | ||
| pageMarginTop: number; | ||
| pageMarginBottom: number; | ||
| pageMarginWidth: number; | ||
| tableBorderWidth: number; | ||
| headingHeight: number; | ||
| subheadingHeight: number; | ||
| } | ||
|
|
||
| export interface PdfImageSize { | ||
| width: number; | ||
| height?: number; | ||
| } | ||
|
|
||
| export abstract class Layout { | ||
| public id: string = ''; | ||
|
|
||
| constructor(id: string) { | ||
| this.id = id; | ||
| } | ||
|
|
||
| public abstract getPdfImageSize(): PdfImageSize; | ||
|
|
||
| public abstract getPdfPageOrientation(): string | undefined; | ||
|
|
||
| public abstract getPdfPageSize(pageSizeParams: PageSizeParams): string | Size; | ||
|
|
||
| public abstract getViewport(itemsCount: number): ViewZoomWidthHeight; | ||
|
|
||
| public abstract getBrowserZoom(): number; | ||
|
|
||
| public abstract getBrowserViewport(): Size; | ||
|
|
||
| public abstract getCssOverridesPath(): string; | ||
| } |
69 changes: 0 additions & 69 deletions
69
x-pack/plugins/reporting/export_types/printable_pdf/server/lib/layouts/preserve_layout.js
This file was deleted.
Oops, something went wrong.
81 changes: 81 additions & 0 deletions
81
x-pack/plugins/reporting/export_types/printable_pdf/server/lib/layouts/preserve_layout.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,81 @@ | ||
| /* | ||
| * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
| * or more contributor license agreements. Licensed under the Elastic License; | ||
| * you may not use this file except in compliance with the Elastic License. | ||
| */ | ||
| import path from 'path'; | ||
| import { Size } from '../../../../../types'; | ||
| import { Layout, PageSizeParams } from './layout'; | ||
|
|
||
| const ZOOM: number = 2; | ||
|
|
||
| export class PreserveLayout extends Layout { | ||
| public readonly selectors = { | ||
| screenshot: '[data-shared-items-container]', | ||
| renderComplete: '[data-shared-item]', | ||
| itemsCountAttribute: 'data-shared-items-count', | ||
| timefilterFromAttribute: 'data-shared-timefilter-from', | ||
| timefilterToAttribute: 'data-shared-timefilter-to', | ||
| }; | ||
|
|
||
| public readonly groupCount = 1; | ||
| private readonly height: number; | ||
| private readonly width: number; | ||
| private readonly scaledHeight: number; | ||
| private readonly scaledWidth: number; | ||
|
|
||
| constructor(id: string, size: Size) { | ||
| super(id); | ||
| this.height = size.height; | ||
| this.width = size.width; | ||
| this.scaledHeight = size.height * ZOOM; | ||
| this.scaledWidth = size.width * ZOOM; | ||
| } | ||
|
|
||
| public getCssOverridesPath() { | ||
| return path.join(__dirname, 'preserve_layout.css'); | ||
| } | ||
|
|
||
| public getBrowserViewport() { | ||
| return { | ||
| height: this.scaledHeight, | ||
| width: this.scaledWidth, | ||
| }; | ||
| } | ||
|
|
||
| public getBrowserZoom() { | ||
| return ZOOM; | ||
| } | ||
|
|
||
| public getViewport() { | ||
| return { | ||
| height: this.scaledHeight, | ||
| width: this.scaledWidth, | ||
| zoom: ZOOM, | ||
| }; | ||
| } | ||
|
|
||
| public getPdfImageSize() { | ||
| return { | ||
| height: this.height, | ||
| width: this.width, | ||
| }; | ||
| } | ||
|
|
||
| public getPdfPageOrientation() { | ||
| return undefined; | ||
| } | ||
|
|
||
| public getPdfPageSize(pageSizeParams: PageSizeParams) { | ||
| return { | ||
| height: | ||
| this.height + | ||
| pageSizeParams.pageMarginTop + | ||
| pageSizeParams.pageMarginBottom + | ||
| pageSizeParams.tableBorderWidth * 2 + | ||
| pageSizeParams.headingHeight + | ||
| pageSizeParams.subheadingHeight, | ||
| width: this.width + pageSizeParams.pageMarginWidth * 2 + pageSizeParams.tableBorderWidth * 2, | ||
| }; | ||
| } | ||
| } | ||
89 changes: 0 additions & 89 deletions
89
x-pack/plugins/reporting/export_types/printable_pdf/server/lib/layouts/print.js
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Zoom used to be a param that could be passed in from a caller, but 2 was the default. This makes it completely hardcoded.
Also, you've removed the explanatory comments: https://github.com/elastic/kibana/blob/master/x-pack/plugins/reporting/export_types/printable_pdf/server/lib/layouts/preserve_layout.js#L9-L12
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Intentional. This setting was never exposed to the user as configurable - #20091
I don't think we ever will expose it. The only reason we use it is to make sure the resolution is a little bigger on the screenshots.
From Brandon in that above issue: