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

Commit

Permalink
Merge pull request #383 from ammendonca/HAWKULAR-495
Browse files Browse the repository at this point in the history
HAWKULAR-495 : Support servers in different feeds
  • Loading branch information
mtho11 committed Jul 31, 2015
2 parents da9a713 + 02edf37 commit 311e646
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 29 deletions.
3 changes: 0 additions & 3 deletions console/src/main/scripts/plugins/metrics/ts/metricsGlobals.ts
Expand Up @@ -31,7 +31,4 @@ module HawkularMetrics {

export var globalEnvironmentId = 'test';

/// This will be set when accessing a feed resource
export var globalFeedId = undefined;

}
41 changes: 15 additions & 26 deletions console/src/main/scripts/plugins/metrics/ts/metricsPlugin.ts
Expand Up @@ -24,7 +24,7 @@ module HawkularMetrics {
'hawkular.services', 'ui.bootstrap', 'topbar', 'patternfly.select', 'angular-momentjs', 'angular-md5', 'toastr']);

_module.config(['$httpProvider', '$locationProvider', '$routeProvider',
($httpProvider, $locationProvider, $routeProvider:ng.route.IRouteProvider) => {
($httpProvider, $locationProvider) => {
$locationProvider.html5Mode(true);
}]);

Expand Down Expand Up @@ -67,11 +67,11 @@ module HawkularMetrics {
resource: function ($route, $location, HawkularInventory, NotificationService:INotificationService) {
var p = HawkularInventory.Resource.get({environmentId: globalEnvironmentId,
resourceId: $route.current.params.resourceId}).$promise;
p.then((response) => {
p.then((response:any) => {
return response.properties.url;
},
(error) => {
this.NotificationService.info('You were redirected to this page because you requested an invalid URL.');
NotificationService.info('You were redirected to this page because you requested an invalid URL.');
$location.path('/');
});
return p;
Expand All @@ -85,11 +85,11 @@ module HawkularMetrics {
resource: function ($route, $location, HawkularInventory, NotificationService:INotificationService) {
var p = HawkularInventory.Resource.get({environmentId: globalEnvironmentId,
resourceId: $route.current.params.resourceId}).$promise;
p.then((response) => {
p.then((response:any) => {
return response.properties.url;
},
(error) => {
this.NotificationService.info('You were redirected to this page because you requested an invalid URL.');
NotificationService.info('You were redirected to this page because you requested an invalid URL.');
$location.path('/');
});
return p;
Expand All @@ -103,11 +103,11 @@ module HawkularMetrics {
resource: function ($route, $location, HawkularInventory, NotificationService:INotificationService) {
var p = HawkularInventory.Resource.get({environmentId: globalEnvironmentId,
resourceId: $route.current.params.resourceId}).$promise;
p.then((response) => {
p.then((response:any) => {
return response.properties.url;
},
(error) => {
this.NotificationService.info('You were redirected to this page because you requested an invalid URL.');
NotificationService.info('You were redirected to this page because you requested an invalid URL.');
$location.path('/');
});
return p;
Expand All @@ -121,14 +121,19 @@ module HawkularMetrics {
resolve: {
resource: function ($route, $location, HawkularInventory, NotificationService:INotificationService) {
var redirectMissingAppServer = function() {
this.NotificationService.info('You were redirected to this page because you requested an invalid ' +
NotificationService.info('You were redirected to this page because you requested an invalid ' +
'Application Server.');
$location.path('/hawkular-ui/app/app-list');
};
var checkAppServerExists = function() {
var idParts = $route.current.params.resourceId.split('~');
if (idParts.length !== 2) {
redirectMissingAppServer();
return;
}
var p = HawkularInventory.FeedResource.get({
environmentId: globalEnvironmentId,
feedId: globalFeedId,
feedId: idParts[0],
resourceId: $route.current.params.resourceId + '~/'
}).$promise;
p.then((response) => {
Expand All @@ -138,23 +143,7 @@ module HawkularMetrics {
);
return p;
};
var isValidAppServer = function() {
if (!globalFeedId) {
return HawkularInventory.Feed.query({environmentId: globalEnvironmentId}).$promise
.then((response) => {
globalFeedId = response.length && response[0].id;
if (globalFeedId) {
return checkAppServerExists();
}
}
/*,
(error) => redirectMissingAppServer()*/
);
} else {
return checkAppServerExists();
}
};
return isValidAppServer();
return checkAppServerExists();
}
}
}).
Expand Down

0 comments on commit 311e646

Please sign in to comment.