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 #545 from lucasponce/AlertsCenterWork
Browse files Browse the repository at this point in the history
HAWKULAR-621 AlertCenter: complete alert details page
  • Loading branch information
mtho11 committed Oct 9, 2015
2 parents 9b028c4 + 51c21b5 commit 4754ff0
Show file tree
Hide file tree
Showing 4 changed files with 169 additions and 138 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -18,61 +18,96 @@ <h1>Alert Center</h1>
<div class="hk-info-top clearfix">
<h3 class="pull-left">Alert Details</h3>
</div>
<div class="panel panel-default clearfix hk-alert-details">
<h2>Alert: {{acd.description | characters: 55}}</h2>
<dl class="dl-horizontal">
<dt>State</dt>
<dd><span class="hk-open">{{acd.detailAlert.status | firstUpper}}</span></dd>
<dt>Severity</dt>
<dd>{{acd.detailAlert.severity | firstUpper}}</dd>
<dt>Description
<a class="hk-btn-icon" tabindex="0" role="button"
popover-trigger="click" popover-placement="top" popover-append-to-body="true"
popover="Alert Trigger description"><i class="fa fa-info-circle"></i></a>
</dt>
<dd>{{acd.description|characters: 40}}</dd>
<dt>Created</dt>
<dd>{{acd.detailAlert.ctime | date:'d MMM yyyy, HH:mm'}}</dd>
<dt>Resource Path
<a class="hk-btn-icon" tabindex="0" role="button"
popover-trigger="click" popover-placement="top" popover-append-to-body="true"
popover="e = environment, f = feed, r = resource id"
><i class="fa fa-info-circle"></i></a>
</dt>
<dd>{{acd.detailAlert.context.resourcePath}}</dd>
<dt><span class="hide">Actions</span>
<dd>
<button class="btn btn-default" type="button"
ng-disabled="acd.detailAlert.status != 'OPEN'" ng-click="acd.acknowledge()">Acknowledge</button>
<button class="btn btn-primary" type="button"
ng-disabled="acd.detailAlert.status == 'RESOLVED'"
ng-click="acd.resolve()">Resolve</button>
</dd>
</dl>
</div>

<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">
<table class="table table-striped table-bordered">
<thead>
<tr>
<th>Time</th>
<th>Type</th>
<th>Recipients</th>
<th>Result</th>
</tr>
</thead>
<tbody>
<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 class="row">
<div class="col-md-9">
<div class="panel panel-default clearfix">
<div class="panel-heading">
<h2>{{acd.description | characters: 55}}</h2>
</div>
<div class="panel-body">
<form class="form-horizontal">
<fieldset>
<div class="form-group">
<label class="col-sm-2 control-label" for="status">State</label>
<div class="col-sm-6">
<select pf-select ng-model="acd.status" id="status">
<option ng-repeat="status in acd.statuses" value="{{status}}">{{status | firstUpper}}</option>
</select>
</div>
</div>
<div class="form-group">
<label class="col-sm-2 control-label">Severity</label>
<div class="col-sm-10">
<span class="hk-input-text">{{acd.detailAlert.severity | firstUpper}}</span>
</div>
</div>
<div class="form-group">
<label class="col-sm-2 control-label">Description
<a class="hk-btn-icon" tabindex="0" role="button" data-toggle="popover" data-html="true" data-placement="top" data-content="Trigger description"><i class="fa fa-info-circle"></i></a>
</label>
<div class="col-sm-10">
<span class="hk-input-text">{{acd.description}}</span>
</div>
</div>
<div class="form-group">
<label class="col-sm-2 control-label">Created</label>
<div class="col-sm-10">
<span class="hk-input-text">{{acd.detailAlert.ctime | date:'d MMM yyyy, HH:mm'}}</span>
</div>
</div>
<div class="form-group">
<label class="col-sm-2 control-label">Resource Path
<a class="hk-btn-icon" tabindex="0" role="button" data-toggle="popover" data-html="true" data-placement="top" data-content="e = environment, f = feed, r = the resource id"><i class="fa fa-info-circle"></i></a>
</label>
<div class="col-sm-10">
<span class="hk-input-text">{{acd.detailAlert.context.resourcePath}}</span>
</div>
</div>
<div class="form-group">
<label class="col-sm-2 control-label">Feed Id</label>
<div class="col-sm-10">
<span class="hk-input-text">{{acd.feedId}}</span>
</div>
</div>
<div class="form-group">
<label class="col-sm-2 control-label">Comments</label>
<div class="col-sm-10">
<textarea class="form-control" rows="2" ng-disabled="acd.status == 'OPEN'" ng-model="acd.comments"></textarea>
</div>
</div>
</fieldset>
</form>
<div class="form-actions col-sm-10 col-sm-offset-2">
<button class="btn btn-default" type="button" ng-click="acd.cancel()">Cancel</button>
<button class="btn btn-primary" type="button" ng-disabled="acd.status == 'OPEN'" ng-click="acd.save()">Save</button>
</div>
</div>
</div>
</div>

