Merge lp:~blake-rouse/maas/fix-1503474 into lp:~maas-committers/maas/trunk

Proposed by Blake Rouse
Status: Merged
Approved by: Blake Rouse
Approved revision: no longer in the source branch.
Merged at revision: 4467
Proposed branch: lp:~blake-rouse/maas/fix-1503474
Merge into: lp:~maas-committers/maas/trunk
Diff against target: 224 lines (+163/-1)
3 files modified
src/maasserver/static/js/angular/controllers/node_details.js (+54/-1)
src/maasserver/static/js/angular/controllers/tests/test_node_details.js (+84/-0)
src/maasserver/static/partials/node-details.html (+25/-0)
To merge this branch: bzr merge lp:~blake-rouse/maas/fix-1503474
Reviewer Review Type Date Requested Status
Andres Rodriguez (community) Approve
Review via email: mp+276722@code.launchpad.net

Commit message

Add the children devices on the node details page.

To post a comment you must log in.
Revision history for this message
Andres Rodriguez (andreserl) wrote :

Codewise, this lgtm! I have not tested it though. just one quick question. This section will only show up when there are containers associated right?

review: Approve
Revision history for this message
Andres Rodriguez (andreserl) wrote :

Oh, and for what I can see, we are showing device name, mac address, right? What about the IP address?

Revision history for this message
Blake Rouse (blake-rouse) wrote :

