Merge ~blake-rouse/maas:fix-service-status-card into maas:master

Proposed by Blake Rouse
Status: Merged
Approved by: Blake Rouse
Approved revision: 781c4295a02013549fc539f6cd8c24c566da9033
Merge reported by: MAAS Lander
Merged at revision: not available
Proposed branch: ~blake-rouse/maas:fix-service-status-card
Merge into: maas:master
Diff against target: 37 lines (+16/-1)
2 files modified
src/maasserver/static/js/angular/directives/controller_status.js (+1/-1)
src/maasserver/static/js/angular/directives/tests/test_controller_status.js (+15/-0)
Reviewer Review Type Date Requested Status
Mike Pontillo (community) Approve
MAAS Lander unittests Pending
Review via email: mp+343464@code.launchpad.net

Commit message

Fixes LP: #1763147 - Fix controller status watcher to be recursive.

To post a comment you must log in.
Revision history for this message
Mike Pontillo (mpontillo) wrote :

Looks good.

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1diff --git a/src/maasserver/static/js/angular/directives/controller_status.js b/src/maasserver/static/js/angular/directives/controller_status.js
2index e72607b..2100fb3 100644
3--- a/src/maasserver/static/js/angular/directives/controller_status.js
4+++ b/src/maasserver/static/js/angular/directives/controller_status.js
5@@ -89,7 +89,7 @@ angular.module('MAAS').directive('maasControllerStatus', [
6 // Watch the services array and the services on the controller,
7 // if any changes then update the status.
8 $scope.$watch("controller.service_ids", updateStatusClass);
9- $scope.$watchCollection("services", updateStatusClass);
10+ $scope.$watch("services", updateStatusClass, true);
11
12 // Update on creation.
13 updateStatusClass();
14diff --git a/src/maasserver/static/js/angular/directives/tests/test_controller_status.js b/src/maasserver/static/js/angular/directives/tests/test_controller_status.js
15index 3e77bff..20999e9 100644
16--- a/src/maasserver/static/js/angular/directives/tests/test_controller_status.js
17+++ b/src/maasserver/static/js/angular/directives/tests/test_controller_status.js
18@@ -146,4 +146,19 @@ describe("maasControllerStatus", function() {
19 var directive = compileDirective();
20 expect(directive.isolateScope().serviceClass).toBe("success");
21 });
22+
23+ it("update service status updates service class", function() {
24+ var services = [
25+ makeService("dead")
26+ ];
27+ ServicesManager._items.push.apply(
28+ ServicesManager._items, services);
29+ $scope.controller = makeController(services);
30+ var directive = compileDirective();
31+ expect(directive.isolateScope().serviceClass).toBe("power-error");
32+
33+ services[0].status = "running";
34+ $scope.$digest();
35+ expect(directive.isolateScope().serviceClass).toBe("success");
36+ });
37 });

Subscribers

People subscribed via source and target branches