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

Team Task Viewer #31

Open
wants to merge 32 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
32 commits
Select commit Hold shift + click to select a range
994abef
initial commit
soemn Oct 20, 2017
3028bc2
added .gitignore
soemn Oct 20, 2017
e106c0d
delete yarn.lock
soemn Oct 20, 2017
4e3e93f
Merge branch 'master' of https://github.com/soemn/project-2
soemn Oct 20, 2017
7195330
added basic user sign up with bcrypt
soemn Oct 20, 2017
59560f6
updated mongoose link and database test code
soemn Oct 24, 2017
87b01a4
mongoclient test
soemn Oct 24, 2017
4b0d884
removed mongodb test
soemn Oct 24, 2017
aa226fb
user registeration and authentication
soemn Oct 24, 2017
ad98fbb
created manage project page and routes
soemn Oct 24, 2017
952848b
added sockets for chat
soemn Oct 25, 2017
040df8a
completed chat
soemn Oct 25, 2017
ef21bd1
removed nav link for task
soemn Oct 25, 2017
b4fea8a
manage project routes and handlebars created
soemn Oct 25, 2017
541da6e
selective emit for sockets added
soemn Oct 25, 2017
ee94fcc
refactored to websocket_routes and updated Board
soemn Oct 26, 2017
656bd5c
updated sockets to connect to project id instead of project name
soemn Oct 26, 2017
3382da2
chat messages can now be saved and are past messages are shown base o…
soemn Oct 26, 2017
f9acd27
tasks can be created in db
soemn Oct 26, 2017
456c5ac
added logic to move task on client side
soemn Oct 27, 2017
879bd91
task can now be moved and new position saved in database
soemn Oct 27, 2017
38792a9
updated readme
soemn Oct 27, 2017
cfc38e3
fixed project based io connection requiring refresh.
soemn Oct 28, 2017
df74681
updated mainboard css
soemn Oct 29, 2017
aba1eeb
removed start and projected end. added task description field. update…
soemn Oct 29, 2017
ed9ea62
Updated readme and css for routes
soemn Oct 29, 2017
df85315
updated task clickable location
soemn Dec 12, 2017
4861fc0
updated join/create/manage project page
soemn Dec 12, 2017
5c87550
updated front page
soemn Dec 12, 2017
1ba9212
updated readme
soemn Dec 12, 2017
965d190
updated comments.
soemn Dec 12, 2017
44b8775
updated readme image sizes.
soemn Dec 13, 2017
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
3 changes: 3 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
.git
.gitignore
node_modules
1 change: 1 addition & 0 deletions .env sample
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
SESSION_SECRET = "string"
5 changes: 5 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
yarn.lock
.env
.dockerignore
Dockerfile
*.pptx
8 changes: 8 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
FROM node:8.7.0
RUN mkdir -p /usr/src/app
WORKDIR /usr/src/app
COPY package.json /usr/src/app
RUN yarn install
COPY . /usr/src/app
CMD ["yarn", "start"]
EXPOSE 3000
84 changes: 39 additions & 45 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,65 +1,59 @@
# Your Project Name
# Team Task Manager

This is the starter code for WDI projects. Please update this README file with information specific to your project. Replace this paragraph for instance, with a short description of your project. Then update the sections below. Refer to your project specificaion for instructions on how to submit your projects.
Link to site:
http://159.89.194.112/

## Getting Started
The Team Task Manager is to help teams be agile even when working offsite. The task board list all tasks for the project in real time and any edits are reflected onto all team members.

Provide instructions here about how to get your project running on our local machine. Do we just need to clone and open a certain file or do we need to install anything first.
In addition, the Team Task Manager comes with inbuilt communication tools.

### Prerequisites
## How to use the Team Task manager

What is needed to install and run the project, how do we install them
1. Register/login to an account.
2. Join/Create a team at "/manageProject"
3. View the Task Board at "/board"
4. Create tasks on the board by pressing the "Create New Task" button
5. Delete task by clicking on the delete button on the Task card
6. Move task around by clicking on the task and clicking another section.

```
Code example
```
## Setting up the project

### How to Use
1. Create .env file in main directory - add SESSION_SECRET
2. yarn install - to install dependencies
3. ensure mongodb is up and running on your local machine

A step by step guide on how to install and use the project, for example if this is a game, how do we play it.
### Stack

Node, Express, Handlebars, MongoDB

```
Code example
```
## ERD

More steps...
1. Projects
2. Tasks
3. Users
4. Messages

```
until finished
```
<img src="./public/images/erd.png" alt="ERD" width="500"/>

## Screenshot

## Tests
The bulk of the website is on the Sprint board.

Did you write automated tests? If so, how do we run them.
<img src="./public/images/sprintBoard.png" alt="Sprintboard Screenshot" width="800"/>

## List of Routes

```
Code example
```
* Login
* Register
* Index (shows guide on how to use)
* Profile (shows list of task)
* Manage Project (allows creating, joining, and leaving projects)
* Task Board (shows the task management board)

## Live Version
## Hosting

Where is this deployed online (github pages, heroku etc), give us the link and any access details we need.

## Built With

What did you use to build it, list the technologies, plugins, gems, packages etc.

