we got graphs
This commit is contained in:
parent
0278942e29
commit
048ee9c03b
2
.gitignore
vendored
2
.gitignore
vendored
@ -1,4 +1,4 @@
|
||||
*__pycache__*
|
||||
.venv*
|
||||
.env
|
||||
.env*
|
||||
mongo_data/*
|
||||
|
@ -1,4 +1,4 @@
|
||||
FROM python:3.10 as pool_base_image
|
||||
FROM python:3.10 AS pool_base_image
|
||||
|
||||
WORKDIR /pool_data
|
||||
|
||||
@ -9,4 +9,3 @@ RUN apt-get update -y && apt-get upgrade -y && apt-get install -y libsasl2-dev p
|
||||
RUN pip install --upgrade pip
|
||||
|
||||
RUN pip --default-timeout=1000 install -r requirements.txt
|
||||
|
||||
|
@ -1,4 +1,4 @@
|
||||
FROM pool_base_image as flask
|
||||
FROM pool_base_image AS flask
|
||||
|
||||
COPY requirements.txt .
|
||||
|
||||
|
3
pyproject.toml
Normal file
3
pyproject.toml
Normal file
@ -0,0 +1,3 @@
|
||||
[tool.pyright]
|
||||
venvPath = "."
|
||||
venv = ".venv"
|
@ -6,3 +6,4 @@ click
|
||||
Flask-WTF
|
||||
bootstrap-flask
|
||||
waitress
|
||||
bokeh
|
||||
|
@ -1,9 +1,10 @@
|
||||
from bokeh.models.layouts import HBox
|
||||
from bokeh.plotting import column
|
||||
from charts import PoolCharts
|
||||
from bokeh.io import output_file, show
|
||||
from bokeh.layouts import row
|
||||
|
||||
output_file("data_plot.html")
|
||||
output_file("static/data_plot.html")
|
||||
|
||||
chart = PoolCharts.PoolCharts()
|
||||
|
||||
@ -13,4 +14,4 @@ total_chlorine = chart.line_chart("Pool Total Chlorine", "total_chlorine", 50)
|
||||
|
||||
free_chlorine = chart.line_chart("Pool Free Chlorine", "free_chlorine", 50)
|
||||
|
||||
show(row(ph, total_chlorine, free_chlorine))
|
||||
show(column(ph, total_chlorine, free_chlorine))
|
||||
|
@ -17,7 +17,7 @@ class PoolCharts():
|
||||
data_list = []
|
||||
date_count = {}
|
||||
for record in data:
|
||||
if record[field] != "None":
|
||||
if field in record and record[field] != "None":
|
||||
if record["date"] not in dates:
|
||||
print("new date record")
|
||||
dates.append(record["date"])
|
||||
@ -42,6 +42,8 @@ class PoolCharts():
|
||||
p.line(x=dates, y=data_list)
|
||||
|
||||
p.xgrid.grid_line_color = None
|
||||
if not data_list:
|
||||
p.y_range.start = 0
|
||||
else:
|
||||
p.y_range.start = round(min(data_list) - 1)
|
||||
|
||||
return p
|
||||
|
File diff suppressed because one or more lines are too long
@ -1,3 +1,4 @@
|
||||
from bokeh.core.enums import SpatialUnitsType
|
||||
import mongo.build_db as pool_database
|
||||
import mongo.query_db as pool_database_query
|
||||
|
||||
@ -7,6 +8,11 @@ from flask_bootstrap import Bootstrap5
|
||||
from wtforms import StringField, SubmitField, DateField, IntegerField, PasswordField, DecimalField, RadioField, TextAreaField
|
||||
from wtforms.validators import DataRequired, Length, Optional
|
||||
from waitress import serve
|
||||
from bokeh.models.layouts import HBox
|
||||
from bokeh.plotting import column
|
||||
from charts import PoolCharts
|
||||
from bokeh.io import output_file, show
|
||||
from bokeh.layouts import row
|
||||
|
||||
app = Flask(__name__)
|
||||
app.secret_key = 'testsecret' #this value will change
|
||||
@ -14,6 +20,21 @@ app.secret_key = 'testsecret' #this value will change
|
||||
bootstrap = Bootstrap5(app)
|
||||
|
||||
csrf = CSRFProtect(app)
|
||||
# used to configure the bokeh plot for graphs
|
||||
output_file("/pool_data/src/flask/static/data_plot.html")
|
||||
|
||||
def create_graphs():
|
||||
chart = PoolCharts.PoolCharts()
|
||||
ph = chart.line_chart("Pool PH", "ph", 30)
|
||||
total_chlorine = chart.line_chart("Pool Total Chlorine", "total_chlorine", 30)
|
||||
free_chlorine = chart.line_chart("Pool Free Chlorine", "free_chlorine", 30)
|
||||
alkalinity = chart.line_chart("Alkalinity", "alkalinity", 30)
|
||||
salt = chart.line_chart("Salt", "salt", 30)
|
||||
temp = chart.line_chart("Temperature", "temp", 30)
|
||||
hardness = chart.line_chart("Hardness", "hardness", 30)
|
||||
stabiliser = chart.line_chart("Stabiliser", "stabiliser", 30)
|
||||
show(row(column(ph, total_chlorine, free_chlorine, temp), column(salt, alkalinity, hardness, stabiliser)))
|
||||
|
||||
|
||||
class userForm(FlaskForm):
|
||||
username = StringField("User Name?", validators=[DataRequired()])
|
||||
@ -54,7 +75,7 @@ def index():
|
||||
def updater():
|
||||
if 'logged_in' not in session:
|
||||
return redirect("/")
|
||||
|
||||
create_graphs()
|
||||
query_db = pool_database_query.pool_query()
|
||||
query = query_db.get_top(10, "ph")
|
||||
form = dataForm()
|
||||
@ -117,4 +138,3 @@ def user_detail(id):
|
||||
if __name__ == '__main__':
|
||||
#app.run(host='0.0.0.0')
|
||||
serve(app, host='0.0.0.0', port=5000, url_scheme='https')
|
||||
|
||||
|
61
src/flask/static/data_plot.html
Normal file
61
src/flask/static/data_plot.html
Normal file
File diff suppressed because one or more lines are too long
@ -1,30 +1,26 @@
|
||||
<!DOCTYPE html>
|
||||
<!doctype html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||
<head>
|
||||
<meta charset="utf-8" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1" />
|
||||
|
||||
<title>
|
||||
{% block title %}
|
||||
Let there Be Pool Data
|
||||
{% endblock %}
|
||||
</title>
|
||||
<title>{% block title %} Let there Be Pool Data {% endblock %}</title>
|
||||
|
||||
{{ bootstrap.load_css() }}
|
||||
|
||||
<style>
|
||||
body { background: #e8f1f9; }
|
||||
body {
|
||||
background: #e8f1f9;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
</head>
|
||||
<body>
|
||||
<!-- this is a base template using Bootstrap-Flask
|
||||
https://bootstrap-flask.readthedocs.io/ -->
|
||||
|
||||
{% block content %}
|
||||
{% endblock %}
|
||||
{% block content %} {% endblock %}
|
||||
|
||||
|
||||
<!-- you can delete the next line if you're not using any Bootstrap JS -->
|
||||
{{ bootstrap.load_js() }}
|
||||
</body>
|
||||
<!-- you can delete the next line if you're not using any Bootstrap JS -->
|
||||
{{ bootstrap.load_js() }}
|
||||
</body>
|
||||
</html>
|
||||
|
@ -27,7 +27,7 @@
|
||||
<td>
|
||||
{{ render_form(form) }}
|
||||
</td>
|
||||
<td>
|
||||
<!-- <td>
|
||||
<div class="container">
|
||||
<div class="col-md-10 col-lg-8 mx-lg-auto mx-md-auto">
|
||||
|
||||
@ -45,11 +45,20 @@
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
</td> -->
|
||||
<td>
|
||||
<div class="container">
|
||||
<div class= "col-xs-12 col-sm-12 col-md-12">
|
||||
<iframe style="width: 100vw;height: 80vh;position: relative;" src="static/data_plot.html" frameborder="0" allowfullscreen>
|
||||
</iframe>
|
||||
</div>
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
{% endblock %}
|
||||
|
Loading…
x
Reference in New Issue
Block a user