Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
C
cbdiscord
Project
Project
Details
Activity
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
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Geovanny E. Vera Pazmino
cbdiscord
Commits
6e88953c
Commit
6e88953c
authored
May 16, 2020
by
Geovanny
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Participation on the front end done
parent
8ebe56c2
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
68 additions
and
3 deletions
+68
-3
model.js
server/house/model.js
+11
-0
route.js
server/house/route.js
+12
-0
controller.js
web/myhouse/controller.js
+18
-1
member_units_view.js
web/myhouse/member_units_view.js
+0
-1
participation_view.js
web/myhouse/participation_view.js
+1
-1
sync.js
web/myhouse/sync.js
+22
-0
view.js
web/myhouse/view.js
+4
-0
No files found.
server/house/model.js
View file @
6e88953c
...
...
@@ -210,4 +210,15 @@ model.warParticipation = async (user_id, house_id, decision) => {
await
db
.
con
.
query
(
'COMMIT;'
);
}
model
.
getParticipation
=
async
(
house_id
)
=>
{
const
sql_text
=
`SELECT u.username, uw.decision
FROM users as u
LEFT JOIN users_war as uw ON uw.user_id = u.id
LEFT JOIN war_days as w ON w.id = uw.war_id
WHERE uw.house_id = ? AND w.completed = 0;`
;
const
data
=
await
db
.
con
.
query
(
sql_text
,
[
house_id
]);
return
data
;
}
module
.
exports
=
model
;
\ No newline at end of file
server/house/route.js
View file @
6e88953c
...
...
@@ -315,6 +315,18 @@ authRouter.delete('/:house_id', async (context, next) => {
}
});
authRouter
.
get
(
'/participation'
,
async
(
context
,
next
)
=>
{
hasHouse
(
context
);
try
{
const
data
=
await
houseModel
.
getParticipation
(
context
.
user
.
house_id
);
context
.
response
.
status
=
200
;
context
.
response
.
body
=
data
;
}
catch
(
error
){
console
.
log
(
error
);
context
.
throw
(
'Failed to get Participation'
);
}
});
authRouter
.
post
(
'/participation'
,
async
(
context
,
next
)
=>
{
hasHouse
(
context
);
const
body
=
context
.
request
.
body
;
...
...
web/myhouse/controller.js
View file @
6e88953c
...
...
@@ -45,6 +45,7 @@ class MyHouseController{
}
async
refresh
(){
this
.
getParticipation
();
this
.
getMembers
();
this
.
getPermissionLevel
();
this
.
getRequests
();
...
...
@@ -108,7 +109,23 @@ class MyHouseController{
}
async
attempParticipate
(
decision
){
console
.
log
(
decision
)
try
{
await
this
.
sync
.
updateParticipation
(
decision
);
alert
(
'Update Successfull'
);
this
.
refresh
();
}
catch
(
error
){
console
.
log
(
error
);
alert
(
'Failed to Update Participaation'
);
}
}
async
getParticipation
(){
try
{
const
data
=
await
this
.
sync
.
getParticipation
();
this
.
view
.
drawParticipationTable
(
data
);
}
catch
(
error
){
console
.
log
(
error
);
}
}
async
getPermissionLevel
(){
...
...
web/myhouse/member_units_view.js
View file @
6e88953c
...
...
@@ -18,7 +18,6 @@ class MemberUnitsView extends EventTarget{
}
drawTable
(
data
){
console
.
log
(
data
)
this
.
table_view
.
drawTable
(
data
);
}
...
...
web/myhouse/participation_view.js
View file @
6e88953c
...
...
@@ -28,7 +28,7 @@ class ParticipationView extends EventTarget{
}
drawTable
(
data
){
this
.
table_view
(
data
);
this
.
table_view
.
drawTable
(
data
);
}
}
...
...
web/myhouse/sync.js
View file @
6e88953c
...
...
@@ -85,9 +85,31 @@ class Sync{
}
const
data
=
await
response
.
json
();
return
data
;
}
async
getParticipation
(){
const
response
=
await
fetch
(
'/api/house/participation'
);
if
(
!
response
.
ok
){
throw
Error
(
'Failed to get participations'
);
}
const
data
=
await
response
.
json
();
return
data
;
}
async
updateParticipation
(
decision
){
const
response
=
await
fetch
(
'/api/house/participation'
,{
method
:
"POST"
,
body
:
JSON
.
stringify
({
decision
:
decision
}),
headers
:
{
'Content-Type'
:
'application/json'
}
});
if
(
!
response
.
ok
){
throw
Error
(
'Failed to Update Participation'
);
}
}
}
export
default
Sync
;
\ No newline at end of file
web/myhouse/view.js
View file @
6e88953c
...
...
@@ -37,6 +37,10 @@ class MyHouseController extends EventTarget{
});
}
drawParticipationTable
(
data
){
this
.
participation_view
.
drawTable
(
data
);
}
drawMemberUnitsTable
(
data
){
this
.
member_units_view
.
drawTable
(
data
);
}
...
...
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