This repository has been archived by the owner on Nov 9, 2017. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 33
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Triggers List (WIP)
- Loading branch information
Showing
6 changed files
with
311 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
80 changes: 80 additions & 0 deletions
80
console/src/main/scripts/plugins/metrics/html/alerts-center-triggers.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,80 @@ | ||
<div class="hk-screen-content"> | ||
<hawkular-subtab ng-controller="Subtab.SubtabController"> | ||
<div class="hk-nav-tabs-container"> | ||
<ul class="nav nav-tabs nav-tabs-pf"> | ||
<li><a href="/hawkular-ui/alerts-center" class="hk-alerts">Alerts</a></li> | ||
<li class="active"><a href="/hawkular-ui/alerts-center-triggers" class="hk-alerts">Definitions</a></li> | ||
</ul> | ||
</div> | ||
</hawkular-subtab> | ||
|
||
<div class="hk-alert-center"> | ||
|
||
<!-- No Triggers --> | ||
<div ng-show="act.triggersList.length === 0"> | ||
<div class="hk-info-top clearfix"> | ||
<h3>Triggers ({{act.triggersList.length}})</h3> | ||
</div> | ||
<div class="blank-slate-pf"> | ||
<div class="blank-slate-pf-icon"> | ||
<i class="fa fa-flag"></i> | ||
</div> | ||
<h1>No Triggers.</h1> | ||
</div> | ||
</div> | ||
|
||
<div ng-show="act.triggersList.length > 0"> | ||
|
||
<div class="hk-info-top clearfix"> | ||
<h3 class="pull-left">Triggers ({{act.headerLinks.total}})</h3> | ||
<span class="hk-update pull-right" data-toggle="tooltip" data-placement="top" title="Last update"> | ||
<i class="fa fa-clock-o" ng-click="act.getTriggers()"></i>{{act.lastUpdateDate | date:'HH:mm'}}</span> | ||
</div> | ||
|
||
<div class="hk-table-container"> | ||
<div class="dataTables_header"> | ||
<div id="DataTables_Table_0_filter" class="dataTables_filter"> | ||
<label><input type="search" ng-model="act.search" aria-controls="DataTables_Table_0"></label> | ||
</div> | ||
<div class="dataTables_info" id="DataTables_Table_0_info" role="status" aria-live="polite">Showing <b>1</b> to <b>{{(act.triggersList | filter:act.search).length}}</b> of <b>{{act.triggersList.length}}</b> Items</div> | ||
</div> | ||
<table class="datatable table table-bordered hk-table-alerts hk-table-detailed hk-table-select"> | ||
<thead> | ||
<tr> | ||
<th ng-click="act.selectAll()"><input type="checkbox"/></th> | ||
<th ng-class="{'sorting_asc': act.sortField == 'name' && act.sortAsc, 'sorting_desc': act.sortField == 'name' && !act.sortAsc, 'sorting': act.sortField != 'name'}" ng-click="act.sortBy('name')">Name</th> | ||
<th ng-class="{'sorting_asc': act.sortField == 'description' && act.sortAsc, 'sorting_desc': act.sortField == 'description' && !act.sortAsc, 'sorting': act.sortField != 'description'}" ng-click="act.sortBy('description')">Description</th> | ||
<th ng-class="{'sorting_asc': act.sortField == 'context.resourceName' && act.sortAsc, 'sorting_desc': act.sortField == 'context.resourceName' && !act.sortAsc, 'sorting': act.sortField != 'context.resourceName'}" ng-click="act.sortBy('context.resourceName')">Resource</th> | ||
<th ng-class="{'sorting_asc': act.sortField == 'severity' && act.sortAsc, 'sorting_desc': act.sortField == 'severity' && !act.sortAsc, 'sorting': act.sortField != 'severity'}" ng-click="act.sortBy('severity')" ng-click="act.sortBy('severity')">Severity</th> | ||
<th ng-class="{'sorting_asc': act.sortField == 'notifications' && act.sortAsc, 'sorting_desc': act.sortField == 'notifications' && !act.sortAsc, 'sorting': act.sortField != 'notifications'}" ng-click="act.sortBy('notifications')" ng-click="act.sortBy('notifications')">Notifications</th> | ||
<th></th> | ||
</tr> | ||
</thead> | ||
<tbody> | ||
<tr ng-repeat="trigger in act.triggersList | filter:act.search" ng-class="{'hk-selected': act.selected}" | ||
ng-click="act.selectItem(trigger)"> | ||
<td><input type="checkbox" ng-checked="trigger.selected"/></td> | ||
<td>{{trigger.name|firstUpper}}</td> | ||
<td>{{trigger.description|firstUpper}}</td> | ||
<td>{{trigger.context.resourceName | truncate: 30}}</td> | ||
<td>{{trigger.severity|firstUpper}}</td> | ||
<td>{{trigger.actions|firstUpper}}</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="act.showDetailPage(trigger.id)"> | ||
</i></a> | ||
</td> | ||
</tr> | ||
</tbody> | ||
</table> | ||
<div class="dataTables_footer"> | ||
<hk-data-pagination resource-list="act.triggersList" current-page="act.triggersCurPage" | ||
page-setter="act.setPage(pageNumber)" | ||
per-page="act.triggersPerPage" headers="act.headerLinks"></hk-data-pagination> | ||
</div> | ||
</div> | ||
|
||
</div> | ||
</div> | ||
|
||
</div> |
134 changes: 134 additions & 0 deletions
134
console/src/main/scripts/plugins/metrics/ts/alertsCenterTriggerList.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,134 @@ | ||
/// | ||
/// Copyright 2015 Red Hat, Inc. and/or its affiliates | ||
/// and other contributors as indicated by the @author tags. | ||
/// | ||
/// Licensed under the Apache License, Version 2.0 (the "License"); | ||
/// you may not use this file except in compliance with the License. | ||
/// You may obtain a copy of the License at | ||
/// | ||
/// http://www.apache.org/licenses/LICENSE-2.0 | ||
/// | ||
/// Unless required by applicable law or agreed to in writing, software | ||
/// distributed under the License is distributed on an "AS IS" BASIS, | ||
/// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
/// See the License for the specific language governing permissions and | ||
/// limitations under the License. | ||
/// | ||
|
||
/// <reference path="metricsPlugin.ts"/> | ||
/// <reference path="../../includes.ts"/> | ||
/// <reference path="services/alertsManager.ts"/> | ||
/// <reference path="services/errorsManager.ts"/> | ||
|
||
module HawkularMetrics { | ||
|
||
export class AlertsCenterTriggerController { | ||
|
||
public static $inject = ['$scope', 'HawkularAlertsManager', | ||
'ErrorsManager', '$log', '$q', '$rootScope', '$interval', '$routeParams', | ||
'HkHeaderParser', '$location']; | ||
|
||
public isWorking = false; | ||
public lastUpdateDate:Date = new Date(); | ||
|
||
public triggersList:IAlertTrigger[]; | ||
public selectedItems:IAlertTrigger[]; | ||
public triggersPerPage = 10; | ||
public triggersCurPage = 0; | ||
public headerLinks:any = {}; | ||
public selectCount = 0; | ||
public hasOpenSelectedItems:boolean = false; | ||
|
||
public loadingMoreItems:boolean = false; | ||
public addProgress:boolean = false; | ||
|
||
constructor(private $scope:any, | ||
private HawkularAlertsManager:IHawkularAlertsManager, | ||
private ErrorsManager:IErrorsManager, | ||
private $log:ng.ILogService, | ||
private $q:ng.IQService, | ||
private $rootScope:IHawkularRootScope, | ||
private $interval:ng.IIntervalService, | ||
private $routeParams:any, | ||
private HkHeaderParser:any, | ||
private $location:ng.ILocationService) { | ||
$scope.ac = this; | ||
|
||
this.autoRefresh(120); | ||
if ($rootScope.currentPersona) { | ||
this.getTriggers(); | ||
} else { | ||
// currentPersona hasn't been injected to the rootScope yet, wait for it.. | ||
$rootScope.$watch('currentPersona', (currentPersona) => | ||
currentPersona && this.getTriggers()); | ||
} | ||
|
||
} | ||
|
||
private autoRefresh(intervalInSeconds:number):void { | ||
let autoRefreshPromise = this.$interval(() => { | ||
this.$log.debug('autoRefresh .... ' + new Date()); | ||
this.getTriggers(); | ||
}, intervalInSeconds * 1000); | ||
|
||
this.$scope.$on('$destroy', () => { | ||
this.$interval.cancel(autoRefreshPromise); | ||
}); | ||
} | ||
|
||
public getTriggers():void { | ||
|
||
this.HawkularAlertsManager.queryTriggers({currentPage: this.triggersCurPage, | ||
perPage: this.triggersPerPage | ||
}) | ||
.then((queriedTriggers) => { | ||
this.headerLinks = this.HkHeaderParser.parse(queriedTriggers.headers); | ||
this.triggersList = queriedTriggers.triggerList; | ||
this.lastUpdateDate = new Date(); | ||
console.dir(this.headerLinks); | ||
}, (error) => { | ||
this.$log.warn(error); | ||
}).catch((error) => { | ||
this.$log.error('Error:' + error); | ||
}).finally(() => { | ||
this.lastUpdateDate = new Date(); | ||
}); | ||
} | ||
|
||
public showDetailPage(triggerId:TriggerId):void { | ||
this.$location.url(`/hawkular-ui/alerts-center-trigger-detail/${triggerId}`); | ||
} | ||
|
||
public setPage(page:number):void { | ||
this.triggersCurPage = page; | ||
this.getTriggers(); | ||
} | ||
|
||
public selectItem(item:IAlertTrigger):void { | ||
item.selected = !item.selected; | ||
this.selectedItems = _.filter(this.triggersList, 'selected'); | ||
this.selectCount = this.selectedItems.length; | ||
this.hasOpenSelectedItems = _.some(this.selectedItems,{'status': 'OPEN'}); | ||
} | ||
|
||
private resetAllUnselected() { | ||
this.selectCount = 0; | ||
this.hasOpenSelectedItems = false; | ||
this.triggersList.forEach((item:IAlertTrigger) => { | ||
item.selected = false; | ||
}); | ||
} | ||
|
||
public selectAll():void { | ||
let toggleTo = this.selectCount !== this.triggersList.length; | ||
_.forEach(this.triggersList, (item:IAlertTrigger) => { | ||
item.selected = toggleTo; | ||
}); | ||
this.selectCount = toggleTo ? this.triggersList.length : 0; | ||
} | ||
|
||
} | ||
|
||
_module.controller('AlertsCenterTriggerController', AlertsCenterTriggerController); | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters