2016-04-28 04:42:03 -05:00
|
|
|
///<reference path="../../headers/common.d.ts" />
|
|
|
|
|
|
|
|
import angular from 'angular';
|
|
|
|
import _ from 'lodash';
|
|
|
|
import coreModule from '../../core/core_module';
|
|
|
|
import config from 'app/core/config';
|
2016-05-02 08:20:58 -05:00
|
|
|
import alertDef from './alert_def';
|
|
|
|
import moment from 'moment';
|
2016-04-28 04:42:03 -05:00
|
|
|
|
|
|
|
export class AlertLogCtrl {
|
|
|
|
|
|
|
|
alertLogs: any;
|
|
|
|
alert: any;
|
|
|
|
|
|
|
|
/** @ngInject */
|
|
|
|
constructor(private $route, private backendSrv) {
|
|
|
|
if ($route.current.params.alertId) {
|
2016-05-09 05:10:53 -05:00
|
|
|
this.loadAlertLogs($route.current.params.alertId);
|
2016-04-28 04:42:03 -05:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-05-09 05:10:53 -05:00
|
|
|
loadAlertLogs(alertId: number) {
|
|
|
|
this.backendSrv.get(`/api/alerts/rules/${alertId}/states`).then(result => {
|
2016-05-02 08:31:40 -05:00
|
|
|
this.alertLogs = _.map(result, log => {
|
2016-05-02 08:20:58 -05:00
|
|
|
log.iconCss = alertDef.getCssForState(log.newState);
|
|
|
|
log.humanTime = moment(log.created).format("YYYY-MM-DD HH:mm:ss");
|
2016-05-02 08:31:40 -05:00
|
|
|
return log;
|
2016-05-02 08:20:58 -05:00
|
|
|
});
|
2016-04-28 04:42:03 -05:00
|
|
|
});
|
|
|
|
|
2016-05-09 05:10:53 -05:00
|
|
|
this.backendSrv.get(`/api/alerts/rules/${alertId}`).then(result => {
|
2016-04-28 04:42:03 -05:00
|
|
|
this.alert = result;
|
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
coreModule.controller('AlertLogCtrl', AlertLogCtrl);
|