diff --git a/app.py b/app.py index 7ff7720..492b362 100644 --- a/app.py +++ b/app.py @@ -121,8 +121,8 @@ def cameras(): return render_template('cameras_partial.html', template_values=values) -@app.route('/camera//live_preview') -def camera_live_preivew(esn=None): +@app.route('/camera//preview_image') +def camera__preivew_image(esn=None): if 'een' in session: een = session['een'] else: @@ -136,8 +136,25 @@ def camera_live_preivew(esn=None): else: return send_file('static/placeholder.png') +@app.route('/camera//preview') +def camera_live_preivew(esn=None): + if 'een' in session: + een = session['een'] + else: + een = EagleEyev3(config) -@app.route('/camera/') + camera = een.get_camera_by_id(esn) + + values = { + "current_user": een.current_user, + "camera": camera, + "events": camera.events['status'] + } + + return render_template('camera_preview.html', template_values=values) + + +@app.route('/camera//events') def camera_detail(esn=None): if 'een' in session: een = session['een'] @@ -157,7 +174,7 @@ def camera_detail(esn=None): "events": camera.events['status'] } - return render_template('camera_detail_partial.html', template_values=values) + return render_template('camera_events_partial.html', template_values=values) @app.route('/camera//status_plot') def camera_status_plot(esn=None): @@ -200,7 +217,7 @@ def camera_status_plot(esn=None): fig.savefig(buf, format="png") # Embed the result in the html output. data = base64.b64encode(buf.getbuffer()).decode("ascii") - return f"
" + return f"
" diff --git a/requirements.txt b/requirements.txt index 7abd0b0..e5e6449 100644 --- a/requirements.txt +++ b/requirements.txt @@ -14,7 +14,7 @@ Werkzeug==2.3.6 gunicorn==20.1.0 cachelib==0.10.2 Flask-Session==0.5.0 -EagleEyev3>=0.0.4 +EagleEyev3>=0.0.8 tqdm pandas numpy diff --git a/templates/camera_detail_partial.html b/templates/camera_detail_partial.html index 0a51e15..6b1dfb7 100644 --- a/templates/camera_detail_partial.html +++ b/templates/camera_detail_partial.html @@ -1,30 +1,3 @@ - - -
-
-

{{ template_values['camera'].name }}

- -
- -
-

Events

-
    - {% if template_values['events'] %} - {% for event in template_values['events'] %} -
  • - {{ event['data'][0]['newStatus']['connectionStatus'] }} -
    {{ event['endTimestamp'] }} -
    {{ event['startTimestamp'] }} -
  • - {% endfor %} - {% else %} -
  • No events in the last six hours
  • - {% endif %} -
-
- -
-
-
+

Preview Image

+
{{ template_values['camera'].name }}
+ diff --git a/templates/camera_events_partial.html b/templates/camera_events_partial.html new file mode 100644 index 0000000..c29bc79 --- /dev/null +++ b/templates/camera_events_partial.html @@ -0,0 +1,15 @@ +

Events

+
{{ template_values['camera'].name }}
+
    + {% if template_values['events'] %} + {% for event in template_values['events'] %} +
  • + {{ event['data'][0]['newStatus']['connectionStatus'] }} +
    {{ event['endTimestamp'] }} +
    {{ event['startTimestamp'] }} +
  • + {% endfor %} + {% else %} +
  • No events in the last six hours
  • + {% endif %} +
\ No newline at end of file diff --git a/templates/camera_preview.html b/templates/camera_preview.html new file mode 100644 index 0000000..3370a72 --- /dev/null +++ b/templates/camera_preview.html @@ -0,0 +1,3 @@ +

Preview Image

+
{{ template_values['camera'].name }}
+ diff --git a/templates/cameras_partial.html b/templates/cameras_partial.html index 0b3f56d..6f45d47 100644 --- a/templates/cameras_partial.html +++ b/templates/cameras_partial.html @@ -1,41 +1,47 @@ -
-

Online

-
    - {% for camera in template_values['cameras'] %} - {% if camera.is_online() and camera.bridge_id %} -
  • {{ camera.name }}
  • - {% endif %} - {% endfor %} -
    - {% for camera in template_values['cameras'] %} - {% if camera.is_online() and camera.bridge_id == None %} -
  • {{ camera.name }}
  • - {% endif %} - {% endfor %} -
+

Cameras

+
Online
+
    +{% for camera in template_values['cameras'] %} + {% if camera.is_online() and camera.bridge_id %} +
  • {{ camera.name }}
  • + preview + events + graph + {% endif %} +{% endfor %} +
    +{% for camera in template_values['cameras'] %} + {% if camera.is_online() and camera.bridge_id == None %} +
  • {{ camera.name }}
  • + preview + events + graph + {% endif %} +{% endfor %} +
-

Offline

-
    - {% for camera in template_values['cameras'] %} - {% if camera.is_offline() and camera.bridge_id %} -
  • {{ camera.name }}
  • - {% endif %} - {% endfor %} -
    - {% for camera in template_values['cameras'] %} - {% if camera.is_offline() and camera.bridge_id == None %} -
  • {{ camera.name }}
  • - {% endif %} - {% endfor %} -
- -
- -
-
- -
+
Offline
+
    +{% for camera in template_values['cameras'] %} + {% if camera.is_offline() and camera.bridge_id %} +
  • {{ camera.name }}
  • + preview + events + graph + {% endif %} +{% endfor %} +
    +{% for camera in template_values['cameras'] %} + {% if camera.is_offline() and camera.bridge_id == None %} +
  • {{ camera.name }}
  • + preview + events + graph + {% endif %} +{% endfor %} +
+ diff --git a/templates/index.html b/templates/index.html index 94bbf1e..1b7c255 100644 --- a/templates/index.html +++ b/templates/index.html @@ -24,11 +24,22 @@
-
- {% include 'cameras_partial.html' %} +
+
+ {% include 'cameras_partial.html' %} +
+
+

Preview Image

+
- -
+
+
+
+

List of Events

+
+
+

Graph of Status Events

+