option to disable acknowledges for read-only users, closes #481
This commit is contained in:
5
dist/datasource-zabbix/datasource.js
vendored
5
dist/datasource-zabbix/datasource.js
vendored
@@ -220,7 +220,7 @@ System.register(['lodash', 'app/core/utils/datemath', './utils', './migrations',
|
|||||||
this.basicAuth = instanceSettings.basicAuth;
|
this.basicAuth = instanceSettings.basicAuth;
|
||||||
this.withCredentials = instanceSettings.withCredentials;
|
this.withCredentials = instanceSettings.withCredentials;
|
||||||
|
|
||||||
var jsonData = instanceSettings.jsonData;
|
var jsonData = instanceSettings.jsonData || {};
|
||||||
|
|
||||||
// Zabbix API credentials
|
// Zabbix API credentials
|
||||||
this.username = jsonData.username;
|
this.username = jsonData.username;
|
||||||
@@ -240,6 +240,9 @@ System.register(['lodash', 'app/core/utils/datemath', './utils', './migrations',
|
|||||||
this.addThresholds = jsonData.addThresholds;
|
this.addThresholds = jsonData.addThresholds;
|
||||||
this.alertingMinSeverity = jsonData.alertingMinSeverity || c.SEV_WARNING;
|
this.alertingMinSeverity = jsonData.alertingMinSeverity || c.SEV_WARNING;
|
||||||
|
|
||||||
|
// Other options
|
||||||
|
this.disableReadOnlyUsersAck = jsonData.disableReadOnlyUsersAck;
|
||||||
|
|
||||||
// Direct DB Connection options
|
// Direct DB Connection options
|
||||||
var dbConnectionOptions = jsonData.dbConnection || {};
|
var dbConnectionOptions = jsonData.dbConnection || {};
|
||||||
this.enableDirectDBConnection = dbConnectionOptions.enable;
|
this.enableDirectDBConnection = dbConnectionOptions.enable;
|
||||||
|
|||||||
2
dist/datasource-zabbix/datasource.js.map
vendored
2
dist/datasource-zabbix/datasource.js.map
vendored
File diff suppressed because one or more lines are too long
8
dist/datasource-zabbix/partials/config.html
vendored
8
dist/datasource-zabbix/partials/config.html
vendored
@@ -126,3 +126,11 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<div class="gf-form-group">
|
||||||
|
<h3 class="page-heading">Other</h3>
|
||||||
|
<gf-form-switch class="gf-form" label-class="width-20"
|
||||||
|
label="Disable acknowledges for read-only users"
|
||||||
|
checked="ctrl.current.jsonData.disableReadOnlyUsersAck">
|
||||||
|
</gf-form-switch>
|
||||||
|
</div>
|
||||||
|
|||||||
4
dist/panel-triggers/triggers_panel_ctrl.js
vendored
4
dist/panel-triggers/triggers_panel_ctrl.js
vendored
@@ -603,6 +603,10 @@ System.register(['lodash', 'jquery', 'moment', '../datasource-zabbix/utils', 'ap
|
|||||||
var grafana_user = this.contextSrv.user.name;
|
var grafana_user = this.contextSrv.user.name;
|
||||||
var ack_message = grafana_user + ' (Grafana): ' + message;
|
var ack_message = grafana_user + ' (Grafana): ' + message;
|
||||||
return this.datasourceSrv.get(trigger.datasource).then(function (datasource) {
|
return this.datasourceSrv.get(trigger.datasource).then(function (datasource) {
|
||||||
|
var userIsEditor = _this8.contextSrv.isEditor || _this8.contextSrv.isGrafanaAdmin;
|
||||||
|
if (datasource.disableReadOnlyUsersAck && !userIsEditor) {
|
||||||
|
return Promise.reject({ message: 'You have no permissions to acknowledge events.' });
|
||||||
|
}
|
||||||
if (eventid) {
|
if (eventid) {
|
||||||
return datasource.zabbix.zabbixAPI.acknowledgeEvent(eventid, ack_message);
|
return datasource.zabbix.zabbixAPI.acknowledgeEvent(eventid, ack_message);
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
File diff suppressed because one or more lines are too long
@@ -28,7 +28,7 @@ class ZabbixAPIDatasource {
|
|||||||
this.basicAuth = instanceSettings.basicAuth;
|
this.basicAuth = instanceSettings.basicAuth;
|
||||||
this.withCredentials = instanceSettings.withCredentials;
|
this.withCredentials = instanceSettings.withCredentials;
|
||||||
|
|
||||||
const jsonData = instanceSettings.jsonData;
|
const jsonData = instanceSettings.jsonData || {};
|
||||||
|
|
||||||
// Zabbix API credentials
|
// Zabbix API credentials
|
||||||
this.username = jsonData.username;
|
this.username = jsonData.username;
|
||||||
@@ -48,6 +48,9 @@ class ZabbixAPIDatasource {
|
|||||||
this.addThresholds = jsonData.addThresholds;
|
this.addThresholds = jsonData.addThresholds;
|
||||||
this.alertingMinSeverity = jsonData.alertingMinSeverity || c.SEV_WARNING;
|
this.alertingMinSeverity = jsonData.alertingMinSeverity || c.SEV_WARNING;
|
||||||
|
|
||||||
|
// Other options
|
||||||
|
this.disableReadOnlyUsersAck = jsonData.disableReadOnlyUsersAck;
|
||||||
|
|
||||||
// Direct DB Connection options
|
// Direct DB Connection options
|
||||||
let dbConnectionOptions = jsonData.dbConnection || {};
|
let dbConnectionOptions = jsonData.dbConnection || {};
|
||||||
this.enableDirectDBConnection = dbConnectionOptions.enable;
|
this.enableDirectDBConnection = dbConnectionOptions.enable;
|
||||||
|
|||||||
@@ -126,3 +126,11 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<div class="gf-form-group">
|
||||||
|
<h3 class="page-heading">Other</h3>
|
||||||
|
<gf-form-switch class="gf-form" label-class="width-20"
|
||||||
|
label="Disable acknowledges for read-only users"
|
||||||
|
checked="ctrl.current.jsonData.disableReadOnlyUsersAck">
|
||||||
|
</gf-form-switch>
|
||||||
|
</div>
|
||||||
|
|||||||
@@ -453,6 +453,10 @@ export class TriggerPanelCtrl extends PanelCtrl {
|
|||||||
let ack_message = grafana_user + ' (Grafana): ' + message;
|
let ack_message = grafana_user + ' (Grafana): ' + message;
|
||||||
return this.datasourceSrv.get(trigger.datasource)
|
return this.datasourceSrv.get(trigger.datasource)
|
||||||
.then(datasource => {
|
.then(datasource => {
|
||||||
|
const userIsEditor = this.contextSrv.isEditor || this.contextSrv.isGrafanaAdmin;
|
||||||
|
if (datasource.disableReadOnlyUsersAck && !userIsEditor) {
|
||||||
|
return Promise.reject({message: 'You have no permissions to acknowledge events.'});
|
||||||
|
}
|
||||||
if (eventid) {
|
if (eventid) {
|
||||||
return datasource.zabbix.zabbixAPI.acknowledgeEvent(eventid, ack_message);
|
return datasource.zabbix.zabbixAPI.acknowledgeEvent(eventid, ack_message);
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
Reference in New Issue
Block a user