* [jQuery](http://jquery.com/) - jQuery for example is something you likely used

## Workflow

Did you write user stories, draw wireframes, use task tracking, produce ERDs? Did you use source control, with regular commits? Include links to them here.

## Authors

Did you collaborate with others on this project, list them here

* **John McClain** - *Responsible for keeping vests white* - [GithubUserName](https://github.com/GithubUserName)

## Acknowledgments

* Hat tip to anyone who's code was used, for example [this was a useful starting point for creating this template](https://gist.github.com/PurpleBooth/109311bb0361f32d87a2).
Hosted on DigitalOcean.

* Ubuntu 16.04.3 x64
* NGINX (reverse proxy)
* pm2 (node process manager)
37 changes: 37 additions & 0 deletions config/ppConfig.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
const passport = require("passport")
const LocalStrategy = require("passport-local").Strategy
const User = require("../models/user")

passport.serializeUser((user, next) => {
next(null, user.id)
})

passport.deserializeUser((id, next) => {
User.findById(id, function(err, user) {
next(err, user)
})
})

passport.use(
new LocalStrategy(
{
usernameField: "user[email]",
passwordField: "user[password]"
},
(email, password, next) => {
User.findOne({ email: email })
.then(user => {
if (!user) return next(null, false)

user.validPassword(password, (err, isMatch) => {
if (err) return next(err)
if (isMatch) return next(null, user)
return next(null, false, { message: "mismatched" })
})
})
.catch(err => next(err))
}
)
)

module.exports = passport
37 changes: 37 additions & 0 deletions controllers/auth.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
const passport = require("passport")
const LocalStrategy = require("passport-local").Strategy
const User = require("../models/user")

passport.serializeUser((user, next) => {
next(null, user.id)
})

passport.deserializeUser((id, next) => {
User.findById(id, function(err, user) {
next(err, user)
})
})

passport.use(
new LocalStrategy(
{
usernameField: "user[email]",
passwordField: "user[password]"
},
(email, password, next) => {
User.findOne({ email: email })
.then(user => {
if (!user) return next(null, false)

user.validPassword(password, (err, isMatch) => {
if (err) return next(err)
if (isMatch) return next(null, user)
return next(null, false, { message: "mismatched" })
})
})
.catch(err => next(err))
}
)
)

module.exports = passport
21 changes: 21 additions & 0 deletions helpers/handlebars.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
var register = function(Handlebars) {
var helpers = {
inc: function(value, options) {
return parseInt(value) + 1
},
foo: function(var1, var2) {
return
}
}

if (Handlebars && typeof Handlebars.registerHelper === "function") {
for (var prop in helpers) {
Handlebars.registerHelper(prop, helpers[prop])
}
} else {
return helpers
}
}

module.exports.register = register
module.exports.helpers = register(null)
25 changes: 25 additions & 0 deletions helpers/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
const isLoggedIn = (req, res, next) => {
if (req.user) {
res.redirect("/")
} else {
next()
}
}

const hasLoggedOut = (req, res, next) => {
if (req.user) {
next()
} else {
res.redirect("/")
}
}

const compare = (item1, item2) => {
return item1 === item2
}

module.exports = {
hasLoggedOut,
isLoggedIn,
compare
}
116 changes: 116 additions & 0 deletions index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,116 @@
require("dotenv").config({ silent: true })
const port = 3000
const dbUrl = "mongodb://127.0.0.1:27017/project-2"

// installing all modules
const express = require("express")
const path = require("path")
const mongoose = require("mongoose")
const exphbs = require("express-handlebars")
const bodyParser = require("body-parser")
const methodOverride = require("method-override")
const session = require("express-session")
const MongoStore = require("connect-mongo")(session)
const passport = require("./config/ppConfig")
const app = express()

//socket.io
const http = require("http").Server(app) //what is this?
const io = require("socket.io")(http)
app.io = io
//helpers
const { hasLoggedOut, isLoggedIn, compare } = require("./helpers")

//models
const User = require("./models/user")
const Project = require("./models/project")

const register_routes = require("./routes/register_routes")
const login_routes = require("./routes/login_routes")
const manageProject_routes = require("./routes/manageProject_routes")
const mainBoard_routes = require("./routes/mainBoard_routes")

//middlewares
app.engine("handlebars", exphbs({ defaultLayout: "main" }))
app.set("view engine", "handlebars")

app.use(bodyParser.json())
app.use(
bodyParser.urlencoded({
extended: true
})
)

app.use(express.static(path.join(__dirname, "public")))
app.use(function(req, res, next) {
console.log("Method: " + req.method + " Path: " + req.url)
next()
})

app.use(methodOverride("_method"))

// initialize mongoose and mongodb
mongoose.connect(dbUrl, {
useMongoClient: true
})
mongoose.Promise = global.Promise

//sessions
app.use(
session({
secret: process.env.SESSION_SECRET,
resave: false,
saveUninitialized: true,
store: new MongoStore({ mongooseConnection: mongoose.connection })
})
)

//passport initialize
app.use(passport.initialize())
app.use(passport.session())

app.use((req, res, next) => {
app.locals.user = req.user
req.io = io
next()
})

//routes
app.get("/", (req, res) => {
User.find()
.then(users => {
res.render("index", {
users
})
})
.catch(err => {
console.log(err)
})
})

app.get("/logout", hasLoggedOut, (req, res) => {
req.logout()
res.redirect("/")
})

app.get("/profile", hasLoggedOut, (req, res) => {
res.render("users/profile")
})

app.use("/manageProject", hasLoggedOut, manageProject_routes)
app.use("/board", hasLoggedOut, mainBoard_routes)

app.use("/register", isLoggedIn, register_routes)
app.use("/login", isLoggedIn, login_routes)

// socket connection routes
const socketIO = require("./routes/websocket_routes")(io)

io.on("projectBasedConnection", key => {
console.log("recieved")
console.log(key)
})

http.listen(port, () => {
console.log(`Server is running on port ${port}`)
})
12 changes: 12 additions & 0 deletions models/message.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
const mongoose = require("mongoose")

const MessageSchema = new mongoose.Schema({
author: String,
content: String,
projectId: mongoose.Schema.Types.ObjectId,
date: Date
})

const Message = mongoose.model("Message", MessageSchema)

module.exports = Message
Loading