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

Commit

Permalink
Fix typescript problems after updating to master
Browse files Browse the repository at this point in the history
Fix additional problems after updating hawtio.d.ts to 2.0.28 so we can use newer angular things, like components
  • Loading branch information
karelhala committed Feb 26, 2016
1 parent a07a081 commit 0670fe0
Show file tree
Hide file tree
Showing 15 changed files with 58 additions and 64 deletions.
2 changes: 1 addition & 1 deletion console/src/main/scripts/bower.json
Expand Up @@ -42,7 +42,7 @@
"angular-utils-pagination": "0.9.4"
},
"devDependencies": {
"hawtio-core-dts": "2.0.23"
"hawtio-core-dts": "2.0.28"
},
"resolutions": {
"lodash": "~3.2.0",
Expand Down
Expand Up @@ -157,7 +157,7 @@ module HawkularMetrics {
if (res.id.indexOf(this.$routeParams.resourceId + '~/') === 0) {
tmpResourceList.push(res);
res.feedId = this.$routeParams.feedId;
res.selected = _.result(_.find(this.resourceList, { 'id': res.id }), 'selected');
res.selected = _.result(_.find(this.resourceList, { 'id': res.id }), 'selected') !== undefined;
promises.push(this.HawkularMetric.AvailabilityMetricData(this.$rootScope.currentPersona.id).query({
tenantId: tenantId,
availabilityId: MetricsService.getMetricId('A', res.feedId, res.id,
Expand Down
Expand Up @@ -255,7 +255,7 @@ module HawkularMetrics {
_.forEach(graphData, (item, key) => {
if (item.hasOwnProperty('length')) {
//TODO: when proper graph used change this
let value = (item['length'] === 'NaN') ? 0 : item['length'];
let value = (!_.isNumber(item['length'])) ? 0 : item['length'];
alertInfo.push(new AlertChartDataPoint(value,
parseInt(key.toString(), 10) * this.alertRound
));
Expand Down Expand Up @@ -289,7 +289,7 @@ module HawkularMetrics {
angular.forEach(resourceLists, (aResourceList) => {
angular.forEach(aResourceList, (res: IResource) => {
res.feedId = this.feedId;
if (res['id'].startsWith(new RegExp(this.$routeParams.resourceId + '~/'))) {
if (res.id.indexOf(this.$routeParams.resourceId + '~/') === 0) {
this.getAlertsInfo(res.feedId, res.id);
this.HawkularAlertRouterManager.registerForAlerts(
res.feedId + '/' + res.id,
Expand Down
Expand Up @@ -256,7 +256,7 @@ module HawkularMetrics {
}, this);
this.$q.all(availPromises).then((data) => {
let tmpChartFileSystemData = {};
_.forEach(data, (item) => {
_.forEach(data, (item: any) => {
if (!tmpChartFileSystemData[item.fileStoreId]) {
tmpChartFileSystemData[item.fileStoreId] = [];
}
Expand Down
Expand Up @@ -323,11 +323,11 @@ module HawkularMetrics {

_module.service('hkTimeUnit', HawkularMetrics.HkTimeUnit.Factory());
_module.service('hkTime', HawkularMetrics.HkTime);
_module.directive('hkFieldsetNotification', HawkularMetrics.HkFieldsetNotification.Factory());
_module.directive('hkAlertPanelList', HawkularMetrics.HkAlertPanelList.Factory());
_module.directive('hkAlertPanel', HawkularMetrics.HkAlertPanel.Factory());
_module.directive('hkTimeInterval', HawkularMetrics.HkTimeInterval.Factory());
_module.directive('hkFieldsetDampening', HawkularMetrics.HkFieldsetDampening.Factory());
_module.directive('hkAlertInfo', HawkularMetrics.HkAlertInfo.Factory());
_module.directive('hkAlertSummary', HawkularMetrics.HkAlertSummary.Factory());
_module.directive('hkFieldsetNotification', [HawkularMetrics.HkFieldsetNotification.Factory()]);
_module.directive('hkAlertPanelList', [HawkularMetrics.HkAlertPanelList.Factory()]);
_module.directive('hkAlertPanel', [HawkularMetrics.HkAlertPanel.Factory()]);
_module.directive('hkTimeInterval', [HawkularMetrics.HkTimeInterval.Factory()]);
_module.directive('hkFieldsetDampening', [HawkularMetrics.HkFieldsetDampening.Factory()]);
_module.directive('hkAlertInfo', [HawkularMetrics.HkAlertInfo.Factory()]);
_module.directive('hkAlertSummary', [HawkularMetrics.HkAlertSummary.Factory()]);
}
Expand Up @@ -37,5 +37,5 @@ module HawkularMetrics {
}
}

_module.directive('hkAlertNotification', HkAlertNotification.Factory());
_module.directive('hkAlertNotification', [HkAlertNotification.Factory()]);
}
Expand Up @@ -65,7 +65,7 @@ module HawkularMetrics {
}
}

_module.directive('hkSwitch', HawkularMetrics.HkSwitch.Factory());
_module.directive('hkSwitch', [HawkularMetrics.HkSwitch.Factory()]);

export class HkTimeInput {

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

_module.directive('hkTimeInput', HawkularMetrics.HkTimeInput.Factory());
_module.directive('hkTimeInput', [HawkularMetrics.HkTimeInput.Factory()]);

export class HkAutofocus {

Expand Down Expand Up @@ -158,6 +158,6 @@ module HawkularMetrics {
}
}

_module.directive('hkAutofocus', HawkularMetrics.HkAutofocus.Factory());
_module.directive('hkAutofocus', [HawkularMetrics.HkAutofocus.Factory()]);

}
Expand Up @@ -127,6 +127,6 @@ module HawkularMetrics {
}
}

_module.directive('hkPagination', HkPagination.Factory());
_module.directive('hkDataPagination', HkDataPagination.Factory());
_module.directive('hkPagination', [HkPagination.Factory()]);
_module.directive('hkDataPagination', [HkDataPagination.Factory()]);
}
Expand Up @@ -26,7 +26,7 @@ module HawkularMetrics {
_module.directive('hkValidFile', function() {
return {
require: 'ngModel',
link: function(scope, el, attrs, ngModel) {
link: function(scope: any, el: any, attrs: any, ngModel: any) {
//change event is fired when file is selected
el.bind('change', function() {
scope.$apply(function() {
Expand Down
61 changes: 27 additions & 34 deletions console/src/main/scripts/plugins/metrics/ts/explorer.ts
@@ -1,5 +1,5 @@
///
/// Copyright 2015 Red Hat, Inc. and/or its affiliates
/// Copyright 2015-2016 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");
Expand All @@ -25,9 +25,8 @@ module HawkularMetrics {
'$modal', '$window', 'HawkularInventory', 'HawkularMetric', 'MetricsService',
'ErrorsManager', '$q', '$sessionStorage', '$localStorage'];


public feeds = ['Test','Data'];
private title:string = 'Hello Explorer';
//private title:string = 'Hello Explorer';
public pleaseWait = true;
public resourceButtonEnabled = false;
private selectedFeed;
Expand All @@ -38,28 +37,26 @@ module HawkularMetrics {
private chartData = [];
private selectedMetric;
private buttonActive = false;
public startTimeStamp:TimestampInMillis;
public endTimeStamp:TimestampInMillis;
public startTimeStamp: TimestampInMillis;
public endTimeStamp: TimestampInMillis;
private chartType = [];
private chartUnit = [];



constructor(private $location:ng.ILocationService,
private $scope:any,
private $rootScope:any,
private $interval:ng.IIntervalService,
private $log:ng.ILogService,
private $routeParams:any,
private $modal:any,
private $window:any,
constructor(private $location: ng.ILocationService,
private $scope: any,
private $rootScope: any,
private $interval: ng.IIntervalService,
private $log: ng.ILogService,
private $routeParams: any,
private $modal: any,
private $window: any,
private HawkularInventory: any,
private HawkularMetric: any,
private MetricsService:IMetricsService,
private ErrorsManager:IErrorsManager,
private $q:ng.IQService,
private $sessionStorage:any,
private $localStorage:any
private MetricsService: IMetricsService,
private ErrorsManager: IErrorsManager,
private $q: ng.IQService,
private $sessionStorage: any,
private $localStorage: any
) {
$scope.exc = this;

Expand All @@ -68,7 +65,7 @@ module HawkularMetrics {
let tmp = $localStorage.hawkular_charts;
if (!angular.isUndefined(tmp)) {
this.charts = tmp;
_.forEach(tmp, (metric:any) => {
_.forEach(tmp, (metric: any) => {
this.$log.log('Found metric in storage: ' + metric.id);
});
if ($rootScope.currentPersona) {
Expand All @@ -87,11 +84,9 @@ module HawkularMetrics {
this.getFeeds();
}

private autoRefreshPromise: ng.IPromise<number>;

private autoRefreshPromise:ng.IPromise<number>;


private autoRefresh(intervalInSeconds:number):void {
private autoRefresh(intervalInSeconds: number): void {
this.autoRefreshPromise = this.$interval(() => {
this.refresh();
}, intervalInSeconds * 1000);
Expand All @@ -101,7 +96,7 @@ module HawkularMetrics {
});
}

private getFeeds():any {
private getFeeds(): any {

this.pleaseWait = true;

Expand All @@ -116,7 +111,7 @@ module HawkularMetrics {
});
}

public selectFeed(feed:string):void {
public selectFeed(feed: string): void {

this.selectedMetric = '';
this.selectedResource = '';
Expand All @@ -126,7 +121,7 @@ module HawkularMetrics {
}

private getResources(feed) {
this.pleaseWait=true;
this.pleaseWait = true;
this.HawkularInventory.ResourceUnderFeed.query({
feedId: feed.id
},
Expand All @@ -138,7 +133,7 @@ module HawkularMetrics {
);
};

public selectResource(resource:string):void {
public selectResource(resource: string): void {

this.selectedResource = resource;
this.selectedMetric = '';
Expand All @@ -165,7 +160,6 @@ module HawkularMetrics {
this.selectedMetric = metric;
this.buttonActive = true;


// this.showChart(); // TODO activate only after button press
}

Expand Down Expand Up @@ -205,11 +199,11 @@ module HawkularMetrics {
}

public refresh() {
if (this.charts ==null) {
if (this.charts == null) {
return;
}

_.forEach(this.charts, (res:any) => {
_.forEach(this.charts, (res: any) => {
let theId = res.id;
// TODO potentially replace with MetricsService....
if (res.type.type === 'GAUGE') {
Expand Down Expand Up @@ -261,8 +255,7 @@ module HawkularMetrics {
});
}


private addMetricToStorage():void {
private addMetricToStorage(): void {
this.$log.log('addMetricToStorage');
this.$localStorage.hawkular_charts = this.charts;
}
Expand Down
Expand Up @@ -136,19 +136,19 @@ module HawkularMetrics {
});
}

public static getMultiplier(response):number {
public static getMultiplier(response): number {
let ret = 1;
let min = Number.MAX_VALUE;
_.forEach(response, (point:IChartDataPoint) => {
_.forEach(response, (point: IChartDataPoint) => {
if (angular.isNumber(point.min)) {
min = Math.min(min, point.min);
}
});

while (min>1000) {
if ((min/1000) > 1) { // TODO 1000 / 1024 depending on input
min = min/1000;
ret*=1000; // TODO return an index and then use this to compute unit + scale
while (min > 1000) {
if ((min / 1000) > 1) { // TODO 1000 / 1024 depending on input
min = min / 1000;
ret *= 1000; // TODO return an index and then use this to compute unit + scale
}
}
return ret;
Expand Down
Expand Up @@ -247,7 +247,8 @@ module HawkularMetrics {

private getDurationAux(duration: number, pattern: string): any {
let result = [];
let durations = this.$filter('duration')(duration, pattern).split(' ');
const filterDuration: any = this.$filter('duration');
let durations = filterDuration(duration, pattern).split(' ');
_.each(pattern.split(' '), (unit: any, idx) => {
result.push({ value: durations[idx], unit: MetricsAvailabilityController.durationUnits[unit].unit });
}, this);
Expand Down
Expand Up @@ -29,7 +29,7 @@ module HawkularTopology {
selection: '=',
force: '='
},
link: ($scope, element, attributes) => {
link: ($scope: any, element: any, attributes: any) => {
element.css('display', 'block');

let graph;
Expand Down
Expand Up @@ -24,7 +24,7 @@ module HawkularTopology {
restrict: 'E',
transclude: true,
template: '<ng-transclude></ng-transclude>',
link: ($scope, element, attrs) => {
link: ($scope: any, element: any, attrs: any) => {
let kind = attrs.kind;
let value = $scope.vm.kinds[kind];

Expand Down
Expand Up @@ -129,7 +129,7 @@ module HawkularTopology {

const extractServerId = (id: string): string => id.substring(0, id.indexOf('/')) + '~';
const extractFeedId = (path: string): string => {
const feedChunk = path.split('/').filter((chunk) => chunk.startsWith('f;'));
const feedChunk = path.split('/').filter((chunk) => _.startsWith(chunk, 'f;'));
return feedChunk.length === 1 && feedChunk[0] ? feedChunk[0].slice(2) : 'localhost';
};

Expand All @@ -154,7 +154,7 @@ module HawkularTopology {
return;
}
let previousServerId;
angular.forEach(flatResources, (res) => {
angular.forEach(flatResources, (res: any) => {
const feedId = extractFeedId(res.path);
const newItem = {
kind: this.typeToKind[res.type.id],
Expand Down

0 comments on commit 0670fe0

Please sign in to comment.