Execute scripts from problem details

This commit is contained in:
Alexander Zobnin
2020-05-27 15:15:36 +03:00
parent 092acec295
commit 6841fa0386
7 changed files with 114 additions and 88 deletions

View File

@@ -317,11 +317,11 @@ export class TriggerPanelCtrl extends MetricsPanelCtrl {
}
getProblemScripts(problem: ProblemDTO) {
const hostIds = problem.hosts?.map(h => h.hostid);
const hostid = problem.hosts?.length ? problem.hosts[0].hostid : null;
return getDataSourceSrv().get(problem.datasource)
.then((datasource: any) => {
return datasource.zabbix.getScripts(hostIds);
return datasource.zabbix.getScripts([hostid]);
});
}
@@ -361,6 +361,15 @@ export class TriggerPanelCtrl extends MetricsPanelCtrl {
});
}
executeScript(problem: ProblemDTO, scriptid: string) {
const hostid = problem.hosts?.length ? problem.hosts[0].hostid : null;
return getDataSourceSrv().get(problem.datasource)
.then((datasource: any) => {
return datasource.zabbix.executeScript(hostid, scriptid);
});
}
handlePageSizeChange(pageSize, pageIndex) {
this.panel.pageSize = pageSize;
this.pageIndex = pageIndex;
@@ -415,6 +424,7 @@ export class TriggerPanelCtrl extends MetricsPanelCtrl {
const { message, action, severity } = data;
return ctrl.acknowledgeProblem(trigger, message, action, severity);
},
onExecuteScript: ctrl.executeScript.bind(ctrl),
onTagClick: (tag, datasource, ctrlKey, shiftKey) => {
if (ctrlKey || shiftKey) {
ctrl.removeTagFilter(tag, datasource);