Merge lp:~mpontillo/maas/fix-ip-range-ordering--bug-1671517 into lp:~maas-committers/maas/trunk

Proposed by Mike Pontillo
Status: Merged
Approved by: Andres Rodriguez
Approved revision: no longer in the source branch.
Merged at revision: 5974
Proposed branch: lp:~mpontillo/maas/fix-ip-range-ordering--bug-1671517
Merge into: lp:~maas-committers/maas/trunk
Diff against target: 77 lines (+34/-5)
3 files modified
src/maasserver/static/js/angular/directives/ipranges.js (+12/-2)
src/maasserver/static/js/angular/directives/tests/test_ipranges.js (+20/-0)
src/maasserver/static/partials/ipranges.html (+2/-3)
To merge this branch: bzr merge lp:~mpontillo/maas/fix-ip-range-ordering--bug-1671517
Reviewer Review Type Date Requested Status
Lee Trager (community) Approve
Review via email: mp+322493@code.launchpad.net

Commit message

Fix sorting of IP ranges on subnet details page.

To post a comment you must log in.
Revision history for this message
Lee Trager (ltrager) wrote :

LGTM!

review: Approve
Revision history for this message
MAAS Lander (maas-lander) wrote :
Download full text (1.9 MiB)

The attempt to merge lp:~mpontillo/maas/fix-ip-range-ordering--bug-1671517 into lp:maas failed. Below is the output from the failed tests.

Hit:1 http://prodstack-zone-2.clouds.archive.ubuntu.com/ubuntu xenial InRelease
Get:2 http://prodstack-zone-2.clouds.archive.ubuntu.com/ubuntu xenial-updates InRelease [102 kB]
Get:3 http://prodstack-zone-2.clouds.archive.ubuntu.com/ubuntu xenial-backports InRelease [102 kB]
Get:4 http://security.ubuntu.com/ubuntu xenial-security InRelease [102 kB]
Fetched 306 kB in 0s (584 kB/s)
Reading package lists...
sudo DEBIAN_FRONTEND=noninteractive apt-get -y \
    --no-install-recommends install apache2 archdetect-deb authbind avahi-utils bash bind9 bind9utils build-essential bzr bzr-builddeb chromium-browser chromium-chromedriver curl daemontools debhelper dh-apport dh-systemd distro-info dnsutils firefox freeipmi-tools git gjs ipython isc-dhcp-common isc-dhcp-server libjs-angularjs libjs-jquery libjs-jquery-hotkeys libjs-yui3-full libjs-yui3-min libnss-wrapper libpq-dev make nodejs-legacy npm postgresql psmisc pxelinux python3-all python3-apt python3-attr python3-bson python3-convoy python3-crochet python3-cssselect python3-curtin python3-dev python3-distro-info python3-django python3-django-nose python3-django-piston3 python3-dnspython python3-docutils python3-formencode python3-hivex python3-httplib2 python3-jinja2 python3-jsonschema python3-lxml python3-netaddr python3-netifaces python3-novaclient python3-oauth python3-oauthlib python3-openssl python3-paramiko python3-petname python3-pexpect python3-psycopg2 python3-pyinotify python3-pyparsing python3-pyvmomi python3-requests python3-seamicroclient python3-setuptools python3-simplestreams python3-sphinx python3-tempita python3-twisted python3-txtftp python3-tz python3-yaml python3-zope.interface python-bson python-crochet python-django python-django-piston python-djorm-ext-pgarray python-formencode python-lxml python-netaddr python-netifaces python-pocket-lint python-psycopg2 python-simplejson python-tempita python-twisted python-yaml socat syslinux-common tgt ubuntu-cloudimage-keyring wget xvfb
