diff --git a/bower.json b/bower.json index 4b104b6..b04a9da 100755 --- a/bower.json +++ b/bower.json @@ -25,7 +25,8 @@ "hawtio-core": "2.0.9", "hawtio-core-navigation": "2.0.17", "hawtio-utilities": "2.0.16", - "hawkular-charts": "~0.1.13" + "hawkular-charts": "~0.1.13", + "hawkular-ui-services": "~0.1.3" }, "devDependencies": { "bootstrap": "3.3.2", diff --git a/dist/hawkular-metrics.js b/dist/hawkular-metrics.js index c4aca87..e7d0ad2 100644 --- a/dist/hawkular-metrics.js +++ b/dist/hawkular-metrics.js @@ -12,7 +12,7 @@ var HawkularMetrics; HawkularMetrics._module = angular.module(HawkularMetrics.pluginName, ['hawkularCharts']); var metricsTab; HawkularMetrics._module.config(['$locationProvider', '$routeProvider', 'HawtioNavBuilderProvider', function ($locationProvider, $routeProvider, navBuilder) { - metricsTab = navBuilder.create().id(HawkularMetrics.pluginName).title(function () { return "Metrics"; }).href(function () { return "/metrics"; }).subPath("Graphs", "graphs", navBuilder.join(HawkularMetrics.templatePath, 'graphs.html')).subPath("Advanced", "advanced", navBuilder.join(HawkularMetrics.templatePath, 'advanced.html')).subPath("Config", "config", navBuilder.join(HawkularMetrics.templatePath, 'config.html')).build(); + metricsTab = navBuilder.create().id(HawkularMetrics.pluginName).title(function () { return "Metrics"; }).href(function () { return "/metrics"; }).subPath("Add Url", "addUrl", navBuilder.join(HawkularMetrics.templatePath, 'add-url.html')).subPath("Metrics Selection", "metricsSelection", navBuilder.join(HawkularMetrics.templatePath, 'metrics-selection.html')).subPath("Overview", "overview", navBuilder.join(HawkularMetrics.templatePath, 'overview.html')).subPath("Metrics View", "metricsView", navBuilder.join(HawkularMetrics.templatePath, 'metrics-view.html')).build(); navBuilder.configureRouting($routeProvider, metricsTab); $locationProvider.html5Mode(true); }]); @@ -25,22 +25,88 @@ var HawkularMetrics; var HawkularMetrics; (function (HawkularMetrics) { - HawkularMetrics.AdvancedController = HawkularMetrics._module.controller("HawkularMetrics.AdvancedController", ['$scope', function ($scope) { - $scope.advancedName = "Advanced Stuff"; - }]); + var AddUrlController = (function () { + function AddUrlController($scope, $log, resourceUrl) { + var _this = this; + this.$scope = $scope; + this.$log = $log; + this.resourceUrl = resourceUrl; + $scope.vm = this; + this.resourceUrl = ''; + $scope.$watch('vm.resourceUrl', function (newValue) { + if (angular.isDefined(newValue)) { + _this.$log.debug("Add New Resource Url: " + newValue); + } + }); + } + AddUrlController.prototype.addUrl = function (url) { + this.$log.debug("Adding Url to backend: " + url); + }; + AddUrlController.$inject = ['$scope', '$log']; + return AddUrlController; + })(); + HawkularMetrics.AddUrlController = AddUrlController; + HawkularMetrics._module.controller('HawkularMetrics.AddUrlController', AddUrlController); })(HawkularMetrics || (HawkularMetrics = {})); var HawkularMetrics; (function (HawkularMetrics) { - HawkularMetrics.ConfigController = HawkularMetrics._module.controller("HawkularMetrics.ConfigController", ['$scope', function ($scope) { - $scope.configName = "My Configuration"; - }]); + var MetricDataService = (function () { + function MetricDataService($q, $rootScope, $http, $log) { + this.$q = $q; + this.$rootScope = $rootScope; + this.$http = $http; + this.$log = $log; + } + MetricDataService.prototype.getBaseUrl = function () { + return 'http://127.0.0.1:8080/rhq-metrics/test/metrics'; + }; + MetricDataService.prototype.getAllMetrics = function () { + this.$log.info('-- Retrieving all metrics'); + var base = this.getBaseUrl() + '/?type=num', deferred = this.$q.defer(); + this.$http.get(base).success(function (data) { + deferred.resolve(data); + }).error(function (reason, status) { + console.error('Error Retrieving all metrics :' + status + ", " + reason); + toastr.warning('No Metrics retrieved.'); + deferred.reject(status + " - " + reason); + }); + return deferred.promise; + }; + MetricDataService.prototype.getMetricsForTimeRange = function (id, startDate, endDate, buckets) { + var _this = this; + this.$log.info('-- Retrieving metrics data for id: ' + id); + this.$log.info('-- Date Range: ' + startDate + ' - ' + endDate); + var numBuckets = buckets || 60, deferred = this.$q.defer(), searchParams = { + params: { + start: startDate.getTime(), + end: endDate.getTime(), + buckets: numBuckets + } + }; + if (startDate >= endDate) { + this.$log.warn("Start date was after end date"); + deferred.reject("Start date was after end date"); + } + this.$http.get(this.getBaseUrl() + '/numeric/' + id + '/data', searchParams).success(function (data) { + deferred.resolve(data); + }).error(function (reason, status) { + _this.$log.error('Error Loading Chart Data:' + status + ", " + reason); + deferred.reject(status + " - " + reason); + }); + return deferred.promise; + }; + MetricDataService.$inject = ['$q', '$rootScope', '$http', '$log']; + return MetricDataService; + })(); + HawkularMetrics.MetricDataService = MetricDataService; + HawkularMetrics._module.service('metricDataService', MetricDataService); })(HawkularMetrics || (HawkularMetrics = {})); var HawkularMetrics; (function (HawkularMetrics) { - var ChartController = (function () { - function ChartController($scope, $rootScope, $interval, $log, metricDataService, startTimeStamp, endTimeStamp, dateRange) { + var MetricsViewController = (function () { + function MetricsViewController($scope, $rootScope, $interval, $log, metricDataService, startTimeStamp, endTimeStamp, dateRange) { var _this = this; this.$scope = $scope; this.$rootScope = $rootScope; @@ -68,53 +134,53 @@ var HawkularMetrics; $scope.vm.startTimeStamp = timeRange[0]; $scope.vm.endTimeStamp = timeRange[1]; $scope.vm.dateRange = moment(timeRange[0]).from(moment(timeRange[1])); - $scope.vm.refreshHistoricalChartDataForTimestamp(startTimeStamp, endTimeStamp); + $scope.vm.refreshHistoricalChartDataForTimestamp(startTimeStamp.getTime(), endTimeStamp.getTime()); }); } - ChartController.prototype.noDataFoundForId = function (id) { + MetricsViewController.prototype.noDataFoundForId = function (id) { this.$log.warn('No Data found for id: ' + id); toastr.warning('No Data found for id: ' + id); }; - ChartController.prototype.calculatePreviousTimeRange = function (startDate, endDate) { + MetricsViewController.calculatePreviousTimeRange = function (startDate, endDate) { var previousTimeRange = []; var intervalInMillis = endDate.getTime() - startDate.getTime(); previousTimeRange.push(new Date(startDate.getTime() - intervalInMillis)); previousTimeRange.push(startDate); return previousTimeRange; }; - ChartController.prototype.showPreviousTimeRange = function () { - var previousTimeRange = this.calculatePreviousTimeRange(this.startTimeStamp, this.endTimeStamp); + MetricsViewController.prototype.showPreviousTimeRange = function () { + var previousTimeRange = MetricsViewController.calculatePreviousTimeRange(this.startTimeStamp, this.endTimeStamp); this.startTimeStamp = previousTimeRange[0]; this.endTimeStamp = previousTimeRange[1]; this.refreshHistoricalChartData(this.startTimeStamp, this.endTimeStamp); }; - ChartController.prototype.calculateNextTimeRange = function (startDate, endDate) { + MetricsViewController.calculateNextTimeRange = function (startDate, endDate) { var nextTimeRange = []; var intervalInMillis = endDate.getTime() - startDate.getTime(); nextTimeRange.push(endDate); nextTimeRange.push(new Date(endDate.getTime() + intervalInMillis)); return nextTimeRange; }; - ChartController.prototype.showNextTimeRange = function () { - var nextTimeRange = this.calculateNextTimeRange(this.startTimeStamp, this.endTimeStamp); + MetricsViewController.prototype.showNextTimeRange = function () { + var nextTimeRange = MetricsViewController.calculateNextTimeRange(this.startTimeStamp, this.endTimeStamp); this.startTimeStamp = nextTimeRange[0]; this.endTimeStamp = nextTimeRange[1]; this.refreshHistoricalChartData(this.startTimeStamp, this.endTimeStamp); }; - ChartController.prototype.hasNext = function () { - var nextTimeRange = this.calculateNextTimeRange(this.startTimeStamp, this.endTimeStamp); - return nextTimeRange[1].getTime() < _.now(); + MetricsViewController.prototype.hasNext = function () { + var nextTimeRange = MetricsViewController.calculateNextTimeRange(this.startTimeStamp, this.endTimeStamp); + return nextTimeRange[1].getTime() < new Date().getTime(); }; - ChartController.prototype.refreshChartDataNow = function (startTime) { + MetricsViewController.prototype.refreshChartDataNow = function (startTime) { var adjStartTimeStamp = moment().subtract('hours', 72).toDate(); this.$rootScope.$broadcast('MultiChartOverlayDataChanged'); this.endTimeStamp = new Date(); this.refreshHistoricalChartData(angular.isUndefined(startTime) ? adjStartTimeStamp : startTime, this.endTimeStamp); }; - ChartController.prototype.refreshHistoricalChartData = function (startDate, endDate) { + MetricsViewController.prototype.refreshHistoricalChartData = function (startDate, endDate) { this.refreshHistoricalChartDataForTimestamp(startDate.getTime(), endDate.getTime()); }; - ChartController.prototype.refreshHistoricalChartDataForTimestamp = function (startTime, endTime) { + MetricsViewController.prototype.refreshHistoricalChartDataForTimestamp = function (startTime, endTime) { var _this = this; if (angular.isUndefined(endTime)) { endTime = this.endTimeStamp.getTime(); @@ -145,7 +211,7 @@ var HawkularMetrics; }); } }; - ChartController.prototype.formatBucketedChartOutput = function (response) { + MetricsViewController.prototype.formatBucketedChartOutput = function (response) { return _.map(response.data, function (point) { return { timestamp: point.timestamp, @@ -158,7 +224,7 @@ var HawkularMetrics; }; }); }; - ChartController.prototype.togglePreviousRangeDataOverlay = function () { + MetricsViewController.prototype.togglePreviousRangeDataOverlay = function () { if (this.showPreviousRangeDataOverlay) { this.chartData.prevDataPoints = []; } @@ -166,9 +232,9 @@ var HawkularMetrics; this.overlayPreviousRangeData(); } }; - ChartController.prototype.overlayPreviousRangeData = function () { + MetricsViewController.prototype.overlayPreviousRangeData = function () { var _this = this; - var previousTimeRange = this.calculatePreviousTimeRange(this.startTimeStamp, this.endTimeStamp); + var previousTimeRange = MetricsViewController.calculatePreviousTimeRange(this.startTimeStamp, this.endTimeStamp); if (this.searchId !== '') { this.metricDataService.getMetricsForTimeRange(this.searchId, previousTimeRange[0], previousTimeRange[1]).then(function (response) { var prevTimeRangeBucketedDataPoints = _this.formatPreviousBucketedOutput(response); @@ -191,7 +257,7 @@ var HawkularMetrics; }); } }; - ChartController.prototype.formatPreviousBucketedOutput = function (response) { + MetricsViewController.prototype.formatPreviousBucketedOutput = function (response) { var _this = this; var mappedNew = _.map(response, function (point, i) { return { @@ -206,7 +272,7 @@ var HawkularMetrics; }); return mappedNew; }; - ChartController.prototype.toggleContextZoom = function () { + MetricsViewController.prototype.toggleContextZoom = function () { if (this.showContextZoom) { this.chartData.contextDataPoints = []; } @@ -214,9 +280,9 @@ var HawkularMetrics; this.refreshContextChart(); } }; - ChartController.prototype.refreshContextChart = function () { + MetricsViewController.prototype.refreshContextChart = function () { var _this = this; - var endTime = _.now(), startTime = moment().subtract('months', 24).valueOf(); + var endTime = moment().valueOf(), startTime = moment().subtract('months', 24).valueOf(); this.$log.debug('refreshChartContext'); if (this.searchId !== '') { if (startTime >= endTime) { @@ -233,7 +299,7 @@ var HawkularMetrics; }); } }; - ChartController.prototype.formatContextOutput = function (response) { + MetricsViewController.prototype.formatContextOutput = function (response) { return _.map(response, function (point) { return { timestamp: point.timestamp, @@ -243,67 +309,21 @@ var HawkularMetrics; }; }); }; - ChartController.$inject = ['$scope', '$rootScope', '$interval', '$log', 'metricDataService']; - return ChartController; + MetricsViewController.$inject = ['$scope', '$rootScope', '$interval', '$log', 'metricDataService']; + return MetricsViewController; })(); - HawkularMetrics.ChartController = ChartController; - HawkularMetrics._module.controller('ChartController', ChartController); + HawkularMetrics.MetricsViewController = MetricsViewController; + HawkularMetrics._module.controller('MetricsViewController', MetricsViewController); })(HawkularMetrics || (HawkularMetrics = {})); var HawkularMetrics; (function (HawkularMetrics) { - var MetricDataService = (function () { - function MetricDataService($q, $rootScope, $http, $log) { - this.$q = $q; - this.$rootScope = $rootScope; - this.$http = $http; - this.$log = $log; - } - MetricDataService.prototype.getBaseUrl = function () { - return 'http://127.0.0.1:8080/rhq-metrics/test/metrics'; - }; - MetricDataService.prototype.getAllMetrics = function () { - this.$log.info('-- Retrieving all metrics'); - var base = this.getBaseUrl() + '/?type=num', deferred = this.$q.defer(); - this.$http.get(base).success(function (data) { - deferred.resolve(data); - }).error(function (reason, status) { - console.error('Error Retrieving all metrics :' + status + ", " + reason); - toastr.warning('No Metrics retrieved.'); - deferred.reject(status + " - " + reason); - }); - return deferred.promise; - }; - MetricDataService.prototype.getMetricsForTimeRange = function (id, startDate, endDate, buckets) { - var _this = this; - this.$log.info('-- Retrieving metrics data for id: ' + id); - this.$log.info('-- Date Range: ' + startDate + ' - ' + endDate); - var numBuckets = buckets || 60, deferred = this.$q.defer(), searchParams = { - params: { - start: startDate.getTime(), - end: endDate.getTime(), - buckets: numBuckets - } - }; - if (startDate >= endDate) { - this.$log.warn("Start date was after end date"); - deferred.reject("Start date was after end date"); - } - this.$http.get(this.getBaseUrl() + '/numeric/' + id + '/data', searchParams).success(function (data) { - deferred.resolve(data); - }).error(function (reason, status) { - _this.$log.error('Error Loading Chart Data:' + status + ", " + reason); - deferred.reject(status + " - " + reason); - }); - return deferred.promise; - }; - MetricDataService.$inject = ['$q', '$rootScope', '$http', '$log']; - return MetricDataService; - })(); - HawkularMetrics.MetricDataService = MetricDataService; - HawkularMetrics._module.service('metricDataService', MetricDataService); + HawkularMetrics.OverviewController = HawkularMetrics._module.controller("HawkularMetrics.OverviewController", ['$scope', function ($scope) { + $scope.overview = "Over View"; + }]); })(HawkularMetrics || (HawkularMetrics = {})); -angular.module("hawkular-metrics-templates", []).run(["$templateCache", function($templateCache) {$templateCache.put("plugins/metrics/html/advanced.html","