diff --git a/backend/Api/BusinessLogic/UserLogic.cs b/backend/Api/BusinessLogic/UserLogic.cs index 77b1800..1e8b282 100644 --- a/backend/Api/BusinessLogic/UserLogic.cs +++ b/backend/Api/BusinessLogic/UserLogic.cs @@ -75,12 +75,6 @@ namespace Api.BusinessLogic public async Task EditProfile(EditUserRequest userRequest, int userId) { - if (!new Regex(@".+@.+\..+").IsMatch(userRequest.Email)) - { - return new ConflictObjectResult(new { message = "Invalid email address" }); - } - - return await _dbAccess.UpdateUser(userRequest, userId); } diff --git a/backend/Api/DBAccess/DBAccess.cs b/backend/Api/DBAccess/DBAccess.cs index e550f11..aa51634 100644 --- a/backend/Api/DBAccess/DBAccess.cs +++ b/backend/Api/DBAccess/DBAccess.cs @@ -91,9 +91,13 @@ namespace Api.DBAccess } } - profile.UserName = user.UserName; + if(user.Email != "" && user.Email != null) + profile.Email = user.Email; + + if (user.UserName != "" && user.UserName != null) + profile.UserName = user.UserName; + - profile.Email = user.Email; bool saved = await _context.SaveChangesAsync() == 1; diff --git a/frontend/devices/index.html b/frontend/devices/index.html index e69de29..282e280 100644 --- a/frontend/devices/index.html +++ b/frontend/devices/index.html @@ -0,0 +1,36 @@ + + + + + + Temperature-Alarm-Web + + + + + + + + +
+
+ Home + Devices +
+ Profile + + + +
+
+ + + + + + + +
IdPlacementLatest Meassurement
+
+ + diff --git a/frontend/home/index.html b/frontend/home/index.html index fec875b..1072dd0 100644 --- a/frontend/home/index.html +++ b/frontend/home/index.html @@ -8,15 +8,19 @@ +
diff --git a/frontend/img/logout.png b/frontend/img/logout.png new file mode 100644 index 0000000..e493049 Binary files /dev/null and b/frontend/img/logout.png differ diff --git a/frontend/login/index.html b/frontend/login/index.html index 171130f..914597a 100644 --- a/frontend/login/index.html +++ b/frontend/login/index.html @@ -20,9 +20,6 @@
- Dont have an account? Register diff --git a/frontend/profile/index.html b/frontend/profile/index.html index a5752d3..1fb7dc1 100644 --- a/frontend/profile/index.html +++ b/frontend/profile/index.html @@ -7,14 +7,18 @@ +
- Home + Home + Devices
- Devices - Profile + Profile + + +
@@ -32,10 +36,10 @@
- + - + diff --git a/frontend/register/index.html b/frontend/register/index.html index 666fe02..94e358c 100644 --- a/frontend/register/index.html +++ b/frontend/register/index.html @@ -10,7 +10,7 @@
-

Create Account

+

Sign Up

