Revision 63f9af58
b/web_client/src/gr/grnet/pithos/web/client/Invitations.java | ||
---|---|---|
1 |
package gr.grnet.pithos.web.client; |
|
2 |
|
|
3 |
import java.util.Date; |
|
4 |
|
|
5 |
import gr.grnet.pithos.web.client.foldertree.Resource; |
|
6 |
|
|
7 |
public class Invitations extends Resource { |
|
8 |
|
|
9 |
private int invitationsLeft; |
|
10 |
|
|
11 |
@Override |
|
12 |
public Date getLastModified() { |
|
13 |
return null; |
|
14 |
} |
|
15 |
|
|
16 |
public int getInvitationsLeft() { |
|
17 |
return invitationsLeft; |
|
18 |
} |
|
19 |
|
|
20 |
public void setInvitationsLeft(int invitationsLeft) { |
|
21 |
this.invitationsLeft = invitationsLeft; |
|
22 |
} |
|
23 |
|
|
24 |
} |
b/web_client/src/gr/grnet/pithos/web/client/InvitationsDialog.java | ||
---|---|---|
34 | 34 |
*/ |
35 | 35 |
package gr.grnet.pithos.web.client; |
36 | 36 |
|
37 |
import gr.grnet.pithos.web.client.foldertree.Resource; |
|
38 |
import gr.grnet.pithos.web.client.rest.PostRequest; |
|
39 |
|
|
40 |
import com.google.gwt.core.client.GWT; |
|
41 |
import com.google.gwt.core.client.Scheduler; |
|
37 | 42 |
import com.google.gwt.dom.client.NativeEvent; |
38 | 43 |
import com.google.gwt.event.dom.client.ClickEvent; |
39 | 44 |
import com.google.gwt.event.dom.client.ClickHandler; |
40 | 45 |
import com.google.gwt.event.dom.client.KeyCodes; |
46 |
import com.google.gwt.http.client.Response; |
|
41 | 47 |
import com.google.gwt.user.client.Event.NativePreviewEvent; |
42 | 48 |
import com.google.gwt.user.client.ui.Anchor; |
43 | 49 |
import com.google.gwt.user.client.ui.Button; |
... | ... | |
61 | 67 |
/** |
62 | 68 |
* The widget constructor. |
63 | 69 |
*/ |
64 |
public InvitationsDialog() { |
|
70 |
public InvitationsDialog(final Pithos app, Invitations inv) {
|
|
65 | 71 |
Anchor close = new Anchor(); |
66 | 72 |
close.addStyleName("close"); |
67 | 73 |
close.addClickHandler(new ClickHandler() { |
... | ... | |
72 | 78 |
} |
73 | 79 |
}); |
74 | 80 |
// Set the dialog's caption. |
75 |
setText("Invite people (# invitations left)");
|
|
81 |
setText("Invite people (" + inv.getInvitationsLeft() + " invitations left)");
|
|
76 | 82 |
setAnimationEnabled(true); |
77 | 83 |
setGlassEnabled(true); |
78 | 84 |
setStyleName("pithos-DialogBox"); |
... | ... | |
82 | 88 |
VerticalPanel inner = new VerticalPanel(); |
83 | 89 |
inner.addStyleName("inner"); |
84 | 90 |
// Create the text and set a style name so we can style it with CSS. |
85 |
HTML text = new HTML("You have # invitations left in your account.");
|
|
91 |
HTML text = new HTML("You have " + inv.getInvitationsLeft() + " invitations left in your account.");
|
|
86 | 92 |
text.setStyleName("pithos-credentialsText"); |
87 | 93 |
text.setWidth(WIDTH_TEXT); |
88 | 94 |
inner.add(text); |
89 | 95 |
FlexTable table = new FlexTable(); |
90 | 96 |
table.setText(0, 0, "Name"); |
91 | 97 |
table.setText(1, 0, "E-mail"); |
92 |
TextBox name = new TextBox(); |
|
98 |
final TextBox name = new TextBox();
|
|
93 | 99 |
name.setWidth(WIDTH_FIELD); |
94 | 100 |
table.setWidget(0, 1, name); |
95 | 101 |
|
96 |
TextBox emailBox = new TextBox(); |
|
102 |
final TextBox emailBox = new TextBox();
|
|
97 | 103 |
emailBox.setWidth(WIDTH_FIELD); |
98 | 104 |
table.setWidget(1, 1, emailBox); |
99 | 105 |
|
... | ... | |
106 | 112 |
Button confirm = new Button("Send", new ClickHandler() { |
107 | 113 |
@Override |
108 | 114 |
public void onClick(ClickEvent event) { |
115 |
PostRequest sendInvitation = new PostRequest("/im/", "", "invitations?uniq=" + emailBox.getText().trim() + "&realname=" + name.getText().trim()) { |
|
116 |
|
|
117 |
@Override |
|
118 |
protected void onUnauthorized(Response response) { |
|
119 |
app.sessionExpired(); |
|
120 |
} |
|
121 |
|
|
122 |
@Override |
|
123 |
public void onSuccess(Resource result) { |
|
124 |
} |
|
125 |
|
|
126 |
@Override |
|
127 |
public void onError(Throwable t) { |
|
128 |
GWT.log("", t); |
|
129 |
} |
|
130 |
}; |
|
131 |
sendInvitation.setHeader("X-Auth-Token", app.getToken()); |
|
132 |
Scheduler.get().scheduleDeferred(sendInvitation); |
|
109 | 133 |
hide(); |
110 | 134 |
} |
111 | 135 |
}); |
b/web_client/src/gr/grnet/pithos/web/client/TopPanel.java | ||
---|---|---|
34 | 34 |
*/ |
35 | 35 |
package gr.grnet.pithos.web.client; |
36 | 36 |
|
37 |
import gr.grnet.pithos.web.client.foldertree.Resource; |
|
38 |
import gr.grnet.pithos.web.client.rest.GetRequest; |
|
39 |
import gr.grnet.pithos.web.client.rest.RestException; |
|
40 |
|
|
41 |
import com.google.gwt.core.client.GWT; |
|
42 |
import com.google.gwt.core.client.Scheduler; |
|
43 |
import com.google.gwt.http.client.Response; |
|
37 | 44 |
import com.google.gwt.resources.client.ImageResource; |
38 | 45 |
import com.google.gwt.safehtml.shared.SafeHtml; |
39 | 46 |
import com.google.gwt.safehtml.shared.SafeHtmlBuilder; |
... | ... | |
104 | 111 |
|
105 | 112 |
@Override |
106 | 113 |
public void execute() { |
107 |
//Somehow get info from the server about invitations sent/left etc and then show the box |
|
108 |
new InvitationsDialog().center(); |
|
114 |
GetRequest<Invitations> getInvitations = new GetRequest<Invitations> (Invitations.class, "/im/", "", "invitations") { |
|
115 |
|
|
116 |
@Override |
|
117 |
public void onSuccess(Invitations _result) { |
|
118 |
new InvitationsDialog(app, _result).center(); |
|
119 |
} |
|
120 |
|
|
121 |
@Override |
|
122 |
public void onError(Throwable t) { |
|
123 |
GWT.log("", t); |
|
124 |
if (t instanceof RestException) |
|
125 |
app.displayError("Error getting invitations: " + ((RestException) t).getHttpStatusText()); |
|
126 |
else |
|
127 |
app.displayError("System error getting invitations: " + t.getMessage()); |
|
128 |
} |
|
129 |
|
|
130 |
@Override |
|
131 |
protected void onUnauthorized(Response response) { |
|
132 |
app.sessionExpired(); |
|
133 |
} |
|
134 |
}; |
|
135 |
getInvitations.setHeader("X-Auth-Token", app.getToken()); |
|
136 |
Scheduler.get().scheduleDeferred(getInvitations); |
|
109 | 137 |
} |
110 | 138 |
})); |
111 | 139 |
userItemMenu.addItem(new MenuItem("send feedback...", new Command() { |
b/web_client/src/gr/grnet/pithos/web/public/pithos.css | ||
---|---|---|
64 | 64 |
.pithos-DialogBox .inner { |
65 | 65 |
width: 95%; |
66 | 66 |
background: url(images/white50.png); |
67 |
padding: 12px; |
|
68 |
} |
|
69 |
|
|
70 |
.pithos-DialogBox .inner form { |
|
71 |
margin: 0px; |
|
72 |
} |
|
73 |
|
|
74 |
.pithos-dialogbox .inner form input, |
|
75 |
.pithos-dialogbox .inner form textarea |
|
76 |
{ |
|
77 |
border: 1px solid #aaa; |
|
78 |
padding:4px; |
|
67 | 79 |
} |
68 | 80 |
|
69 | 81 |
.pithos-DialogBox .button { |
... | ... | |
78 | 90 |
.pithos-DialogBox .Caption { |
79 | 91 |
color: white; |
80 | 92 |
background-color: #4085a5; |
81 |
padding: 4px 4px 4px 8px;
|
|
93 |
padding: 20px;
|
|
82 | 94 |
border-bottom: 1px solid white; |
83 | 95 |
} |
84 | 96 |
|
... | ... | |
88 | 100 |
position: absolute; |
89 | 101 |
width: 13px; |
90 | 102 |
height: 13px; |
91 |
top: 7px;
|
|
103 |
top: 12px;
|
|
92 | 104 |
right: 7px; |
93 | 105 |
} |
94 | 106 |
|
... | ... | |
390 | 402 |
text-align: center; |
391 | 403 |
color: white; |
392 | 404 |
height: 32px; |
393 |
padding-left: 5px;
|
|
394 |
padding-right: 5px;
|
|
405 |
padding: 5px 15px;
|
|
406 |
margin-right: 10px;
|
|
395 | 407 |
} |
396 | 408 |
|
397 | 409 |
.pithos-credentialsText { |
Also available in: Unified diff