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;
|
|
|
|
alertId: any;
|
|
|
|
|
|
|
|
/** @ngInject */
|
|
|
|
constructor(private $route, private backendSrv) {
|
|
|
|
if ($route.current.params.alertId) {
|
|
|
|
this.alertId = $route.current.params.alertId;
|
|
|
|
this.loadAlertLogs();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
loadAlertLogs() {
|
|
|
|
this.backendSrv.get('/api/alerts/events/' + this.alertId).then(result => {
|
|
|
|
this.alertLogs = result;
|
2016-05-02 08:20:58 -05:00
|
|
|
|
|
|
|
_.each(this.alertLogs, log => {
|
|
|
|
log.iconCss = alertDef.getCssForState(log.newState);
|
|
|
|
log.humanTime = moment(log.created).format("YYYY-MM-DD HH:mm:ss");
|
|
|
|
});
|
2016-04-28 04:42:03 -05:00
|
|
|
});
|
|
|
|
|
|
|
|
this.backendSrv.get('/api/alerts/' + this.alertId).then(result => {
|
|
|
|
this.alert = result;
|
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
coreModule.controller('AlertLogCtrl', AlertLogCtrl);
|