Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

core: ability to sort on more space parameters for storage domains #986

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading