Adding in browser info to the report-info drawer (#26307)

* Adding in browser info to the report-info drawer

* Conditionalizes the browser-type panel prints + constantizes jobTypes

* Fixing config feedback lost in force push
This commit is contained in:
Joel Griffith 2018-12-04 12:08:24 -08:00 committed by GitHub
parent 74e21c1983
commit 53f7ed88af
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
10 changed files with 40 additions and 7 deletions

View file

@ -37,3 +37,8 @@ export const UI_SETTINGS_CUSTOM_PDF_LOGO = 'xpackReporting:customPdfLogo';
* @type {string}
*/
export const KIBANA_REPORTING_TYPE = 'reporting';
export const PDF_JOB_TYPE = 'printable_pdf';
export const PNG_JOB_TYPE = 'PNG';
export const CSV_JOB_TYPE = 'csv';
export const USES_HEADLESS_JOB_TYPES = [PDF_JOB_TYPE, PNG_JOB_TYPE];

View file

@ -7,11 +7,12 @@
import { createJobFactory } from './create_job';
import { executeJobFactory } from './execute_job';
import { metadata } from '../metadata';
import { CSV_JOB_TYPE as jobType } from '../../../common/constants';
export function register(registry) {
registry.register({
...metadata,
jobType: 'csv',
jobType,
jobContentExtension: 'csv',
createJobFactory,
executeJobFactory,

View file

@ -7,11 +7,12 @@
import { createJobFactory } from './create_job';
import { executeJobFactory } from './execute_job';
import { metadata } from '../metadata';
import { PNG_JOB_TYPE as jobType } from '../../../common/constants';
export function register(registry) {
registry.register({
...metadata,
jobType: 'PNG',
jobType,
jobContentEncoding: 'base64',
jobContentExtension: 'PNG',
createJobFactory,

View file

@ -7,11 +7,12 @@
import { createJobFactory } from './create_job';
import { executeJobFactory } from './execute_job';
import { metadata } from '../metadata';
import { PDF_JOB_TYPE as jobType } from '../../../common/constants';
export function register(registry) {
registry.register({
...metadata,
jobType: 'printable_pdf',
jobType,
jobContentEncoding: 'base64',
jobContentExtension: 'pdf',
createJobFactory,

View file

@ -17,6 +17,7 @@ import {
} from '@elastic/eui';
import { get } from 'lodash';
import React, { Component, Fragment } from 'react';
import { USES_HEADLESS_JOB_TYPES } from '../../common/constants';
import { JobInfo, jobQueueClient } from '../lib/job_queue_client';
interface Props {
@ -32,6 +33,7 @@ interface State {
}
const NA = 'n/a';
const UNKNOWN = 'unknown';
const getDimensions = (info: JobInfo) => {
const defaultDimensions = { width: null, height: null };
@ -73,7 +75,8 @@ export class ReportInfoButton extends Component<Props, State> {
return null;
}
// TODO browser type
const jobType = get(info, 'jobtype', NA);
// TODO queue method (clicked UI, watcher, etc)
const jobInfoParts = {
datetimes: [
@ -117,7 +120,7 @@ export class ReportInfoButton extends Component<Props, State> {
},
{
title: 'Job Type',
description: get(info, 'jobtype', NA),
description: jobType,
},
{
title: 'Content Type',
@ -145,6 +148,12 @@ export class ReportInfoButton extends Component<Props, State> {
title: 'Status',
description: get(info, 'status', NA),
},
{
title: 'Browser Type',
description: USES_HEADLESS_JOB_TYPES.includes(jobType)
? get(info, 'browser_type', UNKNOWN)
: NA,
},
],
};

View file

@ -21,6 +21,7 @@ export interface JobContent {
}
export interface JobInfo {
browser_type: string;
created_at: string;
priority: number;
jobtype: string;

View file

@ -10,7 +10,9 @@ import { oncePerServer } from './once_per_server';
function enqueueJobFn(server) {
const jobQueue = server.plugins.reporting.queue;
const queueConfig = server.config().get('xpack.reporting.queue');
const config = server.config();
const queueConfig = config.get('xpack.reporting.queue');
const browserType = config.get('xpack.reporting.capture.browser.type');
const exportTypesRegistry = server.plugins.reporting.exportTypesRegistry;
return async function enqueueJob(exportTypeId, jobParams, user, headers, request) {
@ -21,6 +23,7 @@ function enqueueJobFn(server) {
const options = {
timeout: queueConfig.timeout,
created_by: get(user, 'username', false),
browser_type: browserType,
};
return new Promise((resolve, reject) => {

View file

@ -252,6 +252,14 @@ describe('Job Class', function () {
expect(indexArgs.body).to.have.property('priority', defaultPriority);
});
});
it('should set a browser type', function () {
const job = new Job(mockQueue, index, type, payload);
return job.ready.then(() => {
const indexArgs = validateDoc(client.index);
expect(indexArgs.body).to.have.property('browser_type');
});
});
});
describe('option passing', function () {

View file

@ -41,6 +41,7 @@ const schema = {
},
}
},
browser_type: { type: 'keyword' },
jobtype: { type: 'keyword' },
payload: { type: 'object', enabled: false },
priority: { type: 'byte' },

View file

@ -31,6 +31,7 @@ export class Job extends events.EventEmitter {
this.priority = Math.max(Math.min(options.priority || 10, 20), -20);
this.doctype = options.doctype || constants.DEFAULT_SETTING_DOCTYPE;
this.indexSettings = options.indexSettings || {};
this.browser_type = options.browser_type;
this.debug = (msg, err) => {
const logger = options.logger || function () {};
@ -66,6 +67,7 @@ export class Job extends events.EventEmitter {
attempts: 0,
max_attempts: this.maxAttempts,
status: constants.JOB_STATUS_PENDING,
browser_type: this.browser_type,
}
};
@ -131,7 +133,8 @@ export class Job extends events.EventEmitter {
payload: this.payload,
timeout: this.timeout,
max_attempts: this.maxAttempts,
priority: this.priority
priority: this.priority,
browser_type: this.browser_type,
};
}
}