Skip to content

Commit

Permalink
Fix some ngResource integration issues.
Browse files Browse the repository at this point in the history
  • Loading branch information
mtho11 committed Feb 18, 2015
1 parent 5bc731c commit 4508d29
Show file tree
Hide file tree
Showing 16 changed files with 24 additions and 192 deletions.
73 changes: 7 additions & 66 deletions dist/hawkular-metrics.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,18 +39,12 @@ var HawkularMetrics;
this.resourceUrl = '';
}
AddUrlController.prototype.addUrl = function (url) {
var _this = this;
this.$log.debug("Adding Url to backend: " + url);
this.HawkularMetric.Metric.queryNum({ tenantId: 'test' }, function (data) {
console.dir(data);
_this.$log.debug("#Metrics: " + data.length);
});
this.registerFixedMetrics(this.tenantId);
this.$log.debug("Current url: " + this.$location.url());
this.$location.url("/metrics/metricsView");
};
AddUrlController.prototype.registerFixedMetrics = function (tenantId) {
this.HawkularMetric.Metric.queryNum({ tenantId: 'test' });
var result;
var webResponseTimeMetric = {
"name": "web.responseTime",
Expand Down Expand Up @@ -78,60 +72,6 @@ var HawkularMetrics;
HawkularMetrics._module.controller('HawkularMetrics.AddUrlController', AddUrlController);
})(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 || (HawkularMetrics = {}));

