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

Commit

Permalink
Fixing indentation for metricsPlugin.ts
Browse files Browse the repository at this point in the history
  • Loading branch information
ammendonca committed Jul 9, 2015
1 parent d4650fb commit 064c935
Showing 1 changed file with 156 additions and 156 deletions.
312 changes: 156 additions & 156 deletions console/src/main/scripts/plugins/metrics/ts/metricsPlugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,174 +20,174 @@

module HawkularMetrics {

export var _module = angular.module(HawkularMetrics.pluginName, ['ngResource', 'ui.select', 'hawkular.charts',
'hawkular.services', 'ui.bootstrap', 'topbar', 'patternfly.select', 'angular-momentjs', 'angular-md5']);
export var _module = angular.module(HawkularMetrics.pluginName, ['ngResource', 'ui.select', 'hawkular.charts',
'hawkular.services', 'ui.bootstrap', 'topbar', 'patternfly.select', 'angular-momentjs', 'angular-md5']);

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

_module.filter('firstUpper', function () {
return function (input, all) {
return (!!input) ? input.replace(/([^\W_]+[^\s-]*) */g, function (txt) {
return txt.charAt(0).toUpperCase() + txt.substr(1);
}) : '';
};
});
_module.filter('firstUpper', function () {
return function (input, all) {
return (!!input) ? input.replace(/([^\W_]+[^\s-]*) */g, function (txt) {
return txt.charAt(0).toUpperCase() + txt.substr(1);
}) : '';
};
});

/**
* Replicates AngularJS 1.4 limitTo filter
*/
_module.filter('limitTo14', function () {
return function(input, limit, begin) {
if (Math.abs(Number(limit)) === Infinity) {
limit = Number(limit);
} else {
limit = parseInt(limit, 10);
}
if (isNaN(limit)) { return input; }
/**
* Replicates AngularJS 1.4 limitTo filter
*/
_module.filter('limitTo14', function () {
return function(input, limit, begin) {
if (Math.abs(Number(limit)) === Infinity) {
limit = Number(limit);
} else {
limit = parseInt(limit, 10);
}
if (isNaN(limit)) { return input; }

if (typeof input === 'number') { input = input.toString(); }
if (!Array.isArray(input) && !(typeof input === 'string')) { return input; }
if (typeof input === 'number') { input = input.toString(); }
if (!Array.isArray(input) && !(typeof input === 'string')) { return input; }

begin = (!begin || isNaN(begin)) ? 0 : parseInt(begin, 10);
begin = (begin < 0 && begin >= -input.length) ? input.length + begin : begin;
begin = (!begin || isNaN(begin)) ? 0 : parseInt(begin, 10);
begin = (begin < 0 && begin >= -input.length) ? input.length + begin : begin;

if (limit >= 0) {
return input.slice(begin, begin + limit);
if (limit >= 0) {
return input.slice(begin, begin + limit);
} else {
if (begin === 0) {
return input.slice(limit, input.length);
} else {
if (begin === 0) {
return input.slice(limit, input.length);
} else {
return input.slice(Math.max(0, begin + limit), begin);
}
return input.slice(Math.max(0, begin + limit), begin);
}
};
});
}
};
});

_module.config(['$routeProvider', ($routeProvider) => {
$routeProvider.
// this was for single page.. remove ?
when('/hawkular/:resourceId/:timeOffset?/:endTime?', {templateUrl: 'plugins/metrics/html/single-page.html'}).
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
}).$promise;
resPromise.then(function (hkResourceList) {
$location.path('/metrics/response-time/' + hkResourceList[0].id);
}, function () {
$location.url('/error');
});
_module.config(['$routeProvider', ($routeProvider) => {
$routeProvider.
// this was for single page.. remove ?
when('/hawkular/:resourceId/:timeOffset?/:endTime?', {templateUrl: 'plugins/metrics/html/single-page.html'}).
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
}).$promise;
resPromise.then(function (hkResourceList) {
$location.path('/metrics/response-time/' + hkResourceList[0].id);
}, function () {
$location.url('/error');
});

// Returning a promise which would never be resolved, so that the page would not render.
// The page will be redirected before rendering based on the resource list loaded above.
return $q.defer().promise;
}
}
}).
when('/hawkular-ui/url/url-list', {templateUrl: 'plugins/metrics/html/add-url.html'}).
when('/hawkular-ui/url/response-time/:resourceId/:timeOffset?/:endTime?', {
templateUrl: 'plugins/metrics/html/response-time.html',
reloadOnSearch: false,
resolve: {
resource: function ($route, $location, HawkularInventory) {
var p = HawkularInventory.Resource.get({environmentId: globalEnvironmentId,
resourceId: $route.current.params.resourceId}).$promise;
p.then((response) => {
return response.properties.url;
},
(error) => {
toastr.info('You were redirected to this page because you requested an invalid URL.');
$location.path('/');
});
return p;
}
}
}).
when('/hawkular-ui/url/availability/:resourceId/:timeOffset?/:endTime?', {
templateUrl: 'plugins/metrics/html/availability.html',
reloadOnSearch: false,
resolve: {
resource: function ($route, $location, HawkularInventory) {
var p = HawkularInventory.Resource.get({environmentId: globalEnvironmentId,
resourceId: $route.current.params.resourceId}).$promise;
p.then((response) => {
return response.properties.url;
},
(error) => {
toastr.info('You were redirected to this page because you requested an invalid URL.');
$location.path('/');
});
return p;
}
}
}).
when('/hawkular-ui/url/alerts/:resourceId/:timeOffset?/:endTime?', {
templateUrl: 'plugins/metrics/html/alerts.html',
reloadOnSearch: false,
resolve: {
resource: function ($route, $location, HawkularInventory) {
var p = HawkularInventory.Resource.get({environmentId: globalEnvironmentId,
resourceId: $route.current.params.resourceId}).$promise;
p.then((response) => {
return response.properties.url;
},
(error) => {
toastr.info('You were redirected to this page because you requested an invalid URL.');
$location.path('/');
});
return p;
}
}
}).
when('/hawkular-ui/app/app-list', {templateUrl: 'plugins/metrics/html/app-server-list.html'}).
when('/hawkular-ui/app/app-details/:resourceId/:tabId/:timeOffset?/:endTime?', {
templateUrl: 'plugins/metrics/html/app-details/app-server-details.html',
reloadOnSearch: false,
resolve: {
resource: function ($route, $location, HawkularInventory) {
var redirectMissingAppServer = function() {
toastr.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 p = HawkularInventory.FeedResource.get({
environmentId: globalEnvironmentId,
feedId: globalFeedId,
resourceId: '[' + $route.current.params.resourceId + '~/]'
}).$promise;
p.then((response) => {
return response;
},
(error) => redirectMissingAppServer()
);
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 {
// Returning a promise which would never be resolved, so that the page would not render.
// The page will be redirected before rendering based on the resource list loaded above.
return $q.defer().promise;
}
}
}).
when('/hawkular-ui/url/url-list', {templateUrl: 'plugins/metrics/html/add-url.html'}).
when('/hawkular-ui/url/response-time/:resourceId/:timeOffset?/:endTime?', {
templateUrl: 'plugins/metrics/html/response-time.html',
reloadOnSearch: false,
resolve: {
resource: function ($route, $location, HawkularInventory) {
var p = HawkularInventory.Resource.get({environmentId: globalEnvironmentId,
resourceId: $route.current.params.resourceId}).$promise;
p.then((response) => {
return response.properties.url;
},
(error) => {
toastr.info('You were redirected to this page because you requested an invalid URL.');
$location.path('/');
});
return p;
}
}
}).
when('/hawkular-ui/url/availability/:resourceId/:timeOffset?/:endTime?', {
templateUrl: 'plugins/metrics/html/availability.html',
reloadOnSearch: false,
resolve: {
resource: function ($route, $location, HawkularInventory) {
var p = HawkularInventory.Resource.get({environmentId: globalEnvironmentId,
resourceId: $route.current.params.resourceId}).$promise;
p.then((response) => {
return response.properties.url;
},
(error) => {
toastr.info('You were redirected to this page because you requested an invalid URL.');
$location.path('/');
});
return p;
}
}
}).
when('/hawkular-ui/url/alerts/:resourceId/:timeOffset?/:endTime?', {
templateUrl: 'plugins/metrics/html/alerts.html',
reloadOnSearch: false,
resolve: {
resource: function ($route, $location, HawkularInventory) {
var p = HawkularInventory.Resource.get({environmentId: globalEnvironmentId,
resourceId: $route.current.params.resourceId}).$promise;
p.then((response) => {
return response.properties.url;
},
(error) => {
toastr.info('You were redirected to this page because you requested an invalid URL.');
$location.path('/');
});
return p;
}
}
}).
when('/hawkular-ui/app/app-list', {templateUrl: 'plugins/metrics/html/app-server-list.html'}).
when('/hawkular-ui/app/app-details/:resourceId/:tabId/:timeOffset?/:endTime?', {
templateUrl: 'plugins/metrics/html/app-details/app-server-details.html',
reloadOnSearch: false,
resolve: {
resource: function ($route, $location, HawkularInventory) {
var redirectMissingAppServer = function() {
toastr.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 p = HawkularInventory.FeedResource.get({
environmentId: globalEnvironmentId,
feedId: globalFeedId,
resourceId: '[' + $route.current.params.resourceId + '~/]'
}).$promise;
p.then((response) => {
return response;
},
(error) => redirectMissingAppServer()
);
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();
}
};
return isValidAppServer();
}
}
/*,
(error) => redirectMissingAppServer()*/
);
} else {
return checkAppServerExists();
}
}).
otherwise({redirectTo: '/hawkular-ui/url/url-list'});
}]);
};
return isValidAppServer();
}
}
}).
otherwise({redirectTo: '/hawkular-ui/url/url-list'});
}]);

hawtioPluginLoader.addModule(HawkularMetrics.pluginName);
hawtioPluginLoader.addModule(HawkularMetrics.pluginName);
}

0 comments on commit 064c935

Please sign in to comment.