Revision 0e64bec2
b/src/gr/ebs/gss/client/StatusPanel.java | ||
---|---|---|
24 | 24 |
import gr.ebs.gss.client.rest.resource.UserResource; |
25 | 25 |
|
26 | 26 |
import com.google.gwt.core.client.GWT; |
27 |
import com.google.gwt.i18n.client.DateTimeFormat; |
|
27 | 28 |
import com.google.gwt.resources.client.ClientBundle; |
28 | 29 |
import com.google.gwt.resources.client.ImageResource; |
29 | 30 |
import com.google.gwt.user.client.DeferredCommand; |
... | ... | |
43 | 44 |
private HTML fileSizeLabel = new HTML(""); |
44 | 45 |
private HTML quotaIcon = new HTML(""); |
45 | 46 |
private HTML quotaLabel = new HTML(""); |
47 |
private HTML lastLoginLabel = new HTML(""); |
|
46 | 48 |
private HTML currentlyShowingLabel = new HTML(""); |
47 | 49 |
|
48 | 50 |
/** |
... | ... | |
64 | 66 |
|
65 | 67 |
@Source("gr/ebs/gss/resources/yellowled.png") |
66 | 68 |
ImageResource yellowSize(); |
69 |
|
|
70 |
@Source("gr/ebs/gss/resources/xclock.png") |
|
71 |
ImageResource lastLogin(); |
|
67 | 72 |
} |
68 | 73 |
|
69 | 74 |
private final Images images; |
... | ... | |
81 | 86 |
|
82 | 87 |
HorizontalPanel left = new HorizontalPanel(); |
83 | 88 |
left.setSpacing(8); |
89 |
HorizontalPanel middle = new HorizontalPanel(); |
|
90 |
middle.setSpacing(8); |
|
84 | 91 |
HorizontalPanel right = new HorizontalPanel(); |
85 | 92 |
right.setSpacing(8); |
86 | 93 |
outer.add(left); |
94 |
outer.add(middle); |
|
87 | 95 |
outer.add(right); |
88 | 96 |
left.add(new HTML("<b>Totals:</b> ")); |
89 | 97 |
left.add(AbstractImagePrototype.create(images.totalFiles()).createImage()); |
... | ... | |
93 | 101 |
quotaIcon.setHTML(AbstractImagePrototype.create(images.greenSize()).getHTML()); |
94 | 102 |
left.add(quotaIcon); |
95 | 103 |
left.add(quotaLabel); |
104 |
middle.add(AbstractImagePrototype.create(images.lastLogin()).createImage()); |
|
105 |
middle.add(new HTML("<b>Last login:</b> ")); |
|
106 |
middle.add(lastLoginLabel); |
|
96 | 107 |
right.add(currentlyShowingLabel); |
97 | 108 |
outer.setStyleName("statusbar-inner"); |
98 | 109 |
left.setStyleName("statusbar-inner"); |
110 |
middle.setStyleName("statusbar-inner"); |
|
99 | 111 |
right.setStyleName("statusbar-inner"); |
100 | 112 |
outer.setCellHorizontalAlignment(right, HasHorizontalAlignment.ALIGN_RIGHT); |
101 | 113 |
|
... | ... | |
108 | 120 |
UserResource user = app.getCurrentUserResource(); |
109 | 121 |
if (user == null || app.getFolders().getRootItem() == null) |
110 | 122 |
return !DONE; |
111 |
displayStats(user.getQuota());
|
|
123 |
displayStats(user); |
|
112 | 124 |
return DONE; |
113 | 125 |
} |
114 | 126 |
}); |
... | ... | |
117 | 129 |
/** |
118 | 130 |
* Refresh the widget with the provided statistics. |
119 | 131 |
*/ |
120 |
private void displayStats(QuotaHolder stats) { |
|
132 |
private void displayStats(UserResource user) { |
|
133 |
QuotaHolder stats = user.getQuota(); |
|
121 | 134 |
if (stats.getFileCount() == 1) |
122 | 135 |
fileCountLabel.setHTML("1 file"); |
123 | 136 |
else |
... | ... | |
134 | 147 |
quotaIcon.setHTML(AbstractImagePrototype.create(images.greenSize()).getHTML()); |
135 | 148 |
quotaLabel.setHTML(stats.getQuotaLeftAsString() +" free"); |
136 | 149 |
} |
150 |
final DateTimeFormat formatter = DateTimeFormat.getFormat("d/M/yyyy h:mm a"); |
|
151 |
lastLoginLabel.setHTML(formatter.format(user.getLastLogin())); |
|
137 | 152 |
} |
138 | 153 |
|
139 | 154 |
/** |
... | ... | |
146 | 161 |
GetCommand<UserResource> uc = new GetCommand<UserResource>(UserResource.class, user.getUri(), null){ |
147 | 162 |
@Override |
148 | 163 |
public void onComplete() { |
149 |
displayStats(getResult().getQuota());
|
|
164 |
displayStats(getResult()); |
|
150 | 165 |
} |
151 | 166 |
|
152 | 167 |
@Override |
b/src/gr/ebs/gss/client/rest/resource/UserResource.java | ||
---|---|---|
58 | 58 |
|
59 | 59 |
private String announcement; |
60 | 60 |
|
61 |
private Date lastLogin; |
|
62 |
|
|
61 | 63 |
/** |
62 | 64 |
* Retrieve the name. |
63 | 65 |
* |
... | ... | |
284 | 286 |
return announcement; |
285 | 287 |
} |
286 | 288 |
|
287 |
|
|
288 | 289 |
/** |
289 | 290 |
* Modify the announcement. |
290 | 291 |
* |
... | ... | |
294 | 295 |
announcement = anAnnouncement; |
295 | 296 |
} |
296 | 297 |
|
298 |
/** |
|
299 |
* Retrieve the lastLogin. |
|
300 |
* |
|
301 |
* @return the lastLogin |
|
302 |
*/ |
|
303 |
public Date getLastLogin() { |
|
304 |
return lastLogin; |
|
305 |
} |
|
306 |
|
|
297 | 307 |
@Override |
298 | 308 |
public void createFromJSON(String text) { |
299 | 309 |
JSONObject json = (JSONObject) JSONParser.parse(text); |
... | ... | |
307 | 317 |
tagsPath = unmarshallString(json, "tags"); |
308 | 318 |
trashPath = unmarshallString(json, "trash"); |
309 | 319 |
announcement = unmarshallString(json, "announcement"); |
320 |
if (json.get("lastLogin") != null) |
|
321 |
lastLogin = new Date(new Long(json.get("lastLogin").toString())); |
|
310 | 322 |
if (json.get("creationDate") != null) |
311 | 323 |
creationDate = new Date(new Long(json.get("creationDate").toString())); |
312 | 324 |
if (json.get("modificationDate") != null) |
b/src/gr/ebs/gss/server/rest/UserHandler.java | ||
---|---|---|
89 | 89 |
put("shared", parentUrl + PATH_SHARED).put("others", parentUrl + PATH_OTHERS). |
90 | 90 |
put("quota", statistics).put("tags", parentUrl + PATH_TAGS); |
91 | 91 |
String announcement = getConfiguration().getString("announcement"); |
92 |
if(announcement != null && !announcement.isEmpty()) |
|
92 |
if (announcement != null && !announcement.isEmpty())
|
|
93 | 93 |
json.put("announcement", announcement); |
94 |
if (owner.getLastLogin() != null) |
|
95 |
json.put("lastLogin", owner.getLastLogin().getTime()); |
|
94 | 96 |
} catch (JSONException e) { |
95 | 97 |
logger.error("", e); |
96 | 98 |
resp.sendError(HttpServletResponse.SC_INTERNAL_SERVER_ERROR); |
Also available in: Unified diff