From 0670fe04a1792ded58b54c07d2cb7e8ee13e905b Mon Sep 17 00:00:00 2001 From: Karel Hala Date: Wed, 24 Feb 2016 14:10:37 +0100 Subject: [PATCH] Fix typescript problems after updating to master Fix additional problems after updating hawtio.d.ts to 2.0.28 so we can use newer angular things, like components --- console/src/main/scripts/bower.json | 2 +- .../appServerDeploymentsDetails.ts | 2 +- .../app-details/appServerOverviewDetails.ts | 4 +- .../app-details/appServerPlatformDetails.ts | 2 +- .../metrics/ts/directives/alertDirective.ts | 14 ++--- .../alertSetupNotificationDirective.ts | 2 +- .../metrics/ts/directives/hkComponents.ts | 6 +- .../ts/directives/paginationDirectives.ts | 4 +- .../ts/directives/validFileDirective.ts | 2 +- .../scripts/plugins/metrics/ts/explorer.ts | 61 ++++++++----------- .../metrics/ts/services/metricsService.ts | 12 ++-- .../metrics/ts/urlAvailabilityDetails.ts | 3 +- .../directives/hawkularTopologyGraph.ts | 2 +- .../directives/hawkularTopologyIcon.ts | 2 +- .../plugins/topology/ts/topologyPlugin.ts | 4 +- 15 files changed, 58 insertions(+), 64 deletions(-) diff --git a/console/src/main/scripts/bower.json b/console/src/main/scripts/bower.json index fc408054..4e135191 100644 --- a/console/src/main/scripts/bower.json +++ b/console/src/main/scripts/bower.json @@ -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", diff --git a/console/src/main/scripts/plugins/metrics/ts/app-details/appServerDeploymentsDetails.ts b/console/src/main/scripts/plugins/metrics/ts/app-details/appServerDeploymentsDetails.ts index 7850c9a0..0db82d63 100644 --- a/console/src/main/scripts/plugins/metrics/ts/app-details/appServerDeploymentsDetails.ts +++ b/console/src/main/scripts/plugins/metrics/ts/app-details/appServerDeploymentsDetails.ts @@ -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, diff --git a/console/src/main/scripts/plugins/metrics/ts/app-details/appServerOverviewDetails.ts b/console/src/main/scripts/plugins/metrics/ts/app-details/appServerOverviewDetails.ts index d004f816..4c12a819 100644 --- a/console/src/main/scripts/plugins/metrics/ts/app-details/appServerOverviewDetails.ts +++ b/console/src/main/scripts/plugins/metrics/ts/app-details/appServerOverviewDetails.ts @@ -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 )); @@ -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, diff --git a/console/src/main/scripts/plugins/metrics/ts/app-details/appServerPlatformDetails.ts b/console/src/main/scripts/plugins/metrics/ts/app-details/appServerPlatformDetails.ts index b7aefe4f..3f0fe83e 100644 --- a/console/src/main/scripts/plugins/metrics/ts/app-details/appServerPlatformDetails.ts +++ b/console/src/main/scripts/plugins/metrics/ts/app-details/appServerPlatformDetails.ts @@ -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] = []; } diff --git a/console/src/main/scripts/plugins/metrics/ts/directives/alertDirective.ts b/console/src/main/scripts/plugins/metrics/ts/directives/alertDirective.ts index dba0eef2..8c24f03f 100644 --- a/console/src/main/scripts/plugins/metrics/ts/directives/alertDirective.ts +++ b/console/src/main/scripts/plugins/metrics/ts/directives/alertDirective.ts @@ -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()]); } diff --git a/console/src/main/scripts/plugins/metrics/ts/directives/alertSetupNotificationDirective.ts b/console/src/main/scripts/plugins/metrics/ts/directives/alertSetupNotificationDirective.ts index b75bb07d..89d5cfc9 100644 --- a/console/src/main/scripts/plugins/metrics/ts/directives/alertSetupNotificationDirective.ts +++ b/console/src/main/scripts/plugins/metrics/ts/directives/alertSetupNotificationDirective.ts @@ -37,5 +37,5 @@ module HawkularMetrics { } } - _module.directive('hkAlertNotification', HkAlertNotification.Factory()); + _module.directive('hkAlertNotification', [HkAlertNotification.Factory()]); } diff --git a/console/src/main/scripts/plugins/metrics/ts/directives/hkComponents.ts b/console/src/main/scripts/plugins/metrics/ts/directives/hkComponents.ts index 1c1f48c6..a9f4c781 100644 --- a/console/src/main/scripts/plugins/metrics/ts/directives/hkComponents.ts +++ b/console/src/main/scripts/plugins/metrics/ts/directives/hkComponents.ts @@ -65,7 +65,7 @@ module HawkularMetrics { } } - _module.directive('hkSwitch', HawkularMetrics.HkSwitch.Factory()); + _module.directive('hkSwitch', [HawkularMetrics.HkSwitch.Factory()]); export class HkTimeInput { @@ -122,7 +122,7 @@ module HawkularMetrics { } } - _module.directive('hkTimeInput', HawkularMetrics.HkTimeInput.Factory()); + _module.directive('hkTimeInput', [HawkularMetrics.HkTimeInput.Factory()]); export class HkAutofocus { @@ -158,6 +158,6 @@ module HawkularMetrics { } } - _module.directive('hkAutofocus', HawkularMetrics.HkAutofocus.Factory()); + _module.directive('hkAutofocus', [HawkularMetrics.HkAutofocus.Factory()]); } diff --git a/console/src/main/scripts/plugins/metrics/ts/directives/paginationDirectives.ts b/console/src/main/scripts/plugins/metrics/ts/directives/paginationDirectives.ts index c1bef2a1..3aa32627 100644 --- a/console/src/main/scripts/plugins/metrics/ts/directives/paginationDirectives.ts +++ b/console/src/main/scripts/plugins/metrics/ts/directives/paginationDirectives.ts @@ -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()]); } diff --git a/console/src/main/scripts/plugins/metrics/ts/directives/validFileDirective.ts b/console/src/main/scripts/plugins/metrics/ts/directives/validFileDirective.ts index de3329fe..a1d4788a 100644 --- a/console/src/main/scripts/plugins/metrics/ts/directives/validFileDirective.ts +++ b/console/src/main/scripts/plugins/metrics/ts/directives/validFileDirective.ts @@ -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() { diff --git a/console/src/main/scripts/plugins/metrics/ts/explorer.ts b/console/src/main/scripts/plugins/metrics/ts/explorer.ts index a8bbe558..41379f72 100755 --- a/console/src/main/scripts/plugins/metrics/ts/explorer.ts +++ b/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"); @@ -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; @@ -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; @@ -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) { @@ -87,11 +84,9 @@ module HawkularMetrics { this.getFeeds(); } + private autoRefreshPromise: ng.IPromise; - private autoRefreshPromise:ng.IPromise; - - - private autoRefresh(intervalInSeconds:number):void { + private autoRefresh(intervalInSeconds: number): void { this.autoRefreshPromise = this.$interval(() => { this.refresh(); }, intervalInSeconds * 1000); @@ -101,7 +96,7 @@ module HawkularMetrics { }); } - private getFeeds():any { + private getFeeds(): any { this.pleaseWait = true; @@ -116,7 +111,7 @@ module HawkularMetrics { }); } - public selectFeed(feed:string):void { + public selectFeed(feed: string): void { this.selectedMetric = ''; this.selectedResource = ''; @@ -126,7 +121,7 @@ module HawkularMetrics { } private getResources(feed) { - this.pleaseWait=true; + this.pleaseWait = true; this.HawkularInventory.ResourceUnderFeed.query({ feedId: feed.id }, @@ -138,7 +133,7 @@ module HawkularMetrics { ); }; - public selectResource(resource:string):void { + public selectResource(resource: string): void { this.selectedResource = resource; this.selectedMetric = ''; @@ -165,7 +160,6 @@ module HawkularMetrics { this.selectedMetric = metric; this.buttonActive = true; - // this.showChart(); // TODO activate only after button press } @@ -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') { @@ -261,8 +255,7 @@ module HawkularMetrics { }); } - - private addMetricToStorage():void { + private addMetricToStorage(): void { this.$log.log('addMetricToStorage'); this.$localStorage.hawkular_charts = this.charts; } diff --git a/console/src/main/scripts/plugins/metrics/ts/services/metricsService.ts b/console/src/main/scripts/plugins/metrics/ts/services/metricsService.ts index 0a62f3a1..7d27c958 100644 --- a/console/src/main/scripts/plugins/metrics/ts/services/metricsService.ts +++ b/console/src/main/scripts/plugins/metrics/ts/services/metricsService.ts @@ -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; diff --git a/console/src/main/scripts/plugins/metrics/ts/urlAvailabilityDetails.ts b/console/src/main/scripts/plugins/metrics/ts/urlAvailabilityDetails.ts index 813b0d73..06af346d 100644 --- a/console/src/main/scripts/plugins/metrics/ts/urlAvailabilityDetails.ts +++ b/console/src/main/scripts/plugins/metrics/ts/urlAvailabilityDetails.ts @@ -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); diff --git a/console/src/main/scripts/plugins/topology/directives/hawkularTopologyGraph.ts b/console/src/main/scripts/plugins/topology/directives/hawkularTopologyGraph.ts index 2ada011c..8bed40f3 100644 --- a/console/src/main/scripts/plugins/topology/directives/hawkularTopologyGraph.ts +++ b/console/src/main/scripts/plugins/topology/directives/hawkularTopologyGraph.ts @@ -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; diff --git a/console/src/main/scripts/plugins/topology/directives/hawkularTopologyIcon.ts b/console/src/main/scripts/plugins/topology/directives/hawkularTopologyIcon.ts index b1946794..7e4922d2 100644 --- a/console/src/main/scripts/plugins/topology/directives/hawkularTopologyIcon.ts +++ b/console/src/main/scripts/plugins/topology/directives/hawkularTopologyIcon.ts @@ -24,7 +24,7 @@ module HawkularTopology { restrict: 'E', transclude: true, template: '', - link: ($scope, element, attrs) => { + link: ($scope: any, element: any, attrs: any) => { let kind = attrs.kind; let value = $scope.vm.kinds[kind]; diff --git a/console/src/main/scripts/plugins/topology/ts/topologyPlugin.ts b/console/src/main/scripts/plugins/topology/ts/topologyPlugin.ts index 26f41012..0ce3dd7e 100644 --- a/console/src/main/scripts/plugins/topology/ts/topologyPlugin.ts +++ b/console/src/main/scripts/plugins/topology/ts/topologyPlugin.ts @@ -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'; }; @@ -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],