Skip to content

Commit

Permalink
updating to new ui-services
Browse files Browse the repository at this point in the history
  • Loading branch information
jkremser committed Aug 21, 2015
1 parent 1c015a7 commit 68a430d
Show file tree
Hide file tree
Showing 7 changed files with 55 additions and 25 deletions.
2 changes: 1 addition & 1 deletion console/src/main/scripts/bower.json
Expand Up @@ -21,7 +21,7 @@
"angular-toastr": "1.4.1",
"bootstrap-select": "1.6",
"hawkular-charts": "~0.4.11",
"hawkular-ui-services": "~0.6.1",
"hawkular-ui-services": "Jiri-Kremser/hawkular-ui-services#HAWKULAR-565",
"hawtio-core-navigation": "2.0.51",
"hawtio-core": "2.0.16",
"hawtio-template-cache": "2.0.3",
Expand Down
Expand Up @@ -30,8 +30,8 @@ module Topbar {
}

export var TopbarController = _module.controller('Topbar.TopbarController',
['$scope', '$rootScope', '$location', '$route', '$routeParams', 'HawkularNav', 'HawkularInventory',
($scope, $rootScope, $location, $route, $routeParams, HawkularNav, HawkularInventory) => {
['$scope', '$rootScope', '$location', '$route', '$routeParams', 'HawkularNav',
($scope, $rootScope, $location, $route, $routeParams, HawkularNav) => {

$scope.getClass = function(path) {
return $location.path().indexOf(path) === 0 ? 'active' : '';
Expand Down
Expand Up @@ -102,8 +102,12 @@ module HawkularMetrics {
this.startTimeStamp = this.endTimeStamp - (this.$routeParams.timeOffset || 3600000);

var tenantId:TenantId = currentTenantId || this.$rootScope.currentPersona.id;
this.HawkularInventory.ResourceOfType.query({resourceTypeId: 'Datasource'},
(aResourceList, getResponseHeaders) => {
var idParts = this.$routeParams.resourceId.split('~');
var feedId = idParts[0];
this.HawkularInventory.ResourceOfTypeUnderFeed.query({
environmentId: globalEnvironmentId,
feedId: feedId,
resourceTypeId: 'Datasource'}, (aResourceList, getResponseHeaders) => {
var promises = [];
var tmpResourceList = [];
angular.forEach(aResourceList, function(res, idx) {
Expand Down
Expand Up @@ -84,8 +84,12 @@ module HawkularMetrics {
public getResourceList(currentTenantId?: TenantId): any {
this.alertList = []; // FIXME: when we have alerts for app server
var tenantId:TenantId = currentTenantId || this.$rootScope.currentPersona.id;
this.HawkularInventory.ResourceOfType.query({resourceTypeId: 'Deployment'},
(aResourceList, getResponseHeaders) => {
var idParts = this.$routeParams.resourceId.split('~');
var feedId = idParts[0];
this.HawkularInventory.ResourceOfTypeUnderFeed.query({
environmentId: globalEnvironmentId,
feedId: feedId,
resourceTypeId: 'Deployment'}, (aResourceList, getResponseHeaders) => {
var promises = [];
var tmpResourceList = [];
angular.forEach(aResourceList, function(res: any) {
Expand Down
Expand Up @@ -77,7 +77,7 @@ module HawkularMetrics {

var triggerId: string = this.resourceId + '_jvm_pheap';
var resourceId: string = triggerId.slice(0,-10);
var dataId: string = 'MI~R~[' + resourceId + '~/]~MT~WildFly Memory Metrics~Heap Used';
var dataId: string = 'MI~R~[' + resourceId + '~~]~MT~WildFly Memory Metrics~Heap Used';

return this.HawkularAlertsManager.createAlertDefinition({
name: triggerId,
Expand All @@ -104,7 +104,7 @@ module HawkularMetrics {

var triggerId: string = this.resourceId + '_jvm_nheap';
var resourceId: string = triggerId.slice(0,-10);
var dataId: string = 'MI~R~[' + resourceId + '~/]~MT~WildFly Memory Metrics~Heap Used';
var dataId: string = 'MI~R~[' + resourceId + '~~]~MT~WildFly Memory Metrics~Heap Used';

return this.HawkularAlertsManager.createAlertDefinition({
name: triggerId,
Expand All @@ -128,7 +128,7 @@ module HawkularMetrics {
// Jvm trigger doesn't exist, need to create one
var triggerId: string = this.resourceId + '_jvm_garba';
var resourceId: string = triggerId.slice(0,-10);
var dataId: string = 'MI~R~[' + resourceId + '~/]~MT~WildFly Memory Metrics~Accumulated GC Duration';
var dataId: string = 'MI~R~[' + resourceId + '~~]~MT~WildFly Memory Metrics~Accumulated GC Duration';

return this.HawkularAlertsManager.createAlertDefinition({
name: triggerId,
Expand Down
Expand Up @@ -81,10 +81,12 @@ module HawkularMetrics {
});
}

public getResourceList(currentTenantId?: TenantId):any {
public getResourceListForOneFeed(feedId: string, currentTenantId?: TenantId):any {
var tenantId:TenantId = currentTenantId || this.$rootScope.currentPersona.id;
this.HawkularInventory.ResourceOfType.query({resourceTypeId: 'WildFly Server', per_page: this.resPerPage,
page: this.resCurPage}, (aResourceList, getResponseHeaders) => {
this.HawkularInventory.ResourceOfTypeUnderFeed.query({
environmentId: globalEnvironmentId, feedId: feedId,
resourceTypeId: 'WildFly Server', per_page: this.resPerPage,
page: this.resCurPage}, (aResourceList, getResponseHeaders) => {
this.headerLinks = this.HkHeaderParser.parse(getResponseHeaders());
var promises = [];
angular.forEach(aResourceList, function(res, idx) {
Expand All @@ -100,7 +102,7 @@ module HawkularMetrics {
this.lastUpdateTimestamp = new Date();
}, this);
this.$q.all(promises).then((result) => {
this.resourceList = aResourceList;
this.resourceList = _.union(this.resourceList, aResourceList);
});
},
() => { // error
Expand All @@ -112,6 +114,17 @@ module HawkularMetrics {
});
}

public getResourceList(currentTenantId?: TenantId):any {
// for each feed get all WF resources
var tenantId:TenantId = currentTenantId || this.$rootScope.currentPersona.id;
this.HawkularInventory.Feed.query({environmentId:globalEnvironmentId},
(aFeedList) => {
angular.forEach(aFeedList, (feed) => {
this.getResourceListForOneFeed(feed.id, tenantId);
});
});
}

}

_module.controller('HawkularMetrics.AppServerListController', AppServerListController);
Expand Down
31 changes: 20 additions & 11 deletions console/src/main/scripts/plugins/metrics/ts/metricsPlugin.ts
Expand Up @@ -35,9 +35,12 @@ module HawkularMetrics {
when('/metrics/response-time', {
templateUrl: 'plugins/metrics/html/response-time.html',
resolve: {
hkResourceList: function ($filter, $location, $rootScope, $q, HawkularInventory) {
var resPromise = HawkularInventory.Resource.query({
environmentId: globalEnvironmentId
hkResourceList: function ($route, $filter, $location, $rootScope, $q, HawkularInventory) {
var idParts = $route.current.params.resourceId.split('~');
var feedId = idParts[0];
var resPromise = HawkularInventory.ResourceUnderFeed.query({
environmentId: globalEnvironmentId,
feedId: feedId
}).$promise;
resPromise.then(function (hkResourceList) {
$location.path('/metrics/response-time/' + hkResourceList[0].id);
Expand All @@ -57,8 +60,10 @@ module HawkularMetrics {
reloadOnSearch: false,
resolve: {
resource: function ($route, $location, HawkularInventory, NotificationsService:INotificationsService) {
var p = HawkularInventory.Resource.get({environmentId: globalEnvironmentId,
resourceId: $route.current.params.resourceId}).$promise;
var idParts = $route.current.params.resourceId.split('~');
var feedId = idParts[0];
var p = HawkularInventory.ResourceUnderFeed.get({environmentId: globalEnvironmentId,
feedId: feedId, resourceId: $route.current.params.resourceId}).$promise;
p.then((response:any) => {
return response.properties.url;
},
Expand All @@ -75,8 +80,10 @@ module HawkularMetrics {
reloadOnSearch: false,
resolve: {
resource: function ($route, $location, HawkularInventory, NotificationsService:INotificationsService) {
var p = HawkularInventory.Resource.get({environmentId: globalEnvironmentId,
resourceId: $route.current.params.resourceId}).$promise;
var idParts = $route.current.params.resourceId.split('~');
var feedId = idParts[0];
var p = HawkularInventory.ResourceUnderFeed.get({environmentId: globalEnvironmentId,
feedId: feedId, resourceId: $route.current.params.resourceId}).$promise;
p.then((response:any) => {
return response.properties.url;
},
Expand All @@ -93,8 +100,10 @@ module HawkularMetrics {
reloadOnSearch: false,
resolve: {
resource: function ($route, $location, HawkularInventory, NotificationsService:INotificationsService) {
var p = HawkularInventory.Resource.get({environmentId: globalEnvironmentId,
resourceId: $route.current.params.resourceId}).$promise;
var idParts = $route.current.params.resourceId.split('~');
var feedId = idParts[0];
var p = HawkularInventory.ResourceUnderFeed.get({environmentId: globalEnvironmentId,
feedId: feedId, resourceId: $route.current.params.resourceId}).$promise;
p.then((response:any) => {
return response.properties.url;
},
Expand Down Expand Up @@ -123,10 +132,10 @@ module HawkularMetrics {
redirectMissingAppServer();
return;
}
var p = HawkularInventory.FeedResource.get({
var p = HawkularInventory.ResourceUnderFeed.get({
environmentId: globalEnvironmentId,
feedId: idParts[0],
resourceId: $route.current.params.resourceId + '~/'
resourceId: $route.current.params.resourceId + '~~'
}).$promise;
p.then((response) => {
return response;
Expand Down

0 comments on commit 68a430d

Please sign in to comment.