private List<SingleSelectionModel> selectionModels = new ArrayList<SingleSelectionModel>();
Button upload;
+
+ private HTML totalFiles;
+
+ private HTML usedBytes;
+
+ private HTML totalBytes;
+
+ private HTML usedPercent;
@Override
public void onModuleLoad() {
HorizontalPanel treeHeader = new HorizontalPanel();
treeHeader.addStyleName("pithos-treeHeader");
- treeHeader.add(new HTML("Total Files: 6 | Used: 2.1 of 50 GB (4.2%)"));
+ HorizontalPanel statistics = new HorizontalPanel();
+ statistics.add(new HTML("Total Files: "));
+ totalFiles = new HTML();
+ statistics.add(totalFiles);
+ statistics.add(new HTML(" | Used: "));
+ usedBytes = new HTML();
+ statistics.add(usedBytes);
+ statistics.add(new HTML(" of "));
+ totalBytes = new HTML();
+ statistics.add(totalBytes);
+ statistics.add(new HTML(" ("));
+ usedPercent = new HTML();
+ statistics.add(usedPercent);
+ statistics.add(new HTML("%)"));
+ treeHeader.add(statistics);
trees.add(treeHeader);
trees.add(folderTreeView);
}
folderTreeViewModel.initialize(account);
groupTreeViewModel.initialize();
+ updateStatistics();
}
}
Scheduler.get().scheduleDeferred(getAccount);
}
- protected void createHomeContainer(final AccountResource account) {
+ protected void updateStatistics() {
+ totalFiles.setHTML(String.valueOf(account.getNumberOfObjects()));
+ usedBytes.setHTML(String.valueOf(account.getFileSizeAsString()));
+ totalBytes.setHTML(String.valueOf(account.getQuotaAsString()));
+ usedPercent.setHTML(String.valueOf(account.getUsedPercentage()));
+ }
+
+ protected void createHomeContainer(final AccountResource account) {
String path = "/" + Pithos.HOME_CONTAINER;
PutRequest createPithos = new PutRequest(getApiPath(), getUsername(), path) {
@Override
return getSize(bytesUsed , (1024D*1024D*1024D)) + " GB";
}
- public String getQuotaLeftAsString() {
- if (bytesRemaining < 1024)
- return String.valueOf(bytesRemaining) + " B";
- else if (bytesRemaining < 1024 * 1024)
- return getSize(bytesRemaining, 1024D) + " KB";
- else if (bytesRemaining < 1024 * 1024 * 1024)
- return getSize(bytesRemaining,(1024D * 1024D)) + " MB";
- return getSize(bytesRemaining , (1024D * 1024D * 1024D)) + " GB";
+ public String getQuotaAsString() {
+ long quota = bytesUsed + bytesRemaining;
+ if (quota < 1024)
+ return String.valueOf(quota) + " B";
+ else if (quota < 1024 * 1024)
+ return getSize(quota, 1024D) + " KB";
+ else if (quota < 1024 * 1024 * 1024)
+ return getSize(quota,(1024D * 1024D)) + " MB";
+ return getSize(quota , (1024D * 1024D * 1024D)) + " GB";
}
public List<Group> getGroups() {
}
return null;
}
+
+ public double getUsedPercentage() {
+ return 100.0 * bytesUsed / (bytesUsed + bytesRemaining);
+ }
}