Skip to content
Open
Show file tree
Hide file tree
Changes from 1 commit
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
Expand Up @@ -1964,4 +1964,8 @@ public interface CommonApplicationConstants extends Constants {
String permissionFilter();

String propertyId();

String hideUsedLunsForISCSILabel();

String hideUsedLunsForFCPLabel();
}
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,10 @@ public void goBack() {
@Override
public void refresh() {
}

@Override
public void reload() {
}
};

interface WidgetUiBinder extends UiBinder<FlowPanel, PaginationControl> {
Expand Down Expand Up @@ -114,6 +118,11 @@ public void setDataProvider(PagingDataProvider dataProvider) {
updateTableControls();
}

public void reload() {
getDataProvider().reload();
updateTableControls();
}

@UiHandler("prevPageButton")
public void handlePrevPageButtonClick(ClickEvent event) {
getDataProvider().goBack();
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package org.ovirt.engine.ui.common.widget.table;

import java.util.Collection;

/**
* Classes that implement this interface support forward/back paging functionality.
*
Expand Down Expand Up @@ -30,4 +32,18 @@ public interface HasPaging {
* Refresh the current page.
*/
void refresh();

/**
* Reload all and go to the first page.
*/
default void reload() {

}

/**
* Reload all and go to the first page (with providing access to the items, if needed).
*/
default void reload(Collection items) {

}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,10 @@

import java.util.List;

import org.gwtbootstrap3.client.ui.CheckBox;
import org.ovirt.engine.ui.common.CommonApplicationConstants;
import org.ovirt.engine.ui.common.editor.UiCommonEditorDriver;
import org.ovirt.engine.ui.common.gin.AssetProvider;
import org.ovirt.engine.ui.common.widget.HasValidation;
import org.ovirt.engine.ui.common.widget.PaginationControl;
import org.ovirt.engine.ui.common.widget.ValidatedPanelWidget;
Expand All @@ -11,6 +14,7 @@

import com.google.gwt.core.client.GWT;
import com.google.gwt.dom.client.Style.Unit;
import com.google.gwt.safehtml.shared.SafeHtmlUtils;
import com.google.gwt.uibinder.client.UiBinder;
import com.google.gwt.uibinder.client.UiField;
import com.google.gwt.user.client.ui.Label;
Expand All @@ -32,14 +36,23 @@ public class FcpStorageView extends AbstractStorageView<SanStorageModelBase> imp
@UiField
PaginationControl paginationControl;

@UiField
@Ignore
CheckBox hideUsedLunsCheckBox;

LunFilter lunFilter;

private final Driver driver = GWT.create(Driver.class);

private double panelHeight = 292;

private double listHeight = 278;

private static final CommonApplicationConstants constants = AssetProvider.getConstants();

public FcpStorageView(boolean multiSelection) {
initWidget(ViewUiBinder.uiBinder.createAndBindUi(this));
localize();
driver.initialize(this);
this.multiSelection = multiSelection;
}
Expand All @@ -51,6 +64,10 @@ public FcpStorageView(boolean multiSelection, double panelHeight, double listHei
this.listHeight = listHeight;
}

void localize() {
hideUsedLunsCheckBox.setHTML(SafeHtmlUtils.fromString(constants.hideUsedLunsForFCPLabel()));
}

@Override
public void edit(final SanStorageModelBase object) {
driver.edit(object);
Expand All @@ -64,6 +81,8 @@ public void edit(final SanStorageModelBase object) {
onIsValidPropertyChange(object);
}
});

initHideUsedLunsCheckBox();
}

