anmolbabu has uploaded a new change for review.

Change subject: webadmin : Introduce volume profile pdf Export option
......................................................................

webadmin : Introduce volume profile pdf Export option

Introduce volume profile pdf Export option.

Change-Id: I9791208b327dbe3e3b4dacfb568f08e042e8b8c9
Signed-off-by: Anmol Babu <[email protected]>
---
M 
frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/gluster/VolumeProfileStatisticsModel.java
M 
frontend/webadmin/modules/webadmin/src/main/java/org/ovirt/engine/ui/webadmin/ApplicationConstants.java
M 
frontend/webadmin/modules/webadmin/src/main/java/org/ovirt/engine/ui/webadmin/section/main/view/popup/gluster/VolumeProfileStatisticsPopupView.java
M 
frontend/webadmin/modules/webadmin/src/main/java/org/ovirt/engine/ui/webadmin/section/main/view/popup/gluster/VolumeProfileStatisticsPopupView.ui.xml
4 files changed, 53 insertions(+), 7 deletions(-)


  git pull ssh://gerrit.ovirt.org:29418/ovirt-engine refs/changes/65/30265/1

diff --git 
a/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/gluster/VolumeProfileStatisticsModel.java
 
b/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/gluster/VolumeProfileStatisticsModel.java
index caa12e9..4a4b796 100644
--- 
a/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/gluster/VolumeProfileStatisticsModel.java
+++ 
b/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/gluster/VolumeProfileStatisticsModel.java
@@ -13,6 +13,7 @@
 import org.ovirt.engine.core.common.utils.SizeConverter;
 import org.ovirt.engine.core.common.utils.SizeConverter.SizeUnit;
 import org.ovirt.engine.core.compat.Guid;
+import org.ovirt.engine.core.compat.StringFormat;
 import org.ovirt.engine.ui.frontend.AsyncQuery;
 import org.ovirt.engine.ui.frontend.INewAsyncCallback;
 import org.ovirt.engine.ui.uicommonweb.dataprovider.AsyncDataProvider;
@@ -44,6 +45,8 @@
     private Guid clusterId;
     private Guid volumeId;
     private String volumeName;
+
+    private String profileExportUrl;
 
     private GlusterVolumeProfileInfo profileInfo;
 
@@ -225,6 +228,7 @@
                     GlusterVolumeProfileInfo aggregatedProfileInfo = new 
GlusterVolumeProfileInfo();
                     
aggregatedProfileInfo.setBrickProfileDetails((profileInfoEntity.getBrickProfileDetails()
 != null) ? profileInfoEntity.getBrickProfileDetails() : 
getProfileInfo().getBrickProfileDetails());
                     
aggregatedProfileInfo.setNfsProfileDetails((profileInfoEntity.getNfsProfileDetails()
 != null) ? profileInfoEntity.getNfsProfileDetails() : 
getProfileInfo().getNfsProfileDetails());
+                    setProfileExportUrl(formProfileUrl(clusterId.toString(), 
volumeId.toString(), isBrickSelected));
                     setProfileInfo(aggregatedProfileInfo);
                     setSuccessfulProfileStatsFetch(true);
                     
setTitle(ConstantsManager.getInstance().getMessages().volumeProfilingStatsTitle(volumeName));
@@ -283,6 +287,20 @@
         return 
messages.bytesWrittenInCurrentProfileInterval(formatSize(dataWrittenInCurrentInterval.getSecond()),
 dataWrittenInCurrentInterval.getFirst().toString(), 
formatSize(dataWritten.getSecond()), dataWritten.getFirst().toString());
     }
 
+    private String formProfileUrl(String clusterId, String volumeId, boolean 
isBrickProfileSelected)
+    {
+        String apiMatrixParam = ((!isBrickProfileSelected) ? 
";nfsStatistics=true" : "");//$NON-NLS-1$//$NON-NLS-2$
+        return 
StringFormat.format("/ovirt-engine/api/clusters/%s/glustervolumes/%s/profilestatistics%s?accept=application/pdf",
 clusterId, volumeId, apiMatrixParam);//$NON-NLS-1$
+    }
+
+    public String getProfileExportUrl() {
+        return profileExportUrl;
+    }
+
+    public void setProfileExportUrl(String profileExportUrl) {
+        this.profileExportUrl = profileExportUrl;
+    }
+
     public String formatSize(double size) {
         return NumberFormat.getFormat("#.##").format(size);//$NON-NLS-1$
     }
