Skip to content

Commit 5a24976

Browse files
committed
add mock dustbin
1 parent f590e80 commit 5a24976

File tree

5 files changed

+71
-7
lines changed

5 files changed

+71
-7
lines changed

mobileFrontend/hackfestwebsite/yarn.lock

-7
Original file line numberDiff line numberDiff line change
@@ -32,13 +32,6 @@
3232
minimatch "^3.1.2"
3333
strip-json-comments "^3.1.1"
3434

35-
"@fortawesome/react-fontawesome@^0.2.0":
36-
version "0.2.0"
37-
resolved "https://registry.npmjs.org/@fortawesome/react-fontawesome/-/react-fontawesome-0.2.0.tgz"
38-
integrity sha512-uHg75Rb/XORTtVt7OS9WoK8uM276Ufi7gCzshVWkUJbHhh3svsUUeqXerrM96Wm7fRiDzfKRwSoahhMIkGAYHw==
39-
dependencies:
40-
prop-types "^15.8.1"
41-
4235
"@headlessui/react@^1.6.6":
4336
version "1.6.6"
4437
resolved "https://registry.npmjs.org/@headlessui/react/-/react-1.6.6.tgz"

mock-dustbin/close.png

91.7 KB
Loading

mock-dustbin/index.html

+71
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
<!DOCTYPE html>
2+
<html lang="en">
3+
<head>
4+
<meta charset="UTF-8">
5+
<meta http-equiv="X-UA-Compatible" content="IE=edge">
6+
<meta name="viewport" content="width=device-width, initial-scale=1.0">
7+
<title>Mock Dustbin</title>
8+
</head>
9+
<style>
10+
.dustbin-area {
11+
text-align: center;
12+
}
13+
.opened-dustbin {
14+
display: none;
15+
}
16+
.message {
17+
background-color: antiquewhite;
18+
font-size: 40px;
19+
text-align: center;
20+
}
21+
</style>
22+
<body>
23+
<div class="dustbin-area">
24+
<img src="open.png" class="opened-dustbin">
25+
<img src="close.png" class="closed-dustbin">
26+
</div>
27+
<div class="message">closed</div>
28+
<script>
29+
let val = 0.1;
30+
setInterval(() => {
31+
let dustbin_state = "close";
32+
fetch("http://solanabin.pythonanywhere.com/should_open_dustbin/1a77d81f-4ed4-45f0-bdf6-c8980cbfac1e/")
33+
.then((response) => response.json())
34+
.then((data) => {
35+
dustbin_state = data.data;
36+
console.log(dustbin_state);
37+
38+
let opened_dustbin = document.querySelector('.opened-dustbin');
39+
let message = document.querySelector('.message');
40+
let closed_dustbin = document.querySelector('.closed-dustbin');
41+
if(dustbin_state == "close") {
42+
opened_dustbin.style.display = "none";
43+
closed_dustbin.style.display = "block";
44+
message.innerHTML = "Dustbin Closed"
45+
}
46+
if(dustbin_state == "open") {
47+
opened_dustbin.style.display = "block";
48+
closed_dustbin.style.display = "none";
49+
message.innerHTML = "Dustbin Opened. Adding Mock weight of 0.1 kg and sending";
50+
51+
const data_to_send = fetch('http://solanabin.pythonanywhere.com/unit_value_history/1a77d81f-4ed4-45f0-bdf6-c8980cbfac1e/', {
52+
method: 'POST',
53+
headers: {
54+
'Accept': 'application/json',
55+
'Content-Type': 'application/json'
56+
},
57+
body: JSON.stringify({"weight_value": val + "", "height_value": "2", "redeemed": false})
58+
}).then((resp) => {
59+
val += 0.1;
60+
// finnaly close the dustbin
61+
return resp.json();
62+
}).then((data) => {
63+
fetch("http://solanabin.pythonanywhere.com/close_dustbin/1a77d81f-4ed4-45f0-bdf6-c8980cbfac1e/").then((rep) => console.log(rep.json()));
64+
console.log(data);
65+
});
66+
}
67+
});
68+
},8000);
69+
</script>
70+
</body>
71+
</html>

mock-dustbin/index.js

Whitespace-only changes.

mock-dustbin/open.png

113 KB
Loading

0 commit comments

Comments
 (0)