void onIsValidPropertyChange(Model model) {
Expand Down Expand Up @@ -105,8 +124,10 @@ public void focus() {

protected void initLists(SanStorageModelBase model) {
PageFilter pageFilter = new PageFilter(50);
lunFilter = new LunFilter(hideUsedLunsCheckBox.getValue());
SanStorageLunToTargetList sanStorageLunToTargetList =
new SanStorageLunToTargetList(PagingProxyModel.create(pageFilter, model), true, multiSelection);
new SanStorageLunToTargetList(PagingFilteredProxyModel.create(pageFilter, lunFilter, model),
true, multiSelection);
sanStorageLunToTargetList.activateItemsUpdate();
paginationControl.setDataProvider(StoragePagingDataProvider.create(pageFilter, sanStorageLunToTargetList));
model.getItemsChangedEvent().addListener((ev, sender, args) -> paginationControl.updateTableControls());
Expand All @@ -119,6 +140,15 @@ protected void initLists(SanStorageModelBase model) {
contentPanel.setWidget(sanStorageLunToTargetList);
}

private void initHideUsedLunsCheckBox() {
hideUsedLunsCheckBox.addValueChangeHandler(event -> {
if (lunFilter != null) {
lunFilter.setIsHideUsedLuns(event.getValue());
}
paginationControl.reload();
});
}

interface Driver extends UiCommonEditorDriver<SanStorageModelBase, FcpStorageView> {
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,12 @@
justify-content: flex-end;
border-bottom: none;
}

.hideUsedLunsCheckBox {
font-size: 12px;
padding-left: 23px;
height: 10px;
}
</ui:style>

<b:Container fluid="true">
Expand All @@ -27,6 +33,9 @@
<g:Label ui:field="warning" addStyleNames="{style.errorMessageLabel}"/>
</b:Column>
</b:Row>
<b:Row>
<b:CheckBox ui:field="hideUsedLunsCheckBox" value="true" addStyleNames="{style.hideUsedLunsCheckBox}" />
</b:Row>
<b:Row>
<b:Column size="SM_12">
<g:FlowPanel addStyleNames="content-view-pf-pagination clearfix {style.paginationBar}">
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
package org.ovirt.engine.ui.common.widget.uicommon.storage;

import java.util.Collection;

import org.ovirt.engine.ui.uicommonweb.models.storage.SanStorageModelBase;

/**
* Create a proxy model that will intercept {@link SanStorageModelBase#getItems()} and filter the items.
* From a logical point of view all data is still one model i.e. user changes are not lost when
* applying the filter and submitting.
*/
public class FilteredProxyModel extends ProxyModelBase {

private final ModelFilter<?> filter;

public FilteredProxyModel(SanStorageModelBase model, ModelFilter<?> filter) {
super(model);
this.filter = filter;
}

public static FilteredProxyModel create(ModelFilter<?> filter, SanStorageModelBase model) {
return new FilteredProxyModel(model, filter);
}

@Override
public Collection getItems() {
return filter.filter(getModel().getItems());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@ interface ViewUiBinder extends UiBinder<Widget, IscsiLunToTargetView> {
private final double treeHeight;
private final boolean multiSelection;

private LunFilter lunFilter;

public IscsiLunToTargetView(double treeHeight, boolean multiSelection) {
this.treeHeight = treeHeight;
this.multiSelection = multiSelection;
Expand All @@ -38,14 +40,20 @@ public IscsiLunToTargetView(double treeHeight, boolean multiSelection) {
driver.initialize(this);
}

public IscsiLunToTargetView(double treeHeight, boolean multiSelection, LunFilter lunFilter) {
this(treeHeight, multiSelection);
this.lunFilter = lunFilter;
}

@Override
public void edit(final SanStorageModelBase object) {
driver.edit(object);
initLists(object);
}

void initLists(SanStorageModelBase object) {
sanStorageLunToTargetList = new SanStorageLunToTargetList(object, false, multiSelection);
sanStorageLunToTargetList = new SanStorageLunToTargetList(FilteredProxyModel.create(lunFilter, object),
false, multiSelection);
sanStorageLunToTargetList.setTreeContainerHeight(treeHeight);
lunsListPanel.add(sanStorageLunToTargetList);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import java.util.List;

import org.gwtbootstrap3.client.ui.CheckBox;
import org.ovirt.engine.core.compat.StringHelper;
import org.ovirt.engine.ui.common.CommonApplicationConstants;
import org.ovirt.engine.ui.common.editor.UiCommonEditorDriver;
Expand Down Expand Up @@ -72,11 +73,18 @@ interface ViewUiBinder extends UiBinder<Widget, IscsiStorageView> {
@Ignore
Label subLabel;

@UiField
@Ignore
CheckBox hideUsedLunsCheckBox;

private double treeCollapsedHeight = 245;
private double treeExpandedHeight = 355;
private double lunsTreeHeight = 405;
private double tabContentHeight = 100;

private LunFilter lunFilter;
private SanTargetFilter sanTargetFilter;

private final Driver driver = GWT.create(Driver.class);

private static final CommonApplicationConstants constants = AssetProvider.getConstants();
Expand All @@ -103,6 +111,7 @@ public IscsiStorageView(boolean multiSelection,
void localize() {
lunToTargetsTab.setLabel(constants.storageIscsiPopupLunToTargetsTabLabel());
targetsToLunTab.setLabel(constants.storageIscsiPopupTargetsToLunTabLabel());
hideUsedLunsCheckBox.setHTML(SafeHtmlUtils.fromString(constants.hideUsedLunsForISCSILabel()));
}

@Override
Expand Down Expand Up @@ -170,12 +179,17 @@ public void edit(final IscsiStorageModel object) {
warning.setVisible(!StringHelper.isNullOrEmpty(warningText));
}
});

initHideUsedLunsCheckBox(object);
}

void initLists(IscsiStorageModel object) {
lunFilter = new LunFilter(hideUsedLunsCheckBox.getValue());
sanTargetFilter = new SanTargetFilter(hideUsedLunsCheckBox.getValue());
// Create discover panel and storage lists
iscsiTargetToLunView = new IscsiTargetToLunView(treeCollapsedHeight, treeExpandedHeight, false, multiSelection);
iscsiLunToTargetView = new IscsiLunToTargetView(lunsTreeHeight, multiSelection);
iscsiTargetToLunView = new IscsiTargetToLunView(treeCollapsedHeight, treeExpandedHeight, false, multiSelection,
sanTargetFilter, lunFilter);
iscsiLunToTargetView = new IscsiLunToTargetView(lunsTreeHeight, multiSelection, lunFilter);

// Update Style
dialogTabPanel.getElement().getStyle().setHeight(tabContentHeight, Unit.PCT);
Expand Down Expand Up @@ -243,6 +257,18 @@ public void cleanup() {
public void focus() {
}

private void initHideUsedLunsCheckBox(IscsiStorageModel object) {
hideUsedLunsCheckBox.addValueChangeHandler(event -> {
if (lunFilter != null) {
lunFilter.setIsHideUsedLuns(event.getValue());
}
if (sanTargetFilter != null) {
sanTargetFilter.setIsHideUsedLuns(event.getValue());
}
updateListByGrouping(object);
});
}

interface WidgetStyle extends CssResource {
String barEditDomain();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,12 @@
font-size: 12px;
padding-left: 50px;
}

.hideUsedLunsCheckBox {
font-size: 12px;
padding-left: 60px;
height: 10px;
}
</ui:style>

<b:Container fluid="true">
Expand All @@ -105,6 +111,9 @@
<pa:AlertPanel ui:field="warning" visible="false" />
</b:Column>
</b:Row>
<b:Row>
<b:CheckBox ui:field="hideUsedLunsCheckBox" value="true" addStyleNames="{style.hideUsedLunsCheckBox}" />
</b:Row>
<b:Row>
<t:DialogTabPanel ui:field="dialogTabPanel" contentStyle="{style.content}" navStyle="{style.maxHeight}" addStyleNames="{style.tabPanel}" height="100%" width="100%">
<t:tab>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,9 @@ interface ViewUiBinder extends UiBinder<Widget, IscsiTargetToLunView> {
private boolean hideLeaf;
private boolean multiSelection;

private SanTargetFilter sanTargetFilter;
private LunFilter leafLunFilter;

private final Driver driver = GWT.create(Driver.class);

public IscsiTargetToLunView(double treeCollapsedHeight, double treeExpandedHeight) {
Expand All @@ -53,6 +56,14 @@ public IscsiTargetToLunView(double treeCollapsedHeight, double treeExpandedHeigh
driver.initialize(this);
}

public IscsiTargetToLunView(double treeCollapsedHeight, double treeExpandedHeight,
boolean hideLeaf, boolean multiSelection, SanTargetFilter sanTargetFilter,
LunFilter leafLunFilter) {
this(treeCollapsedHeight, treeExpandedHeight, hideLeaf, multiSelection);
this.sanTargetFilter = sanTargetFilter;
this.leafLunFilter = leafLunFilter;
}

@Override
public void edit(final SanStorageModelBase object) {
driver.edit(object);
Expand Down Expand Up @@ -88,7 +99,8 @@ private void setProposeDiscover(boolean proposeDiscover) {
void initLists(SanStorageModelBase object) {
// Create discover panel and storage lists
iscsiDiscoverTargetsView = new IscsiDiscoverTargetsView();
sanStorageTargetToLunList = new SanStorageTargetToLunList(object, hideLeaf, multiSelection);
sanStorageTargetToLunList = new SanStorageTargetToLunList(FilteredProxyModel.create(sanTargetFilter, object),
hideLeaf, multiSelection, leafLunFilter);

// Add view widgets to panel
targetsToLunsDiscoverPanel.add(iscsiDiscoverTargetsView);
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
package org.ovirt.engine.ui.common.widget.uicommon.storage;

import java.util.Collection;
import java.util.stream.Collectors;

import org.ovirt.engine.ui.uicommonweb.models.storage.LunModel;

/**
* LUN model filter.
*/
public class LunFilter extends LunFilterBase implements ModelFilter<LunModel> {

public LunFilter(boolean isHideUsedLuns) {
super(isHideUsedLuns);
}

public Collection<LunModel> filter(Collection<LunModel> items) {
if (items == null || !needFilter()) {
return items;
}

return items.stream().filter(lunModel -> {
if (getIsHideUsedLuns()) {
return !lunModel.getIsUsed();
}
return true;
}).collect(Collectors.toList());
}
}
Loading