Skip to content

Commit a527a9a

Browse files
committed
Using REST api first
1 parent 507a2e9 commit a527a9a

File tree

3 files changed

+24
-7
lines changed

3 files changed

+24
-7
lines changed

src/Pulse.Host/app/js/controllers.js

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,19 @@
33
/* Controllers */
44

55
angular.module('myApp.controllers', [])
6-
.controller('MyCtrl1', ['$scope', 'streamService', function ($scope, streamService) {
6+
.controller('MyCtrl1', ['$scope', 'streamService', 'serviceControlService', function ($scope, streamService, serviceControlService) {
77

8-
$scope.model = {success: 0, fail: 0};
8+
$scope.model = {active_endpoints: '?', number_of_failing_endpoints: '?'};
99

10-
streamService.subscribe($scope, 'HeartbeatSummary', function (message) {
10+
serviceControlService.getHeartbeatStats().then(function (stat) {
11+
$scope.model.active_endpoints = stat.active_endpoints;
12+
$scope.model.number_of_failing_endpoints = stat.number_of_failing_endpoints;
13+
});
14+
15+
streamService.subscribe($scope, 'HeartbeatSummaryChanged', function (message) {
1116
$scope.$apply(function (scope) {
12-
scope.model.success = message.active_endpoints;
13-
scope.model.fail = message.number_of_failing_endpoints;
17+
scope.model.active_endpoints = message.active_endpoints;
18+
scope.model.number_of_failing_endpoints = message.number_of_failing_endpoints;
1419
});
1520
});
1621

src/Pulse.Host/app/js/services.js

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,18 @@ angular.module('myApp.services', [])
4040
}])
4141
.service('serviceControlService', ['$http', 'serviceControlUrl', function($http, serviceControlUrl) {
4242

43+
this.getHeartbeatStats = function () {
44+
return $http.jsonp(serviceControlUrl + '/heartbeats/stats?callback=JSON_CALLBACK').then(function (response) {
45+
return response.data;
46+
});
47+
};
48+
49+
this.getHeartbeatsList = function () {
50+
return $http.jsonp(serviceControlUrl + '/heartbeats?callback=JSON_CALLBACK').then(function (response) {
51+
return response.data;
52+
});
53+
};
54+
4355
this.getEndpoints = function() {
4456
return $http.jsonp(serviceControlUrl + '/endpoints?callback=JSON_CALLBACK').then(function(response) {
4557
return response.data;
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<div ng-controller="MyCtrl1">
22
<h2>Heartbeats indicators</h2>
33
<div class="well">
4-
<a href="#/view2" class="btn btn-success btn-lg">{{model.success}} active endpoints</a>
5-
<a href="#/view2" class="btn btn-danger btn-lg">{{model.fail}} failing endpoints</a>
4+
<a href="#/view2" class="btn btn-success btn-lg">{{model.active_endpoints}} active endpoints</a>
5+
<a href="#/view2" class="btn btn-danger btn-lg">{{model.number_of_failing_endpoints}} failing endpoints</a>
66
</div>
77
</div>

0 commit comments

Comments
 (0)