diff --git a/frontend/scripts/devices.js b/frontend/scripts/devices.js new file mode 100644 index 0000000..821c1c0 --- /dev/null +++ b/frontend/scripts/devices.js @@ -0,0 +1,26 @@ +import { getDevicesOnUserId } from "./services/devices.service.js"; + +let idlocation = localStorage.getItem("rememberLogin") +let id; +if(idlocation){ + id = localStorage.getItem("id"); +} +else{ + id = localStorage.getItem("id"); +} +getDevicesOnUserId(id).then(res => { + buildTable(res) +}) + + +function buildTable(data) { + var table = document.getElementById(`deviceTable`); + data.forEach((device) => { + var row = ` + Name + ${device.id} + ${device.name} + `; + table.innerHTML += row; + }); + } \ No newline at end of file diff --git a/frontend/scripts/home.js b/frontend/scripts/home.js index 8538bbb..912ffa0 100644 --- a/frontend/scripts/home.js +++ b/frontend/scripts/home.js @@ -61,24 +61,4 @@ function buildTable(data) { `; table.innerHTML += row; }); -} - -// Get the modal -var modal = document.getElementById("chartModal"); -var btn = document.getElementById("myBtn"); -var span = document.getElementsByClassName("close")[0]; -btn.onclick = function () { - modal.style.display = "block"; -}; - -// When the user clicks on (x), close the modal -span.onclick = function () { - modal.style.display = "none"; -}; - -// When the user clicks anywhere outside of the modal, close it -window.onclick = function (event) { - if (event.target == modal) { - modal.style.display = "none"; - } -}; +} \ No newline at end of file diff --git a/frontend/scripts/login.js b/frontend/scripts/login.js index 2348cd0..5d661d5 100644 --- a/frontend/scripts/login.js +++ b/frontend/scripts/login.js @@ -17,15 +17,7 @@ document.getElementById("loginForm").addEventListener("submit", function(event) } else{ if (typeof(Storage) !== "undefined") { - if(document.getElementById("rememberId").checked == true){ - localStorage.setItem("id", response.id); - localStorage.setItem("rememberLogin", true); - } - else{ - localStorage.setItem("rememberLogin", false); - sessionStorage.setItem("id", response.id); - } - + localStorage.setItem("id", response.id); } } diff --git a/frontend/scripts/profile.js b/frontend/scripts/profile.js index 3e28c13..9587ac4 100644 --- a/frontend/scripts/profile.js +++ b/frontend/scripts/profile.js @@ -3,14 +3,8 @@ import { get } from "./services/users.service.js"; import { update } from "./services/users.service.js"; import { updatePassword } from "./services/users.service.js"; -let idlocation = localStorage.getItem("rememberLogin") -let id; -if(idlocation){ - id = localStorage.getItem("id"); -} -else{ - id = localStorage.getItem("id"); -} +let id = localStorage.getItem("id"); + get(id).then(res => { var table = document.getElementById(`profileCard`); table.innerHTML += ` @@ -40,6 +34,8 @@ document.querySelectorAll(".close").forEach(closeBtn => { closeBtn.onclick = () => { pswModal.style.display = "none"; editModal.style.display = "none"; + document.getElementById("form-error").innerText = ""; + document.getElementById("form-error").style.display = "none"; }; }); diff --git a/frontend/scripts/services/devices.service.js b/frontend/scripts/services/devices.service.js index b2b18d8..bcef00a 100644 --- a/frontend/scripts/services/devices.service.js +++ b/frontend/scripts/services/devices.service.js @@ -1,12 +1,11 @@ -import { address } from "../../shared/constants"; +import { address } from "../../shared/constants.js"; -export function getDevicesOnUserId(id) { - fetch(`${address}/get-on-user-id`, { +export function getDevicesOnUserId(userId) { + fetch(`${address}/device/${userId}`, { method: "GET", headers: { "Content-Type": "application/json" }, - body: JSON.stringify({ id: id }) }) .then(response => response.json()) .then(data => console.log("Success:", data)) diff --git a/frontend/shared/utils.js b/frontend/shared/utils.js index 419b3c0..fa13ce0 100644 --- a/frontend/shared/utils.js +++ b/frontend/shared/utils.js @@ -10,3 +10,9 @@ export async function handleResponse(response) { return { error: "Request failed with HTTP code " + response.status }; } +document.querySelectorAll(".logoutContainer").forEach(closeBtn => { + closeBtn.onclick = () => { + localStorage.clear(); + window.location.href = "/index.html"; + }; +}); diff --git a/frontend/styles/auth.css b/frontend/styles/auth.css index 47b65ea..0ce6579 100644 --- a/frontend/styles/auth.css +++ b/frontend/styles/auth.css @@ -9,6 +9,7 @@ body { } .topnav a { + height: 20px; float: left; color: #f2f2f2; text-align: center; @@ -17,15 +18,16 @@ body { font-size: 17px; } - .topnav a:hover { + .topnav a:hover, .topnav span:hover { background-color: #ddd; color: black; - } - - .topnav a.active { + cursor: pointer; +} + +.topnav a.active { background-color: #04aa6d; color: white; - } +} /* Full-width input fields */ input[type=text], input[type=password], input[type=email] { @@ -60,7 +62,7 @@ button:hover { .details { display: flex; - justify-content: space-between; + justify-content: flex-end; margin-top: 0.5rem; } @@ -74,3 +76,15 @@ button:hover { margin-top: 1rem; } +.logoutContainer{ + display: flex; + justify-content: center; + align-items: center; + width: 50px; +} + +.logout{ + width: 20px; + height: 24px; +} + diff --git a/frontend/styles/devices.css b/frontend/styles/devices.css new file mode 100644 index 0000000..e69de29