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

Commit

Permalink
Signed-off-by: Guilherme Deusdará <guibanci@gmail.com>
Browse files Browse the repository at this point in the history
Signed-off-by: Felipe Campos <fepascampos@gmail.com>

Co-authored-by: Guilherme Deusdará <guibanci@gmail.com>
Co-authored-by: Felipe Campos <fepascampos@gmail.com>
  • Loading branch information
gdeusdara and Felipe Campos committed May 15, 2018
1 parent edde308 commit cab37b0
Show file tree
Hide file tree
Showing 16 changed files with 168 additions and 227 deletions.
2 changes: 1 addition & 1 deletion Schedule/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -57,4 +57,4 @@ coverage/

*/fastlane/report.xml
*/fastlane/Preview.html
*/fastlane/screenshots
*/fastlane/screenshots
File renamed without changes.
2 changes: 1 addition & 1 deletion Schedule/Client/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,4 @@ RUN npm install -g
EXPOSE 8080


CMD ["npm", "start"]
CMD ["npm", "start"]
File renamed without changes.
143 changes: 113 additions & 30 deletions Schedule/Client/api.js
Original file line number Diff line number Diff line change
Expand Up @@ -115,46 +115,106 @@ module.exports = function api(options) {
});

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

var week = currentWeekNumber(currentDate);

week = JSON.stringify(week);

}

var id = msg.args.query.id;

console.log(id);


this.act('role:schedule,cmd:listWeek', {
week: week,
id: id
}, respond)
});

this.add('role:api,path:listSectorDay', function (msg, respond) {
var day = msg.args.query.day;
var sector = msg.args.query.sector;
this.act('role:schedule,cmd:listSectorDay', {
day: day,
sector: sector
}, respond)
});

this.add('role:api,path:listSectorMonth', function (msg, respond) {
var month = msg.args.query.month;
var sector = msg.args.query.sector;
this.act('role:schedule,cmd:listSectorMonth', {
month: month,
sector: sector
}, respond)
});

this.add('role:api,path:listSectorYear', function (msg, respond) {
var year = msg.args.query.year;
var sector = msg.args.query.sector;
this.act('role:schedule,cmd:listSectorYear', {
year: year,
sector: sector
}, respond)
});

this.add('role:api,path:listSectorWeek', 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) {
if(year == undefined){
year = currentDate.getFullYear();
} else {
}else {
currentDate.setFullYear(year);
}
if (month == undefined) {
month = currentDate.getMonth() + 1;
} else {
currentDate.setMonth(month);
}
if (day == undefined) {
if(day == undefined){
day = currentDate.getDate() - 1;
} else {
}else {
currentDate.setDate(day);
}
if (week == undefined) {
if(month == undefined){
month = currentDate.getMonth() + 1;
}else{
currentDate.setMonth(month);
}
if(week == undefined){

var week = currentWeekNumber(currentDate);
var week = currentWeekNumber(currentDate);

week = JSON.stringify(week);
week = JSON.stringify(week);

}

var id = msg.args.query.id;
var sector = msg.args.query.sector;

console.log(id);
console.log(sector);


this.act('role:schedule,cmd:listWeek', {
this.act('role:schedule,cmd:listSectorWeek', {
week: week,
id: id
}, respond)
});

sector: sector
}, respond)
});

this.add('role:api,path:listHourWeek', function (msg, respond) {
var currentDate = new Date();
Expand Down Expand Up @@ -257,17 +317,40 @@ module.exports = function api(options) {
fail: '/api/schedule/error'
}
},
error: { GET: true }
error: { GET: true },

listSectorDay: { GET: true,
auth: {
strategy: 'jwt',
fail: '/api/schedule/error'
}
},
listSchedule: { GET: true,
auth: {
strategy: 'jwt',
fail: '/api/schedule/error'
}
},
listSectorMonth: { GET: true,
auth: {
strategy: 'jwt',
fail: '/api/schedule/error'
}
},
listSectorYear: { GET: true,
auth: {
strategy: 'jwt',
fail: '/api/schedule/error'
}
},
listSectorWeek: { GET: true,
auth: {
strategy: 'jwt',
fail: '/api/schedule/error'

},
error: {GET: true }
}
}
}, respond)
})









1 change: 0 additions & 1 deletion Schedule/Client/client_schedule.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
var express = require('express');