diff --git 
a/frontend/webadmin/modules/webadmin/src/main/java/org/ovirt/engine/ui/webadmin/ApplicationConstants.java
 
b/frontend/webadmin/modules/webadmin/src/main/java/org/ovirt/engine/ui/webadmin/ApplicationConstants.java
index 8d50e52..7fe8bcd 100644
--- 
a/frontend/webadmin/modules/webadmin/src/main/java/org/ovirt/engine/ui/webadmin/ApplicationConstants.java
+++ 
b/frontend/webadmin/modules/webadmin/src/main/java/org/ovirt/engine/ui/webadmin/ApplicationConstants.java
@@ -3743,4 +3743,7 @@
 
     @DefaultStringValue("Could not fetch brick profile stats")
     String brickProfileErrorMessage();
+
+    @DefaultStringValue("Save As Pdf")
+    String exportToPdf();
 }
diff --git 
a/frontend/webadmin/modules/webadmin/src/main/java/org/ovirt/engine/ui/webadmin/section/main/view/popup/gluster/VolumeProfileStatisticsPopupView.java
 
b/frontend/webadmin/modules/webadmin/src/main/java/org/ovirt/engine/ui/webadmin/section/main/view/popup/gluster/VolumeProfileStatisticsPopupView.java
index b51aa55..ca90160 100644
--- 
a/frontend/webadmin/modules/webadmin/src/main/java/org/ovirt/engine/ui/webadmin/section/main/view/popup/gluster/VolumeProfileStatisticsPopupView.java
+++ 
b/frontend/webadmin/modules/webadmin/src/main/java/org/ovirt/engine/ui/webadmin/section/main/view/popup/gluster/VolumeProfileStatisticsPopupView.java
@@ -20,7 +20,6 @@
 import org.ovirt.engine.ui.uicompat.IEventListener;
 import org.ovirt.engine.ui.uicompat.PropertyChangedEventArgs;
 import org.ovirt.engine.ui.webadmin.ApplicationConstants;
-import org.ovirt.engine.ui.webadmin.ApplicationMessages;
 import org.ovirt.engine.ui.webadmin.ApplicationResources;
 import 
org.ovirt.engine.ui.webadmin.section.main.presenter.popup.gluster.VolumeProfileStatisticsPopupPresenterWidget;
 
@@ -32,6 +31,7 @@
 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.Anchor;
 import com.google.gwt.user.client.ui.Label;
 import com.google.inject.Inject;
 
@@ -85,6 +85,10 @@
     Label bytesWritten;
 
     @UiField
+    @WithElementId
+    Anchor brickProfileAnchor;
+
+    @UiField
     DialogTab nfsTab;
 
     @UiField
@@ -120,24 +124,32 @@
     @WithElementId
     Label nfsBytesWritten;
 
+    @UiField
+    @WithElementId
+    Anchor nfsProfileAnchor;
+
+    private final ApplicationConstants constants;
+    private final ApplicationResources resources;
+
     private final Driver driver = GWT.create(Driver.class);
 
     @Inject
     public VolumeProfileStatisticsPopupView(EventBus eventBus,
             ApplicationResources resources,
-            ApplicationConstants constants,
-            ApplicationMessages messages) {
+            ApplicationConstants constants) {
         super(eventBus, resources);
-        initEditors(constants, resources);
+        this.constants = constants;
+        this.resources = resources;
+        initEditors();
         initWidget(ViewUiBinder.uiBinder.createAndBindUi(this));
         ViewIdHandler.idHandler.generateAndSetIds(this);
-        localize(constants, messages);
+        localize();
         nfsErrorLabel.setVisible(false);
         bricksErrorLabel.setVisible(false);
         driver.initialize(this);
     }
 
