Skip to content
This repository has been archived by the owner on Nov 9, 2017. It is now read-only.

Commit

Permalink
Merge pull request #206 from vrockai/HAWKULAR-312
Browse files Browse the repository at this point in the history
HAWKULAR-312: Alerts Page should auto refresh itself
  • Loading branch information
mtho11 committed Jun 12, 2015
2 parents f8022e1 + aa8847e commit 4e3a0dc
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,8 @@
module HawkularMetrics {

export class MetricsAlertController {
public static $inject = ['$scope', 'HawkularAlert', 'HawkularAlertsManager', 'HawkularErrorManager', '$log', '$q', '$rootScope', '$routeParams', '$modal'];
public static $inject = ['$scope', 'HawkularAlert', 'HawkularAlertsManager', 'HawkularErrorManager', '$log', '$q',
'$rootScope', '$routeParams', '$modal', '$interval'];

private metricId: string;
public alertList: any = [];
Expand All @@ -38,7 +39,8 @@ module HawkularMetrics {
private $q: ng.IQService,
private $rootScope: any,
private $routeParams: any,
private $modal: any) {
private $modal: any,
private $interval: ng.IIntervalService) {

this.$log.debug('querying data');
this.$log.debug('$routeParams', $routeParams);
Expand Down Expand Up @@ -72,13 +74,28 @@ module HawkularMetrics {
return !!((value.start > $scope.alertsTimeStart) && (value.start < $scope.alertsTimeEnd));
};

HawkularAlertsManager.queryConsoleAlerts(this.metricId).then((data)=> {
this.getAlerts();
this.autoRefresh(20);
}

private getAlerts():void {
this.HawkularAlertsManager.queryConsoleAlerts(this.metricId).then((data)=> {
this.$log.debug('queryConsoleAlerts', data);
this.alertList = data;
this.alertList.$resolved = true; // FIXME
}, (error) => { return this.HawkularErrorManager.errorHandler(error, 'Error fetching alerts.'); });
}

private autoRefresh(intervalInSeconds:number):void {
var autoRefreshPromise = this.$interval(() => {
this.getAlerts();
}, intervalInSeconds * 1000);

this.$scope.$on('$destroy', () => {
this.$interval.cancel(autoRefreshPromise);
});
}

public alertResolve(alert: any, index: number): void {
for (var i = 0; i< this.alertList.length; i++) {
if (this.alertList[i].$$hashKey === alert.$$hashKey) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,7 @@ module HawkularMetrics {
this.startTimeStamp = this.$scope.hkStartTimestamp;
this.refreshSummaryData(this.getMetricId());
this.refreshHistoricalChartDataForTimestamp(this.getMetricId());
this.refreshAlerts(this.getMetricId(), this.$scope.hkStartTimestamp, this.endTimeStamp);
this.retrieveThreshold();
}, intervalInSeconds * 1000);

Expand Down

0 comments on commit 4e3a0dc

Please sign in to comment.