diff --git a/backend/config/db.js b/backend/config/db.js index 124f845..598e0bd 100644 --- a/backend/config/db.js +++ b/backend/config/db.js @@ -1,5 +1,6 @@ const mysql = require('mysql'); +// Create the connection to the database const db = mysql.createConnection({ host: process.env.DB_HOST, user: process.env.DB_USER, @@ -7,12 +8,55 @@ const db = mysql.createConnection({ 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; \ No newline at end of file +module.exports = db; diff --git a/frontend/src/app/components/location-card/location-card.component.html b/frontend/src/app/components/location-card/location-card.component.html index f4ee6f7..ee734df 100644 --- a/frontend/src/app/components/location-card/location-card.component.html +++ b/frontend/src/app/components/location-card/location-card.component.html @@ -1,5 +1,5 @@
- +

diff --git a/frontend/src/app/pages/home/home.component.html b/frontend/src/app/pages/home/home.component.html index 6915e45..cba853a 100644 --- a/frontend/src/app/pages/home/home.component.html +++ b/frontend/src/app/pages/home/home.component.html @@ -1,53 +1,50 @@

-
+
-

Dobro došli na Smetovi.ba

+

Dobro došli na Smetovi.ba

-

Lokacije

+

Lokacije

-
- +
+
-

Konjički klub "Smet"

-

Location Address or description.

+

Konjički klub "Smet"

-
-
- +
+
-

Spomen obilježje

-

Location Address or description.

+

Spomen obilježje

-
+
+
-

Restoran 360

-

Location Address or description.

+

Restoran 360

-
+
+
-

Dom Saveza Izviđača i Radioamatera

-

Location Address or description.

+

Dom Saveza Izviđača i Radioamatera

+
\ No newline at end of file diff --git a/frontend/src/app/pages/location/location.component.html b/frontend/src/app/pages/location/location.component.html index 360b013..637c195 100644 --- a/frontend/src/app/pages/location/location.component.html +++ b/frontend/src/app/pages/location/location.component.html @@ -6,7 +6,7 @@
-

Google map

+
diff --git a/frontend/src/app/pages/location/location.component.ts b/frontend/src/app/pages/location/location.component.ts index 051d62b..abaefcb 100644 --- a/frontend/src/app/pages/location/location.component.ts +++ b/frontend/src/app/pages/location/location.component.ts @@ -9,7 +9,7 @@ const DUMMY_LOCATIONS = [ name: 'Konjicki klub "Smet"', address: 'Smetovi bb', type: 'Zooloski vrt', - image: 'https://images.pexels.com/photos/808465/pexels-photo-808465.jpeg', + image: '/assets/images/smet.jpg', }, { id: 2, @@ -17,7 +17,7 @@ const DUMMY_LOCATIONS = [ address: 'Smetovi bb', type: 'Restoran', image: - 'https://images.pexels.com/photos/552785/pexels-photo-552785.jpeg?auto=compress&cs=tinysrgb&w=1260&h=750&dpr=2', + '/assets/images/restoran_360.jpg', }, ]; diff --git a/frontend/src/assets/images/dom_saveza_izvidaca_i_radioamatera.jpg b/frontend/src/assets/images/dom_saveza_izvidaca_i_radioamatera.jpg new file mode 100644 index 0000000..1fc6305 Binary files /dev/null and b/frontend/src/assets/images/dom_saveza_izvidaca_i_radioamatera.jpg differ diff --git a/frontend/src/assets/images/restoran_360.jpg b/frontend/src/assets/images/restoran_360.jpg new file mode 100644 index 0000000..b810772 Binary files /dev/null and b/frontend/src/assets/images/restoran_360.jpg differ diff --git a/frontend/src/assets/images/hero-section.jpg b/frontend/src/assets/images/spomenik.jpg similarity index 100% rename from frontend/src/assets/images/hero-section.jpg rename to frontend/src/assets/images/spomenik.jpg