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 855a592a..43465188 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 @@ -38,11 +38,10 @@ public class ResourcesRestController { public SimpleResource newResource(@RequestParam final String name, @RequestParam final String type, @RequestParam(required = false, defaultValue = "") final String description, - @RequestParam(required = false, defaultValue = MediaType.APPLICATION_XML_VALUE) final String ctype, @RequestParam final String content) throws InformationServiceException { - return service.saveNewResource(name, type, description, ctype, content); + return service.saveNewResource(name, type, description, content); } @DeleteMapping("/{id}") diff --git a/apps/dnet-is-application/src/main/java/eu/dnetlib/is/resources/SimpleResourceService.java b/apps/dnet-is-application/src/main/java/eu/dnetlib/is/resources/SimpleResourceService.java index 4ae07260..87154c0d 100644 --- a/apps/dnet-is-application/src/main/java/eu/dnetlib/is/resources/SimpleResourceService.java +++ b/apps/dnet-is-application/src/main/java/eu/dnetlib/is/resources/SimpleResourceService.java @@ -54,7 +54,6 @@ public class SimpleResourceService { public SimpleResource saveNewResource(final String name, final String type, final String description, - final String ctype, final String content) { final Date now = new Date(); 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 3b6edf5b..fccd6a54 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 @@ -14,32 +14,43 @@ app.controller('resourcesController', function($scope, $http) { }); }; - $scope.prepareNewRes = function() { + $scope.prepareNewResource = function() { $scope.tmpRes = { - 'id' : '', 'name' : '', - 'description' : '' + 'description' : '', + 'content' : '' }; } - - $scope.prepareEditMetadata = function(res) { - $scope.tmpRes = angular.copy(res); + + $scope.prepareEditMetadata = function(r) { + $scope.tmpRes = angular.copy(r); } - $scope.prepareEditContent = function(res) { - $scope.tmpRes = angular.copy(res); + $scope.prepareEditContent = function(r) { + $scope.tmpRes = angular.copy(r); $scope.tmpContent = "loading..."; - $http.get('./api/resources/' + res.id + '/content?' + $.now()).then(function successCallback(res) { - $scope.tmpContent = res.data; - }, function errorCallback(res) { + $http.get('./api/resources/' + r.id + '/content?' + $.now()).then(function successCallback(res) { + $scope.tmpContent = res.data; + }, function errorCallback(res) { alert('ERROR: ' + res.data.message); }); } - - $scope.prepareUploadContent = function(res) { - $scope.tmpRes = angular.copy(res); + + $scope.createNewResource = function(r) { + $http.defaults.headers.post["Content-Type"] = "application/x-www-form-urlencoded; charset=UTF-8"; + $http.post('./api/resources/?' + $.now(), $.param({ + 'name' : r.name, + 'type' : $scope.type, + 'description' : r.description, + 'content' : r.content + })).then(function successCallback(res) { + alert("Resource saved"); + $scope.reload(); + }, function errorCallback(res) { + alert('ERROR: ' + res.data.message); + }); } - + $scope.saveMetadata = function(id, md) { $http.defaults.headers.post["Content-Type"] = "application/json;charset=UTF-8"; $http.post('./api/resources/' + id + '/metadata?' + $.now(), md).then(function successCallback(res) { @@ -61,12 +72,6 @@ app.controller('resourcesController', function($scope, $http) { }); }; - - $scope.uploadContent = function(id, content) { - // TODO - }; - - $scope.deleteResource = function(r) { if (confirm("Are you sure ?")) { $http.delete('./api/resources/' + encodeURIComponent(r.id) + '?' + $.now()).then(function successCallback(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 fff58275..d48394b0 100644 --- a/apps/dnet-is-application/src/main/resources/templates/simpleResources.html +++ b/apps/dnet-is-application/src/main/resources/templates/simpleResources.html @@ -14,8 +14,11 @@
-
+
+

+ +

@@ -35,7 +38,7 @@

- raw content + raw content
@@ -50,8 +53,7 @@
+ +