-
Notifications
You must be signed in to change notification settings - Fork 8.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Reporting] Clean up types for internal APIs needed for UI (#105508)
* [Reporting] Refactor types for API response data * fix api test * Update x-pack/plugins/reporting/common/types.ts Co-authored-by: Jean-Louis Leysens <jloleysens@gmail.com> * more verbose comments * set comments in interface type definition * Update x-pack/plugins/reporting/common/types.ts Co-authored-by: Michael Dokolin <dokmic@gmail.com> * more strict * Update x-pack/plugins/reporting/public/management/report_info_button.tsx Co-authored-by: Michael Dokolin <dokmic@gmail.com> * Update x-pack/plugins/reporting/public/management/report_info_button.tsx Co-authored-by: Michael Dokolin <dokmic@gmail.com> * fix suggestion * fix accidental declaration of interface methods as function properties * fix info panel Co-authored-by: Jean-Louis Leysens <jloleysens@gmail.com> Co-authored-by: Michael Dokolin <dokmic@gmail.com>
- Loading branch information
1 parent
5f5f097
commit 35fc0bf
Showing
26 changed files
with
3,641 additions
and
1,414 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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,75 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License | ||
* 2.0; you may not use this file except in compliance with the Elastic License | ||
* 2.0. | ||
*/ | ||
|
||
import { JobId, ReportApiJSON, ReportSource, TaskRunResult } from '../../common/types'; | ||
|
||
type ReportPayload = ReportSource['payload']; | ||
|
||
/* | ||
* This class represents a report job for the UI | ||
* It can be instantiated with ReportApiJSON: the response data format for the report job APIs | ||
*/ | ||
export class Job { | ||
public id: JobId; | ||
public index: string; | ||
|
||
public objectType: ReportPayload['objectType']; | ||
public title: ReportPayload['title']; | ||
public isDeprecated: ReportPayload['isDeprecated']; | ||
public browserTimezone?: ReportPayload['browserTimezone']; | ||
public layout: ReportPayload['layout']; | ||
|
||
public jobtype: ReportSource['jobtype']; | ||
public created_by: ReportSource['created_by']; | ||
public created_at: ReportSource['created_at']; | ||
public started_at: ReportSource['started_at']; | ||
public completed_at: ReportSource['completed_at']; | ||
public status: ReportSource['status']; | ||
public attempts: ReportSource['attempts']; | ||
public max_attempts: ReportSource['max_attempts']; | ||
|
||
public timeout: ReportSource['timeout']; | ||
public kibana_name: ReportSource['kibana_name']; | ||
public kibana_id: ReportSource['kibana_id']; | ||
public browser_type: ReportSource['browser_type']; | ||
|
||
public size?: TaskRunResult['size']; | ||
public content_type?: TaskRunResult['content_type']; | ||
public csv_contains_formulas?: TaskRunResult['csv_contains_formulas']; | ||
public max_size_reached?: TaskRunResult['max_size_reached']; | ||
public warnings?: TaskRunResult['warnings']; | ||
|
||
constructor(report: ReportApiJSON) { | ||
this.id = report.id; | ||
this.index = report.index; | ||
|
||
this.jobtype = report.jobtype; | ||
this.objectType = report.payload.objectType; | ||
this.title = report.payload.title; | ||
this.layout = report.payload.layout; | ||
this.created_by = report.created_by; | ||
this.created_at = report.created_at; | ||
this.started_at = report.started_at; | ||
this.completed_at = report.completed_at; | ||
this.status = report.status; | ||
this.attempts = report.attempts; | ||
this.max_attempts = report.max_attempts; | ||
|
||
this.timeout = report.timeout; | ||
this.kibana_name = report.kibana_name; | ||
this.kibana_id = report.kibana_id; | ||
this.browser_type = report.browser_type; | ||
this.browserTimezone = report.payload.browserTimezone; | ||
this.size = report.output?.size; | ||
this.content_type = report.output?.content_type; | ||
|
||
this.isDeprecated = report.payload.isDeprecated || false; | ||
this.csv_contains_formulas = report.output?.csv_contains_formulas; | ||
this.max_size_reached = report.output?.max_size_reached; | ||
this.warnings = report.output?.warnings; | ||
} | ||
} |
Oops, something went wrong.