option to disable acknowledges for read-only users, closes #481
This commit is contained in:
@@ -28,7 +28,7 @@ class ZabbixAPIDatasource {
|
||||
this.basicAuth = instanceSettings.basicAuth;
|
||||
this.withCredentials = instanceSettings.withCredentials;
|
||||
|
||||
const jsonData = instanceSettings.jsonData;
|
||||
const jsonData = instanceSettings.jsonData || {};
|
||||
|
||||
// Zabbix API credentials
|
||||
this.username = jsonData.username;
|
||||
@@ -48,6 +48,9 @@ class ZabbixAPIDatasource {
|
||||
this.addThresholds = jsonData.addThresholds;
|
||||
this.alertingMinSeverity = jsonData.alertingMinSeverity || c.SEV_WARNING;
|
||||
|
||||
// Other options
|
||||
this.disableReadOnlyUsersAck = jsonData.disableReadOnlyUsersAck;
|
||||
|
||||
// Direct DB Connection options
|
||||
let dbConnectionOptions = jsonData.dbConnection || {};
|
||||
this.enableDirectDBConnection = dbConnectionOptions.enable;
|
||||
|
||||
@@ -126,3 +126,11 @@
|
||||
</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;
|
||||
return this.datasourceSrv.get(trigger.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) {
|
||||
return datasource.zabbix.zabbixAPI.acknowledgeEvent(eventid, ack_message);
|
||||
} else {
|
||||
|
||||
Reference in New Issue
Block a user