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 #839 from karelhala/HAWKULAR-960
Browse files Browse the repository at this point in the history
HAWKULAR-960 Create message center.
  • Loading branch information
mtho11 committed Feb 9, 2016
2 parents 63bf1d9 + 7e3f84b commit f46c5b5
Show file tree
Hide file tree
Showing 9 changed files with 333 additions and 72 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,7 @@
<li ng-class="getClass('/hawkular-ui/agent-installer/')" >
<a href="/hawkular-ui/agent-installer/view">Install Agent</a>
</li>
<li class="pull-right">
<hk-message-center></hk-message-center>
</li>
</ul>
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
<section class="hk-message-center">
<div class="dropdown" dropdown auto-close="outsideClick" ng-click="vm.msgCenterClicked()">
<div href="#" class="hk-message-title" dropdown-toggle>
<i class="fa fa-inbox"></i>
<span>
Messages
</span>
<span class="badge ng-binding" ng-show="vm.storedMessages.length - vm.seenMessages !== 0">{{vm.storedMessages.length - vm.seenMessages}}</span>
</div>
<ul class="dropdown-menu dropdown-menu-right">
<li>
<div id="toast-container">
<div ng-repeat="oneMsg in vm.storedMessages | limitTo : vm.visibleMessages" class="toast {{oneMsg.type.cssClass}}">
<div ng-if="oneMsg.type.value !== 'action' && oneMsg.type.value !== 'loading'" ng-click="vm.removeMessage($index)" title="Remove this message">
{{oneMsg.message}}
<div class="pull-right toast-pf-action">
<span>{{oneMsg.timestamp | date:'HH:mm:ss'}}</span>
</div>
</div>
<div ng-if="oneMsg.type.value === 'loading'" ng-click="vm.removeMessage($index)" title="Remove this message">
<div class="progress-container">
<div class="progress progress-striped active" style="margin-bottom: 0px;">
<div class="progress-bar progress-bar-info" style="width:100%;">{{oneMsg.message}}</div>
</div>
</div>
</div>
<div ng-if="oneMsg.type.value === 'action'">
<span ng-bind-html="oneMsg.message"></span>
<a href="#" ng-click="vm.removeMessage($index)" title="Remove this message">
<i class="fa fa-times pull-right"></i>
</a>
</div>
</div>
</div>
</li>
<li class="hk-last-item">
<a class="hk-show-more" ng-click="vm.moreMessages($event)" ng-show="vm.storedMessages.length > vm.visibleMessages">
Show more...
</a>
<div class="hk-no-messages" ng-show="!vm.storedMessages || vm.storedMessages.length === 0">
No messages to show.
</div>
</li>
</ul>
</div>

</section>
53 changes: 53 additions & 0 deletions console/src/main/scripts/plugins/metrics/less/metrics.less
Original file line number Diff line number Diff line change
Expand Up @@ -2881,6 +2881,59 @@ section {
}
}

// Message center
.hk-message-center {

.hk-message-title {
color: @navbar-pf-color;
margin-right: @grid-gutter-width/3;
text-decoration: none;
cursor: pointer;

i.fa {
color: inherit;
margin-right: 7px;
margin-top: 11px;
}
}

.dropdown-menu {
margin-top: 10px;
margin-right: 5px;

&::after {
position: absolute;
top: -6px;
right: 40px;
display: inline-block;
border-right: 6px solid transparent;
border-bottom: 6px solid white;
border-left: 6px solid transparent;
content: '';
}
}

#toast-container {
position: inherit;
margin-right: 5px;
margin-left: 5px;
}
.hk-last-item {

.hk-show-more {
text-align: center;
color: #0099d3;
}

.hk-no-messages {
width: @popover-max-width;
margin-top: @grid-gutter-width/3;
margin-bottom: @grid-gutter-width/3;
text-align: center;
}
}
}

// Agent installer screen

