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

Walter branch #17

Open
wants to merge 38 commits into
base: wze_branch
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
38 commits
Select commit Hold shift + click to select a range
a88d37f
"test change"
coreyspratlan Jul 28, 2020
d16fd25
Merge branch 'master' into Corey-branch
jordidaigle Jul 28, 2020
a58b413
Merge pull request #3 from elock721/Corey-branch
jordidaigle Jul 28, 2020
a5cf5ec
testing
Waltrevino Jul 28, 2020
03c4ef9
Merge pull request #5 from elock721/walter_branch
Waltrevino Jul 28, 2020
e6977ff
made initial seed files
coreyspratlan Jul 29, 2020
d919c8f
Merge branch 'master' of https://github.com/elock721/Project-2-Idea i…
coreyspratlan Jul 29, 2020
9904c6c
Merge pull request #6 from elock721/Corey-branch
elock721 Jul 29, 2020
d70cad3
added more seeds
coreyspratlan Jul 29, 2020
4427777
Merge pull request #7 from elock721/Corey-branch
elock721 Jul 29, 2020
f34d114
Backend updates
Waltrevino Jul 29, 2020
1f85017
Merge pull request #8 from elock721/walter_branch
elock721 Jul 29, 2020
b653a26
Update changes to testing backend hmtl
Waltrevino Jul 30, 2020
067ba96
Merge pull request #9 from elock721/walter_branch
elock721 Jul 30, 2020
24f9737
fixed .env and config.json files
coreyspratlan Jul 30, 2020
fb9b964
Merge branch 'master' into Corey-branch
coreyspratlan Jul 30, 2020
9d27134
Merge pull request #10 from elock721/Corey-branch
elock721 Jul 30, 2020
43b50eb
Added buttons and sidebar to members page
jordidaigle Jul 31, 2020
fc6a0cf
Backend api route modifications
Waltrevino Jul 31, 2020
e905f25
Cool background and button edits
jordidaigle Jul 31, 2020
2fa44a0
Merge pull request #11 from elock721/walter_branch
elock721 Jul 31, 2020
8b1dba4
Merge branch 'master' of github.com:elock721/Project-2-Idea into Jord…
jordidaigle Jul 31, 2020
0f2b529
Merge pull request #12 from elock721/Jordan'sBrch
elock721 Jul 31, 2020
150545d
login and signup complete
elock721 Jul 31, 2020
b525c5e
Merge pull request #14 from elock721/ejl_branch
Waltrevino Jul 31, 2020
90e20a2
changed class names in html
jordidaigle Jul 31, 2020
8bc0c66
Merge pull request #15 from elock721/Jordan'sBrch
elock721 Jul 31, 2020
b163c07
Member html update
Waltrevino Jul 31, 2020
7e03a54
Merge pull request #16 from elock721/walter_branch
elock721 Jul 31, 2020
3ac3e2e
Members html update
Waltrevino Jul 31, 2020
9ec6c42
Member html update
Waltrevino Jul 31, 2020
ab53c4d
Member html update
Waltrevino Jul 31, 2020
67ae879
Member html update...
Waltrevino Jul 31, 2020
38c9466
Testing push
Waltrevino Aug 1, 2020
48bb75b
Pushing CSS changes w/ CArds and search
jordidaigle Aug 2, 2020
dff366f
Merge pull request #18 from elock721/Jordan'sBrch
elock721 Aug 2, 2020
6acf020
Merge commit
Waltrevino Aug 2, 2020
8b95d3d
git testing....
Waltrevino Aug 3, 2020
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
2 changes: 0 additions & 2 deletions .env.example

This file was deleted.

3 changes: 1 addition & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,10 @@ LOCALDB_URL=mysql://root:dbpassword@localhost:3306/Project2Dev
### Autofix linting errors where pssible (Note: this will not necessarily fix all of them)
npm run fix