It only shows up when atleast one exists. Yes IP address is shown.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'src/maasserver/static/js/angular/controllers/node_details.js'
--- src/maasserver/static/js/angular/controllers/node_details.js 2015-11-02 03:34:34 +0000
+++ src/maasserver/static/js/angular/controllers/node_details.js 2015-11-05 02:32:14 +0000
@@ -38,7 +38,7 @@
38 skipStorage: false38 skipStorage: false
39 };39 };
40 $scope.checkingPower = false;40 $scope.checkingPower = false;
4141 $scope.devices = [];
4242
43 // Holds errors that are displayed on the details page.43 // Holds errors that are displayed on the details page.
44 $scope.errors = {44 $scope.errors = {
@@ -361,6 +361,56 @@
361 }361 }
362 }362 }
363363
364 // Update the devices array on the scope based on the device children
365 // on the node.
366 function updateDevices() {
367 $scope.devices = [];
368 angular.forEach($scope.node.devices, function(child) {
369 var device = {
370 name: child.fqdn
371 };
372
373 // Add the interfaces to the device object if any exists.
374 if(angular.isArray(child.interfaces) &&
375 child.interfaces.length > 0) {
376 angular.forEach(child.interfaces, function(nic, nicIdx) {
377 var deviceWithMAC = angular.copy(device);
378 deviceWithMAC.mac_address = nic.mac_address;
379
380 // Remove device name so it is not duplicated in the
381 // table since this is another MAC address on this
382 // device.
383 if(nicIdx > 0) {
384 deviceWithMAC.name = "";
385 }
386
387 // Add this links to the device object if any exists.
388 if(angular.isArray(nic.links) &&
389 nic.links.length > 0) {
390 angular.forEach(nic.links, function(link, lIdx) {
391 var deviceWithLink = angular.copy(
392 deviceWithMAC);
393 deviceWithLink.ip_address = link.ip_address;
394
395 // Remove the MAC address so it is not
396 // duplicated in the table since this is
397 // another link on this interface.
398 if(lIdx > 0) {
399 deviceWithLink.mac_address = "";
400 }
401
402 $scope.devices.push(deviceWithLink);
403 });
404 } else {
405 $scope.devices.push(deviceWithMAC);
406 }
407 });
408 } else {
409 $scope.devices.push(device);
410 }
411 });
412 }
413
364 // Starts the watchers on the scope.414 // Starts the watchers on the scope.
365 function startWatching() {415 function startWatching() {
366 // Update the title and name when the node fqdn changes.416 // Update the title and name when the node fqdn changes.
@@ -369,6 +419,9 @@
369 updateName();419 updateName();
370 });420 });
371421
422 // Update the devices on the node.
423 $scope.$watch("node.devices", updateDevices);
424
372 // Update the availableActionOptions when the node actions change.425 // Update the availableActionOptions when the node actions change.
373 $scope.$watch("node.actions", updateAvailableActionOptions);426 $scope.$watch("node.actions", updateAvailableActionOptions);
374427
375428
=== modified file 'src/maasserver/static/js/angular/controllers/tests/test_node_details.js'
--- src/maasserver/static/js/angular/controllers/tests/test_node_details.js 2015-11-02 03:34:34 +0000
+++ src/maasserver/static/js/angular/controllers/tests/test_node_details.js 2015-11-05 02:32:14 +0000
@@ -204,6 +204,8 @@
204 skipNetworking: false,204 skipNetworking: false,
205 skipStorage: false205 skipStorage: false
206 });206 });
207 expect($scope.checkingPower).toBe(false);
208 expect($scope.devices).toEqual([]);
207 });209 });
208210
209 it("sets initial values for summary section", function() {211 it("sets initial values for summary section", function() {
@@ -625,6 +627,7 @@
625627
626 expect(watches).toEqual([628 expect(watches).toEqual([
627 "node.fqdn",629 "node.fqdn",
630 "node.devices",
628 "node.actions",631 "node.actions",
629 "node.nodegroup.id",632 "node.nodegroup.id",
630 "node.architecture",633 "node.architecture",
@@ -668,6 +671,87 @@
668 [["architectures"], ["hwe_kernels"], ["osinfo"]]);671 [["architectures"], ["hwe_kernels"], ["osinfo"]]);
669 });672 });
670673
674 it("updates $scope.devices", function() {
675 var setActiveDefer = $q.defer();
676 spyOn(NodesManager, "setActiveItem").and.returnValue(
677 setActiveDefer.promise);
678 var defer = $q.defer();
679 var controller = makeController(defer);
680
681 node.devices = [
682 {
683 fqdn: "device1.maas",
684 interfaces: []
685 },
686 {
687 fqdn: "device2.maas",
688 interfaces: [
689 {
690 mac_address: "00:11:22:33:44:55",
691 links: []
692 }
693 ]
694 },
695 {
696 fqdn: "device3.maas",
697 interfaces: [
698 {
699 mac_address: "00:11:22:33:44:66",
700 links: []
701 },
702 {
703 mac_address: "00:11:22:33:44:77",
704 links: [
705 {
706 ip_address: "192.168.122.1"
707 },
708 {
709 ip_address: "192.168.122.2"
710 },
711 {
712 ip_address: "192.168.122.3"
713 }
714 ]
715 }
716 ]
717 }
718 ];
719
720 defer.resolve();
721 $rootScope.$digest();
722 setActiveDefer.resolve(node);
723 $rootScope.$digest();
724
725 expect($scope.devices).toEqual([
726 {
727 name: "device1.maas"
728 },
729 {
730 name: "device2.maas",
731 mac_address: "00:11:22:33:44:55"
732 },
733 {
734 name: "device3.maas",
735 mac_address: "00:11:22:33:44:66"
736 },
737 {
738 name: "",
739 mac_address: "00:11:22:33:44:77",
740 ip_address: "192.168.122.1"
741 },
742 {
743 name: "",
744 mac_address: "",
745 ip_address: "192.168.122.2"
746 },
747 {
748 name: "",
749 mac_address: "",
750 ip_address: "192.168.122.3"
751 }
752 ]);
753 });
754
671 describe("tagsAutocomplete", function() {755 describe("tagsAutocomplete", function() {
672756
673 it("calls TagsManager.autocomplete with query", function() {757 it("calls TagsManager.autocomplete with query", function() {
674758
=== modified file 'src/maasserver/static/partials/node-details.html'
--- src/maasserver/static/partials/node-details.html 2015-11-04 19:22:30 +0000
+++ src/maasserver/static/partials/node-details.html 2015-11-05 02:32:14 +0000
@@ -272,6 +272,31 @@
272 </form>272 </form>
273 </div>273 </div>
274 </div>274 </div>
275 <div class="row" data-ng-show="devices.length">
276 <div class="inner-wrapper">
277 <div class="twelve-col">
278 <h2 class="title">Containers and VMs</h2>
279 </div>
280 <div class="twelve-col">
281 <div class="table">
282 <header class="table__head">
283 <div class="table__row">
284 <div class="table__header table__column--30">Name</div>
285 <div class="table__header table__column--30">MAC</div>
286 <div class="table__header table__column--40">IP Address</div>
287 </div>
288 </header>
289 <main class="table__body" data-selected-rows>
290 <div class="table__row" data-ng-repeat="device in devices">
291 <div class="table__data table__column--30">{$ device.name $}</div>
292 <div class="table__data table__column--30">{$ device.mac_address $}</div>
293 <div class="table__data table__column--40">{$ device.ip_address $}</div>
294 </div>
295 </main>
296 </div>
297 </div>
298 </div>
299 </div>
275 <div class="row ng-hide" data-ng-show="isSuperUser()">300 <div class="row ng-hide" data-ng-show="isSuperUser()">
276 <div class="inner-wrapper">301 <div class="inner-wrapper">
277 <form class="disabled">302 <form class="disabled">