branch develop updated (6f93a2b -> 924395d)
This is an automated email from the git hooks/post-receive script. New change to branch develop in repository coselmar. See http://git.codelutin.com/coselmar.git from 6f93a2b fixes #6205 Merge branch 'feature/6205-improve-user-search' into develop new 993c889 fix error on user search with active, inactive, both new 4c5b6ed change 'Deleted' label to 'disable' for users, and redirect to users list after modify new e24edc0 review data encoding with POST method new ea8bffd change way to create document with file, in order to have metadata in utf-8 : split into to ways : first create document and then attach file new 924395d Fixes #6438 Merge branch 'feature/6438-improve-user-management' into develop The 5 revisions listed above as "new" are entirely new to this repository and will be described in separate emails. The revisions listed as "adds" were already present in the repository and have only been added to this reference. Detailed log of new commits: commit 924395d7384b36fa35eb4ea4f1e9043abdb17ae2 Merge: 993c889 ea8bffd Author: Yannick Martel <martel@©odelutin.com> Date: Fri Jan 16 12:49:37 2015 +0100 Fixes #6438 Merge branch 'feature/6438-improve-user-management' into develop commit ea8bffd280ceb0cec0403d8a6d281966ed82584e Author: Yannick Martel <martel@©odelutin.com> Date: Fri Jan 16 12:49:10 2015 +0100 change way to create document with file, in order to have metadata in utf-8 : split into to ways : first create document and then attach file commit e24edc0cb9cc21ee243d3cfc81114c95a96736ea Author: Yannick Martel <martel@©odelutin.com> Date: Thu Jan 15 18:09:26 2015 +0100 review data encoding with POST method commit 4c5b6ed017870c908ea47035f6111d9da5509747 Author: Yannick Martel <martel@©odelutin.com> Date: Thu Jan 15 15:11:18 2015 +0100 change 'Deleted' label to 'disable' for users, and redirect to users list after modify commit 993c8895145b30b256fa66bf427180a8dcb0556f Author: Yannick Martel <martel@©odelutin.com> Date: Thu Jan 15 11:37:28 2015 +0100 fix error on user search with active, inactive, both Summary of changes: .../persistence/entity/CoselmarUserTopiaDao.java | 2 +- .../src/main/xmi/coselmar-model.zargo | Bin 10322 -> 10390 bytes .../fr/ifremer/coselmar/beans/DocumentBean.java | 12 ++++- .../coselmar/converter/BeanEntityConverter.java | 3 +- .../coselmar/services/v1/DocumentsWebService.java | 54 +++++++++++++++++++- coselmar-rest/src/main/resources/mapping | 3 +- coselmar-ui/src/main/webapp/index.html | 2 + .../src/main/webapp/js/coselmar-controllers.js | 56 ++++++++++++--------- .../main/webapp/js/coselmar-questions-services.js | 14 ++---- .../src/main/webapp/js/coselmar-services.js | 45 +++++++++++++++-- .../src/main/webapp/js/coselmar-user-services.js | 15 ++---- coselmar-ui/src/main/webapp/js/coselmar.js | 3 ++ .../src/main/webapp/views/documents/document.html | 4 ++ coselmar-ui/src/main/webapp/views/users/user.html | 2 +- coselmar-ui/src/main/webapp/views/users/users.html | 2 +- 15 files changed, 161 insertions(+), 56 deletions(-) -- To stop receiving notification emails like this one, please contact codelutin.com SCM administrator <admin+scm@codelutin.com>.
This is an automated email from the git hooks/post-receive script. New commit to branch develop in repository coselmar. See http://git.codelutin.com/coselmar.git commit 993c8895145b30b256fa66bf427180a8dcb0556f Author: Yannick Martel <martel@©odelutin.com> Date: Thu Jan 15 11:37:28 2015 +0100 fix error on user search with active, inactive, both --- .../ifremer/coselmar/persistence/entity/CoselmarUserTopiaDao.java | 2 +- coselmar-ui/src/main/webapp/js/coselmar-controllers.js | 6 +++--- coselmar-ui/src/main/webapp/js/coselmar-user-services.js | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/coselmar-persistence/src/main/java/fr/ifremer/coselmar/persistence/entity/CoselmarUserTopiaDao.java b/coselmar-persistence/src/main/java/fr/ifremer/coselmar/persistence/entity/CoselmarUserTopiaDao.java index efa1174..458da7d 100644 --- a/coselmar-persistence/src/main/java/fr/ifremer/coselmar/persistence/entity/CoselmarUserTopiaDao.java +++ b/coselmar-persistence/src/main/java/fr/ifremer/coselmar/persistence/entity/CoselmarUserTopiaDao.java @@ -128,7 +128,7 @@ public class CoselmarUserTopiaDao extends AbstractCoselmarUserTopiaDao<CoselmarU // only active ? if (!activeAndInactive) { - String activeCondition = DaoUtils.andAttributeEquals("CU", CoselmarUser.PROPERTY_ACTIVE, args, true); + String activeCondition = DaoUtils.andAttributeEquals("CU", CoselmarUser.PROPERTY_ACTIVE, args, example.isActive()); hqlBuilder.append(activeCondition); } diff --git a/coselmar-ui/src/main/webapp/js/coselmar-controllers.js b/coselmar-ui/src/main/webapp/js/coselmar-controllers.js index ddd2f53..9b457ee 100644 --- a/coselmar-ui/src/main/webapp/js/coselmar-controllers.js +++ b/coselmar-ui/src/main/webapp/js/coselmar-controllers.js @@ -205,14 +205,14 @@ coselmarControllers.directive('ngFileModel', ['$parse', function ($parse) { coselmarControllers.controller("UsersCtrl", ['$scope', '$route', '$routeParams', '$location', 'userService', function($scope, $route, $routeParams, $location, userService){ //manage keywords if given - $scope.search = { searchKeyword : ''}; + $scope.search = { searchKeywords : []}; $scope.example = {}; var keywords = $routeParams.keywords; if (Array.isArray(keywords)) { - $scope.search.searchKeyword = keywords[0]; + $scope.search.searchKeywords = keywords; } else if (keywords) { - $scope.search.searchKeyword = keywords; + $scope.search.searchKeywords.push(keywords); } var showDisable = $routeParams.showDisable; if (showDisable) { diff --git a/coselmar-ui/src/main/webapp/js/coselmar-user-services.js b/coselmar-ui/src/main/webapp/js/coselmar-user-services.js index 52a44e3..309e67a 100644 --- a/coselmar-ui/src/main/webapp/js/coselmar-user-services.js +++ b/coselmar-ui/src/main/webapp/js/coselmar-user-services.js @@ -70,7 +70,7 @@ function User(resource, config){ this.getUsers = function(searchKeywords, showDisable, successFunction){ // Load all users - var userResource = resource(baseURL, {'search' : {'fullTextSearch' : searchKeywords, 'activeAndInactive': showDisable}}); + var userResource = resource(baseURL, {'search' : {'fullTextSearch' : searchKeywords, 'activeAndInactive': showDisable, 'active': true}}); userResource.query(successFunction); }; -- To stop receiving notification emails like this one, please contact codelutin.com SCM administrator <admin+scm@codelutin.com>.
This is an automated email from the git hooks/post-receive script. New commit to branch develop in repository coselmar. See http://git.codelutin.com/coselmar.git commit 4c5b6ed017870c908ea47035f6111d9da5509747 Author: Yannick Martel <martel@©odelutin.com> Date: Thu Jan 15 15:11:18 2015 +0100 change 'Deleted' label to 'disable' for users, and redirect to users list after modify --- coselmar-ui/src/main/webapp/js/coselmar-controllers.js | 4 ++-- coselmar-ui/src/main/webapp/views/users/user.html | 2 +- coselmar-ui/src/main/webapp/views/users/users.html | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/coselmar-ui/src/main/webapp/js/coselmar-controllers.js b/coselmar-ui/src/main/webapp/js/coselmar-controllers.js index 9b457ee..aecc3cb 100644 --- a/coselmar-ui/src/main/webapp/js/coselmar-controllers.js +++ b/coselmar-ui/src/main/webapp/js/coselmar-controllers.js @@ -351,8 +351,8 @@ coselmarControllers.controller("UserViewCtrl", if(isValidForm) { userService.saveUser($scope.user, function() { - // On success, reload the view page - $location.search(""); + // On success, back on users list + $location.path("/users"); },function(error) { //TODO ymartel 20141118 : deal with error.status or statusText diff --git a/coselmar-ui/src/main/webapp/views/users/user.html b/coselmar-ui/src/main/webapp/views/users/user.html index c3c87ab..eebbedb 100644 --- a/coselmar-ui/src/main/webapp/views/users/user.html +++ b/coselmar-ui/src/main/webapp/views/users/user.html @@ -52,7 +52,7 @@ <tr> <td>Status</td> <td ng-if="user.active">Active</td> - <td ng-if="!user.active">Deleted</td> + <td ng-if="!user.active">Disable</td> </tr> </table> <div class="float-right"> diff --git a/coselmar-ui/src/main/webapp/views/users/users.html b/coselmar-ui/src/main/webapp/views/users/users.html index 765d71a..adff98a 100644 --- a/coselmar-ui/src/main/webapp/views/users/users.html +++ b/coselmar-ui/src/main/webapp/views/users/users.html @@ -109,7 +109,7 @@ <td>{{user.organization}}</td> <td>{{user.role}}</td> <td ng-if="user.active">Active</td> - <td ng-if="!user.active">Deleted</td> + <td ng-if="!user.active">Disable</td> <td> <a class="btn btn-action btn-edit" href="#/users/{{user.id}}?edit"> <span class="glyphicon glyphicon-edit" aria-hidden="true"></span>Modify -- To stop receiving notification emails like this one, please contact codelutin.com SCM administrator <admin+scm@codelutin.com>.
This is an automated email from the git hooks/post-receive script. New commit to branch develop in repository coselmar. See http://git.codelutin.com/coselmar.git commit e24edc0cb9cc21ee243d3cfc81114c95a96736ea Author: Yannick Martel <martel@©odelutin.com> Date: Thu Jan 15 18:09:26 2015 +0100 review data encoding with POST method --- coselmar-ui/src/main/webapp/index.html | 2 ++ .../src/main/webapp/js/coselmar-questions-services.js | 14 ++++---------- coselmar-ui/src/main/webapp/js/coselmar-services.js | 8 ++++---- coselmar-ui/src/main/webapp/js/coselmar-user-services.js | 13 ++++--------- coselmar-ui/src/main/webapp/js/coselmar.js | 3 +++ 5 files changed, 17 insertions(+), 23 deletions(-) diff --git a/coselmar-ui/src/main/webapp/index.html b/coselmar-ui/src/main/webapp/index.html index 0493c56..bd194a0 100644 --- a/coselmar-ui/src/main/webapp/index.html +++ b/coselmar-ui/src/main/webapp/index.html @@ -24,6 +24,8 @@ <html ng-app="coselmarApp" ng-controller="HomeCtrl"> <head> + <meta charset="utf-8" /> + <link rel="stylesheet" href="webjars/bootstrap/3.3.1/css/bootstrap.css"> <link rel="stylesheet" href="webjars/font-awesome/4.2.0/css/font-awesome.css"> <link rel="stylesheet" href="css/coselmar.css"> diff --git a/coselmar-ui/src/main/webapp/js/coselmar-questions-services.js b/coselmar-ui/src/main/webapp/js/coselmar-questions-services.js index 31a05ff..f5f4d1e 100644 --- a/coselmar-ui/src/main/webapp/js/coselmar-questions-services.js +++ b/coselmar-ui/src/main/webapp/js/coselmar-questions-services.js @@ -37,6 +37,7 @@ function Question(resource, config){ var formData = new FormData(); formData.append("question", JSON.stringify(question)); + var questionParam = $.param({'question' : JSON.stringify(question)}); // Save the Question var serviceURl = baseURL; @@ -46,13 +47,9 @@ function Question(resource, config){ var questionResource = resource(serviceURl, null, { 'save': { method:'POST', - transformRequest: angular.identity, - headers:{ - 'Content-Type': undefined - } } }); - questionResource.save(null, formData, successFunction, failFunction); + questionResource.save(null, questionParam, successFunction, failFunction); }; this.findUsers = function(example, successFunction) { @@ -90,19 +87,16 @@ function Question(resource, config){ var formData = new FormData(); formData.append("documents", JSON.stringify(documents)); + var documentsParam = $.param({'documents': JSON.stringify(documents)}) var serviceURl = baseURL + "/" + questionId + "/documents"; var questionResource = resource(serviceURl, null, { 'save': { method:'POST', - transformRequest: angular.identity, isArray: true, - headers:{ - 'Content-Type': undefined - } } }); - questionResource.save(null, formData, successFunction, failFunction); + questionResource.save(null, documentsParam, successFunction, failFunction); }; this.findAllTypes = function(successFunction){ diff --git a/coselmar-ui/src/main/webapp/js/coselmar-services.js b/coselmar-ui/src/main/webapp/js/coselmar-services.js index 7ba27db..c205a04 100644 --- a/coselmar-ui/src/main/webapp/js/coselmar-services.js +++ b/coselmar-ui/src/main/webapp/js/coselmar-services.js @@ -45,10 +45,10 @@ function Document(resource, config){ var docResource = resource(baseURL, null, { 'upload': { method:'POST', - transformRequest: angular.identity, - headers:{ - 'Content-Type':undefined - } + transformRequest: function (data, headersGetterFunction) { + return data; + }, + headers: {'Content-Type': undefined, 'Content-Transfer-Encoding': 'utf-8'} } }); docResource.upload(null, formData, successFunction, failFunction); diff --git a/coselmar-ui/src/main/webapp/js/coselmar-user-services.js b/coselmar-ui/src/main/webapp/js/coselmar-user-services.js index 309e67a..efd0c70 100644 --- a/coselmar-ui/src/main/webapp/js/coselmar-user-services.js +++ b/coselmar-ui/src/main/webapp/js/coselmar-user-services.js @@ -34,8 +34,7 @@ function User(resource, config){ this.saveUser = function(user, successFunction, failFunction){ - var formData = new FormData(); - formData.append("user", JSON.stringify(user)); + var param = $.param({ 'user': JSON.stringify(user)}); // Save the User var serviceURl = baseURL; @@ -44,14 +43,10 @@ function User(resource, config){ } var userResource = resource(serviceURl, null, { 'save': { - method:'POST', - transformRequest: angular.identity, - headers:{ - 'Content-Type': undefined - } + method:'POST' } }); - userResource.save(null, formData, successFunction, failFunction); + userResource.save(null, param, successFunction, failFunction); } this.getUser = function(id, scope){ @@ -91,7 +86,7 @@ function User(resource, config){ 'post' : { method: 'POST', headers : { - 'Content-Type' : 'application/x-www-form-urlencoded' + 'Content-Type' : 'application/x-www-form-urlencoded;charset=utf-8' }, }}); userResource.post(credentials, successFunction, failFunction); diff --git a/coselmar-ui/src/main/webapp/js/coselmar.js b/coselmar-ui/src/main/webapp/js/coselmar.js index f10805e..12e3435 100644 --- a/coselmar-ui/src/main/webapp/js/coselmar.js +++ b/coselmar-ui/src/main/webapp/js/coselmar.js @@ -126,4 +126,7 @@ coselmarApp.config(function($httpProvider) { } }; }); + + // edit content-type for send data to the server + $httpProvider.defaults.headers.post['Content-Type'] = 'application/x-www-form-urlencoded;charset=utf-8'; }); \ No newline at end of file -- To stop receiving notification emails like this one, please contact codelutin.com SCM administrator <admin+scm@codelutin.com>.
This is an automated email from the git hooks/post-receive script. New commit to branch develop in repository coselmar. See http://git.codelutin.com/coselmar.git commit ea8bffd280ceb0cec0403d8a6d281966ed82584e Author: Yannick Martel <martel@©odelutin.com> Date: Fri Jan 16 12:49:10 2015 +0100 change way to create document with file, in order to have metadata in utf-8 : split into to ways : first create document and then attach file --- .../src/main/xmi/coselmar-model.zargo | Bin 10322 -> 10390 bytes .../fr/ifremer/coselmar/beans/DocumentBean.java | 12 ++++- .../coselmar/converter/BeanEntityConverter.java | 3 +- .../coselmar/services/v1/DocumentsWebService.java | 54 ++++++++++++++++++++- coselmar-rest/src/main/resources/mapping | 3 +- .../src/main/webapp/js/coselmar-controllers.js | 46 ++++++++++-------- .../src/main/webapp/js/coselmar-services.js | 37 ++++++++++++++ .../src/main/webapp/views/documents/document.html | 4 ++ 8 files changed, 135 insertions(+), 24 deletions(-) diff --git a/coselmar-persistence/src/main/xmi/coselmar-model.zargo b/coselmar-persistence/src/main/xmi/coselmar-model.zargo index c48b79e..ee44fcc 100644 Binary files a/coselmar-persistence/src/main/xmi/coselmar-model.zargo and b/coselmar-persistence/src/main/xmi/coselmar-model.zargo differ diff --git a/coselmar-rest/src/main/java/fr/ifremer/coselmar/beans/DocumentBean.java b/coselmar-rest/src/main/java/fr/ifremer/coselmar/beans/DocumentBean.java index 51e778d..2b60237 100644 --- a/coselmar-rest/src/main/java/fr/ifremer/coselmar/beans/DocumentBean.java +++ b/coselmar-rest/src/main/java/fr/ifremer/coselmar/beans/DocumentBean.java @@ -50,6 +50,7 @@ public class DocumentBean implements Serializable { protected String summary; protected Date publicationDate; protected String comment; + protected String fileName; // Document could be internal file or external link protected boolean withFile; @@ -61,7 +62,7 @@ public class DocumentBean implements Serializable { String type, String summary, String language, Date publicationDate, String authors, String license, String copyright, boolean withFile, String mimeType, String externalUrl, - String comment) { + String comment, String fileName) { this.id = id; this.name = name; this.ownerName = ownerName; @@ -86,6 +87,7 @@ public class DocumentBean implements Serializable { this.withFile = withFile; this.mimeType = mimeType; this.externalUrl = externalUrl; + this.fileName = fileName; this.comment = comment; } @@ -229,6 +231,14 @@ public class DocumentBean implements Serializable { this.mimeType = mimeType; } + public String getFileName() { + return fileName; + } + + public void setFileName(String fileName) { + this.fileName = fileName; + } + public String getComment() { return comment; } diff --git a/coselmar-rest/src/main/java/fr/ifremer/coselmar/converter/BeanEntityConverter.java b/coselmar-rest/src/main/java/fr/ifremer/coselmar/converter/BeanEntityConverter.java index 3ae8e53..3dc4765 100644 --- a/coselmar-rest/src/main/java/fr/ifremer/coselmar/converter/BeanEntityConverter.java +++ b/coselmar-rest/src/main/java/fr/ifremer/coselmar/converter/BeanEntityConverter.java @@ -77,7 +77,8 @@ public class BeanEntityConverter { document.isWithFile(), document.getMimeType(), document.getExternalUrl(), - document.getComment() + document.getComment(), + document.getFileName() ); } diff --git a/coselmar-rest/src/main/java/fr/ifremer/coselmar/services/v1/DocumentsWebService.java b/coselmar-rest/src/main/java/fr/ifremer/coselmar/services/v1/DocumentsWebService.java index 63dbf28..9392bf6 100644 --- a/coselmar-rest/src/main/java/fr/ifremer/coselmar/services/v1/DocumentsWebService.java +++ b/coselmar-rest/src/main/java/fr/ifremer/coselmar/services/v1/DocumentsWebService.java @@ -263,6 +263,58 @@ public class DocumentsWebService extends CoselmarWebServiceSupport { } + public void addDocumentFile(String documentId, UploadFile uploadFile) throws InvalidCredentialException, UnauthorizedException { + + // Check authentication + String authorization = getContext().getHeader("Authorization"); + UserWebToken userWebToken = checkAuthentication(authorization); + + // Only Expert or Supervisor can add document + String userRole = userWebToken.getRole(); + if (!DOCUMENT_EDIT_ALLOWED_USER_ROLES.contains(userRole.toUpperCase())) { + String message = String.format("User %s %s ('%s') is not allowed to add document", + userWebToken.getFirstName(), userWebToken.getLastName(), userWebToken.getUserId()); + if (log.isWarnEnabled()) { + log.warn(message); + } + throw new UnauthorizedException(message); + } + + Preconditions.checkNotNull(documentId); + Preconditions.checkNotNull(uploadFile); + + // retrieve user who will be assigned as document owner + String userFullId = getFullUserIdFromShort(userWebToken.getUserId()); + + CoselmarUser owner; + try { + owner = getCoselmarUserDao().forTopiaIdEquals(userFullId).findUnique(); + } catch (TopiaNoResultException tnre) { + // Should not happened, cause user are not really deleted + String message = String.format("Seems that logged user ('%s') does not exist anymore.", userFullId); + if (log.isErrorEnabled()) { + log.equals(message); + } + throw new InvalidCredentialException(message); + } + + String documentFullId = getFullIdFromShort(Document.class, documentId); + Document document = getDocumentDao().forTopiaIdEquals(documentFullId).findAny(); + + Pair<String, String> pathAndContentType = managerDocumentFile(uploadFile, owner); + String filePath = pathAndContentType.getLeft(); + String contentType = pathAndContentType.getRight(); + + document.setWithFile(true); + document.setMimeType(contentType); + document.setFilePath(filePath); + document.setFileName(uploadFile.getName()); + + commit(); + + } + + public Render getDocumentFile(String documentId) throws NoResultException { // reconstitute full id @@ -278,7 +330,7 @@ public class DocumentsWebService extends CoselmarWebServiceSupport { } File documentFile = new File(filePath); - String fileName = document.getName(); + String fileName = StringUtils.isNotBlank(document.getFileName()) ? document.getFileName() : document.getName(); String fileMimeType = document.getMimeType(); try { InputStream fileStream = new FileInputStream(documentFile); diff --git a/coselmar-rest/src/main/resources/mapping b/coselmar-rest/src/main/resources/mapping index 1a93585..fe0500d 100644 --- a/coselmar-rest/src/main/resources/mapping +++ b/coselmar-rest/src/main/resources/mapping @@ -36,7 +36,8 @@ GET /v1/documents/types DocumentsWebService.getTypes GET /v1/documents/{documentId} DocumentsWebService.getDocument GET /v1/documents/{documentId}/file DocumentsWebService.getDocumentFile POST /v1/documents DocumentsWebService.addDocument -PUT /v1/documents/{documentId} DocumentsWebService.saveDocument +POST /v1/documents/{documentId} DocumentsWebService.saveDocument +POST /v1/documents/{documentId}/file DocumentsWebService.addDocumentFile DELETE /v1/documents/{documentId} DocumentsWebService.deleteDocument # Users Api diff --git a/coselmar-ui/src/main/webapp/js/coselmar-controllers.js b/coselmar-ui/src/main/webapp/js/coselmar-controllers.js index aecc3cb..75c9906 100644 --- a/coselmar-ui/src/main/webapp/js/coselmar-controllers.js +++ b/coselmar-ui/src/main/webapp/js/coselmar-controllers.js @@ -127,15 +127,20 @@ coselmarControllers.controller("NewDocumentCtrl", ['$scope', '$location', 'docum // Call service to create a new document if (isValidForm) { - documentService.createDocument( - $scope.document, $scope.upload.file, function() { - $location.path("/documents"); + documentService.saveDocument($scope.document, function(document) { + if ($scope.upload.file) { + var documentId = document.id; + documentService.saveDocumentFile(documentId, $scope.upload.file, function() { + $location.path("/documents"); + }); + } else { + $location.path("/documents"); + } + }, function(error) { + console.log("error occurs"); + } + ); - },function(error) { - //TODO ymartel 20141118 : deal with error.status or statusText - console.log("error occurs"); - console.log(error.s); - }); } }; @@ -878,18 +883,19 @@ coselmarControllers.controller('ModalCreateDocumentsCtrl', function ($scope, $mo } if (isValidForm) { - if ($scope.upload.file) { - $scope.document.withFile = true; - } - documentService.createDocument( - $scope.document, $scope.upload.file, function(document) { - $modalInstance.close(document); - - },function(error) { - //TODO ymartel 20141118 : deal with error.status or statusText - console.log("error occurs"); - console.log(error.s); - }); + documentService.saveDocument($scope.document, function(document) { + if ($scope.upload.file) { + var documentId = document.id; + documentService.saveDocumentFile(documentId, $scope.upload.file, function() { + $modalInstance.close(document); + }); + } else { + $modalInstance.close(document); + } + }, function(error) { + console.log("error occurs"); + } + ); } }; diff --git a/coselmar-ui/src/main/webapp/js/coselmar-services.js b/coselmar-ui/src/main/webapp/js/coselmar-services.js index c205a04..e0cebeb 100644 --- a/coselmar-ui/src/main/webapp/js/coselmar-services.js +++ b/coselmar-ui/src/main/webapp/js/coselmar-services.js @@ -33,6 +33,43 @@ function Document(resource, config){ var baseURL = config.BASE_URL + "/documents"; + this.saveDocument = function(document, successFunction, failFunction) { + + var param = $.param({ 'document': JSON.stringify(document)}); + + var serviceURL = baseURL; + if (document.id) { + serviceURL = baseURL + "/" + document.id; + } + + // Save the document + var saveDocumentResource = resource(serviceURL, null, { + 'save': { method: 'POST'} + }); + + saveDocumentResource.save(null, param, successFunction, failFunction); + }; + + this.saveDocumentFile = function(documentId, file, successFunction, failFunction) { + + var formData = new FormData(); + if (file) { + formData.append("uploadFile", file); + } + + var serviceURL = baseURL + "/" + documentId + "/file"; + + // Save the document + var docResource = resource(serviceURL, null, { + 'upload': { + method:'POST', + transformRequest: angular.identity, + headers: {'Content-Type': undefined, 'Content-Transfer-Encoding': 'utf-8'} + } + }); + docResource.upload(null, formData, successFunction, failFunction); + }; + this.createDocument = function(metadata, file, successFunction, failFunction) { var formData = new FormData(); diff --git a/coselmar-ui/src/main/webapp/views/documents/document.html b/coselmar-ui/src/main/webapp/views/documents/document.html index 7eae60a..c6f382b 100644 --- a/coselmar-ui/src/main/webapp/views/documents/document.html +++ b/coselmar-ui/src/main/webapp/views/documents/document.html @@ -83,6 +83,10 @@ <td ng-if="document.withFile">{{document.mimeType}}</td> <td ng-if="!document.withFile">External Link</td> </tr> + <tr ng-if="document.withFile && document.fileName"> + <td>Document File</td> + <td>{{document.fileName}}</td> + </tr> <tr> <td>Comment</td> <td>{{document.comment}}</td> -- To stop receiving notification emails like this one, please contact codelutin.com SCM administrator <admin+scm@codelutin.com>.
This is an automated email from the git hooks/post-receive script. New commit to branch develop in repository coselmar. See http://git.codelutin.com/coselmar.git commit 924395d7384b36fa35eb4ea4f1e9043abdb17ae2 Merge: 993c889 ea8bffd Author: Yannick Martel <martel@©odelutin.com> Date: Fri Jan 16 12:49:37 2015 +0100 Fixes #6438 Merge branch 'feature/6438-improve-user-management' into develop .../src/main/xmi/coselmar-model.zargo | Bin 10322 -> 10390 bytes .../fr/ifremer/coselmar/beans/DocumentBean.java | 12 ++++- .../coselmar/converter/BeanEntityConverter.java | 3 +- .../coselmar/services/v1/DocumentsWebService.java | 54 ++++++++++++++++++++- coselmar-rest/src/main/resources/mapping | 3 +- coselmar-ui/src/main/webapp/index.html | 2 + .../src/main/webapp/js/coselmar-controllers.js | 50 ++++++++++--------- .../main/webapp/js/coselmar-questions-services.js | 14 ++---- .../src/main/webapp/js/coselmar-services.js | 45 +++++++++++++++-- .../src/main/webapp/js/coselmar-user-services.js | 13 ++--- coselmar-ui/src/main/webapp/js/coselmar.js | 3 ++ .../src/main/webapp/views/documents/document.html | 4 ++ coselmar-ui/src/main/webapp/views/users/user.html | 2 +- coselmar-ui/src/main/webapp/views/users/users.html | 2 +- 14 files changed, 156 insertions(+), 51 deletions(-) -- To stop receiving notification emails like this one, please contact codelutin.com SCM administrator <admin+scm@codelutin.com>.
participants (1)
-
codelutin.com scm