var HawkularMetrics;
(function (HawkularMetrics) {
HawkularMetrics.MetricsSelectionController = HawkularMetrics._module.controller("HawkularMetrics.MetricsSelectionController", ['$scope', function ($scope) {
Expand All @@ -142,13 +82,13 @@ var HawkularMetrics;
var HawkularMetrics;
(function (HawkularMetrics) {
var MetricsViewController = (function () {
function MetricsViewController($scope, $rootScope, $interval, $log, metricDataService, startTimeStamp, endTimeStamp, dateRange) {
function MetricsViewController($scope, $rootScope, $interval, $log, HawkularMetric, startTimeStamp, endTimeStamp, dateRange) {
var _this = this;
this.$scope = $scope;
this.$rootScope = $rootScope;
this.$interval = $interval;
this.$log = $log;
this.metricDataService = metricDataService;
this.HawkularMetric = HawkularMetric;
this.startTimeStamp = startTimeStamp;
this.endTimeStamp = endTimeStamp;
this.dateRange = dateRange;
Expand All @@ -157,6 +97,7 @@ var HawkularMetrics;
this.hideHighLowValues = false;
this.showPreviousRangeDataOverlay = false;
this.showContextZoom = true;
this.tenantId = 'test';
this.bucketedDataPoints = [];
this.contextDataPoints = [];
$scope.vm = this;
Expand Down Expand Up @@ -225,7 +166,7 @@ var HawkularMetrics;
startTime = this.startTimeStamp.getTime();
}
if (this.searchId !== '') {
this.metricDataService.getMetricsForTimeRange(this.searchId, new Date(startTime), new Date(endTime), 60).then(function (response) {
this.HawkularMetric.NumericMetricData.queryMetrics({ tenantId: this.tenantId, numericId: this.searchId, start: startTime, end: endTime, buckets: 60 }).$promise.then(function (response) {
console.dir(response);
_this.bucketedDataPoints = _this.formatBucketedChartOutput(response);
console.dir(_this.bucketedDataPoints);
Expand Down Expand Up @@ -272,7 +213,7 @@ var HawkularMetrics;
var _this = this;
var previousTimeRange = MetricsViewController.calculatePreviousTimeRange(this.startTimeStamp, this.endTimeStamp);
if (this.searchId !== '') {
this.metricDataService.getMetricsForTimeRange(this.searchId, previousTimeRange[0], previousTimeRange[1]).then(function (response) {
this.HawkularMetric.NumericMetricData.queryMetrics({ tenantId: this.tenantId, numericId: this.searchId, start: previousTimeRange[0], end: previousTimeRange[1], buckets: 60 }).$promise.then(function (response) {
var prevTimeRangeBucketedDataPoints = _this.formatPreviousBucketedOutput(response);
if (angular.isDefined(prevTimeRangeBucketedDataPoints) && prevTimeRangeBucketedDataPoints.length !== 0) {
_this.chartData = {
Expand Down Expand Up @@ -325,7 +266,7 @@ var HawkularMetrics;
this.$log.warn('Start Date was >= End Date');
return;
}
this.metricDataService.getMetricsForTimeRange(this.searchId, new Date(startTime), new Date(endTime), 300).then(function (response) {
this.HawkularMetric.NumericMetricData.queryMetrics({ tenantId: this.tenantId, numericId: this.searchId, start: startTime, end: endTime, buckets: 60 }).$promise.then(function (response) {
_this.chartData.contextDataPoints = _this.formatContextOutput(response);
if (angular.isUndefined(_this.chartData.contextDataPoints) || _this.chartData.contextDataPoints.length === 0) {
_this.noDataFoundForId(_this.searchId);
Expand All @@ -345,7 +286,7 @@ var HawkularMetrics;
};
});
};
MetricsViewController.$inject = ['$scope', '$rootScope', '$interval', '$log', 'metricDataService'];
MetricsViewController.$inject = ['$scope', '$rootScope', '$interval', '$log', 'HawkularMetric'];
return MetricsViewController;
})();
HawkularMetrics.MetricsViewController = MetricsViewController;
Expand Down
2 changes: 1 addition & 1 deletion plugins/metrics/bower.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
"toastr": "2.1.0",
"lodash": "2.4.1",
"hawkular-charts": "~0.1.13",
"hawkular-ui-services": "~0.1.3"
"hawkular-ui-services": "~0.1.4"
},
"devDependencies": {
"bootstrap": "3.3.2",
Expand Down
File renamed without changes.
4 changes: 0 additions & 4 deletions plugins/metrics/d.ts/metrics/ts/config.d.ts

This file was deleted.

4 changes: 0 additions & 4 deletions plugins/metrics/d.ts/metrics/ts/graphs.d.ts

This file was deleted.

2 changes: 0 additions & 2 deletions plugins/metrics/d.ts/metrics/ts/hawkularRestResource.d.ts

This file was deleted.

13 changes: 0 additions & 13 deletions plugins/metrics/d.ts/metrics/ts/metricDataService.d.ts

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/// <reference path="metricsPlugin.d.ts" />
declare module HawkularMetrics {
var AdvancedController: ng.IModule;
var MetricsSelectionController: ng.IModule;
}
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ declare module HawkularMetrics {
private $rootScope;
private $interval;
private $log;
private metricDataService;
private HawkularMetric;
startTimeStamp: Date;
endTimeStamp: Date;
dateRange: string;
Expand All @@ -47,7 +47,8 @@ declare module HawkularMetrics {
hideHighLowValues: boolean;
showPreviousRangeDataOverlay: boolean;
showContextZoom: boolean;
constructor($scope: any, $rootScope: ng.IRootScopeService, $interval: ng.IIntervalService, $log: ng.ILogService, metricDataService: any, startTimeStamp: Date, endTimeStamp: Date, dateRange: string);
private tenantId;
constructor($scope: any, $rootScope: ng.IRootScopeService, $interval: ng.IIntervalService, $log: ng.ILogService, HawkularMetric: any, startTimeStamp: Date, endTimeStamp: Date, dateRange: string);
private bucketedDataPoints;
private contextDataPoints;
private chartData;
Expand Down
9 changes: 4 additions & 5 deletions plugins/metrics/defs.d.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
/// <reference path="d.ts/includes.d.ts"/>
/// <reference path="d.ts/metrics/ts/metricsGlobals.d.ts"/>
/// <reference path="d.ts/metrics/ts/metricsPlugin.d.ts"/>
/// <reference path="d.ts/metrics/ts/addUrl.d.ts"/>
/// <reference path="d.ts/metrics/ts/metricDataService.d.ts"/>
/// <reference path="d.ts/metrics/ts/metricsSelection.d.ts"/>
/// <reference path="d.ts/metrics/ts/metricsView.d.ts"/>
/// <reference path="d.ts/metrics/ts/overview.d.ts"/>
/// <reference path="d.ts/metrics/ts/addUrlPage.d.ts"/>
/// <reference path="d.ts/metrics/ts/metricsSelectionPage.d.ts"/>
/// <reference path="d.ts/metrics/ts/metricsViewPage.d.ts"/>
/// <reference path="d.ts/metrics/ts/overviewPage.d.ts"/>
Original file line number Diff line number Diff line change
Expand Up @@ -35,11 +35,6 @@ module HawkularMetrics {

addUrl(url:string):void {
this.$log.debug("Adding Url to backend: " + url);
this.HawkularMetric.Metric.queryNum({tenantId: 'test'}, (data) => {
console.dir(data);
this.$log.debug("#Metrics: " + data.length);
});

this.registerFixedMetrics(this.tenantId);

this.$log.debug("Current url: " + this.$location.url());
Expand All @@ -56,7 +51,6 @@ module HawkularMetrics {
/// select metrics for the resource url
registerFixedMetrics(tenantId:string):void {
/// for now just register the two metrics
this.HawkularMetric.Metric.queryNum({tenantId: 'test'});

var result:any;
var webResponseTimeMetric = {
Expand Down
82 changes: 0 additions & 82 deletions plugins/metrics/plugins/metrics/ts/metricDataService.ts

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -81,19 +81,20 @@ module HawkularMetrics {
* @param metricDataService
*/
export class MetricsViewController implements IMetricsViewController {
public static $inject = ['$scope', '$rootScope', '$interval', '$log', 'metricDataService'];
public static $inject = ['$scope', '$rootScope', '$interval', '$log', 'HawkularMetric'];

searchId = '';
showAvgLine = true;
hideHighLowValues = false;
showPreviousRangeDataOverlay = false;
showContextZoom = true;
private tenantId = 'test';

constructor(private $scope:any,
private $rootScope:ng.IRootScopeService,
private $interval:ng.IIntervalService,
private $log:ng.ILogService,
private metricDataService,
private HawkularMetric:any,
public startTimeStamp:Date,
public endTimeStamp:Date,
public dateRange:string) {
Expand Down Expand Up @@ -210,8 +211,8 @@ module HawkularMetrics {

if (this.searchId !== '') {

this.metricDataService.getMetricsForTimeRange(this.searchId, new Date(startTime), new Date(endTime), 60)
.then((response) => {
this.HawkularMetric.NumericMetricData.queryMetrics({tenantId: this.tenantId, numericId: this.searchId, start: startTime, end: endTime, buckets: 60}).$promise
.then((response) => {
console.dir(response);
// we want to isolate the response from the data we are feeding to the chart
this.bucketedDataPoints = this.formatBucketedChartOutput(response);
Expand Down Expand Up @@ -268,7 +269,7 @@ module HawkularMetrics {
var previousTimeRange = MetricsViewController.calculatePreviousTimeRange(this.startTimeStamp, this.endTimeStamp);

if (this.searchId !== '') {
this.metricDataService.getMetricsForTimeRange(this.searchId, previousTimeRange[0], previousTimeRange[1])
this.HawkularMetric.NumericMetricData.queryMetrics({tenantId: this.tenantId, numericId: this.searchId, start: previousTimeRange[0], end: previousTimeRange[1], buckets: 60}).$promise
.then((response) => {
// we want to isolate the response from the data we are feeding to the chart
var prevTimeRangeBucketedDataPoints = this.formatPreviousBucketedOutput(response);
Expand Down Expand Up @@ -334,7 +335,8 @@ module HawkularMetrics {
return;
}

this.metricDataService.getMetricsForTimeRange(this.searchId, new Date(startTime), new Date(endTime), 300)

this.HawkularMetric.NumericMetricData.queryMetrics({tenantId: this.tenantId, numericId: this.searchId, start: startTime, end: endTime, buckets: 60}).$promise
.then((response) => {

this.chartData.contextDataPoints = this.formatContextOutput(response);
Expand Down

0 comments on commit 4508d29

Please sign in to comment.