<div class="col-md-3">
<div class="panel panel-default clearfix" ng-show="acd.actionsHistory.length > 0">
<div class="panel-heading">
<h2>Notifications</h2>
</div>
<div class="panel-body">
<div class="hk-box-v-item" ng-repeat="action in acd.actionsHistory">
<div class="hk-display-table">
<div class="hk-icon-container">
<i class="fa fa-envelope-o"></i>
</div>
<div class="hk-info-container">
<span class="email">{{action.actionId}}</span>
<span class="type">{{action.actionPlugin | firstUpper}}</span>
<span class="date">{{action.ctime | date:'d MMM yyyy, HH:mm'}}</span>
</div>
</div>
</div>
</div>
</div>
</div>

</div>

</div>
Expand Down
84 changes: 35 additions & 49 deletions console/src/main/scripts/plugins/metrics/ts/alertsCenterDetails.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,12 @@ module HawkularMetrics {
public feedId:FeedId;
public detailAlert:IAlert;
public description:string;
public comments:string;
public status:string;
public statuses;

public endTimeStamp:TimestampInMillis;
public startTimeStamp:TimestampInMillis;
public bucketedDataPoints;
public chartData;

public alertsTimeStart:TimestampInMillis;
public alertsTimeEnd:TimestampInMillis;
Expand All @@ -51,7 +52,7 @@ module HawkularMetrics {
private $q:ng.IQService,
private $rootScope:IHawkularRootScope,
private $routeParams:any,
private $location:ng.ILocaleService,
private $location:ng.ILocationService,
private MetricsService:IMetricsService,
private NotificationsService:INotificationsService) {
$scope.acd = this;
Expand All @@ -62,6 +63,7 @@ module HawkularMetrics {
this.alertsTimeEnd = $routeParams.endTime ? $routeParams.endTime : Date.now();
this.alertsTimeStart = this.alertsTimeEnd - this.alertsTimeOffset;
this.actionsHistory = [];
this.statuses = [];
this.getAlert(this._alertId);
this.getActions(this._alertId);

Expand All @@ -73,24 +75,51 @@ module HawkularMetrics {
let descriptionsParts = alert.trigger.description.split('~');
this.description = descriptionsParts[0];
this.feedId = descriptionsParts[1];
this.status = alert.status;
if (this.status === 'OPEN') {
this.statuses = ['OPEN', 'ACKNOWLEDGED', 'RESOLVED'];
} else {
this.statuses = ['ACKNOWLEDGED', 'RESOLVED'];
}
if (alert.status === 'OPEN' || alert.status === 'ACKNOWLEDGED') {
this.comments = alert.ackNotes;
} else {
this.comments = alert.resolvedNotes;
}
});
}

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

public cancel():void {
this.$location.url(`/hawkular-ui/alerts-center`);
}

public save(): void {
if (this.status === 'OPEN') {
return;
}
if (this.status === 'ACKNOWLEDGED') {
this.acknowledge();
} else {
this.resolve();
}
}

public resolve():void {
this.$log.log('ResolveDetail: ' + this._alertId);
this.isWorking = true;

let resolvedAlerts = {
alertIds: this._alertId,
resolvedBy: this.$rootScope.currentPersona.name,
resolvedNotes: 'Manually resolved'
resolvedNotes: this.comments
};

this.HawkularAlertsManager.resolveAlerts(resolvedAlerts).then(() => {
Expand All @@ -100,15 +129,14 @@ module HawkularMetrics {
});
}


public acknowledge() {
this.$log.log('Ack Alert Detail: ' + this._alertId);
this.isWorking = true;

let ackAlerts = {
alertIds: this._alertId,
ackBy: this.$rootScope.currentPersona.name,
ackNotes: 'Manually acknowledged'
ackNotes: this.comments
};

this.HawkularAlertsManager.ackAlerts(ackAlerts).then(() => {
Expand All @@ -118,48 +146,6 @@ module HawkularMetrics {
});
}



public refreshHistoricalChartDataForTimestamp(resourceId:ResourceId,
startTime?:TimestampInMillis,
endTime?:TimestampInMillis):void {
/// calling refreshChartData without params use the model values
if (!endTime) {
endTime = this.endTimeStamp;
}
if (!startTime) {
startTime = this.startTimeStamp;
}

if (resourceId) {

this.MetricsService.retrieveGaugeMetrics(this.$rootScope.currentPersona.id, resourceId,
startTime, endTime, 120)
.then((response) => {

// we want to isolate the response from the data we are feeding to the chart
this.bucketedDataPoints = MetricsService.formatBucketedChartOutput(response);

if (this.bucketedDataPoints.length) {
// this is basically the DTO for the chart
this.chartData = {
id: resourceId,
startTimeStamp: startTime,
endTimeStamp: endTime,
dataPoints: this.bucketedDataPoints
};

} else {
this.$log.warn('No Data found for id: ' + resourceId);
}

}, (error) => {
this.NotificationsService.error('Error Loading Chart Data: ' + error);
});
}
}


}

_module.controller('AlertsCenterDetailsController', AlertsCenterDetailsController);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@ module HawkularMetrics {
ackTime: TimestampInMillis;
ctime: TimestampInMillis;
resolvedBy: string;
resolvedByNotes: string;
resolvedNotes: string;
resolvedTime: TimestampInMillis;
severity: string; /// @todo: change to enum
status: string; /// @todo: change to enum
Expand Down

0 comments on commit 4754ff0

Please sign in to comment.