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

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

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

  <div class="grid_6 alpha">
    <h1>Stream Editor</h1>
  </div>
  <div class="grid_6 alpha">
    <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 tooltip">
      <p><a class="button blue small" href="/rowers/workout/{{ workout.id }}/otwsetpower">OTW Power</a></p>
      <span class="tooltiptext">Run calculations to get power values for your row.</span>
      
    </div>
  </div>
  <div class="grid_6 alpha">
    <div class="grid_2 prefix_2 alpha">
      <p><a class="button gray small" href="/rowers/workout/{{ workout.id }}/workflow">Workflow View</a></p>
    </div>
    <div class="grid_2 omega">
      <p><a class="button blue small" href="/rowers/workout/{{ workout.id }}/wind">Wind Edit</a></p>
    </div>
  </div>
  <div class="grid_6  alpha">
    <p>
      Edit river Stream between turning points in your row. 
      Use positive (+) values to denote rowing with the stream, 
      negative (-) values to denote rowing against the stream.
    </p>
    
    <form enctype="multipart/form-data" action="{{ formloc }}" method="post">
      {% if form.errors %}
      <p style="color: red;">
        Please correct the error{{ form.errors|pluralize }} below.
      </p>
      {% endif %}
      
      <table>
        {{ form.as_table }}
      </table>
      {% csrf_token %}
  </div>
  <div id="formbutton" class="grid_1 prefix_3 suffix_2">
    <input class="button green" type="submit" value="Update">
  </div>
  </form>
  <img src="/static/img/rivercurrent.jpg" width="400">
  
</div>

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

	<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>

{% endblock %}
