CSS fixes and invitations dialog
authorChristos Stathis <chstath@ebs.gr>
Thu, 27 Oct 2011 14:45:32 +0000 (17:45 +0300)
committerChristos Stathis <chstath@ebs.gr>
Thu, 27 Oct 2011 14:45:32 +0000 (17:45 +0300)
src/gr/grnet/pithos/web/client/Invitations.java [new file with mode: 0644]
src/gr/grnet/pithos/web/client/InvitationsDialog.java
src/gr/grnet/pithos/web/client/TopPanel.java
src/gr/grnet/pithos/web/public/pithos.css

diff --git a/src/gr/grnet/pithos/web/client/Invitations.java b/src/gr/grnet/pithos/web/client/Invitations.java
new file mode 100644 (file)
index 0000000..7b859bd
--- /dev/null
@@ -0,0 +1,24 @@
+package gr.grnet.pithos.web.client;
+
+import java.util.Date;
+
+import gr.grnet.pithos.web.client.foldertree.Resource;
+
+public class Invitations extends Resource {
+
+       private int invitationsLeft;
+       
+       @Override
+       public Date getLastModified() {
+               return null;
+       }
+
+       public int getInvitationsLeft() {
+               return invitationsLeft;
+       }
+
+       public void setInvitationsLeft(int invitationsLeft) {
+               this.invitationsLeft = invitationsLeft;
+       }
+
+}
index ec8ce4a..97dd954 100644 (file)
  */
 package gr.grnet.pithos.web.client;
 
+import gr.grnet.pithos.web.client.foldertree.Resource;
+import gr.grnet.pithos.web.client.rest.PostRequest;
+
+import com.google.gwt.core.client.GWT;
+import com.google.gwt.core.client.Scheduler;
 import com.google.gwt.dom.client.NativeEvent;
 import com.google.gwt.event.dom.client.ClickEvent;
 import com.google.gwt.event.dom.client.ClickHandler;
 import com.google.gwt.event.dom.client.KeyCodes;
+import com.google.gwt.http.client.Response;
 import com.google.gwt.user.client.Event.NativePreviewEvent;
 import com.google.gwt.user.client.ui.Anchor;
 import com.google.gwt.user.client.ui.Button;
