-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #9 from rotirk20/development
Changes on UI home and some examples for backend creation of tables - first draft
- Loading branch information
Showing
8 changed files
with
65 additions
and
24 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,18 +1,62 @@ | ||
const mysql = require('mysql'); | ||
|
||
// Create the connection to the database | ||
const db = mysql.createConnection({ | ||
host: process.env.DB_HOST, | ||
user: process.env.DB_USER, | ||
password: process.env.DB_PASSWORD, | ||
database: process.env.DB_NAME | ||
}); | ||
|
||
// Connect to the database and create tables if they don't exist | ||
db.connect((err) => { | ||
if (err) { | ||
console.error('Error connecting to MySQL:', err); | ||
return; | ||
} | ||
console.log('Connected to MySQL database'); | ||
|
||
// SQL for checking and creating tables | ||
const queries = [ | ||
`CREATE TABLE IF NOT EXISTS locationTypes ( | ||
id INT AUTO_INCREMENT PRIMARY KEY, | ||
typeName VARCHAR(255) NOT NULL | ||
);`, | ||
`CREATE TABLE IF NOT EXISTS users ( | ||
id INT AUTO_INCREMENT PRIMARY KEY, | ||
userName VARCHAR(255) NOT NULL, | ||
email VARCHAR(255) NOT NULL UNIQUE | ||
);`, | ||
`CREATE TABLE IF NOT EXISTS locations ( | ||
id INT AUTO_INCREMENT PRIMARY KEY, | ||
locationName VARCHAR(255) NOT NULL, | ||
locationTypeId INT, | ||
userId INT, | ||
longitude FLOAT, | ||
latitude FLOAT, | ||
image VARCHAR(255), | ||
FOREIGN KEY (locationTypeId) REFERENCES locationTypes(id), | ||
FOREIGN KEY (userId) REFERENCES users(id) | ||
);`, | ||
`CREATE TABLE IF NOT EXISTS user_locations ( | ||
userId INT, | ||
locationId INT, | ||
PRIMARY KEY (userId, locationId), | ||
FOREIGN KEY (userId) REFERENCES users(id), | ||
FOREIGN KEY (locationId) REFERENCES locations(id) | ||
);` | ||
]; | ||
|
||
// Loop through each query to create tables | ||
queries.forEach((query) => { | ||
db.query(query, (error, results) => { | ||
if (error) { | ||
console.error('Error creating table:', error); | ||
} else { | ||
console.log('Table checked/created successfully.'); | ||
} | ||
}); | ||
}); | ||
}); | ||
|
||
module.exports = db; | ||
module.exports = db; |
2 changes: 1 addition & 1 deletion
2
frontend/src/app/components/location-card/location-card.component.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,53 +1,50 @@ | ||
<div class="w-full"> | ||
<!-- Image Section --> | ||
<div class="relative h-[500px] bg-cover bg-center" | ||
style="background-image: url('/assets/smetovi-bg.jpg');"> | ||
<div class="relative h-[500px] bg-cover bg-center" style="background-image: url('/assets/smetovi-bg.jpg');"> | ||
<div class="absolute inset-0 bg-black bg-opacity-50 flex items-center justify-center backdrop-blur-md"> | ||
<h1 class="text-white text-4xl md:text-6xl font-bold text-center">Dobro došli na Smetovi.ba</h1> | ||
<h1 class="text-white text-3xl md:text-5xl font-bold text-center uppercase">Dobro došli na Smetovi.ba</h1> | ||
</div> | ||
</div> | ||
|
||
<!-- Location Section --> | ||
<div class="bg-white py-12"> | ||
<div class="container mx-auto px-4"> | ||
<h2 class="text-3xl font-semibold text-center mb-8">Lokacije</h2> | ||
<h2 class="text-4xl font-semibold text-center mb-8">Lokacije</h2> | ||
|
||
<div class="grid grid-cols-1 sm:grid-cols-2 md:grid-cols-3 lg:grid-cols-4 gap-8"> | ||
<!-- Location 1 --> | ||
<div class="bg-white-100 rounded-lg shadow-lg"> | ||
<img class="w-full" src="/assets/images/smet.jpg"> | ||
<div class="bg-white-100"> | ||
<img class="w-64 h-64 object-cover rounded-full mx-auto" src="/assets/images/smet.jpg"> | ||
<div class="p-6"> | ||
<h3 class="text-xl font-bold mb-2">Konjički klub "Smet"</h3> | ||
<p>Location Address or description.</p> | ||
<h3 class="text-xl font-medium mb-2 text-center">Konjički klub "Smet"</h3> | ||
</div> | ||
|
||
</div> | ||
|
||
<!-- Location 2 --> | ||
<div class="bg-white-100 rounded-lg shadow-lg"> | ||
<img class="w-full" src="/assets/images/hero-section.jpg"> | ||
<div class="bg-white-100"> | ||
<img class="w-64 h-64 object-cover rounded-full mx-auto" src="/assets/images/spomenik.jpg"> | ||
<div class="p-6"> | ||
<h3 class="text-xl font-bold mb-2">Spomen obilježje</h3> | ||
<p>Location Address or description.</p> | ||
<h3 class="text-xl font-medium mb-2 text-center">Spomen obilježje</h3> | ||
</div> | ||
</div> | ||
|
||
<!-- Location 3 --> | ||
<div class="bg-white-100 rounded-lg shadow-lg"> | ||
<div class="bg-white-100"> | ||
<img class="w-64 h-64 object-cover rounded-full mx-auto" src="/assets/images/restoran_360.jpg"> | ||
<div class="p-6"> | ||
<h3 class="text-xl font-bold mb-2">Restoran 360</h3> | ||
<p>Location Address or description.</p> | ||
<h3 class="text-xl font-medium mb-2 text-center">Restoran 360</h3> | ||
</div> | ||
</div> | ||
|
||
<!-- Location 4 --> | ||
<div class="bg-white-100 rounded-lg shadow-lg"> | ||
<div class="bg-white-100"> | ||
<img class="w-64 h-64 object-cover rounded-full mx-auto" src="/assets/images/dom_saveza_izvidaca_i_radioamatera.jpg"> | ||
<div class="p-6"> | ||
<h3 class="text-xl font-bold mb-2">Dom Saveza Izviđača i Radioamatera</h3> | ||
<p>Location Address or description.</p> | ||
<h3 class="text-xl font-medium mb-2 text-center">Dom Saveza Izviđača i Radioamatera</h3> | ||
</div> | ||
</div> | ||
</div> | ||
</div> | ||
</div> | ||
|
||
</div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
File renamed without changes