Oved Ourfali has uploaded a new change for review.

Change subject: userportal: adding user message of the day
......................................................................

userportal: adding user message of the day

This patch adds the user message of the day functionality in the user
portal login page

Change-Id: I020c4772388ac5ebc2b6391ad3b0e1eef0081309
Bug-Url: https://bugzilla.redhat.com/show_bug.cgi?id=983120
Signed-off-by: Oved Ourfali <oourf...@redhat.com>
---
M 
frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/dataprovider/AsyncDataProvider.java
M 
frontend/webadmin/modules/userportal-gwtp/src/main/java/org/ovirt/engine/ui/userportal/ApplicationTemplates.java
M 
frontend/webadmin/modules/userportal-gwtp/src/main/java/org/ovirt/engine/ui/userportal/section/login/view/LoginPopupView.java
M 
frontend/webadmin/modules/userportal-gwtp/src/main/java/org/ovirt/engine/ui/userportal/section/login/view/LoginPopupView.ui.xml
4 files changed, 116 insertions(+), 2 deletions(-)


  git pull ssh://gerrit.ovirt.org:29418/ovirt-engine refs/changes/45/17545/1

diff --git 
a/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/dataprovider/AsyncDataProvider.java
 
b/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/dataprovider/AsyncDataProvider.java
index 9a812ec..624669d 100644
--- 
a/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/dataprovider/AsyncDataProvider.java
+++ 
b/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/dataprovider/AsyncDataProvider.java
@@ -1349,6 +1349,20 @@
                 aQuery);
     }
 
+    public static void getUserMessageOfTheDayViaPublic(AsyncQuery aQuery) {
+        aQuery.converterCallback = new IAsyncConverter() {
+            @Override
+            public Object Convert(Object source, AsyncQuery _asyncQuery)
+            {
+                return source != null ? (String) source : ""; //$NON-NLS-1$
+            }
+        };
+        Frontend.RunPublicQuery(VdcQueryType.GetConfigurationValue,
+                new 
GetConfigurationValueParameters(ConfigurationValues.UserMessageOfTheDay,
+                        getDefaultConfigurationVersion()),
+                aQuery);
+    }
+
     public static void getSearchResultsLimit(AsyncQuery aQuery) {
         aQuery.converterCallback = new IAsyncConverter() {
             @Override
diff --git 
a/frontend/webadmin/modules/userportal-gwtp/src/main/java/org/ovirt/engine/ui/userportal/ApplicationTemplates.java
 
b/frontend/webadmin/modules/userportal-gwtp/src/main/java/org/ovirt/engine/ui/userportal/ApplicationTemplates.java
index 6c11546..b56ae0f 100644
--- 
a/frontend/webadmin/modules/userportal-gwtp/src/main/java/org/ovirt/engine/ui/userportal/ApplicationTemplates.java
+++ 
b/frontend/webadmin/modules/userportal-gwtp/src/main/java/org/ovirt/engine/ui/userportal/ApplicationTemplates.java
@@ -45,4 +45,10 @@
             String usedByYouLabel, int usedByYouPercentage,String usedByYou,
             String usedByOthersLabel, int usedByOthersPercentage, String 
usedByOthers,
             String freeLabel, int freePercentage, String free);
+
+    //@Template("<span><span style='position: relative; margin-left: 3px; 
margin-right: 3px; white-space: nowrap; height: 14px; line-height: 
14px;'>{0}</span></span>")
+    //@Template("<div class=\"notify\">{0}</div>")
+    //@Template("<span 
style='border-top-style:none;border-right-style:solid;border-bottom-style:solid;border-left-style:solid;border-color:
 #ff9933;-webkit-border-bottom-right-radius: 
12px;-webkit-border-bottom-left-radius: 12px;-moz-border-radius-bottomright: 
12px;-moz-border-radius-bottomleft: 12px;border-bottom-right-radius: 
12px;border-bottom-left-radius: 12px;padding:0px;font-size:13px;color: 
black;width: 300px;-webkit-box-shadow:  0px 2px 2px 2px rgba(0, 0, 0, 
.3);box-shadow:  0px 2px 2px 2px rgba(0, 0, 0, .3);'>{0}</span>")
+    @Template("<div>{0}</div>")
+    SafeHtml userMessageOfTheDay(String title);
 }
diff --git 
a/frontend/webadmin/modules/userportal-gwtp/src/main/java/org/ovirt/engine/ui/userportal/section/login/view/LoginPopupView.java
 
