Feat: add option to show data source name (#2007)
Original [PR](https://github.com/grafana/grafana-zabbix/pull/2003) Fixes #1766 --------- Co-authored-by: olaf <olaf@initworks.com>
This commit is contained in:
5
.changeset/happy-trainers-sniff.md
Normal file
5
.changeset/happy-trainers-sniff.md
Normal file
@@ -0,0 +1,5 @@
|
|||||||
|
---
|
||||||
|
'grafana-zabbix': minor
|
||||||
|
---
|
||||||
|
|
||||||
|
Problems Panel: Add option to show data source name
|
||||||
@@ -37,6 +37,7 @@
|
|||||||
"uid": "PCAF1C06DCF802728"
|
"uid": "PCAF1C06DCF802728"
|
||||||
},
|
},
|
||||||
"descriptionAtNewLine": false,
|
"descriptionAtNewLine": false,
|
||||||
|
"showDatasourceName": false,
|
||||||
"descriptionField": true,
|
"descriptionField": true,
|
||||||
"fontSize": "100%",
|
"fontSize": "100%",
|
||||||
"gridPos": {
|
"gridPos": {
|
||||||
@@ -64,6 +65,7 @@
|
|||||||
"allowDangerousHTML": false,
|
"allowDangerousHTML": false,
|
||||||
"customLastChangeFormat": false,
|
"customLastChangeFormat": false,
|
||||||
"descriptionAtNewLine": false,
|
"descriptionAtNewLine": false,
|
||||||
|
"showDatasourceName": false,
|
||||||
"descriptionField": true,
|
"descriptionField": true,
|
||||||
"fontSize": "100%",
|
"fontSize": "100%",
|
||||||
"highlightBackground": false,
|
"highlightBackground": false,
|
||||||
|
|||||||
@@ -36,7 +36,6 @@ export default class AlertCard extends PureComponent<AlertCardProps> {
|
|||||||
|
|
||||||
render() {
|
render() {
|
||||||
const { problem, panelOptions } = this.props;
|
const { problem, panelOptions } = this.props;
|
||||||
const showDatasourceName = panelOptions.targets && panelOptions.targets.length > 1;
|
|
||||||
const cardClass = cx('alert-rule-item', 'zbx-trigger-card', {
|
const cardClass = cx('alert-rule-item', 'zbx-trigger-card', {
|
||||||
'zbx-trigger-highlighted': panelOptions.highlightBackground,
|
'zbx-trigger-highlighted': panelOptions.highlightBackground,
|
||||||
});
|
});
|
||||||
@@ -153,7 +152,7 @@ export default class AlertCard extends PureComponent<AlertCardProps> {
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
{showDatasourceName && (
|
{panelOptions.showDatasourceName && (
|
||||||
<div className="alert-rule-item__time zabbix-trigger-source">
|
<div className="alert-rule-item__time zabbix-trigger-source">
|
||||||
<span>
|
<span>
|
||||||
<i className="fa fa-database"></i>
|
<i className="fa fa-database"></i>
|
||||||
|
|||||||
@@ -205,6 +205,7 @@ export const problemsPanelMigrationHandler = (panel: PanelModel<Partial<Problems
|
|||||||
ageField: panel.ageField,
|
ageField: panel.ageField,
|
||||||
descriptionField: panel.descriptionField,
|
descriptionField: panel.descriptionField,
|
||||||
descriptionAtNewLine: panel.descriptionAtNewLine,
|
descriptionAtNewLine: panel.descriptionAtNewLine,
|
||||||
|
showDatasourceName: panel.showDatasourceName,
|
||||||
hostsInMaintenance: panel.hostsInMaintenance,
|
hostsInMaintenance: panel.hostsInMaintenance,
|
||||||
showTriggers: panel.showTriggers,
|
showTriggers: panel.showTriggers,
|
||||||
sortProblems: panel.sortProblems,
|
sortProblems: panel.sortProblems,
|
||||||
|
|||||||
@@ -214,6 +214,12 @@ export const plugin = new PanelPlugin<ProblemsPanelOptions, {}>(ProblemsPanel)
|
|||||||
defaultValue: defaultPanelOptions.descriptionAtNewLine,
|
defaultValue: defaultPanelOptions.descriptionAtNewLine,
|
||||||
showIf: (options) => options.layout === 'list',
|
showIf: (options) => options.layout === 'list',
|
||||||
category: ['Fields'],
|
category: ['Fields'],
|
||||||
|
})
|
||||||
|
.addBooleanSwitch({
|
||||||
|
path: 'showDatasourceName',
|
||||||
|
name: 'Datasource name',
|
||||||
|
defaultValue: defaultPanelOptions.showDatasourceName,
|
||||||
|
category: ['Fields'],
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
@@ -19,6 +19,7 @@ export interface ProblemsPanelOptions {
|
|||||||
opdataField?: boolean;
|
opdataField?: boolean;
|
||||||
descriptionField?: boolean;
|
descriptionField?: boolean;
|
||||||
descriptionAtNewLine?: boolean;
|
descriptionAtNewLine?: boolean;
|
||||||
|
showDatasourceName?: boolean;
|
||||||
// Options
|
// Options
|
||||||
hostsInMaintenance?: boolean;
|
hostsInMaintenance?: boolean;
|
||||||
showTriggers?: 'all triggers' | 'unacknowledged' | 'acknowledged';
|
showTriggers?: 'all triggers' | 'unacknowledged' | 'acknowledged';
|
||||||
@@ -70,6 +71,7 @@ export const defaultPanelOptions: Partial<ProblemsPanelOptions> = {
|
|||||||
opdataField: false,
|
opdataField: false,
|
||||||
descriptionField: true,
|
descriptionField: true,
|
||||||
descriptionAtNewLine: false,
|
descriptionAtNewLine: false,
|
||||||
|
showDatasourceName: false,
|
||||||
// Options
|
// Options
|
||||||
sortProblems: 'lastchange',
|
sortProblems: 'lastchange',
|
||||||
limit: undefined,
|
limit: undefined,
|
||||||
|
|||||||
Reference in New Issue
Block a user