mirror of
https://github.com/grafana/grafana.git
synced 2024-11-27 11:20:27 -06:00
chore(alerting): style refactoring
This commit is contained in:
parent
35c73902da
commit
3e462f2914
@ -14,14 +14,16 @@ type AlertState struct {
|
||||
}
|
||||
|
||||
var (
|
||||
ALERT_STATE_OK = "OK"
|
||||
ALERT_STATE_CRITICAL = "CRITICAL"
|
||||
ALERT_STATE_WARN = "WARN"
|
||||
ALERT_STATE_ACKNOWLEDGED = "ACKNOWLEDGED"
|
||||
VALID_STATES = []string{"OK", "WARN", "CRITICAL", "ACKNOWLEDGED"}
|
||||
)
|
||||
|
||||
func (this *UpdateAlertStateCommand) IsValidState() bool {
|
||||
return this.NewState == ALERT_STATE_OK || this.NewState == ALERT_STATE_WARN || this.NewState == ALERT_STATE_CRITICAL || this.NewState == ALERT_STATE_ACKNOWLEDGED
|
||||
for _, v := range VALID_STATES {
|
||||
if this.NewState == v {
|
||||
return true
|
||||
}
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
// Commands
|
||||
|
@ -11,18 +11,16 @@ export class AlertLogCtrl {
|
||||
|
||||
alertLogs: any;
|
||||
alert: any;
|
||||
alertId: any;
|
||||
|
||||
/** @ngInject */
|
||||
constructor(private $route, private backendSrv) {
|
||||
if ($route.current.params.alertId) {
|
||||
this.alertId = $route.current.params.alertId;
|
||||
this.loadAlertLogs();
|
||||
this.loadAlertLogs($route.current.params.alertId);
|
||||
}
|
||||
}
|
||||
|
||||
loadAlertLogs() {
|
||||
this.backendSrv.get(`/api/alerts/rules/${this.alertId}/states`).then(result => {
|
||||
loadAlertLogs(alertId: number) {
|
||||
this.backendSrv.get(`/api/alerts/rules/${alertId}/states`).then(result => {
|
||||
this.alertLogs = _.map(result, log => {
|
||||
log.iconCss = alertDef.getCssForState(log.newState);
|
||||
log.humanTime = moment(log.created).format("YYYY-MM-DD HH:mm:ss");
|
||||
@ -30,7 +28,7 @@ export class AlertLogCtrl {
|
||||
});
|
||||
});
|
||||
|
||||
this.backendSrv.get(`/api/alerts/rules/${this.alertId}`).then(result => {
|
||||
this.backendSrv.get(`/api/alerts/rules/${alertId}`).then(result => {
|
||||
this.alert = result;
|
||||
});
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user