Skip to content

Commit

Permalink
Updated the README.md and made changes, so that it can be hosted on a…
Browse files Browse the repository at this point in the history
…ny domain. Notify me, if there is anything I missed that prevents this.
  • Loading branch information
shlc001 committed Nov 20, 2023
1 parent b8a40fc commit 10a6a4e
Show file tree
Hide file tree
Showing 19 changed files with 90 additions and 56 deletions.
11 changes: 11 additions & 0 deletions .env
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# Database Information | This should be straightforward to setup
VUE_APP_DB_HOST=
VUE_APP_DB_USER=
VUE_APP_DB_PASS=
VUE_APP_DB_NAME=

# Get an API key for the PRO edition from openweathermap.org
VUE_APP_API_KEY=

# Example: https://www-student.cse.buffalo.edu/CSE442-542/2023-Spring/cse-442a
VUE_APP_WEB_DOMAIN=
2 changes: 0 additions & 2 deletions .gitignore

This file was deleted.

43 changes: 36 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,21 +1,25 @@
# Directory

### Img Directory
### backend Directory
* It is very important that you have the database set up correctly (as mentioned in Instructions)
*
* When you have the 'dist' folder created after using vue to compile the project, it's important to have the backend folder with all the .php files in the same directory.

### img Directory

* Holds all the static images related to the project

### Public Directory
### public Directory

* This holds index.html, which is self-evident in its function (main html root)

### Src Directory
### src Directory

* The src directory holds the bulk of the code for the project

* The NavBar Folder holds navbar.vue, which is the main navigation for logged in users

* The components folder in the src directory holds the various folders pertaining to webpages and inside those subfolders holds the vue files (html, css, javascript) for that particular page.

* The components folder in the src directory holds the various folders pertaining to webpages and inside those subfolders holds the vue files (html, css, javascript) for that particular page.

* App.vue is the root of the program, think of it as a main method, but for vue

Expand All @@ -28,9 +32,13 @@

* router.js represents every page on the site and how to reach that site, follow the general format of what's in the file and you should be all good!

### uploads Directory
* The uploads folder is a must have for the outfits recommendations system to work appropriately, ensure it is in the root folder where you upload the dist after compiling the project


### Rest of the files

* Don't touch babel.config.js unless necessary
* Don't touch babel.config.js unless necessary ||| Backwards Version Compatability

* globals.css is a css file that applies to the entire website

Expand All @@ -46,10 +54,26 @@

* vue.config.js is a config file that allows the website to run property

* the .env file should be updated with the appropriate info. Example for: VUE_APP_WEB_DOMAIN=https://www-student.cse.buffalo.edu/CSE442-542/2023-Spring/cse-442a

# Instructions

* Ensure that your repository is on node version 12.22.12 and npm version 6.14.6 before building your project:

* For the database, preferably use mySQL. Here's a link to a clone of the empty database with all the settings preconfigured: https://file.io/XNB4dc6vhqGP

* For the backend/security.php file. In the "$allowed_origins" array data structure, make sure you add the website where you're hosting this project into the allowed origins

* Ensure you have an empty uploads folder in the directory of which you put the deployed website

* Do the same as above, just for the backend directory.

* Make sure you fill in the environmental variables in .env. I left some comments as guidance

* You will need an API key from openweathermap.org. You will need the PRO edition API key.



### To install npm version 6.14.6 for your repository:
* npm i [email protected]

Expand All @@ -68,10 +92,15 @@ npm start

