Problems: Add operational data field, closes #1260

This commit is contained in:
Alexander Zobnin
2023-01-20 16:51:54 +01:00
parent bc62e35477
commit 41d292c51d
5 changed files with 20 additions and 0 deletions

View File

@@ -26,6 +26,7 @@ export function joinTriggersWithProblems(problems: ZBXProblem[], triggers: ZBXTr
description: p.name || t.description, description: p.name || t.description,
comments: t.comments, comments: t.comments,
value: t.value, value: t.value,
opdata: p.opdata,
groups: t.groups, groups: t.groups,
hosts: t.hosts, hosts: t.hosts,
items: t.items, items: t.items,

View File

@@ -235,6 +235,7 @@ export interface ProblemDTO {
proxy?: string; proxy?: string;
severity?: string; severity?: string;
priority?: string; priority?: string;
opdata?: string;
acknowledged?: '1' | '0'; acknowledged?: '1' | '0';
acknowledges?: ZBXAcknowledge[]; acknowledges?: ZBXAcknowledge[];

View File

@@ -174,6 +174,7 @@ export default class ProblemList extends PureComponent<ProblemListProps, Problem
}, },
{ Header: 'Status', accessor: 'value', show: options.statusField, width: 100, Cell: statusCell }, { Header: 'Status', accessor: 'value', show: options.statusField, width: 100, Cell: statusCell },
{ Header: 'Problem', accessor: 'name', minWidth: 200, Cell: ProblemCell }, { Header: 'Problem', accessor: 'name', minWidth: 200, Cell: ProblemCell },
{ Header: 'Operational data', accessor: 'opdata', show: options.opdataField, width: 150, Cell: OpdataCell },
{ {
Header: 'Ack', Header: 'Ack',
id: 'ack', id: 'ack',
@@ -362,6 +363,15 @@ function ProblemCell(props: RTCell<ProblemDTO>) {
); );
} }
function OpdataCell(props: RTCell<ProblemDTO>) {
const problem = props.original;
return (
<div>
<span>{problem.opdata}</span>
</div>
);
}
function AgeCell(props: RTCell<ProblemDTO>) { function AgeCell(props: RTCell<ProblemDTO>) {
const problem = props.original; const problem = props.original;
const timestamp = moment.unix(problem.timestamp); const timestamp = moment.unix(problem.timestamp);

View File

@@ -195,6 +195,12 @@ export const plugin = new PanelPlugin<ProblemsPanelOptions, {}>(ProblemsPanel)
defaultValue: defaultPanelOptions.ageField, defaultValue: defaultPanelOptions.ageField,
category: ['Fields'], category: ['Fields'],
}) })
.addBooleanSwitch({
path: 'opdataField',
name: 'Operational data',
defaultValue: defaultPanelOptions.opdataField,
category: ['Fields'],
})
.addBooleanSwitch({ .addBooleanSwitch({
path: 'descriptionField', path: 'descriptionField',
name: 'Description', name: 'Description',

View File

@@ -16,6 +16,7 @@ export interface ProblemsPanelOptions {
severityField?: boolean; severityField?: boolean;
ackField?: boolean; ackField?: boolean;
ageField?: boolean; ageField?: boolean;
opdataField?: boolean;
descriptionField?: boolean; descriptionField?: boolean;
descriptionAtNewLine?: boolean; descriptionAtNewLine?: boolean;
// Options // Options
@@ -66,6 +67,7 @@ export const defaultPanelOptions: Partial<ProblemsPanelOptions> = {
severityField: true, severityField: true,
ackField: true, ackField: true,
ageField: false, ageField: false,
opdataField: false,
descriptionField: true, descriptionField: true,
descriptionAtNewLine: false, descriptionAtNewLine: false,
// Options // Options