Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
D
daa-custom-stack
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
Felipe Vieira de Moraes Tavares
daa-custom-stack
Commits
aedaf069
Commit
aedaf069
authored
Feb 15, 2017
by
nemoNoboru
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
added modify name in frontend
parent
8e9a7be3
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
31 additions
and
7 deletions
+31
-7
index.js
backend/app/index.js
+5
-5
docker-compose.yml
backend/docker-compose.yml
+1
-1
people.js
frontend/app/core/people.js
+20
-0
index.html
frontend/app/index.html
+5
-1
No files found.
backend/app/index.js
View file @
aedaf069
...
@@ -18,7 +18,7 @@ var people_path = '/people'
...
@@ -18,7 +18,7 @@ var people_path = '/people'
function
end
(
res
,
err
)
{
function
end
(
res
,
err
)
{
if
(
err
)
{
if
(
err
)
{
re
turn
re
s
.
status
(
500
).
send
(
err
)
res
.
status
(
500
).
send
(
err
)
}
else
{
}
else
{
res
.
send
(
"ok"
)
res
.
send
(
"ok"
)
}
}
...
@@ -37,8 +37,8 @@ app.post(people_path,function (req,res) {
...
@@ -37,8 +37,8 @@ app.post(people_path,function (req,res) {
})
})
})
})
app
.
put
(
people_path
+
"/:person_id"
,
function
(
req
,
res
)
{
app
.
put
(
people_path
,
function
(
req
,
res
)
{
people
.
modify
(
req
.
params
.
person_id
,
req
.
body
.
name
,
function
(
err
)
{
people
.
modify
(
req
.
body
.
person_id
,
req
.
body
.
name
,
function
(
err
)
{
end
(
res
,
err
)
end
(
res
,
err
)
})
})
})
})
...
@@ -50,13 +50,13 @@ app.delete(people_path+"/:person_id",function (req,res) {
...
@@ -50,13 +50,13 @@ app.delete(people_path+"/:person_id",function (req,res) {
})
})
app
.
post
(
people_path
+
"/pets"
,
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
)
end
(
res
,
err
)
})
})
})
})
app
.
delete
(
people_path
+
"/pets"
,
function
(
req
,
res
)
{
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
)
end
(
res
,
err
)
})
})
})
})
...
...
backend/docker-compose.yml
View file @
aedaf069
db
:
db
:
image
:
mongo
image
:
mongo
ports
:
ports
:
-
"
2701
7
:27017"
-
"
2701
8
:27017"
command
:
"
--smallfiles
--logpath=/dev/null"
command
:
"
--smallfiles
--logpath=/dev/null"
web
:
web
:
build
:
.
build
:
.
...
...
frontend/app/core/people.js
View file @
aedaf069
...
@@ -10,10 +10,16 @@ app.service('people', function ($http) {
...
@@ -10,10 +10,16 @@ app.service('people', function ($http) {
this
.
add
=
function
(
n
,
callback
)
{
this
.
add
=
function
(
n
,
callback
)
{
$http
.
post
(
'http://127.0.0.1:8000/people'
,{
name
:
n
}).
then
(
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
)
{
app
.
controller
(
'peopleCtrl'
,
function
(
$scope
,
people
)
{
var
self
=
this
var
self
=
this
$scope
.
editing
=
false
this
.
load
=
function
()
{
this
.
load
=
function
()
{
people
.
index
(
function
(
people
)
{
people
.
index
(
function
(
people
)
{
...
@@ -34,4 +40,18 @@ app.controller('peopleCtrl',function ($scope,people) {
...
@@ -34,4 +40,18 @@ app.controller('peopleCtrl',function ($scope,people) {
$scope
.
name
=
''
$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
})
}
})
})
frontend/app/index.html
View file @
aedaf069
...
@@ -23,7 +23,11 @@
...
@@ -23,7 +23,11 @@
</div>
</div>
</div>
</div>
<hr/>
<hr/>
<div
class=
"box"
ng-repeat=
'i in people_list'
>
{{i.name }}
<div
class=
"box"
ng-repeat=
'i in people_list'
>
<span
ng-hide=
'editing'
>
{{i.name}}
</span>
<button
ng-hide=
'editing'
ng-click=
'edit(i.name)'
>
edit
</button>
<input
ng-show=
'editing'
class=
"text"
ng-model=
'e'
/>
<button
ng-click=
'save(i,e)'
ng-show=
'editing'
>
save
</button>
<section
class=
'align-right'
>
<section
class=
'align-right'
>
<button
class=
'align-right'
ng-click=
'remove(i)'
>
Trash
</button>
<button
class=
'align-right'
ng-click=
'remove(i)'
>
Trash
</button>
</section>
</section>
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment