Skip to content

Commit

Permalink
add dashboard for emscloud
Browse files Browse the repository at this point in the history
  • Loading branch information
Alexander Demichev committed Feb 22, 2018
1 parent ac00928 commit 4e50770
Show file tree
Hide file tree
Showing 34 changed files with 522 additions and 227 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
/* global miqHttpInject */

angular.module('patternfly.card').controller('aggregateStatusCardController', ['$q', 'providerId', 'attributesHash', 'attributesIconHash', 'attributesUrl', 'API', 'miqService', function($q, providerId, attributesHash, attributesIconHash, attributesUrl, API, miqService) {
var vm = this;

var parserAttributesHash = JSON.parse(attributesHash);

var attributes = Object.keys(parserAttributesHash);

var parsedAttributesIconHash = JSON.parse(attributesIconHash);

var parsedAttributesUrl = JSON.parse(attributesUrl);

var init = function() {
ManageIQ.angular.scope = vm;
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 = {
"iconImage": "/assets/svg/vendor-" + getIcon(vm.provider.type) + ".svg",
"largeIcon": true,
};

vm.AggStatus = [];
for (var i = 0; i < attributes.length; i++) {
vm.AggStatus.push({
"id": parserAttributesHash[attributes[i]] + '_' + providerId,
"iconClass": parsedAttributesIconHash[attributes[i]],
"title": parserAttributesHash[attributes[i]],
"count": vm.provider[attributes[i]].length,
"href": getUrl(attributes[i]),
"notification": {
"iconClass": "pficon pficon-error-circle-o",
"count": 0,
},
});
}
});
};

var getIcon = function getIcon(providerType) {
var type = providerType.split("::");
return type[2].toLowerCase();
};

var getUrl = function(entity) {
return providerId + "?display=" + parsedAttributesUrl[entity];
};

init();
}]);
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,10 @@ angular.module('miq.util').factory('chartsMixin', ['$document', function($docume
},
cpuUsageDonutConfig: {
chartId: 'cpuDonutChart',
thresholds: { 'warning': '60', 'error': '90' },
thresholds: {
'warning': '60',
'error': '90',
},
},
memoryUsageConfig: {
chartId: 'memUsageChart',
Expand All @@ -66,7 +69,10 @@ angular.module('miq.util').factory('chartsMixin', ['$document', function($docume
},
memoryUsageDonutConfig: {
chartId: 'memoryDonutChart',
thresholds: { 'warning': '60', 'error': '90' },
thresholds: {
'warning': '60',
'error': '90',
},
},
recentHostsConfig: {
chartId: 'recentHostsChart',
Expand All @@ -76,9 +82,17 @@ angular.module('miq.util').factory('chartsMixin', ['$document', function($docume
contents: dailyTimeTooltip,
position: lineChartTooltipPositionFactory('recentHostsChart'),
},
point: {r: 1},
size: {height: 145},
grid: {y: {show: false}},
point: {
r: 1,
},
size: {
height: 145,
},
grid: {
y: {
show: false,
},
},
setAreaChart: true,
},
recentVmsConfig: {
Expand All @@ -89,16 +103,47 @@ angular.module('miq.util').factory('chartsMixin', ['$document', function($docume
contents: dailyTimeTooltip,
position: lineChartTooltipPositionFactory('recentVmsChart'),
},
point: {r: 1},
size: {height: 145},
grid: {y: {show: false}},
point: {
r: 1,
},
size: {
height: 145,
},
grid: {
y: {
show: false,
},
},
setAreaChart: true,
},
recentInstancesConfig: {
chartId: 'recentInstancesChart',
headTitle: __('Recent Instances'),
label: __('Instances'),
tooltip: {
contents: dailyTimeTooltip,
position: lineChartTooltipPositionFactory('recentInstancesChart'),
},
point: {
r: 1,
},
size: {
height: 145,
},
grid: {
y: {
show: false,
},
},
setAreaChart: true,
},
};

var processData = function(data, xDataLabel, yDataLabel) {
if (! data) {
return { dataAvailable: false };
return {
dataAvailable: false,
};
}
data.xData.unshift(xDataLabel);
data.yData.unshift(yDataLabel);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,15 +1,14 @@
/* global miqHttpInject */

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

var init = function() {
ManageIQ.angular.scope = vm;
vm.timeframeLabel = __('Last 30 Days');
var url = '/ems_infra_dashboard/cluster_metrics_data/' + providerId;
var heatmapPromise = $http.get(url)
var heatmapPromise = $http.get(heatmapUrl)
.then(function(response) {
vm.heatmapData = response.data.data;
})
Expand All @@ -29,10 +28,7 @@ angular.module( 'patternfly.charts' ).controller('heatmapController', ['$q', 'pr
vm.showLegends = true;
};

var heatmapTitles = {
"clusterCpuUsage": "CPU",
"clusterMemoryUsage": "Memory",
};
parsedHeatmapTitles = JSON.parse(heatmapTitles);

var processHeatmapData = function(heatmapsStruct, data) {
heatmapsStruct.data = {};
Expand All @@ -42,13 +38,13 @@ angular.module( 'patternfly.charts' ).controller('heatmapController', ['$q', 'pr

var heatmapData = function(d) {
var percent = -1;
var tooltip = __("Cluster: ") + d.node + "<br>" + __("Provider: ") + d.provider;
var tooltip = __(resourceType) + d.node + "<br>" + __("Provider: ") + d.provider;
if (d.percent === null || d.total === null) {
tooltip += "<br> " + __("Usage: Unknown");
} else {
percent = d.percent;
tooltip += "<br>" + __("Usage: ") + sprintf(__("%d%% in use of %d %s total"), (percent * 100).toFixed(0),
d.total, d.unit);
d.total, d.unit);
}
return {
"id": keys[i] + '_' + d.id,
Expand All @@ -58,14 +54,16 @@ angular.module( 'patternfly.charts' ).controller('heatmapController', ['$q', 'pr
};

for (var i in keys) {
if (keys[i] === 'title') { continue; }
if (keys[i] === 'title') {
continue;
}
if (data[keys[i]] === null) {
heatmapsStruct.data[heatmapTitles[keys[i]]] = [];
heatmapsStruct.data[parsedHeatmapTitles[keys[i]]] = [];
vm.dataAvailable = false;
} else {
heatmapsStructData = data[keys[i]].map(heatmapData);
}
heatmapsStruct.data[heatmapTitles[keys[i]]] = _.sortBy(heatmapsStructData, 'value').reverse();
heatmapsStruct.data[parsedHeatmapTitles[keys[i]]] = _.sortBy(heatmapsStructData, 'value').reverse();
}
} else {
heatmapsStruct.data = [];
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/* global miqHttpInject */
angular.module( 'patternfly.charts' ).controller( 'lineChartController', ['$q', 'providerId', '$http', 'chartsMixin', 'objectType', 'miqService', function($q, providerId, $http, chartsMixin, objectType, miqService) {
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() {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
/* global miqHttpInject */
angular.module('patternfly.charts').controller('recentResourceLineChartController', ['$q', '$http', 'chartName', 'recentResourceUrl', 'chartConf', 'chartsMixin', 'miqService', function($q, $http, chartName, recentResourceUrl, chartConf, chartsMixin, miqService) {
var vm = this;
vm.id = chartName;
var init = function() {
ManageIQ.angular.scope = vm;
vm.loadingDone = false;
vm.config = chartsMixin.chartConfig[chartConf];
vm.timeframeLabel = __('Last 30 Days');
var resourcesDataPromise = $http.get(recentResourceUrl)
.then(function(response) {
vm.data = response.data.data;
})
.catch(miqService.handleFailure);

$q.all([resourcesDataPromise]).then(function() {
if (vm.data.recentResources.dataAvailable === false) {
vm.data.dataAvailable = false;
} else {
vm.data = chartsMixin.processData(vm.data.recentResources, 'dates', vm.data.recentResources.config.label);
}
vm.loadingDone = true;
});

vm.custShowXAxis = false;
vm.custShowYAxis = false;
vm.custAreaChart = true;
};

init();
}]);
Original file line number Diff line number Diff line change
@@ -1,13 +1,11 @@
angular.module( 'patternfly.charts' ).controller('utilizationTrendChartController', ['$q', 'providerId', 'chartsMixin', '$http', 'miqService', function($q, providerId, chartsMixin, $http, miqService) {
angular.module('patternfly.charts').controller('utilizationTrendChartController', ['$q', 'providerId', 'utilizationUrl', 'chartsMixin', '$http', 'miqService', function($q, providerId, utilizationUrl, chartsMixin, $http, miqService) {
var vm = this;

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

var url = '/ems_infra_dashboard/ems_utilization_data/' + providerId;
var metricsPromise = $http.get(url)
var metricsPromise = $http.get(utilizationUrl)
.then(function(response) {
vm.metricsData = response.data.data;
})
Expand Down Expand Up @@ -42,7 +40,9 @@ angular.module( 'patternfly.charts' ).controller('utilizationTrendChartControlle
for (var i in keys) {
if (data[keys[i]] === null) {
metricsDataStruct.data[keys[i]] = {
'data': {dataAvailable: false},
'data': {
dataAvailable: false,
},
'config': {
'title': chartsMixin.chartConfig[keys[i] + 'UsageConfig'].title,
},
Expand All @@ -61,7 +61,9 @@ angular.module( 'patternfly.charts' ).controller('utilizationTrendChartControlle
}
}
} else {
metricsDataStruct.data = {dataAvailable: false};
metricsDataStruct.data = {
dataAvailable: false,
};
}
return metricsDataStruct.data;
};
Expand Down

This file was deleted.

Loading

0 comments on commit 4e50770

Please sign in to comment.