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
f83bb449
Commit
f83bb449
authored
May 15, 2020
by
Geovanny
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
House request system done
parent
5356bdd6
Show whitespace changes
Inline
Side-by-side
Showing
12 changed files
with
168 additions
and
23 deletions
+168
-23
route.js
server/house/route.js
+14
-0
controller.js
web/houses/controller.js
+39
-2
index.html
web/houses/index.html
+2
-2
sync.js
web/houses/sync.js
+32
-1
view.js
web/houses/view.js
+17
-3
sync.js
web/myunits/sync.js
+9
-0
house.scss
web/sass/house.scss
+17
-2
house.css
web/stylesheets/house.css
+13
-1
house.css.map
web/stylesheets/house.css.map
+1
-1
main.css
web/stylesheets/main.css
+13
-1
main.css.map
web/stylesheets/main.css.map
+1
-1
table_view.js
web/views/table_view.js
+10
-9
No files found.
server/house/route.js
View file @
f83bb449
...
...
@@ -38,6 +38,20 @@ router.get('/all', async (context, next) => {
}
});
authRouter
.
get
(
'/has-house'
,
async
(
context
,
next
)
=>
{
try
{
if
(
context
.
user
.
house_id
){
context
.
response
.
body
=
true
;
}
else
{
context
.
response
.
body
=
false
;
}
context
.
response
.
status
=
200
;
}
catch
(
error
){
console
.
log
(
error
);
context
.
throw
(
400
,
'ERROR'
);
}
})
authRouter
.
post
(
'/request'
,
async
(
context
,
next
)
=>
{
if
(
context
.
user
.
house_id
){
context
.
throw
(
400
,
'Already in a house'
)
...
...
web/houses/controller.js
View file @
f83bb449
...
...
@@ -6,17 +6,54 @@ class HousesController{
this
.
view
=
view
;
this
.
sync
=
new
Sync
();
this
.
houses
=
[];
this
.
selectedIndex
=
undefined
;
this
.
getHouses
();
this
.
view
.
addEventListener
(
"house_select"
,
(
event
)
=>
this
.
selectedIndex
=
event
.
detail
);
this
.
view
.
addEventListener
(
"request_attemp"
,
()
=>
this
.
attempRequest
());
this
.
checkHouse
();
setInterval
(
async
()
=>
this
.
checkHouse
(),
5000
)
}
async
attempRequest
(){
if
(
this
.
selectedIndex
===
undefined
){
alert
(
"No house selected"
);
return
;
}
try
{
await
this
.
sync
.
requestHouse
(
this
.
houses
[
this
.
selectedIndex
].
id
);
alert
(
'Attemp Successfully Sent'
);
}
catch
(
error
){
console
.
log
(
error
);
alert
(
"Attemp failed"
);
}
}
async
checkHouse
(){
try
{
const
has_house
=
await
this
.
sync
.
hasHouse
();
if
(
has_house
){
this
.
view
.
hideJoin
();
}
else
{
this
.
view
.
showJoin
();
}
}
catch
(
error
){
console
.
log
(
error
);
}
}
async
getHouses
(){
this
.
houses
=
[];
try
{
const
houses
=
await
this
.
sync
.
getHouses
();
this
.
view
.
drawTable
(
houses
);
this
.
houses
=
await
this
.
sync
.
getHouses
();
}
catch
(
error
){
console
.
log
(
error
);
alert
(
'Failed to retrieve houses'
);
}
this
.
view
.
drawTable
(
this
.
houses
);
}
}
...
...
web/houses/index.html
View file @
f83bb449
...
...
@@ -16,8 +16,8 @@
<script
src=
"/navbar/navbar.js"
></script>
<content-body>
<table-wrapper
class=
"house_table"
>
<div
class=
"tab"
>
<button
class=
"
join_house"
>
Join House
</button>
<div
class=
"tab"
style=
"display:none"
>
<button
class=
"
request_house"
>
Send House Request
</button>
</div>
<table
id=
"data_table"
class=
"display"
></table>
</table-wrapper>
...
...
web/houses/sync.js
View file @
f83bb449
...
...
@@ -3,10 +3,41 @@ class Sync{
async
getHouses
(){
const
houses_response
=
await
fetch
(
'/api/house/all'
);
if
(
!
houses_response
.
ok
){
throw
Error
(
'Failed to get units'
)
}
const
houses
=
await
houses_response
.
json
();
return
houses
;
}
async
hasHouse
(){
const
response
=
await
fetch
(
'/api/house/has-house'
);
if
(
response
.
status
===
401
){
return
false
;
}
if
(
!
response
.
ok
){
throw
Error
(
'Failed to get units'
)
}
const
has_house
=
await
response
.
json
();
return
has_house
;
}
async
requestHouse
(
house_id
){
const
response
=
await
fetch
(
'/api/house/request'
,
{
method
:
"POST"
,
body
:
JSON
.
stringify
({
house_id
:
house_id
}),
headers
:
{
'Content-Type'
:
'application/json'
}
});
if
(
!
response
.
ok
){
throw
Error
(
'Failed to Send Request'
)
}
}
}
export
default
Sync
;
\ No newline at end of file
web/houses/view.js
View file @
f83bb449
...
...
@@ -13,9 +13,23 @@ class HousesView extends EventTarget{
constructor
(){
super
();
this
.
join
_tab
=
document
.
querySelector
(
'.tab'
);
this
.
join_button
=
this
.
join_tab
.
querySelector
(
'.join_button
'
);
this
.
request
_tab
=
document
.
querySelector
(
'.tab'
);
this
.
request_button
=
this
.
request_tab
.
querySelector
(
'.request_house
'
);
this
.
houses_table_view
=
new
TableView
(
$
(
'table-wrapper'
),
house_columns
);
this
.
houses_table_view
.
addEventListener
(
"row_click"
,
(
event
)
=>
{
this
.
dispatchEvent
(
new
CustomEvent
(
"house_select"
,
{
detail
:
event
.
detail
}));
});
this
.
request_button
.
addEventListener
(
"click"
,
(
event
)
=>
{
this
.
dispatchEvent
(
new
CustomEvent
(
"request_attemp"
));
});
}
hideJoin
(){
this
.
request_tab
.
style
.
display
=
"none"
;
}
showJoin
(){
this
.
request_tab
.
style
.
display
=
""
;
}
drawTable
(
data
){
...
...
web/myunits/sync.js
View file @
f83bb449
...
...
@@ -28,6 +28,9 @@ class Sync{
'Content-Type'
:
'application/json'
}
});
if
(
!
response
.
ok
){
throw
Error
(
'Failed to get units'
)
}
}
async
modifyUnit
(
data
){
...
...
@@ -38,12 +41,18 @@ class Sync{
'Content-Type'
:
'application/json'
}
});
if
(
!
response
.
ok
){
throw
Error
(
'Failed to get units'
)
}
}
async
deleteUnit
(
id
){
const
response
=
await
fetch
(
`/api/user/unit/
${
id
}
`
,
{
method
:
"DELETE"
,
});
if
(
!
response
.
ok
){
throw
Error
(
'Failed to get units'
)
}
}
}
...
...
web/sass/house.scss
View file @
f83bb449
...
...
@@ -6,7 +6,7 @@
max-width
:
1000px
;
margin-left
:
-500px
;
.
join
_house
{
.
request
_house
{
float
:
right
;
margin
:
5px
;
color
:
whitesmoke
;
...
...
@@ -14,4 +14,19 @@
background-color
:
grey
;
border-radius
:
3px
;
}
.dataTable
{
tr
.even.active
{
background-color
:
rgb
(
151
,
151
,
151
);
td
.sorting_1
{
background-color
:
rgb
(
151
,
151
,
151
);
}
}
tr
.odd.active
{
background-color
:
rgb
(
151
,
151
,
151
);
td
.sorting_1
{
background-color
:
rgb
(
151
,
151
,
151
);
}
}
}
}
web/stylesheets/house.css
View file @
f83bb449
...
...
@@ -6,7 +6,7 @@
max-width
:
1000px
;
margin-left
:
-500px
;
}
.house_table
.
join
_house
{
.house_table
.
request
_house
{
float
:
right
;
margin
:
5px
;
color
:
whitesmoke
;
...
...
@@ -14,5 +14,17 @@
background-color
:
grey
;
border-radius
:
3px
;
}
.house_table
.dataTable
tr
.even.active
{
background-color
:
#979797
;
}
.house_table
.dataTable
tr
.even.active
td
.sorting_1
{
background-color
:
#979797
;
}
.house_table
.dataTable
tr
.odd.active
{
background-color
:
#979797
;
}
.house_table
.dataTable
tr
.odd.active
td
.sorting_1
{
background-color
:
#979797
;
}
/*# sourceMappingURL=house.css.map */
web/stylesheets/house.css.map
View file @
f83bb449
{"version":3,"sourceRoot":"","sources":["../sass/house.scss"],"names":[],"mappings":"AAAA;EACI;EACA;EACA;EACA;EACA;EACA;;AAEA;EACI;EACA;EACA;EACA;EACA;EACA","file":"house.css"}
\ No newline at end of file
{"version":3,"sourceRoot":"","sources":["../sass/house.scss"],"names":[],"mappings":"AAAA;EACI;EACA;EACA;EACA;EACA;EACA;;AAEA;EACI;EACA;EACA;EACA;EACA;EACA;;AAGA;EACI;;AACA;EACI;;AAGR;EACI;;AACA;EACI","file":"house.css"}
\ No newline at end of file
web/stylesheets/main.css
View file @
f83bb449
...
...
@@ -360,7 +360,7 @@ unit-detail {
max-width
:
1000px
;
margin-left
:
-500px
;
}
.house_table
.
join
_house
{
.house_table
.
request
_house
{
float
:
right
;
margin
:
5px
;
color
:
whitesmoke
;
...
...
@@ -368,6 +368,18 @@ unit-detail {
background-color
:
grey
;
border-radius
:
3px
;
}
.house_table
.dataTable
tr
.even.active
{
background-color
:
#979797
;
}
.house_table
.dataTable
tr
.even.active
td
.sorting_1
{
background-color
:
#979797
;
}
.house_table
.dataTable
tr
.odd.active
{
background-color
:
#979797
;
}
.house_table
.dataTable
tr
.odd.active
td
.sorting_1
{
background-color
:
#979797
;
}
body
{
font-family
:
Roboto
;
...
...
web/stylesheets/main.css.map
View file @
f83bb449
{"version":3,"sourceRoot":"","sources":["../fontawesome/font_awesome.scss","../sass/navbar.scss","../sass/table.scss","../sass/login.scss","../sass/unit.scss","../sass/house.scss","../sass/main.scss"],"names":[],"mappings":"AAAA;EACI;EACA;EACA;EACA;EACA;;AAGF;EACE;EACA;EACA;EACA;EACA;;AAGF;EACE;EACA;EACA;EACA;EACA;;AAmBF;EACI;IAAK;;EACP;IAAO;;;AC1CX;EACI;EACA;EACA;EACA,eACI;EAGJ;EACA;;;AAGJ;EAEI;EACA;EACA;;AACA;EACI;EACA;EAEA;EACA;;;AAIR;EACI;EACA;;;AAGJ;EACI;EACA;EACA;EACA;EACA;EACA;;;AAGJ;EACI;EACA;EACA;EACA;EACA;EACA;;AACA;EACI;EACA;EACA;EACA;EACA;;;AAGR;EACI;;;AAGJ;EACI;EACA;EACA;EACA;EACA;EACA;EACA;;AACA;EACI;EACA;;AAEJ;EACI;;;AAKJ;EACI;;;AAIR;EACI;EACA;EACA;;AACA;EACI;EACA;;;AAIR;EACI;;;AAKA;EACI;;AAEJ;EACI;;;ACtGR;EACI;;;AAEJ;EACI;;AAEA;EACI;;;AAKR;EACI;;AACA;EACI;;;AAGR;EACI;;;AAGJ;EACI;EACA;EACA;;;AAIJ;EACI;EACA;EAEA,eACI;;;AClCR;EACI;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;;;AAGJ;EACI;EAEA;EACA;EACA;;AACA;EACI;EACA;;;AAIN;AACF;EACI;EAEA;EACA;EACA;EACA;EACA;;;AAGF;AACF;EACI;;;AAGF;AACF;EACI;;;AAGF;AACF;EACI;EACA;EACA;EACA;EACA;;;AAGJ;EACI;AAA0B;;;AAG9B;AACA;EACI;IAAM;;EACN;IAAI;;;AAGN;EACE;EACA;;AAEF;EACE;;AAEF;EACE;EACA;EACA;EACA;EACA;EACA;;AAEF;EACE;EACA;EACA;EACA;;;ACnFJ;EACI;EACA;EACA;;;AAGJ;EACI;EACA;;;AAGJ;EACI;EACA;;;AAEJ;EACI;EACA;EACA;;;AAGJ;EACI,eACI;EAGJ;EACA;;;AAGJ;EACI;EACA;EACA;EACA;EACA;EACA;;;AAIJ;EACI;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;;;AAGJ;EACI;EACA;EACA;EACA;;;AAEJ;EACI;EACA;EACA;;;AAEJ;EACI;EACA;;AACA;EACI;EACA;;;AAGR;EACI;;;AAEJ;EACI;;AACA;EACI;EACA;EACA;EACA;EACA;EACA;EACA;;;AAGR;EACI;EACA;;;AAEJ;EACI;EACA;;;AAEJ;EACI;EACA;;;ACnGJ;EACI;EACA;EACA;EACA;EACA;EACA;;AAEA;EACI;EACA;EACA;EACA;EACA;EACA;;;ACPR;EACI;EACA;EACA;EACA;EACA,eACI;;;AAKR;EACI;EACA;;;AAGJ;EACI;EACA;;AACA;EACI","file":"main.css"}
\ No newline at end of file
{"version":3,"sourceRoot":"","sources":["../fontawesome/font_awesome.scss","../sass/navbar.scss","../sass/table.scss","../sass/login.scss","../sass/unit.scss","../sass/house.scss","../sass/main.scss"],"names":[],"mappings":"AAAA;EACI;EACA;EACA;EACA;EACA;;AAGF;EACE;EACA;EACA;EACA;EACA;;AAGF;EACE;EACA;EACA;EACA;EACA;;AAmBF;EACI;IAAK;;EACP;IAAO;;;AC1CX;EACI;EACA;EACA;EACA,eACI;EAGJ;EACA;;;AAGJ;EAEI;EACA;EACA;;AACA;EACI;EACA;EAEA;EACA;;;AAIR;EACI;EACA;;;AAGJ;EACI;EACA;EACA;EACA;EACA;EACA;;;AAGJ;EACI;EACA;EACA;EACA;EACA;EACA;;AACA;EACI;EACA;EACA;EACA;EACA;;;AAGR;EACI;;;AAGJ;EACI;EACA;EACA;EACA;EACA;EACA;EACA;;AACA;EACI;EACA;;AAEJ;EACI;;;AAKJ;EACI;;;AAIR;EACI;EACA;EACA;;AACA;EACI;EACA;;;AAIR;EACI;;;AAKA;EACI;;AAEJ;EACI;;;ACtGR;EACI;;;AAEJ;EACI;;AAEA;EACI;;;AAKR;EACI;;AACA;EACI;;;AAGR;EACI;;;AAGJ;EACI;EACA;EACA;;;AAIJ;EACI;EACA;EAEA,eACI;;;AClCR;EACI;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;;;AAGJ;EACI;EAEA;EACA;EACA;;AACA;EACI;EACA;;;AAIN;AACF;EACI;EAEA;EACA;EACA;EACA;EACA;;;AAGF;AACF;EACI;;;AAGF;AACF;EACI;;;AAGF;AACF;EACI;EACA;EACA;EACA;EACA;;;AAGJ;EACI;AAA0B;;;AAG9B;AACA;EACI;IAAM;;EACN;IAAI;;;AAGN;EACE;EACA;;AAEF;EACE;;AAEF;EACE;EACA;EACA;EACA;EACA;EACA;;AAEF;EACE;EACA;EACA;EACA;;;ACnFJ;EACI;EACA;EACA;;;AAGJ;EACI;EACA;;;AAGJ;EACI;EACA;;;AAEJ;EACI;EACA;EACA;;;AAGJ;EACI,eACI;EAGJ;EACA;;;AAGJ;EACI;EACA;EACA;EACA;EACA;EACA;;;AAIJ;EACI;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;;;AAGJ;EACI;EACA;EACA;EACA;;;AAEJ;EACI;EACA;EACA;;;AAEJ;EACI;EACA;;AACA;EACI;EACA;;;AAGR;EACI;;;AAEJ;EACI;;AACA;EACI;EACA;EACA;EACA;EACA;EACA;EACA;;;AAGR;EACI;EACA;;;AAEJ;EACI;EACA;;;AAEJ;EACI;EACA;;;ACnGJ;EACI;EACA;EACA;EACA;EACA;EACA;;AAEA;EACI;EACA;EACA;EACA;EACA;EACA;;AAGA;EACI;;AACA;EACI;;AAGR;EACI;;AACA;EACI;;;ACnBhB;EACI;EACA;EACA;EACA;EACA,eACI;;;AAKR;EACI;EACA;;;AAGJ;EACI;EACA;;AACA;EACI","file":"main.css"}
\ No newline at end of file
web/views/table_view.js
View file @
f83bb449
...
...
@@ -4,29 +4,30 @@ class TableView extends EventTarget{
super
();
if
(
!
element
)
{
if
(
!
element
){
throw
Error
(
'No element passed'
);
}
if
(
!
columns
){
throw
Error
(
'Columns are needed'
);
}
this
.
element
=
element
;
this
.
$
element
=
element
;
this
.
columns
=
columns
;
this
.
table
=
element
.
find
(
'#data_table'
);
this
.
datatable
=
this
.
table
.
DataTable
({
this
.
$
table
=
element
.
find
(
'#data_table'
);
this
.
datatable
=
this
.
$
table
.
DataTable
({
columns
:
this
.
columns
});
if
(
overflow
){
this
.
$overflow_div
=
$
(
"<div></div>"
).
addClass
(
"overflow_table"
);
this
.
element
.
find
(
'#data_table_filter'
).
after
(
this
.
$overflow_div
);
this
.
table
.
detach
();
this
.
$overflow_div
.
append
(
this
.
table
);
this
.
$
element
.
find
(
'#data_table_filter'
).
after
(
this
.
$overflow_div
);
this
.
$
table
.
detach
();
this
.
$overflow_div
.
append
(
this
.
$
table
);
}
const
datatable
=
this
.
datatable
;
const
view
=
this
;
this
.
table
.
children
(
"#units_table
tbody"
).
on
(
"click"
,
"tr"
,
function
(){
this
.
$table
.
children
(
"
tbody"
).
on
(
"click"
,
"tr"
,
function
(){
const
index
=
datatable
.
row
(
this
).
index
();
view
.
$table
.
children
(
"tbody"
).
children
().
removeClass
(
"active"
);
$
(
datatable
.
row
(
this
).
node
()).
addClass
(
"active"
);
view
.
dispatchEvent
(
new
CustomEvent
(
"row_click"
,
{
detail
:
index
}));
})
}
...
...
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