Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/proud-adults-obey.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'grafana-zabbix': minor
---

Add datasource column to problem table
22 changes: 20 additions & 2 deletions src/panel-triggers/components/Problems/Problems.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,8 @@ export default class ProblemList extends PureComponent<ProblemListProps, Problem
super(props);
this.rootWidth = 0;
this.state = {
expanded: {},
expandedProblems: {},
expanded: {},
page: 0,
};
}
Expand Down Expand Up @@ -139,7 +139,7 @@ export default class ProblemList extends PureComponent<ProblemListProps, Problem
const statusCell = (props) => StatusCell(props, highlightNewerThan);
const statusIconCell = (props) => StatusIconCell(props, highlightNewerThan);
const hostNameCell = (props) => (
<HostCell name={props.original.host} maintenance={props.original.hostInMaintenance} />
<HostCell name={props.original.host} maintenance={props.original.hostInMaintenance} />
);
const hostTechNameCell = (props) => (
<HostCell name={props.original.hostTechName} maintenance={props.original.hostInMaintenance} />
Expand Down Expand Up @@ -209,6 +209,14 @@ export default class ProblemList extends PureComponent<ProblemListProps, Problem
id: 'lastchange',
Cell: (props) => LastChangeCell(props, options.customLastChangeFormat && options.lastChangeFormat),
},
{
Header: 'Datasource',
className: 'data-source',
width: 200,
accessor: 'datasource',
show: options.showDatasourceName,
Cell: (props) => DataSourceCell(props)
},
{ Header: '', className: 'custom-expander', width: 60, expander: true, Expander: CustomExpander },
];
for (const column of columns) {
Expand Down Expand Up @@ -339,6 +347,16 @@ function StatusCell(props: RTCell<ProblemDTO>, highlightNewerThan?: string) {
);
}

function DataSourceCell(props: RTCell<ProblemDTO>) {
const { getDataSourceSrv } = require('@grafana/runtime');
let dsName: string = props.original.datasource as string;
if ((props.original.datasource as DataSourceRef)?.uid) {
const dsInstance = getDataSourceSrv().getInstanceSettings((props.original.datasource as DataSourceRef).uid);
dsName = dsInstance.name;
}
return <span>{dsName}</span>;
};

function StatusIconCell(props: RTCell<ProblemDTO>, highlightNewerThan?: string) {
const status = props.value === '0' ? 'ok' : 'problem';
let newProblem = false;
Expand Down