Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
823c1c5
(not so random pair generator) project has been been done locally. N…
Ahmed-username Jul 4, 2018
0f525ec
deploying to heroku
Ahmed-username Jul 4, 2018
493b063
all files are ready
Ahmed-username Jul 4, 2018
8ac28c1
updating files
Ahmed-username Jul 4, 2018
10cc301
deploying app fail failed, retrying
Ahmed-username Jul 4, 2018
7fc5ce1
fixed app,listen
Ahmed-username Jul 4, 2018
7c65794
changed css and wrapped students array in a clusure
Ahmed-username Jul 5, 2018
be9438a
remove bundle from ignore
Ahmed-username Jul 5, 2018
cd5ca24
changed fetch urls for localhost to /
Ahmed-username Jul 5, 2018
16c5b83
Home gif is now clickable
Ahmed-username Jul 5, 2018
9c7e8c8
chaned button in image
Ahmed-username Jul 5, 2018
220b1a4
added a footer and fonts
Ahmed-username Jul 7, 2018
158c94e
changed the page colors
Ahmed-username Jul 9, 2018
e06eb55
changed buttons and background. Added extra checks on new list
Ahmed-username Jul 11, 2018
e7adbe1
changed background on generate
Ahmed-username Jul 11, 2018
292a9e3
changed class to className
Ahmed-username Jul 11, 2018
9649e57
fixed
Ahmed-username Jul 11, 2018
c16bbe1
fixed a bug in a students name
Ahmed-username Jul 12, 2018
a05bc07
fixed a css bug
Ahmed-username Jul 12, 2018
94b4d64
changed css
Ahmed-username Jul 13, 2018
6652287
css update
Ahmed-username Jul 13, 2018
0112fe2
changed background animation
Ahmed-username Jul 22, 2018
de7bc53
changed bg color
Ahmed-username Jul 29, 2018
b32d6be
Update README.md
Ahmed-username Aug 24, 2018
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
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,2 @@
/node_modules
/static/bundle.js
/static/bundle.js.map
1 change: 1 addition & 0 deletions Procfile
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
web: node server.js
33 changes: 1 addition & 32 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,32 +1 @@
# Your own project

Build an app of your choice.

- You are free to use any technologies covered so far. You are welcome to try new technologies you find interesting.
- Keep it simple. Aim to get the basic functionality working on day one. You can then extend it on days two and three.
- Feel free to use an external API to provide additional functionality to your app. Avoid APIs that use complex authentication mechanisms.
- Use pen and paper to draw a diagram of the webpage layout before starting to code. Have a think about what components you will need in advance.
- Think about how to organise your data in advance
- Make sure your app is responsive
- Commit frequently
- Create pull request at the end
- Keep it simple

## Technical notes

