From 533897d4e6349eed0b8cad65a241351f641a8187 Mon Sep 17 00:00:00 2001 From: jiahuay Date: Mon, 24 Feb 2014 17:16:46 -0800 Subject: [PATCH] Enable sorting columns in servers table on review page Change-Id: Ia43d066feaaf925dd09d34d520210388dc11b471 --- .../ods/ui/install_review/install_review.js | 43 ++++++++++++++++--- public/ods/ui/servers/servers.css | 6 +-- 2 files changed, 41 insertions(+), 8 deletions(-) diff --git a/public/ods/ui/install_review/install_review.js b/public/ods/ui/install_review/install_review.js index 577cd33..5bca988 100644 --- a/public/ods/ui/install_review/install_review.js +++ b/public/ods/ui/install_review/install_review.js @@ -26,7 +26,7 @@ steal( } else { this.element.html(this.view('init')); - + this.dataTableIpAddrSort(); this.initServerTable(); this.onSecurityData(this.options.odsState.security); @@ -91,6 +91,36 @@ steal( $("#storage_end").html(data.interfaces.storage.ip_end); }, + dataTableIpAddrSort: function() { + jQuery.extend(jQuery.fn.dataTableExt.oSort, { + "ip-address-pre": function(a) { + var m = a.split("."), + x = ""; + + for (var i = 0; i < m.length; i++) { + var item = m[i]; + if (item.length == 1) { + x += "00" + item; + } else if (item.length == 2) { + x += "0" + item; + } else { + x += item; + } + } + + return x; + }, + + "ip-address-asc": function(a, b) { + return ((a < b) ? -1 : ((a > b) ? 1 : 0)); + }, + + "ip-address-desc": function(a, b) { + return ((a < b) ? 1 : ((a > b) ? -1 : 0)); + } + }); + }, + initServerTable: function() { this.dataTable = $('#tb_server_review').dataTable({ "sScrollY": "450px", @@ -101,11 +131,14 @@ steal( }, { "mData": "mac" }, { - "mData": "management_ip" + "mData": "management_ip", + "sType": "ip-address" }, { - "mData": "tenant_ip" + "mData": "tenant_ip", + "sType": "ip-address" }, { - "mData": "switch_ip" + "mData": "switch_ip", + "sType": "ip-address" }, { "mData": "port" }, { @@ -122,7 +155,7 @@ steal( }], "aoColumnDefs": [{ bSortable: false, - aTargets: [0, 1, 2, 3, 6] + aTargets: [1, 6] }], "aaSorting": [ [4, "asc"], diff --git a/public/ods/ui/servers/servers.css b/public/ods/ui/servers/servers.css index a9e613c..6e0a166 100644 --- a/public/ods/ui/servers/servers.css +++ b/public/ods/ui/servers/servers.css @@ -85,15 +85,15 @@ table.display thead th { } .sorting { - background: url('../../../img/bg.gif') no-repeat 60% 50%; + background: url('../../../img/bg.gif') no-repeat 70% 50%; } .sorting_desc { - background: url('../../../img/desc.gif') no-repeat 60% 50%; + background: url('../../../img/desc.gif') no-repeat 70% 50%; } .sorting_asc { - background: url('../../../img/asc.gif') no-repeat 60% 50%; + background: url('../../../img/asc.gif') no-repeat 70% 50%; } .highlight {