.hk-agent-installer {
Expand Down
149 changes: 85 additions & 64 deletions console/src/main/scripts/plugins/metrics/ts/appServerDetails.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,27 +41,27 @@ module HawkularMetrics {
/* tslint:disable:variable-name */

constructor(private $rootScope: any,
private $scope: any,
private $route: any,
private $routeParams: any,
private $q: ng.IQService,
private $timeout: ng.ITimeoutService,
private HawkularOps: any,
private NotificationsService: INotificationsService,
private HawkularInventory: any,
private HawkularAlertsManager: any,
private $log: ng.ILogService,
private $location: ng.ILocationService,
private HawkularAlert: any,
public availableTabs: any,
public activeTab: any) {

private $scope: any,
private $route: any,
private $routeParams: any,
private $q: ng.IQService,
private $timeout: ng.ITimeoutService,
private HawkularOps: any,
private NotificationsService: INotificationsService,
private HawkularInventory: any,
private HawkularAlertsManager: any,
private $log: ng.ILogService,
private $location: ng.ILocationService,
private HawkularAlert: any,
public availableTabs: any,
public activeTab: any) {
$scope.tabs = this;
HawkularOps.init(this.NotificationsService);

this.defaultEmail = this.$rootScope.userDetails.email || 'myemail@company.com';
this.feedId = this.$routeParams.feedId;
this.resourceId = this.$routeParams.feedId + '/' + this.$routeParams.resourceId;
this.defaultAction = { email: [this.defaultEmail] };
this.defaultAction = {email: [this.defaultEmail]};
$scope.$on('$routeUpdate', (action, newRoute) => {
if (newRoute.params.action && newRoute.params.action === 'export-jdr') {
$scope.tabs.requestExportJDR();
Expand All @@ -86,18 +86,18 @@ module HawkularMetrics {
this.loadTriggers();
});

$scope.tabs = this;

let experimentalTabs = [''];
$rootScope.$watch('isExperimental', (isExperimental) => {
this.$timeout(() => {
_.forEach(this.availableTabs, (tab: any) => {
if (experimentalTabs.indexOf(tab.id) !== -1) {
tab.enabled = isExperimental;
}
if (!$rootScope.hasOwnProperty('isExperimentalWatch')) {
let experimentalTabs = [''];
$rootScope.isExperimentalWatch = $rootScope.$watch('isExperimental', (isExperimental) => {
this.$timeout(() => {
_.forEach(this.availableTabs, (tab: any) => {
if (experimentalTabs.indexOf(tab.id) !== -1) {
tab.enabled = isExperimental;
}
});
});
});
});
}

this.availableTabs = [
{
Expand Down Expand Up @@ -143,29 +143,50 @@ module HawkularMetrics {
];

this.activeTab = $routeParams.tabId || 'overview';

$scope.$on('ExportJDRSuccess', (event, data) => {
this.$log.info('JDR generated!');
this.jdrGenerating = false;
this.hasGeneratedSuccessfully = true;
this.hasGeneratedError = false;
});

$scope.$on('ExportJDRError', (event, data) => {
this.$log.info('JDR generation failed!');
this.jdrGenerating = false;
this.hasGeneratedSuccessfully = false;
this.hasGeneratedError = true;
});

if (!$rootScope.hasOwnProperty('exportJdrSuccess')) {
$rootScope.exportJdrSuccess = $rootScope.$on('ExportJDRSuccess', (event, data) => {
if (data && data.hasOwnProperty('jdrResponse') && data.hasOwnProperty('fileName')) {
const resourceId = data['jdrResponse'].resourcePath.split(';').last().replace(/~/g, '');
const action =
`<a href="${data.url}" download="${data.fileName}">Download JDR for server ${resourceId}</a>`;
this.NotificationsService.removeFromMessagesByKeyValue('resourcePath', data['jdrResponse'].resourcePath);
this.NotificationsService.pushActionMessage(
action,
`Generated JDR for server ${resourceId}`
);
}
this.$log.info('JDR generated!');
this.jdrGenerating = false;
this.hasGeneratedSuccessfully = true;
this.hasGeneratedError = false;
});
}

if (!$rootScope.hasOwnProperty('exportJdrError')) {
$rootScope.exportJdrError = $rootScope.$on('ExportJDRError', (event, data) => {
if (data && data.hasOwnProperty('jdrResponse')) {
const resourceId = data['jdrResponse'].resourcePath.split(';').last().replace(/~/g, '');
this.NotificationsService.removeFromMessagesByKeyValue('resourcePath', data['jdrResponse'].resourcePath);
this.NotificationsService.error(`JDR generation for server ${resourceId} failed.`);
}
this.$log.info('JDR generation failed!');
this.jdrGenerating = false;
this.hasGeneratedSuccessfully = false;
this.hasGeneratedError = true;
});
}
}

public updateTab(newTabId: string) {
this.$route.updateParams({ tabId: newTabId });
this.$route.updateParams({tabId: newTabId});
}

public requestExportJDR() {
this.jdrGenerating = true;
this.NotificationsService.pushLoadingMessage(
`Generating JDR for server ${this.$routeParams.resourceId}`,
this.resourcePath
);
this.HawkularOps.performExportJDROperation(
this.resourcePath,
this.$rootScope.userDetails.token,
Expand Down Expand Up @@ -208,7 +229,7 @@ module HawkularMetrics {
autoEnable: true, // Enable trigger once an alert is resolved
autoResolve: false, // Don't change into AUTORESOLVE mode as we don't have AUTORESOLVE conditions
severity: 'MEDIUM',
actions: { email: [this.defaultEmail] },
actions: {email: [this.defaultEmail]},
firingMatch: 'ANY',
tags: {
resourceId: qualifiedResourceId
Expand Down Expand Up @@ -285,7 +306,7 @@ module HawkularMetrics {
autoEnable: true, // Enable trigger once an alert is resolved
autoResolve: false, // Don't change into AUTORESOLVE mode as we don't have AUTORESOLVE conditions
severity: 'HIGH',
actions: { email: [this.defaultEmail] },
actions: {email: [this.defaultEmail]},
firingMatch: 'ANY',
tags: {
resourceId: qualifiedResourceId
Expand Down Expand Up @@ -365,7 +386,7 @@ module HawkularMetrics {
autoEnable: true, // Enable trigger once an alert is resolved
autoResolve: false, // Don't change into AUTORESOLVE mode as we don't have AUTORESOLVE conditions
severity: 'HIGH',
actions: { email: [this.defaultEmail] },
actions: {email: [this.defaultEmail]},
tags: {
resourceId: qualifiedResourceId
},
Expand Down Expand Up @@ -427,7 +448,7 @@ module HawkularMetrics {
autoEnable: true, // Enable trigger once an alert is resolved
autoResolve: false, // Don't change into AUTORESOLVE mode as we don't have AUTORESOLVE conditions
severity: 'MEDIUM',
actions: { email: [this.defaultEmail] },
actions: {email: [this.defaultEmail]},
tags: {
resourceId: qualifiedResourceId
},
Expand Down Expand Up @@ -488,7 +509,7 @@ module HawkularMetrics {
autoEnable: true, // Enable trigger once an alert is resolved
autoResolve: false, // Don't change into AUTORESOLVE mode as we don't have AUTORESOLVE conditions
severity: 'LOW',
actions: { email: [this.defaultEmail] },
actions: {email: [this.defaultEmail]},
tags: {
resourceId: qualifiedResourceId
},
Expand Down Expand Up @@ -546,7 +567,7 @@ module HawkularMetrics {
autoEnable: true, // Enable trigger once an alert is resolved
autoResolve: false, // Don't change into AUTORESOLVE mode as we don't have AUTORESOLVE conditions
severity: 'LOW',
actions: { email: [this.defaultEmail] },
actions: {email: [this.defaultEmail]},
tags: {
resourceId: qualifiedResourceId
},
Expand Down Expand Up @@ -610,7 +631,7 @@ module HawkularMetrics {
autoEnable: true, // Enable trigger once an alert is resolved
autoResolve: false, // Don't change into AUTORESOLVE mode as we don't have AUTORESOLVE conditions
severity: 'MEDIUM',
actions: { email: [this.defaultEmail] },
actions: {email: [this.defaultEmail]},
tags: {
resourceId: qualifiedResourceId
},
Expand Down Expand Up @@ -685,14 +706,14 @@ module HawkularMetrics {
.withName('CPU usage')
.withDescription(description)
.withActions(this.defaultAction)
.withTags({ resourceId: this.feedId, resourceName: cpuResource['name'] })
.withTags({resourceId: this.feedId, resourceName: cpuResource['name']})
.withContext(
new AlertDefinitionContextBuilder(AlertDefinitionContext.TRESHOLD_TRIGGER_TYPE)
.withAlertType('CPU_USAGE_EXCEED')
.withResourceType('CPU')
.withResourceName(this.feedId)
.withResourcePath(this.$rootScope.resourcePath)
.build()
new AlertDefinitionContextBuilder(AlertDefinitionContext.TRESHOLD_TRIGGER_TYPE)
.withAlertType('CPU_USAGE_EXCEED')
.withResourceType('CPU')
.withResourceName(this.feedId)
.withResourcePath(this.$rootScope.resourcePath)
.build()
)
.build(),
dampenings: AppServerDetailsController.defaultDampenings(triggerId),
Expand Down Expand Up @@ -738,16 +759,16 @@ module HawkularMetrics {
.withId(triggerId)
.withName('Available memory')
.withDescription(description)
.withTags({ resourceId: this.feedId })
.withTags({resourceId: this.feedId})
.withActions(this.defaultAction)
.withContext(
new AlertDefinitionContextBuilder(AlertDefinitionContext.RANGE_PERCENT_TRIGGER_TYPE)
.withAlertType('AVAILABLE_MEMORY')
.withResourceType('Memory')
.withResourceName(this.feedId)
.withResourcePath(this.$rootScope.resourcePath)
.withTriggerTypeProperty1(totalMemoryId)
.withTriggerTypeProperty2('Total memory').build()
new AlertDefinitionContextBuilder(AlertDefinitionContext.RANGE_PERCENT_TRIGGER_TYPE)
.withAlertType('AVAILABLE_MEMORY')
.withResourceType('Memory')
.withResourceName(this.feedId)
.withResourcePath(this.$rootScope.resourcePath)
.withTriggerTypeProperty1(totalMemoryId)
.withTriggerTypeProperty2('Total memory').build()
).build(),
dampenings: AppServerDetailsController.defaultDampenings(triggerId),
conditions: [
Expand Down

0 comments on commit f46c5b5

Please sign in to comment.