*/
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;
/**
* The widget constructor.
*/
- public InvitationsDialog() {
+ public InvitationsDialog(final Pithos app, Invitations inv) {
Anchor close = new Anchor();
close.addStyleName("close");
close.addClickHandler(new ClickHandler() {
}
});
// Set the dialog's caption.
- setText("Invite people (# invitations left)");
+ setText("Invite people (" + inv.getInvitationsLeft() + " invitations left)");
setAnimationEnabled(true);
setGlassEnabled(true);
setStyleName("pithos-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);
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();
}
});
*/
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;
@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() {
.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 {
.pithos-DialogBox .Caption {
color: white;
background-color: #4085a5;
- padding: 4px 4px 4px 8px;
+ padding: 20px;
border-bottom: 1px solid white;
}
position: absolute;
width: 13px;
height: 13px;
- top: 7px;
+ top: 12px;
right: 7px;
}
text-align: center;
color: white;
height: 32px;
- padding-left: 5px;
- padding-right: 5px;
+ padding: 5px 15px;
+ margin-right: 10px;
}
.pithos-credentialsText {