diff --git a/docs-parent/TODO b/docs-parent/TODO index e559e087..726b0eb7 100644 --- a/docs-parent/TODO +++ b/docs-parent/TODO @@ -1,2 +1,3 @@ -- Server side reordering files +- Reordering files (server) - GET /app/stats to display general data (server/client) +- User settings \ No newline at end of file diff --git a/docs-web/src/main/java/com/sismics/docs/rest/resource/AppResource.java b/docs-web/src/main/java/com/sismics/docs/rest/resource/AppResource.java index d0555136..b90884d3 100644 --- a/docs-web/src/main/java/com/sismics/docs/rest/resource/AppResource.java +++ b/docs-web/src/main/java/com/sismics/docs/rest/resource/AppResource.java @@ -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 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(); } diff --git a/docs-web/src/main/webapp/style/main.less b/docs-web/src/main/webapp/style/main.less index 1e8ce297..fa6ae9b2 100644 --- a/docs-web/src/main/webapp/style/main.less +++ b/docs-web/src/main/webapp/style/main.less @@ -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; + } } \ No newline at end of file diff --git a/docs-web/src/test/java/com/sismics/docs/rest/TestAppResource.java b/docs-web/src/test/java/com/sismics/docs/rest/TestAppResource.java index 0c44639d..0123ed49 100644 --- a/docs-web/src/test/java/com/sismics/docs/rest/TestAppResource.java +++ b/docs-web/src/test/java/com/sismics/docs/rest/TestAppResource.java @@ -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")); } /**