Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChristopher Frost2012-09-10 13:06:42 -0400
committerChristopher Frost2012-09-10 13:06:42 -0400
commitc3b6a2d0d580bb85738f7c45460e0beb50f86db9 (patch)
treede5011fea959365d15f40b87ea0e7567e53c3509 /org.eclipse.virgo.management.console
parentd7ff87154208151dbacca2200315c5808ee22313 (diff)
downloadorg.eclipse.virgo.kernel-c3b6a2d0d580bb85738f7c45460e0beb50f86db9.tar.gz
org.eclipse.virgo.kernel-c3b6a2d0d580bb85738f7c45460e0beb50f86db9.tar.xz
org.eclipse.virgo.kernel-c3b6a2d0d580bb85738f7c45460e0beb50f86db9.zip
388186 - Incorrect sorting by Id in Explorer tab of web admin console
Diffstat (limited to 'org.eclipse.virgo.management.console')
-rw-r--r--org.eclipse.virgo.management.console/src/main/webapp/js/common.js37
-rw-r--r--org.eclipse.virgo.management.console/src/main/webapp/js/explorer.js2
-rw-r--r--org.eclipse.virgo.management.console/src/main/webapp/js/overview.js2
-rw-r--r--org.eclipse.virgo.management.console/src/main/webapp/js/repositories.js2
4 files changed, 30 insertions, 13 deletions
diff --git a/org.eclipse.virgo.management.console/src/main/webapp/js/common.js b/org.eclipse.virgo.management.console/src/main/webapp/js/common.js
index 79bf1f38..d7c89d35 100644
--- a/org.eclipse.virgo.management.console/src/main/webapp/js/common.js
+++ b/org.eclipse.virgo.management.console/src/main/webapp/js/common.js
@@ -206,7 +206,7 @@ var Util = function(){
});
};
- var doSort = function(table, th){
+ var doSort = function(table, th, type){
var upArrow = '\u2191';
var downArrow = '\u2193';
@@ -222,7 +222,7 @@ var Util = function(){
var index = th.col;
- var compare = function(tr1, tr2){
+ var compareAlpha = function(tr1, tr2){
var getText = function(tr){
var cell = $('*:nth-child(' + (index+1) + ')', tr);
return $(cell).text();
@@ -232,8 +232,20 @@ var Util = function(){
return ((text1 < text2) ? -1 : ((text1 > text2) ? 1 : 0));
};
- var revCompare = function(tr1, tr2) {
- return -compare(tr1, tr2);
+ var compareNumeric = function(tr1, tr2){
+ var getText = function(tr){
+ var cell = $('*:nth-child(' + (index+1) + ')', tr);
+ return $(cell).text();
+ };
+ return getText(tr1) - getText(tr2);
+ };
+
+ var revCompareAlpha = function(tr1, tr2) {
+ return -compareAlpha(tr1, tr2);
+ };
+
+ var revCompareNumeric = function(tr1, tr2) {
+ return -compareNumeric(tr1, tr2);
};
var ths = $(th).siblings();
@@ -258,14 +270,19 @@ var Util = function(){
var tBody = $('tbody', table);
var tRows = tBody.children();
tRows.remove();
- tRows.sort(isSorted ? revCompare : compare);
+ if(type == 'numeric'){
+ tRows.sort(isSorted ? revCompareNumeric : compareNumeric);
+ }else{
+ tRows.sort(isSorted ? revCompareAlpha : compareAlpha);
+ }
tBody.append(tRows);
};
var sortTable = function(clickEvent){
- var th = clickEvent.data;
+ var th = clickEvent.data.header;
var table = th.parents('table');
- doSort(table, th);
+ var sortType = clickEvent.data.type;
+ doSort(table, th, sortType);
decorate(table);
};
@@ -274,10 +291,10 @@ var Util = function(){
if(properties.headers){
var tHeadRow = $('<tr />');
$.each(properties.headers, function(index, item){
- var th = $('<th>' + item + '</th>');
+ var th = $('<th>' + item.title + '</th>');
th.col = index;
if (properties.sortable) {
- th.click(th, sortTable);
+ th.click({header: th, type: item.type}, sortTable);
}
tHeadRow.append(th);
if (properties.sortable && index == properties.sortIndex) {
@@ -315,7 +332,7 @@ var Util = function(){
newTable.append(tBody);
if(properties.sortable && sortTh != null){
- doSort(newTable, sortTh);
+ doSort(newTable, sortTh, properties.headers[0].type);
};
decorate(newTable);
diff --git a/org.eclipse.virgo.management.console/src/main/webapp/js/explorer.js b/org.eclipse.virgo.management.console/src/main/webapp/js/explorer.js
index 82dc34c9..5b7b3d1b 100644
--- a/org.eclipse.virgo.management.console/src/main/webapp/js/explorer.js
+++ b/org.eclipse.virgo.management.console/src/main/webapp/js/explorer.js
@@ -61,7 +61,7 @@ var SideBar = function(layoutManager, dataSource){
self.bundlesTable = util.makeTable({
id: 'bundle-table',
- headers: ['Id', 'SymbolicName', 'Version'],
+ headers: [{title: 'Id', type: 'numeric'}, {title: 'SymbolicName', type: 'char'}, {title: 'Version', type: 'numeric'}],
rows: tRows,
sortable : true,
sortIndex: 0,
diff --git a/org.eclipse.virgo.management.console/src/main/webapp/js/overview.js b/org.eclipse.virgo.management.console/src/main/webapp/js/overview.js
index 7dd4574e..bdbacfd3 100644
--- a/org.eclipse.virgo.management.console/src/main/webapp/js/overview.js
+++ b/org.eclipse.virgo.management.console/src/main/webapp/js/overview.js
@@ -16,7 +16,7 @@ function pageinit() {
var renderOverviewTable = function(rows) {
$('#server-overview').replaceWith(util.makeTable({
- headers: ['Name', 'Value'],
+ headers: [{title: 'Name'}, {title: 'Value'}],
rows: rows
}));
util.pageReady();
diff --git a/org.eclipse.virgo.management.console/src/main/webapp/js/repositories.js b/org.eclipse.virgo.management.console/src/main/webapp/js/repositories.js
index 3874d8df..bfc7bebe 100644
--- a/org.eclipse.virgo.management.console/src/main/webapp/js/repositories.js
+++ b/org.eclipse.virgo.management.console/src/main/webapp/js/repositories.js
@@ -76,7 +76,7 @@ renderArtifactDescriptorSummaries: function(artifactDescriptorSummaries){
var descriptorTable = util.makeTable({
clazz: 'repository-table table-selectable',
- headers: ['Type', 'Name', 'Version'],
+ headers: [{title: 'Type'}, {title: 'Name'}, {title: 'Version'}],
rows: rows,
selectable: true,
sortable: true,

Back to the top