Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Geeksevent #41

Open
wants to merge 9 commits into
base: master
Choose a base branch
from
Open
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
5,105 changes: 736 additions & 4,369 deletions package-lock.json

Large diffs are not rendered by default.

46 changes: 23 additions & 23 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,37 +1,37 @@
{
"name": "gsg_narrowcast",
"version": "1.0.0",
"description": "GSG Narrowcast",
"main": "index.js",
"description": "[![Build Status](https://travis-ci.org/FACG4/gsg_narrowcast.svg?branch=master)](https://travis-ci.org/FACG4/gsg_narrowcast) # GSG_Narrowcast: An app that allows you to quickly and effortlessly learn about all upcoming events held in GSG as well as understand what GSG does as an entity, what their main programs are and whether they interest you.",
"main": ".eslintrc.js",
"directories": {
"test": "test"
},
"dependencies": {
"bcrypt": "^2.0.1",
"env2": "^2.2.2",
"express": "^4.16.3",
"jsonwebtoken": "^8.3.0",
"mongodb": "^3.0.10",
"mongoose": "^5.1.6",
"tap-spec": "^5.0.0",
"tape": "^4.9.1"
},
"devDependencies": {
"mocha": "^5.2.0"
},
"scripts": {
"start": "nodemon src/index.js",
"test": "istanbul cover test/tests_index.js | tap-spec"
"test": "tape test/tests_index.js | tap-spec",
"start": "node ./src/index.js"
},
"repository": {
"type": "git",
"url": "git+https://github.com/FACG4/gsg_narrowcast.git"
},
"author": "Abdallah, Ishak, Razan, Farah",
"keywords": [],
"author": "",
"license": "ISC",
"bugs": {
"url": "https://github.com/FACG4/gsg_narrowcast/issues"
},
"homepage": "https://github.com/FACG4/gsg_narrowcast#readme",
"devDependencies": {
"eslint": "^4.19.1",
"eslint-config-airbnb-base": "^12.1.0",
"eslint-plugin-import": "^2.12.0",
"istanbul": "^0.4.5",
"mocha": "^5.2.0",
"nodemon": "^1.17.5",
"supertest": "^3.1.0",
"tap-spec": "^5.0.0",
"tape": "^4.9.1"
},
"dependencies": {
"env2": "^2.2.2",
"express": "^4.16.3",
"express-handlebars": "^3.0.0",
"mongoose": "^5.1.5"
}
"homepage": "https://github.com/FACG4/gsg_narrowcast#readme"
}
Binary file added public/css/0Z4A0232.JPG
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added public/css/gazageeks.JPG
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
73 changes: 73 additions & 0 deletions public/css/style.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
.EventPageBody{
background-image: url('gazageeks.JPG');
background-repeat: no-repeat;
background-size: cover;
}

.addeventBtn{background-color: orange;
border-radius: 10px;
width: 200px;
color: #47413d
text-align: center;
margin-left:50px;
}

.addeventBtn:hover{
background-color: rgb(43, 153, 188);
color: white;
}

.Add-wrap {
text-align: center;
font-size: 20px;
background-color: black;
opacity: 0.8;
width: 900px;
margin-left: 430px;
padding-bottom: 30px;
padding-top: 30px;
border-radius: 20px;

}


label{color: white;
border-radius: 60px;
text-align: center;
}

.addEventTitle{
color: white;
font-weight: bolder;
font-size: 50px;
}

.imageurl{
border-radius: 10px;
text-align: center;
margin-left:40px;
margin-right: 40px;
width: 300px;

}

.des{
margin-left:4px;
}




.des, .speaker, .title, .hall, .date, .start-date , .end-date{
border-radius: 10px;


}
.hall{
width: 300px;
}
.start-date , .end-date{
text-align: center;
}


Empty file added public/js/dom.js
Empty file.
42 changes: 42 additions & 0 deletions public/js/event_dom.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
const select = (selector) =>
document.querySelector(selector);
const form = select('.dd-post');
const addeventBtn =select('.addeventBtn')
;
addeventBtn.addEventListener('click', function(event) {
e.preventDefault();
var data = {
title: select('.title').value,
description:select('.des').value,
speaker :select('.speaker ').value,
hall: select('.hall').value,
startDate: select('.start-date').value,
endDate:select('end-date').value,
ImageUrl:select('imageurl').value
}

fetch('/events', {
headers: {
'content-type': 'application/json'
},
method: 'POST',
body: data,
}).then(function(res){
return res.json();
}).then(function(res){
console.log(res);
});

});

var btn_form= select("#myBtn");


console.log(btn_form)
btn_form.addEventListener("click", function (e) {





});
15 changes: 13 additions & 2 deletions src/app.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
const { express, path, exphbs } = require('./reqs');

