Skip to content

Commit

Permalink
Cleaned up some debug comments, fixed issue #2 by implementing the la…
Browse files Browse the repository at this point in the history
…nding.html template, started writing the header nav and added styling for the week and day views.
  • Loading branch information
mandagill committed Mar 17, 2015
1 parent b37b384 commit e3718d7
Show file tree
Hide file tree
Showing 8 changed files with 155 additions and 29 deletions.
8 changes: 6 additions & 2 deletions bioretro.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,12 @@ def get_token():
return render_template('okauth.html')


@app.route('/landing')
def go_to_landing():
# Interstitial landing page fixes issue #2
return render_template('landing.html')


@app.route('/fetch_data')
def fetch_data():

Expand Down Expand Up @@ -82,8 +88,6 @@ def get_week_number():
week_num = week_num_int - 1
session['week_viewing'] = week_num

print "here's the week num in session: ", session['week_viewing']

return str(week_num)


Expand Down
13 changes: 8 additions & 5 deletions data_filter.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,16 @@ def check_for_new_bpm():
latest_timestamp = int(latest_datapoint.end_time)
now_in_nanotime = nanotime.now()

# If the timestamp on the most recent datapoint is more than a day old, call Google for updated data
if latest_timestamp < (int(nanotime.now()) - DAY_IN_NANOSECS):
endbound = str(int(nanotime.now())) # Get now in nanotime for the endbound of the dataset
new_data = foa.fetch_data(data_type='bpm', startbound=latest_datapoint.end_time, endbound=endbound)

try:
data_dict = json.loads(new_data)
except:
print "This is what new_data looks like: ", new_data

data_point_store.save_to_db(new_data)
return True
else:
Expand Down Expand Up @@ -121,8 +128,7 @@ def format_data_week(list_of_points):
continue
else:
week_info[k] = False

print week_info

return week_info


Expand Down Expand Up @@ -161,7 +167,6 @@ def render_data(week_number):
# Go get an ordered list of dates for the given week for sorting the data:
sort_keys = generate_days_index(int(week_number))

print "these are the sort keys being returned:", sort_keys
return sort_keys, one_weeks_data


Expand Down Expand Up @@ -214,8 +219,6 @@ def format_data_day(day_string):
else:
pass


print "This is the days data dict: ", to_display
return to_display


Expand Down
53 changes: 50 additions & 3 deletions static/style.css
Original file line number Diff line number Diff line change
@@ -1,15 +1,62 @@

body {
background-color: #FFFCF3;
font-family: 'Varela Round', sans-serif;
}

.day-in-week {
height: 200px;
width: 200px;
border-color: #7e7e7e;
border-width: 5px;
border-radius: 20%;
margin: 20px !important;
}

#previous-link {
text-align: left;
}

#next-link {
float: right;
}

.day-clickable {

}

