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.
Merge pull request #220 from vrockai/alertsRefactor
Console: Alerts refactoring
- Loading branch information
Showing
13 changed files
with
227 additions
and
194 deletions.
There are no files selected for viewing
56 changes: 56 additions & 0 deletions
56
ui/console/src/main/scripts/plugins/directives/plugins/alert/html/alert.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,56 @@ | ||
<div> | ||
<div class="panel panel-default alert alert-danger" ng-if="alert.type=='AVAILABILITY'"> | ||
<div class="hk-alert-icon"> | ||
<i class="fa fa-flag"></i> | ||
</div> | ||
<div class="hk-date"> | ||
{{alert.start | date:'medium' }} | ||
</div> | ||
<div class="hk-event"> | ||
Server <strong>down</strong> for {{(alert.end - alert.start)/1000 | number: 0}} seconds (until | ||
<span ng-if="alert.isThisYear && alert.isToday">{{alert.end | date:'shortTime' }}).</span> | ||
<span ng-if="alert.isThisYear && !alert.isToday">{{alert.end | date:'MMM d, h:mm:ss a' }}).</span> | ||
<span ng-if="!alert.isThisYear">{{alert.end | date:'medium' }}).</span> | ||
</div> | ||
|
||
<div class="alert-resolver"> | ||
<a ng-click="alertResolve(alert, $index)" tooltip="Mark as resolved" | ||
tooltip-placement="top" | ||
tooltip-trigger="mouseenter" | ||
tooltip-popup-delay="500"> | ||
<i class="fa" ng-class="{'fa-check-square-o': hover, 'fa-square-o': !hover}" | ||
ng-mouseenter="hover = true" | ||
ng-mouseleave="hover = false"> | ||
</i> | ||
</a> | ||
</div> | ||
</div> | ||
|
||
<div class="panel panel-default alert alert-danger" ng-if="alert.type=='THRESHOLD'"> | ||
<div class="hk-alert-icon"> | ||
<i class="fa fa-flag"></i> | ||
</div> | ||
<div class="hk-date"> | ||
{{alert.start | date:'medium' }} | ||
</div> | ||
<div class="hk-event"> | ||
<strong>Response time</strong> was above the threshold ({{alert.threshold | number: 0}} ms) for {{(alert.end - alert.start) / 1000.0 | number: 0}} seconds (until | ||
<span ng-if="alert.isThisYear && alert.isToday">{{alert.end | date:'shortTime' }}).</span> | ||
<span ng-if="alert.isThisYear && !alert.isToday">{{alert.end | date:'MMM d, h:mm:ss a' }}).</span> | ||
<span ng-if="!alert.isThisYear">{{alert.end | date:'medium' }}).</span> | ||
The average response time was {{alert.avg | number: 0}} ms. | ||
</div> | ||
|
||
<div class="alert-resolver"> | ||
<a ng-click="alertResolve()" tooltip="Mark as resolved" | ||
tooltip-placement="top" | ||
tooltip-trigger="mouseenter" | ||
tooltip-popup-delay="500"> | ||
<i class="fa" ng-class="{'fa-check-square-o': hover, 'fa-square-o': !hover}" | ||
ng-mouseenter="hover = true" | ||
ng-mouseleave="hover = false"> | ||
</i> | ||
</a> | ||
</div> | ||
</div> | ||
</div> |
4 changes: 4 additions & 0 deletions
4
ui/console/src/main/scripts/plugins/directives/plugins/alert/html/alertList.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,4 @@ | ||
<div> | ||
<hk-alert-panel ng-repeat="alert in alertList | orderBy: '-start' | limitTo: (limit ? limit : 1000) track by $index" | ||
hk-alert="alert" hk-refresh="alertResolve(hkAlert)"></hk-alert-panel> | ||
</div> |
94 changes: 94 additions & 0 deletions
94
ui/console/src/main/scripts/plugins/directives/plugins/alert/ts/alertDirective.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,94 @@ | ||
/// | ||
/// 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="../../includes.ts"/> | ||
/// <reference path="../../includes.ts"/> | ||
|
||
module Alert { | ||
|
||
export var _module = angular.module('hawkular-alerts'); | ||
|
||
class HkAlertPanel { | ||
|
||
public link: (scope: any, element: ng.IAugmentedJQuery, attrs: ng.IAttributes) => void; | ||
public replace = 'true'; | ||
public scope = { | ||
alert: '=hkAlert', | ||
refresh: '&hkRefresh' | ||
}; | ||
public templateUrl = 'plugins/alert/html/alert.html'; | ||
|
||
|
||
constructor(private HawkularAlert) { | ||
this.link = (scope: any, element: ng.IAugmentedJQuery, attrs: ng.IAttributes) => { | ||
scope.alertResolve = (): void => { | ||
this.HawkularAlert.Alert.resolve({alertIds: scope.alert.id}, {}, () => { | ||
scope.refresh({hkAlert: scope.alert}); | ||
}); | ||
}; | ||
}; | ||
} | ||
|
||
public static Factory() { | ||
var directive = (HawkularAlert: any) => { | ||
return new HkAlertPanel(HawkularAlert); | ||
}; | ||
|
||
directive['$inject'] = ['HawkularAlert']; | ||
|
||
return directive; | ||
} | ||
} | ||
|
||
_module.directive('hkAlertPanel', HkAlertPanel.Factory()); | ||
|
||
class HkAlertPanelList { | ||
|
||
public link: (scope: any, element: ng.IAugmentedJQuery, attrs: ng.IAttributes) => void; | ||
public replace = 'true'; | ||
public scope = { | ||
alertList: '=hkAlertList', | ||
limit: '=hkLimit' | ||
}; | ||
public templateUrl = 'plugins/alert/html/alertList.html'; | ||
|
||
constructor() { | ||
this.link = (scope: any, element: ng.IAugmentedJQuery, attrs: ng.IAttributes) => { | ||
scope.alertResolve = (alert): void => { | ||
for (var i = 0; i< scope.alertList.length; i++) { | ||
if (scope.alertList[i].id === alert.id) { | ||
scope.alertList.splice(i, 1); | ||
break; | ||
} | ||
} | ||
}; | ||
}; | ||
} | ||
|
||
public static Factory() { | ||
var directive = () => { | ||
return new HkAlertPanelList(); | ||
}; | ||
|
||
directive['$inject'] = []; | ||
|
||
return directive; | ||
} | ||
} | ||
|
||
_module.directive('hkAlertPanelList', HkAlertPanelList.Factory()); | ||
} |
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
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
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
Oops, something went wrong.