diff --git a/.changeset/proud-adults-obey.md b/.changeset/proud-adults-obey.md new file mode 100644 index 000000000..2b96e3728 --- /dev/null +++ b/.changeset/proud-adults-obey.md @@ -0,0 +1,5 @@ +--- +'grafana-zabbix': minor +--- + +Add datasource column to problem table diff --git a/src/panel-triggers/components/Problems/Problems.tsx b/src/panel-triggers/components/Problems/Problems.tsx index bf7f22740..a8064ffe6 100644 --- a/src/panel-triggers/components/Problems/Problems.tsx +++ b/src/panel-triggers/components/Problems/Problems.tsx @@ -49,8 +49,8 @@ export default class ProblemList extends PureComponent StatusCell(props, highlightNewerThan); const statusIconCell = (props) => StatusIconCell(props, highlightNewerThan); const hostNameCell = (props) => ( - + ); const hostTechNameCell = (props) => ( @@ -209,6 +209,14 @@ export default class ProblemList extends PureComponent 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) { @@ -339,6 +347,16 @@ function StatusCell(props: RTCell, highlightNewerThan?: string) { ); } +function DataSourceCell(props: RTCell) { + 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 {dsName}; + }; + function StatusIconCell(props: RTCell, highlightNewerThan?: string) { const status = props.value === '0' ? 'ok' : 'problem'; let newProblem = false;