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

Elliottbranch #13

Open
wants to merge 27 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
27 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
f1bcc21
sign up css
elock721 Jul 31, 2020
0f4927a
Merge branch 'master' into elliottbranch
elock721 Jul 31, 2020
4dce97a
html changes
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
2133911
Merge branch 'master' into elliottbranch
elock721 Jul 31, 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.
18 changes: 18 additions & 0 deletions models/truck.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
// 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
}
});

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
105 changes: 105 additions & 0 deletions public/find_Or_Post.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,105 @@
<!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">
<!-- <script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/js/bootstrap.min.js"
integrity="sha384-JZR6Spejh4U02d8jOt6vLEHfe/JQGiRRSQQxSfFWpi1MquVdAyjUar5+76PVCmYl"
crossorigin="anonymous"></script> -->
<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">Truck Name</label>
<input type="input" class="form-control" id="truck_name" placeholder="Truck Name">
</div>
<div class="form-group">
<label for="location">Location</label>
<input type="input" class="form-control" id="location" placeholder="Select Neighborhood">
</div>
<div class="form-group">
<label for="cuisine_type">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 class="card">
<div class="card-header">
<h4>Table data</h4>
</div>
<div class="card-body">
<ul id="tableList" class="list-group"></ul>
</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>

</html>
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.
172 changes: 172 additions & 0 deletions public/js/find_Or_Post.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,172 @@
$(document).ready(function() {
// Getting references to our form and inputs
var findTruckForm = $("form.find");
var truckNameInput = $("input#truck_name");
var locationInput = $("input#location");
var cuisineTypeInput = $("input#cuisine_type");

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

var tableList = $("#tableList");
var tableBody = $("#tableBody");

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

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

// tableList.empty();
$(".table")
.find("tbody")
.empty();

// var userData = {
// name: truckNameInput.val().trim(),
// cuisine: cuisineTypeInput.val().trim(),
// neighborhood: locationInput.val().trim()

// }

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

console.log(data);
console.log("------------------------------------");

for (var i = 0; i < data.length; i++) {
$(".table")
.find("tbody")
// .append($('<tr>').append($('<td>').append($('<img>').attr('src', 'img.png').text('Image cell'))))
.append(
$("<tr>")
// .append($('<td>').text(data[i].id))
.append($('<th scope="row">').text(data[i].id))
.append($("<td>").text(data[i].name))
.append($("<td>").text(data[i].cuisine))
.append($("<td>").text(data[i].neighborhood))
);
}
});
});
$(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");

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);
}



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

function queryByCuisine(searchBy){
$.get("/api/trucks/cuisine/" + searchBy.cuisine, function(qryResults){
renderTable(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)));
}
}

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

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

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