### Associated Links (requires you to be logged into github):
[Project Requirements](https://github.com/the-Coding-Boot-Camp-at-UT/UTA-AUS-FSF-FT-06-2020-U-C/blob/master/01-Class-Content/15-Project-2/02-Homework/README.md

[Deployment w/ Sequelize](https://github.com/the-Coding-Boot-Camp-at-UT/UTA-AUS-FSF-FT-06-2020-U-C/blob/master/01-Class-Content/14-Full-Stack/04-Supplemental/SequelizeHerokuDeploymentProcess.md)


testing123
testing............`
5 changes: 3 additions & 2 deletions config/config.json
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
{
"development": {
"use_env_variable": "LOCALDB_URL"
"use_env_variable": "LOCALDB_URL",
"dialect": "mysql"
},
"test": {
"username": "root",
"password": null,
"database": "database_test",
"database": "fmf",
"host": "127.0.0.1",
"dialect": "mysql"
},
Expand Down
30 changes: 28 additions & 2 deletions db/schema.sql
Original file line number Diff line number Diff line change
@@ -1,2 +1,28 @@
DROP DATABASE IF EXISTS Project2Dev;
CREATE DATABASE Project2Dev;
DROP DATABASE IF EXISTS fmf;
CREATE DATABASE fmf;
USE fmf;

CREATE TABLE trucks (
id INT NOT NULL AUTO_INCREMENT,
name VARCHAR(45) NULL,
cuisine VARCHAR (45),
neighborhood VARCHAR (45),
createdAt DATE,
updatedAt DATE,
PRIMARY KEY (id)
);

INSERT INTO trucks (name, cuisine, neighborhood, createdAt, UpdatedAt)
VALUES ("Veracruz All Natural", "Mexican", "4208 Manchaca Rd. 78704", now(), now()),
("Gordoughs Big Fat Donuts", "American", "1503 South First Street 78704", now(), now()),
("Con Madre Kitchen", "Mexican", "628 E Oltorf St", now(), now()),
("Pueblo Viejo Taco Truck", "Mexican", "121 Pickle Rd", now(), now()),
("Mama Mal's Italian Cuisine Food Truck", "Southern Italian", "1320 S Lamar Blvd", now(), now()),
("Tamale Addiction", "Mexican", "2340 S Lamar Blvd", now(), now()),
("IL Saporis Italian", "Italian", "603 W Live Oak St", now(), now()),
("Luke's Inside Out", "Sandwich", "1109 S Lamar Blvd", now(), now()),
("Pitalicious", "Mediterranean", "1503 S Congress Ave", now(), now()),
("Cannone Cucina Italiana", "Italian", "1720 Barton Springs Rd", now(), now());
SELECT * FROM fmf.trucks;


Empty file added db/schemaV1.sql
Empty file.
24 changes: 24 additions & 0 deletions models/truck.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
// Creating our User model
module.exports = function(sequelize, DataTypes) {
var Truck = sequelize.define("Truck", {
// The email cannot be null, and must be a proper email before creation
name: {
type: DataTypes.STRING
},
cuisine: {
type: DataTypes.STRING
},
neighborhood: {
type: DataTypes.STRING
},
latitude: {
type: DataTypes.FLOAT
},
longitude: {
type: DataTypes.FLOAT
}
});

return Truck;
};

4 changes: 3 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
"scripts": {
"test": "npm run lint",
"start": "node server.js",
"dev": "nodemon server.js",
"lint": "eslint --quiet .",
"fix": "eslint --fix .",
"watch": "nodemon server.js"
Expand All @@ -14,11 +15,12 @@
"author": "",
"license": "ISC",
"dependencies": {
"@ciar4n/izmir": "^1.0.1",
"bcryptjs": "2.4.3",
"dotenv": "^8.2.0",
"express": "^4.17.0",
"express-session": "^1.16.1",
"mysql2": "^1.6.5",
"mysql2": "^1.7.0",
"passport": "^0.4.0",
"passport-local": "^1.0.0",
"sequelize": "^5.8.6"
Expand Down
96 changes: 96 additions & 0 deletions public/find_Or_Post.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,96 @@
<!DOCTYPE html>
<html lang="en">

<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootswatch/3.3.7/lumen/bootstrap.min.css">
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css"
integrity="sha384-Gn5384xqQ1aoWXA+058RXPxPg6fy4IWvTNh0E263XmFcJlSAwiGgFAW/dAiS6JXm" crossorigin="anonymous">
<title>Test Area</title>
</head>

<body>
<div class="row">
<div class="col-md-2">
<h2>Find</h2>
<form class="find">
<div class="form-group">
<label for="">Truck Name</label>
<input type="input" class="form-control" id="truck_name" placeholder="Truck Name">
</div>
<div class="form-group">
<label for="">Location</label>
<input type="input" class="form-control" id="location" placeholder="Select Neighborhood">
</div>
<div class="form-group">
<label for="">Cuisine</label>
<input type="input" class="form-control" id="cuisine_type" placeholder="Cuisine Type">
</div>
<br />
<button type="submit" class="btn btn-default">Search</button>
</form>
</div>

<div class="col-md-2">
<h2>Post</h2>
<form class="add">
<div class="form-group">
<label for="add_truck_name">Truck Name</label>
<input type="input" class="form-control" id="add_truck_name" placeholder="Truck Name">
</div>
<div class="form-group">
<label for="add_location">Location</label>
<input type="input" class="form-control" id="add_location" placeholder="Select Neighborhood">
</div>
<div class="form-group">
<label for="add_cuisine_type">Cuisine</label>
<input type="input" class="form-control" id="add_cuisine_type" placeholder="Cuisine Type">
</div>
<br />
<button type="submit" class="btn btn-default">Add</button>
</form>
</div>

<div class="col-md-2">
<h2>Delete</h2>
<form class="delete">
<div class="form-group">
<label for="del_truck_name">Truck Name</label>
<input type="input" class="form-control" id="del_truck_name" placeholder="Truck Name">
</div>
<div class="form-group">
<label for="del_location">Location</label>
<input type="input" class="form-control" id="del_location" placeholder="Select Neighborhood">
</div>
<div class="form-group">
<label for="del_cuisine_type">Cuisine</label>
<input type="input" class="form-control" id="del_cuisine_type" placeholder="Cuisine Type">
</div>
<br />
<button type="submit" class="btn btn-default">Delete</button>
</form>
</div>
</div>

</div> -->

<table class="table table-bordered table-light table-hover">
<thead>
<tr class="text-center">
<th scope="col">Id</th>
<th scope="col">Truck Name</th>
<th scope="col">Cuisine Type</th>
<th scope="col">Neighborhood</th>
</tr>
</thead>
<tbody>
</tbody>
</table>

<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>
<script type="text/javascript" src="js/find_Or_Post.js"></script>

</body>
<!-- COLLEGE FOOTBALL -->
</html>
Binary file added public/images/login.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/images/truck.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
177 changes: 177 additions & 0 deletions public/js/find_Or_Post.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,177 @@
$(document).ready(function() {
// Getting references to our form and inputs
var findTruckForm = $("form.find");
var truckNameInput = $("input#truck_name");
var cuisineTypeInput = $("input#cuisine_type");
var locationInput = $("input#location");

var addTruckForm = $("form.add");
var addTruckNameInput = $("input#add_truck_name");
var addLocationInput = $("input#add_location");
var addCuisineTypeInput = $("input#add_cuisine_type");

var addLatitude = $("input#add_latitude");
var addLongitude = $("input#add_longitude");

// initMap();

findTruckForm.on("submit", function(event) {
event.preventDefault();
clearTable();

var searchBy = {
name: truckNameInput.val().trim(),
cuisine: cuisineTypeInput.val().trim(),
neighborhood: locationInput.val().trim()
};

// Make sure atleast one field has been filled
if (!searchBy.name && !searchBy.cuisine && !searchBy.neighborhood) {
console.log("PLEASE SELECT ATLEAST ONE ITEM TO SEARCH FOR");

tstQry();
// Search by name, cuisine, neighborhood
} else if (searchBy.name && searchBy.cuisine && searchBy.neighborhood) {
console.log("search by ALL 3");

// Search by name only
} else if (searchBy.name && !searchBy.cuisine && !searchBy.neighborhood) {
queryByName(searchBy);

// Search by cuisine
} else if (!searchBy.name && searchBy.cuisine && !searchBy.neighborhood) {
console.log("search by CUISINE");
queryByCuisine(searchBy);

// Search by location
} else if (!searchBy.name && !searchBy.cuisine && searchBy.neighborhood) {
console.log("search by LOCATION");

// Search by name and cuisine
} else if (searchBy.name && searchBy.cuisine && !searchBy.neighborhood) {
console.log("search by NAME & CUISINE");

// Search by name and location
} else if (searchBy.name && !searchBy.cuisine && searchBy.neighborhood) {
console.log("search by NAME & LOCATION");

// Search by cuisine and location
} else if (!searchBy.name && searchBy.cuisine && searchBy.neighborhood) {
console.log("search by CUISINE & LOCATION");
}
});


function tstQry() {
$.ajax({ url: "/api/trucks", method: "GET" })
// .then (renderTable)
.then(function(qryResults){
renderResults(qryResults);
initMap(qryResults);
});
}

function queryByName(searchBy) {
console.log(searchBy);
$.get("/api/trucks/" + searchBy.name, function(qryResults) {
// renderTable(qryResults);
renderResults(qryResults);
initMap(qryResults);
});
}

function queryByCuisine(searchBy) {
$.get("/api/trucks/cuisine/" + searchBy.cuisine, function(qryResults) {
// renderTable(qryResults);
renderResults(qryResults);
initMap(qryResults);
});
}

function clearTable() {
$(".table")
.find("tbody")
.empty();
}

function renderTable(qryResults) {
for (var i = 0; i < qryResults.length; i++) {
$(".table")
.find("tbody")
.append(
$("<tr>")
.append($('<th scope="row">').text(qryResults[i].id))
.append($("<td>").text(qryResults[i].name))
.append($("<td>").text(qryResults[i].cuisine))
.append($("<td>").text(qryResults[i].neighborhood))
.append($("<td>").text(qryResults[i].latitude))
.append($("<td>").text(qryResults[i].longitude))
);
}
}

function renderResults(qryResults) {
for (var i = 0; i < qryResults.length; i++) {

let resBox = $('<div>');
let nameEl = $('<h3>');
let cuisineEl = $('<p>');
let neighborhoodEl = $('<p>');

resBox.attr('class',"card")
nameEl.text(qryResults[i].name);
nameEl.attr("class","title");
cuisineEl.text(qryResults[i].cuisine);
cuisineEl.attr("class","subtitle");
neighborhoodEl.text(qryResults[i].neighborhood);
neighborhoodEl.attr("class","card-footer");


resBox.append(nameEl);
resBox.append(cuisineEl);
resBox.append(neighborhoodEl);

$('.table').find('tbody').append(resBox);
}
}


$("#view_all").on("click", function(){
qryAllRecords();


})


function qryAllRecords() {
$.ajax({ url: "/api/trucks", method: "GET" })
// .then (renderTable)
.then(function(qryResults){
// renderResults(qryResults);
renderTable(qryResults);


});
}




// WORKS FINE
addTruckForm.on("submit", function(event) {
event.preventDefault();

var addUserData = {
name: addTruckNameInput.val().trim(),
cuisine: addCuisineTypeInput.val().trim(),
neighborhood: addLocationInput.val().trim(),
latitude: addLatitude.val().trim(),
longitude: addLongitude.val().trim()
};

$.post("/api/trucks", addUserData).then(function(data) {
console.log(data);
});
});
});

Loading