b/frontend/webadmin/modules/userportal-gwtp/src/main/java/org/ovirt/engine/ui/userportal/section/login/view/LoginPopupView.java
index de2ad9c..a568b0a 100644
--- 
a/frontend/webadmin/modules/userportal-gwtp/src/main/java/org/ovirt/engine/ui/userportal/section/login/view/LoginPopupView.java
+++ 
b/frontend/webadmin/modules/userportal-gwtp/src/main/java/org/ovirt/engine/ui/userportal/section/login/view/LoginPopupView.java
@@ -13,23 +13,32 @@
 import org.ovirt.engine.ui.common.widget.editor.EntityModelPasswordBoxEditor;
 import org.ovirt.engine.ui.common.widget.editor.EntityModelTextBoxEditor;
 import org.ovirt.engine.ui.common.widget.editor.ListModelListBoxEditor;
+import org.ovirt.engine.ui.frontend.AsyncQuery;
+import org.ovirt.engine.ui.frontend.INewAsyncCallback;
+import org.ovirt.engine.ui.uicommonweb.dataprovider.AsyncDataProvider;
 import org.ovirt.engine.ui.uicommonweb.models.userportal.UserPortalLoginModel;
 import org.ovirt.engine.ui.userportal.ApplicationConstants;
 import org.ovirt.engine.ui.userportal.ApplicationDynamicMessages;
 import org.ovirt.engine.ui.userportal.ApplicationMessages;
 import org.ovirt.engine.ui.userportal.ApplicationResources;
+import org.ovirt.engine.ui.userportal.ApplicationTemplates;
 import 
org.ovirt.engine.ui.userportal.section.login.presenter.LoginPopupPresenterWidget;
 
 import com.google.gwt.core.client.GWT;
 import com.google.gwt.editor.client.SimpleBeanEditorDriver;
 import com.google.gwt.event.shared.EventBus;
+import com.google.gwt.resources.client.CssResource;
 import com.google.gwt.uibinder.client.UiBinder;
 import com.google.gwt.uibinder.client.UiField;
+import com.google.gwt.user.client.ui.HTML;
 import com.google.gwt.user.client.ui.Label;
 import com.google.gwt.user.client.ui.Panel;
+import com.google.gwt.user.client.ui.PopupPanel;
 import com.google.inject.Inject;
 
 public class LoginPopupView extends AbstractLoginPopupView implements 
LoginPopupPresenterWidget.ViewDef {
+
+    private final ApplicationTemplates templates;
 
     interface Driver extends SimpleBeanEditorDriver<UserPortalLoginModel, 
LoginPopupView> {
     }
@@ -93,7 +102,19 @@
     @Ignore
     Panel errorMessagePanel;
 
+    @Ignore
+    SimplePopupPanel tooltipPanel;
+
+    @Ignore
+    HTML tooltip;
+
+    @UiField
+    Style style;
+
     private final Driver driver = GWT.create(Driver.class);
+    private int popupLeft = 0;
+    private int popupTop = 0;
+    private boolean hasMessageOfTheDay = false;
 
     @Inject
     public LoginPopupView(EventBus eventBus,
@@ -101,8 +122,11 @@
             ApplicationResources resources,
             ApplicationConstants constants,
             ApplicationMessages messages,
-            ApplicationDynamicMessages dynamicMessages) {
+            ApplicationDynamicMessages dynamicMessages,
+            ApplicationTemplates templates) {
         super(eventBus, resources, clientAgentType);
+
+        this.templates = templates;
 
         // We need this code because resetAndFocus is called when 
userNameEditor is Disabled
         userNameEditor = new EntityModelTextBoxEditor() {
@@ -129,6 +153,49 @@
         driver.initialize(this);
     }
 
+    private void initUserMessageOfTheDayToolTip(final ApplicationTemplates 
templates) {
+        tooltipPanel = new SimplePopupPanel();
+        tooltipPanel.setStyleName(style.motd());
+        tooltipPanel.hide();
+        tooltip = new HTML();
+
+        AsyncQuery _asyncQuery = new AsyncQuery();
+        _asyncQuery.setModel(this);
+        _asyncQuery.asyncCallback = new INewAsyncCallback() {
+            @Override
+            public void onSuccess(Object model, Object result) {
+                String message = (String) result;
+                if (message != null && !message.isEmpty()) {
+                    hasMessageOfTheDay = true;
+                    tooltip.setHTML(templates.userMessageOfTheDay(message));
+                    tooltipPanel.setWidget(tooltip);
+                } else {
+                    tooltipPanel.hide();
+                }
+            }
+        };
+        AsyncDataProvider.getUserMessageOfTheDayViaPublic(_asyncQuery);
+
+    }
+
+    private void setToolTipPositionAndShow() {
+        if (popupLeft == 0) {
+            popupLeft = popup.getAbsoluteLeft();
+        }
+        if (popupTop == 0) {
+            popupTop = popup.getAbsoluteTop();
+        }
+        if (hasMessageOfTheDay) {
+            final int errorHeight = errorMessagePanel.isVisible() ? 
errorMessage.getOffsetHeight() : 0;
+            tooltipPanel.setPopupPositionAndShow(new 
PopupPanel.PositionCallback() {
+                @Override
+                public void setPosition(int offsetWidth, int offsetHeight) {
+                    tooltipPanel.setPopupPosition(popupLeft - (offsetWidth / 
2), popupTop + ((popup.getOffsetHeight()) / 2 + errorHeight));
+                }
+            });
+        }
+    }
+
     void localize(ApplicationConstants constants,
             ApplicationDynamicMessages dynamicMessages) {
         headerLabel.setText(dynamicMessages.loginHeaderLabel());
@@ -148,6 +215,7 @@
     @Override
     public void edit(UserPortalLoginModel object) {
         driver.edit(object);
+        initUserMessageOfTheDayToolTip(templates);
     }
 
     @Override
@@ -160,6 +228,7 @@
         userNameEditor.asValueBox().selectAll();
         userNameEditor.asValueBox().setFocus(true);
         clearErrorMessage();
+        setToolTipPositionAndShow();
     }
 
     @Override
@@ -168,6 +237,7 @@
         errorMessage.setVisible(text != null);
         if (errorMessage.isVisible()) {
             errorMessagePanel.setVisible(true);
+            setToolTipPositionAndShow();
         }
     }
 
@@ -181,4 +251,7 @@
         return loginButton;
     }
 
