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 #537 from lucasponce/AlertsCenterWork
Browse files Browse the repository at this point in the history
Alerts center work
  • Loading branch information
mtho11 committed Oct 8, 2015
2 parents bd01a32 + 2e03462 commit bef44ab
Show file tree
Hide file tree
Showing 12 changed files with 203 additions and 200 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,7 @@ <h2>{{acd.description}}</h2>
</dl>
</div>

<!--
<div class="hk-info-top clearfix">
<div class="hk-info-top clearfix" ng-show="acd.actionsHistory.length > 0">
<h3 class="pull-left">Notification History</h3>
</div>
<div class="hk-table-container">
Expand All @@ -58,23 +57,21 @@ <h3 class="pull-left">Notification History</h3>
<th>Time</th>
<th>Type</th>
<th>Recipients</th>
<th>Result</th>
</tr>
</thead>
<tbody>
<tr>
<td>15 Aug 2015, 21:55</td>
<td>Email</td>
<td>jdoe@redhat.com</td>
</tr>
<tr>
<td>12 Aug 2015, 09:34</td>
<td>SMS</td>
<td>508-555-1212</td>
<tr ng-repeat="action in acd.actionsHistory">
<td>{{action.ctime | date:'d MMM yyyy, HH:mm'}}</td>
<td>{{action.actionPlugin}}</td>
<td>{{action.actionId}}</td>
<td>{{action.result}}</td>
</tr>
</tbody>
</table>
</div>