var bodyParser = require('body-parser')
var seneca = require('seneca');
var senecaWeb = require('seneca-web');
Expand Down
15 changes: 8 additions & 7 deletions Schedule/Client/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,33 +2,34 @@
"name": "node-app",
"version": "1.0.0",
"description": "",
"main": "client_schedule.js",
"main": "client_sector.js",
"scripts": {
"start": "nodemon client_schedule.js",
"test": "./node_modules/.bin/mocha --reporter spec"
"start": "nodemon client_sector.js",
"test": "mocha"
},
"author": "",
"license": "MIT",
"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",
"morgan": "^1.9.0",
"nodemon": "^1.10.2",
"seneca": "^3.4.3",
"seneca-amqp-transport": "^2.2.0",
"seneca-entity": "^2.0.2",
"seneca-mongo-store": "^1.1.0"
"seneca-mongo-store": "^1.1.0",
"seneca-web": "^2.2.0",
"seneca-web-adapter-express": "^1.1.1"
},
"devDependencies": {
"assert": "^1.4.1",
"express": "^4.16.3",
"express-session": "^1.15.6",
"istanbul": "^0.4.5",
"jest": "^22.4.3",
"jsonwebtoken": "^8.2.1",
"mocha": "^5.0.5",
"passport": "^0.4.0",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,33 +2,28 @@
"name": "node-app",
"version": "1.0.0",
"description": "",
"main": "client_scheduleSector.js",
"main": "client_schedule.js",
"scripts": {
"start": "nodemon client_scheduleSector.js",
"start": "nodemon client_schedule.js",
"test": "./node_modules/.bin/mocha --reporter spec"
},
"author": "",
"license": "MIT",
"dependencies": {
"bcrypt": "^1.0.3",
"body-parser": "1.15.2",
"express": "^4.14.0",
"jsonwebtoken": "^8.2.0",
"mongoose": "^4.6.1",
"morgan": "^1.9.0",
"nodemon": "^1.10.2",
"seneca": "^3.4.3",
"seneca-amqp-transport": "^2.2.0",
"seneca-entity": "^2.0.2",
"seneca-mongo-store": "^1.1.0",
"seneca-web": "^2.2.0",
"seneca-web-adapter-express": "^1.1.1"
"seneca-mongo-store": "^1.1.0"
},
"devDependencies": {
"assert": "^1.4.1",
"express": "^4.16.3",
"express-session": "^1.15.6",
"istanbul": "^0.4.5",
"jest": "^22.4.3",
"jsonwebtoken": "^8.2.1",
"mocha": "^5.0.5",
"passport": "^0.4.0",
Expand Down
3 changes: 2 additions & 1 deletion Schedule/Server/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@

FROM node:latest

RUN mkdir -p /usr/src/app
Expand All @@ -10,4 +11,4 @@ RUN npm install -g
EXPOSE 8080


CMD ["npm", "start"]
CMD ["npm", "start"]
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,7 @@
"description": "",
"main": "app.js",
"scripts": {
"start": "nodemon scheduleSector.js",
"test": "./node_modules/.bin/mocha --reporter spec"
"start": "nodemon schedule.js"
},
"author": "",
"license": "MIT",
Expand Down
40 changes: 38 additions & 2 deletions Schedule/Server/schedule.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@


var seneca = require('seneca');
var currentWeekNumber = require('current-week-number');

Expand Down Expand Up @@ -88,6 +86,14 @@ seneca()
var month = msg.month;
var schedule = this.make('schedule');
schedule.list$({ month, id }, function (error, schedule) {
respond(null, schedule);
});
})
.add('role:schedule,cmd:listSectorDay', function (msg, respond) {
var sector = msg.sector;
var day = msg.day;
var schedule = this.make('schedule');
schedule.list$({ day , sector }, function (error, schedule) {
respond(null, schedule);
});
})
Expand Down Expand Up @@ -133,3 +139,33 @@ seneca()
respond(null, { success: false, message: 'acesso negado' });
})

.add('role:schedule,cmd:listSectorMonth', function (msg, respond) {
var sector = msg.sector;
var month = msg.month;
var schedule = this.make('schedule');
schedule.list$({ month , sector }, function (error, schedule) {
respond(null, schedule);
});
})

.add('role:schedule,cmd:listSectorYear',function(msg,respond){
var sector = msg.sector;
var year = msg.year;
var schedule = this.make('schedule');
schedule.list$({year , sector},function(error,schedule){
respond(null,schedule);
});
})

.add('role:schedule,cmd:listSectorWeek',function(msg,respond){
var sector = msg.sector;
var week = msg.week;
console.log(week , sector);
console.log(sector);
console.log(week);
var schedule = this.make('schedule');
schedule.list$({sector , week}, function(error,schedule){
respond(null,schedule);
console.log(schedule);
});
})
Loading

0 comments on commit cab37b0

Please sign in to comment.