-    private void localize(ApplicationConstants constants, ApplicationMessages 
messages) {
+    private void localize() {
         bricks.setLabel(constants.selectBrickToViewFopStats());
         nfsServers.setLabel(constants.selectServerToViewFopStats());
         bricksTab.setLabel(constants.volumeProfileBricksTab());
@@ -146,7 +158,7 @@
         nfsErrorLabel.setText(constants.nfsProfileErrorMessage());
     }
 
-    private void initEditors(ApplicationConstants constants, 
ApplicationResources resources) {
+    private void initEditors() {
         nfsRefreshIcon = new RefreshActionIcon(SafeHtmlUtils.EMPTY_SAFE_HTML, 
resources);
         brickRefreshIcon = new 
RefreshActionIcon(SafeHtmlUtils.EMPTY_SAFE_HTML, resources);
         bricks = new ListModelListBoxEditor<BrickProfileDetails>(new 
NullSafeRenderer<BrickProfileDetails>() {
@@ -237,6 +249,12 @@
 
     }
 
+    private void initAnchor(String url, Anchor anchor) {
+        anchor.setHref(url);
+        anchor.setText(constants.exportToPdf());
+        anchor.setTarget("_blank");//$NON-NLS-1$
+    }
+
     @Override
     public void edit(final VolumeProfileStatisticsModel object) {
         driver.edit(object);
@@ -291,6 +309,11 @@
                 }
                 if(e.propertyName.equals("statusOfFetchingProfileStats")) 
{//$NON-NLS-1$
                     boolean disableErrorLabels = 
!(object.isSuccessfulProfileStatsFetch());
+                    if(!disableErrorLabels) {
+                        String url = object.getProfileExportUrl();
+                        boolean isBrickTabSelected = 
!(url.contains(";nfsStatistics=true"));//$NON-NLS-1$
+                        initAnchor(url, (isBrickTabSelected) ? 
brickProfileAnchor : nfsProfileAnchor);
+                    }
                     bricksErrorLabel.setVisible(disableErrorLabels);
                     nfsErrorLabel.setVisible(disableErrorLabels);
                 }
diff --git 
a/frontend/webadmin/modules/webadmin/src/main/java/org/ovirt/engine/ui/webadmin/section/main/view/popup/gluster/VolumeProfileStatisticsPopupView.ui.xml
 
b/frontend/webadmin/modules/webadmin/src/main/java/org/ovirt/engine/ui/webadmin/section/main/view/popup/gluster/VolumeProfileStatisticsPopupView.ui.xml
index d1427fc..fcd935f 100644
--- 
a/frontend/webadmin/modules/webadmin/src/main/java/org/ovirt/engine/ui/webadmin/section/main/view/popup/gluster/VolumeProfileStatisticsPopupView.ui.xml
+++ 
b/frontend/webadmin/modules/webadmin/src/main/java/org/ovirt/engine/ui/webadmin/section/main/view/popup/gluster/VolumeProfileStatisticsPopupView.ui.xml
@@ -44,6 +44,7 @@
                     <g:Label ui:field="bytesRead" />
                     <g:Label ui:field="bytesWritten" />
                 </g:VerticalPanel>
+                <g:Anchor ui:field="brickProfileAnchor"/>
             </g:VerticalPanel>
             </g:SimplePanel>
             </t:content>
@@ -70,6 +71,7 @@
                     <g:Label ui:field="nfsBytesRead" />
                     <g:Label ui:field="nfsBytesWritten" />
                 </g:VerticalPanel>
+                <g:Anchor ui:field="nfsProfileAnchor"/>
             </g:VerticalPanel>
             </g:SimplePanel>
             </t:content>


-- 
To view, visit http://gerrit.ovirt.org/30265
To unsubscribe, visit http://gerrit.ovirt.org/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I9791208b327dbe3e3b4dacfb568f08e042e8b8c9
Gerrit-PatchSet: 1
Gerrit-Project: ovirt-engine
Gerrit-Branch: ovirt-engine-3.5
Gerrit-Owner: anmolbabu <[email protected]>
_______________________________________________
Engine-patches mailing list
[email protected]
http://lists.ovirt.org/mailman/listinfo/engine-patches

Reply via email to