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>
|
||||
</div>
|
||||
</body>
|
||||
<link rel="stylesheet" href="home.css" />
|
||||
<script type="module" src="home.js"></script>
|
||||
<link rel="stylesheet" href="/styles/home.css" />
|
||||
<script type="module" src="/scripts/home.js"></script>
|
||||
</html>
|
@ -23,14 +23,14 @@
|
||||
<input type="checkbox" name="remember"> Remember me
|
||||
</label>
|
||||
<label>
|
||||
Dont have an account? <a href="../register/register.html">Register</a>
|
||||
Dont have an account? <a href="./login.html">Register</a>
|
||||
</label>
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
</body>
|
||||
<link rel="stylesheet" href="login.css">
|
||||
<script type="module" src="login.js"></script>
|
||||
<link rel="stylesheet" href="/styles/login.css">
|
||||
<script type="module" src="/scripts/login.js"></script>
|
||||
|
||||
</html>
|
@ -25,7 +25,7 @@
|
||||
<button type="submit">Register</button>
|
||||
<div class="loginText">
|
||||
<label>
|
||||
Already have an account? <a href="../login/login.html">Login</a>
|
||||
Already have an account? <a href="./home.html">Login</a>
|
||||
</label>
|
||||
</div>
|
||||
</div>
|
||||
@ -33,7 +33,7 @@
|
||||
</div>
|
||||
</body>
|
||||
|
||||
<link rel="stylesheet" href="register.css">
|
||||
<script type="module" src="register.js"></script>
|
||||
<link rel="stylesheet" href="/styles/register.css">
|
||||
<script type="module" src="/scripts/register.js"></script>
|
||||
|
||||
</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) =>
|
||||
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) {
|
||||
event.preventDefault(); // Prevents default form submission
|
||||
event.preventDefault();
|
||||
|
||||
// Get form values
|
||||
const emailOrUsername = document.getElementById("emailorusn").value;
|
||||
const password = document.getElementById("psw").value;
|
||||
|
||||
|
||||
// Call function with form values
|
||||
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`, {
|
||||
method: "GET",
|
||||
headers: {
|
||||
@ -13,7 +13,7 @@ function getDevicesOnUserId(id) {
|
||||
.catch(error => console.error("Error:", error));
|
||||
}
|
||||
|
||||
function update(ids) {
|
||||
export function update(ids) {
|
||||
fetch(`${address}/get-on-user-id`, {
|
||||
method: "PATCH",
|
||||
headers: {
|
||||
@ -24,4 +24,17 @@ function update(ids) {
|
||||
.then(response => response.json())
|
||||
.then(data => console.log("Success:", data))
|
||||
.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) {
|
||||
console.log(usernameOrEmail);
|
||||
console.log(password);
|
||||
|
||||
fetch(`${address}/login`, {
|
||||
fetch(`${address}/user/login`, {
|
||||
method: "POST",
|
||||
headers: {
|
||||
"Content-Type": "application/json"
|
||||
@ -17,7 +18,7 @@ export function login(usernameOrEmail, password) {
|
||||
}
|
||||
|
||||
export function create(email, username, password, repeatPassword){
|
||||
fetch(`${address}/create`, {
|
||||
fetch(`${address}/user/create`, {
|
||||
method: "POST",
|
||||
headers: {
|
||||
"Content-Type": "application/json"
|
||||
@ -29,8 +30,8 @@ export function create(email, username, password, repeatPassword){
|
||||
.catch(error => console.error("Error:", error));
|
||||
}
|
||||
|
||||
export function update(email, username, password){
|
||||
fetch(`${address}/update`, {
|
||||
function update(email, username, password){
|
||||
fetch(`${address}/user/update`, {
|
||||
method: "PATCH",
|
||||
headers: {
|
||||
"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