mirror of
https://github.com/sismics/docs.git
synced 2024-12-22 11:23:48 +01:00
Document count in GET /app, TODO
This commit is contained in:
parent
4d50b220a2
commit
9e5459cafe
@ -1,2 +1,3 @@
|
||||
- Server side reordering files
|
||||
- Reordering files (server)
|
||||
- GET /app/stats to display general data (server/client)
|
||||
- User settings
|
@ -17,9 +17,13 @@ import org.apache.log4j.Logger;
|
||||
import org.codehaus.jettison.json.JSONException;
|
||||
import org.codehaus.jettison.json.JSONObject;
|
||||
|
||||
import com.sismics.docs.core.dao.jpa.DocumentDao;
|
||||
import com.sismics.docs.core.dao.jpa.criteria.DocumentCriteria;
|
||||
import com.sismics.docs.core.dao.jpa.dto.DocumentDto;
|
||||
import com.sismics.docs.core.util.ConfigUtil;
|
||||
import com.sismics.docs.core.util.jpa.PaginatedList;
|
||||
import com.sismics.docs.core.util.jpa.PaginatedLists;
|
||||
import com.sismics.docs.core.util.jpa.SortCriteria;
|
||||
import com.sismics.docs.rest.constant.BaseFunction;
|
||||
import com.sismics.rest.exception.ForbiddenClientException;
|
||||
import com.sismics.rest.exception.ServerException;
|
||||
@ -42,16 +46,32 @@ public class AppResource extends BaseResource {
|
||||
*/
|
||||
@GET
|
||||
@Produces(MediaType.APPLICATION_JSON)
|
||||
public Response version() throws JSONException {
|
||||
public Response info() throws JSONException {
|
||||
if (!authenticate()) {
|
||||
throw new ForbiddenClientException();
|
||||
}
|
||||
|
||||
ResourceBundle configBundle = ConfigUtil.getConfigBundle();
|
||||
String currentVersion = configBundle.getString("api.current_version");
|
||||
String minVersion = configBundle.getString("api.min_version");
|
||||
|
||||
JSONObject response = new JSONObject();
|
||||
|
||||
// Specific data
|
||||
DocumentDao documentDao = new DocumentDao();
|
||||
PaginatedList<DocumentDto> paginatedList = PaginatedLists.create(1, 0);
|
||||
SortCriteria sortCriteria = new SortCriteria(0, true);
|
||||
DocumentCriteria documentCriteria = new DocumentCriteria();
|
||||
documentCriteria.setUserId(principal.getId());
|
||||
documentDao.findByCriteria(paginatedList, documentCriteria, sortCriteria);
|
||||
response.put("document_count", paginatedList.getResultCount());
|
||||
|
||||
// General data
|
||||
response.put("current_version", currentVersion.replace("-SNAPSHOT", ""));
|
||||
response.put("min_version", minVersion);
|
||||
response.put("total_memory", Runtime.getRuntime().totalMemory());
|
||||
response.put("free_memory", Runtime.getRuntime().freeMemory());
|
||||
|
||||
return Response.ok().entity(response).build();
|
||||
}
|
||||
|
||||
|
@ -1,3 +1,4 @@
|
||||
// Documents list
|
||||
.table-documents {
|
||||
thead th {
|
||||
cursor: pointer;
|
||||
@ -9,6 +10,7 @@
|
||||
}
|
||||
}
|
||||
|
||||
// File thumbnails
|
||||
.thumbnail-file {
|
||||
cursor: pointer;
|
||||
}
|
||||
@ -21,6 +23,7 @@
|
||||
overflow: visible;
|
||||
}
|
||||
|
||||
// Fields bound to datepicker
|
||||
input[readonly][datepicker-popup] {
|
||||
cursor: pointer;
|
||||
}
|
||||
@ -29,21 +32,30 @@ input[readonly][datepicker-popup] {
|
||||
.inline-edit {
|
||||
cursor: pointer;
|
||||
display: block;
|
||||
|
||||
span {
|
||||
display: block;
|
||||
}
|
||||
|
||||
input {
|
||||
display: none;
|
||||
margin-bottom: 0;
|
||||
}
|
||||
|
||||
&.active {
|
||||
span {
|
||||
display: none;
|
||||
}
|
||||
|
||||
input {
|
||||
display: inline-block;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.inline-edit span {
|
||||
display: block;
|
||||
}
|
||||
|
||||
.inline-edit input {
|
||||
display: none;
|
||||
margin-bottom: 0;
|
||||
}
|
||||
|
||||
.inline-edit.active span {
|
||||
display: none;
|
||||
}
|
||||
|
||||
.inline-edit.active input {
|
||||
display: inline-block;
|
||||
// Pagination
|
||||
.pagination {
|
||||
ul > li {
|
||||
cursor: pointer;
|
||||
}
|
||||
}
|
@ -26,8 +26,13 @@ public class TestAppResource extends BaseJerseyTest {
|
||||
*/
|
||||
@Test
|
||||
public void testAppResource() throws JSONException {
|
||||
// Login app1
|
||||
clientUtil.createUser("app1");
|
||||
String app1Token = clientUtil.login("app1");
|
||||
|
||||
// Check the application info
|
||||
WebResource appResource = resource().path("/app");
|
||||
appResource.addFilter(new CookieAuthenticationFilter(app1Token));
|
||||
ClientResponse response = appResource.get(ClientResponse.class);
|
||||
response = appResource.get(ClientResponse.class);
|
||||
Assert.assertEquals(Status.OK, Status.fromStatusCode(response.getStatus()));
|
||||
@ -40,6 +45,7 @@ public class TestAppResource extends BaseJerseyTest {
|
||||
Assert.assertTrue(freeMemory > 0);
|
||||
Long totalMemory = json.getLong("total_memory");
|
||||
Assert.assertTrue(totalMemory > 0 && totalMemory > freeMemory);
|
||||
Assert.assertEquals(0, json.getInt("document_count"));
|
||||
}
|
||||
|
||||
/**
|
||||
|
Loading…
Reference in New Issue
Block a user