frontend init: made services
This commit is contained in:
parent
505fc1912c
commit
87a0df65f7
0
frontend/home/home.css
Normal file
0
frontend/home/home.css
Normal file
11
frontend/home/home.html
Normal file
11
frontend/home/home.html
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
<!DOCTYPE html>
|
||||||
|
<html lang="en">
|
||||||
|
<head>
|
||||||
|
<meta charset="UTF-8">
|
||||||
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||||
|
<title>Temperature-Alarm-Web</title>
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<h3>hello</h3>
|
||||||
|
</body>
|
||||||
|
</html>
|
0
frontend/home/home.js
Normal file
0
frontend/home/home.js
Normal file
27
frontend/services/devices.service.js
Normal file
27
frontend/services/devices.service.js
Normal file
@ -0,0 +1,27 @@
|
|||||||
|
const address = "http://10.135.51.116/temperature-alarm-webapi/devices"
|
||||||
|
|
||||||
|
function getDevicesOnUserId(id) {
|
||||||
|
fetch(`${address}/get-on-user-id`, {
|
||||||
|
method: "GET",
|
||||||
|
headers: {
|
||||||
|
"Content-Type": "application/json"
|
||||||
|
},
|
||||||
|
body: JSON.stringify({ id: id })
|
||||||
|
})
|
||||||
|
.then(response => response.json())
|
||||||
|
.then(data => console.log("Success:", data))
|
||||||
|
.catch(error => console.error("Error:", error));
|
||||||
|
}
|
||||||
|
|
||||||
|
function update(ids) {
|
||||||
|
fetch(`${address}/get-on-user-id`, {
|
||||||
|
method: "PATCH",
|
||||||
|
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));
|
||||||
|
}
|
14
frontend/services/temperature-logs.service.js
Normal file
14
frontend/services/temperature-logs.service.js
Normal file
@ -0,0 +1,14 @@
|
|||||||
|
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));
|
||||||
|
}
|
40
frontend/services/users.service.js
Normal file
40
frontend/services/users.service.js
Normal file
@ -0,0 +1,40 @@
|
|||||||
|
const address = "http://10.135.51.116/temperature-alarm-webapi/users"
|
||||||
|
|
||||||
|
function login(username, password) {
|
||||||
|
fetch(`${address}/login`, {
|
||||||
|
method: "POST",
|
||||||
|
headers: {
|
||||||
|
"Content-Type": "application/json"
|
||||||
|
},
|
||||||
|
body: JSON.stringify({username: username, password: password})
|
||||||
|
})
|
||||||
|
.then(response => response.json())
|
||||||
|
.then(data => console.log("Success:", data))
|
||||||
|
.catch(error => console.error("Error:", error));
|
||||||
|
}
|
||||||
|
|
||||||
|
function create(email, username, password){
|
||||||
|
fetch(`${address}/create`, {
|
||||||
|
method: "POST",
|
||||||
|
headers: {
|
||||||
|
"Content-Type": "application/json"
|
||||||
|
},
|
||||||
|
body: JSON.stringify({email: email, username: username, password: password})
|
||||||
|
})
|
||||||
|
.then(response => response.json())
|
||||||
|
.then(data => console.log("Success:", data))
|
||||||
|
.catch(error => console.error("Error:", error));
|
||||||
|
}
|
||||||
|
|
||||||
|
function update(email, username, password){
|
||||||
|
fetch(`${address}/update`, {
|
||||||
|
method: "PATCH",
|
||||||
|
headers: {
|
||||||
|
"Content-Type": "application/json"
|
||||||
|
},
|
||||||
|
body: JSON.stringify({email: email, username: username, password: password})
|
||||||
|
})
|
||||||
|
.then(response => response.json())
|
||||||
|
.then(data => console.log("Success:", data))
|
||||||
|
.catch(error => console.error("Error:", error));
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user