.navlink {
.no-data {
background-color: #D3D3D3;
}

.stressful {
background-color: #E070E3;
}

.not-stressful {
background-color: #ABE575;
}

.navlink {
color: #0E570A;
}

.week{
padding:
text-align: center;
}

.navbar-brand {
font-size: 3em;
}

.navbar {
font-family: 'Varela Round', sans-serif;
background-color: #ABE575;
}

.active {
background-color: #ABE575;
}

.content {
padding: 20px;
}
16 changes: 8 additions & 8 deletions templates/calendar.html
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,11 @@

<!-- Latest compiled and minified JavaScript -->
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.2/js/bootstrap.min.js"></script>

<script src="../static/base.js"></script>

<link rel="stylesheet" href="../static/style.css">
<script src="../static/base.js"></script>
</head>
<body>
<div class="content">
<p>This will have a calendar.</p>
<table class="table week">
<tr>
Expand All @@ -26,19 +25,20 @@
<tr class='day-clickable'>
{% for each in keys %}
{% if a_weeks_data[each] == True %}
<td class='warning day-in-week'></td>
<td class='stressful day-in-week'></td>
{% elif a_weeks_data[each] == False %}
<td class='success day-in-week'></td>
<td class='not-stressful day-in-week'></td>
{% else %}
<td class='info day-in-week'></td>
<td class='no-data day-in-week'></td>
{% endif %}
{% endfor %}
</tr>
<br>
<div class='navlink'>
<a href='/older'>Previous week</a>
<a href='/newer'>Next week</a>
<a id='previous-link' href='/older'>Previous week</a>
<a id='next-link' href='/newer'>Next week</a>
</div>
</table>
</div>
</body>
</html>
9 changes: 6 additions & 3 deletions templates/day.html
Original file line number Diff line number Diff line change
Expand Up @@ -7,24 +7,27 @@
<script src="//code.jquery.com/jquery-migrate-1.2.1.min.js"></script>
<!-- Latest compiled and minified CSS -->
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.2/css/bootstrap.min.css">
<link rel="stylesheet" href="../static/style.css">

<!-- Latest compiled and minified JavaScript -->
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.2/js/bootstrap.min.js"></script>

<script src="../static/base.js"></script>
</head>
<body>
<div class="content">
<p>This will be a day view.</p>
<table class="table">
{% for each in keys %}
{% if each not in days_data %}
<tr><td class='info'>{{ each }}</td>
<tr class='no-data'><td>{{ each }}</td><td></td>
{% elif days_data[each][0] == True %}
<tr><td class='warning'>{{ each }}<div class='bpm'>{{ days_data[each][1]}}</div></td></tr>
<tr class='stressful'><td>{{ each }}</td><td><div class='bpm'>{{ days_data[each][1]}}</div></td></tr>
{% elif days_data[each][0] == False %}
<tr><td class='success'>{{ each }}<div class='bpm'>{{ days_data[each][1]}}</div></td></tr>
<tr class='not-stressful'><td>{{ each }}</td><td><div class='bpm'>{{ days_data[each][1]}}</div></td></tr>
{% endif %}
{% endfor %}
</table>
</div>
</body>
</html>
47 changes: 47 additions & 0 deletions templates/global.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
<!DOCTYPE html>
<html>
<head>
<title>:D</title>
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.2/css/bootstrap.min.css">
<link rel="stylesheet" href="../static/style.css">
</head>
<body>

<nav class="navbar navbar-default">
<div class="container-fluid">
<!-- Brand and toggle get grouped for better mobile display -->
<div class="navbar-header">
<button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#bs-example-navbar-collapse-1">
<span class="sr-only">Toggle navigation</span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
<a class="navbar-brand" href="#">BioRetro</a>
</div>

<!-- Collect the nav links, forms, and other content for toggling -->
<div class="collapse navbar-collapse" id="bs-example-navbar-collapse-1">
<ul class="nav navbar-nav">
<li class="active"><a href="#">about this project<span class="sr-only"></span></a></li>
</ul>
<ul class="nav navbar-nav navbar-right">
<li class="active"><a href="http://github.com/mandagill">Check me out on GitHub</a></li>
</ul>
</div><!-- /.navbar-collapse -->
</div><!-- /.container-fluid -->
</nav>
<br>
<div class="content">
<input type="submit" value="refresh data from Google" id="get-moar-data">
<div class="error-msg" id="data-refresh-response">
</div>
<br>
<input type="submit" value="Show me the latest BioRetro" id="show-bio-retro" href="" target="_blank">
<br>
</div>
<script src="//code.jquery.com/jquery-1.11.2.min.js"></script>
<script src="//code.jquery.com/jquery-migrate-1.2.1.min.js"></script>
<script src="/static/base.js"></script>
</body>
</html>
22 changes: 22 additions & 0 deletions templates/landing.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
<!DOCTYPE html>
<html>
<head>
<title>:D</title>
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.2/css/bootstrap.min.css">
<link rel="stylesheet" href="../static/style.css">
</head>
<body>
<p>LANDING page</p>
<br>
<input type="submit" value="refresh data from Google" id="get-moar-data">
<br>
<div class="error-msg" id="data-refresh-response">
</div>
<br>
<input type="submit" value="Show me the latest BioRetro" id="show-bio-retro" href="" target="_blank">
<br>
<script src="//code.jquery.com/jquery-1.11.2.min.js"></script>
<script src="//code.jquery.com/jquery-migrate-1.2.1.min.js"></script>
<script src="/static/base.js"></script>
</body>
</html>
16 changes: 8 additions & 8 deletions templates/okauth.html
Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,19 @@
<html>
<head>
<title>:D</title>
<link rel="stylesheet" href="../static/style.css">
</head>
<body>
<p>You are OAUTHORIZED</p>
<br>
<input type="submit" value="refresh data from Google" id="get-moar-data">
<br>
<div class="error-msg" id="data-refresh-response">
</div>
<br>
<input type="submit" value="Show me the latest BioRetro" id="show-bio-retro">
<br>
<script src="//code.jquery.com/jquery-1.11.2.min.js"></script>
<script src="//code.jquery.com/jquery-migrate-1.2.1.min.js"></script>
<script src="/static/base.js"></script>
<form action="/landing">
<input type="submit">
</form>
</body>
</html>
</html>


<a href="" target="_blank">

0 comments on commit e3718d7

Please sign in to comment.