Skip to content

Commit

Permalink
Merge branch 'master' of https://github.com/cbolles/brick-hack-vi
Browse files Browse the repository at this point in the history
  • Loading branch information
cbolles committed Feb 9, 2020
2 parents 90074d4 + a5ea101 commit 5bd018c
Show file tree
Hide file tree
Showing 9 changed files with 227 additions and 2 deletions.
45 changes: 43 additions & 2 deletions server/server/main.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,51 @@
from flask import Flask
from flask import Flask, request, Response, render_template

app = Flask(__name__)


@app.route('/')
def hello_world():
return 'Hello, World!'
return render_template('WMAskStudent.html')


@app.route('/Settings.html')
def hello_universe():
return render_template('Settings.html')


@app.route('/Settings/Timer.html')
def hello_galaxy():
return render_template('Timer.html')


@app.route('/Settings/Timer/NotificationWasher.html')
def hello_milky_way():
return render_template('NotificationWasher.html')




@app.route('/washer/user_interaction', methods=['POST'])
def handle_washer_interaction():
"""
Handles when a user interacts with a washing machine. Updates the status of the washing machine
and the number of available washers. Expects information passed in like so.
{
"washer_id": int,
"user_id": int,
"washer_status": int,
"time_remaining": long (time in seconds, -1 if not applicable)
}
"""
data = request.get_json()
print(data['washer_id'])
washer_id = data['washer_id']
user_id = data['user_id']
washer_status = data['washer_status']
time_remaining = data['time_remaining']
print('Washer: {}, By, {}, In state: {}, With {} remaining', washer_id, user_id, washer_status,
time_remaining)
return Response(status=200)


if __name__ == '__main__':
Expand Down
Binary file added server/server/static/OpenWM.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added server/server/static/washing machine.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
25 changes: 25 additions & 0 deletions server/server/templates/MainPage.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>RIT Laundry Services</title>

</head>
<body style="background-color:#ffd1b3;">
<center>
<h1> Welcome to RIT Laundry Services </h1>
<form action="/WMaskStudent" target="_blank" method="GET">
<fieldset>
<legend>Select one of the machines you want to use:</legend>
<div>
<a href="WMaskStudent.html"><button>Washing Machine</button></a>
<button>Drying Machine</button>
</div>
</fieldset>
</form>
</center>

<img src="/static/washing machine.png" alt="Washing Machine"/>

</body>
</html>
15 changes: 15 additions & 0 deletions server/server/templates/NotificationWasher.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>WasherNotification</title>
</head>
<body style="background-color:#ffd1b3;">
<center>
<h1> Washing machine is done!</h1>
<br>
<h1>Please, come take your cloth out of the washing machine!</h1>
</center>

</body>
</html>
66 changes: 66 additions & 0 deletions server/server/templates/Settings.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Settings</title>
</head>
<body style="background-color:#ffd1b3;">
<center>
<h1 style="font-family:verdana;">Choose Your Settings</h1>
</center>
<form action="/Settings/Timer.html" target="_blank" method="GET">
<form>
<fieldset>
<legend>Temperature:</legend>
<div>
<input type="radio" name="temp" value="cold"> Cold <br>
<input type="radio" name="temp" value="warm"> Warm <br>
<input type="radio" name="temp" value="hot"> Hot <br>
</div>
</fieldset>
</form>
<br>
<br>
<form>
<fieldset>
<legend>Soil Level:</legend>
<div>
<input type="radio" name="temp" value="low"> Low <br>
<input type="radio" name="temp" value="medium"> Medium <br>
<input type="radio" name="temp" value="high"> High <br>
</div>
</fieldset>
</form>
<br>
<br>
<form>
<fieldset>
<legend>Spin Speed:</legend>
<div>
<input type="radio" name="temp" value="low"> Low <br>
<input type="radio" name="temp" value="medium"> Medium <br>
<input type="radio" name="temp" value="high"> High <br>
</div>
</fieldset>
</form>
<br>
<br>
<form>
<fieldset>
<legend>Present Cycles:</legend>
<div>
<input type="radio" name="temp" value="heavyduty"> Heavy Duty <br>
<input type="radio" name="temp" value="normaleco"> Normal Eco <br>
<input type="radio" name="temp" value="delicat"> Delicate <br>
<input type="radio" name="temp" value="permpress"> Perm Press <br>
<input type="radio" name="temp" value="rinsespin"> Rinse & Spin <br>
<input type="radio" name="temp" value="spin"> Spin <br>
</div>
</fieldset>
</form>
<br>
<br>
<a href="/Settings/Timer.html"><button>Start</button></a>
</form>
</body>
</html>
45 changes: 45 additions & 0 deletions server/server/templates/Timer.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>WasherTimer</title>
</head>
<body style="background-color:#ffd1b3;" style="font-size:large">
<form action="/Settings/Timer/NotificationWasher.html" target="_blank" method="GET">
<p id="demo"></p>

<script>
// Set the date we're counting down to
var countDownDate = new Date("Feb 8, 2020 19:05:25").getTime();

// Update the count down every 1 second
var x = setInterval(function() {

// Get today's date and time
var now = new Date().getTime();

// Find the distance between now and the count down date
var distance = countDownDate - now;

// Time calculations for days, hours, minutes and seconds
var days = Math.floor(distance / (1000 * 60 * 60 * 24));
var hours = Math.floor((distance % (1000 * 60 * 60 * 24)) / (1000 * 60 * 60));
var minutes = Math.floor((distance % (1000 * 60 * 60)) / (1000 * 60));
var seconds = Math.floor((distance % (1000 * 60)) / 1000);

// Output the result in an element with id="demo"
document.getElementById("demo").innerHTML = days + "d " + hours + "h "
+ minutes + "m " + seconds + "s ";

// If the count down is over, write some text
if (distance < 0) {
clearInterval(x);
document.getElementById("demo").innerHTML = "EXPIRED";
setTimeout("location.href = '/Settings/Timer/NotificationWasher.html';", 1000);

}
}, 1000);
</script>
</form>
</body>
</html>
13 changes: 13 additions & 0 deletions server/server/templates/WMUnavailable.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<!DOCTYPE html>
<head>
<title>RIT Laundry Services</title>
</head>
<body style="background-color:#ffd1b3;">

<h1>Welcome to RIT's Laundry Services</h1>
<h2>No washing Machines are available at this time.</h2>
<p>The next available washing machine will finish it's cycle in: 06:23 minutes</p>
<img src="/static/washing machine.png" alt="Washing Machine"/>

</body>
</html>
20 changes: 20 additions & 0 deletions server/server/templates/WMaskStudent.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
<!DOCTYPE html>
<html lang="en">
<head>
<title>RIT Laundry Services</title>
</head>
<body style="background-color:#ffd1b3;">
<h1>Washing Machines </h1>
<img src="/static/OpenWM.png" alt="Washing Machine"/>
<form action="/Settings.html" target="_blank" method="GET">
<fieldset>
<legend>Available washing machines are:</legend>
<input type="radio" name="number" value="machine1" > Washing Machine 1<br>
<input type="radio" name="number" value="machine2" > Washing Machine 2<br>
<input type="radio" name="number" value="machine3" > Washing Machine 3<br>
<input type="radio" name="number" value="machine4" > Washing Machine 4<br>
<a href="Settings.html"><button>Next</button></a>
</fieldset>
</form>
</body>
</html>

0 comments on commit 5bd018c

Please sign in to comment.