Skip to content

Commit

Permalink
added database and history
Browse files Browse the repository at this point in the history
  • Loading branch information
CoderCatA5 committed Dec 6, 2021
1 parent aaea02d commit 1a57c44
Show file tree
Hide file tree
Showing 5 changed files with 9 additions and 5 deletions.
7 changes: 5 additions & 2 deletions client/src/components/Grid.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ class Grid extends React.Component {
[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],
[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],
],
history:[],

}
}
Expand All @@ -43,13 +44,15 @@ class Grid extends React.Component {
};

tick(){
this.setState({...this.state,grid:nextFrameGravity(this.state.grid)})
const history=this.state.history;
history.push(this.state.grid);
this.setState({...this.state,grid:nextFrameGravity(this.state.grid),history:history})
}


render() {
var dis_grid=[];
console.log(this.state.grid)
console.log(this.state.history)
for (let row = 0; row < this.state.grid.length; row++) {
for (let col = 0; col < this.state.grid[row].length; col++) {
dis_grid.push(<Cell key={[row,col]} type={this.state.grid[row][col]} row={row} col={col} func={this.handleClick} grid={this.state.grid}/>)
Expand Down
Binary file added server.zip
Binary file not shown.
3 changes: 2 additions & 1 deletion server/app/config/db.config.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
//use own mongodb url here
module.exports = {
url: "mongodb://127.0.0.1:27017/?directConnection=true&serverSelectionTimeoutMS=2000/mydb"
url: "mongodb+srv://algos:algos@cluster0.ucxlw.mongodb.net/algorithmos?retryWrites=true&w=majority"
};
2 changes: 1 addition & 1 deletion server/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
"api",
"mongodb"
],
"author": "bezkoder",
"author": "algorithmos",
"license": "ISC",
"dependencies": {
"body-parser": "^1.19.0",
Expand Down
2 changes: 1 addition & 1 deletion server/server.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ db.mongoose

// simple route
app.get("/", (req, res) => {
res.json({ message: "Welcome to bezkoder application." });
res.json({ message: "Welcome to Algorithmos application." });
});

require("./app/routes/turorial.routes")(app);
Expand Down

0 comments on commit 1a57c44

Please sign in to comment.