@@ -61,7 +67,7 @@ public class InvitationsDialog extends DialogBox {
        /**
         * The widget constructor.
         */
-       public InvitationsDialog() {
+       public InvitationsDialog(final Pithos app, Invitations inv) {
                Anchor close = new Anchor();
                close.addStyleName("close");
                close.addClickHandler(new ClickHandler() {
@@ -72,7 +78,7 @@ public class InvitationsDialog extends DialogBox {
                        }
                });
                // Set the dialog's caption.
-               setText("Invite people (# invitations left)");
+               setText("Invite people (" + inv.getInvitationsLeft() + " invitations left)");
                setAnimationEnabled(true);
                setGlassEnabled(true);
                setStyleName("pithos-DialogBox");
@@ -82,18 +88,18 @@ public class InvitationsDialog extends DialogBox {
                VerticalPanel inner = new VerticalPanel();
                inner.addStyleName("inner");
                // Create the text and set a style name so we can style it with CSS.
-               HTML text = new HTML("You have # invitations left in your account.");
+               HTML text = new HTML("You have " + inv.getInvitationsLeft() + " invitations left in your account.");
                text.setStyleName("pithos-credentialsText");
                text.setWidth(WIDTH_TEXT);
                inner.add(text);
                FlexTable table = new FlexTable();
                table.setText(0, 0, "Name");
                table.setText(1, 0, "E-mail");
-               TextBox name = new TextBox();
+               final TextBox name = new TextBox();
                name.setWidth(WIDTH_FIELD);
                table.setWidget(0, 1, name);
 
-               TextBox emailBox = new TextBox();
+               final TextBox emailBox = new TextBox();
                emailBox.setWidth(WIDTH_FIELD);
                table.setWidget(1, 1, emailBox);
 
@@ -106,6 +112,24 @@ public class InvitationsDialog extends DialogBox {
                Button confirm = new Button("Send", new ClickHandler() {
                        @Override
                        public void onClick(ClickEvent event) {
+                               PostRequest sendInvitation = new PostRequest("/im/", "", "invitations?uniq=" + emailBox.getText().trim() + "&realname=" + name.getText().trim()) {
+                                       
+                                       @Override
+                                       protected void onUnauthorized(Response response) {
+                                               app.sessionExpired();
+                                       }
+                                       
+                                       @Override
+                                       public void onSuccess(Resource result) {
+                                       }
+                                       
+                                       @Override
+                                       public void onError(Throwable t) {
+                                               GWT.log("", t);
+                                       }
+                               };
+                               sendInvitation.setHeader("X-Auth-Token", app.getToken());
+                               Scheduler.get().scheduleDeferred(sendInvitation);
                                hide();
                        }
                });
index 47ecb1a..3ea8211 100644 (file)
  */
 package gr.grnet.pithos.web.client;
 
+import gr.grnet.pithos.web.client.foldertree.Resource;
+import gr.grnet.pithos.web.client.rest.GetRequest;
+import gr.grnet.pithos.web.client.rest.RestException;
+
+import com.google.gwt.core.client.GWT;
+import com.google.gwt.core.client.Scheduler;
+import com.google.gwt.http.client.Response;
 import com.google.gwt.resources.client.ImageResource;
 import com.google.gwt.safehtml.shared.SafeHtml;
 import com.google.gwt.safehtml.shared.SafeHtmlBuilder;
@@ -104,8 +111,29 @@ public class TopPanel extends Composite {
                        
                        @Override
                        public void execute() {
-                               //Somehow get info from the server about invitations sent/left etc and then show the box
-                               new InvitationsDialog().center();
+                               GetRequest<Invitations> getInvitations = new GetRequest<Invitations> (Invitations.class, "/im/", "", "invitations") {
+
+                                       @Override
+                                       public void onSuccess(Invitations _result) {
+                                               new InvitationsDialog(app, _result).center();
+                                       }
+
+                                       @Override
+                                       public void onError(Throwable t) {
+                                               GWT.log("", t);
+                           if (t instanceof RestException)
+                               app.displayError("Error getting invitations: " + ((RestException) t).getHttpStatusText());
+                           else
+                               app.displayError("System error getting invitations: " + t.getMessage());
+                                       }
+
+                                       @Override
+                                       protected void onUnauthorized(Response response) {
+                                               app.sessionExpired();
+                                       }
+                               };
+                               getInvitations.setHeader("X-Auth-Token", app.getToken());
+                               Scheduler.get().scheduleDeferred(getInvitations);
                        }
                }));
         userItemMenu.addItem(new MenuItem("send feedback...", new Command() {
index 175698d..6ab150f 100644 (file)
@@ -64,6 +64,18 @@ a.info:hover div {
 .pithos-DialogBox .inner {
        width: 95%;
        background: url(images/white50.png);
+       padding: 12px;
+}
+
+.pithos-DialogBox .inner form {
+       margin: 0px;
+}
+
+.pithos-dialogbox .inner form input,
+.pithos-dialogbox .inner form textarea
+{
+    border: 1px solid #aaa;
+    padding:4px;
 }
 
 .pithos-DialogBox .button {
@@ -78,7 +90,7 @@ a.info:hover div {
 .pithos-DialogBox .Caption {
        color: white;
        background-color: #4085a5;
-       padding: 4px 4px 4px 8px;
+       padding: 20px;
        border-bottom: 1px solid white;
 }
 
@@ -88,7 +100,7 @@ a.info:hover div {
        position: absolute;
        width: 13px;
        height: 13px;
-       top: 7px;
+       top: 12px;
        right: 7px;
 }
 
@@ -390,8 +402,8 @@ table.pithos-permList.props-labels {
     text-align: center;
     color: white;
     height: 32px;
-       padding-left: 5px;
-       padding-right: 5px;
+       padding: 5px 15px;
+       margin-right: 10px;
 }
 
 .pithos-credentialsText {