Open [http://localhost:8080](http://localhost:8080).


## Build for deploying

Note:
* After building, you can the upload `dist` folder to cheshire using scp.
* After building, you can the upload `dist` folder to the appropriate location

* Make sure you have the backend folder with all the php files in the directory where you put the dist folder

* Also, make sure you have an empty uploads folder with the appropriate permissions to allow for the website to put images into these folders

* If you're trying this on cheshire, make sure you move the files out of the dist folder one directory up, so ../ otherwise it will not work!

Expand Down
2 changes: 0 additions & 2 deletions backend/security.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,7 @@

function access_control(){
$allowed_origins = array(
'https://www-student.cse.buffalo.edu',
'http://localhost:8080',
'http://localhost:3000'
);
if (isset($_SERVER["HTTP_ORIGIN"])) {
// Decide if the origin in $_SERVER['HTTP_ORIGIN'] is the one that you want to allow
Expand Down
2 changes: 1 addition & 1 deletion src/components/DesktopAccountSettings/AccountSettings.vue
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ export default {
async getUserId() {
try {
const response = await axios.get("https://www-student.cse.buffalo.edu/CSE442-542/2023-Spring/cse-442a/backend/get_userid.php", { withCredentials: true });
const response = await axios.get(process.env.VUE_APP_WEB_DOMAIN + "/backend/get_userid.php", { withCredentials: true });
this.user_id = response.data.userid;
console.log("User_id: "+response.data.userid);
} catch (error) {
Expand Down
28 changes: 14 additions & 14 deletions src/components/DesktopHomepageLoggedIn/WebsiteHomePageLoggedIn.vue
Original file line number Diff line number Diff line change
Expand Up @@ -51,37 +51,37 @@

<div class="outfit-box" v-if="recommendedOutfit.outerwear">
<h1>Outerwear</h1>
<img :src="`https://www-student.cse.buffalo.edu/CSE442-542/2023-Spring/cse-442a/uploads/${recommendedOutfit.outerwear.image}`" alt="Outerwear" />
<img :src="`${process.env.VUE_APP_WEB_DOMAIN}/uploads/${recommendedOutfit.outerwear.image}`" alt="Outerwear" />
<p>{{ recommendedOutfit.outerwear.name }}</p>
</div>

<div class="outfit-box" v-if="recommendedOutfit.middlewear">
<h1>Middlewear</h1>
<img :src="`https://www-student.cse.buffalo.edu/CSE442-542/2023-Spring/cse-442a/uploads/${recommendedOutfit.middlewear.image}`" alt="Middlewear" />
<img :src="`${process.env.VUE_APP_WEB_DOMAIN}/uploads/${recommendedOutfit.middlewear.image}`" alt="Middlewear" />
<p>{{ recommendedOutfit.middlewear.name }}</p>
</div>

<div class="outfit-box" v-if="recommendedOutfit.innerwear">
<h1>Innerwear</h1>
<img :src="`https://www-student.cse.buffalo.edu/CSE442-542/2023-Spring/cse-442a/uploads/${recommendedOutfit.innerwear.image}`" alt="Innerwear" />
<img :src="`${process.env.VUE_APP_WEB_DOMAIN}/uploads/${recommendedOutfit.innerwear.image}`" alt="Innerwear" />
<p>{{ recommendedOutfit.innerwear.name }}</p>
</div>

<div class="outfit-box" v-if="recommendedOutfit.pants">
<h1>Pants</h1>
<img :src="`https://www-student.cse.buffalo.edu/CSE442-542/2023-Spring/cse-442a/uploads/${recommendedOutfit.pants.image}`" alt="Pants" />
<img :src="`${process.env.VUE_APP_WEB_DOMAIN}/uploads/${recommendedOutfit.pants.image}`" alt="Pants" />
<p>{{ recommendedOutfit.pants.name }}</p>
</div>

<div class="outfit-box" v-if="recommendedOutfit.headwear">
<h1>Headwear</h1>
<img :src="`https://www-student.cse.buffalo.edu/CSE442-542/2023-Spring/cse-442a/uploads/${recommendedOutfit.headwear.image}`" alt="Headwear" />
<img :src="`${process.env.VUE_APP_WEB_DOMAIN}/uploads/${recommendedOutfit.headwear.image}`" alt="Headwear" />
<p>{{ recommendedOutfit.headwear.name }}</p>
</div>

<div class="outfit-box" v-if="recommendedOutfit.shoes">
<h1>Shoes</h1>
<img :src="`https://www-student.cse.buffalo.edu/CSE442-542/2023-Spring/cse-442a/uploads/${recommendedOutfit.shoes.image}`" alt="Shoes" />
<img :src="`${process.env.VUE_APP_WEB_DOMAIN}/uploads/${recommendedOutfit.shoes.image}`" alt="Shoes" />
<p>{{ recommendedOutfit.shoes.name }}</p>
</div>
</div>
Expand Down Expand Up @@ -319,7 +319,7 @@ export default {
this.startTimer();
},
logoutUser(){
axios.post("https://www-student.cse.buffalo.edu/CSE442-542/2023-Spring/cse-442a/backend/logout.php?action=logout" , null, { withCredentials: true })
axios.post(process.env.VUE_APP_WEB_DOMAIN + "/backend/logout.php?action=logout" , null, { withCredentials: true })
.then((res) => {
if (res.data.status === 1 && this.$router && this.$router.currentRoute.path !== '/login') {
document.cookie = "auth_token=; expires=Thu, 01 Jan 1970 00:00:01 GMT; path=/CSE442-542/2023-Spring/cse-442a;";
Expand Down Expand Up @@ -385,7 +385,7 @@ export default {
},
async getUserId() {
try {
const response = await axios.get("https://www-student.cse.buffalo.edu/CSE442-542/2023-Spring/cse-442a/backend/get_userid.php", { withCredentials: true });
const response = await axios.get(process.env.VUE_APP_WEB_DOMAIN + "/backend/get_userid.php", { withCredentials: true });
this.$data.data.userid = response.data.userid;
await this.loadLocation();
await this.loadUnits();
Expand All @@ -398,7 +398,7 @@ export default {
},
async loadLocation() {
try {
const response = await axios.get("https://www-student.cse.buffalo.edu/CSE442-542/2023-Spring/cse-442a/backend/load_location.php", {
const response = await axios.get(process.env.VUE_APP_WEB_DOMAIN + "/backend/load_location.php", {
params: {
userid: this.$data.data.userid,
},
Expand Down Expand Up @@ -441,7 +441,7 @@ export default {
}
},
async loadUnits() {
axios.get("https://www-student.cse.buffalo.edu/CSE442-542/2023-Spring/cse-442a/backend/load_units.php",
axios.get(process.env.VUE_APP_WEB_DOMAIN + "/backend/load_units.php",
{
params: {
userid: this.$data.data.userid,
Expand All @@ -459,7 +459,7 @@ export default {
});
},
async loadTempSettings() {
axios.get("https://www-student.cse.buffalo.edu/CSE442-542/2023-Spring/cse-442a/backend/load_temperatures.php",
axios.get(process.env.VUE_APP_WEB_DOMAIN + "/backend/load_temperatures.php",
{
params: {
userid: this.$data.data.userid,
Expand Down Expand Up @@ -501,7 +501,7 @@ export default {
async getAllItems(temp_category) {
let items = {};
try {
const response = await axios.post("https://www-student.cse.buffalo.edu/CSE442-542/2023-Spring/cse-442a/backend/get_my_items.php", {
const response = await axios.post(process.env.VUE_APP_WEB_DOMAIN + "/backend/get_my_items.php", {
user_id: this.$data.data.userid,
temp_category: temp_category,
});
Expand Down Expand Up @@ -589,7 +589,7 @@ export default {
let savedOutfitAlready = false;
try {
const response = await axios.post("https://www-student.cse.buffalo.edu/CSE442-542/2023-Spring/cse-442a/backend/saved_items.php", {
const response = await axios.post(process.env.VUE_APP_WEB_DOMAIN + "/backend/saved_items.php", {
"outerwear": this.recommendedOutfit.outerwear,
"middlewear": this.recommendedOutfit.middlewear,
"innerwear": this.recommendedOutfit.innerwear,
Expand All @@ -611,7 +611,7 @@ export default {
return savedOutfitAlready
},
saveToMyItems(){
axios.post("https://www-student.cse.buffalo.edu/CSE442-542/2023-Spring/cse-442a/backend/saved_items.php", {
axios.post(process.env.VUE_APP_WEB_DOMAIN + "/backend/saved_items.php", {
"outerwear": this.recommendedOutfit.outerwear,
"middlewear": this.recommendedOutfit.middlewear,
"innerwear": this.recommendedOutfit.innerwear,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ export default {
methods: {
async getUserId() {
try {
const response = await axios.get("https://www-student.cse.buffalo.edu/CSE442-542/2023-Spring/cse-442a/backend/get_userid.php", { withCredentials: true });
const response = await axios.get(process.env.VUE_APP_WEB_DOMAIN + "/backend/get_userid.php", { withCredentials: true });
this.data.userid = response.data.userid;
console.log("User_id: "+response.data.userid);
this.loadLocation();
Expand All @@ -88,7 +88,7 @@ export default {
}
},
saveLocation() {
axios.post("https://www-student.cse.buffalo.edu/CSE442-542/2023-Spring/cse-442a/backend/saved_location.php",
axios.post(process.env.VUE_APP_WEB_DOMAIN + "/backend/saved_location.php",
{
userid: this.data.userid,
city: this.data.cityName,
Expand All @@ -106,7 +106,7 @@ export default {
});
},
loadLocation() {
axios.get("https://www-student.cse.buffalo.edu/CSE442-542/2023-Spring/cse-442a/backend/load_location.php",
axios.get(process.env.VUE_APP_WEB_DOMAIN + "/backend/load_location.php",
{
params: {
userid: this.data.userid,
Expand Down
2 changes: 1 addition & 1 deletion src/components/DesktopMyItems/SavedItem.vue
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ export default {
methods: {
deleteAnItem(){
console.log("Delete was called")
axios.post("https://www-student.cse.buffalo.edu/CSE442-542/2023-Spring/cse-442a/backend/delete_my_items.php", {
axios.post(process.env.VUE_APP_WEB_DOMAIN + "/backend/delete_my_items.php", {
userid: this.userid,
clothing_name: this.clothing_name,
image_name: this.image_name,
Expand Down
6 changes: 3 additions & 3 deletions src/components/DesktopMyItems/TempItem.vue
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
v-for="item in items"
:key = "item.id"
:clothing_name = "item.clothing_name"
:upload_path = '`https://www-student.cse.buffalo.edu/CSE442-542/2023-Spring/cse-442a/uploads/${item.upload_path}`'
:upload_path = '`${process.env.VUE_APP_WEB_DOMAIN}/uploads/${item.upload_path}`'
:image_name = "item.upload_path"
:userid = userid
:temp_category = temp_category
Expand Down Expand Up @@ -64,15 +64,15 @@ export default {
},
async getUserId() {
try {
const response = await axios.get("https://www-student.cse.buffalo.edu/CSE442-542/2023-Spring/cse-442a/backend/get_userid.php", { withCredentials: true });
const response = await axios.get(process.env.VUE_APP_WEB_DOMAIN + "/backend/get_userid.php", { withCredentials: true });
this.userid = response.data.userid;
console.log("The user id is: " + this.userid)
} catch (error) {
console.error("Unsuccessful request in getUserId().", error);
}
},
getAllItems(){
axios.post("https://www-student.cse.buffalo.edu/CSE442-542/2023-Spring/cse-442a/backend/get_my_items.php",
axios.post(process.env.VUE_APP_WEB_DOMAIN + "/backend/get_my_items.php",
{
user_id: this.userid,
temp_category: this.temp_category,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,15 +79,15 @@ export default {
},
async getUserId() {
try {
const response = await axios.get("https://www-student.cse.buffalo.edu/CSE442-542/2023-Spring/cse-442a/backend/get_userid.php", { withCredentials: true });
const response = await axios.get(process.env.VUE_APP_WEB_DOMAIN + "/backend/get_userid.php", { withCredentials: true });
this.userid = response.data.userid;
this.loadTempSettings();
} catch (error) {
console.error("Unsuccessful request in getUserId().", error);
}
},
loadTempSettings() {
axios.get("https://www-student.cse.buffalo.edu/CSE442-542/2023-Spring/cse-442a/backend/load_temperatures.php",
axios.get(process.env.VUE_APP_WEB_DOMAIN + "/backend/load_temperatures.php",
{
params: {
userid: this.userid,
Expand All @@ -105,7 +105,7 @@ export default {
});
},
saveTempSettings() {
axios.post("https://www-student.cse.buffalo.edu/CSE442-542/2023-Spring/cse-442a/backend/saved_temperatures.php",
axios.post(process.env.VUE_APP_WEB_DOMAIN + "/backend/saved_temperatures.php",
{
userid: this.userid,
hot: this.tempValues.hot,
Expand Down
6 changes: 3 additions & 3 deletions src/components/DesktopUnits/WebsiteUnitsPage.vue
Original file line number Diff line number Diff line change
Expand Up @@ -84,15 +84,15 @@ export default {
methods: {
async getUserId() {
try {
const response = await axios.get("https://www-student.cse.buffalo.edu/CSE442-542/2023-Spring/cse-442a/backend/get_userid.php", { withCredentials: true });
const response = await axios.get(process.env.VUE_APP_WEB_DOMAIN + "/backend/get_userid.php", { withCredentials: true });
this.userid = response.data.userid;
this.loadUnits();
} catch (error) {
console.error("Unsuccessful request in getUserId().", error);
}
},
saveUnits() {
axios.post("https://www-student.cse.buffalo.edu/CSE442-542/2023-Spring/cse-442a/backend/saved_units.php",
axios.post(process.env.VUE_APP_WEB_DOMAIN + "/backend/saved_units.php",
{
userid: this.userid,
temperature: this.temperature,
Expand All @@ -110,7 +110,7 @@ export default {
});
},
loadUnits() {
axios.get("https://www-student.cse.buffalo.edu/CSE442-542/2023-Spring/cse-442a/backend/load_units.php",
axios.get(process.env.VUE_APP_WEB_DOMAIN + "/backend/load_units.php",
{
params: {
userid: this.userid,
Expand Down
2 changes: 1 addition & 1 deletion src/components/LoginPage/WebsiteLoginPage.vue
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@
formData.append("username", this.username);
formData.append("password", this.password);
axios.post("https://www-student.cse.buffalo.edu/CSE442-542/2023-Spring/cse-442a/backend/login.php?action=login", formData, { withCredentials: true })
axios.post(process.env.VUE_APP_WEB_DOMAIN + "/backend/login.php?action=login", formData, { withCredentials: true })
.then((res) => {
console.log(res)
console.log(res.data)
Expand Down
6 changes: 2 additions & 4 deletions src/components/Modal/Modal.vue
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@
},
async getUserId() {
try {
const response = await axios.get("https://www-student.cse.buffalo.edu/CSE442-542/2023-Spring/cse-442a/backend/get_userid.php", { withCredentials: true });
const response = await axios.get(process.env.VUE_APP_WEB_DOMAIN + "/backend/get_userid.php", { withCredentials: true });
this.userid = response.data.userid;
console.log("The user id is: " + this.userid)
} catch (error) {
Expand All @@ -105,9 +105,7 @@
fd.append("clothing_name", this.clothing_name)
fd.append('temp_category', this.temp_category)
fd.append('clothing_category', this.clothing_category)
// https://www-student.cse.buffalo.edu/CSE442-542/2023-Spring/cse-442a/backend/my_items.php
// http://localhost/project_s23-iweatherify/backend/my_items.php
axios.post("https://www-student.cse.buffalo.edu/CSE442-542/2023-Spring/cse-442a/backend/my_items.php", fd, {header: {'Content-Type':'multipart/form-data'}}).then(
axios.post(process.env.VUE_APP_WEB_DOMAIN + "/backend/my_items.php", fd, {header: {'Content-Type':'multipart/form-data'}}).then(
(res) => {
if(res.data.status === 1){
// console.log("This is the response from the server")
Expand Down
2 changes: 1 addition & 1 deletion src/components/RegistrationPage/RegisterPage.vue
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,7 @@
formData.append("username", this.username);
formData.append("password", this.password);
axios.post("https://www-student.cse.buffalo.edu/CSE442-542/2023-Spring/cse-442a/backend/register.php?action=register", formData)
axios.post(process.env.VUE_APP_WEB_DOMAIN + "/backend/register.php?action=register", formData)
.then((res) => {
if(res.data.status === "error"){
console.log("Couldnt send post request")
Expand Down
Loading

0 comments on commit 10a6a4e

Please sign in to comment.