The open and composable observability and data visualization platform. Visualize metrics, logs, and traces from multiple sources like Prometheus, Loki, Elasticsearch, InfluxDB, Postgres and many more.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 
grafana/public/app/features/alerting/alert_list_ctrl.ts

57 lines
1.4 KiB

///<reference path="../../headers/common.d.ts" />
import angular from 'angular';
import _ from 'lodash';
import coreModule from '../../core/core_module';
import appEvents from '../../core/app_events';
import moment from 'moment';
import alertDef from './alert_def';
export class AlertListCtrl {
alerts: any;
stateFilters = [
{text: 'All', value: null},
{text: 'OK', value: 'ok'},
{text: 'Pending', value: 'pending'},
{text: 'Warning', value: 'warning'},
{text: 'Critical', value: 'critical'},
{text: 'Execution Error', value: 'execution_error'},
];
filters = {
state: 'ALL'
};
/** @ngInject */
constructor(private backendSrv, private $location) {
var params = $location.search();
this.filters.state = params.state || null;
this.loadAlerts();
}
filtersChanged() {
this.$location.search(this.filters);
}
loadAlerts() {
this.backendSrv.get('/api/alerts', this.filters).then(result => {
this.alerts = _.map(result, alert => {
alert.stateModel = alertDef.getStateDisplayModel(alert.state);
alert.newStateDateAgo = moment(alert.newStateDate).fromNow().replace(" ago", "");
return alert;
});
});
}
openHowTo() {
appEvents.emit('show-modal', {
src: 'public/app/features/alerting/partials/alert_howto.html',
modalClass: 'confirm-modal',
model: {}
});
}
}
coreModule.controller('AlertListCtrl', AlertListCtrl);