changed frontend structure
This commit is contained in:
parent
6e1aef1dc2
commit
dc82267cbc
1
frontend/index.html
Normal file
1
frontend/index.html
Normal file
@ -0,0 +1 @@
|
|||||||
|
<meta http-equiv="refresh" content="0; url=/pages/login.html" />
|
@ -33,6 +33,6 @@
|
|||||||
</table>
|
</table>
|
||||||
</div>
|
</div>
|
||||||
</body>
|
</body>
|
||||||
<link rel="stylesheet" href="home.css" />
|
<link rel="stylesheet" href="/styles/home.css" />
|
||||||
<script type="module" src="home.js"></script>
|
<script type="module" src="/scripts/home.js"></script>
|
||||||
</html>
|
</html>
|
@ -23,14 +23,14 @@
|
|||||||
<input type="checkbox" name="remember"> Remember me
|
<input type="checkbox" name="remember"> Remember me
|
||||||
</label>
|
</label>
|
||||||
<label>
|
<label>
|
||||||
Dont have an account? <a href="../register/register.html">Register</a>
|
Dont have an account? <a href="./login.html">Register</a>
|
||||||
</label>
|
</label>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</form>
|
</form>
|
||||||
</div>
|
</div>
|
||||||
</body>
|
</body>
|
||||||
<link rel="stylesheet" href="login.css">
|
<link rel="stylesheet" href="/styles/login.css">
|
||||||
<script type="module" src="login.js"></script>
|
<script type="module" src="/scripts/login.js"></script>
|
||||||
|
|
||||||
</html>
|
</html>
|
@ -25,7 +25,7 @@
|
|||||||
<button type="submit">Register</button>
|
<button type="submit">Register</button>
|
||||||
<div class="loginText">
|
<div class="loginText">
|
||||||
<label>
|
<label>
|
||||||
Already have an account? <a href="../login/login.html">Login</a>
|
Already have an account? <a href="./home.html">Login</a>
|
||||||
</label>
|
</label>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@ -33,7 +33,7 @@
|
|||||||
</div>
|
</div>
|
||||||
</body>
|
</body>
|
||||||
|
|
||||||
<link rel="stylesheet" href="register.css">
|
<link rel="stylesheet" href="/styles/register.css">
|
||||||
<script type="module" src="register.js"></script>
|
<script type="module" src="/scripts/register.js"></script>
|
||||||
|
|
||||||
</html>
|
</html>
|
@ -1,4 +1,4 @@
|
|||||||
import { mockTemperatureLogs } from "../../mockdata/temperature-logs.mockdata.js"; // Import data
|
import { mockTemperatureLogs } from "../mockdata/temperature-logs.mockdata.js"; // Import data
|
||||||
|
|
||||||
const xValues = mockTemperatureLogs.map((log) =>
|
const xValues = mockTemperatureLogs.map((log) =>
|
||||||
new Date(log.date).toLocaleString()
|
new Date(log.date).toLocaleString()
|
@ -1,13 +1,10 @@
|
|||||||
import { login } from "../../services/users.service.js";
|
import { login } from "./services/users.service.js";
|
||||||
|
|
||||||
document.getElementById("loginForm").addEventListener("submit", function(event) {
|
document.getElementById("loginForm").addEventListener("submit", function(event) {
|
||||||
event.preventDefault(); // Prevents default form submission
|
event.preventDefault();
|
||||||
|
|
||||||
// Get form values
|
|
||||||
const emailOrUsername = document.getElementById("emailorusn").value;
|
const emailOrUsername = document.getElementById("emailorusn").value;
|
||||||
const password = document.getElementById("psw").value;
|
const password = document.getElementById("psw").value;
|
||||||
|
|
||||||
|
|
||||||
// Call function with form values
|
|
||||||
login(emailOrUsername, password);
|
login(emailOrUsername, password);
|
||||||
});
|
});
|
@ -1,6 +1,6 @@
|
|||||||
const address = "http://10.135.51.116/temperature-alarm-webapi/devices"
|
import { address } from "../../shared/constants";
|
||||||
|
|
||||||
function getDevicesOnUserId(id) {
|
export function getDevicesOnUserId(id) {
|
||||||
fetch(`${address}/get-on-user-id`, {
|
fetch(`${address}/get-on-user-id`, {
|
||||||
method: "GET",
|
method: "GET",
|
||||||
headers: {
|
headers: {
|
||||||
@ -13,7 +13,7 @@ function getDevicesOnUserId(id) {
|
|||||||
.catch(error => console.error("Error:", error));
|
.catch(error => console.error("Error:", error));
|
||||||
}
|
}
|
||||||
|
|
||||||
function update(ids) {
|
export function update(ids) {
|
||||||
fetch(`${address}/get-on-user-id`, {
|
fetch(`${address}/get-on-user-id`, {
|
||||||
method: "PATCH",
|
method: "PATCH",
|
||||||
headers: {
|
headers: {
|
||||||
@ -24,4 +24,17 @@ function update(ids) {
|
|||||||
.then(response => response.json())
|
.then(response => response.json())
|
||||||
.then(data => console.log("Success:", data))
|
.then(data => console.log("Success:", data))
|
||||||
.catch(error => console.error("Error:", error));
|
.catch(error => console.error("Error:", error));
|
||||||
|
}
|
||||||
|
|
||||||
|
export function getLogsOnDeviceIds(id) {
|
||||||
|
fetch(`${address}/get-on-device-ids`, {
|
||||||
|
method: "GET",
|
||||||
|
headers: {
|
||||||
|
"Content-Type": "application/json"
|
||||||
|
},
|
||||||
|
body: JSON.stringify({ ids: id })
|
||||||
|
})
|
||||||
|
.then(response => response.json())
|
||||||
|
.then(data => console.log("Success:", data))
|
||||||
|
.catch(error => console.error("Error:", error));
|
||||||
}
|
}
|
@ -1,10 +1,11 @@
|
|||||||
const address = "http://10.135.51.116/temperature-alarm-webapi/users"
|
import { address } from "../../shared/constants";
|
||||||
|
|
||||||
|
|
||||||
export function login(usernameOrEmail, password) {
|
export function login(usernameOrEmail, password) {
|
||||||
console.log(usernameOrEmail);
|
console.log(usernameOrEmail);
|
||||||
console.log(password);
|
console.log(password);
|
||||||
|
|
||||||
fetch(`${address}/login`, {
|
fetch(`${address}/user/login`, {
|
||||||
method: "POST",
|
method: "POST",
|
||||||
headers: {
|
headers: {
|
||||||
"Content-Type": "application/json"
|
"Content-Type": "application/json"
|
||||||
@ -17,7 +18,7 @@ export function login(usernameOrEmail, password) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export function create(email, username, password, repeatPassword){
|
export function create(email, username, password, repeatPassword){
|
||||||
fetch(`${address}/create`, {
|
fetch(`${address}/user/create`, {
|
||||||
method: "POST",
|
method: "POST",
|
||||||
headers: {
|
headers: {
|
||||||
"Content-Type": "application/json"
|
"Content-Type": "application/json"
|
||||||
@ -29,8 +30,8 @@ export function create(email, username, password, repeatPassword){
|
|||||||
.catch(error => console.error("Error:", error));
|
.catch(error => console.error("Error:", error));
|
||||||
}
|
}
|
||||||
|
|
||||||
export function update(email, username, password){
|
function update(email, username, password){
|
||||||
fetch(`${address}/update`, {
|
fetch(`${address}/user/update`, {
|
||||||
method: "PATCH",
|
method: "PATCH",
|
||||||
headers: {
|
headers: {
|
||||||
"Content-Type": "application/json"
|
"Content-Type": "application/json"
|
@ -1,14 +0,0 @@
|
|||||||
const address = "http://10.135.51.116/temperature-alarm-webapi/temperature-logs"
|
|
||||||
|
|
||||||
function getOnDeviceIds(ids) {
|
|
||||||
fetch(`${address}/get-on-device-ids`, {
|
|
||||||
method: "GET",
|
|
||||||
headers: {
|
|
||||||
"Content-Type": "application/json"
|
|
||||||
},
|
|
||||||
body: JSON.stringify({ ids: ids })
|
|
||||||
})
|
|
||||||
.then(response => response.json())
|
|
||||||
.then(data => console.log("Success:", data))
|
|
||||||
.catch(error => console.error("Error:", error));
|
|
||||||
}
|
|
1
frontend/shared/constants.js
Normal file
1
frontend/shared/constants.js
Normal file
@ -0,0 +1 @@
|
|||||||
|
export const address = "hhttps://temperature.mercantec.tech/api"
|
Loading…
Reference in New Issue
Block a user