Formatting data to a flat list
diff --git a/xos-apps/auto-scale/gui/src/js/autoscaling.service.js b/xos-apps/auto-scale/gui/src/js/autoscaling.service.js
index 4146f19..15b9118 100644
--- a/xos-apps/auto-scale/gui/src/js/autoscaling.service.js
+++ b/xos-apps/auto-scale/gui/src/js/autoscaling.service.js
@@ -1,17 +1,43 @@
'use strict';
angular.module('autoscaling')
-.service('Autoscaling', function($http, $interval, $rootScope){
+.service('Autoscaling', function($http, $interval, $rootScope, lodash){
- const pollingFrequency = 1;
+ const pollingFrequency = 10;
var pollinginterval;
+ /**
+ * Convert data to a flat array of resources
+ */
+
+ this.formatData = (data) => {
+ const list = [];
+ // cicle trough all slices
+ lodash.map(data, (item) => {
+ // cicle trough every resource
+ item.resources = lodash.forEach(
+ Object.keys(item.resources),
+ (resource) => {
+ const tmp = item.resources[resource];
+ tmp.service = item.service;
+ tmp.slice = item.slice;
+ tmp.project_id = item.project_id;
+ tmp.instance_name = tmp.xos_instance_info.instance_name;
+ delete tmp.xos_instance_info;
+ list.push(tmp);
+ }
+ )
+ });
+ return list;
+ };
+
this.getAutoscalingData = () => {
- pollinginterval = $interval(() => {
- $http.get('/autoscaledata')
- .then((res) => {
- $rootScope.$emit('autoscaling.update', res.data);
+ // pollinginterval = $interval(() => {
+ // $http.get('/autoscaledata')
+ $http.get('../mocks/mock.json')
+ .success((res) => {
+ $rootScope.$emit('autoscaling.update', this.formatData(res));
});
- }, pollingFrequency * 1000)
+ // }, pollingFrequency * 1000)
};
});
\ No newline at end of file