Added proxy and emetting data every 10 sec
diff --git a/xos-apps/auto-scale/gui/src/index.html b/xos-apps/auto-scale/gui/src/index.html
index fec8ec4..7b9c168 100644
--- a/xos-apps/auto-scale/gui/src/index.html
+++ b/xos-apps/auto-scale/gui/src/index.html
@@ -64,7 +64,8 @@
<!-- inject:js -->
<script src="/.tmp/main.js"></script>
- <script src="/.tmp/autoscaling_details.js"></script>
+ <script src="/.tmp/autoscaling_details.directive.js"></script>
+ <script src="/.tmp/autoscaling.service.js"></script>
<!-- endinject -->
</div>
diff --git a/xos-apps/auto-scale/gui/src/js/autoscaling.service.js b/xos-apps/auto-scale/gui/src/js/autoscaling.service.js
new file mode 100644
index 0000000..4146f19
--- /dev/null
+++ b/xos-apps/auto-scale/gui/src/js/autoscaling.service.js
@@ -0,0 +1,17 @@
+'use strict';
+
+angular.module('autoscaling')
+.service('Autoscaling', function($http, $interval, $rootScope){
+
+ const pollingFrequency = 1;
+ var pollinginterval;
+
+ this.getAutoscalingData = () => {
+ pollinginterval = $interval(() => {
+ $http.get('/autoscaledata')
+ .then((res) => {
+ $rootScope.$emit('autoscaling.update', res.data);
+ });
+ }, pollingFrequency * 1000)
+ };
+});
\ No newline at end of file
diff --git a/xos-apps/auto-scale/gui/src/js/autoscaling_details.js b/xos-apps/auto-scale/gui/src/js/autoscaling_details.directive.js
similarity index 65%
rename from xos-apps/auto-scale/gui/src/js/autoscaling_details.js
rename to xos-apps/auto-scale/gui/src/js/autoscaling_details.directive.js
index f6fb4d6..e4bd9ef 100644
--- a/xos-apps/auto-scale/gui/src/js/autoscaling_details.js
+++ b/xos-apps/auto-scale/gui/src/js/autoscaling_details.directive.js
@@ -6,8 +6,10 @@
bindToController: true,
controllerAs: 'vm',
templateUrl: 'templates/service-container.tpl.html',
- controller: () => {
-
+ controller: ($rootScope) => {
+ $rootScope.$on('autoscaling.update', (evt, data) => {
+ console.log(data);
+ });
}
};
});
diff --git a/xos-apps/auto-scale/gui/src/js/main.js b/xos-apps/auto-scale/gui/src/js/main.js
index 5976fd9..665aafe 100644
--- a/xos-apps/auto-scale/gui/src/js/main.js
+++ b/xos-apps/auto-scale/gui/src/js/main.js
@@ -6,8 +6,9 @@
'ngAnimate',
'chart.js'
])
-.run(() => {
- console.log('autoscaling is running');
+.run((Autoscaling) => {
+ // start polling data
+ Autoscaling.getAutoscalingData();
})
.config(($stateProvider, $urlRouterProvider) => {
$stateProvider
@@ -15,6 +16,6 @@
url: '/',
template: '<service-container></service-container>'
});
-
+
$urlRouterProvider.otherwise('/');
});