diff --git a/backend/app/index.js b/backend/app/index.js index 39998fc9ba8ca224e3cc689cf693726bdfd472a2..2e924b5d8b21eb8f3dfa8b1051091820d5dc42a7 100644 --- a/backend/app/index.js +++ b/backend/app/index.js @@ -18,7 +18,7 @@ var people_path = '/people' function end(res,err) { if (err) { - return res.status(500).send(err) + res.status(500).send(err) }else{ res.send("ok") } @@ -37,8 +37,8 @@ app.post(people_path,function (req,res) { }) }) -app.put(people_path+"/:person_id",function (req,res) { - people.modify(req.params.person_id,req.body.name, function (err) { +app.put(people_path,function (req,res) { + people.modify(req.body.person_id,req.body.name, function (err) { end(res,err) }) }) @@ -50,13 +50,13 @@ app.delete(people_path+"/:person_id",function (req,res) { }) app.post(people_path+"/pets",function (req,res) { - people.addPet(req.body.id,req.body.petname, function (err) { + people.addPet(req.body.person_id,req.body.petname, function (err) { end(res,err) }) }) app.delete(people_path+"/pets",function (req,res) { - people.removePet(req.body.id,req.body.petname, function (err) { + people.removePet(req.body.person_id,req.body.petname, function (err) { end(res,err) }) }) diff --git a/backend/docker-compose.yml b/backend/docker-compose.yml index 8d0d189fcb2f54a948683cc6ffe6bcec17673def..16d29714e5faad8fc8a80d405a6a9acc77598d8d 100644 --- a/backend/docker-compose.yml +++ b/backend/docker-compose.yml @@ -1,7 +1,7 @@ db: image: mongo ports: - - "27017:27017" + - "27018:27017" command: "--smallfiles --logpath=/dev/null" web: build: . diff --git a/frontend/app/core/people.js b/frontend/app/core/people.js index f4262df623698b20ee2d88dfe56eee805a22f703..030cfa8c403bcbf01d29e92c1c31cda6b6e3255a 100644 --- a/frontend/app/core/people.js +++ b/frontend/app/core/people.js @@ -10,10 +10,16 @@ app.service('people', function ($http) { this.add = function (n,callback) { $http.post('http://127.0.0.1:8000/people',{name:n}).then(callback) } + + this.modify = function (item,callback) { + $http.put('http://127.0.0.1:8000/people',{person_id: item._id, name: item.name}) + .then(callback) + } }) app.controller('peopleCtrl',function ($scope,people) { var self = this + $scope.editing = false this.load = function () { people.index(function (people) { @@ -34,4 +40,18 @@ app.controller('peopleCtrl',function ($scope,people) { $scope.name = '' } + $scope.edit = function (name) { + $scope.editing = true; + $scope.e = name + } + + $scope.save = function (item,e) { + item.name = e + console.log(e) + people.modify(item,function (err) { + self.load() + $scope.editing = false + }) + } + }) diff --git a/frontend/app/index.html b/frontend/app/index.html index 1cf35f2484fedeb6cc574a29b0643ca04b9ffe9e..95cbd3c946db0c121dfc18cca0730e3f8a585253 100644 --- a/frontend/app/index.html +++ b/frontend/app/index.html @@ -23,7 +23,11 @@