Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChristopher Frost2012-10-17 11:25:19 -0400
committerChristopher Frost2012-10-17 11:25:19 -0400
commit36e7d845000ee20a14e56c78107ae2591464cfa7 (patch)
treecff6113fa858942c2387d889a0ef464d1ce4ae53
parent754489daa4574d932d97741946313612bc3494c6 (diff)
downloadorg.eclipse.virgo.kernel-36e7d845000ee20a14e56c78107ae2591464cfa7.tar.gz
org.eclipse.virgo.kernel-36e7d845000ee20a14e56c78107ae2591464cfa7.tar.xz
org.eclipse.virgo.kernel-36e7d845000ee20a14e56c78107ae2591464cfa7.zip
391099 Adding a version sorter for tables
-rw-r--r--org.eclipse.virgo.management.console/src/main/webapp/js/common.js28
-rw-r--r--org.eclipse.virgo.management.console/src/main/webapp/js/repositories.js2
-rw-r--r--org.eclipse.virgo.management.console/src/main/webapp/js/wirings.js2
3 files changed, 29 insertions, 3 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 bdc2dd93..63a68a51 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
@@ -240,6 +240,26 @@ var Util = function(){
return getText(tr1) - getText(tr2);
};
+ var compareVersion = function(tr1, tr2){
+ var getText = function(tr){
+ var cell = $('*:nth-child(' + (index+1) + ')', tr);
+ return $(cell).text();
+ };
+ var ver1 = getText(tr1).split('.');
+ var ver2 = getText(tr2).split('.');
+ var result = ver1[0] - ver2[0];
+ if(result == 0){
+ result = ver1[1] - ver2[1];
+ }
+ if(result == 0){
+ result = ver1[2] - ver2[2];
+ }
+ if(result == 0){
+ result = ((ver1[3] < ver2[3]) ? -1 : ((ver1[3] > ver2[3]) ? 1 : 0));
+ }
+ return result;
+ };
+
var revCompareAlpha = function(tr1, tr2) {
return -compareAlpha(tr1, tr2);
};
@@ -248,6 +268,10 @@ var Util = function(){
return -compareNumeric(tr1, tr2);
};
+ var revCompareVersion = function(tr1, tr2){
+ return -compareVersion(tr1, tr2);
+ };
+
var ths = $(th).siblings();
ths.removeClass('table-th-sort');
ths.removeClass('table-th-sort-rev');
@@ -272,8 +296,10 @@ var Util = function(){
tRows.remove();
if(type == 'numeric'){
tRows.sort(isSorted ? revCompareNumeric : compareNumeric);
- }else{
+ }else if(type == 'alpha'){
tRows.sort(isSorted ? revCompareAlpha : compareAlpha);
+ }else{
+ tRows.sort(isSorted ? revCompareVersion : compareVersion);
}
tBody.append(tRows);
};
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 aaac68d6..994aeb5f 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
@@ -80,7 +80,7 @@ Repositories = {
var descriptorTable = util.makeTable({
clazz: 'repository-table table-selectable',
- headers: [{title: 'Type'}, {title: 'Name'}, {title: 'Version', type: 'numeric'}],
+ headers: [{title: 'Type', type: 'alpha'}, {title: 'Name', type: 'alpha'}, {title: 'Version', type: 'version'}],
rows: rows,
selectable: true,
sortable: true,
diff --git a/org.eclipse.virgo.management.console/src/main/webapp/js/wirings.js b/org.eclipse.virgo.management.console/src/main/webapp/js/wirings.js
index 02261ebf..0eb4c7bf 100644
--- a/org.eclipse.virgo.management.console/src/main/webapp/js/wirings.js
+++ b/org.eclipse.virgo.management.console/src/main/webapp/js/wirings.js
@@ -68,7 +68,7 @@ var SideBar = function(layoutManager, dataSource){
self.bundlesTable = util.makeTable({
id: 'bundle-table',
- headers: [{title: 'Id', type: 'numeric'}, {title: 'SymbolicName', type: 'char'}, {title: 'Version', type: 'numeric'}],
+ headers: [{title: 'Id', type: 'numeric'}, {title: 'SymbolicName', type: 'alpha'}, {title: 'Version', type: 'version'}],
rows: tRows,
sortable : true,
sortIndex: 0,

Back to the top