alert_log_ctrl.ts 1.0 KB

123456789101112131415161718192021222324252627282930313233343536373839
  1. ///<reference path="../../headers/common.d.ts" />
  2. import angular from 'angular';
  3. import _ from 'lodash';
  4. import coreModule from '../../core/core_module';
  5. import config from 'app/core/config';
  6. import alertDef from './alert_def';
  7. import moment from 'moment';
  8. export class AlertLogCtrl {
  9. alertLogs: any;
  10. alert: any;
  11. alertId: any;
  12. /** @ngInject */
  13. constructor(private $route, private backendSrv) {
  14. if ($route.current.params.alertId) {
  15. this.alertId = $route.current.params.alertId;
  16. this.loadAlertLogs();
  17. }
  18. }
  19. loadAlertLogs() {
  20. this.backendSrv.get('/api/alerts/events/' + this.alertId).then(result => {
  21. this.alertLogs = _.map(result, log => {
  22. log.iconCss = alertDef.getCssForState(log.newState);
  23. log.humanTime = moment(log.created).format("YYYY-MM-DD HH:mm:ss");
  24. return log;
  25. });
  26. });
  27. this.backendSrv.get('/api/alerts/' + this.alertId).then(result => {
  28. this.alert = result;
  29. });
  30. }
  31. }
  32. coreModule.controller('AlertLogCtrl', AlertLogCtrl);