Skip to content
This repository has been archived by the owner on Oct 3, 2019. It is now read-only.

Commit

Permalink
#37 implementando calculos para semana
Browse files Browse the repository at this point in the history
Signed-off-by: Ezequiel de Oliveira <ezequiel1de1oliveira@gmail.com>
Signed-off-by: Guilherme Deusdará <guibanci@gmail.com>

Co-Authored-by: Ezequiel de Oliveira <ezequiel1de1oliveira@gmail.com>
Co-Authored-by: Guilherme Deusdará <guibanci@gmail.com>
  • Loading branch information
EzequielDeOliveira and gdeusdara committed May 11, 2018
1 parent 77e6085 commit d8abfce
Show file tree
Hide file tree
Showing 3 changed files with 43 additions and 6 deletions.
40 changes: 36 additions & 4 deletions Schedule/Client/api.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
module.exports = function api(options) {
currentWeekNumber = require('current-week-number');

this.add('role:api,path:create', function (msg, respond) {

Expand Down Expand Up @@ -65,14 +66,45 @@ module.exports = function api(options) {
var id = msg.args.query.id;
this.act('role:schedule,cmd:listYear', {
year: year,
id: id
id: id
}, respond)
});

this.add('role:api,path:listWeek', function (msg, respond) {
var currentDate = new Date();
var year = msg.args.query.year;
var day = msg.args.query.day;
var month = msg.args.query.month;
var week = msg.args.query.week;
console.log(week);
if(year == undefined){
year = currentDate.getFullYear();
}else {
currentDate.setFullYear(year);
}
if(day == undefined){
day = currentDate.getDate() - 1;
}else {
currentDate.setDate(day);
}
if(month == undefined){
month = currentDate.getMonth() + 1;
}else{
currentDate.setMonth(month);
}
if(week == undefined){

var week = currentWeekNumber(currentDate);

week = JSON.stringify(week);

}

var id = msg.args.query.id;
console.log(week)

console.log(id);


this.act('role:schedule,cmd:listWeek', {
week: week,
id: id
Expand All @@ -93,11 +125,11 @@ module.exports = function api(options) {
pin: 'role:api,path:*',
map: {
create: { POST: true,
auth: {
/* auth: {
strategy: 'jwt',
fail: '/api/schedule/error'
}
},
*/ },
listDay: { GET: true,
auth: {
strategy: 'jwt',
Expand Down
1 change: 1 addition & 0 deletions Schedule/Client/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
"dependencies": {
"bcrypt": "^2.0.1",
"body-parser": "1.15.2",
"current-week-number": "^1.0.7",
"express": "^4.14.0",
"jsonwebtoken": "^8.2.0",
"mongoose": "^4.6.1",
Expand Down
8 changes: 6 additions & 2 deletions Schedule/Server/schedule.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ seneca()
schedule.year = JSON.stringify(schedule.year);
schedule.day = date.getDate()
schedule.day = JSON.stringify(schedule.day);
schedule.month = date.getMonth()
schedule.month = date.getMonth()+1
schedule.month = JSON.stringify(schedule.month);
schedule.week = currentWeekNumber(date);
schedule.week = JSON.stringify(schedule.week);
Expand Down Expand Up @@ -80,9 +80,13 @@ seneca()
.add('role:schedule,cmd:listWeek',function(msg,respond){
var id = msg.id;
var week = msg.week;
console.log(week , id);
console.log(id);
console.log(week);
var schedule = this.make('schedule');
schedule.list$({week , id}, function(error,schedule){
schedule.list$({id , week}, function(error,schedule){
respond(null,schedule);
console.log(schedule);
});
})

Expand Down

0 comments on commit d8abfce

Please sign in to comment.