Reading package lists...
Building dependency tree...
Reading state information...
authbind is already the newest version (2.1.1+nmu1).
avahi-utils is already the newest version (0.6.32~rc+dfsg-1ubuntu2).
build-essential is already the newest version (12.1ubuntu2).
debhelper is already the newest version (9.20160115ubuntu3).
distro-info is already the newest version (0.14build1).
git is already the newest version (1:2.7.4-0ubuntu1).
libjs-angularjs is already the newest version (1.2.28-1ubuntu2).
libjs-jquery is already the newest version (1.11.3+dfsg-4).
libjs-yui3-full is already the newest version (3.5.1-1ubuntu3).
libjs-yui3-min is already the newest version (3.5.1-1ubuntu3).
make is already the newest version (4.1-6).
postgresql is already the newest version (9.5+173).
psmisc is already the newest version (22.21-2.1build1).
pxelinux is already the newest version (3:6.03+dfsg-11ubuntu1).
python-formencode is already the newest version (1.3.0-0ubuntu5).
python-lxml is already the newest version (3.5.0-1build1).
python-netaddr is already the newest version (0.7.18-1...

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'src/maasserver/static/js/angular/directives/ipranges.js'
2--- src/maasserver/static/js/angular/directives/ipranges.js 2016-10-20 20:53:41 +0000
3+++ src/maasserver/static/js/angular/directives/ipranges.js 2017-04-12 22:53:37 +0000
4@@ -6,8 +6,9 @@
5
6 angular.module('MAAS').directive('maasIpRanges', [
7 '$filter', 'IPRangesManager', 'UsersManager',
8- 'ManagerHelperService', function(
9- $filter, IPRangesManager, UsersManager, ManagerHelperService) {
10+ 'ManagerHelperService', 'ConverterService', function(
11+ $filter, IPRangesManager, UsersManager, ManagerHelperService,
12+ ConverterService) {
13 return {
14 restrict: "E",
15 scope: {
16@@ -105,6 +106,15 @@
17 });
18 };
19
20+ // Sort ranges by starting IP address.
21+ $scope.ipRangeSort = function(range) {
22+ if(range.start_ip.indexOf(':') !== -1) {
23+ return ConverterService.ipv6Expand(range.start_ip);
24+ } else {
25+ return ConverterService.ipv4ToInteger(range.start_ip);
26+ }
27+ };
28+
29 // Load the reqiured managers.
30 ManagerHelperService.loadManagers($scope, [
31 IPRangesManager, UsersManager]).then(
32
33=== modified file 'src/maasserver/static/js/angular/directives/tests/test_ipranges.js'
34--- src/maasserver/static/js/angular/directives/tests/test_ipranges.js 2016-10-20 20:53:41 +0000
35+++ src/maasserver/static/js/angular/directives/tests/test_ipranges.js 2017-04-12 22:53:37 +0000
36@@ -299,4 +299,24 @@
37 expect(scope.deleteIPRange).toBeNull();
38 });
39 });
40+
41+ describe("ipRangeSort", function() {
42+
43+ it("returns sortable numeric IPv4 value", function() {
44+ var directive = compileDirective();
45+ var scope = directive.isolateScope();
46+ var smaller = scope.ipRangeSort({ 'start_ip': '10.0.0.21'});
47+ var larger = scope.ipRangeSort({ 'start_ip': '10.0.0.200'});
48+ expect(smaller < larger).toBe(true);
49+ });
50+
51+ it("returns sortable numeric IPv6 value", function() {
52+ var directive = compileDirective();
53+ var scope = directive.isolateScope();
54+ var smaller = scope.ipRangeSort({ 'start_ip': '2001::21'});
55+ var larger = scope.ipRangeSort({ 'start_ip': '2001::200'});
56+ expect(smaller < larger).toBe(true);
57+ });
58+ });
59+
60 });
61
62=== modified file 'src/maasserver/static/partials/ipranges.html'
63--- src/maasserver/static/partials/ipranges.html 2017-04-07 16:08:21 +0000
64+++ src/maasserver/static/partials/ipranges.html 2017-04-12 22:53:37 +0000
65@@ -10,10 +10,9 @@
66 </div>
67 </header>
68 <main class="table__body">
69- <div class="table__row"
70- data-ng-repeat="iprange in (subnetIPRanges = ipranges | filterBySubnet:obj | orderBy:'start_ip')"
71+ <div class="table__row" data-ng-repeat="iprange in (subnetIPRanges = ipranges | filterBySubnet:obj) | orderBy:ipRangeSort"
72 data-ng-class="{ 'is-active': isIPRangeInEditMode(iprange) || isIPRangeInDeleteMode(iprange)}">
73- <div class="table__data table-col--20" aria-label="Start IP Address">{$ iprange.start_ip $}</div>
74+ <div class="table__data table-col--20" aria-label="Start IP Address">{$ iprange.start_ip $}</div>
75 <div class="table__data table-col--20" aria-label="End IP Address">{$ iprange.end_ip $}</div>
76 <div class="table__data table-col--10" aria-label="Owner">{$ iprange.type == "dynamic" ? "MAAS" : iprange.user_username $}</div>
77 <div class="table__data table-col--10" aria-label="Type">{$ iprange.type == "dynamic" ? "Dynamic" : "Reserved" $}</div>