ofri masad has uploaded a new change for review. Change subject: userportal: redesign for resources tab ......................................................................
userportal: redesign for resources tab This patch is a facelift for the User Portal Resources tab. - The basic Box design was changed - Removed VMs Box - Refined the UI for Quota monitoring Change-Id: I26ea6eb7f7ec93ffa69a2a4dea52c7e5d50dead9 Signed-off-by: Ofri Masad <oma...@redhat.com> --- M frontend/webadmin/modules/gwt-common/src/main/java/org/ovirt/engine/ui/common/CommonApplicationMessages.java M frontend/webadmin/modules/userportal-gwtp/src/main/java/org/ovirt/engine/ui/userportal/ApplicationConstants.java M frontend/webadmin/modules/userportal-gwtp/src/main/java/org/ovirt/engine/ui/userportal/section/main/view/tab/extended/SideTabExtendedResourceView.java M frontend/webadmin/modules/userportal-gwtp/src/main/java/org/ovirt/engine/ui/userportal/section/main/view/tab/extended/SideTabExtendedResourceView.ui.xml M frontend/webadmin/modules/userportal-gwtp/src/main/java/org/ovirt/engine/ui/userportal/widget/DoublePercentageProgressBar.java M frontend/webadmin/modules/userportal-gwtp/src/main/java/org/ovirt/engine/ui/userportal/widget/DoublePercentageProgressBar.ui.xml M frontend/webadmin/modules/userportal-gwtp/src/main/java/org/ovirt/engine/ui/userportal/widget/QuotaProgressBar.java M frontend/webadmin/modules/userportal-gwtp/src/main/resources/org/ovirt/engine/ui/userportal/images/general/storage_icon.png 8 files changed, 520 insertions(+), 438 deletions(-) git pull ssh://gerrit.ovirt.org:29418/ovirt-engine refs/changes/59/11259/1 diff --git a/frontend/webadmin/modules/gwt-common/src/main/java/org/ovirt/engine/ui/common/CommonApplicationMessages.java b/frontend/webadmin/modules/gwt-common/src/main/java/org/ovirt/engine/ui/common/CommonApplicationMessages.java index 4cec0d6..ece2c55 100644 --- a/frontend/webadmin/modules/gwt-common/src/main/java/org/ovirt/engine/ui/common/CommonApplicationMessages.java +++ b/frontend/webadmin/modules/gwt-common/src/main/java/org/ovirt/engine/ui/common/CommonApplicationMessages.java @@ -77,4 +77,13 @@ @DefaultMessage("No {0} to display") String noItemsToDisplay(String items); + + @DefaultMessage("Exceeded {0}% / {1}vCPU") + String exceedingCpus(int percentage, int number); + + @DefaultMessage("Exceeded {0}% / {1}") + String exceedingMem(int percentage, String mem); + + @DefaultMessage("Exceeded {0}% / {1}GB") + String exceedingStorage(int percentage, double gb); } diff --git a/frontend/webadmin/modules/userportal-gwtp/src/main/java/org/ovirt/engine/ui/userportal/ApplicationConstants.java b/frontend/webadmin/modules/userportal-gwtp/src/main/java/org/ovirt/engine/ui/userportal/ApplicationConstants.java index e78ae93..c8f19af 100644 --- a/frontend/webadmin/modules/userportal-gwtp/src/main/java/org/ovirt/engine/ui/userportal/ApplicationConstants.java +++ b/frontend/webadmin/modules/userportal-gwtp/src/main/java/org/ovirt/engine/ui/userportal/ApplicationConstants.java @@ -373,15 +373,24 @@ String doubleClickForConsole(); - @DefaultStringValue("Consumed by Others") + @DefaultStringValue("Used by Others") String othersUseQuota(); - @DefaultStringValue("Consumed by You") + @DefaultStringValue("Used by You") String youUseQuota(); + + @DefaultStringValue("Free") + String freeQuota(); @DefaultStringValue("Free Memory: ") String freeMemory(); @DefaultStringValue("Free Storage: ") String freeStorage(); + + @DefaultStringValue("Quota Summary ") + String quotaSummary(); + + @DefaultStringValue("Virtual Machines' Disks & Snapshots ") + String vmDisksAndSnapshots(); } diff --git a/frontend/webadmin/modules/userportal-gwtp/src/main/java/org/ovirt/engine/ui/userportal/section/main/view/tab/extended/SideTabExtendedResourceView.java b/frontend/webadmin/modules/userportal-gwtp/src/main/java/org/ovirt/engine/ui/userportal/section/main/view/tab/extended/SideTabExtendedResourceView.java index 7215680..8ac19a2 100644 --- a/frontend/webadmin/modules/userportal-gwtp/src/main/java/org/ovirt/engine/ui/userportal/section/main/view/tab/extended/SideTabExtendedResourceView.java +++ b/frontend/webadmin/modules/userportal-gwtp/src/main/java/org/ovirt/engine/ui/userportal/section/main/view/tab/extended/SideTabExtendedResourceView.java @@ -1,15 +1,19 @@ package org.ovirt.engine.ui.userportal.section.main.view.tab.extended; -import com.google.gwt.event.dom.client.ClickEvent; -import com.google.gwt.event.dom.client.ClickHandler; +import com.google.gwt.event.logical.shared.ResizeEvent; +import com.google.gwt.event.logical.shared.ResizeHandler; import com.google.gwt.resources.client.CssResource; -import com.google.gwt.user.client.ui.*; +import com.google.gwt.user.client.Window; +import com.google.gwt.user.client.ui.Widget; +import com.google.gwt.user.client.ui.VerticalPanel; +import com.google.gwt.user.client.ui.ScrollPanel; +import com.google.gwt.user.client.ui.FlowPanel; +import com.google.gwt.user.client.ui.Label; import org.ovirt.engine.core.common.businessentities.QuotaUsagePerUser; import org.ovirt.engine.core.compat.Event; import org.ovirt.engine.core.compat.EventArgs; import org.ovirt.engine.core.compat.Guid; import org.ovirt.engine.core.compat.IEventListener; -import org.ovirt.engine.ui.common.CommonApplicationMessages; import org.ovirt.engine.ui.common.SubTableResources; import org.ovirt.engine.ui.common.idhandler.ElementIdHandler; import org.ovirt.engine.ui.common.idhandler.WithElementId; @@ -18,13 +22,11 @@ import org.ovirt.engine.ui.common.widget.dialog.AdvancedParametersExpander; import org.ovirt.engine.ui.common.widget.refresh.RefreshPanel; import org.ovirt.engine.ui.common.widget.refresh.SimpleRefreshManager; -import org.ovirt.engine.ui.common.widget.renderer.DiskSizeRenderer; import org.ovirt.engine.ui.uicommonweb.models.resources.ResourcesModel; import org.ovirt.engine.ui.userportal.ApplicationConstants; import org.ovirt.engine.ui.userportal.ApplicationResources; import org.ovirt.engine.ui.userportal.section.main.presenter.tab.extended.SideTabExtendedResourcePresenter; import org.ovirt.engine.ui.userportal.uicommon.model.resources.ResourcesModelProvider; -import org.ovirt.engine.ui.userportal.widget.PercentageProgressBar; import org.ovirt.engine.ui.userportal.widget.QuotaProgressBar; import org.ovirt.engine.ui.userportal.widget.ToStringEntityModelLabel; import org.ovirt.engine.ui.userportal.widget.resources.VmTable; @@ -55,29 +57,11 @@ } private static final ApplicationConstants constants = GWT.create(ApplicationConstants.class); - private static final CommonApplicationMessages messages = GWT.create(CommonApplicationMessages.class); - private static final DiskSizeRenderer<Number> diskSizeRenderer = - new DiskSizeRenderer<Number>(DiskSizeRenderer.DiskSizeUnit.GIGABYTE); @UiField Style style; - @UiField - @Path("DefinedVMs.Entity") - @WithElementId - ToStringEntityModelLabel definedVms; - - @UiField - @Path("RunningVMs.Entity") - @WithElementId - ToStringEntityModelLabel runningVms; - - @UiField - @Path("RunningVMsPercentage.Entity") - @WithElementId("runningVmsPercentage") - PercentageProgressBar vmsProgressBar; - - @UiField + @UiField(provided = true) @Path("UsedCPUsPercentage.Entity") @WithElementId("usedCpusPercentage") QuotaProgressBar cpusProgressBar; @@ -86,7 +70,7 @@ @WithElementId VerticalPanel cpusQuotasList; - @UiField + @UiField(provided = true) @Path("UsedMemoryPercentage.Entity") @WithElementId("memoryUsagePercentage") QuotaProgressBar memoryProgressBar; @@ -95,7 +79,7 @@ @WithElementId VerticalPanel memoryQuotasList; - @UiField + @UiField(provided = true) @Path("UsedMemoryPercentage.Entity") @WithElementId("storageUsagePercentage") QuotaProgressBar storageProgressBar; @@ -150,41 +134,38 @@ @UiField @Ignore - FlowPanel infoBoxRight; + FlowPanel infoBoxMemory; @UiField @Ignore - FlowPanel infoBoxMiddle; + FlowPanel infoBoxCpu; @UiField @Ignore - FlowPanel infoBoxLeft; - - @UiField - @Ignore - DockLayoutPanel bottomLayoutPanel; - - @UiField - @Ignore - HorizontalPanel bottomInfoBox; + FlowPanel bottomLayoutPanel; @UiField(provided = true) RefreshPanel refreshPanel; - private SimpleRefreshManager refreshManager; - @Inject public SideTabExtendedResourceView(ResourcesModelProvider modelProvider, EventBus eventBus, ClientStorage clientStorage, - SubTableResources headerResources, ApplicationResources resources, ApplicationConstants constans) { - vmTable = new VmTable(modelProvider, headerResources, resources, constans); - refreshManager = new SimpleRefreshManager(modelProvider, eventBus, clientStorage); + SubTableResources headerResources, ApplicationResources resources, ApplicationConstants constants) { + + vmTable = new VmTable(modelProvider, headerResources, resources, constants); + vmTable.setVisible(true); + + SimpleRefreshManager refreshManager = new SimpleRefreshManager(modelProvider, eventBus, clientStorage); refreshPanel = refreshManager.getRefreshPanel(); + + cpusProgressBar = new QuotaProgressBar(QuotaProgressBar.QuotaType.CPU); + memoryProgressBar = new QuotaProgressBar(QuotaProgressBar.QuotaType.MEM); + storageProgressBar = new QuotaProgressBar(QuotaProgressBar.QuotaType.STORAGE); + initWidget(ViewUiBinder.uiBinder.createAndBindUi(this)); Driver.driver.initialize(this); ViewIdHandler.idHandler.generateAndSetIds(this); localize(); - modelProvider.getModel().getUsedQuotaPercentage().getEntityChangedEvent().addListener(new IEventListener() { @Override @@ -193,38 +174,18 @@ } }); + Window.addResizeHandler(new ResizeHandler() { + @Override + public void onResize(ResizeEvent resizeEvent) { + vcpuExpanderContent.setHeight(infoBoxCpu.getOffsetHeight() - 150 + "px"); //$NON-NLS-1$ + memoryExpanderContent.setHeight(infoBoxMemory.getOffsetHeight() - 150 + "px"); //$NON-NLS-1$ + vmTable.setHeight(bottomLayoutPanel.getOffsetHeight() - 350 + "px"); //$NON-NLS-1$ + } + }); + vcpuExpander.initWithContent(vcpuExpanderContent.getElement()); memoryExpander.initWithContent(memoryExpanderContent.getElement()); storageExpander.initWithContent(storageExpanderContent.getElement()); - - ClickHandler clickHandler = new ClickHandler() { - @Override - public void onClick(ClickEvent clickEvent) { - if (vcpuExpander.isDown() || memoryExpander.isDown()) { - infoBoxLeft.setStyleName(style.infoBoxLeftExtended()); - infoBoxMiddle.setStyleName(style.infoBoxMiddleExtended()); - infoBoxRight.setStyleName(style.infoBoxRightExtended()); - } else { - infoBoxLeft.setStyleName(style.infoBoxLeft()); - infoBoxMiddle.setStyleName(style.infoBoxMiddle()); - infoBoxRight.setStyleName(style.infoBoxRight()); - } - } - }; - vcpuExpander.addClickHandler(clickHandler); - memoryExpander.addClickHandler(clickHandler); - storageExpander.addClickHandler(new ClickHandler() { - @Override - public void onClick(ClickEvent clickEvent) { - if (storageExpander.isDown()) { - bottomLayoutPanel.setWidgetSize(bottomInfoBox, 260); - bottomLayoutPanel.setHeight("400px"); //$NON-NLS-1$ - } else { - bottomLayoutPanel.setWidgetSize(bottomInfoBox, 130); - bottomLayoutPanel.setHeight("265px"); //$NON-NLS-1$ - } - } - }); } private void localize() { @@ -238,14 +199,9 @@ storageExpander.setTitleWhenExpended(constants.hideQuotaDistribution()); } - public void initQuotaList(ResourcesModel model) { List<QuotaUsagePerUser> list = (List<QuotaUsagePerUser>) model.getUsedQuotaPercentage().getEntity(); QuotaUsagePerUser aggregatedUsage = new QuotaUsagePerUser(Guid.Empty, "", 0, 0, 0, 0, 0, 0); - - boolean unlimitedVcpu = false; - boolean unlimitedMem = false; - boolean unlimitedStorage = false; if (list != null) { cpusQuotasList.clear(); @@ -257,10 +213,6 @@ storageQuotasList.setSpacing(7); for (QuotaUsagePerUser quotaPerUserUsageEntity : list) { - unlimitedMem |= quotaPerUserUsageEntity.isUnlimitedMemory(); - unlimitedStorage |= quotaPerUserUsageEntity.isUnlimitedStorage(); - unlimitedVcpu |= quotaPerUserUsageEntity.isUnlimitedVcpu(); - aggregate(aggregatedUsage, quotaPerUserUsageEntity); addQuotaToVcpuQuotaList(quotaPerUserUsageEntity); @@ -268,116 +220,88 @@ addQuotaToStorageQuotaList(quotaPerUserUsageEntity); } - if (unlimitedVcpu) { - cpusProgressBar.setUnlimited(true); - } else { - cpusProgressBar.setValueA((int)aggregatedUsage.getOthersVcpuUsagePercentage()); - cpusProgressBar.setValueB((int) aggregatedUsage.getUserVcpuUsagePercentage()); - cpusProgressBar.setTitle(messages.quotaFreeCpus(aggregatedUsage.getFreeVcpu())); - } + cpusProgressBar.setValues(aggregatedUsage.getVcpuLimit(), + aggregatedUsage.getVcpuTotalUsage() - aggregatedUsage.getVcpuUsageForUser(), + aggregatedUsage.getVcpuUsageForUser()); + memoryProgressBar.setValues(aggregatedUsage.getMemoryLimit(), + aggregatedUsage.getMemoryTotalUsage() - aggregatedUsage.getMemoryUsageForUser(), + aggregatedUsage.getMemoryUsageForUser()); + storageProgressBar.setValues(aggregatedUsage.getStorageLimit(), + aggregatedUsage.getStorageTotalUsage() - aggregatedUsage.getStorageUsageForUser(), + aggregatedUsage.getStorageUsageForUser()); - if (unlimitedMem) { - memoryProgressBar.setUnlimited(true); - } else { - memoryProgressBar.setValueA((int)aggregatedUsage.getOthersMemoryUsagePercentage()); - memoryProgressBar.setValueB((int)aggregatedUsage.getUserMemoryUsagePercentage()); - String freeMem = aggregatedUsage.getFreeMemory() > 4096 ? - aggregatedUsage.getFreeMemory()/1024 + "GB" //$NON-NLS-1$ - : aggregatedUsage.getFreeMemory() + "MB"; //$NON-NLS-1$ - memoryProgressBar.setTitle(constants.freeMemory() + freeMem); - } - - if (unlimitedStorage) { - storageProgressBar.setUnlimited(true); - } else { - storageProgressBar.setValueA((int)aggregatedUsage.getOthersStorageUsagePercentage()); - storageProgressBar.setValueB((int)aggregatedUsage.getUserStorageUsagePercentage()); - String freeStorage = aggregatedUsage.getFreeStorage() == 0 ? - "0" : //$NON-NLS-1$ - diskSizeRenderer.render(aggregatedUsage.getFreeStorage()); - storageProgressBar.setTitle(constants.freeStorage() + freeStorage); - } - - vcpuExpander.setTitleWhenCollapsed(constants.showQuotaDistribution() + " (" + list.size() + ")"); //$NON-NLS-1$ //$NON-NLS-2$ + String title = constants.showQuotaDistribution() + " (" + list.size() + ")"; //$NON-NLS-1$ //$NON-NLS-2$ + vcpuExpander.setTitleWhenCollapsed(title); + memoryExpander.setTitleWhenCollapsed(title); + storageExpander.setTitleWhenCollapsed(title); } } private void addQuotaToVcpuQuotaList(QuotaUsagePerUser quotaPerUserUsageEntity) { - QuotaProgressBar vcpuQuotaProgressBar = new QuotaProgressBar(); - if (quotaPerUserUsageEntity.isUnlimitedVcpu()) { - vcpuQuotaProgressBar.setUnlimited(true); - } else { - vcpuQuotaProgressBar.setValueA((int) quotaPerUserUsageEntity.getOthersVcpuUsagePercentage()); - vcpuQuotaProgressBar.setValueB((int) quotaPerUserUsageEntity.getUserVcpuUsagePercentage()); - vcpuQuotaProgressBar.setTitle(messages.quotaFreeCpus(quotaPerUserUsageEntity.getFreeVcpu())); - if (quotaPerUserUsageEntity.getVcpuTotalUsage() == 0) { - vcpuQuotaProgressBar.setZeroValue(); - } - } - + QuotaProgressBar vcpuQuotaProgressBar = new QuotaProgressBar(QuotaProgressBar.QuotaType.CPU); + vcpuQuotaProgressBar.setValues(quotaPerUserUsageEntity.getVcpuLimit(), + quotaPerUserUsageEntity.getVcpuTotalUsage() - quotaPerUserUsageEntity.getVcpuUsageForUser(), + quotaPerUserUsageEntity.getVcpuUsageForUser()); addQuotaRow(cpusQuotasList, quotaPerUserUsageEntity.getQuotaName(), vcpuQuotaProgressBar); + } + + private void addQuotaToMemoryQuotaList(QuotaUsagePerUser quotaPerUserUsageEntity) { + QuotaProgressBar memoryQuotaProgressBar = new QuotaProgressBar(QuotaProgressBar.QuotaType.MEM); + memoryQuotaProgressBar.setValues(quotaPerUserUsageEntity.getMemoryLimit(), + quotaPerUserUsageEntity.getMemoryTotalUsage() - quotaPerUserUsageEntity.getMemoryUsageForUser(), + quotaPerUserUsageEntity.getMemoryUsageForUser()); + addQuotaRow(memoryQuotasList, quotaPerUserUsageEntity.getQuotaName(), memoryQuotaProgressBar); + } + + private void addQuotaToStorageQuotaList(QuotaUsagePerUser quotaPerUserUsageEntity) { + QuotaProgressBar storageQuotaProgressBar = new QuotaProgressBar(QuotaProgressBar.QuotaType.STORAGE); + storageQuotaProgressBar.setValues(quotaPerUserUsageEntity.getStorageLimit(), + quotaPerUserUsageEntity.getStorageTotalUsage() - quotaPerUserUsageEntity.getStorageUsageForUser(), + quotaPerUserUsageEntity.getStorageUsageForUser()); + addQuotaRow(storageQuotasList, quotaPerUserUsageEntity.getQuotaName(), storageQuotaProgressBar); } private void addQuotaRow(VerticalPanel list, String quotaName, QuotaProgressBar progressBar) { FlowPanel flowPanel = new FlowPanel(); Label quotaNameLabel = new Label(); quotaNameLabel.setText(quotaName); + quotaNameLabel.setStyleName(style.quotaNameText()); flowPanel.add(quotaNameLabel); flowPanel.add(progressBar); - flowPanel.setWidth("100%"); //$NON-NLS-1$ list.add(flowPanel); } - private void addQuotaToMemoryQuotaList(QuotaUsagePerUser quotaPerUserUsageEntity) { - QuotaProgressBar memoryQuotaProgressBar = new QuotaProgressBar(); - if (quotaPerUserUsageEntity.isUnlimitedMemory()) { - memoryQuotaProgressBar.setUnlimited(true); - } else { - memoryQuotaProgressBar.setValueA((int) quotaPerUserUsageEntity.getOthersMemoryUsagePercentage()); - memoryQuotaProgressBar.setValueB((int) quotaPerUserUsageEntity.getUserMemoryUsagePercentage()); - String freeMem = quotaPerUserUsageEntity.getFreeMemory() > 4096 ? - quotaPerUserUsageEntity.getFreeMemory()/1024 + "GB" //$NON-NLS-1$ - : quotaPerUserUsageEntity.getFreeMemory() + "MB"; //$NON-NLS-1$ - memoryQuotaProgressBar.setTitle(constants.freeMemory() + freeMem); - if (quotaPerUserUsageEntity.getMemoryTotalUsage() == 0) { - memoryQuotaProgressBar.setZeroValue(); - } - } - - addQuotaRow(memoryQuotasList, quotaPerUserUsageEntity.getQuotaName(), memoryQuotaProgressBar); - } - - private void addQuotaToStorageQuotaList(QuotaUsagePerUser quotaPerUserUsageEntity) { - QuotaProgressBar storageQuotaProgressBar = new QuotaProgressBar(); - if (quotaPerUserUsageEntity.isUnlimitedStorage()) { - storageQuotaProgressBar.setUnlimited(true); - } else { - storageQuotaProgressBar.setValueA((int) quotaPerUserUsageEntity.getOthersStorageUsagePercentage()); - storageQuotaProgressBar.setValueB((int) quotaPerUserUsageEntity.getUserStorageUsagePercentage()); - String freeStorage = quotaPerUserUsageEntity.getFreeStorage() == 0 ? - "0" : //$NON-NLS-1$ - diskSizeRenderer.render(quotaPerUserUsageEntity.getFreeStorage()); - storageQuotaProgressBar.setTitle(constants.freeStorage() + freeStorage); - if (quotaPerUserUsageEntity.getStorageTotalUsage() == 0) { - storageQuotaProgressBar.setZeroValue(); - } - } - - addQuotaRow(storageQuotasList, quotaPerUserUsageEntity.getQuotaName(), storageQuotaProgressBar); - } - private void aggregate(QuotaUsagePerUser aggregatedUsage, QuotaUsagePerUser quotaPerUserUsageEntity) { - aggregatedUsage.setVcpuLimit(quotaPerUserUsageEntity.getVcpuLimit() + aggregatedUsage.getVcpuLimit()); - aggregatedUsage.setVcpuUsageForUser(quotaPerUserUsageEntity.getVcpuUsageForUser() + aggregatedUsage.getVcpuUsageForUser()); - aggregatedUsage.setVcpuTotalUsage(quotaPerUserUsageEntity.getVcpuTotalUsage() + aggregatedUsage.getVcpuTotalUsage()); + if (quotaPerUserUsageEntity.isUnlimitedVcpu() || aggregatedUsage.isUnlimitedVcpu()) { + aggregatedUsage.setVcpuLimit(QuotaProgressBar.UNLIMITED); + } else { + aggregatedUsage.setVcpuLimit(quotaPerUserUsageEntity.getVcpuLimit() + aggregatedUsage.getVcpuLimit()); + } + aggregatedUsage.setVcpuUsageForUser(quotaPerUserUsageEntity.getVcpuUsageForUser() + + aggregatedUsage.getVcpuUsageForUser()); + aggregatedUsage.setVcpuTotalUsage(quotaPerUserUsageEntity.getVcpuTotalUsage() + + aggregatedUsage.getVcpuTotalUsage()); - aggregatedUsage.setMemoryLimit(quotaPerUserUsageEntity.getMemoryLimit() + aggregatedUsage.getMemoryLimit()); - aggregatedUsage.setMemoryUsageForUser(quotaPerUserUsageEntity.getMemoryUsageForUser() + aggregatedUsage.getMemoryUsageForUser()); - aggregatedUsage.setMemoryTotalUsage(quotaPerUserUsageEntity.getMemoryTotalUsage() + aggregatedUsage.getMemoryTotalUsage()); + if (quotaPerUserUsageEntity.isUnlimitedMemory() || aggregatedUsage.isUnlimitedMemory()) { + aggregatedUsage.setMemoryLimit(QuotaProgressBar.UNLIMITED); + } else { + aggregatedUsage.setMemoryLimit(quotaPerUserUsageEntity.getMemoryLimit() + aggregatedUsage.getMemoryLimit()); + } + aggregatedUsage.setMemoryUsageForUser(quotaPerUserUsageEntity.getMemoryUsageForUser() + + aggregatedUsage.getMemoryUsageForUser()); + aggregatedUsage.setMemoryTotalUsage(quotaPerUserUsageEntity.getMemoryTotalUsage() + + aggregatedUsage.getMemoryTotalUsage()); - aggregatedUsage.setStorageLimit(quotaPerUserUsageEntity.getStorageLimit() + aggregatedUsage.getStorageLimit()); - aggregatedUsage.setStorageUsageForUser(quotaPerUserUsageEntity.getStorageUsageForUser() + aggregatedUsage.getStorageUsageForUser()); - aggregatedUsage.setStorageTotalUsage(quotaPerUserUsageEntity.getStorageTotalUsage() + aggregatedUsage.getStorageTotalUsage()); + if (quotaPerUserUsageEntity.isUnlimitedStorage() || aggregatedUsage.isUnlimitedStorage()) { + aggregatedUsage.setStorageLimit(QuotaProgressBar.UNLIMITED); + } else { + aggregatedUsage.setStorageLimit(quotaPerUserUsageEntity.getStorageLimit() + + aggregatedUsage.getStorageLimit()); + } + aggregatedUsage.setStorageUsageForUser(quotaPerUserUsageEntity.getStorageUsageForUser() + + aggregatedUsage.getStorageUsageForUser()); + aggregatedUsage.setStorageTotalUsage(quotaPerUserUsageEntity.getStorageTotalUsage() + + aggregatedUsage.getStorageTotalUsage()); } @Override @@ -393,13 +317,6 @@ } interface Style extends CssResource { - - String infoBoxLeft(); - String infoBoxMiddle(); - String infoBoxRight(); - String infoBoxLeftExtended(); - String infoBoxMiddleExtended(); - String infoBoxRightExtended(); + String quotaNameText(); } - } diff --git a/frontend/webadmin/modules/userportal-gwtp/src/main/java/org/ovirt/engine/ui/userportal/section/main/view/tab/extended/SideTabExtendedResourceView.ui.xml b/frontend/webadmin/modules/userportal-gwtp/src/main/java/org/ovirt/engine/ui/userportal/section/main/view/tab/extended/SideTabExtendedResourceView.ui.xml index 0415257..3e0dd3b 100644 --- a/frontend/webadmin/modules/userportal-gwtp/src/main/java/org/ovirt/engine/ui/userportal/section/main/view/tab/extended/SideTabExtendedResourceView.ui.xml +++ b/frontend/webadmin/modules/userportal-gwtp/src/main/java/org/ovirt/engine/ui/userportal/section/main/view/tab/extended/SideTabExtendedResourceView.ui.xml @@ -14,141 +14,109 @@ <ui:with field='constants' type='org.ovirt.engine.ui.userportal.ApplicationConstants' /> <ui:style type="org.ovirt.engine.ui.userportal.section.main.view.tab.extended.SideTabExtendedResourceView.Style"> + .parent { + background-color: #f1f1f1; + } + .mainPanel { float: left; - margin-left: 15px; + margin: 15px; margin-right: 20px; - height: 100%; - overflow-x: hidden; - overflow-y: visible; - width: 98%; - } - - .infoContainerLeft, .infoContainerMiddle, .infoContainerRight { - padding-top: 15px; - min-width: 260px; - } - - .infoContainerLeft { - float: left; - width: 33%; - } - - .infoContainerMiddle { - float: left; - width: 32%; - padding-left: 5px; - } - - .infoContainerRight { - float: right; - width: 33%; - padding-left: 5px; - } - - .infoContainerContainer { - overflow: visible; + margin-top: 15px; + height: 98%; width: 100%; - float: left; + background-color: #f1f1f1; } - .infoBoxLeft, .infoBoxMiddle, .infoBoxRight, .infoBoxLeftExtended, .infoBoxMiddleExtended, .infoBoxRightExtended { + .westPanel { + overflow: visible; + height: 100%; + } + + .infoBoxCpu, .infoBoxMemory { width: 260px; border-style: solid; border-width: 1px; - border-color: #e3eaf2; - padding-top: 8px; - padding-left: 8px; + border-color: #7a7a7a; + padding: 1px; border-radius: 9px; + background-color: white; + box-shadow: 2px 2px 5px #888888; + position: absolute; + margin-bottom: 15px; } - .infoBoxLeft, .infoBoxMiddle, .infoBoxRight { - height: 120px; - } - - .infoBoxLeftExtended, .infoBoxMiddleExtended, .infoBoxRightExtended { - height: 230px; - } - - .infoBoxMiddle, .infoBoxMiddleExtended { - margin: 0 auto; - } - - .infoBoxLeft, .infoBoxLeftExtended { + .headingContainer { float: left; - } - - .infoBoxRight, .infoBoxRightExtended { - float: right; + background-color: #273240; + width: 100%; + border-radius: 9px 9px 0 0; } .iconImageContainer { float: left; + padding-top: 1px; + padding-left: 4px; } - .infoBoxDetailsRowLabel, .infoBoxDetailsRowValue, .detailsBoxRowLabel, .detailsBoxRowValue { + .headingTextContainer { + float: left; + padding: 10px; + } + + .detailsBoxRowLabel, .detailsBoxRowValue { float: left; padding-top: 7px; - } - - .infoBoxDetailsRowLabel, .detailsBoxRowLabel { - color: #3A5F7D; font-family: Arial,sans-serif; font-size: 13px; + } + + .detailsBoxRowLabel { text-align: left; width: 50%; } - .infoBoxDetailsRowValue, .detailsBoxRowValue { + .detailsBoxRowValue { color: black; - font-family: Arial,sans-serif; - font-size: 13px; padding-left: 7px; - text-align: left; + text-align: right; width: 30%; } .resourcesGeneralLabel { - color: black; + color: white; font-family: Arial,sans-serif; - font-size: 14px; + font-size: 18px; font-weight: bold; - } - - .infoBoxDetailsRow { - width: 100%; } .infoBoxDetails, .infoBoxDetailsStorage { float: left; - width: 84%; + width: 100%; padding-left: 8px; } .infoBoxDetailsStorage { - margin: 30px; - } - - .bottomBorder { - border-width: 1px; - border-color: #e3eaf2; - border-style: solid; - width: 100%; - margin-top: 15px; - margin-bottom: 15px; - float: left; - border-radius: 9px; + border-right-width: 1px; + border-right-color: #e3eaf2; + border-right-style: solid; + width: 260px; height: 265px; } - .storageBox { - padding-top: 8px; - padding-left: 15px; - width: 350px; - float: left; + .centerPanel { + border-width: 1px; + border-color: #7a7a7a; + border-style: solid; + width: 99%; + margin-bottom: 15px; + border-radius: 9px; + background-color: white; + box-shadow: 2px 2px 5px #888888; + padding: 1px; } - .storageBoxLow { + .snapshotsDataPanel { padding-top: 8px; padding-left: 15px; width: 350px; @@ -159,49 +127,69 @@ width: 100%; } - .detailsBoxRowLabel { - width: 60%; - } - - .detailsBoxRowValue { - width: 30%; - } - .expanderContent { float: left; - width: 90%; - height: 100px; + width: 97%; + height: 160px; + overflow-x: hidden; + overflow-y: scroll; } .expander { margin-top:15px; + float: left; + width: 95%; + height: 17px; + background-color: #d5d5d5; + font-size: 9px; + font-weight: bold; } .progressBar { width: 80%; + margin-left: 7px; } .quotaList { width: 100%; - height: auto; + height: 100px; + } + + .othersUseLabel, .youUseLabel{ + height: 7px; + width: 7px; + margin: 3px; + float: left; } .othersUseLabel { - height: 7px; - width: 7px; background-color: #b6c2cb; - margin: 3px; } .youUseLabel { - height: 7px; - width: 7px; background-color: #043459; + } + + .freeLabel { + height: 6px; + width: 6px; + background-color: #ffffff; + border-style: solid; + border-width: 1px; + border-color: #7a7a7a; margin: 3px; + float: left; } .legend { width: 10; + float: left; + } + + .legendRight { + width: 10; + float: left; + margin-left: 15px; } .line { @@ -213,138 +201,194 @@ margin-top: 8px; } + .verticalLine { + height: 100%; + width: 10px; + border-right-width: 1px; + border-right-color: #e3eaf2; + border-right-style: solid; + } + .refreshPanel { - float: right; + float: left; + cursor: hand; cursor: pointer; border: 1px solid transparent; display: table-cell; width: 30px; } - .refreshPanelWrapper { - text-align: right; + .legendContainer { + background-color: #f1f3f6; + font-size: 10px; + float: left; + width: 100%; + height: 13px; + padding-top: 2px; + } + + .legendText { + float: left; + } + + .vmTablePanel { + height: 40%; + width: 99%; + visibility: visible; + } + + .quotaSummaryText, .vmDisksAndSnapshotsText { + float: left; + margin-top: 10px; + margin-bottom: 2px; + margin-left: 10px; + font-size: 12px; + font-weight: bold; + } + + .quotaNameText { + font-size: 12px; + font-weight: bold; + } + + .vmDisksAndSnapshotsText { + margin-left: 15px; } </ui:style> - <g:FlowPanel> - <g:SimplePanel width="100%"> - <f:RefreshPanel ui:field="refreshPanel" addStyleNames="{style.refreshPanel}" /> - </g:SimplePanel> - <g:ScrollPanel> - <g:FlowPanel ui:field="mainPanel" addStyleNames="{style.mainPanel}"> - <g:FlowPanel ui:field="infoContainer" addStyleNames="{style.infoContainerContainer}"> - <g:FlowPanel addStyleNames="{style.infoContainerLeft}"> - <g:FlowPanel ui:field="infoBoxLeft" addStyleNames="{style.infoBoxLeft}"> - <g:FlowPanel> - <g:FlowPanel addStyleNames="{style.iconImageContainer}"> - <g:Image resource='{resources.vmIcon}'/> - </g:FlowPanel> - <g:FlowPanel addStyleNames="{style.infoBoxDetails}"> - <g:Label text="{constants.vmsExtResource}:" - addStyleNames="{style.resourcesGeneralLabel}"/> - <w:PercentageProgressBar ui:field="vmsProgressBar" addStyleNames="{style.progressBar}"/> + <g:FlowPanel addStyleNames="{style.parent}"> - <g:FlowPanel addStyleNames="{style.infoBoxDetailsRow}"> - <g:Label text="{constants.definedVmsExtResource}:" - addStyleNames="{style.infoBoxDetailsRowLabel}"/> - <w:ToStringEntityModelLabel - ui:field="definedVms" addStyleNames="{style.infoBoxDetailsRowValue}"/> + + <g:DockLayoutPanel ui:field="mainPanel" addStyleNames="{style.mainPanel}"> + <g:west size='280'> + <g:DockLayoutPanel unit="PCT" ui:field="infoContainer" addStyleNames="{style.westPanel}"> + <g:north size='50'> + <g:FlowPanel ui:field="infoBoxCpu" addStyleNames="{style.infoBoxCpu}"> + + <g:FlowPanel addStyleNames="{style.headingContainer}"> + <g:FlowPanel addStyleNames="{style.iconImageContainer}"> + <g:Image resource='{resources.cpuIcon}'/> </g:FlowPanel> - - <g:FlowPanel addStyleNames="{style.infoBoxDetailsRow}"> - <g:Label text="{constants.runningVmsExtResource}:" - addStyleNames="{style.infoBoxDetailsRowLabel}"/> - <w:ToStringEntityModelLabel - ui:field="runningVms" addStyleNames="{style.infoBoxDetailsRowValue}"/> + <g:FlowPanel addStyleNames="{style.headingTextContainer}"> + <g:Label text="{constants.vcpusExtResource}" + addStyleNames="{style.resourcesGeneralLabel}"/> </g:FlowPanel> </g:FlowPanel> - - </g:FlowPanel> - </g:FlowPanel> - </g:FlowPanel> - - <g:FlowPanel addStyleNames="{style.infoContainerMiddle}"> - <g:FlowPanel ui:field="infoBoxMiddle" addStyleNames="{style.infoBoxMiddle}"> - <g:FlowPanel> - <g:FlowPanel addStyleNames="{style.iconImageContainer}"> - <g:Image resource='{resources.cpuIcon}'/> + <g:FlowPanel addStyleNames="{style.legendContainer}"> + <g:FlowPanel addStyleNames="{style.legend}"> + <g:SimplePanel addStyleNames="{style.othersUseLabel}"/> + <g:Label text="{constants.othersUseQuota}" addStyleNames="{style.legendText}"/> + </g:FlowPanel> + <g:FlowPanel addStyleNames="{style.legendRight}"> + <g:SimplePanel addStyleNames="{style.youUseLabel}"/> + <g:Label text="{constants.youUseQuota}" addStyleNames="{style.legendText}"/> + </g:FlowPanel> + <g:FlowPanel addStyleNames="{style.legendRight}"> + <g:SimplePanel addStyleNames="{style.freeLabel}"/> + <g:Label text="{constants.freeQuota}" addStyleNames="{style.legendText}"/> + </g:FlowPanel> </g:FlowPanel> <g:FlowPanel addStyleNames="{style.infoBoxDetails}"> - - - <g:Label text="{constants.vcpusExtResource}:" - addStyleNames="{style.resourcesGeneralLabel}"/> + <g:Label text="{constants.quotaSummary}" addStyleNames="{style.quotaSummaryText}"/> <w:QuotaProgressBar ui:field="cpusProgressBar" addStyleNames="{style.progressBar}"/> - <g:HorizontalPanel addStyleNames="{style.legend}"> - <g:SimplePanel addStyleNames="{style.othersUseLabel}"/> - <g:Label text="{constants.othersUseQuota}"/> - </g:HorizontalPanel> - <g:HorizontalPanel addStyleNames="{style.legend}"> - <g:SimplePanel addStyleNames="{style.youUseLabel}"/> - <g:Label text="{constants.youUseQuota}"/> - </g:HorizontalPanel> - <g:SimplePanel addStyleNames="{style.line}"/> - <g:FlowPanel> - <d:AdvancedParametersExpander ui:field="vcpuExpander" - addStyleNames="{style.expander}"/> - <g:ScrollPanel ui:field="vcpuExpanderContent" - addStyleNames="{style.expanderContent}"> - <g:VerticalPanel ui:field="cpusQuotasList" addStyleNames="{style.quotaList}"/> - </g:ScrollPanel> - </g:FlowPanel> - + <d:AdvancedParametersExpander ui:field="vcpuExpander" addStyleNames="{style.expander}"/> + <g:ScrollPanel ui:field="vcpuExpanderContent" addStyleNames="{style.expanderContent}"> + <g:VerticalPanel ui:field="cpusQuotasList" addStyleNames="{style.quotaList}"/> + </g:ScrollPanel> </g:FlowPanel> </g:FlowPanel> - </g:FlowPanel> - </g:FlowPanel> - - <g:FlowPanel addStyleNames="{style.infoContainerRight}"> - <g:FlowPanel ui:field="infoBoxRight" addStyleNames="{style.infoBoxRight}"> - <g:FlowPanel> - <g:FlowPanel addStyleNames="{style.iconImageContainer}"> - <g:Image resource='{resources.memoryIcon}'/> + </g:north> + <g:south size='50'> + <g:FlowPanel ui:field="infoBoxMemory" addStyleNames="{style.infoBoxMemory}"> + <g:FlowPanel addStyleNames="{style.headingContainer}"> + <g:FlowPanel addStyleNames="{style.iconImageContainer}"> + <g:Image resource='{resources.memoryIcon}'/> + </g:FlowPanel> + <g:FlowPanel addStyleNames="{style.headingTextContainer}"> + <g:Label text="{constants.memExtResource}" + addStyleNames="{style.resourcesGeneralLabel}"/> + </g:FlowPanel> + </g:FlowPanel> + <g:FlowPanel addStyleNames="{style.legendContainer}"> + <g:FlowPanel addStyleNames="{style.legend}"> + <g:SimplePanel addStyleNames="{style.othersUseLabel}"/> + <g:Label text="{constants.othersUseQuota}" addStyleNames="{style.legendText}"/> + </g:FlowPanel> + <g:FlowPanel addStyleNames="{style.legendRight}"> + <g:SimplePanel addStyleNames="{style.youUseLabel}"/> + <g:Label text="{constants.youUseQuota}" addStyleNames="{style.legendText}"/> + </g:FlowPanel> + <g:FlowPanel addStyleNames="{style.legendRight}"> + <g:SimplePanel addStyleNames="{style.freeLabel}"/> + <g:Label text="{constants.freeQuota}" addStyleNames="{style.legendText}"/> + </g:FlowPanel> </g:FlowPanel> <g:FlowPanel addStyleNames="{style.infoBoxDetails}"> - <g:Label text="{constants.memExtResource}:" - addStyleNames="{style.resourcesGeneralLabel}"/> + <g:Label text="{constants.quotaSummary}" addStyleNames="{style.quotaSummaryText}"/> + <w:QuotaProgressBar ui:field="memoryProgressBar" addStyleNames="{style.progressBar}"/> - <g:HorizontalPanel addStyleNames="{style.legend}"> - <g:SimplePanel addStyleNames="{style.othersUseLabel}"/> - <g:Label text="{constants.othersUseQuota}"/> - </g:HorizontalPanel> - <g:HorizontalPanel addStyleNames="{style.legend}"> - <g:SimplePanel addStyleNames="{style.youUseLabel}"/> - <g:Label text="{constants.youUseQuota}"/> - </g:HorizontalPanel> - <g:SimplePanel addStyleNames="{style.line}"/> - <g:FlowPanel> - <d:AdvancedParametersExpander ui:field="memoryExpander" - addStyleNames="{style.expander}"/> - <g:ScrollPanel ui:field="memoryExpanderContent" - addStyleNames="{style.expanderContent}"> - <g:VerticalPanel ui:field="memoryQuotasList" addStyleNames="{style.quotaList}"/> - </g:ScrollPanel> - </g:FlowPanel> - </g:FlowPanel> + <d:AdvancedParametersExpander ui:field="memoryExpander" + addStyleNames="{style.expander}"/> + <g:ScrollPanel ui:field="memoryExpanderContent" + addStyleNames="{style.expanderContent}"> + <g:VerticalPanel ui:field="memoryQuotasList" addStyleNames="{style.quotaList}"/> + </g:ScrollPanel> + </g:FlowPanel> + </g:FlowPanel> + </g:south> + </g:DockLayoutPanel> + </g:west> + + <g:center> + <g:FlowPanel ui:field="bottomLayoutPanel" addStyleNames="{style.centerPanel}"> + <g:FlowPanel addStyleNames="{style.headingContainer}"> + <g:FlowPanel addStyleNames="{style.iconImageContainer}"> + <g:Image resource='{resources.storageIcon}'/> + </g:FlowPanel> + <g:FlowPanel addStyleNames="{style.headingTextContainer}"> + <g:Label text="{constants.storageExtResource}" + addStyleNames="{style.resourcesGeneralLabel}"/> </g:FlowPanel> </g:FlowPanel> - </g:FlowPanel> - </g:FlowPanel> - <g:DockLayoutPanel ui:field="bottomLayoutPanel" addStyleNames="{style.bottomBorder}"> - <g:north size='130'> <g:HorizontalPanel ui:field="bottomInfoBox"> - - <g:FlowPanel addStyleNames="{style.storageBox}"> - <g:FlowPanel addStyleNames="{style.iconImageContainer}"> - <g:Image resource='{resources.storageIcon}'/> + <g:FlowPanel addStyleNames="{style.infoBoxDetailsStorage}"> + <g:FlowPanel addStyleNames="{style.legendContainer}"> + <g:FlowPanel addStyleNames="{style.legend}"> + <g:SimplePanel addStyleNames="{style.othersUseLabel}"/> + <g:Label text="{constants.othersUseQuota}" addStyleNames="{style.legendText}"/> + </g:FlowPanel> + <g:FlowPanel addStyleNames="{style.legendRight}"> + <g:SimplePanel addStyleNames="{style.youUseLabel}"/> + <g:Label text="{constants.youUseQuota}" addStyleNames="{style.legendText}"/> + </g:FlowPanel> + <g:FlowPanel addStyleNames="{style.legendRight}"> + <g:SimplePanel addStyleNames="{style.freeLabel}"/> + <g:Label text="{constants.freeQuota}" addStyleNames="{style.legendText}"/> + </g:FlowPanel> </g:FlowPanel> + <g:Label text="{constants.quotaSummary}" addStyleNames="{style.quotaSummaryText}"/> + <w:QuotaProgressBar ui:field="storageProgressBar" addStyleNames="{style.progressBar}"/> + + + <g:FlowPanel> + <d:AdvancedParametersExpander ui:field="storageExpander" + addStyleNames="{style.expander}"/> + <g:ScrollPanel ui:field="storageExpanderContent" + addStyleNames="{style.expanderContent}"> + <g:VerticalPanel ui:field="storageQuotasList" addStyleNames="{style.quotaList}"/> + </g:ScrollPanel> + </g:FlowPanel> + </g:FlowPanel> + + <g:FlowPanel addStyleNames="{style.verticalLine}"/> + + <g:FlowPanel addStyleNames="{style.snapshotsDataPanel}"> + <g:FlowPanel addStyleNames="{style.infoBoxDetails}"> - <g:Label text="{constants.storageExtResource}:" - addStyleNames="{style.resourcesGeneralLabel}"/> <g:FlowPanel addStyleNames="{style.storageDetailsRow}"> <g:Label text="{constants.totalSizeExtResource}:" @@ -369,35 +413,19 @@ </g:FlowPanel> </g:FlowPanel> - <g:FlowPanel addStyleNames="{style.infoBoxDetailsStorage}"> - <!--<g:Label text="{constants.memExtResource}:" addStyleNames="{style.resourcesGeneralLabel}" />--> - <w:QuotaProgressBar ui:field="storageProgressBar" addStyleNames="{style.progressBar}"/> - <g:HorizontalPanel addStyleNames="{style.legend}"> - <g:SimplePanel addStyleNames="{style.othersUseLabel}"/> - <g:Label text="{constants.othersUseQuota}"/> - </g:HorizontalPanel> - <g:HorizontalPanel addStyleNames="{style.legend}"> - <g:SimplePanel addStyleNames="{style.youUseLabel}"/> - <g:Label text="{constants.youUseQuota}"/> - </g:HorizontalPanel> - <g:SimplePanel addStyleNames="{style.line}"/> - <g:FlowPanel> - <d:AdvancedParametersExpander ui:field="storageExpander" - addStyleNames="{style.expander}"/> - <g:ScrollPanel ui:field="storageExpanderContent" - addStyleNames="{style.expanderContent}"> - <g:VerticalPanel ui:field="storageQuotasList" addStyleNames="{style.quotaList}"/> - </g:ScrollPanel> - </g:FlowPanel> - </g:FlowPanel> </g:HorizontalPanel> - </g:north> - <g:center> - <r:VmTable ui:field="vmTable"/> - </g:center> - </g:DockLayoutPanel> - </g:FlowPanel> - </g:ScrollPanel> + <g:FlowPanel addStyleNames="{style.line}"/> + <g:Label text="{constants.vmDisksAndSnapshots}" addStyleNames="{style.vmDisksAndSnapshotsText}"/> + <r:VmTable ui:field="vmTable" addStyleNames="{style.vmTablePanel}"/> + </g:FlowPanel> + </g:center> + <g:east size='50'> + <g:SimplePanel width="100%"> + <f:RefreshPanel ui:field="refreshPanel" addStyleNames="{style.refreshPanel}"/> + </g:SimplePanel> + </g:east> + </g:DockLayoutPanel> + </g:FlowPanel> </ui:UiBinder> diff --git a/frontend/webadmin/modules/userportal-gwtp/src/main/java/org/ovirt/engine/ui/userportal/widget/DoublePercentageProgressBar.java b/frontend/webadmin/modules/userportal-gwtp/src/main/java/org/ovirt/engine/ui/userportal/widget/DoublePercentageProgressBar.java index 54aa988..8008856 100644 --- a/frontend/webadmin/modules/userportal-gwtp/src/main/java/org/ovirt/engine/ui/userportal/widget/DoublePercentageProgressBar.java +++ b/frontend/webadmin/modules/userportal-gwtp/src/main/java/org/ovirt/engine/ui/userportal/widget/DoublePercentageProgressBar.java @@ -27,8 +27,8 @@ initWidget(WidgetUiBinder.uiBinder.createAndBindUi(this)); } - private Object valueA; - private Object valueB; + private Integer valueA; + private Integer valueB; @UiField WidgetStyle style; @@ -57,21 +57,10 @@ public void setValueA(Integer value) { this.valueA = value; - String percentage = value + "%"; //$NON-NLS-1$ - percentageLabelA.setText(value < 10 ? "" : percentage); //$NON-NLS-1$ - percentageLabelA.setStyleName(style.percentageLabel()); - percentageBarA.setWidth(percentage); - percentageBarA.setVisible(value != 0); - percentageBarA.setTitle(percentage); } public void setValueB(Integer value) { this.valueB = value; - String percentage = value + "%"; //$NON-NLS-1$ - percentageLabelB.setText(value < 10 ? "" : percentage); //$NON-NLS-1$ - percentageBarB.setWidth(percentage); - percentageBarB.setVisible(value != 0); - percentageBarB.setTitle(percentage); } public void setZeroValue() { @@ -81,6 +70,40 @@ percentageBarA.setWidth("99%"); //$NON-NLS-1$ percentageLabelA.setText(ZERO); percentageLabelA.setStyleName(style.percentageLabelBlack()); + } + + public void setBars() { + int fakeA = valueA; + int fakeB = valueB; + + if (valueA != null && valueB != null && valueA + valueB >= 99) { + double factor = (double)98 / (valueA + valueB); + fakeA = (int)Math.round(factor * valueA); + fakeB = (int)Math.round(factor * valueB); + + fakeA = (fakeB == 0 ? 99 : fakeA); + fakeB = (fakeA == 0 ? 99 : fakeB); + } + + if (valueB != null) { + String percentageB = valueB + "%"; //$NON-NLS-1$ + String fakePercentageB = fakeB + "%"; //$NON-NLS-1$ + percentageLabelB.setText(valueB < 10 ? "" : percentageB); //$NON-NLS-1$ + percentageLabelB.setStyleName(style.percentageLabel()); + percentageBarB.setWidth(fakePercentageB); + percentageBarB.setVisible(valueB != 0); + percentageBarB.setTitle(percentageB); + } + + if (valueA != null) { + String percentageA = valueA + "%"; //$NON-NLS-1$ + String fakePercentageA = fakeA + "%"; //$NON-NLS-1$ + percentageLabelA.setText(valueA < 10 ? "" : percentageA); //$NON-NLS-1$ + percentageLabelA.setStyleName(style.percentageLabelBlack()); + percentageBarA.setWidth(fakePercentageA); + percentageBarA.setVisible(valueA != 0); + percentageBarA.setTitle(percentageA); + } } public Object getValueA() { @@ -106,6 +129,8 @@ String percentageBarUnlimited(); + String percentageBarExceeded(); + String empty(); String percentageBarA(); diff --git a/frontend/webadmin/modules/userportal-gwtp/src/main/java/org/ovirt/engine/ui/userportal/widget/DoublePercentageProgressBar.ui.xml b/frontend/webadmin/modules/userportal-gwtp/src/main/java/org/ovirt/engine/ui/userportal/widget/DoublePercentageProgressBar.ui.xml index 78442ab..fbb96e7 100644 --- a/frontend/webadmin/modules/userportal-gwtp/src/main/java/org/ovirt/engine/ui/userportal/widget/DoublePercentageProgressBar.ui.xml +++ b/frontend/webadmin/modules/userportal-gwtp/src/main/java/org/ovirt/engine/ui/userportal/widget/DoublePercentageProgressBar.ui.xml @@ -19,7 +19,8 @@ .percentageLabel, .percentageLabelBlack { text-align: center; font-family: Arial,sans-serif; - font-size: 12px; + font-size: 11px; + margin: 1px; } .percentageLabel { @@ -27,7 +28,7 @@ } .percentageLabelBlack { - color: black; + color: #043459; } .percentageBarA { @@ -48,11 +49,19 @@ .percentageBarUnlimited { float: left; - background-color: #e0e7ec; - width: 100%; + background-color: #009933; + width: 99%; height: 15px; margin: 1px 0 1px 1px; } + + .percentageBarExceeded { + float: left; + background-color: #ff0000; + width: 99%; + height: 15px; + margin: 1px 0 1px 1px; + } .empty { float: left; @@ -67,7 +76,7 @@ <g:FlowPanel addStyleNames="{style.progressBar}"> <g:FlowPanel addStyleNames="{style.percentageBox}"> <g:FlowPanel ui:field="percentageBarA" addStyleNames="{style.percentageBarA}"> - <g:Label text="0%" ui:field="percentageLabelA" addStyleNames="{style.percentageLabel}"/> + <g:Label text="0%" ui:field="percentageLabelA" addStyleNames="{style.percentageLabelBlack}"/> </g:FlowPanel> <g:FlowPanel ui:field="percentageBarB" addStyleNames="{style.percentageBarB}"> diff --git a/frontend/webadmin/modules/userportal-gwtp/src/main/java/org/ovirt/engine/ui/userportal/widget/QuotaProgressBar.java b/frontend/webadmin/modules/userportal-gwtp/src/main/java/org/ovirt/engine/ui/userportal/widget/QuotaProgressBar.java index 56219ab..81a5e17 100644 --- a/frontend/webadmin/modules/userportal-gwtp/src/main/java/org/ovirt/engine/ui/userportal/widget/QuotaProgressBar.java +++ b/frontend/webadmin/modules/userportal-gwtp/src/main/java/org/ovirt/engine/ui/userportal/widget/QuotaProgressBar.java @@ -1,15 +1,100 @@ package org.ovirt.engine.ui.userportal.widget; +import com.google.gwt.core.client.GWT; +import org.ovirt.engine.ui.common.CommonApplicationMessages; +import org.ovirt.engine.ui.common.widget.renderer.DiskSizeRenderer; +import org.ovirt.engine.ui.userportal.ApplicationConstants; + public class QuotaProgressBar extends DoublePercentageProgressBar { - public void setUnlimited(boolean unlimited) { - if (unlimited) { - percentageBarA.setStyleName(style.percentageBarUnlimited()); - percentageLabelA.setText("Unlimited"); //$NON-NLS-1$ - percentageLabelA.setTitle("Unlimited"); //$NON-NLS-1$ + public static final int UNLIMITED = -1; + private static final CommonApplicationMessages messages = GWT.create(CommonApplicationMessages.class); + private static final ApplicationConstants constants = GWT.create(ApplicationConstants.class); + private static final DiskSizeRenderer<Number> diskSizeRenderer = + new DiskSizeRenderer<Number>(DiskSizeRenderer.DiskSizeUnit.GIGABYTE); + + private QuotaType type; + + public QuotaProgressBar(QuotaType type) { + this.type = type; + } + + public void setUnlimited() { + percentageBarA.setStyleName(style.percentageBarUnlimited()); + percentageLabelA.setStyleName(style.percentageLabel()); + percentageLabelA.setText("Unlimited"); //$NON-NLS-1$ + percentageLabelA.setTitle("Unlimited"); //$NON-NLS-1$ + percentageBarB.setVisible(false); + + } + + public void setExceeded(String title) { + percentageBarA.setStyleName(style.percentageBarExceeded()); + percentageLabelA.setStyleName(style.percentageLabel()); + percentageLabelA.setText("Exceeded"); //$NON-NLS-1$ + percentageLabelA.setTitle(title); + percentageBarB.setVisible(false); + } + + public void setValues(double limit, double consumedByOthers, double consumedByUser) { + + int othersConsumptionPercent = (int) Math.round(consumedByOthers * 100 / limit); + int userConsumptionPercent = (int) Math.round(consumedByUser * 100 / limit); + double free = limit - consumedByOthers - consumedByUser; + + switch (getType()) { + case STORAGE: + String freeStorage = free == 0 ? "0" : diskSizeRenderer.render(free); //$NON-NLS-1$ + setTitle(constants.freeStorage() + freeStorage); + break; + case CPU: + setTitle(messages.quotaFreeCpus((int) free)); + break; + case MEM: + String freeMem = free > 4096 ? diskSizeRenderer.render(free/1024) : (int) free + "MB"; //$NON-NLS-1$ //$NON-NLS-2$ + setTitle(constants.freeMemory() + freeMem); + break; + } + + if (limit == UNLIMITED) { // unlimited + setUnlimited(); + } else if (consumedByOthers + consumedByUser == 0) { // empty + setZeroValue(); + } else if (consumedByOthers + consumedByUser > limit) { // exceeded + switch (getType()) { + case STORAGE: + setExceeded(messages.exceedingStorage(othersConsumptionPercent + userConsumptionPercent - 100, -free)); + break; + case CPU: + setExceeded(messages.exceedingCpus(othersConsumptionPercent + userConsumptionPercent - 100, (int) -free)); + break; + case MEM: + String freeMem = free < -4096 ? diskSizeRenderer.render(-free/1024) : (int) -free + "MB"; //$NON-NLS-1$ //$NON-NLS-2$ + setExceeded(messages.exceedingMem(othersConsumptionPercent + userConsumptionPercent - 100, freeMem)); + break; + } } else { percentageBarA.setStyleName(style.percentageBarA()); + percentageLabelA.setStyleName(style.percentageLabelBlack()); + percentageBarB.setVisible(true); + setValueA(othersConsumptionPercent); + setValueB(userConsumptionPercent); + setBars(); } - percentageBarB.setVisible(!unlimited); } + + public QuotaType getType() { + return type; + } + + public void setType(QuotaType type) { + this.type = type; + } + + public static enum QuotaType { + STORAGE, + CPU, + MEM + } + } diff --git a/frontend/webadmin/modules/userportal-gwtp/src/main/resources/org/ovirt/engine/ui/userportal/images/general/storage_icon.png b/frontend/webadmin/modules/userportal-gwtp/src/main/resources/org/ovirt/engine/ui/userportal/images/general/storage_icon.png index 167c729..fb51477 100644 --- a/frontend/webadmin/modules/userportal-gwtp/src/main/resources/org/ovirt/engine/ui/userportal/images/general/storage_icon.png +++ b/frontend/webadmin/modules/userportal-gwtp/src/main/resources/org/ovirt/engine/ui/userportal/images/general/storage_icon.png Binary files differ -- To view, visit http://gerrit.ovirt.org/11259 To unsubscribe, visit http://gerrit.ovirt.org/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I26ea6eb7f7ec93ffa69a2a4dea52c7e5d50dead9 Gerrit-PatchSet: 1 Gerrit-Project: ovirt-engine Gerrit-Branch: master Gerrit-Owner: ofri masad <oma...@redhat.com> _______________________________________________ Engine-patches mailing list Engine-patches@ovirt.org http://lists.ovirt.org/mailman/listinfo/engine-patches