Skip to content

Commit

Permalink
core: ability to sort on more space parameters for storage domains
Browse files Browse the repository at this point in the history
Added ability to sort on following collumns on Storage tab:
- Allocated space
- Confirmed free space
- Total space

Signed-off-by: Jasper Berton <[email protected]>
  • Loading branch information
JasperB-TeamBlue authored and dupondje committed Dec 31, 2024
1 parent f094a8e commit 472ed34
Showing 1 changed file with 19 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package org.ovirt.engine.ui.webadmin.section.main.view;

import java.util.Comparator;
import java.util.HashMap;
import java.util.Map;

Expand Down Expand Up @@ -130,6 +131,7 @@ public Long getRawValue(StorageDomain object) {
return totalSpace == null ? null : Long.valueOf(totalSpace);
}
};
totalSpaceColumn.makeSortable(StorageDomainFieldAutoCompleter.TOTAL_SIZE);
getTable().addColumn(totalSpaceColumn, constants.totalSpaceStorage(), "130px"); //$NON-NLS-1$

AbstractStorageSizeColumn<StorageDomain> freeSpaceColumn = new AbstractStorageSizeColumn<StorageDomain>() {
Expand Down Expand Up @@ -158,6 +160,22 @@ public SafeHtml getTooltip(StorageDomain object) {
return SafeHtmlUtils.fromString(constants.confirmedFreeSpaceStorageThinTooltip());
}
};
confirmedFreeSpaceColumn.makeSortable(new Comparator<StorageDomain>() {
@Override
public int compare(StorageDomain storage1, StorageDomain storage2) {
if (storage1.getConfirmedAvailableDiskSize() == null && storage2.getConfirmedAvailableDiskSize() == null
&& storage1.getAvailableDiskSize() != null && storage2.getAvailableDiskSize() != null) {
return storage1.getAvailableDiskSize().compareTo(storage2.getAvailableDiskSize());
} else if (storage1.getConfirmedAvailableDiskSize() != null && storage2.getConfirmedAvailableDiskSize() != null) {
return storage1.getConfirmedAvailableDiskSize().compareTo(storage2.getConfirmedAvailableDiskSize());
} else if (storage1.getConfirmedAvailableDiskSize() != null && storage2.getAvailableDiskSize() != null) {
return storage1.getConfirmedAvailableDiskSize().compareTo(storage2.getAvailableDiskSize());
} else if (storage2.getConfirmedAvailableDiskSize() != null && storage1.getAvailableDiskSize() != null) {
return storage1.getAvailableDiskSize().compareTo(storage2.getConfirmedAvailableDiskSize());
}
return storage2.getName().compareTo(storage1.getName());
}
});
getTable().addColumn(confirmedFreeSpaceColumn, constants.confirmedFreeSpaceStorage(), "180px"); //$NON-NLS-1$

AbstractStorageSizeColumn<StorageDomain> allocatedSpaceColumn = new AbstractStorageSizeColumn<StorageDomain>() {
Expand All @@ -167,6 +185,7 @@ public Long getRawValue(StorageDomain object) {
return allocatedSpace == null ? null : Long.valueOf(allocatedSpace);
}
};
allocatedSpaceColumn.makeSortable(StorageDomainFieldAutoCompleter.COMMITTED);
getTable().addColumn(allocatedSpaceColumn, constants.allocatedSpaceStorage(), "130px"); //$NON-NLS-1$

AbstractTextColumn<StorageDomain> descriptionColumn = new AbstractTextColumn<StorageDomain>() {
Expand Down

0 comments on commit 472ed34

Please sign in to comment.