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 #731 from jshaughn/hawkular-888
Browse files Browse the repository at this point in the history
Hawkular-888 linkify AlertCenter->Alerts->Resource
  • Loading branch information
mtho11 committed Dec 17, 2015
2 parents b534fd1 + 49c7a4f commit 195d9d6
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 2 deletions.
Expand Up @@ -69,7 +69,7 @@ <h3 class="pull-left">Alerts ({{ac.headerLinks.total}})</h3>
<th ng-class="{'sorting_asc': ac.sortField == 'severity' && ac.sortAsc, 'sorting_desc': ac.sortField == 'severity' && !ac.sortAsc, 'sorting': ac.sortField != 'severity'}" ng-click="ac.sortBy('severity')">Severity</th>
<th ng-class="{'sorting_asc': ac.sortField == 'trigger.description' && ac.sortAsc, 'sorting_desc': ac.sortField == 'trigger.description' && !ac.sortAsc, 'sorting': ac.sortField != 'trigger.description'}" ng-click="ac.sortBy('trigger.description')">Description</th>
<th ng-class="{'sorting_asc': ac.sortField == 'ctime' && ac.sortAsc, 'sorting_desc': ac.sortField == 'ctime' && !ac.sortAsc, 'sorting': ac.sortField != 'ctime'}" ng-click="ac.sortBy('ctime')" ng-click="ac.sortBy('ctime')">Created</th>
<th ng-class="{'sorting_asc': ac.sortField == 'context.resourceName' && ac.sortAsc, 'sorting_desc': ac.sortField == 'context.resourceName' && !ac.sortAsc, 'sorting': ac.sortField != 'context.resourceName'}" ng-click="ac.sortBy('context.resourceName')">Resource Name</th>
<th ng-class="{'sorting_asc': ac.sortField == 'context.resourceName' && ac.sortAsc, 'sorting_desc': ac.sortField == 'context.resourceName' && !ac.sortAsc, 'sorting': ac.sortField != 'context.resourceName'}" ng-click="ac.sortBy('context.resourceName')">Resource</th>
<th></th>
</tr>
</thead>
Expand All @@ -81,7 +81,8 @@ <h3 class="pull-left">Alerts ({{ac.headerLinks.total}})</h3>
<td>{{alert.severity|firstUpper}}</td>
<td>{{alert.trigger.description| truncate: 50}}</td>
<td>{{alert.ctime | date:'d MMM yyyy, HH:mm'}}</td>
<td>{{alert.context.resourceName | truncate: 30 : false : 'middle'}}</td>
<td><a ng-href="{{ac.getResourceRoute(alert.trigger)}}">
{{alert.context.resourceName | truncate: 30 : false : 'middle'}}</a></td>
<td><a class="btn btn-link"><i class="fa fa-chevron-circle-right fa-lg"
tooltip="View Details" tooltip-trigger tooltip-placement="top"
ng-click="ac.showDetailPage(alert.id)">
Expand Down
35 changes: 35 additions & 0 deletions console/src/main/scripts/plugins/metrics/ts/alertsCenterList.ts
Expand Up @@ -155,6 +155,41 @@ module HawkularMetrics {
}
}

public getResourceRoute(trigger:IAlertTrigger):string {
let route = 'unknown-resource-type';
let encodedId = this.encodeResourceId(trigger.id);

switch (trigger.context.resourceType) {
case 'App Server' :
route = '/hawkular-ui/app/app-details/' + trigger.context.resourceName + '/jvm';
break;
case 'App Server Deployment' :
route = '/hawkular-ui/app/app-details/' + trigger.context.resourceName + '/deployments';
break;
case 'DataSource' :
let resIdPart = trigger.context.resourceName.split('~/')[0];
route = '/hawkular-ui/app/app-details/' + resIdPart + '/datasources';
break;
case 'URL' :
let parts = trigger.id.split('_trigger_');
let resourceId = parts[0];
let segment = ( parts[1] === 'thres' ) ? 'response-time' : 'availability';
route = '/hawkular-ui/url/' + segment + '/' + trigger.id.split('_trigger_')[0];
break;
}

return route;
}

private encodeResourceId(resourceId:string):string {
// for some reason using standard encoding is not working correctly in the route. So do something dopey...
//let encoded = encodeURIComponent(resourceId);
let encoded = resourceId;
while (encoded.indexOf('/') > -1) {
encoded = encoded.replace('/', '$');
}
return encoded;
}

public ackSelected() {
this.$log.log('Ack Selected: ' + this.selectCount);
Expand Down

0 comments on commit 195d9d6

Please sign in to comment.