const controllers = require('./controllers');
const bodyParser = require('body-parser');
const dbConnection = require('./database/db_connect')
Copy link
Contributor

Choose a reason for hiding this comment

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

Why are you requiring dbconnection in your app?

Copy link
Author

Choose a reason for hiding this comment

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

becuese i have a problem to save data i enter in the form in data base
its necessary to require dbconnection app

Copy link
Contributor

Choose a reason for hiding this comment

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

It is not. You shouldn't require your dbConnection in your app.

const app = express();

app.set('views', path.join(__dirname, 'views'));
Expand All @@ -8,9 +10,18 @@ app.engine('hbs', exphbs({
extname: 'hbs',
layoutsDir: path.join(__dirname, 'views', 'layouts'),
partialsDir: path.join(__dirname, 'views', 'partials'),
defaultLayout: 'main',
defaultLayout: 'main'
}));

const port = 3000;
app.use(bodyParser.json());
app.use(bodyParser.urlencoded({ extended: false }));





app.use(controllers)
app.use(express.static(path.join(__dirname, '..', 'public')));
app.set('port', process.env.PORT || 3000);

Expand Down
28 changes: 28 additions & 0 deletions src/controllers/event.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
const Events = require('../database/events');

exports.get = (req, res, next) => {
res.render('event', {event: true, script: 'event_dom.js', title: 'My page' });
Copy link
Contributor

Choose a reason for hiding this comment

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

Why is the event: true?

}

exports.post = (req, res, next) => {

const schema = {
Copy link
Contributor

Choose a reason for hiding this comment

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

Separate the queries from the controllers

title: req.body.title,
description: req.body.description,
speaker:req.body.title,
hall:req.body.hall,
startDate:req.body.startDate,
endDate:req.body.endDate

}
Events.create(schema)
.then(docs=>{
res.end()
})
.catch(err => {

res.end()
})


};
11 changes: 11 additions & 0 deletions src/controllers/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
const express = require('express');

const router = express.Router();
const event = require('./event')


router.post('/event', event.post);
router.get('/event', event.get);


module.exports=router
34 changes: 0 additions & 34 deletions src/database/db_build.js

This file was deleted.

7 changes: 3 additions & 4 deletions src/database/db_connect.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
const mongoose = require('mongoose');
require('env2')('./config.env');

const dbUrl = process.env.DB_URL;

mongoose.connect(dbUrl);
const dbConnection = mongoose.connection;
dburl = 'mongodb://localhost/database'
mongoose.connect(dburl);

module.exports = { dbConnection };
module.exports = mongoose.connection;
15 changes: 15 additions & 0 deletions src/database/events.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
const mongoose = require('mongoose')



const eventSchema = mongoose.Schema({
startDate: Date,
endDate: Date,
title: String,
hall: String,
speaker: String,
imageUrl: String,
description: String,

});
module.exports= mongoose.model('Events', eventSchema)
9 changes: 9 additions & 0 deletions src/database/programs.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
const mongoose = require('mongoose')

const programSchema = mongoose.Schema({
title: { type: String, unique: true },
description: String,
imageUrl: String,
contactPerson: String,
});
module.exports = mongoose.model('Programs', programSchema)
23 changes: 23 additions & 0 deletions src/database/queries/add_event.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@

const Events = require('../events.js');

const schema = {
title: req.body.title,
description: req.body.description,
speaker:req.body.title,
hall:req.body.hall,
startDate:req.body.startDate,
endDate:req.body.endDate

}
Events.create(schema)
.then(docs=>{
res.end()
})
.catch(err => {

res.end()
})

module.exports =schema ;

3 changes: 3 additions & 0 deletions src/database/queries/saveEvent.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
const Events = require('../events')

module.exports = (object) => new Events({ object }).save();
Copy link
Contributor

Choose a reason for hiding this comment

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

Good, you've created a query, and used it where?

Copy link
Author

Choose a reason for hiding this comment

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

event.js in controller

Copy link
Contributor

Choose a reason for hiding this comment

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

No you haven't required it in event.js.

10 changes: 10 additions & 0 deletions src/database/users.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
const mongoose = require('mongoose')

const usersSchema = mongoose.Schema({
role: Number,
username: { type: String, unique: true },
password: String,
email: { type: String, unique: true },
});
module.exports = mongoose.model('Users' ,usersSchema);

2 changes: 0 additions & 2 deletions src/index.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
const app = require('./app');

/* eslint-disable no-console */

app.listen(app.get('port'), () => {
console.log('this app runs on port', app.get('port'));
});
4 changes: 3 additions & 1 deletion src/reqs.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,9 @@ const express = require('express');
const path = require('path');
const exphbs = require('express-handlebars');
const fs = require('fs');
const Event = require ('./controllers/event')


module.exports = {
express, path, exphbs, fs,
express, path, exphbs, fs,Event,
};
Loading