+    public interface Style extends CssResource {
+        String motd();
+    }
 }
diff --git 
a/frontend/webadmin/modules/userportal-gwtp/src/main/java/org/ovirt/engine/ui/userportal/section/login/view/LoginPopupView.ui.xml
 
b/frontend/webadmin/modules/userportal-gwtp/src/main/java/org/ovirt/engine/ui/userportal/section/login/view/LoginPopupView.ui.xml
index e8b193c..e0adaf0 100644
--- 
a/frontend/webadmin/modules/userportal-gwtp/src/main/java/org/ovirt/engine/ui/userportal/section/login/view/LoginPopupView.ui.xml
+++ 
b/frontend/webadmin/modules/userportal-gwtp/src/main/java/org/ovirt/engine/ui/userportal/section/login/view/LoginPopupView.ui.xml
@@ -6,7 +6,7 @@
 
        <ui:with field='resources' 
type='org.ovirt.engine.ui.userportal.ApplicationResources' />
 
-       <ui:style>
+       <ui:style 
type="org.ovirt.engine.ui.userportal.section.login.view.LoginPopupView.Style">
                .loginForm {
                        padding-top: 40px;
                        background-color: #FFFFFF;
@@ -82,6 +82,27 @@
                        font-size: 11px;
                        width: 130px;
                }
+
+        .motd {
+                border-top-style:none;
+                border-right-style:solid;
+                border-bottom-style:solid;
+                border-left-style:solid;
+                border-color: #ff9933;
+                -webkit-border-bottom-right-radius: 12px;
+                -webkit-border-bottom-left-radius: 12px;
+                -moz-border-radius-bottomright: 12px;
+                -moz-border-radius-bottomleft: 12px;
+                border-bottom-right-radius: 12px;
+                border-bottom-left-radius: 12px;
+                padding:0px;
+                font-size:13px;
+                color: black;
+                background-color: white;
+                width: 300px;
+                -webkit-box-shadow:  0px 2px 2px 2px rgba(0, 0, 0, .3);
+                box-shadow:  0px 2px 2px 2px rgba(0, 0, 0, .3);
+        }
        </ui:style>
 
        <ui:style field='loginPopupStyle'>


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

Gerrit-MessageType: newchange
Gerrit-Change-Id: I020c4772388ac5ebc2b6391ad3b0e1eef0081309
Gerrit-PatchSet: 1
Gerrit-Project: ovirt-engine
Gerrit-Branch: master
Gerrit-Owner: Oved Ourfali <oourf...@redhat.com>
_______________________________________________
Engine-patches mailing list
Engine-patches@ovirt.org
http://lists.ovirt.org/mailman/listinfo/engine-patches

Reply via email to