diff --git a/apps/dnet-is-application/src/main/java/eu/dnetlib/is/resources/ResourcesRestController.java b/apps/dnet-is-application/src/main/java/eu/dnetlib/is/resources/ResourcesRestController.java index 1afef4a9..73672851 100644 --- a/apps/dnet-is-application/src/main/java/eu/dnetlib/is/resources/ResourcesRestController.java +++ b/apps/dnet-is-application/src/main/java/eu/dnetlib/is/resources/ResourcesRestController.java @@ -8,7 +8,10 @@ import javax.servlet.http.HttpServletRequest; import org.apache.commons.io.IOUtils; import org.apache.commons.lang3.StringUtils; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.web.bind.annotation.DeleteMapping; import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.PathVariable; import org.springframework.web.bind.annotation.PostMapping; @@ -29,6 +32,15 @@ public class ResourcesRestController { @Autowired private SimpleResourceRepository simpleResourceRepository; + private static final Log log = LogFactory.getLog(ResourcesRestController.class); + + @DeleteMapping("/{type}/{id}") + public List deleteResources(@PathVariable final String type, @PathVariable final String id) { + log.info("Deleting rewsource: " + id); + simpleResourceRepository.deleteById(id); + return listResources(type); + } + @GetMapping("/{type}") public List listResources(@PathVariable final String type) { return simpleResourceRepository.findByType(type) diff --git a/apps/dnet-is-application/src/main/resources/static/js/simpleResources.js b/apps/dnet-is-application/src/main/resources/static/js/simpleResources.js index 9b14013c..d71697fa 100644 --- a/apps/dnet-is-application/src/main/resources/static/js/simpleResources.js +++ b/apps/dnet-is-application/src/main/resources/static/js/simpleResources.js @@ -51,9 +51,9 @@ app.controller('resourcesController', function($scope, $http) { }); }; - $scope.deleteResource = function(id) { + $scope.deleteResource = function(r) { if (confirm("Are you sure ?")) { - $http.delete('./api/resources/' + encodeURIComponent(id) + '?' + $.now()).then(function successCallback(res) { + $http.delete('./api/resources/' + encodeURIComponent(r.type) + '/' + encodeURIComponent(r.id) + '?' + $.now()).then(function successCallback(res) { $scope.resources = res.data; alert("Resource deleted"); }, function errorCallback(res) { diff --git a/apps/dnet-is-application/src/main/resources/templates/simpleResources.html b/apps/dnet-is-application/src/main/resources/templates/simpleResources.html index 51399b19..949866b1 100644 --- a/apps/dnet-is-application/src/main/resources/templates/simpleResources.html +++ b/apps/dnet-is-application/src/main/resources/templates/simpleResources.html @@ -22,30 +22,22 @@

Number of resources: {{(resources | filter:resFilter).length}}

- - - - - - - - - - - - - - - - - - - - -
IDNameDescription
no resources
{{r.id}}{{r.name}}{{r.description}} - - -
+ +
+
+ {{r.contentType}} +
{{r.name}}
+

{{r.description}}

+

+ Id: {{r.id}}
+ Creation date: {{r.creationDate}}
+ Modification date: {{r.modificationDate}} +

+ + +
+
+ @@ -69,7 +61,7 @@
- +