Skip to content

Commit

Permalink
Fixed miq_bootstrap call
Browse files Browse the repository at this point in the history
- Added .catch to all API/http request calls.

https://www.pivotaltracker.com/story/show/147962059
  • Loading branch information
h-kataria committed Oct 9, 2017
1 parent 0921480 commit 7465f68
Show file tree
Hide file tree
Showing 7 changed files with 37 additions and 25 deletions.
@@ -1,6 +1,6 @@
/* global miqHttpInject */

angular.module( 'patternfly.card' ).controller('aggregateStatusCardController', ['$q', 'providerId', 'API', function($q, providerId, API) {
angular.module( 'patternfly.card' ).controller('aggregateStatusCardController', ['$q', 'providerId', 'API', 'miqService', function($q, providerId, API, miqService) {
var vm = this;
var attributes = ["ems_clusters", "hosts", "storages", "vms", "miq_templates"];
var attrHsh = {
Expand Down Expand Up @@ -29,9 +29,11 @@ angular.module( 'patternfly.card' ).controller('aggregateStatusCardController',

var init = function() {
ManageIQ.angular.scope = vm;
var promiseProviderData = API.get("/api/providers/" + providerId + "?attributes=" + attributes).then(function(data) {
vm.provider = data;
});
var promiseProviderData = API.get("/api/providers/" + providerId + "?attributes=" + attributes)
.then(function(data) {
vm.provider = data;
})
.catch(miqService.handleFailure);

$q.all([promiseProviderData]).then(function() {
vm.status = {
Expand Down
@@ -1,16 +1,18 @@
/* global miqHttpInject */

angular.module( 'patternfly.charts' ).controller('heatmapController', ['$q', 'providerId', '$http', function($q, providerId, $http) {
angular.module( 'patternfly.charts' ).controller('heatmapController', ['$q', 'providerId', '$http', 'miqService', function($q, providerId, $http, miqService) {
var vm = this;
vm.id = "heatmap_" + providerId;
vm.data = {};

var init = function() {
ManageIQ.angular.scope = vm;
var url = '/ems_infra_dashboard/cluster_metrics_data/' + providerId;
var heatmapPromise = $http.get(url).then(function(response) {
vm.heatmapData = response.data.data;
});
var heatmapPromise = $http.get(url)
.then(function(response) {
vm.heatmapData = response.data.data;
})
.catch(miqService.handleFailure);

$q.all([heatmapPromise]).then(function() {
vm.title = vm.heatmapData.heatmaps.title;
Expand Down
@@ -1,14 +1,16 @@
/* global miqHttpInject */
angular.module( 'patternfly.charts' ).controller( 'lineChartController', ['$q', 'providerId', '$http', 'chartsMixin', 'objectType', function($q, providerId, $http, chartsMixin, objectType ) {
angular.module( 'patternfly.charts' ).controller( 'lineChartController', ['$q', 'providerId', '$http', 'chartsMixin', 'objectType', 'miqService', function($q, providerId, $http, chartsMixin, objectType, miqService) {
var vm = this;
vm.id = "lineChart_" + providerId;
var init = function() {
ManageIQ.angular.scope = vm;
vm.config = chartsMixin.chartConfig['recent' + objectType + 'Config'];
var url = '/ems_infra_dashboard/recent_objects_data/' + providerId + '?object_type=' + objectType;
var dataPromise = $http.get(url).then(function(response) {
vm.data = response.data.data;
});
var dataPromise = $http.get(url)
.then(function(response) {
vm.data = response.data.data;
})
.catch(miqService.handleFailure);

$q.all([dataPromise]).then(function() {
vm.data = chartsMixin.processData(vm.data.recentData, 'dates', vm.data.recentData.config.label);
Expand Down
@@ -1,14 +1,16 @@
/* global miqHttpInject */
angular.module( 'patternfly.charts' ).controller( 'recentHostsLineChartController', ['$q', 'providerId', '$http', 'chartsMixin', function($q, providerId, $http, chartsMixin ) {
angular.module( 'patternfly.charts' ).controller( 'recentHostsLineChartController', ['$q', 'providerId', '$http', 'chartsMixin', 'miqService', function($q, providerId, $http, chartsMixin, miqService) {
var vm = this;
vm.id = "recentHostsLineChart_" + providerId;
var init = function() {
ManageIQ.angular.scope = vm;
vm.config = chartsMixin.chartConfig.recentHostsConfig;
var url = '/ems_infra_dashboard/recent_hosts_data/' + providerId;
var hostsDataPromise = $http.get(url).then(function(response) {
vm.data = response.data.data;
});
var hostsDataPromise = $http.get(url)
.then(function(response) {
vm.data = response.data.data;
})
.catch(miqService.handleFailure);

$q.all([hostsDataPromise]).then(function() {
if (vm.data.recentHosts.dataAvailable === false) {
Expand Down
@@ -1,14 +1,16 @@
/* global miqHttpInject */
angular.module( 'patternfly.charts' ).controller( 'recentVmsLineChartController', ['$q', 'providerId', '$http', 'chartsMixin', function($q, providerId, $http, chartsMixin ) {
angular.module( 'patternfly.charts' ).controller( 'recentVmsLineChartController', ['$q', 'providerId', '$http', 'chartsMixin', 'miqService', function($q, providerId, $http, chartsMixin, miqService) {
var vm = this;
vm.id = "recentVmsLineChart_" + providerId;
var init = function() {
ManageIQ.angular.scope = vm;
vm.config = chartsMixin.chartConfig.recentVmsConfig;
var url = '/ems_infra_dashboard/recent_vms_data/' + providerId;
var vmsDataPromise = $http.get(url).then(function(response) {
vm.data = response.data.data;
});
var vmsDataPromise = $http.get(url)
.then(function(response) {
vm.data = response.data.data;
})
.catch(miqService.handleFailure);

$q.all([vmsDataPromise]).then(function() {
if (vm.data.recentVms.dataAvailable === false) {
Expand Down
@@ -1,14 +1,16 @@
angular.module( 'patternfly.charts' ).controller('utilizationTrendChartController', ['$q', 'providerId', 'chartsMixin', '$http', function($q, providerId, chartsMixin, $http) {
angular.module( 'patternfly.charts' ).controller('utilizationTrendChartController', ['$q', 'providerId', 'chartsMixin', '$http', 'miqService', function($q, providerId, chartsMixin, $http, miqService) {
var vm = this;

var init = function() {
ManageIQ.angular.scope = vm;
vm.data = {};

var url = '/ems_infra_dashboard/ems_utilization_data/' + providerId;
var metricsPromise = $http.get(url).then(function(response) {
vm.metricsData = response.data.data;
});
var metricsPromise = $http.get(url)
.then(function(response) {
vm.metricsData = response.data.data;
})
.catch(miqService.handleFailure);

$q.all([metricsPromise]).then(function() {
vm.data = processMetricsData(vm.data, vm.metricsData.ems_utilization);
Expand Down
2 changes: 1 addition & 1 deletion app/views/ems_infra/_show_dashboard.html.haml
Expand Up @@ -13,4 +13,4 @@

:javascript
ManageIQ.angular.app.value('providerId', '#{@record.id}');
miq_bootstrap('.ems-infra-dashboard', '');
miq_bootstrap('.ems-infra-dashboard');

0 comments on commit 7465f68

Please sign in to comment.