diff options
| -rw-r--r-- | README.md | 1 | ||||
| -rw-r--r-- | deliverables/iteration-02.plan.md | 19 | ||||
| -rw-r--r-- | web/README.md | 30 | ||||
| -rw-r--r-- | web/app.js | 24 | ||||
| -rw-r--r-- | web/models/mockpoints.js | 32 | ||||
| -rw-r--r-- | web/models/points.js | 32 | ||||
| -rw-r--r-- | web/public/javascripts/map.js | 57 | ||||
| -rw-r--r-- | web/routes/index.js | 82 | ||||
| -rw-r--r-- | web/views/map.pug | 16 |
9 files changed, 153 insertions, 140 deletions
diff --git a/README.md b/README.md new file mode 100644 index 0000000..acdfd5a --- /dev/null +++ b/README.md @@ -0,0 +1 @@ +# SOME README diff --git a/deliverables/iteration-02.plan.md b/deliverables/iteration-02.plan.md index 0ae3c1b..80aa340 100644 --- a/deliverables/iteration-02.plan.md +++ b/deliverables/iteration-02.plan.md @@ -11,8 +11,6 @@ ## Process -(Optional:) Quick introduction - #### Roles & responsibilities Describe the different roles on the team and the responsibilities associated with each role. @@ -25,13 +23,11 @@ List each team member and: | Name | Responsibilities | Strengths | Weaknesses | |-----------------|----------------------------------------|------------------------------|--------------------------------| -| Xuhao Yu | "back end", integration | js, android, data management | memory, ios, react | -| Samarth Agarwal | "back end", database | Java, Databases, HTML/CSS | JavaScript, Node.js, React | -| Letian Zhao | "front end" | Java, JavaScript, SQL | React, Swift, App Development | -| Ivan Shen | "front end", Testing, Trello moderator | Java, JavaScript, Testing | Expo, Swift, SQL, React | -| Mohammed Ahmed | "back end", database | Java, Kanban, Node.js | React, Swift, Data Management | | Andrew Mihai | "front end", meetings note taker | Java, MVC methodology, Swift | React, Databases, Javascript | +| Ivan Shen | "front end", Testing, Trello moderator | Java, JavaScript, Testing | Expo, Swift, SQL, React | | Kumar Damani | Scrum master, server side, API | web, sql, kanban | React, graphic design, apps | +| Mohammed Ahmed | "back end", database | Java, Kanban, Node.js | React, Swift, Data Management | +| Samarth Agarwal | "back end", database | Java, Databases, HTML/CSS | JavaScript, Node.js, React | #### Team Rules @@ -44,16 +40,15 @@ Communications: > Code reviews are discussed in the comment section of the pull request. > A github wiki is also maintained for documentation. > Frequency is ~3-5 hrs for each of them. - * If you have a partner project, what is your process (in detail) for communicating with your partner? Meetings: * How are people held accountable for attending meetings, completing action items? Is there a moderator or process? > We hold an in-person sprint meeting every Tuesday and everyone is expected to attend that meeting. We understand that sometimes other commitments might take priority and the person may not be able to attend in-person, so that person can also attend via video chat over Discord. -> During the meetings, the scrum master goes over each item in the agenda (distributed beforehand). This will involve getting to know what each person has done over the last week, and are currently working on. Readying tasks for the upcoming sprint by ensuring the developer understand exactly what is expected from the task. +> During the meetings, the scrum master goes over each item in the agenda (distributed beforehand). This will involve getting to know what each person has done over the last week, and are currently working on. Readying tasks for the upcoming sprint by ensuring the developer understands exactly what is expected from the task. Conflict Resolution: * List at least three team scenarios/conflicts you discussed in lecture and how you decided you will resolve them. Indecisions? Non-responsive team members? Any other scenarios you can think of? -> Asked on piazza if we need to come up with this again. +> Same as iteration-01, see [here](https://github.com/csc301-winter-2019/project-team-02/blob/master/deliverables/iteration-01.planṃd#conflict-resolution). #### Events @@ -61,10 +56,10 @@ Describe meetings (and other events) you are planning to have: * When and where? Recurring or ad hoc? In-person or online? > We have mandatory in-person meetings every Tuesday from 3-6 pm inside a booked study room at the Gerstein Library. We have an online meeting on Fridays from 4-6 pm if needed. * What's the purpose of each meeting? - > The purpose of each meeting is to determine what everbody has done the previous week and what features need to be worked on for the current week. + > The purpose of each meeting is to determine what everybody has done over the previous week and what tasks need to be worked on for the upcoming week. * Other events could be coding sessions, code reviews, quick weekly sync meeting online, etc. -> Stays same as d1 +> Same as iteration-01, see [here](https://github.com/csc301-winter-2019/project-team-02/blob/master/deliverables/iteration-01.planṃd#conflict-resolution). #### Artifacts diff --git a/web/README.md b/web/README.md index d470960..b7f02b3 100644 --- a/web/README.md +++ b/web/README.md @@ -13,34 +13,8 @@ `docker run -d --name mymongo -p 27017:27017 mongo` -2. enter inside the container: - - `docker exec -it mymongo mongo` - -3. run inside the interactive mongo shell: - - `use helpthehome` - -4. Put in some dummy data to start, run: - -``` -db.pointscollection.insert({ - "type": "MultiPoint", - "name": "points", - "color": "#0000ff", - "style": { - "radius": 8, - "fillColor": "#00ce00", - "color": "#008c00", - "weight": 2, - "opacity": 1, - "fillOpacity": 1 - }, - "coordinates": [-73.9580, 40.8003] -}) -``` - -5. Now you are ready to start the app: + +2. Now you are ready to start the app: From this directory: @@ -3,6 +3,7 @@ var express = require('express'); var path = require('path'); var cookieParser = require('cookie-parser'); var logger = require('morgan'); +var mongoose = require('mongoose'); var indexRouter = require('./routes/index'); var usersRouter = require('./routes/users'); @@ -19,6 +20,29 @@ app.use(express.urlencoded({ extended: false })); app.use(cookieParser()); app.use(express.static(path.join(__dirname, 'public'))); +var env = process.env.NODE_ENV || 'development'; +var uri; +if (env === 'development') { + uri = 'mongodb://localhost:27017/helpthehome' + // use for small testing only if really necessary + // uri = 'mongodb+srv://development:dreamteam@cluster0-krnr4.mongodb.net/helpthehome?retryWrites=true' +} else if (env === 'qa') { + uri = process.env.MONGODB_URI +} else if (env === 'production') { + uri = '' +} + +// Mongoose connection to MongoDB +mongoose.connect(uri, { useNewUrlParser: true }, function (error) { + if (error) { + console.log(error); + console.log("App was not able to connect to the mongo server!"); + console.log("... double check that the mongo server is running locally"); + } else { + console.log(`connected to ${uri}`); + } +}); + app.use('/', indexRouter); app.use('/users', usersRouter); diff --git a/web/models/mockpoints.js b/web/models/mockpoints.js new file mode 100644 index 0000000..ff5e771 --- /dev/null +++ b/web/models/mockpoints.js @@ -0,0 +1,32 @@ +var mongoose = require('mongoose'); + +// Mongoose Schema definition +var Schema = mongoose.Schema; +var dumbJsonSchema = new Schema({ + type: String, + coordinates: Array, + ageRange: String, + clothingDescription: String, + isInjured: Boolean, + reasonForHelp: String +}); + +// Mongoose Model definition +var dumbJson = mongoose.model('dumbJstring', dumbJsonSchema, 'dumbpointscollection'); + +// this function gets ALL the points from the db +// returns the entire document without modifications +exports.get_points = function(callback) { + dumbJson.find({}).exec(function(err, docs) { + if (err) callback(err, null); + callback(null, docs); + }); +} + +// this function stores A user report into the db +exports.save_request = function(data, callback) { + dumbJson.create(data, function(err, result) { + if (err) callback(err, null); + callback(null, result); + }); +} diff --git a/web/models/points.js b/web/models/points.js new file mode 100644 index 0000000..3a07c82 --- /dev/null +++ b/web/models/points.js @@ -0,0 +1,32 @@ +var mongoose = require('mongoose'); + +// Mongoose Schema definition +var Schema = mongoose.Schema; +var JsonSchema = new Schema({ + type: String, + coordinates: Array, + ageRange: String, + clothingDescription: String, + isInjured: Boolean, + reasonForHelp: String +}); + +// Mongoose Model definition +var Json = mongoose.model('Jstring', JsonSchema, 'pointscollection'); + +// this function gets ALL the points from the db +// returns the entire document without modifications +exports.get_points = function(callback) { + Json.find({}).exec(function(err, docs) { + if (err) callback(err, null); + callback(null, docs); + }); +} + +// this function stores A user report into the db +exports.save_request = function(data, callback) { + Json.create(data, function(err, result) { + if (err) callback(err, null); + callback(null, result); + }); +} diff --git a/web/public/javascripts/map.js b/web/public/javascripts/map.js index 44fba38..190307d 100644 --- a/web/public/javascripts/map.js +++ b/web/public/javascripts/map.js @@ -5,48 +5,19 @@ // different basemap L.tileLayer('https://stamen-tiles-{s}.a.ssl.fastly.net/toner-lite/{z}/{x}/{y}{r}.{ext}', { - attribution: 'Map tiles by <a href="http://stamen.com">Stamen Design</a>, <a href="http://creativecommons.org/licenses/by/3.0">CC BY 3.0</a> — Map data © <a href="https://www.openstreetmap.org/copyright">OpenStreetMap</a> contributors', - subdomains: 'abcd', - minZoom: 0, - maxZoom: 20, - ext: 'png' + attribution: 'Map tiles by <a href="http://stamen.com">Stamen Design</a>, <a href="http://creativecommons.org/licenses/by/3.0">CC BY 3.0</a> — Map data © <a href="https://www.openstreetmap.org/copyright">OpenStreetMap</a> contributors', + subdomains: 'abcd', + minZoom: 0, + maxZoom: 18, + ext: 'png' }).addTo(map); -// Create point feature for somewhere downtown -var myDataPoint = L.marker([43.6529, -79.3849]).addTo(map); - -// Create line feature and add style and add to map -var myDataLine = L.polyline([ - [43.6529, -79.3849], - [43.6531, -79.3855]], - {color: 'red', weight: 10}).addTo(map); - -// Create area feature add style and add to map -var myArea = L.polygon([ - [43.650948, -79.385655], - [43.66, -79.388], - [43.6634, -79.4011], - [43.66, -79.4011]], - {color: 'blue', weight: 4}).addTo(map); - -// Bind popup to Data Point object -// myDataPoint.bindPopup("This is my city"); -// i can add regular html to this too - neat! -myDataPoint.bindPopup("<h3>City Hall (not really)</h3><p>Toronto, ON<br>Information about city hall.</p>"); - -// Bind popup to area object -myArea.bindPopup("U of T Campus (not really)"); - -// Create an Empty Popup -var popup = L.popup(); - -// Write function to set Properties of the Popup -function onMapClick(e) { - popup - .setLatLng(e.latlng) - .setContent("You clicked the map at " + e.latlng.toString()) - .openOn(map); -} - -// Listen for a click event on the Map element -map.on('click', onMapClick); +L.geoJson(points, { + pointToLayer: function (feature, latlng) { + //return L.circleMarker(latlng); + return L.marker(latlng); + } +}).bindPopup(function (layer) { + // layer.feature.geometry gives you access to all the fields + return "<p>" + JSON.stringify(layer.feature.geometry) + "</p>"; +}).addTo(map) diff --git a/web/routes/index.js b/web/routes/index.js index ffe1c21..b2d0796 100644 --- a/web/routes/index.js +++ b/web/routes/index.js @@ -1,61 +1,45 @@ var express = require('express'); var router = express.Router(); - -// Mongoose import -var mongoose = require('mongoose'); - -var env = process.env.NODE_ENV || 'development'; -var uri; -if (env === 'development') { - uri = 'mongodb://localhost:27017/helpthehome' - // use for small testing only if really necessary - // uri = 'mongodb+srv://development:dreamteam@cluster0-krnr4.mongodb.net/helpthehome?retryWrites=true' -} else if (env === 'qa') { - uri = process.env.MONGODB_URI -} else if (env === 'production') { - uri = '' -} - -// Mongoose connection to MongoDB -mongoose.connect(uri, { useNewUrlParser: true }, function (error) { - if (error) { - console.log(error); - console.log("App was not able to connect to the mongo server!"); - console.log("... double check that the mongo server is running locally"); - } else { - console.log(`connected to ${uri}`); - } -}); - -// Mongoose Schema definition -var Schema = mongoose.Schema; -var JsonSchema = new Schema({ - name: String, - type: Schema.Types.Mixed, - coordinates: Array -}); - -// Mongoose Model definition -var Json = mongoose.model('Jstring', JsonSchema, 'pointscollection'); +var Mockpoints = require('../models/mockpoints'); +var Points = require('../models/points'); /* GET home page. */ router.get('/', function(req, res, next) { - // for now just redirect to /map - //res.render('index', { title: 'Welcome' }); - res.redirect('/map'); + // for now just redirect to /map + res.redirect('/map'); }); /* GET Map page. */ router.get('/map', function(req,res) { - // we can use the database to fetch a point, SELECT coordinates - Json.findOne({name: "points"}, 'coordinates', function(e,point){ - if (e) return e; - // send the view lat, and long. - res.render('map', { - lat : point.coordinates[1], - lng : point.coordinates[0] - }); - }); + // load the map with all the points + // Mockpoints.get_points(function(err, points){ + Points.get_points(function(err, points){ + res.render('map', { + lat : 43.665234, + lng : -79.383370, + points: points + }); + }); +}); + +router.post('/mobilerequest', function(req, res) { + var data = { + 'coordinates': req.body.coordinates, + 'type': req.body.type, + 'isInjured': req.body.isInjured, + 'reasonForHelp': req.body.reasonForHelp, + 'ageRange': req.body.ageRange, + 'clothingDescription': req.body.clothingDescription + } + Points.save_request(data, function(err, result) { + if (err) { + console.log(`err inserting mobile request into db: ${err}`); + res.status(500).send({ error: "boo:(" }); + } else { + console.log(result); + res.status(200).send({'status': 'success', 'data': data}); + } + }); }); module.exports = router; diff --git a/web/views/map.pug b/web/views/map.pug index b7781fa..725c8a8 100644 --- a/web/views/map.pug +++ b/web/views/map.pug @@ -1,11 +1,11 @@ extends layout.pug block content - #sidebar - h1 This is a sidebar - #map - - script(type='text/javascript'). - var map = L.map('map').setView([#{lat},#{lng}], 15); - script(src='/javascripts/map.js') - + #sidebar + h1 This is a sidebar + #map + script(type='text/javascript'). + var map = L.map('map').setView([#{lat},#{lng}], 13); + var points = !{JSON.stringify(points)}; + console.log(points); + script(src='/javascripts/map.js') |