<!--
<div class="hk-info-top clearfix">
<h3 class="pull-left">Metrics</h3>
</div>
Expand Down
22 changes: 15 additions & 7 deletions console/src/main/scripts/plugins/metrics/ts/alertsCenterDetails.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ module HawkularMetrics {

export class AlertsCenterDetailsController {

public static $inject = ['$scope', 'HawkularAlertsManager', 'HawkularAlert', 'ErrorsManager',
public static $inject = ['$scope', 'HawkularAlertsManager', 'ErrorsManager',
'$log', '$q', '$rootScope', '$routeParams', '$location', 'MetricsService', 'NotificationsService'];

private _alertId:AlertId;
Expand All @@ -42,10 +42,10 @@ module HawkularMetrics {
public alertsTimeOffset:TimestampInMillis;
public isWorking: boolean = false;

public actionsHistory;

constructor(private $scope:any,
private HawkularAlertsManager:IHawkularAlertsManager,
private HawkularAlert:any,
private ErrorsManager:IErrorsManager,
private $log:ng.ILogService,
private $q:ng.IQService,
Expand All @@ -61,20 +61,27 @@ module HawkularMetrics {
// If the end time is not specified in URL use current time as end time
this.alertsTimeEnd = $routeParams.endTime ? $routeParams.endTime : Date.now();
this.alertsTimeStart = this.alertsTimeEnd - this.alertsTimeOffset;
this.actionsHistory = [];
this.getAlert(this._alertId);
this.getActions(this._alertId);

}

public getAlert(alertId:AlertId) {
return this.HawkularAlert.Alert.get({alertId: alertId}, (alertResponse) => {
this.detailAlert = alertResponse;
let descriptionsParts = alertResponse.trigger.description.split('~');
return this.HawkularAlertsManager.getAlert(alertId).then((alert) => {
this.detailAlert = alert;
let descriptionsParts = alert.trigger.description.split('~');
this.description = descriptionsParts[0];
this.feedId = descriptionsParts[1];

});
}

public getActions(alertId:AlertId) {
return this.HawkularAlertsManager.queryActionsHistory(alertId).then((queriedActions) => {
console.dir(queriedActions);
this.actionsHistory = queriedActions.actionsList;
});
}

public resolve():void {
this.$log.log('ResolveDetail: ' + this._alertId);
Expand All @@ -89,6 +96,7 @@ module HawkularMetrics {
this.HawkularAlertsManager.resolveAlerts(resolvedAlerts).then(() => {
this.isWorking = false;
this.getAlert(this._alertId);
this.getActions(this._alertId);
});
}

Expand All @@ -106,8 +114,8 @@ module HawkularMetrics {
this.HawkularAlertsManager.ackAlerts(ackAlerts).then(() => {
this.isWorking = false;
this.getAlert(this._alertId);
this.getActions(this._alertId);
});

}


Expand Down
23 changes: 10 additions & 13 deletions console/src/main/scripts/plugins/metrics/ts/alertsCenterList.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ module HawkularMetrics {

export class AlertsCenterController {

public static $inject = ['$scope', 'HawkularAlert', 'HawkularAlertsManager',
public static $inject = ['$scope', 'HawkularAlertsManager',
'ErrorsManager', '$log', '$q', '$rootScope', '$interval', '$routeParams',
'HkHeaderParser', '$location'];

Expand All @@ -45,7 +45,6 @@ module HawkularMetrics {
public addProgress:boolean = false;

constructor(private $scope:any,
private HawkularAlert:any,
private HawkularAlertsManager:IHawkularAlertsManager,
private ErrorsManager:IErrorsManager,
private $log:ng.ILogService,
Expand Down Expand Up @@ -84,17 +83,15 @@ module HawkularMetrics {
}

public getAlerts():void {
this.HawkularAlert.Alert.query().$promise.
then((alerts:IAlert[]) => {
this.alertsList = alerts;

}, (error) => {
this.$log.warn(error);
}).catch((error) => {
this.$log.error('Error:' + error);
}).finally(() => {
this.lastUpdateDate = new Date();
});
this.HawkularAlertsManager.queryAlerts().then((queriedAlerts) => {
this.alertsList = queriedAlerts.alertList;
}, (error) => {
this.$log.warn(error);
}).catch((error) => {
this.$log.error('Error:' + error);
}).finally(() => {
this.lastUpdateDate = new Date();
});
}

//public getAlerts():void {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,8 +79,8 @@ module HawkularMetrics {

private getAlerts(metricIdPrefix:string, startTime:TimestampInMillis, endTime:TimestampInMillis, res:any):void {
let connArray: any, respArray: any;
let connPromise = this.HawkularAlertsManager.queryAlerts(metricIdPrefix + '_ds_conn', startTime, endTime)
.then((connData)=> {
let connPromise = this.HawkularAlertsManager.queryAlerts({statuses: 'OPEN',
triggerIds: metricIdPrefix + '_ds_conn', startTime: startTime, endTime: endTime}).then((connData)=> {
_.forEach(connData.alertList, (item) => {
item['alertType']='DSCONN';
item['condition']=item['dataId'].substr(item['dataId'].lastIndexOf('~')+1);
Expand All @@ -90,8 +90,8 @@ module HawkularMetrics {
//return this.ErrorsManager.errorHandler(error, 'Error fetching alerts.');
});

let respPromise = this.HawkularAlertsManager.queryAlerts(metricIdPrefix + '_ds_resp', startTime, endTime)
.then((respData)=> {
let respPromise = this.HawkularAlertsManager.queryAlerts({statuses: 'OPEN',
triggerIds: metricIdPrefix + '_ds_resp', startTime: startTime, endTime: endTime}).then((respData)=> {
_.forEach(respData.alertList, (item) => {
item['alertType']='DSRESP';
item['condition']=item['dataId'].substr(item['dataId'].lastIndexOf('~')+1);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,8 +85,8 @@ module HawkularMetrics {

private getAlerts(metricIdPrefix:string, startTime:TimestampInMillis, endTime:TimestampInMillis):void {
let pheapArray:any, nheapArray:any, garbaArray:any;
let pheapPromise = this.HawkularAlertsManager.queryAlerts(metricIdPrefix + '_jvm_pheap', startTime, endTime)
.then((pheapData)=> {
let pheapPromise = this.HawkularAlertsManager.queryAlerts({statuses:'OPEN',
triggerIds: metricIdPrefix + '_jvm_pheap', startTime: startTime, endTime: endTime}).then((pheapData)=> {
_.forEach(pheapData.alertList, (item) => {
item['alertType'] = 'PHEAP';
});
Expand All @@ -95,8 +95,8 @@ module HawkularMetrics {
return this.ErrorsManager.errorHandler(error, 'Error fetching alerts.');
});

let nheapPromise = this.HawkularAlertsManager.queryAlerts(metricIdPrefix + '_jvm_nheap', startTime, endTime)
.then((nheapData)=> {
let nheapPromise = this.HawkularAlertsManager.queryAlerts({statuses:'OPEN',
triggerIds: metricIdPrefix + '_jvm_nheap', startTime: startTime, endTime: endTime}).then((nheapData)=> {
_.forEach(nheapData.alertList, (item) => {
item['alertType'] = 'NHEAP';
});
Expand All @@ -105,8 +105,8 @@ module HawkularMetrics {
return this.ErrorsManager.errorHandler(error, 'Error fetching alerts.');
});

let garbaPromise = this.HawkularAlertsManager.queryAlerts(metricIdPrefix + '_jvm_garba', startTime, endTime)
.then((garbaData)=> {
let garbaPromise = this.HawkularAlertsManager.queryAlerts({statuses: 'OPEN',
triggerIds: metricIdPrefix + '_jvm_garba', startTime: startTime, endTime: endTime}).then((garbaData)=> {
_.forEach(garbaData.alertList, (item) => {
item['alertType'] = 'GARBA';
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,11 +82,11 @@ module HawkularMetrics {
let expiredSessionsTriggerId = metricIdPrefix + '_web_expired_sessions';
let rejectedSessionsTriggerId = metricIdPrefix + '_web_rejected_sessions';

let triggersId = activeSessionsTriggerId + ',' + expiredSessionsTriggerId + ',' + rejectedSessionsTriggerId;
let triggerIds = activeSessionsTriggerId + ',' + expiredSessionsTriggerId + ',' + rejectedSessionsTriggerId;

let sessionsArray:any;
let sessionsPromise = this.HawkularAlertsManager.queryAlerts(triggersId, startTime, endTime)
.then((sessionsData)=> {
let sessionsPromise = this.HawkularAlertsManager.queryAlerts({statuses: 'OPEN', triggerIds: triggerIds,
startTime: startTime, endTime: endTime}).then((sessionsData)=> {
_.forEach(sessionsData.alertList, (item) => {
if (item['triggerId'] === activeSessionsTriggerId) {
item['alertType'] = 'ACTIVE_SESSIONS';
Expand Down
4 changes: 2 additions & 2 deletions console/src/main/scripts/plugins/metrics/ts/metricsAlerts.ts
Original file line number Diff line number Diff line change
Expand Up @@ -190,8 +190,8 @@ module HawkularMetrics {

let triggerIds = this.resourceId + '_trigger_avail,' + this.resourceId + '_trigger_thres';

this.HawkularAlertsManager.queryAlerts(triggerIds, this.alertsTimeStart, this.alertsTimeEnd,
this.resCurPage, this.resPerPage).then((queriedAlerts)=> {
this.HawkularAlertsManager.queryAlerts({statuses: 'OPEN', triggerIds: triggerIds, startTime: this.alertsTimeStart,
endTime: this.alertsTimeEnd, currentPage: this.resCurPage, perPage: this.resPerPage}).then((queriedAlerts)=> {
this.headerLinks = this.HkHeaderParser.parse(queriedAlerts.headers);
_.forEach(queriedAlerts.alertList, (item) => {
if (item['type'] === 'THRESHOLD') {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,8 @@ module HawkularMetrics {

private getAlerts(metricId:string, startTime:TimestampInMillis, endTime:TimestampInMillis):void {
let triggerIds = metricId + '_trigger_avail';
this.HawkularAlertsManager.queryAlerts(triggerIds, startTime, endTime).then((alertAvailData)=> {
this.HawkularAlertsManager.queryAlerts({statuses: 'OPEN', triggerIds: triggerIds, startTime: startTime,
endTime: endTime}).then((alertAvailData)=> {
_.forEach(alertAvailData.alertList, (item) => { item['alertType']='PINGAVAIL';});
this.alertList = alertAvailData.alertList;
}, (error) => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,8 @@ module HawkularMetrics {

private getAlerts(metricId:MetricId, startTime:TimestampInMillis, endTime:TimestampInMillis):void {
let triggerIds = metricId + '_trigger_thres';
this.HawkularAlertsManager.queryAlerts(triggerIds, startTime, endTime).then((responseAlertData)=> {
this.HawkularAlertsManager.queryAlerts({statuses: 'OPEN', triggerIds: triggerIds, startTime: startTime,
endTime: endTime}).then((responseAlertData)=> {
_.forEach(responseAlertData.alertList, (item) => { item['alertType']='PINGRESPONSE';});
this.alertList = responseAlertData.alertList;
}, (error) => {
Expand Down

0 comments on commit bef44ab

Please sign in to comment.