{% extends "base.html" %}
{% load staticfiles %}
{% load rowerfilters %}

{% block title %}Advanced Features {% endblock %}

{% block content %}
<div id="workouts" class="grid_6 alpha">

    {% if form.errors %}
        <p style="color: red;">
            Please correct the error{{ form.errors|pluralize }} below.
        </p>
    {% endif %}

	<h1>Advanced OTW features</h1>
	{% if user.rower.rowerplan == 'basic' %}
	<p>This is a preview of the page with advanced functionality for Pro users. See <a href="/rowers/about">the About page</a> for more information and to sign up for Pro Membership</a>
	{% endif %}
	<div class="grid_2 alpha">
	<p>
	<a class="button gray small" href="/rowers/workout/{{ workout.id }}/edit">Edit Workout</a>
</p>
	</div>
	<div class="grid_2">
	<p>
	<a class="button gray small" href="/rowers/workout/{{ workout.id }}/advanced">Advanced Edit</a>
</p>
	</div>
	<div class="grid_2 omega">
	<p>
	<a class="button gray small" href="/rowers/workout/{{ workout.id }}/export">Export</a>
</p>

	</div>

	<div class="grid_6  alpha">

	<table width=100%>
	<tr>
	<th>Date:</th><td>{{ workout.date }}</td>
	</tr><tr>
	<th>Time:</th><td>{{ workout.starttime }}</td>
	</tr><tr>
	<th>Distance:</th><td>{{ workout.distance }}m</td>
	</tr><tr>
	<th>Duration:</th><td>{{ workout.duration |durationprint:"%H:%M:%S.%f" }}</td>
	</tr>
	<th>Public link to this workout</th>
	<td>
	<a href="/rowers/workout/{{ workout.id }}">https://rowsandall.com/rowers/workout/{{ workout.id }}</a>
	<td>
	</table>
	</div>


<div class="grid_6 alpha">
	<div class="grid_2 alpha">
	<p>
	{% if user.rower.rowerplan == 'pro' or user.rower.rowerplan == 'coach' %}
	<a class="button blue small" href="/rowers/workout/{{ workout.id }}/wind">Edit Wind Data</a>
	{% else %}
	<a class="button blue small" href="/rowers/about">Edit Wind Data</a>
	{% endif %}

	</p>
	<p>
	Add wind data for OTW workouts
	</p>
	</div>
	<div class="grid_2">
	<p>
	{% if user.rower.rowerplan == 'pro' or user.rower.rowerplan == 'coach' %}
	<a class="button blue small" href="/rowers/workout/{{ workout.id }}/stream">Edit Stream Data</a>
	{% else %}
	<a class="button blue small" href="/rowers/about">Edit Stream Data</a>
	{% endif %}

	</p>
	<p>
	For river dwellers. Add stream  information.
	</p>
	</div>
	<div class="grid_2 omega">
		<p>
	{% if user.rower.rowerplan == 'pro' or user.rower.rowerplan == 'coach' %}
		<a class="button blue small" href="/rowers/workout/{{ workout.id }}/otwsetpower">OTW Power</a>
	{% else %}
		<a class="button blue small" href="/rowers/about">OTW Power</a>
	{% endif %}
		</p>
		<p>
		Run OTW Power calculations (wind & stream correction, equivalent erg pace)
		</p>
	</div>
	


<div class="grid_6 alpha">

	<div class="grid_2 alpha">
		<p>
	{% if user.rower.rowerplan == 'pro' or user.rower.rowerplan == 'coach' %}
		<a class="button blue small" href="/rowers/workout/{{ workout.id }}/interactiveotwplot">Corrected Pace Plot</a>
	{% else %}
	<a class="button blue small" href="/rowers/about">Corrected Pace Plot</a>
	{% endif %}

		</p>
		<p>
		Wind and Stream corrected pace plots will be here.
		</p>
	</div>
	<div class="grid_2 suffix_2 omega">
	<p>
	<a class="button blue small" href="/rowers/workout/{{ workout.id }}/interactiveplot">Big Interactive Plot</a>
	</p>
		<p>
		See (and save) the big interactive plot
		</p>
	</div>
</div>
</div>
</div>

<div id="advancedplots" class="grid_6 omega">
      <div class="grid_6 alpha">

	<script type="text/javascript" src="/static/js/bokeh-0.12.3.min.js"></script>
	<script async="true" type="text/javascript">
    Bokeh.set_log_level("info");
	</script>

	{{ interactiveplot |safe }}

    <script>
    // Set things up to resize the plot on a window resize. You can play with
    // the arguments of resize_width_height() to change the plot's behavior.
    var plot_resize_setup = function () {
        var plotid = Object.keys(Bokeh.index)[0]; // assume we have just one plot
        var plot = Bokeh.index[plotid];
        var plotresizer = function() {
            // arguments: use width, use height, maintain aspect ratio
            plot.resize_width_height(true, true, true);
        };
        window.addEventListener('resize', plotresizer);
        plotresizer();
    };
    window.addEventListener('load', plot_resize_setup);
    </script>
    <style>
    /* Need this to get the page in "desktop mode"; not having an infinite height.*/
    html, body {height: 100%; margin:5px;}
    </style>


<div id="interactiveplot" class="grid_6 omega">
	{{ the_div |safe }}
</div>
</div>

{% endblock %}