* Run `npm install` after cloning to download all dependencies
* Use `npm run dev -- --watch` to build React
* Use `node server.js` to run the Node server in another tab
* You can view the site at [http://localhost:8080](http://localhost:8080)
* If you would like to user `nodemon` to automatically rebuild your server, run `npm run server`
* The node server file is `/server.js`
* The index home page is in `/views/index.hbs`
* Place all static files such as images and CSS in the `static` folder.

## README

* Produce a README.md which explains
* what the project does
* what technologies it uses
* how to build it and run it
* any unresolved issues the user should be aware of
A tool used to generate a pair of two. Pairs are generated based on previous results.
99 changes: 98 additions & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 7 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,20 @@
"babel-preset-env"
]
},
"engines": {
"node": "10.4.1"
},
"dependencies": {
"body-parser": "^1.18.3",
"classnames": "^2.2.6",
"express": "^4.16.3",
"hbs": "^4.0.1",
"jest": "^22.3.0",
"node-fetch": "^2.1.2",
"react": "^16.2.0",
"react-dom": "^16.2.0"
"react-dom": "^16.2.0",
"react-router-dom": "^4.3.1",
"shuffle-array": "^1.0.1"
},
"devDependencies": {
"babel-jest": "^22.4.1",
Expand Down
167 changes: 163 additions & 4 deletions server.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,170 @@ const app = express();
app.use(bodyParser.json());
app.use('/static', express.static('static'));
app.set('view engine', 'hbs');
//////////////////////////////////////////////////

app.get('/', function(req, res){
let dates={
0:"9/7/2018 at: 0:21:58"
}


let history=[];

function outerIds(){
let counter=1;
let ids={
0:"Cohort-2"
}

const innerIds= {


getCounter(){
return counter;
},

getIds(){

return ids;
},

saveIds(name){

ids[counter]=name;
counter++;
return ids;
}
}
return innerIds;
}

function outerPairs ()
{
let all = [
[
{name: "Ahmed", counters:{Alex:2, Edem:2, Ethan:2, Hamzah:3, Harry:2, James:2, Jose:4, Julius:3, Matt:1, Michael:1, Ollie:2, Phoebe:3, Rafal:3, Ralph:1, Sheila:2}},

{name: "Alex", counters:{Ahmed:2, Edem:2, Ethan:1, Hamzah:5, Harry:1, James:2, Jose:4, Julius:1, Matt:2, Michael:1, Ollie:2, Phoebe:1, Rafal:3, Ralph:2, Sheila:1}},

{name: "Edem", counters:{Alex:2, Ahmed:2, Ethan:3, Hamzah:5, Harry:0, James:2, Jose:1, Julius:2, Matt:0, Michael:1, Ollie:2, Phoebe:1, Rafal:3, Ralph:2, Sheila:1}},

{name: "Ethan", counters:{Alex:1, Edem:3, Ahmed:2, Hamzah:0, Harry:1, James:2, Jose:2, Julius:2, Matt:1, Michael:1, Ollie:1, Phoebe:1, Rafal:1, Ralph:2, Sheila:1}},

{name: "Hamzah", counters:{Alex:5, Edem:5, Ethan:0, Ahmed:3, Harry:1, James:2, Jose:2, Julius:1, Matt:3, Michael:1, Ollie:1, Phoebe:3, Rafal:1, Ralph:1, Sheila:1}},

{name: "Harry", counters:{Alex:1, Edem:0, Ethan:1, Hamzah:1, Ahmed:2, James:2, Jose:2, Julius:1, Matt:2, Michael:1, Ollie:2, Phoebe:3, Rafal:1, Ralph:2, Sheila:0}},

{name: "James", counters:{Alex:2, Edem:2, Ethan:2, Hamzah:2, Harry:2, Ahmed:2, Jose:2, Julius:2, Matt:1, Michael:3, Ollie:1, Phoebe:2, Rafal:2, Ralph:2, Sheila:1}},

{name: "Jose", counters:{Alex:3, Edem:1, Ethan:2, Hamzah:2, Harry:2, James:2, Ahmed:4, Julius:2, Matt:1, Michael:1, Ollie:1, Phoebe:3, Rafal:1, Ralph:2, Sheila:1}},

{name: "Julius", counters:{Alex:1, Edem:2, Ethan:2, Hamzah:1, Harry:1, James:2, Jose:2, Ahmed:3, Matt:2, Michael:1, Ollie:2, Phoebe:2, Rafal:1, Ralph:1, Sheila:2}},

{name: "Matt", counters:{Alex:2, Edem:0, Ethan:1, Hamzah:3, Harry:2, James:1, Jose:1, Julius:2, Ahmed:1, Michael:2, Ollie:1, Phoebe:3, Rafal:1, Ralph:1, Sheila:2}},

{name: "Michael", counters:{Alex:1, Edem:1, Ethan:1, Hamzah:1, Harry:1, James:3, Jose:1, Julius:1, Matt:2, Ahmed:1, Ollie:1, Phoebe:2, Rafal:1, Ralph:1, Sheila:2}},

{name: "Ollie", counters:{Alex:2, Edem:2, Ethan:1, Hamzah:1, Harry:2, James:1, Jose:1, Julius:2, Matt:1, Michael:1, Ahmed:2, Phoebe:2, Rafal:2, Ralph:1, Sheila:2}},

{name: "Phoebe", counters:{Alex:1, Edem:1, Ethan:1, Hamzah:3, Harry:2, James:2, Jose:3, Julius:2, Matt:3, Michael:2, Ollie:2, Ahmed:3, Rafal:1, Ralph:2, Sheila:3}},

{name: "Rafal", counters:{Alex:3, Edem:3, Ethan:1, Hamzah:1, Harry:1, James:2, Jose:1, Julius:1, Matt:1, Michael:1, Ollie:2, Phoebe:1, Ahmed:3, Ralph:0, Sheila:1}},

{name: "Ralph", counters:{Alex:2, Edem:2, Ethan:1, Hamzah:1, Harry:2, James:2, Jose:2, Julius:1, Matt:1, Michael:1, Ollie:1, Phoebe:2, Rafal:0, Ahmed:1, Sheila:2}},

{name: "Sheila", counters:{Alex:1, Edem:1, Ethan:1, Hamzah:1, Harry:1, James:1, Jose:1, Julius:2, Matt:2, Michael:2, Ollie:2, Phoebe:3, Rafal:1, Ralph:2, Ahmed:2}}
]


];

const innerPairs ={

all(){
return all;
},

load(i){
return all[i];
},
save(newArr,id){
let date = new Date();
let fullDate=`${date.getDate()}/${date.getMonth()+1}/${date.getFullYear()} at: ${date.getHours()}:${date.getMinutes()}:${date.getSeconds()}`;
dates[id]=fullDate;

all[id]=newArr;
return all[id];
},
add(newArr){
all.push(newArr);
return newArr;
}

}
return innerPairs;

}

//////////////////////////////////////////////////

const pairs=outerPairs();
const ids=outerIds();

app.get('/api/allLists', function(req,res){
res.json(pairs.all());
})

app.get('/api/all/:id', function(req,res){
res.json(pairs.load(req.params.id));
})

app.post('/api/save/:id', function(req,res){

res.json(pairs.save(req.body.arr, req.params.id));
})

app.post('/api/newList', function(req,res){

res.json(pairs.add(req.body.arr));
})

app.get('/api/loadIds', function(req,res){
res.json(ids.getIds());
})

app.post('/api/newId', function(req,res){
res.json(ids.saveIds(req.body.name));
})

app.get('/api/getDates', function(req,res){
res.json(dates);
})

app.get('/api/getDate/:id', function(req,res){
res.json(dates[req.params.id]);
})

app.get('/api/getHistory', function(req,res){
res.json({AllPreviousResults:history});
})

app.post('/api/saveHistory', function(req,res){
let tempObj=req.body;
let date = new Date();
let fullDate=`${date.getDate()}/${date.getMonth()+1}/${date.getFullYear()} at: ${date.getHours()}:${date.getMinutes()}:${date.getSeconds()}`;
tempObj.date=fullDate;
history.push(tempObj);

res.json({tempObj});
})



app.get('*', function(req, res){
res.render('index');
})

app.listen(8080, function(){
console.log('Listening on port 8080');
});
const port = process.env.PORT || 8080;
app.listen( port, function(){
console.log(`Listening on port number ${port}`);
});
Loading