From 50c7066f88039df0ecb556361734c12bdd548146 Mon Sep 17 00:00:00 2001 From: jendib Date: Tue, 8 Sep 2015 22:25:30 +0200 Subject: [PATCH 1/9] user agent and ip are nullable --- .../java/com/sismics/docs/rest/resource/UserResource.java | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/docs-web/src/main/java/com/sismics/docs/rest/resource/UserResource.java b/docs-web/src/main/java/com/sismics/docs/rest/resource/UserResource.java index 501a4e9b..b1fe41eb 100644 --- a/docs-web/src/main/java/com/sismics/docs/rest/resource/UserResource.java +++ b/docs-web/src/main/java/com/sismics/docs/rest/resource/UserResource.java @@ -40,6 +40,7 @@ import com.sismics.docs.rest.constant.BaseFunction; import com.sismics.rest.exception.ClientException; import com.sismics.rest.exception.ForbiddenClientException; import com.sismics.rest.exception.ServerException; +import com.sismics.rest.util.JsonUtil; import com.sismics.rest.util.ValidationUtil; import com.sismics.security.UserPrincipal; import com.sismics.util.filter.TokenBasedSecurityFilter; @@ -513,8 +514,8 @@ public class UserResource extends BaseResource { for (AuthenticationToken authenticationToken : authenticationTokenDao.getByUserId(principal.getId())) { JsonObjectBuilder session = Json.createObjectBuilder() .add("create_date", authenticationToken.getCreationDate().getTime()) - .add("ip", authenticationToken.getIp()) - .add("user_agent", authenticationToken.getUserAgent()); + .add("ip", JsonUtil.nullable(authenticationToken.getIp())) + .add("user_agent", JsonUtil.nullable(authenticationToken.getUserAgent())); if (authenticationToken.getLastConnectionDate() != null) { session.add("last_connection_date", authenticationToken.getLastConnectionDate().getTime()); } From d8cefddebd4a68afdc6be093cb49ffe982f73f5d Mon Sep 17 00:00:00 2001 From: Benjamin Gamard Date: Sat, 12 Sep 2015 21:31:51 +0200 Subject: [PATCH 2/9] Update README.md --- README.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 64e71255..6652a14a 100644 --- a/README.md +++ b/README.md @@ -24,13 +24,14 @@ Features - Support image and PDF files - Flexible search engine - Full text search in image and PDF -- SHA-256 encryption +- 256-bit AES encryption - Tag system - Multi-users ACL system - Audit log - Document sharing by URL - RESTful Web API - Fully featured Android client +- Tested to 100k documents Download -------- From cfde218d32cf7715a4ddff1057bd99b631ed1828 Mon Sep 17 00:00:00 2001 From: jendib Date: Sun, 13 Sep 2015 23:54:06 +0200 Subject: [PATCH 3/9] #23: Tag tree (server) --- .../com/sismics/docs/core/dao/jpa/TagDao.java | 7 +++-- .../sismics/docs/core/dao/jpa/dto/TagDto.java | 23 +++++++++++++++ .../docs/core/dao/jpa/dto/TagStatDto.java | 2 +- .../com/sismics/docs/core/model/jpa/Tag.java | 25 ++++++++++++++++ .../src/main/resources/config.properties | 2 +- .../resources/db/update/dbupdate-002-0.sql | 2 ++ docs-web/src/dev/resources/config.properties | 2 +- .../docs/rest/resource/TagResource.java | 29 +++++++++++++++++-- docs-web/src/prod/resources/config.properties | 2 +- .../src/stress/resources/config.properties | 2 +- .../sismics/docs/rest/TestTagResource.java | 6 +++- 11 files changed, 91 insertions(+), 11 deletions(-) create mode 100644 docs-core/src/main/resources/db/update/dbupdate-002-0.sql diff --git a/docs-core/src/main/java/com/sismics/docs/core/dao/jpa/TagDao.java b/docs-core/src/main/java/com/sismics/docs/core/dao/jpa/TagDao.java index da108dd9..dbff4438 100644 --- a/docs-core/src/main/java/com/sismics/docs/core/dao/jpa/TagDao.java +++ b/docs-core/src/main/java/com/sismics/docs/core/dao/jpa/TagDao.java @@ -103,7 +103,7 @@ public class TagDao { @SuppressWarnings("unchecked") public List getByDocumentId(String documentId, String userId) { EntityManager em = ThreadLocalContext.get().getEntityManager(); - StringBuilder sb = new StringBuilder("select t.TAG_ID_C, t.TAG_NAME_C, t.TAG_COLOR_C from T_DOCUMENT_TAG dt "); + StringBuilder sb = new StringBuilder("select t.TAG_ID_C, t.TAG_NAME_C, t.TAG_COLOR_C, t.TAG_IDPARENT_C from T_DOCUMENT_TAG dt "); sb.append(" join T_TAG t on t.TAG_ID_C = dt.DOT_IDTAG_C "); sb.append(" where dt.DOT_IDDOCUMENT_C = :documentId and t.TAG_DELETEDATE_D is null "); sb.append(" and t.TAG_IDUSER_C = :userId and dt.DOT_DELETEDATE_D is null "); @@ -123,6 +123,7 @@ public class TagDao { tagDto.setId((String) o[i++]); tagDto.setName((String) o[i++]); tagDto.setColor((String) o[i++]); + tagDto.setParentId((String) o[i++]); tagDtoList.add(tagDto); } return tagDtoList; @@ -137,7 +138,7 @@ public class TagDao { @SuppressWarnings("unchecked") public List getStats(String userId) { EntityManager em = ThreadLocalContext.get().getEntityManager(); - StringBuilder sb = new StringBuilder("select t.TAG_ID_C, t.TAG_NAME_C, t.TAG_COLOR_C, count(d.DOC_ID_C) "); + StringBuilder sb = new StringBuilder("select t.TAG_ID_C, t.TAG_NAME_C, t.TAG_COLOR_C, t.TAG_IDPARENT_C, count(d.DOC_ID_C) "); sb.append(" from T_TAG t "); sb.append(" left join T_DOCUMENT_TAG dt on t.TAG_ID_C = dt.DOT_IDTAG_C and dt.DOT_DELETEDATE_D is null "); sb.append(" left join T_DOCUMENT d on d.DOC_ID_C = dt.DOT_IDDOCUMENT_C and d.DOC_DELETEDATE_D is null and d.DOC_IDUSER_C = :userId "); @@ -158,6 +159,7 @@ public class TagDao { tagDto.setId((String) o[i++]); tagDto.setName((String) o[i++]); tagDto.setColor((String) o[i++]); + tagDto.setParentId((String) o[i++]); tagDto.setCount(((Number) o[i++]).intValue()); tagStatDtoList.add(tagDto); } @@ -281,6 +283,7 @@ public class TagDao { // Update the tag tagFromDb.setName(tag.getName()); tagFromDb.setColor(tag.getColor()); + tagFromDb.setParentId(tag.getParentId()); // Create audit log AuditLogUtil.create(tagFromDb, AuditLogType.UPDATE); diff --git a/docs-core/src/main/java/com/sismics/docs/core/dao/jpa/dto/TagDto.java b/docs-core/src/main/java/com/sismics/docs/core/dao/jpa/dto/TagDto.java index 343acd90..6666015d 100644 --- a/docs-core/src/main/java/com/sismics/docs/core/dao/jpa/dto/TagDto.java +++ b/docs-core/src/main/java/com/sismics/docs/core/dao/jpa/dto/TagDto.java @@ -23,6 +23,11 @@ public class TagDto { * Color. */ private String color; + + /** + * Parent ID. + */ + private String parentId; /** * Getter of id. @@ -77,4 +82,22 @@ public class TagDto { public void setColor(String color) { this.color = color; } + + /** + * Getter of parentId. + * + * @return the parentId + */ + public String getParentId() { + return parentId; + } + + /** + * Setter of parentId. + * + * @param color parentId + */ + public void setParentId(String parentId) { + this.parentId = parentId; + } } diff --git a/docs-core/src/main/java/com/sismics/docs/core/dao/jpa/dto/TagStatDto.java b/docs-core/src/main/java/com/sismics/docs/core/dao/jpa/dto/TagStatDto.java index cb54a7d7..03b0e76c 100644 --- a/docs-core/src/main/java/com/sismics/docs/core/dao/jpa/dto/TagStatDto.java +++ b/docs-core/src/main/java/com/sismics/docs/core/dao/jpa/dto/TagStatDto.java @@ -2,7 +2,7 @@ package com.sismics.docs.core.dao.jpa.dto; /** - * Tag DTO. + * Tag stat DTO. * * @author bgamard */ diff --git a/docs-core/src/main/java/com/sismics/docs/core/model/jpa/Tag.java b/docs-core/src/main/java/com/sismics/docs/core/model/jpa/Tag.java index 70fcba4c..e556c7d2 100644 --- a/docs-core/src/main/java/com/sismics/docs/core/model/jpa/Tag.java +++ b/docs-core/src/main/java/com/sismics/docs/core/model/jpa/Tag.java @@ -39,6 +39,12 @@ public class Tag implements Loggable { @Column(name = "TAG_IDUSER_C", nullable = false, length = 36) private String userId; + /** + * User ID. + */ + @Column(name = "TAG_IDPARENT_C", length = 36) + private String parentId; + /** * Creation date. */ @@ -165,12 +171,31 @@ public class Tag implements Loggable { public void setDeleteDate(Date deleteDate) { this.deleteDate = deleteDate; } + + /** + * Getter of parentId. + * + * @return parentId + */ + public String getParentId() { + return parentId; + } + + /** + * Setter of parentId. + * + * @param parentId parentId + */ + public void setParentId(String parentId) { + this.parentId = parentId; + } @Override public String toString() { return MoreObjects.toStringHelper(this) .add("id", id) .add("name", name) + .add("parentId", parentId) .toString(); } diff --git a/docs-core/src/main/resources/config.properties b/docs-core/src/main/resources/config.properties index 9484a82d..d8b90e8b 100644 --- a/docs-core/src/main/resources/config.properties +++ b/docs-core/src/main/resources/config.properties @@ -1 +1 @@ -db.version=1 \ No newline at end of file +db.version=2 \ No newline at end of file diff --git a/docs-core/src/main/resources/db/update/dbupdate-002-0.sql b/docs-core/src/main/resources/db/update/dbupdate-002-0.sql new file mode 100644 index 00000000..14551cf3 --- /dev/null +++ b/docs-core/src/main/resources/db/update/dbupdate-002-0.sql @@ -0,0 +1,2 @@ +alter table T_TAG add column TAG_IDPARENT_C varchar(36); +update T_CONFIG set CFG_VALUE_C = '2' where CFG_ID_C = 'DB_VERSION'; diff --git a/docs-web/src/dev/resources/config.properties b/docs-web/src/dev/resources/config.properties index f2362d2f..87577f48 100644 --- a/docs-web/src/dev/resources/config.properties +++ b/docs-web/src/dev/resources/config.properties @@ -1,3 +1,3 @@ api.current_version=${project.version} api.min_version=1.0 -db.version=1 \ No newline at end of file +db.version=2 \ No newline at end of file diff --git a/docs-web/src/main/java/com/sismics/docs/rest/resource/TagResource.java b/docs-web/src/main/java/com/sismics/docs/rest/resource/TagResource.java index 05b8cc4b..1ec03fd3 100644 --- a/docs-web/src/main/java/com/sismics/docs/rest/resource/TagResource.java +++ b/docs-web/src/main/java/com/sismics/docs/rest/resource/TagResource.java @@ -22,6 +22,7 @@ import com.sismics.docs.core.dao.jpa.dto.TagStatDto; import com.sismics.docs.core.model.jpa.Tag; import com.sismics.rest.exception.ClientException; import com.sismics.rest.exception.ForbiddenClientException; +import com.sismics.rest.util.JsonUtil; import com.sismics.rest.util.ValidationUtil; /** @@ -50,7 +51,8 @@ public class TagResource extends BaseResource { items.add(Json.createObjectBuilder() .add("id", tag.getId()) .add("name", tag.getName()) - .add("color", tag.getColor())); + .add("color", tag.getColor()) + .add("parent", JsonUtil.nullable(tag.getParentId()))); } JsonObjectBuilder response = Json.createObjectBuilder() @@ -96,7 +98,8 @@ public class TagResource extends BaseResource { @PUT public Response add( @FormParam("name") String name, - @FormParam("color") String color) { + @FormParam("color") String color, + @FormParam("parent") String parentId) { if (!authenticate()) { throw new ForbiddenClientException(); } @@ -117,11 +120,20 @@ public class TagResource extends BaseResource { throw new ClientException("AlreadyExistingTag", MessageFormat.format("Tag already exists: {0}", name)); } + // Check the parent + if (parentId != null) { + Tag parentTag = tagDao.getByTagId(principal.getId(), parentId); + if (parentTag == null) { + throw new ClientException("ParentNotFound", MessageFormat.format("Parent not found: {0}", parentId)); + } + } + // Create the tag tag = new Tag(); tag.setName(name); tag.setColor(color); tag.setUserId(principal.getId()); + tag.setParentId(parentId); String id = tagDao.create(tag); JsonObjectBuilder response = Json.createObjectBuilder() @@ -140,7 +152,8 @@ public class TagResource extends BaseResource { public Response update( @PathParam("id") String id, @FormParam("name") String name, - @FormParam("color") String color) { + @FormParam("color") String color, + @FormParam("parent") String parentId) { if (!authenticate()) { throw new ForbiddenClientException(); } @@ -161,6 +174,14 @@ public class TagResource extends BaseResource { throw new ClientException("TagNotFound", MessageFormat.format("Tag not found: {0}", id)); } + // Check the parent + if (parentId != null) { + Tag parentTag = tagDao.getByTagId(principal.getId(), parentId); + if (parentTag == null) { + throw new ClientException("ParentNotFound", MessageFormat.format("Parent not found: {0}", parentId)); + } + } + // Check for name duplicate Tag tagDuplicate = tagDao.getByName(principal.getId(), name); if (tagDuplicate != null && !tagDuplicate.getId().equals(id)) { @@ -174,6 +195,8 @@ public class TagResource extends BaseResource { if (!StringUtils.isEmpty(color)) { tag.setColor(color); } + // Parent tag is always updated to have the possibility to delete it + tag.setParentId(parentId); tagDao.update(tag); diff --git a/docs-web/src/prod/resources/config.properties b/docs-web/src/prod/resources/config.properties index f2362d2f..87577f48 100644 --- a/docs-web/src/prod/resources/config.properties +++ b/docs-web/src/prod/resources/config.properties @@ -1,3 +1,3 @@ api.current_version=${project.version} api.min_version=1.0 -db.version=1 \ No newline at end of file +db.version=2 \ No newline at end of file diff --git a/docs-web/src/stress/resources/config.properties b/docs-web/src/stress/resources/config.properties index f2362d2f..87577f48 100644 --- a/docs-web/src/stress/resources/config.properties +++ b/docs-web/src/stress/resources/config.properties @@ -1,3 +1,3 @@ api.current_version=${project.version} api.min_version=1.0 -db.version=1 \ No newline at end of file +db.version=2 \ No newline at end of file diff --git a/docs-web/src/test/java/com/sismics/docs/rest/TestTagResource.java b/docs-web/src/test/java/com/sismics/docs/rest/TestTagResource.java index b9fa0532..3094879a 100644 --- a/docs-web/src/test/java/com/sismics/docs/rest/TestTagResource.java +++ b/docs-web/src/test/java/com/sismics/docs/rest/TestTagResource.java @@ -2,6 +2,7 @@ package com.sismics.docs.rest; import javax.json.JsonArray; import javax.json.JsonObject; +import javax.json.JsonValue; import javax.ws.rs.client.Entity; import javax.ws.rs.core.Form; import javax.ws.rs.core.Response; @@ -44,7 +45,8 @@ public class TestTagResource extends BaseJerseyTest { .cookie(TokenBasedSecurityFilter.COOKIE_NAME, tag1Token) .put(Entity.form(new Form() .param("name", "Tag4") - .param("color", "#00ff00")), JsonObject.class); + .param("color", "#00ff00") + .param("parent", tag3Id)), JsonObject.class); String tag4Id = json.getString("id"); Assert.assertNotNull(tag4Id); @@ -129,6 +131,7 @@ public class TestTagResource extends BaseJerseyTest { Assert.assertTrue(tags.size() > 0); Assert.assertEquals("Tag4", tags.getJsonObject(1).getString("name")); Assert.assertEquals("#00ff00", tags.getJsonObject(1).getString("color")); + Assert.assertEquals(tag3Id, tags.getJsonObject(1).getString("parent")); // Update a tag json = target().path("/tag/" + tag4Id).request() @@ -146,6 +149,7 @@ public class TestTagResource extends BaseJerseyTest { Assert.assertTrue(tags.size() > 0); Assert.assertEquals("UpdatedName", tags.getJsonObject(1).getString("name")); Assert.assertEquals("#0000ff", tags.getJsonObject(1).getString("color")); + Assert.assertEquals(JsonValue.NULL, tags.getJsonObject(1).get("parent")); // Deletes a tag target().path("/tag/" + tag4Id).request() From 80bd11b44ecea451cd07fe98fd9d0237bf74d8c8 Mon Sep 17 00:00:00 2001 From: jendib Date: Tue, 15 Sep 2015 00:14:13 +0200 Subject: [PATCH 4/9] #23: Edit tag parent --- .../java/com/sismics/docs/rest/resource/TagResource.java | 8 ++++++-- docs-web/src/main/webapp/src/partial/docs/tag.html | 9 +++++++++ 2 files changed, 15 insertions(+), 2 deletions(-) diff --git a/docs-web/src/main/java/com/sismics/docs/rest/resource/TagResource.java b/docs-web/src/main/java/com/sismics/docs/rest/resource/TagResource.java index 1ec03fd3..11883aab 100644 --- a/docs-web/src/main/java/com/sismics/docs/rest/resource/TagResource.java +++ b/docs-web/src/main/java/com/sismics/docs/rest/resource/TagResource.java @@ -121,7 +121,9 @@ public class TagResource extends BaseResource { } // Check the parent - if (parentId != null) { + if (StringUtils.isEmpty(parentId)) { + parentId = null; + } else { Tag parentTag = tagDao.getByTagId(principal.getId(), parentId); if (parentTag == null) { throw new ClientException("ParentNotFound", MessageFormat.format("Parent not found: {0}", parentId)); @@ -175,7 +177,9 @@ public class TagResource extends BaseResource { } // Check the parent - if (parentId != null) { + if (StringUtils.isEmpty(parentId)) { + parentId = null; + } else { Tag parentTag = tagDao.getByTagId(principal.getId(), parentId); if (parentTag == null) { throw new ClientException("ParentNotFound", MessageFormat.format("Parent not found: {0}", parentId)); diff --git a/docs-web/src/main/webapp/src/partial/docs/tag.html b/docs-web/src/main/webapp/src/partial/docs/tag.html index c8f02165..37a9e7c9 100644 --- a/docs-web/src/main/webapp/src/partial/docs/tag.html +++ b/docs-web/src/main/webapp/src/partial/docs/tag.html @@ -21,6 +21,15 @@ + + +   From c7b752718344b006d4b4daeb4d113fb526a9b61f Mon Sep 17 00:00:00 2001 From: jendib Date: Tue, 15 Sep 2015 23:03:42 +0200 Subject: [PATCH 5/9] Closes #23: Tag tree search --- .../src/app/docs/controller/Document.js | 17 ++++ .../webapp/src/partial/docs/document.html | 97 +++++++++++-------- docs-web/src/main/webapp/src/style/main.less | 13 +++ 3 files changed, 89 insertions(+), 38 deletions(-) diff --git a/docs-web/src/main/webapp/src/app/docs/controller/Document.js b/docs-web/src/main/webapp/src/app/docs/controller/Document.js index 6af0d944..551c1dcc 100644 --- a/docs-web/src/main/webapp/src/app/docs/controller/Document.js +++ b/docs-web/src/main/webapp/src/app/docs/controller/Document.js @@ -13,6 +13,7 @@ angular.module('docs').controller('Document', function($scope, $timeout, $state, $scope.currentPage = 1; $scope.limit = _.isUndefined(localStorage.documentsPageSize) ? 10 : localStorage.documentsPageSize; $scope.search = ''; + $scope.setSearch = function(search) { $scope.search = search }; // A timeout promise is used to slow down search requests to the server // We keep track of it for cancellation purpose @@ -101,4 +102,20 @@ angular.module('docs').controller('Document', function($scope, $timeout, $state, $scope.viewDocument = function(id) { $state.transitionTo('document.view', { id: id }); }; + + // Load tags + var tags = []; + Restangular.one('tag/list').getList().then(function(data) { + tags = data.tags; + }); + + /** + * Find children tags. + * @param parent + */ + $scope.getChildrenTags = function(parent) { + return _.filter(tags, function(tag) { + return tag.parent == parent; + }); + }; }); \ No newline at end of file diff --git a/docs-web/src/main/webapp/src/partial/docs/document.html b/docs-web/src/main/webapp/src/partial/docs/document.html index e4b91b11..ab403e40 100644 --- a/docs-web/src/main/webapp/src/partial/docs/document.html +++ b/docs-web/src/main/webapp/src/partial/docs/document.html @@ -5,49 +5,60 @@ Add a document

-
- - - - - - - - +
+ + +
+ + + + + + + + +
- - - - - + + + + + - - - - - + + + + +
Title Creation date
Title Creation date
- {{ document.title }} ({{ document.file_count }}) - - - {{ document.create_date | date: 'yyyy-MM-dd' }}
+ {{ document.title }} ({{ document.file_count }}) + + + {{ document.create_date | date: 'yyyy-MM-dd' }}
@@ -70,4 +81,14 @@
-
\ No newline at end of file + + + \ No newline at end of file diff --git a/docs-web/src/main/webapp/src/style/main.less b/docs-web/src/main/webapp/src/style/main.less index 1ba0630a..ec55a44b 100644 --- a/docs-web/src/main/webapp/src/style/main.less +++ b/docs-web/src/main/webapp/src/style/main.less @@ -183,4 +183,17 @@ input[readonly].share-link { .tab-pane { margin-top: 20px; +} + +// Tag tree +.tag-tree-dropdown { + padding-left: 0; + + .tag-tree { + li { + margin-left: 20px; + margin-top: 8px; + margin-bottom: 8px; + } + } } \ No newline at end of file From 2c782a23d855f062039dee15abdd7c8d3c9c2177 Mon Sep 17 00:00:00 2001 From: jendib Date: Tue, 22 Sep 2015 01:34:01 +0200 Subject: [PATCH 6/9] Closes #37: Search terms in URL + empty tag tree + transitionTo -> go + audit log message can be empty --- .../docs/rest/resource/AuditLogResource.java | 3 ++- docs-web/src/main/webapp/src/app/docs/app.js | 3 +++ .../webapp/src/app/docs/controller/Document.js | 15 +++++++++++++-- .../src/app/docs/controller/DocumentDefault.js | 4 ++-- .../src/app/docs/controller/DocumentEdit.js | 6 +++--- .../src/app/docs/controller/DocumentView.js | 4 ++-- .../main/webapp/src/app/docs/controller/Login.js | 2 +- .../main/webapp/src/app/docs/controller/Main.js | 4 ++-- .../webapp/src/app/docs/controller/Navigation.js | 4 ++-- .../src/app/docs/controller/SettingsUser.js | 2 +- .../src/app/docs/controller/SettingsUserEdit.js | 6 +++--- .../src/app/share/controller/FileModalView.js | 4 ++-- .../webapp/src/app/share/controller/FileView.js | 2 +- .../main/webapp/src/app/share/controller/Share.js | 4 ++-- .../main/webapp/src/partial/docs/document.html | 3 ++- 15 files changed, 41 insertions(+), 25 deletions(-) diff --git a/docs-web/src/main/java/com/sismics/docs/rest/resource/AuditLogResource.java b/docs-web/src/main/java/com/sismics/docs/rest/resource/AuditLogResource.java index 8c128e06..a1ad4e72 100644 --- a/docs-web/src/main/java/com/sismics/docs/rest/resource/AuditLogResource.java +++ b/docs-web/src/main/java/com/sismics/docs/rest/resource/AuditLogResource.java @@ -19,6 +19,7 @@ import com.sismics.docs.core.util.jpa.PaginatedLists; import com.sismics.docs.core.util.jpa.SortCriteria; import com.sismics.rest.exception.ForbiddenClientException; import com.sismics.rest.exception.ServerException; +import com.sismics.rest.util.JsonUtil; /** * Audit log REST resources. @@ -70,7 +71,7 @@ public class AuditLogResource extends BaseResource { .add("target", auditLogDto.getEntityId()) .add("class", auditLogDto.getEntityClass()) .add("type", auditLogDto.getType().name()) - .add("message", auditLogDto.getMessage()) + .add("message", JsonUtil.nullable(auditLogDto.getMessage())) .add("create_date", auditLogDto.getCreateTimestamp())); } diff --git a/docs-web/src/main/webapp/src/app/docs/app.js b/docs-web/src/main/webapp/src/app/docs/app.js index 4a88388a..ab3a7c9a 100644 --- a/docs-web/src/main/webapp/src/app/docs/app.js +++ b/docs-web/src/main/webapp/src/app/docs/app.js @@ -125,6 +125,9 @@ angular.module('docs', } } }) + .state('document.default.search', { + url: '/search/:search' + }) .state('document.default.file', { url: '/file/:fileId', views: { diff --git a/docs-web/src/main/webapp/src/app/docs/controller/Document.js b/docs-web/src/main/webapp/src/app/docs/controller/Document.js index 551c1dcc..4497d41a 100644 --- a/docs-web/src/main/webapp/src/app/docs/controller/Document.js +++ b/docs-web/src/main/webapp/src/app/docs/controller/Document.js @@ -12,7 +12,7 @@ angular.module('docs').controller('Document', function($scope, $timeout, $state, $scope.offset = 0; $scope.currentPage = 1; $scope.limit = _.isUndefined(localStorage.documentsPageSize) ? 10 : localStorage.documentsPageSize; - $scope.search = ''; + $scope.search = $state.params.search ? $state.params.search : ''; $scope.setSearch = function(search) { $scope.search = search }; // A timeout promise is used to slow down search requests to the server @@ -66,6 +66,17 @@ angular.module('docs').controller('Document', function($scope, $timeout, $state, $timeout.cancel(timeoutPromise); } + if ($state.current.name == 'document.default' + || $state.current.name == 'document.default.search') { + $state.go($scope.search == '' ? + 'document.default' : 'document.default.search', { + search: $scope.search + }, { + location: 'replace', + notify: false + }); + } + // Call API later timeoutPromise = $timeout(function () { $scope.loadDocuments(); @@ -100,7 +111,7 @@ angular.module('docs').controller('Document', function($scope, $timeout, $state, * Display a document. */ $scope.viewDocument = function(id) { - $state.transitionTo('document.view', { id: id }); + $state.go('document.view', { id: id }); }; // Load tags diff --git a/docs-web/src/main/webapp/src/app/docs/controller/DocumentDefault.js b/docs-web/src/main/webapp/src/app/docs/controller/DocumentDefault.js index e5433e09..361ef241 100644 --- a/docs-web/src/main/webapp/src/app/docs/controller/DocumentDefault.js +++ b/docs-web/src/main/webapp/src/app/docs/controller/DocumentDefault.js @@ -81,7 +81,7 @@ angular.module('docs').controller('DocumentDefault', function($scope, $state, Re * Navigate to the selected file. */ $scope.openFile = function (file) { - $state.transitionTo('document.default.file', { fileId: file.id }) + $state.go('document.default.file', { fileId: file.id }) }; /** @@ -107,6 +107,6 @@ angular.module('docs').controller('DocumentDefault', function($scope, $state, Re * Add a document with checked files. */ $scope.addDocument = function() { - $state.transitionTo('document.add', { files: _.pluck($scope.checkedFiles(), 'id') }); + $state.go('document.add', { files: _.pluck($scope.checkedFiles(), 'id') }); }; }); \ No newline at end of file diff --git a/docs-web/src/main/webapp/src/app/docs/controller/DocumentEdit.js b/docs-web/src/main/webapp/src/app/docs/controller/DocumentEdit.js index c0d7d4b3..c9141ec7 100644 --- a/docs-web/src/main/webapp/src/app/docs/controller/DocumentEdit.js +++ b/docs-web/src/main/webapp/src/app/docs/controller/DocumentEdit.js @@ -95,7 +95,7 @@ angular.module('docs').controller('DocumentEdit', function($rootScope, $scope, $ if ($scope.isEdit()) { // Go back to the edited document $scope.pageDocuments(); - $state.transitionTo('document.view', { id: $stateParams.id }); + $state.go('document.view', { id: $stateParams.id }); } else { // Reset the scope and stay here var fileUploadCount = _.size($scope.newFiles) + resolve.length; @@ -188,9 +188,9 @@ angular.module('docs').controller('DocumentEdit', function($rootScope, $scope, $ */ $scope.cancel = function() { if ($scope.isEdit()) { - $state.transitionTo('document.view', { id: $stateParams.id }); + $state.go('document.view', { id: $stateParams.id }); } else { - $state.transitionTo('document.default'); + $state.go('document.default'); } }; diff --git a/docs-web/src/main/webapp/src/app/docs/controller/DocumentView.js b/docs-web/src/main/webapp/src/app/docs/controller/DocumentView.js index 8962c884..dbe473d5 100644 --- a/docs-web/src/main/webapp/src/app/docs/controller/DocumentView.js +++ b/docs-web/src/main/webapp/src/app/docs/controller/DocumentView.js @@ -62,7 +62,7 @@ angular.module('docs').controller('DocumentView', function ($scope, $state, $sta * Navigate to the selected file. */ $scope.openFile = function (file) { - $state.transitionTo('document.view.file', { id: $stateParams.id, fileId: file.id }) + $state.go('document.view.file', { id: $stateParams.id, fileId: file.id }) }; /** @@ -80,7 +80,7 @@ angular.module('docs').controller('DocumentView', function ($scope, $state, $sta if (result == 'ok') { Restangular.one('document', document.id).remove().then(function () { $scope.loadDocuments(); - $state.transitionTo('document.default'); + $state.go('document.default'); }); } }); diff --git a/docs-web/src/main/webapp/src/app/docs/controller/Login.js b/docs-web/src/main/webapp/src/app/docs/controller/Login.js index 14340858..9c695aa3 100644 --- a/docs-web/src/main/webapp/src/app/docs/controller/Login.js +++ b/docs-web/src/main/webapp/src/app/docs/controller/Login.js @@ -9,7 +9,7 @@ angular.module('docs').controller('Login', function($scope, $rootScope, $state, User.userInfo(true).then(function(data) { $rootScope.userInfo = data; }); - $state.transitionTo('document.default'); + $state.go('document.default'); }, function() { var title = 'Login failed'; var msg = 'Username or password invalid'; diff --git a/docs-web/src/main/webapp/src/app/docs/controller/Main.js b/docs-web/src/main/webapp/src/app/docs/controller/Main.js index bb56d24e..18e04ce7 100644 --- a/docs-web/src/main/webapp/src/app/docs/controller/Main.js +++ b/docs-web/src/main/webapp/src/app/docs/controller/Main.js @@ -6,9 +6,9 @@ angular.module('docs').controller('Main', function($scope, $rootScope, $state, User) { User.userInfo().then(function(data) { if (data.anonymous) { - $state.transitionTo('login'); + $state.go('login'); } else { - $state.transitionTo('document.default'); + $state.go('document.default'); } }); }); \ No newline at end of file diff --git a/docs-web/src/main/webapp/src/app/docs/controller/Navigation.js b/docs-web/src/main/webapp/src/app/docs/controller/Navigation.js index 64417aa9..d21bbb09 100644 --- a/docs-web/src/main/webapp/src/app/docs/controller/Navigation.js +++ b/docs-web/src/main/webapp/src/app/docs/controller/Navigation.js @@ -41,7 +41,7 @@ angular.module('docs').controller('Navigation', function($scope, $http, $state, */ $scope.openLogs = function() { $scope.errorNumber = 0; - $state.transitionTo('settings.log'); + $state.go('settings.log'); }; /** @@ -52,7 +52,7 @@ angular.module('docs').controller('Navigation', function($scope, $http, $state, User.userInfo(true).then(function(data) { $rootScope.userInfo = data; }); - $state.transitionTo('main'); + $state.go('main'); }); $event.preventDefault(); }; diff --git a/docs-web/src/main/webapp/src/app/docs/controller/SettingsUser.js b/docs-web/src/main/webapp/src/app/docs/controller/SettingsUser.js index f65160aa..8a499264 100644 --- a/docs-web/src/main/webapp/src/app/docs/controller/SettingsUser.js +++ b/docs-web/src/main/webapp/src/app/docs/controller/SettingsUser.js @@ -19,6 +19,6 @@ angular.module('docs').controller('SettingsUser', function($scope, $state, Resta * Edit a user. */ $scope.editUser = function(user) { - $state.transitionTo('settings.user.edit', { username: user.username }); + $state.go('settings.user.edit', { username: user.username }); }; }); \ No newline at end of file diff --git a/docs-web/src/main/webapp/src/app/docs/controller/SettingsUserEdit.js b/docs-web/src/main/webapp/src/app/docs/controller/SettingsUserEdit.js index ecd4d027..91537989 100644 --- a/docs-web/src/main/webapp/src/app/docs/controller/SettingsUserEdit.js +++ b/docs-web/src/main/webapp/src/app/docs/controller/SettingsUserEdit.js @@ -38,7 +38,7 @@ angular.module('docs').controller('SettingsUserEdit', function($scope, $dialog, promise.then(function() { $scope.loadUsers(); - $state.transitionTo('settings.user'); + $state.go('settings.user'); }); }; @@ -54,9 +54,9 @@ angular.module('docs').controller('SettingsUserEdit', function($scope, $dialog, if (result == 'ok') { Restangular.one('user', $stateParams.username).remove().then(function() { $scope.loadUsers(); - $state.transitionTo('settings.user'); + $state.go('settings.user'); }, function () { - $state.transitionTo('settings.user'); + $state.go('settings.user'); }); } }); diff --git a/docs-web/src/main/webapp/src/app/share/controller/FileModalView.js b/docs-web/src/main/webapp/src/app/share/controller/FileModalView.js index 8426022d..f705378c 100644 --- a/docs-web/src/main/webapp/src/app/share/controller/FileModalView.js +++ b/docs-web/src/main/webapp/src/app/share/controller/FileModalView.js @@ -24,7 +24,7 @@ angular.module('share').controller('FileModalView', function($rootScope, $modalI if (value.id == $stateParams.fileId) { var next = $scope.files[key + 1]; if (next) { - $state.transitionTo('share.file', { documentId: $stateParams.documentId, shareId: $stateParams.shareId, fileId: next.id }); + $state.go('share.file', { documentId: $stateParams.documentId, shareId: $stateParams.shareId, fileId: next.id }); } } }); @@ -38,7 +38,7 @@ angular.module('share').controller('FileModalView', function($rootScope, $modalI if (value.id == $stateParams.fileId) { var previous = $scope.files[key - 1]; if (previous) { - $state.transitionTo('share.file', { documentId: $stateParams.documentId, shareId: $stateParams.shareId, fileId: previous.id }); + $state.go('share.file', { documentId: $stateParams.documentId, shareId: $stateParams.shareId, fileId: previous.id }); } } }); diff --git a/docs-web/src/main/webapp/src/app/share/controller/FileView.js b/docs-web/src/main/webapp/src/app/share/controller/FileView.js index 3ea83514..07e45b23 100644 --- a/docs-web/src/main/webapp/src/app/share/controller/FileView.js +++ b/docs-web/src/main/webapp/src/app/share/controller/FileView.js @@ -16,6 +16,6 @@ angular.module('share').controller('FileView', function($modal, $state, $statePa modal.closed = true; },function(result) { modal.closed = true; - $state.transitionTo('share', { documentId: $stateParams.documentId, shareId: $stateParams.shareId }); + $state.go('share', { documentId: $stateParams.documentId, shareId: $stateParams.shareId }); }); }); \ No newline at end of file diff --git a/docs-web/src/main/webapp/src/app/share/controller/Share.js b/docs-web/src/main/webapp/src/app/share/controller/Share.js index f3ddda15..c1e15ae6 100644 --- a/docs-web/src/main/webapp/src/app/share/controller/Share.js +++ b/docs-web/src/main/webapp/src/app/share/controller/Share.js @@ -10,7 +10,7 @@ angular.module('share').controller('Share', function($scope, $state, $stateParam $scope.document = data; }, function (response) { if (response.status == 403) { - $state.transitionTo('403'); + $state.go('403'); } }); @@ -24,6 +24,6 @@ angular.module('share').controller('Share', function($scope, $state, $stateParam * Navigate to the selected file. */ $scope.openFile = function (file) { - $state.transitionTo('share.file', { documentId: $stateParams.documentId, shareId: $stateParams.shareId, fileId: file.id }) + $state.go('share.file', { documentId: $stateParams.documentId, shareId: $stateParams.shareId, fileId: file.id }) }; }); \ No newline at end of file diff --git a/docs-web/src/main/webapp/src/partial/docs/document.html b/docs-web/src/main/webapp/src/partial/docs/document.html index ab403e40..207e4374 100644 --- a/docs-web/src/main/webapp/src/partial/docs/document.html +++ b/docs-web/src/main/webapp/src/partial/docs/document.html @@ -11,6 +11,7 @@ Tags @@ -48,7 +49,7 @@ {{ document.title }} ({{ document.file_count }}) - + {{ document.create_date | date: 'yyyy-MM-dd' }} From 08633a993dfdd8d3eb99b309cef1ac05eae3d3a2 Mon Sep 17 00:00:00 2001 From: jendib Date: Sun, 1 Nov 2015 13:30:46 +0100 Subject: [PATCH 7/9] Closes #34: nothing displayed if no description --- docs-android/app/app.iml | 26 ++++++++++--------- docs-android/app/build.gradle | 8 +++--- .../docs/activity/DocumentViewActivity.java | 2 +- .../listener/RecyclerItemClickListener.java | 11 +++++--- 4 files changed, 27 insertions(+), 20 deletions(-) diff --git a/docs-android/app/app.iml b/docs-android/app/app.iml index d5ce36f5..afd2300c 100644 --- a/docs-android/app/app.iml +++ b/docs-android/app/app.iml @@ -12,10 +12,12 @@