Problems: add ack field to table view, closes #946
This commit is contained in:
@@ -5,10 +5,12 @@ interface FAIconProps {
|
|||||||
customClass?: string;
|
customClass?: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
export default function FAIcon(props: FAIconProps) {
|
export const FAIcon: React.FC<FAIconProps> = (props: FAIconProps) => {
|
||||||
return (
|
return (
|
||||||
<span className={`fa-icon-container ${props.customClass || ''}`}>
|
<span className={`fa-icon-container ${props.customClass || ''}`}>
|
||||||
<i className={`fa fa-${props.icon}`}></i>
|
<i className={`fa fa-${props.icon}`}></i>
|
||||||
</span>
|
</span>
|
||||||
);
|
);
|
||||||
}
|
};
|
||||||
|
|
||||||
|
export default FAIcon;
|
||||||
|
|||||||
34
src/panel-triggers/components/Problems/AckCell.tsx
Normal file
34
src/panel-triggers/components/Problems/AckCell.tsx
Normal file
@@ -0,0 +1,34 @@
|
|||||||
|
import React from 'react';
|
||||||
|
import { css } from 'emotion';
|
||||||
|
import { RTCell } from '../../types';
|
||||||
|
import { ProblemDTO } from '../../../datasource-zabbix/types';
|
||||||
|
import { FAIcon } from '../FAIcon';
|
||||||
|
import { useTheme, stylesFactory } from '@grafana/ui';
|
||||||
|
import { GrafanaTheme } from '@grafana/data';
|
||||||
|
|
||||||
|
const getStyles = stylesFactory((theme: GrafanaTheme) => {
|
||||||
|
return {
|
||||||
|
countLabel: css`
|
||||||
|
font-size: ${theme.typography.size.sm};
|
||||||
|
`,
|
||||||
|
};
|
||||||
|
});
|
||||||
|
|
||||||
|
export const AckCell: React.FC<RTCell<ProblemDTO>> = (props: RTCell<ProblemDTO>) => {
|
||||||
|
const problem = props.original;
|
||||||
|
const theme = useTheme();
|
||||||
|
const styles = getStyles(theme);
|
||||||
|
|
||||||
|
return (
|
||||||
|
<div>
|
||||||
|
{problem.acknowledges?.length > 0 &&
|
||||||
|
<>
|
||||||
|
<FAIcon icon="comments" />
|
||||||
|
<span className={styles.countLabel}> ({problem.acknowledges?.length})</span>
|
||||||
|
</>
|
||||||
|
}
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
export default AckCell;
|
||||||
@@ -11,7 +11,8 @@ import { AckProblemData } from '../Modal';
|
|||||||
import GFHeartIcon from '../GFHeartIcon';
|
import GFHeartIcon from '../GFHeartIcon';
|
||||||
import { ProblemsPanelOptions, GFTimeRange, RTCell, TriggerSeverity, RTResized } from '../../types';
|
import { ProblemsPanelOptions, GFTimeRange, RTCell, TriggerSeverity, RTResized } from '../../types';
|
||||||
import { ProblemDTO, ZBXEvent, ZBXTag, ZBXAlert } from '../../../datasource-zabbix/types';
|
import { ProblemDTO, ZBXEvent, ZBXTag, ZBXAlert } from '../../../datasource-zabbix/types';
|
||||||
import FAIcon from '../FAIcon';
|
import { FAIcon } from '../FAIcon';
|
||||||
|
import { AckCell } from './AckCell';
|
||||||
|
|
||||||
export interface ProblemListProps {
|
export interface ProblemListProps {
|
||||||
problems: ProblemDTO[];
|
problems: ProblemDTO[];
|
||||||
@@ -110,6 +111,10 @@ 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: 'description', minWidth: 200, Cell: ProblemCell},
|
{ Header: 'Problem', accessor: 'description', minWidth: 200, Cell: ProblemCell},
|
||||||
|
{
|
||||||
|
Header: 'Ack', id: 'ack', show: options.ackField, width: 70,
|
||||||
|
Cell: props => <AckCell {...props} />
|
||||||
|
},
|
||||||
{
|
{
|
||||||
Header: 'Tags', accessor: 'tags', show: options.showTags, className: 'problem-tags',
|
Header: 'Tags', accessor: 'tags', show: options.showTags, className: 'problem-tags',
|
||||||
Cell: props => <TagCell {...props} onTagClick={this.handleTagClick} />
|
Cell: props => <TagCell {...props} onTagClick={this.handleTagClick} />
|
||||||
|
|||||||
@@ -50,6 +50,12 @@
|
|||||||
checked="ctrl.panel.severityField"
|
checked="ctrl.panel.severityField"
|
||||||
on-change="ctrl.render()">
|
on-change="ctrl.render()">
|
||||||
</gf-form-switch>
|
</gf-form-switch>
|
||||||
|
<gf-form-switch class="gf-form"
|
||||||
|
label-class="width-9"
|
||||||
|
label="Ack"
|
||||||
|
checked="ctrl.panel.ackField"
|
||||||
|
on-change="ctrl.render()">
|
||||||
|
</gf-form-switch>
|
||||||
<gf-form-switch class="gf-form"
|
<gf-form-switch class="gf-form"
|
||||||
label-class="width-9"
|
label-class="width-9"
|
||||||
label="Age"
|
label="Age"
|
||||||
|
|||||||
@@ -48,6 +48,7 @@ export const PANEL_DEFAULTS = {
|
|||||||
statusField: true,
|
statusField: true,
|
||||||
statusIcon: false,
|
statusIcon: false,
|
||||||
severityField: true,
|
severityField: true,
|
||||||
|
ackField: true,
|
||||||
ageField: false,
|
ageField: false,
|
||||||
descriptionField: true,
|
descriptionField: true,
|
||||||
descriptionAtNewLine: false,
|
descriptionAtNewLine: false,
|
||||||
|
|||||||
@@ -11,6 +11,7 @@ export interface ProblemsPanelOptions {
|
|||||||
statusField?: boolean;
|
statusField?: boolean;
|
||||||
statusIcon?: boolean;
|
statusIcon?: boolean;
|
||||||
severityField?: boolean;
|
severityField?: boolean;
|
||||||
|
ackField?: boolean;
|
||||||
ageField?: boolean;
|
ageField?: boolean;
|
||||||
descriptionField?: boolean;
|
descriptionField?: boolean;
|
||||||
descriptionAtNewLine?: boolean;
|
descriptionAtNewLine?: boolean;
|
||||||
|
|||||||
Reference in New Issue
Block a user