Merge ~blake-rouse/maas:fix-vlan-editing into maas:master

Proposed by Blake Rouse
Status: Merged
Approved by: Blake Rouse
Approved revision: fb39255de8c15b3162db529707be971befebbae1
Merge reported by: MAAS Lander
Merged at revision: not available
Proposed branch: ~blake-rouse/maas:fix-vlan-editing
Merge into: maas:master
Diff against target: 244 lines (+146/-4)
6 files modified
src/maasserver/static/js/angular/controllers/space_details.js (+11/-0)
src/maasserver/static/js/angular/controllers/tests/test_space_details.js (+19/-0)
src/maasserver/static/js/angular/controllers/tests/test_vlan_details.js (+41/-0)
src/maasserver/static/js/angular/controllers/vlan_details.js (+22/-0)
src/maasserver/static/partials/space-details.html (+16/-2)
src/maasserver/static/partials/vlan-details.html (+37/-2)
Reviewer Review Type Date Requested Status
Andres Rodriguez (community) Approve
Review via email: mp+331455@code.launchpad.net

Commit message

LP: #1684085 - Add edit button to vlan and space details page.

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

lgtm!

review: Approve
Revision history for this message
MAAS Lander (maas-lander) wrote :

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/controllers/space_details.js b/src/maasserver/static/js/angular/controllers/space_details.js
2index c5707aa..5383c9a 100644
3--- a/src/maasserver/static/js/angular/controllers/space_details.js
4+++ b/src/maasserver/static/js/angular/controllers/space_details.js
5@@ -25,6 +25,7 @@ angular.module('MAAS').controller('SpaceDetailsController', [
6 $scope.spaceManager = SpacesManager;
7 $scope.subnets = SubnetsManager.getItems();
8 $scope.loaded = false;
9+ $scope.editSummary = false;
10
11 // Updates the page title.
12 function updateTitle() {
13@@ -68,6 +69,16 @@ angular.module('MAAS').controller('SpaceDetailsController', [
14 return UsersManager.isSuperUser();
15 };
16
17+ // Called when the "edit" button is cliked in the space summary
18+ $scope.enterEditSummary = function() {
19+ $scope.editSummary = true;
20+ };
21+
22+ // Called when the "cancel" button is cliked in the space summary
23+ $scope.exitEditSummary = function() {
24+ $scope.editSummary = false;
25+ };
26+
27 // Return true if this is the default Space
28 $scope.isDefaultSpace = function() {
29 if(!angular.isObject($scope.space)) {
30diff --git a/src/maasserver/static/js/angular/controllers/tests/test_space_details.js b/src/maasserver/static/js/angular/controllers/tests/test_space_details.js
31index 18b9967..2c66146 100644
32--- a/src/maasserver/static/js/angular/controllers/tests/test_space_details.js
33+++ b/src/maasserver/static/js/angular/controllers/tests/test_space_details.js
34@@ -175,6 +175,25 @@ describe("SpaceDetailsController", function() {
35 expect($rootScope.title).toBe(space.name);
36 });
37
38+ describe("enterEditSummary", function() {
39+
40+ it("sets editSummary", function() {
41+ var controller = makeController();
42+ $scope.enterEditSummary();
43+ expect($scope.editSummary).toBe(true);
44+ });
45+ });
46+
47+ describe("exitEditSummary", function() {
48+
49+ it("sets editSummary", function() {
50+ var controller = makeController();
51+ $scope.enterEditSummary();
52+ $scope.exitEditSummary();
53+ expect($scope.editSummary).toBe(false);
54+ });
55+ });
56+
57 describe("canBeDeleted", function() {
58
59 it("returns false if space is null", function() {
60diff --git a/src/maasserver/static/js/angular/controllers/tests/test_vlan_details.js b/src/maasserver/static/js/angular/controllers/tests/test_vlan_details.js
61index 9e30e59..d587327 100644
62--- a/src/maasserver/static/js/angular/controllers/tests/test_vlan_details.js
63+++ b/src/maasserver/static/js/angular/controllers/tests/test_vlan_details.js
64@@ -572,6 +572,47 @@ describe("VLANDetailsController", function() {
65 });
66 });
67
68+ describe("enterEditSummary", function() {
69+
70+ it("sets editSummary", function() {
71+ var controller = makeController();
72+ controller.enterEditSummary();
73+ expect(controller.editSummary).toBe(true);
74+ });
75+ });
76+
77+ describe("exitEditSummary", function() {
78+
79+ it("sets editSummary", function() {
80+ var controller = makeController();
81+ controller.enterEditSummary();
82+ controller.exitEditSummary();
83+ expect(controller.editSummary).toBe(false);
84+ });
85+ });
86+
87+ describe("getSpaceName", function() {
88+
89+ it("returns space name", function() {
90+ var controller = makeController();
91+ var spaceName = makeName("space");
92+ SpacesManager._items = [{
93+ id: 1,
94+ name: spaceName
95+ }];
96+ controller.vlan = {
97+ space: 1
98+ };
99+ expect(controller.getSpaceName()).toBe(spaceName);
100+ });
101+
102+ it("returns space (undefined)", function() {
103+ var controller = makeController();
104+ controller.vlan = {};
105+ expect(controller.getSpaceName()).toBe("(undefined)");
106+ });
107+ });
108+
109 describe("updatePossibleActions", function() {
110
111 // Note: updatePossibleActions() is called indirectly by these tests
112diff --git a/src/maasserver/static/js/angular/controllers/vlan_details.js b/src/maasserver/static/js/angular/controllers/vlan_details.js
113index 97a6f4b..6369092 100644
114--- a/src/maasserver/static/js/angular/controllers/vlan_details.js
115+++ b/src/maasserver/static/js/angular/controllers/vlan_details.js
116@@ -74,12 +74,34 @@ angular.module('MAAS').controller('VLANDetailsController', [
117 vm.provideDHCPAction = {};
118 vm.primaryRack = null;
119 vm.secondaryRack = null;
120+ vm.editSummary = false;
121+
122
123 // Return true if the authenticated user is super user.
124 vm.isSuperUser = function() {
125 return UsersManager.isSuperUser();
126 };
127
128+ // Called when the "edit" button is cliked in the vlan summary
129+ vm.enterEditSummary = function() {
130+ vm.editSummary = true;
131+ };
132+
133+ // Called when the "cancel" button is cliked in the vlan summary
134+ vm.exitEditSummary = function() {
135+ vm.editSummary = false;
136+ };
137+
138+ // Get the space name for the VLAN.
139+ vm.getSpaceName = function() {
140+ var space = SpacesManager.getItemFromList(vm.vlan.space);
141+ if(space) {
142+ return space.name;
143+ } else {
144+ return "(undefined)";
145+ }
146+ };
147+
148 // Get the aciton structure for the action with the specified name.
149 vm.getActionByName = function(name) {
150 var i;
151diff --git a/src/maasserver/static/partials/space-details.html b/src/maasserver/static/partials/space-details.html
152index 4230f85..856dd01 100644
153--- a/src/maasserver/static/partials/space-details.html
154+++ b/src/maasserver/static/partials/space-details.html
155@@ -45,15 +45,29 @@
156 <section class="row">
157 <div class="wrapper--inner">
158 <div class="twelve-col">
159- <h2>Space summary</h2>
160+ <h2 class="u-float--left">Space summary</h2>
161+ <button type="button" name="button" class="button--secondary button--inline u-float--right" data-ng-click="enterEditSummary()" data-ng-if="!editSummary">Edit</button>
162 </div>
163- <maas-obj-form obj="space" table-form="true" manager="spaceManager" data-ng-disabled="!isSuperUser()">
164+ <div class="twelve-col" data-ng-if="!editSummary">
165+ <dl class="six-col">
166+ <dt class="two-col">Name</dt>
167+ <dd class="four-col last-col">{$ space.name $}</dd>
168+ <dt class="two-col">Description</dt>
169+ <dd class="four-col last-col">{$ space.description $}</dd>
170+ </dl>
171+ </div>
172+ <maas-obj-form obj="space" table-form="true" manager="spaceManager" data-ng-disabled="!isSuperUser()" data-ng-if="editSummary" table-form="true" save-on-blur="false" after-save="exitEditSummary">
173 <fieldset class="form__fieldset six-col">
174 <maas-obj-field type="text" key="name" label="Name" placeholder="Space name"
175 label-width="two" input-width="three" blur-on-enter="true"></maas-obj-field>
176 <maas-obj-field type="textarea" key="description" label="Description" placeholder="Space description"
177 label-width="two" input-width="three" blur-on-enter="true"></maas-obj-field>
178 </fieldset>
179+ <div class="twelve-col u-align--right">
180+ <button class="button--base button--inline"
181+ data-ng-click="exitEditSummary()">Cancel</button>
182+ <button class="button--positive button--inline" maas-obj-save>Save summary</button>
183+ </div>
184 </maas-obj-form>
185 </div>
186 </section>
187diff --git a/src/maasserver/static/partials/vlan-details.html b/src/maasserver/static/partials/vlan-details.html
188index 1d33549..a653cdc 100644
189--- a/src/maasserver/static/partials/vlan-details.html
190+++ b/src/maasserver/static/partials/vlan-details.html
191@@ -222,9 +222,39 @@
192 <section class="row">
193 <div class="wrapper--inner">
194 <div class="twelve-col">
195- <h2>VLAN Summary</h2>
196+ <h2 class="u-float--left">VLAN Summary</h2>
197+ <button type="button" name="button" class="button--secondary button--inline u-float--right" data-ng-click="vlanDetails.enterEditSummary()" data-ng-if="!vlanDetails.editSummary">Edit</button>
198 </div>
199- <maas-obj-form obj="vlanDetails.vlan" manager="vlanDetails.vlanManager" data-ng-disabled="!vlanDetails.isSuperUser()">
200+ <div class="twelve-col" data-ng-if="!vlanDetails.editSummary">
201+ <dl class="six-col">
202+ <dt class="two-col">VID</dt>
203+ <dd class="four-col last-col">{$ vlanDetails.vlan.vid $}</dd>
204+ <dt class="two-col">Name</dt>
205+ <dd class="four-col last-col">{$ vlanDetails.vlan.name $}</dd>
206+ <dt class="two-col">MTU</dt>
207+ <dd class="four-col last-col">{$ vlanDetails.vlan.mtu $}</dd>
208+ <dt class="two-col">Space</dt>
209+ <dd class="four-col last-col">{$ vlanDetails.getSpaceName() $}</dd>
210+ <dt class="two-col">Description</dt>
211+ <dd class="four-col last-col">{$ vlanDetails.vlan.description $}</dd>
212+ </dl>
213+ <dl class="six-col last-col">
214+ <dt class="two-col">Fabric</dt>
215+ <dd class="four-col last-col">
216+ <a href="#/fabric/{$ vlanDetails.fabric.id $}">{$ vlanDetails.fabric.name $}</a>
217+ </dd>
218+ <div data-ng-if="vlanDetails.relatedControllers">
219+ <dt class="two-col">Rack controllers <span class="icon icon--help tooltip" aria-label="A rack controller controls hosts and images and runs network services&#xa;like DHCP for connected VLANs."></span></dt>
220+ <dd class="four-col last-col">
221+ <span data-ng-repeat="rack in vlanDetails.relatedControllers">
222+ <a href="#/node/controller/{$ rack.system_id $}">{$ rack.hostname $}</a>
223+ </span>&nbsp;
224+ </dd>
225+ </div>
226+ </dl>
227+ </div>
228+ <maas-obj-form obj="vlanDetails.vlan" manager="vlanDetails.vlanManager" data-ng-disabled="!vlanDetails.isSuperUser()" data-ng-if="vlanDetails.editSummary"
229+ table-form="true" save-on-blur="false" after-save="vlanDetails.exitEditSummary">
230 <fieldset class="form__fieldset six-col">
231 <maas-obj-field type="text" key="vid" label="VID" placeholder="VLAN VID"
232 label-width="two" input-width="three" blur-on-enter="true"></maas-obj-field>
233@@ -254,6 +284,11 @@
234 </div>
235 </dl>
236 </div>
237+ <div class="twelve-col u-align--right">
238+ <button class="button--base button--inline"
239+ data-ng-click="vlanDetails.exitEditSummary()">Cancel</button>
240+ <button class="button--positive button--inline" maas-obj-save>Save summary</button>
241+ </div>
242 </maas-obj-form>
243 </div>
244 </section>

Subscribers

People subscribed via source and target branches