Skip to content
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

[Reporting] Wholesale moves client to newest-platform #58945

Merged
merged 38 commits into from
Mar 17, 2020
Merged
Show file tree
Hide file tree
Changes from 7 commits
Commits
Show all changes
38 commits
Select commit Hold shift + click to select a range
ea2d736
Move over to new plugin space, working implementation
Feb 27, 2020
83b2b96
Fixing tests for report_listing snapshots
Feb 27, 2020
5fd3a22
WIP: Fixing react-component tests
Feb 28, 2020
af0f877
Merge remote-tracking branch 'upstream/master' into reporting/client-…
Feb 28, 2020
fe429b9
Merge remote-tracking branch 'upstream/master' into reporting/client-…
Feb 28, 2020
c02b023
Fixing report_info_button tests
Feb 28, 2020
ede19d4
Fixing download linksies
Feb 28, 2020
1a9d6b1
Merge remote-tracking branch 'upstream/master' into reporting/client-…
Mar 2, 2020
e1f4a31
WIP: Final working implementation
Mar 4, 2020
0799652
Merge remote-tracking branch 'upstream/master' into reporting/client-…
Mar 4, 2020
bae7445
Merge remote-tracking branch 'upstream/master' into reporting/client-…
Mar 6, 2020
6322228
Fixing attachAction API + API URLs
Mar 6, 2020
ca80be2
Let the past die. Kill it if you have to. That’s the only way to beco…
Mar 6, 2020
e4d4be7
Merge remote-tracking branch 'upstream/master' into reporting/client-…
Mar 9, 2020
ed82044
Fixing stream-client for new platform APIs
Mar 9, 2020
de45fd9
Fixing types and tests
Mar 9, 2020
257d9c6
Fix broken mock
Mar 9, 2020
9c96e79
Merge remote-tracking branch 'upstream/master' into reporting/client-…
Mar 10, 2020
7dee2d0
Adds back in warnings to report info button
Mar 10, 2020
a03734e
kibana.json line-breaks on required plugins
Mar 10, 2020
1f07d5b
Fixing broked snapshots
Mar 10, 2020
1ef2a1f
Merge remote-tracking branch 'upstream/master' into reporting/client-…
Mar 10, 2020
d0f6c76
Merge remote-tracking branch 'upstream/master' into reporting/client-…
Mar 11, 2020
15a2fbf
Fix license checks in client-side components
Mar 12, 2020
ff293ad
Merge remote-tracking branch 'upstream/master' into reporting/client-…
Mar 12, 2020
3008ad7
Adding back in warnings to report_listing component
Mar 13, 2020
5f2bb0c
Fix danglig unused import
Mar 13, 2020
5d0f89e
Merge remote-tracking branch 'upstream/master' into reporting/client-…
Mar 13, 2020
d3d668c
Adds license checks for basic to our csv panel action
Mar 13, 2020
61e86ab
Merge remote-tracking branch 'upstream/master' into reporting/client-…
Mar 13, 2020
a10e111
Fixes issues from prior fork
Mar 13, 2020
f20576f
Merge remote-tracking branch 'upstream/master' into reporting/client-…
Mar 13, 2020
ce27fa1
Move relative pathing to absolute
Mar 13, 2020
6ad3dac
Merge remote-tracking branch 'upstream/master' into reporting/client-…
Mar 16, 2020
210d627
Fix POST URL copying as we've moved from static methods
Mar 16, 2020
b002fd5
Fix layoutId props
Mar 16, 2020
9c2ecb7
Fixes types for layoutId
Mar 16, 2020
a603278
Merge branch 'master' into reporting/client-np-migration
elasticmachine Mar 17, 2020
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 0 additions & 2 deletions x-pack/legacy/plugins/reporting/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,6 @@ export const reporting = (kibana: any) => {
'plugins/reporting/share_context_menu/register_reporting',
],
embeddableActions: ['plugins/reporting/panel_actions/get_csv_panel_action'],
home: ['plugins/reporting/register_feature'],
managementSections: ['plugins/reporting/views/management'],
tsullivan marked this conversation as resolved.
Show resolved Hide resolved
injectDefaultVars(server: Legacy.Server, options?: ReportingConfigOptions) {
const config = server.config();
return {
Expand Down
96 changes: 96 additions & 0 deletions x-pack/plugins/reporting/common/poller.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,96 @@
/*
* 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 _ from 'lodash';
import { PollerOptions } from '..';

// @TODO Maybe move to observables someday
export class Poller {
private readonly functionToPoll: () => Promise<any>;
private readonly successFunction: (...args: any) => any;
private readonly errorFunction: (error: Error) => any;
private _isRunning: boolean;
private _timeoutId: NodeJS.Timeout | null;
private pollFrequencyInMillis: number;
private trailing: boolean;
private continuePollingOnError: boolean;
private pollFrequencyErrorMultiplier: number;

constructor(options: PollerOptions) {
this.functionToPoll = options.functionToPoll; // Must return a Promise
this.successFunction = options.successFunction || _.noop;
this.errorFunction = options.errorFunction || _.noop;
this.pollFrequencyInMillis = options.pollFrequencyInMillis;
this.trailing = options.trailing || false;
this.continuePollingOnError = options.continuePollingOnError || false;
this.pollFrequencyErrorMultiplier = options.pollFrequencyErrorMultiplier || 1;

this._timeoutId = null;
this._isRunning = false;
}

getPollFrequency() {
return this.pollFrequencyInMillis;
}

_poll() {
return this.functionToPoll()
.then(this.successFunction)
.then(() => {
if (!this._isRunning) {
return;
}

this._timeoutId = setTimeout(this._poll.bind(this), this.pollFrequencyInMillis);
})
.catch(e => {
this.errorFunction(e);
if (!this._isRunning) {
return;
}

if (this.continuePollingOnError) {
this._timeoutId = setTimeout(
this._poll.bind(this),
this.pollFrequencyInMillis * this.pollFrequencyErrorMultiplier
);
} else {
this.stop();
}
});
}

start() {
if (this._isRunning) {
return;
}

this._isRunning = true;
if (this.trailing) {
this._timeoutId = setTimeout(this._poll.bind(this), this.pollFrequencyInMillis);
} else {
this._poll();
}
}

stop() {
if (!this._isRunning) {
return;
}

this._isRunning = false;

if (this._timeoutId) {
clearTimeout(this._timeoutId);
}

this._timeoutId = null;
}

isRunning() {
return this._isRunning;
}
}
15 changes: 15 additions & 0 deletions x-pack/plugins/reporting/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,21 @@ export const JOB_COMPLETION_NOTIFICATIONS_POLLER_CONFIG = {

export const API_BASE_URL = '/api/reporting/jobs';
export const REPORTING_MANAGEMENT_HOME = '/app/kibana#/management/kibana/reporting';
export const API_LIST_URL = '/api/reporting/jobs';

export const JOB_STATUS_FAILED = 'failed';
export const JOB_STATUS_COMPLETED = 'completed';

export enum JobStatuses {
PENDING = 'pending',
PROCESSING = 'processing',
COMPLETED = 'completed',
FAILED = 'failed',
CANCELLED = 'cancelled',
}

export const PDF_JOB_TYPE = 'printable_pdf';
export const PNG_JOB_TYPE = 'PNG';
export const CSV_JOB_TYPE = 'csv';
export const CSV_FROM_SAVEDOBJECT_JOB_TYPE = 'csv_from_savedobject';
export const USES_HEADLESS_JOB_TYPES = [PDF_JOB_TYPE, PNG_JOB_TYPE];
12 changes: 12 additions & 0 deletions x-pack/plugins/reporting/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ import {
NotificationsStart,
} from '../../../src/core/public';

export { ToastsSetup, HttpSetup, ApplicationStart } from 'src/core/public';
tsullivan marked this conversation as resolved.
Show resolved Hide resolved

export type JobId = string;
export type JobStatus = 'completed' | 'pending' | 'processing' | 'failed';

Expand Down Expand Up @@ -57,3 +59,13 @@ export type DownloadReportFn = (jobId: JobId) => DownloadLink;

type ManagementLink = string;
export type ManagementLinkFn = () => ManagementLink;

export interface PollerOptions {
functionToPoll: () => Promise<any>;
pollFrequencyInMillis: number;
trailing?: boolean;
continuePollingOnError?: boolean;
pollFrequencyErrorMultiplier?: number;
successFunction?: (...args: any) => any;
errorFunction?: (error: Error) => any;
}
2 changes: 1 addition & 1 deletion x-pack/plugins/reporting/kibana.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"id": "reporting",
"version": "8.0.0",
"kibanaVersion": "kibana",
"requiredPlugins": [],
"requiredPlugins": ["home", "management", "licensing"],
"server": false,
"ui": true
}
Loading