Skip to content
Open

Dev #61

Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ jobs:
build-job:
working_directory: ~/origin-calendar
docker:
- image: circleci/node:8.11.0
- image: circleci/node:latest-browsers
- image: mongo:3.4.4
steps:
- checkout
Expand Down
27 changes: 27 additions & 0 deletions client/css/style.css
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,14 @@ label {
border-top: 1px solid #9393932b;
}

.table-striped {
overflow: scroll;
max-height: 500px;
}
.trash {
fill: #dc4245;
}

th {
color: whitesmoke;
background-color: #4f6995;
Expand All @@ -145,3 +153,22 @@ th {
opacity: 1
}
}

.text-center{
margin:auto;
justify-content: center;
}

#cancelbro{
margin:10;
}

select.form-control{
width:30%;
margin:left;
}
.auth {
position: absolute;
right: 15px;
top: 3px;
}
1,160 changes: 1,008 additions & 152 deletions package-lock.json

Large diffs are not rendered by default.

13 changes: 9 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,10 @@
"scripts": {
"build": "webpack --mode production",
"lint": "eslint .",
"start": "node .",
"start": "node server/server.js",
"dev-start": "npm run build && node server/server.js",
"dev": "webpack -w --mode development",
"test": "mocha tests --exit",
"test": "npm run build && mocha tests/* --exit",
"posttest": " "
},
"dependencies": {
Expand All @@ -27,6 +27,7 @@
"cors": "^2.5.2",
"dotenv": "^6.0.0",
"express": "^4.16.3",
"googleapis": "^27.0.0",
"helmet": "^3.13.0",
"loopback": "^3.0.0",
"loopback-boot": "^2.6.5",
Expand All @@ -35,14 +36,18 @@
"loopback-connector-sendgrid": "^2.2.4",
"mocha": "^5.2.0",
"moment": "^2.22.2",
"moment-timezone": "^0.5.21",
"morgan": "^1.9.0",
"nightmare": "^3.0.1",
"opn": "^5.4.0",
"react": "^16.4.1",
"react-dom": "^16.4.1",
"react-router-dom": "^4.3.1",
"serve-favicon": "^2.0.1",
"strong-error-handler": "^2.0.0",
"webpack": "^4.12.0",
"webpack-cli": "^3.0.8"
"webpack": "^4.20.2",
"webpack-cli": "^3.0.8",
"webpack-node-externals": "^1.7.2"
},
"devDependencies": {
"eslint": "^3.17.1",
Expand Down
100 changes: 71 additions & 29 deletions server/boot/create-admin.js
Original file line number Diff line number Diff line change
@@ -1,44 +1,86 @@
'use strict';

require('dotenv').config();

module.exports = (app) => {
const {Visitor, Role, RoleMapping} = app.models;
Visitor.findOrCreate({
where: {
email: 'instructor@origincodeacademy.com',
},
},

const instructors = [
{
email: 'instructor@origincodeacademy.com',
firstName: 'John',
lastName: 'Doe',
password: process.env.ADMIN_PASSWORD,
emailVerified: true,
},
(err, visitor) => {
if (err) console.log(err);
Role.findOrCreate({
where: {
name: 'ADMIN',
},
{
email: 'anthony@origincodeacademy.com',
firstName: 'Anthony',
lastName: 'Valera',
password: process.env.ADMIN_PASSWORD,
},
{
email: 'christian@origincodeacademy.com',
firstName: 'Christian',
lastName: 'McFarland',
password: process.env.ADMIN_PASSWORD2,
},
{
email: 'michael@origincodeacademy.com',
firstName: 'Michael',
lastName: 'Roberts',
password: process.env.ADMIN_PASSWORD3,
},
];

instructors.forEach(({email, firstName, lastName, password}) => {
Visitor.findOrCreate({
where: {
email,
},
},
{
email,
firstName,
lastName,
password,
emailVerified: true,
authToken: {},
},
{
name: 'ADMIN',
(err, visitor) => {
Role.findOrCreate({
where: {
name: 'ADMIN',
},
},
(err, role) => {
if (err) console.log('error creating role', err);
RoleMapping.findOrCreate({
where: {
principalType: 'ADMIN',
},
{
name: 'ADMIN',
},
{
principalType: 'ADMIN',
principalId: visitor.id,
}, (error, mapping) => {
if (err) console.log(err);
});
});
(err, role) => {
if (err) console.log('error creating role', err);
RoleMapping.findOrCreate({
where: {
principalType: 'ADMIN',
principalId: visitor.id,
},
},
{
principalType: 'ADMIN',
principalId: visitor.id,
}, (error, mapping) => {
if (err) console.log(err);
});
});
});
});

Visitor.findOrCreate({
where: {
email: 'student@origincodeacademy.com',
},
},
{
email: 'student@origincodeacademy.com',
firstName: 'Student',
lastName: 'Studentson',
password: 'abc123',
emailVerified: true,
});
};
59 changes: 59 additions & 0 deletions server/models/apt-request.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,4 +39,63 @@ module.exports = function(Aptrequest) {
{arg: 'time', type: 'string', required: true}],
returns: {arg: 'res', type: 'Object'},
});

Aptrequest.removeApt = function(email, time, cb) {
Aptrequest.app.models.Email.send({
to: email,
from: 'instructor@origincodeacademy.com',
subject: 'Appointment Removed',
text: `Your appointment on ${moment(time).format('L')}
at ${moment(time).format('hh:mm a')} was removed`,
}, function(err, mail) {
if (err) console.log(err);
return cb(null, mail);
});
};

Aptrequest.remoteMethod('removeApt', {
accepts: [{arg: 'email', type: 'string', required: true},
{arg: 'time', type: 'string', required: true}],
returns: {arg: 'res', type: 'Object'},
});

Aptrequest.replacedApt = function(email, time, cb) {
Aptrequest.app.models.Email.send({
to: email,
from: 'instructor@origincodeacademy.com',
subject: 'Appointment unavailable',
text: `Your appointment on ${moment(time).format('L')}
at ${moment(time).format('hh:mm a')} is no longer available.`,
}, function(err, mail) {
if (err) cb(err);
return cb(null, mail);
});
};

Aptrequest.remoteMethod('replacedApt', {
accepts: [{arg: 'email', type: 'string', required: true},
{arg: 'time', type: 'string', required: true}],
returns: {arg: 'res', type: 'Object'},
});

Aptrequest.emailAdmin = function(instructorEmail, time, studentName, cb) {
Aptrequest.app.models.Email.send({
to: instructorEmail,
from: 'instructor@origincodeacademy.com',
subject: `${studentName} Requested Your
${moment(time).format('hh:mma')} Appointment`,
text: `${studentName} has requested your appointment at
${moment(time).format('hh:mm a')} on ${moment(time).format('L')}`,
}, function(err, mail) {
if (err) cb(err);
return cb(null, mail);
});
};

Aptrequest.remoteMethod('emailAdmin', {
accepts: [{arg: 'instructorEmail', type: 'string', required: true},

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Similar blocks of code found in 2 locations. Consider refactoring.

{arg: 'time', type: 'string', required: true},
{arg: 'studentName', type: 'string', required: true}],
returns: {arg: 'res', type: 'Object'},
});
};
4 changes: 4 additions & 0 deletions server/models/apt-request.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,10 @@
"type": "string",
"required": true
},
"instructorId": {
"type": "string",
"required": false
},
"time": {
"type": "date",
"required": true
Expand Down
27 changes: 26 additions & 1 deletion server/models/booked-apt.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,30 @@
'use strict';
const moment = require('moment');

module.exports = function(Bookedapt) {
module.exports = function(BookedApt) {


BookedApt.removedConfirmed = function(email, time, studentName, cb) {
BookedApt.app.models.Email.send({
to: email,
from: 'instructor@origincodeacademy.com',
subject: ' Confirmed Appointment Removed',
text: `Your appointment on ${moment(time).format('L')}
at ${moment(time).format('hh:mm a')} was removed${studentName}`,
}, function(err, mail) {
if (err) console.log(err);
return cb(null, mail);
});
};

BookedApt.remoteMethod('removedConfirmed', {
accepts: [{arg: 'email', type: 'string', required: true},

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Similar blocks of code found in 2 locations. Consider refactoring.

{arg: 'time', type: 'string', required: true},
{arg: 'studentName', type: 'string', required: true}],
http:{path:'/removedConfirmed', verb:'post'},
returns: {arg: 'res', type: 'Object'},
});



};
4 changes: 4 additions & 0 deletions server/models/booked-apt.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,10 @@
"type": "string",
"required": true
},
"instructorId": {
"type": "string",
"required": true
},
"duration": {
"type": "number",
"required": true
Expand Down
Loading