Skip to content
This repository has been archived by the owner on Nov 9, 2017. It is now read-only.

Commit

Permalink
Refactor AlertService to NotificationService to not confuse Alerts wi…
Browse files Browse the repository at this point in the history
…th actual Hawkular Alerts.
  • Loading branch information
mtho11 committed Jul 23, 2015
1 parent be5694a commit a54e7f1
Show file tree
Hide file tree
Showing 9 changed files with 43 additions and 43 deletions.
4 changes: 2 additions & 2 deletions console/src/main/scripts/plugins/metrics/ts/alertsManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,13 +48,13 @@ module HawkularMetrics {

export class HawkularAlertsManager implements IHawkularAlertsManager{

public static $inject = ['HawkularAlert', '$q', '$log', '$moment','AlertService'];
public static $inject = ['HawkularAlert', '$q', '$log', '$moment','NotificationService'];

constructor(private HawkularAlert: any,
private $q: ng.IQService,
private $log: ng.ILogService,
private $moment: any,
private AlertService:any) {
private NotificationService:INotificationService) {
}

public createTrigger(id: TriggerId, triggerName: string, enabled: boolean,
Expand Down
6 changes: 3 additions & 3 deletions console/src/main/scripts/plugins/metrics/ts/errorManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,11 +30,11 @@ module HawkularMetrics {

export class HawkularErrorManager implements IHawkularErrorManager {

public static $inject = ['$q', '$log', 'AlertService'];
public static $inject = ['$q', '$log', 'NotificationService'];

constructor(private $q: ng.IQService,
private $log: ng.ILogService,
private AlertService: IAlertService) {
private NotificationService: INotificationService) {
}

private errorToastr(error: any, errorMsg: string): void {
Expand All @@ -46,7 +46,7 @@ module HawkularMetrics {
errorMsgComplete = errorMsg + ' ' + error;
}

this.AlertService.error(errorMsgComplete);
this.NotificationService.error(errorMsgComplete);
}

public errorHandler(error: any, msg: string, cb?: (error: any, msg: string) => void): ng.IPromise<void> {
Expand Down
4 changes: 2 additions & 2 deletions console/src/main/scripts/plugins/metrics/ts/metricService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -67,11 +67,11 @@ module HawkularMetrics {

export class MetricService implements IMetricService {

public static $inject = ['$log', 'HawkularMetric', 'AlertService'];
public static $inject = ['$log', 'HawkularMetric', 'NotificationService'];

constructor(private $log:ng.ILogService,
private HawkularMetric:any,
private AlertService:IAlertService) {
private NotificationService:INotificationService) {
}


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ module HawkularMetrics {
export class MetricsAvailabilityController {
/// for minification only
public static $inject = ['$scope', '$rootScope', '$interval', '$window', '$log', 'HawkularMetric', 'HawkularAlert',
'$routeParams', '$filter', '$moment', 'HawkularAlertsManager', 'HawkularErrorManager', 'AlertService'];
'$routeParams', '$filter', '$moment', 'HawkularAlertsManager', 'HawkularErrorManager', 'NotificationService'];

private availabilityDataPoints:IChartDataPoint[] = [];
private autoRefreshPromise:ng.IPromise<number>;
Expand All @@ -48,7 +48,6 @@ module HawkularMetrics {
public downtimeCount = 0;
public empty = true;
public math;

constructor(private $scope:any,
private $rootScope:any,
private $interval:ng.IIntervalService,
Expand All @@ -61,7 +60,7 @@ module HawkularMetrics {
private $moment:any,
private HawkularAlertsManager:IHawkularAlertsManager,
private HawkularErrorManager:IHawkularErrorManager,
private AlertService:IAlertService,
private NotificationService:INotificationService,
public alertList:any,
public startTimeStamp:TimestampInMillis,
public endTimeStamp:TimestampInMillis) {
Expand Down Expand Up @@ -163,7 +162,7 @@ module HawkularMetrics {
}

}, (error) => {
this.AlertService.error('Error Loading Avail Summary Data: ' + error);
this.NotificationService.error('Error Loading Avail Summary Data: ' + error);
});

}
Expand Down Expand Up @@ -207,7 +206,7 @@ module HawkularMetrics {
this.uptimeRatio = 1 - downtimeDuration / (+this.$moment() - response[0].timestamp);
this.downtimeCount = downtimeCount;
}, (error) => {
this.AlertService.error('Error Loading Avail Data: ' + error);
this.NotificationService.error('Error Loading Avail Data: ' + error);
});
}
}
Expand Down
16 changes: 8 additions & 8 deletions console/src/main/scripts/plugins/metrics/ts/metricsPlugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -94,14 +94,14 @@ module HawkularMetrics {
templateUrl: 'plugins/metrics/html/response-time.html',
reloadOnSearch: false,
resolve: {
resource: function ($route, $location, HawkularInventory, AlertService) {
resource: function ($route, $location, HawkularInventory, NotificationService:INotificationService) {
var p = HawkularInventory.Resource.get({environmentId: globalEnvironmentId,
resourceId: $route.current.params.resourceId}).$promise;
p.then((response) => {
return response.properties.url;
},
(error) => {
AlertService.info('You were redirected to this page because you requested an invalid URL.');
NotificationService.info('You were redirected to this page because you requested an invalid URL.');
$location.path('/');
});
return p;
Expand All @@ -112,14 +112,14 @@ module HawkularMetrics {
templateUrl: 'plugins/metrics/html/availability.html',
reloadOnSearch: false,
resolve: {
resource: function ($route, $location, HawkularInventory, AlertService) {
resource: function ($route, $location, HawkularInventory, NotificationService:INotificationService) {
var p = HawkularInventory.Resource.get({environmentId: globalEnvironmentId,
resourceId: $route.current.params.resourceId}).$promise;
p.then((response) => {
return response.properties.url;
},
(error) => {
AlertService.info('You were redirected to this page because you requested an invalid URL.');
NotificationService.info('You were redirected to this page because you requested an invalid URL.');
$location.path('/');
});
return p;
Expand All @@ -130,14 +130,14 @@ module HawkularMetrics {
templateUrl: 'plugins/metrics/html/alerts.html',
reloadOnSearch: false,
resolve: {
resource: function ($route, $location, HawkularInventory, AlertService) {
resource: function ($route, $location, HawkularInventory, NotificaitonService:INotificationService) {
var p = HawkularInventory.Resource.get({environmentId: globalEnvironmentId,
resourceId: $route.current.params.resourceId}).$promise;
p.then((response) => {
return response.properties.url;
},
(error) => {
AlertService.info('You were redirected to this page because you requested an invalid URL.');
NotificaitonService.info('You were redirected to this page because you requested an invalid URL.');
$location.path('/');
});
return p;
Expand All @@ -149,9 +149,9 @@ module HawkularMetrics {
templateUrl: 'plugins/metrics/html/app-details/app-server-details.html',
reloadOnSearch: false,
resolve: {
resource: function ($route, $location, HawkularInventory, AlertService) {
resource: function ($route, $location, HawkularInventory, NotificationService:INotificationService) {
var redirectMissingAppServer = function() {
AlertService.info('You were redirected to this page because you requested an invalid ' +
NotificationService.info('You were redirected to this page because you requested an invalid ' +
'Application Server.');
$location.path('/hawkular-ui/app/app-list');
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ module HawkularMetrics {
}

export class QuickAlertController implements IQuickAlertController {
public static $inject = ['$scope', 'HawkularAlert', '$log', '$q', 'AlertService'];
public static $inject = ['$scope', 'HawkularAlert', '$log', '$q', 'NotificationService'];

private metricId:MetricId;
private PROMISE_BREAK: string = 'magicValue1234';
Expand All @@ -35,7 +35,7 @@ module HawkularMetrics {
private HawkularAlert:any,
private $log: ng.ILogService,
private $q: ng.IQService,
private AlertService: IAlertService) {
private NotificationService: INotificationService) {
this.$scope.showQuickAlert = false;
this.$scope.quickTrigger = {
operator: 'LT',
Expand Down Expand Up @@ -72,7 +72,7 @@ module HawkularMetrics {
errorMsgComplete = errorMsg + ' ' + error;
}

this.AlertService.error(errorMsgComplete);
this.NotificationService.error(errorMsgComplete);
}

private errorHandler(error: any, msg: string) {
Expand Down Expand Up @@ -143,7 +143,7 @@ module HawkularMetrics {
// Success ThresholdCondition save
() => {
this.$log.debug('Success ThresholdCondition save');
this.AlertService.success('Alert Created!');
this.NotificationService.success('Alert Created!');

this.toggleQuickAlert();

Expand All @@ -166,7 +166,7 @@ module HawkularMetrics {
}
);
} else {
this.AlertService.warning('No metric selected');
this.NotificationService.warning('No metric selected');
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ module HawkularMetrics {
export class MetricsViewController {
/// for minification only
public static $inject = ['$scope', '$rootScope', '$interval', '$log', 'HawkularAlert',
'$routeParams', 'HawkularAlertsManager', 'HawkularErrorManager', 'AlertService', 'MetricService'];
'$routeParams', 'HawkularAlertsManager', 'HawkularErrorManager', 'NotificationService', 'MetricService'];

private bucketedDataPoints:IChartDataPoint[] = [];
private contextDataPoints:IChartDataPoint[] = [];
Expand All @@ -64,7 +64,7 @@ module HawkularMetrics {
private $routeParams:any,
private HawkularAlertsManager: IHawkularAlertsManager,
private HawkularErrorManager: IHawkularErrorManager,
private AlertService: IAlertService,
private NotificationService: INotificationService,
private MetricService: IMetricService ) {
$scope.vm = this;

Expand Down Expand Up @@ -126,7 +126,7 @@ module HawkularMetrics {

private noDataFoundForId(resourceId:ResourceId):void {
this.$log.warn('No Data found for id: ' + resourceId);
///this.AlertService.warning('No Data found for id: ' + id);
///this.NotificationService.warning('No Data found for id: ' + id);
}

private refreshChartDataNow(metricId:MetricId, startTime?:TimestampInMillis):void {
Expand Down Expand Up @@ -176,7 +176,7 @@ module HawkularMetrics {
this.average = Math.round(_.last(dataPoints).avg);

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

}
Expand Down Expand Up @@ -234,7 +234,7 @@ module HawkularMetrics {
}

}, (error) => {
this.AlertService.error('Error Loading Chart Data: ' + error);
this.NotificationService.error('Error Loading Chart Data: ' + error);
});
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,14 +23,14 @@

module HawkularMetrics {

export interface IAlertService {
export interface INotificationService {
info(message: string): void;
success(message: string): void;
warning(message: string): void;
error(message: string): void;
}

export class AlertService implements IAlertService {
export class NotificationService implements INotificationService {

public static $inject = ['$log', 'toastr'];

Expand Down Expand Up @@ -60,5 +60,5 @@ module HawkularMetrics {
}
}

_module.service('AlertService', AlertService);
_module.service('NotificationService', NotificationService);
}
21 changes: 11 additions & 10 deletions console/src/main/scripts/plugins/metrics/ts/urlList.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
/// <reference path='alertsManager.ts'/>
/// <reference path='pagination.ts'/>
/// <reference path='errorManager.ts'/>
/// <reference path='alertService.ts'/>
/// <reference path='notificationService.ts'/>

module HawkularMetrics {

Expand All @@ -28,7 +28,7 @@ module HawkularMetrics {
/// this is for minification purposes
public static $inject = ['$location', '$scope', '$rootScope', '$interval', '$log', '$filter', '$modal',
'HawkularInventory', 'HawkularMetric', 'HawkularAlert', 'HawkularAlertsManager','HawkularErrorManager', '$q',
'md5', 'HkHeaderParser', 'AlertService'];
'md5', 'HkHeaderParser', 'NotificationService'];

private autoRefreshPromise:ng.IPromise<number>;
private httpUriPart = 'http://';
Expand All @@ -50,12 +50,12 @@ module HawkularMetrics {
private HawkularInventory:any,
private HawkularMetric:any,
private HawkularAlert:any,
private HawkularAlertsManager: HawkularMetrics.IHawkularAlertsManager,
private HawkularErrorManager: HawkularMetrics.IHawkularErrorManager,
private HawkularAlertsManager: IHawkularAlertsManager,
private HawkularErrorManager: IHawkularErrorManager,
private $q: ng.IQService,
private md5: any,
private HkHeaderParser: HawkularMetrics.IHkHeaderParser,
private AlertService: HawkularMetrics.IAlertService,
private HkHeaderParser: IHkHeaderParser,
private NotificationService: INotificationService,
public resourceUrl:string
) {
$scope.vm = this;
Expand Down Expand Up @@ -158,7 +158,7 @@ module HawkularMetrics {
(e) => err(e, 'Error saving threshold trigger.'))

//this.$location.url('/hawkular/' + metricId);
.then(() => this.AlertService.info('Your data is being collected. Please be patient (should be about ' +
.then(() => this.NotificationService.info('Your data is being collected. Please be patient (should be about ' +
'another minute).'),
(e) => err(e, 'Error saving availability trigger.'))

Expand Down Expand Up @@ -238,15 +238,15 @@ module HawkularMetrics {
class DeleteResourceModalController {

static $inject = ['$scope', '$rootScope', '$modalInstance', '$q', 'HawkularInventory', 'HawkularAlertsManager',
'AlertService', 'resource'];
'NotificationService', 'resource'];

constructor(private $scope: any,
private $rootScope: any,
private $modalInstance: any,
private $q: ng.IQService,
private HawkularInventory,
private HawkularAlertsManager: HawkularMetrics.IHawkularAlertsManager,
private AlertService: IAlertService,
private NotificationService: INotificationService,
public resource) {
$scope.vm = this;
}
Expand All @@ -272,7 +272,8 @@ module HawkularMetrics {
this.HawkularAlertsManager.deleteTrigger(triggerIds[1])])
.then(removeResource)
.then((res) => {
this.AlertService.success('The URL ' + this.resource.properties.url + ' is no longer being monitored.');
this.NotificationService.success('The URL ' + this.resource.properties.url +
' is no longer being monitored.');
this.$modalInstance.close(res);
});
}
Expand Down

0 comments on commit a54e7f1

Please sign in to comment.